From a7e6761ba0cfccdf33ed552eb2d3b783c8e4ab4a Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 16 Apr 2025 20:49:12 +0800
Subject: [PATCH] feat:事件弹窗显示调整

---
 src/views/TaskManage/TaskTop/TaskTime.vue |   42 ++++++++++++++++++++----------------------
 1 files changed, 20 insertions(+), 22 deletions(-)

diff --git a/src/views/TaskManage/TaskTop/TaskTime.vue b/src/views/TaskManage/TaskTop/TaskTime.vue
index e20c7f7..c9cb869 100644
--- a/src/views/TaskManage/TaskTop/TaskTime.vue
+++ b/src/views/TaskManage/TaskTop/TaskTime.vue
@@ -10,13 +10,18 @@
 import * as echarts from 'echarts';
 import { jobNumBar } from '@/api/home/task';
 import dayjs from 'dayjs';
+import useEchartsResize from '@/hooks/useEchartsResize'
+import { useStore } from 'vuex';
+
+const store = useStore();
 
 // 日期
 const currenDate = dayjs().format('YYYY-MM-DD');
 const newTime = ref([currenDate, currenDate]);
 
 const chartRef = ref(null);
-let chart = null;
+let { chart } = useEchartsResize(chartRef)
+
 
 const option = {
   tooltip: {
@@ -91,35 +96,27 @@
 };
 
 // 获取任务时间统计数据
-const getJobNumBar = (value,date_enum) => {
-  jobNumBar({date_enum}).then(res => {
+const getJobNumBar = (value) => {
+  jobNumBar(value).then(res => {
     if (res.data.code !== 0) return;
     option.xAxis.data = res.data.data.map(item => item.name);
     option.series[0].data = res.data.data.map(item => item.value);
-    chart.setOption(option);
+    chart.value.setOption(option);
   });
 };
 
-onBeforeUnmount(() => {
-  if (chart) {
-    chart.dispose();
-    chart = null;
+// 添加监听
+watch(() => store.state.task.taskSearchParams, (newVal) => {
+  if (newVal) {
+    getJobNumBar(newVal);
+    (newVal);
   }
-  window.removeEventListener('resize', handleResize);
-});
+}, { deep: true });
+
 onMounted(() => {
-  chart = echarts.init(chartRef.value);
-  getJobNumBar(newTime.value, 'CURRENT_YEAR');
-  
-  if (chart && !chart.isDisposed()) {
-    chart.resize();
-  }
+  getJobNumBar({date_enum: 'TODAY'});
 });
 
-onUnmounted(() => {
-  window.removeEventListener('resize', chart?.resize);
-  chart?.dispose();
-});
 </script>
 
 <style lang="scss" scoped>
@@ -129,7 +126,8 @@
   height: 100%;
   margin-left: 14px;
   .title {
-    margin-top: 10px; 
+    font-size: 14px;
+    margin-top: 10px;
     width: 502px;
     height: 28.6px;
     background: url('@/assets/images/task/task-num-total.png') no-repeat center / 100% 100%;
@@ -142,4 +140,4 @@
     height: 200px;
   }
 }
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3