done 本日班组情况

This commit is contained in:
DESKTOP-FUDKNA8\znjsz 2024-01-31 11:16:39 +08:00
parent 62d3566f29
commit da305dbba9
3 changed files with 53 additions and 58 deletions

View File

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

View File

@ -1,11 +1,13 @@
export const options = { export const options = {
color: ['#ffd601', '#72340b'], color: ['#a4c9d1', '#72340b', '#ffd601' ],
grid: { grid: {
top: 10, top: 8,
bottom: 0, bottom: 20,
left: 0, left: 42,
right: 28, right: 28,
containLabel: true, },
legend: {
show: false,
}, },
xAxis: { xAxis: {
max: 100, max: 100,
@ -23,8 +25,6 @@ export const options = {
type: "category", type: "category",
data: ["A组", "B组", "C组"], data: ["A组", "B组", "C组"],
inverse: true, inverse: true,
animationDuration: 300,
animationDurationUpdate: 300,
max: 2, // only the largest 3 bars will be displayed max: 2, // only the largest 3 bars will be displayed
axisLabel: { axisLabel: {
fontSize: 16, fontSize: 16,
@ -38,27 +38,18 @@ export const options = {
}, },
series: [ series: [
{ {
realtimeSort: true,
type: "bar", type: "bar",
// data: [10, 20, 30], data: [34, 2, 23],
data: [],
label: { label: {
show: true, show: true,
position: "right", position: "right",
valueAnimation: true,
formatter: "{c}%", formatter: "{c}%",
color: "#fff", color: "#fff",
fontSize: 16, fontSize: 16,
}, },
}, },
], ],
legend: {
show: false,
},
animationDuration: 0,
animationDurationUpdate: 3000,
animationEasing: "linear",
animationEasingUpdate: "linear",
}; };
export default function setup(echartInstance, dataArr) { export default function setup(echartInstance, dataArr) {

View File

@ -20,7 +20,7 @@ import LineMonth from '../components/datapage/LineMonth.vue';
<!-- 本月生产线情况 --> <!-- 本月生产线情况 -->
<LineMonth /> <LineMonth />
<!-- 本日班组情况 --> <!-- 本日班组情况 -->
<!-- <TeamChartDay /> --> <TeamChartDay />
<!-- 本月班组情况 --> <!-- 本月班组情况 -->
<!-- <TeamChartMonth /> --> <!-- <TeamChartMonth /> -->
</div> </div>