From 898c836c57c22b9439321e96650f8a35b1cea917 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Sun, 13 Apr 2025 08:07:06 +0800
Subject: [PATCH] feat: 添加echartsResize hooks,添加ztzf组件样式
---
src/views/SignMachineNest/MachineLeft/InspectionRaskDetails.vue | 15 +++++----------
1 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/src/views/SignMachineNest/MachineLeft/InspectionRaskDetails.vue b/src/views/SignMachineNest/MachineLeft/InspectionRaskDetails.vue
index 150515b..98cf3b9 100644
--- a/src/views/SignMachineNest/MachineLeft/InspectionRaskDetails.vue
+++ b/src/views/SignMachineNest/MachineLeft/InspectionRaskDetails.vue
@@ -15,13 +15,16 @@
import CommonTitle from '@/components/CommonTitle.vue';
import CommonDateTime from '@/components/CommonDateTime.vue';
import { jobNumBar, eventNumPie } from '@/api/home'
+import useEchartsResize from '@/hooks/useEchartsResize'
// 日期
const currenDate = dayjs().format('YYYY-MM-DD');
const newTime = ref([currenDate, currenDate]);
// 统计图
const chartRef = ref(null);
+let { chart } = useEchartsResize(chartRef)
const pieRef = ref(null);
+let { chart: pieChart } = useEchartsResize(pieRef)
const option = {
@@ -160,8 +163,6 @@
}
]
};
-let chart = null;
-let pieChart = null;
// TODAY,CURRENT_WEEK,CURRENT_MONTH,CURRENT_YEAR
const getData = (value,date_enum) => {
@@ -177,7 +178,7 @@
option.xAxis.data = res.data?.data.map(item => item.name);
option.series[0].data = res.data?.data.map(item => item.data[0].value);
option.series[1].data = res.data?.data.map(item => item.data[1].value);
- chart.setOption(option);
+ chart.value.setOption(option);
})
// 获取饼状图
eventNumPie(params).then(res => {
@@ -191,16 +192,10 @@
};
});
pieOption.series[0].data = updatedPieData;
- pieChart.setOption(pieOption);
+ pieChart.value.setOption(pieOption);
})
};
onMounted(() => {
- chart= echarts.init(chartRef.value);
- pieChart = echarts.init(pieRef.value);
- window.addEventListener('resize', () => {
- chart?.resize();
- pieChart?.resize();
- });
getData(newTime.value, 'TODAY');
});
</script>
--
Gitblit v1.9.3