From 2800fa4f32f3900509cb4d6eefaf2bfaf54efdd7 Mon Sep 17 00:00:00 2001
From: 罗广辉 <guanghui.luo@foxmail.com>
Date: Mon, 21 Apr 2025 18:29:09 +0800
Subject: [PATCH] fix: 天气显示

---
 src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue |   57 +++++++++++++++++++++++----------------------------------
 1 files changed, 23 insertions(+), 34 deletions(-)

diff --git a/src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue b/src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue
index 469035f..78115f9 100644
--- a/src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue
+++ b/src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue
@@ -1,7 +1,6 @@
 <!-- 巡检任务详情 -->
 <template>
-	<common-title title="巡检任务情况" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun">
-	</common-title>
+	<common-title title="巡检任务情况" :style="{ marginLeft: pxToRem(14) }" @details="detailsFun"></common-title>
 	<div class="inspection-rask-details">
 		<div class="inspection-num">
 			<div class="total">
@@ -9,7 +8,7 @@
 				<div class="name">总任务数</div>
 			</div>
 			<div class="status">
-				<div class="item" v-for="(item, index) in list">
+				<div class="item" v-for="(item, index) in list" :key="index">
 					<div>
 						<div :style="{ color: item.color }" class="value">
 							{{ jobStatistics[item.field] }}
@@ -34,14 +33,15 @@
 import { getJobNumBar, getJobStatistics, getTotalJobNum } from '@/api/home'
 import dayjs from 'dayjs'
 import InspectionRaskDetailsDialog from '@/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetailsDialog.vue'
+import useEchartsResize from '@/hooks/useEchartsResize'
 const currenDate = dayjs().format('YYYY-MM-DD')
 const newTime = ref([currenDate, currenDate])
 const list = ref([
-	{ name: '计划执行', value: 89, color: '#FFFFFF', field: 'planned_executions' },
-	{ name: '执行中', value: 100, color: '#FFA768', field: 'running_num' },
-	{ name: '待执行', value: 66, color: '#FFE17E', field: 'pending_executions' },
-	{ name: '已执行', value: 10, color: '#8EFFAC', field: 'executed' },
-	{ name: '执行失败', value: 10, color: '#FF8E8E', field: 'failed_executions' },
+	{ name: '计划执行', value: 0, color: '#FFFFFF', field: 'planned_executions' },
+	{ name: '执行中', value: 0, color: '#FFA768', field: 'running_num' },
+	{ name: '待执行', value: 0, color: '#FFE17E', field: 'pending_executions' },
+	{ name: '已执行', value: 0, color: '#8EFFAC', field: 'executed' },
+	{ name: '执行失败', value: 0, color: '#FF8E8E', field: 'failed_executions' },
 ])
 const option = {
 	grid: {
@@ -107,14 +107,14 @@
 		},
 	},
 }
+
 // 是否展示巡检任务详情
 const isShowDetailsDialog = ref(false)
-const detailsFun = () => {	
+const detailsFun = () => {
 	isShowDetailsDialog.value = true
-	
 }
-
-let chart = null
+const chartRef = ref(null)
+let { chart } = useEchartsResize(chartRef)
 
 // TODAY,CURRENT_WEEK,CURRENT_MONTH,CURRENT_YEAR
 const getData = (value, date_enum) => {
@@ -129,11 +129,10 @@
 	getJobNumBar(params).then(res => {
 		option.xAxis.data = res.data?.data.map(item => item.name)
 		option.series.data = res.data?.data.map(item => item.value)
-		chart.setOption(option)
+		chart.value.setOption(option)
 	})
 }
 
-const chartRef = ref(null)
 const total = ref(0)
 const jobStatistics = ref({
 	planned_executions: 0,
@@ -144,11 +143,6 @@
 })
 
 onMounted(() => {
-	chart = echarts.init(chartRef.value)
-	// 监听窗口大小变化
-	window.addEventListener('resize', () => {
-		chart?.resize()
-	})
 	getTotalJobNum().then(res => {
 		total.value = res.data?.data || 0
 	})
@@ -162,12 +156,7 @@
 	padding: 16px 16px;
 	width: 390px;
 	height: 414px;
-	background: linear-gradient(
-		270deg,
-		rgba(31, 62, 122, 0) 0%,
-		rgba(31, 62, 122, 0.35) 21%,
-		#1f3e7a 100%
-	);
+	background: linear-gradient(270deg, rgba(31, 62, 122, 0) 0%, rgba(31, 62, 122, 0.35) 21%, #1f3e7a 100%);
 	border-radius: 0px 0px 0px 0px;
 	opacity: 0.85;
 
@@ -201,22 +190,22 @@
 			height: 110px;
 			display: grid;
 			grid-template-columns: repeat(3, 1fr);
-			grid-template-rows: repeat(1	, 30px); // 设置每行高度
+			grid-template-rows: repeat(1, 30px); // 设置每行高度
 			gap: 10px 0; // 调整行间距
 			align-content: center;
-			
+
 			.item {
 				display: flex;
 				align-items: center;
 			}
 			.right-line {
-        width: 0px;
-        height: 36px;
-        border-radius: 0px 0px 0px 0px;
-        border: 1px solid;
-        border-image: linear-gradient(180deg, rgba(27, 148, 255, 0), rgba(27, 148, 255, 1), rgba(27, 148, 255, 0)) 1 1;
-        margin-left: 10px;
-      }
+				width: 0px;
+				height: 36px;
+				border-radius: 0px 0px 0px 0px;
+				border: 1px solid;
+				border-image: linear-gradient(180deg, rgba(27, 148, 255, 0), rgba(27, 148, 255, 1), rgba(27, 148, 255, 0)) 1 1;
+				margin-left: 10px;
+			}
 			.name {
 				width: 56px;
 				text-align: center;

--
Gitblit v1.9.3