Compare commits

..

No commits in common. "53ead4788283fa4178150cf543d2e34e77b20011" and "2276c1f9dd33576c3805bb125991b7d8b5938947" have entirely different histories.

9 changed files with 244 additions and 301 deletions

View File

@ -8,49 +8,47 @@ import setupFn from "./TeamChartDayOptions";
const store = useWsStore(); const store = useWsStore();
const chartChart = ref(null); const chartChart = ref(null);
const chart = ref(null); const chart = ref(null);
const showChartDom = ref(false);
/** 无状态,处理数据 */ const dayData = ref([]);
function loadData(yieldArray) { store.$subscribe((mutation, state) => {
const result = []; console.log("[ChartDay] ===> state: ", state.data2.classTodayProductYield);
if (yieldArray == undefined || yieldArray?.length == 0) return null; if (
for (let i = 0; i < yieldArray.length; ++i) { state.data2.classTodayProductYield == undefined ||
if (yieldArray[i].teamName == "A组") { state.data2.classTodayProductYield?.length == 0
result[0] = parseInt(yieldArray[i].yield); ) {
} else if (yieldArray[i].teamName == "B组") { console.log("[ChartDay] ===> 清除状态");
result[1] = parseInt(yieldArray[i].yield); dayData.value.splice(0);
} else if (yieldArray[i].teamName == "C组") {
result[2] = parseInt(yieldArray[i].yield);
}
}
return result;
}
function setupChart(chart, dom, data) {
if (chart.value) chart.value.dispose();
nextTick(() => {
chart.value = echarts.init(dom);
setupFn(chart.value, data);
});
}
/** 有状态,处理数据 */
function __apply(yieldArray) {
const d = loadData(yieldArray);
if (!d) {
showChartDom.value = false;
if (chart.value) chart.value.dispose(); if (chart.value) chart.value.dispose();
return; return;
} }
showChartDom.value = true;
setupChart(chart, chartChart.value, d);
}
// for (let i = 0; i < state.data2.classTodayProductYield.length; ++i) {
store.$subscribe((mutation, state) => { if (state.data2.classTodayProductYield[i].teamName == "A组") {
__apply(state.data2.classTodayProductYield); dayData.value[0] = parseInt(state.data2.classTodayProductYield[i].yield);
} else if (state.data2.classTodayProductYield[i].teamName == "B组") {
dayData.value[1] = parseInt(state.data2.classTodayProductYield[i].yield);
} else if (state.data2.classTodayProductYield[i].teamName == "C组") {
dayData.value[2] = parseInt(state.data2.classTodayProductYield[i].yield);
}
}
console.log("[ChartDay] ===> dayData: ", dayData.value);
setupChart();
}); });
// onMounted(() => {
// nextTick(() => {
// setupChart();
// })
// })
function setupChart() {
if (chart.value) chart.value.dispose();
nextTick(() => {
chart.value = echarts.init(chartChart.value);
setupFn(chart.value, dayData.value);
});
}
onMounted(() => { onMounted(() => {
chartChart.value.classList.add("h-full"); chartChart.value.classList.add("h-full");
}); });
@ -58,12 +56,10 @@ onMounted(() => {
<template> <template>
<Container class="chart" title="本日班组情况" icon="cube"> <Container class="chart" title="本日班组情况" icon="cube">
<div <div ref="chartChart" class="chart-chart" style="{opacity: (dayData && dayData.length > 0) ? 1 : 0}"></div>
ref="chartChart" <p v-show="!dayData || dayData.length === 0" class="empty-data-hint">
class="chart-chart" 暂无数据
:style="{ opacity: showChartDom ? 1 : 0 }" </p>
></div>
<p v-show="!chart" class="empty-data-hint">暂无数据</p>
</Container> </Container>
</template> </template>

View File

@ -1,9 +1,9 @@
export const options = { export const options = {
color: ['#a4c9d1', '#72340b', '#ffd601' ], color: ['#ffd601', '#72340b', '#a4c9d1'],
grid: { grid: {
top: 8, top: 10,
bottom: 20, bottom: 0,
left: 42, left: 0,
right: 28, right: 28,
}, },
legend: { legend: {
@ -39,7 +39,7 @@ export const options = {
series: [ series: [
{ {
type: "bar", type: "bar",
data: [34, 2, 23], data: [],
label: { label: {
show: true, show: true,
position: "right", position: "right",

View File

@ -5,75 +5,58 @@ import Container from "./Base/Container.vue";
import { useWsStore } from "../store"; import { useWsStore } from "../store";
import setupFn from "./TeamChartMonthOptions"; import setupFn from "./TeamChartMonthOptions";
const show = ref(false);
const chartContainer = ref(null);
const chartInstance = ref(null);
const store = useWsStore(); const store = useWsStore();
const chartChart = ref(null);
const chart = ref(null);
const monthData = ref(null);
store.$subscribe((mutation, state) => {
console.log("[ChartMonth] ===> state: ", state.data2.monthlyTarget);
if (
state.data2.monthlyTarget == undefined ||
state.data2.monthlyTarget?.length == 0
) {
console.log("[ChartMonth] ===> 清除状态");
monthData.value = null;
if (chart.value) chart.value.dispose();
return;
}
if (!state.data2.monthlyTarget[0]) return;
const { targetProduction, nowProduction, targetYield, nowYield } =
state.data2.monthlyTarget[0];
monthData.value = { targetProduction, nowProduction, targetYield, nowYield };
setupChart();
});
// 绿24FF5E // 绿24FF5E
// FFB524 // FFB524
// FF3737 // FF3737
onMounted(() => {
chartContainer.value.classList.add("h-full");
const d = loadData(store.data2.monthlyTarget);
if (!d) {
show.value = false;
if (chartInstance.value) {
chartInstance.value.dispose();
chartInstance.value = null;
}
} else {
if (!chartInstance.value)
chartInstance.value = echarts.init(chartContainer.value);
setupFn(chartInstance.value, d);
show.value = true;
}
});
//
store.$subscribe((mutation, state) => {
const d = loadData(state.data2.monthlyTarget);
if (!d) {
show.value = false;
if (chartInstance.value) {
chartInstance.value.dispose();
chartInstance.value = null;
}
} else {
if (!chartInstance.value)
chartInstance.value = echarts.init(chartContainer.value);
setupFn(chartInstance.value, d);
show.value = true;
}
});
// utils function setupChart() {
function loadData(monthlyTarget) { if (chart.value) chart.value.dispose();
if ( nextTick(() => {
monthlyTarget == undefined || console.log("[ChartMonth] ===> 初始化表格: ", monthData.value);
monthlyTarget?.length == 0 || chart.value = echarts.init(chartChart.value);
!monthlyTarget[0] setupFn(chart.value, monthData.value);
) { });
return null;
}
return {
targetProduction: monthlyTarget[0].targetProduction,
nowProduction: monthlyTarget[0].nowProduction,
targetYield: monthlyTarget[0].targetYield,
nowYield: monthlyTarget[0].nowYield,
};
} }
onMounted(() => {
chartChart.value.classList.add("h-full");
// nextTick(() => {
// setupChart();
// })
});
</script> </script>
<template> <template>
<Container class="chart" title="本月班组情况" icon="cube"> <Container class="chart" title="本月班组情况" icon="cube">
<div <div ref="chartChart" class="chart-chart" style="{opacity: (monthData) ? 1 : 0}"></div>
ref="chartContainer" <p v-show="!monthData" class="empty-data-hint">暂无数据</p>
class="chart-chart"
:style="{ opacity: show ? 1 : 0 }"
></div>
<p v-show="!show" class="empty-data-hint">暂无数据</p>
</Container> </Container>
</template> </template>
@ -82,6 +65,8 @@ function loadData(monthlyTarget) {
height: 300px; height: 300px;
} }
.chart-inner {}
.chart-chart { .chart-chart {
height: 100%; height: 100%;
} }

View File

@ -7,7 +7,7 @@ export const options = {
}, },
title: [ title: [
{ {
text: "当前产量:" + 118 + " 片", text: "当前产量:" + 100 + " 片",
left: "27%", left: "27%",
textAlign: "center", textAlign: "center",
top: "70%", top: "70%",
@ -17,7 +17,7 @@ export const options = {
}, },
}, },
{ {
text: "目标产量:" + 213 + " 片", text: "目标产量:" + 100 + " 片",
left: "27%", left: "27%",
textAlign: "center", textAlign: "center",
top: "85%", top: "85%",
@ -27,7 +27,7 @@ export const options = {
}, },
}, },
{ {
text: "当前成品率:" + 78 + "%", text: "当前成品率:" + 22 + "%",
left: "72%", left: "72%",
textAlign: "center", textAlign: "center",
top: "70%", top: "70%",
@ -37,7 +37,7 @@ export const options = {
}, },
}, },
{ {
text: "目标成品率:" + 90 + "%", text: "目标成品率:" + 22 + "%",
left: "72%", left: "72%",
textAlign: "center", textAlign: "center",
top: "85%", top: "85%",
@ -85,7 +85,7 @@ export const options = {
data: [ data: [
{ {
// value: (nowProduction / targetProduction * 100).toFixed(1), // value: (nowProduction / targetProduction * 100).toFixed(1),
value: 89.78, value: 100,
}, },
], ],
}, },
@ -128,7 +128,7 @@ export const options = {
data: [ data: [
{ {
// value: targetYield, // value: targetYield,
value: 78, value: 100,
name: "Perfect", name: "Perfect",
title: { title: {
show: false, show: false,
@ -140,7 +140,8 @@ export const options = {
}, },
}, },
{ {
value: 90, value: 100,
// value: nowYield,
name: "Good", name: "Good",
title: { title: {
show: false, show: false,
@ -149,7 +150,6 @@ export const options = {
show: false, show: false,
valueAnimation: true, valueAnimation: true,
offsetCenter: ["0%", "10%"], offsetCenter: ["0%", "10%"],
formatter: '99.23%'
}, },
}, },
{ {
@ -174,11 +174,3 @@ export default function setup(echartInstance, data) {
new_options.series[1].detail.formatter = (data.nowYield / data.targetYield * 100).toFixed(2) + '%', new_options.series[1].detail.formatter = (data.nowYield / data.targetYield * 100).toFixed(2) + '%',
echartInstance.setOption(new_options); echartInstance.setOption(new_options);
} }
// {
// "targetProduction": 99,
// "nowProduction": 58,
// "targetYield": 12,
// "nowYield": 9
// }

View File

@ -9,17 +9,32 @@ const store = useWsStore();
const chartChart = ref(null); const chartChart = ref(null);
const chart = ref(null); const chart = ref(null);
// //
const hourData = ref([]); const hourData = ref([
// { lineName: '001', hour: '00:00', num: 10 },
// { lineName: '002', hour: '00:20', num: 20 },
// { lineName: '003', hour: '00:30', num: 30 },
// { lineName: '004', hour: '00:40', num: 14 },
// { lineName: '005', hour: '00:50', num: 50 }
]);
store.$subscribe((mutation, state) => { store.$subscribe((mutation, state) => {
// console.log("[HourChart] =======>", state.data2.lineHourList?.length);
if ( if (
state.data2.lineHourList == undefined || state.data2.lineHourList == undefined ||
state.data2.lineHourList?.length == 0 state.data2.lineHourList?.length == 0
) { ) {
// console.log("[HourChart] ");
hourData.value.splice(0); hourData.value.splice(0);
if (chart.value) chart.value.dispose(); if (chart.value) chart.value.dispose();
return; return;
} }
hourData.value = (state.data2?.lineHourList ?? []).map((item, index) => ({ // console.log("[HourChart] ===> : ", state.data2.lineHourList);
hourData.value = (state.data2?.lineHourList ?? [
// { lineName: '001', hour: '00:00', num: 10 },
// { lineName: '002', hour: '00:20', num: 20 },
// { lineName: '003', hour: '00:30', num: 30 },
// { lineName: '004', hour: '00:40', num: 14 },
// { lineName: '005', hour: '00:50', num: 50 },
]).map((item, index) => ({
id: `${item.lineName}_${index}`, id: `${item.lineName}_${index}`,
hour: item.hour || `${index}`.padStart(2, "0"), hour: item.hour || `${index}`.padStart(2, "0"),
data: item.num || Math.floor(Math.random() * 100), data: item.num || Math.floor(Math.random() * 100),
@ -31,12 +46,29 @@ function setupChart() {
if (chart.value) chart.value.dispose(); if (chart.value) chart.value.dispose();
nextTick(() => { nextTick(() => {
chart.value = echarts.init(chartChart.value); chart.value = echarts.init(chartChart.value);
// console.log("[HourChart] ===> chart: ", chart.value, hourData.value.map((item) => item.hour), hourData.value.map((item) => item.data));
chartSetup( chartSetup(
chart.value, chart.value,
hourData.value.map((item) => item.hour), hourData.value.map((item) => item.hour),
hourData.value.map((item) => item.data) hourData.value.map((item) => item.data)
); );
}); });
// chart.value.setOption({
// xAxis: {
// type: "category",
// data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
// },
// yAxis: {
// type: "value",
// },
// series: [
// {
// data: [150, 230, 224, 218, 135, 147, 260],
// type: "line",
// },
// ],
// });
} }
onMounted(() => { onMounted(() => {
@ -46,11 +78,7 @@ onMounted(() => {
<template> <template>
<Container class="chart" title="小时数据" icon="cube"> <Container class="chart" title="小时数据" icon="cube">
<div <div ref="chartChart" class="chart-chart" style="{opacity: (hourData && hourData.length > 0) ? 1 : 0}"></div>
ref="chartChart"
class="chart-chart"
style="{opacity: (hourData && hourData.length > 0) ? 1 : 0}"
></div>
<p v-show="!hourData || hourData.length === 0" class="empty-data-hint"> <p v-show="!hourData || hourData.length === 0" class="empty-data-hint">
暂无数据 暂无数据
</p> </p>
@ -60,7 +88,6 @@ onMounted(() => {
<style scoped> <style scoped>
.chart { .chart {
/* height: 300px; */ /* height: 300px; */
height: auto;
} }
.chart-chart { .chart-chart {

View File

@ -6,141 +6,88 @@ import { useWsStore } from "../../store";
import chartSetup from "./LatestWeekYieldOptions"; import chartSetup from "./LatestWeekYieldOptions";
const store = useWsStore(); const store = useWsStore();
const chartContainer = ref(null); const chartChart = ref(null);
const chartInstance = ref(null); const chart = ref(null);
const show = ref(false); //
const hourData = ref([
// { lineName: '001', hour: '00:00', num: 10 },
// { lineName: '002', hour: '00:20', num: 20 },
// { lineName: '003', hour: '00:30', num: 30 },
// { lineName: '004', hour: '00:40', num: 14 },
// { lineName: '005', hour: '00:50', num: 50 }
]);
store.$subscribe((mutation, state) => {
// console.log("[HourChart] =======>", state.data2.lineHourList?.length);
if (
state.data2.lineHourList == undefined ||
state.data2.lineHourList?.length == 0
) {
// console.log("[HourChart] ");
hourData.value.splice(0);
if (chart.value) chart.value.dispose();
return;
}
// console.log("[HourChart] ===> : ", state.data2.lineHourList);
hourData.value = (state.data2?.lineHourList ?? [
// { lineName: '001', hour: '00:00', num: 10 },
// { lineName: '002', hour: '00:20', num: 20 },
// { lineName: '003', hour: '00:30', num: 30 },
// { lineName: '004', hour: '00:40', num: 14 },
// { lineName: '005', hour: '00:50', num: 50 },
]).map((item, index) => ({
id: `${item.lineName}_${index}`,
hour: item.hour || `${index}`.padStart(2, "0"),
data: item.num || Math.floor(Math.random() * 100),
}));
setupChart();
});
function setupChart() {
if (chart.value) chart.value.dispose();
nextTick(() => {
chart.value = echarts.init(chartChart.value);
// console.log("[HourChart] ===> chart: ", chart.value, hourData.value.map((item) => item.hour), hourData.value.map((item) => item.data));
chartSetup(
chart.value,
hourData.value.map((item) => item.hour),
hourData.value.map((item) => item.data)
);
});
// chart.value.setOption({
// xAxis: {
// type: "category",
// data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
// },
// yAxis: {
// type: "value",
// },
// series: [
// {
// data: [150, 230, 224, 218, 135, 147, 260],
// type: "line",
// },
// ],
// });
}
onMounted(() => { onMounted(() => {
chartContainer.value.classList.add("h-full"); chartChart.value.classList.add("h-full");
// const d = loadData(store.data2.lineSevenDayLogList);
const d = loadData([
{
data: [
{ day: "1001", num: 24 },
{ day: "1002", num: 14 },
{ day: "1003", num: 234 },
{ day: "1004", num: 84 },
{ day: "1005", num: 34 },
{ day: "1006", num: 44 },
{ day: "1007", num: 20 },
],
name: "钢一线",
},
{ data: [], name: "钢二线" },
{ data: [], name: "钢三线" },
]);
if (!d) {
show.value = false;
if (chartInstance.value) {
chartInstance.value.dispose();
chartInstance.value = null;
}
} else {
if (!chartInstance.value)
chartInstance.value = echarts.init(chartContainer.value);
chartSetup(chartInstance.value);
show.value = true;
}
}); });
//
store.$subscribe((mutation, state) => {
// const d = loadData(state.data2.lineSevenDayLogList);
const d = loadData([
{
data: [
{ day: "1001", num: 24 },
{ day: "1002", num: 14 },
{ day: "1003", num: 234 },
{ day: "1004", num: 84 },
{ day: "1005", num: 34 },
{ day: "1006", num: 44 },
{ day: "1007", num: 20 },
],
name: "钢一线",
},
{
data: [
{ day: "1001", num: 24 },
{ day: "1002", num: 14 },
{ day: "1003", num: 234 },
{ day: "1004", num: 84 },
{ day: "1005", num: 34 },
{ day: "1006", num: 44 },
{ day: "1007", num: 20 },
],
name: "钢二线",
},
{
data: [
{ day: "1001", num: 24 },
{ day: "1002", num: 14 },
{ day: "1003", num: 234 },
{ day: "1004", num: 84 },
{ day: "1005", num: 34 },
{ day: "1006", num: 44 },
{ day: "1007", num: 20 },
],
name: "钢三线",
},
]);
if (!d) {
show.value = false;
if (chartInstance.value) {
chartInstance.value.dispose();
chartInstance.value = null;
}
} else {
if (!chartInstance.value)
chartInstance.value = echarts.init(chartContainer.value);
chartSetup(chartInstance.value);
show.value = true;
}
});
function loadData(list) {
if (!list || list.length != 3 || list[0].data.length <= 0) return null;
const outerdata = [[], [], [], [], [], [], []];
list.forEach(line => {
})
const dateList = list[0].data.map((item) => item.day.toString()).sort();
console.log("datelist", dateList);
dateList.forEach((date, index) => {
outerdata[index][0] = date;
});
list.forEach((line, index) => {
if (line.data[0] != null) {
for (let x = 0; x < 7; x++) {
for (let y = 0; y < line.data.length; y++) {
if (outerdata[x + 1][0] == line.data[y].day) {
outerdata[x + 1][line + 1] = line.data[y].num;
}
}
}
}
});
return outerdata;
}
</script> </script>
<template> <template>
<Container class="chart" title="近7日产量" icon="cube"> <Container class="chart" title="近7日产量" icon="cube">
<div <div ref="chartChart" class="chart-chart" style="{opacity: (hourData && hourData.length > 0) ? 1 : 0}"></div>
ref="chartContainer" <p v-show="!hourData || hourData.length === 0" class="empty-data-hint">
class="chart-chart" 暂无数据
:style="{ opacity: show ? 1 : 0 }" </p>
></div>
<p v-show="!show" class="empty-data-hint">暂无数据</p>
</Container> </Container>
</template> </template>
<style scoped> <style scoped>
.chart { .chart {
/* height: 300px; */ /* height: 300px; */
height: auto;
} }
.chart-chart { .chart-chart {

View File

@ -1,68 +1,63 @@
const d = new Date();
const m = d.getMonth() + 1;
export const options = { export const options = {
legend: {
textStyle: {
color: "#fff8",
},
},
tooltip: {},
dataset: {
source: [
["date", "钢1线", "钢2线", "钢3线"],
[m + "-" + 1, 0, 0, 0],
[m + "-" + 2, 0, 0, 0],
[m + "-" + 3, 0, 0, 0],
[m + "-" + 4, 0, 0, 0],
[m + "-" + 5, 0, 0, 0],
],
},
grid: { grid: {
top: 56, top: 10,
bottom: 12, bottom: 0,
left: 20, left: 12,
right: 20, right: 10,
containLabel: true, containLabel: true,
}, },
xAxis: { xAxis: {
type: "category", type: "category",
data: [],
axisLabel: { axisLabel: {
fontSize: 16, fontSize: 16,
color: "#fff8", color: '#fff8'
},
axisLine: {
show: true,
lineStyle: {
color: "#e6e6e633",
},
}, },
}, },
yAxis: { yAxis: {
name: "片", type: "value",
nameTextStyle: { axisLine: {
color: "#fff8", show: true,
fontSize: 18, lineStyle: {
color: "#e6e6e633",
}, },
axisLabel: {
fontSize: 18,
color: "#fff8",
}, },
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: "#fff8", color: '#e6e6e633'
}
}, },
axisLabel: {
fontSize: 16,
color: '#fff8'
}, },
minInterval: 1, minInterval: 1,
max: 100,
min: 1
}, },
series: [{ type: "bar" }, { type: "bar" }, { type: "bar" }], series: [
{
data: [],
// data: Array.from({ length: 7 }, () => Math.random() * 100),
type: "bar",
// barWidth: 20,
showBackground: true,
backgroundStyle: {
color: "rgba(180, 180, 180, 0.2)",
},
},
],
}; };
export default function setup( export default function setup(echartInstance, timeArr, dataArr) {
echartInstance,
list = [
["1-12", 1, 2, 3],
["1-13", 4, 5, 6],
["1-14", 14, 15, 16],
["1-15", 9],
["1-16", 4, 5, 6],
["1-17", 1, 1, 1],
]
) {
const new_options = { ...options }; const new_options = { ...options };
new_options.dataset.source = [["date", "钢1线", "钢2线", "钢3线"], ...list]; new_options.xAxis.data = timeArr;
new_options.series[0].data = dataArr;
echartInstance.setOption(new_options); echartInstance.setOption(new_options);
} }

View File

@ -12,9 +12,9 @@ import LineMonth from '../components/datapage/LineMonth.vue';
<template> <template>
<div class="data-page"> <div class="data-page">
<!-- 小时数据 --> <!-- 小时数据 -->
<HourChart /> <!-- <HourChart /> -->
<!-- 近7日产量 --> <!-- 近7日产量 -->
<LatestWeekYield /> <!-- <LatestWeekYield /> -->
<!-- 本日生产线情况 --> <!-- 本日生产线情况 -->
<!-- <LineToday /> --> <!-- <LineToday /> -->
<!-- 本月生产线情况 --> <!-- 本月生产线情况 -->

View File

@ -21,7 +21,7 @@ const props = defineProps({
</div> </div>
<div class="data-list"> <div class="data-list">
<HourChart /> <HourChart />
<TeamChartDay /> <!-- <TeamChartDay /> -->
<TeamChartMonth /> <TeamChartMonth />
</div> </div>
</div> </div>
@ -40,14 +40,15 @@ const props = defineProps({
position: absolute; position: absolute;
top: 0; top: 0;
right: 32px; right: 32px;
gap: 24px;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: space-around;
} }
:fullscreen .data-list { :fullscreen .data-list {
width: 35%; width: 35%;
gap: 12px; gap: 32px;
padding: 32px 0; padding: 32px 0;
justify-content: space-around; justify-content: space-around;
} }