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/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue | 45 +++++++++++++++++----------------------------
1 files changed, 17 insertions(+), 28 deletions(-)
diff --git a/src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue b/src/views/Home/HomeLeft/InspectionRaskDetails/InspectionRaskDetails.vue
index 469035f..9831c09 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">
@@ -34,6 +33,7 @@
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([
@@ -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