This commit is contained in:
DESKTOP-FUDKNA8\znjsz 2024-01-22 16:29:09 +08:00
parent ef3c7a422a
commit e7a0d10423
9 changed files with 63 additions and 49 deletions

View File

@ -43,18 +43,21 @@ watch(() => settings.carouselTime, val => {
}) })
const pathMap = { const pathMap = {
'/1-1': 1, // 线
'/1-2': 2, '/3-1': 1,
'/1-3': 3, '/3-2': 2,
'/1-4': 4, '/3-3': 11, // 3,
'/3-4': 12,
// 线
'/2-1': 5, '/2-1': 5,
'/2-2': 6, '/2-2': 6,
'/2-3': 7, '/2-3': 7,
'/2-4': 8, '/2-4': 4,
'/3-1': 9, // 线
'/3-2': 10, '/1-1': 9,
'/3-3': 11, '/1-2': 10,
'/3-4': 12 '/1-3': 3,
'/1-4': 8
} }
</script> </script>

View File

@ -9,19 +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("=======>", state.data2.lineHourList?.length); // 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;
} }
console.log("lineHourList ===> ", state.data2.lineHourList); // console.log("[HourChart] ===> : ", state.data2.lineHourList);
hourData.value = (state.data2?.lineHourList ?? []).map((item, index) => ({ 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),
@ -33,6 +46,7 @@ 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),
@ -64,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>
@ -80,8 +90,7 @@ onMounted(() => {
height: 300px; height: 300px;
} }
.chart-inner { .chart-inner {}
}
.chart-chart { .chart-chart {
height: 100%; height: 100%;

View File

@ -1,9 +1,9 @@
export const options = { export const options = {
grid: { grid: {
top: "10", top: 10,
bottom: "10", bottom: 0,
left: "10", left: 12,
right: "10", right: 10,
containLabel: true, containLabel: true,
}, },
xAxis: { xAxis: {
@ -43,8 +43,10 @@ export const options = {
}, },
series: [ series: [
{ {
data: Array.from({ length: 7 }, () => Math.random() * 100), data: [],
// data: Array.from({ length: 7 }, () => Math.random() * 100),
type: "bar", type: "bar",
// barWidth: 20,
showBackground: true, showBackground: true,
backgroundStyle: { backgroundStyle: {
color: "rgba(180, 180, 180, 0.2)", color: "rgba(180, 180, 180, 0.2)",

View File

@ -9,20 +9,23 @@ const store = useWsStore();
const chartChart = ref(null); const chartChart = ref(null);
const chart = ref(null); const chart = ref(null);
const dayData = ref([]); const dayData = ref([10,12,13]);
store.$subscribe((mutation, state) => { store.$subscribe((mutation, state) => {
console.log("[ChartDay] ===> state: ", state.data2.classTodayProductYield);
if ( if (
state.data2.classTodayProductYield == undefined || state.data2.classTodayProductYield == undefined ||
state.data2.classTodayProductYield?.length == 0 state.data2.classTodayProductYield?.length == 0
) { ) {
console.log("[ChartDay] ===> 清除状态");
dayData.value.splice(0); dayData.value.splice(0);
if (chart.value) chart.value.dispose(); if (chart.value) chart.value.dispose();
return; return;
} }
console.log( classTodayProductYield = [
"classTodayProductYield ===> ", {yieldName: 'A', yield: 10},
state.data2.classTodayProductYield {yieldName: 'C', yield: 20},
); {yieldName: 'B', yield: 20},
]
for (let i = 0; i < state.data2.classTodayProductYield.length; ++i) { for (let i = 0; i < state.data2.classTodayProductYield.length; ++i) {
if (state.data2.classTodayProductYield[i].teamName == "A组") { if (state.data2.classTodayProductYield[i].teamName == "A组") {
dayData.value[0] = parseInt(state.data2.classTodayProductYield[i].yield); dayData.value[0] = parseInt(state.data2.classTodayProductYield[i].yield);
@ -32,6 +35,7 @@ store.$subscribe((mutation, state) => {
dayData.value[2] = parseInt(state.data2.classTodayProductYield[i].yield); dayData.value[2] = parseInt(state.data2.classTodayProductYield[i].yield);
} }
} }
console.log("[ChartDay] ===> dayData: ", dayData.value);
setupChart(); setupChart();
}); });
@ -50,11 +54,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: (dayData && dayData.length > 0) ? 1 : 0}"></div>
ref="chartChart"
class="chart-chart"
style="{opacity: (dayData && dayData.length > 0) ? 1 : 0}"
></div>
<p v-show="!dayData || dayData.length === 0" class="empty-data-hint"> <p v-show="!dayData || dayData.length === 0" class="empty-data-hint">
暂无数据 暂无数据
</p> </p>
@ -66,8 +66,7 @@ onMounted(() => {
height: 300px; height: 300px;
} }
.chart-inner { .chart-inner {}
}
.chart-chart { .chart-chart {
height: 100%; height: 100%;

View File

@ -1,9 +1,9 @@
export const options = { export const options = {
grid: { grid: {
top: "10", top: 10,
bottom: "10", bottom: 0,
left: "10", left: 12,
right: "10", right: 10,
containLabel: true, containLabel: true,
}, },
xAxis: { xAxis: {
@ -56,6 +56,7 @@ export const options = {
}; };
export default function setup(echartInstance, dataArr) { export default function setup(echartInstance, dataArr) {
debugger;
const new_options = { ...options }; const new_options = { ...options };
new_options.series[0].data = dataArr; new_options.series[0].data = dataArr;
echartInstance.setOption(new_options); echartInstance.setOption(new_options);

View File

@ -30,9 +30,9 @@ alarmList.value = (store.data1.alarmArrList ?? [
// })); // }));
// }); // });
function handleIgnore() { // function handleIgnore() {
alarmList.value.splice(0) // alarmList.value.splice(0)
} // }
</script> </script>
<template> <template>

View File

@ -10,7 +10,7 @@ import TeamChartMonth from "../components/TeamChartMonth.vue";
<div class="data-list"> <div class="data-list">
<HourChart /> <HourChart />
<TeamChartDay /> <TeamChartDay />
<TeamChartMonth /> <!-- <TeamChartMonth /> -->
</div> </div>
</div> </div>
</template> </template>

View File

@ -9,13 +9,13 @@ export const useWsStore = defineStore("wsData", () => {
function updateData(category, data) { function updateData(category, data) {
switch (category) { switch (category) {
case "1": case "1":
data1.value = data; data1.value = { ...data1.value, ...data };
break; break;
case "2": case "2":
data2.value = data; data2.value = { ...data2.value, ...data };
break; break;
case "3": case "3":
data3.value = data; data3.value = { ...data3.value, ...data };
default: default:
break; break;
} }

View File

@ -10,7 +10,7 @@ export const useSettings = defineStore("settings", () => {
carousel: false, carousel: false,
carouselTime: 10000, // s carouselTime: 10000, // s
fullscreen: false, fullscreen: false,
eqStatus: false, eqStatus: true,
}); });
function changeScale(width, height) { function changeScale(width, height) {