From 67ddfbd2db13529c8923838d4dc7ed4cf105b0fe Mon Sep 17 00:00:00 2001
From: 马宇豪 <978517621@qq.com>
Date: 星期五, 20 十月 2023 15:41:51 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 src/views/monitorData/gasData/index.vue |   58 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 45 insertions(+), 13 deletions(-)

diff --git a/src/views/monitorData/gasData/index.vue b/src/views/monitorData/gasData/index.vue
index 552db39..3bc9b1d 100644
--- a/src/views/monitorData/gasData/index.vue
+++ b/src/views/monitorData/gasData/index.vue
@@ -39,7 +39,7 @@
                 </el-form>
             </div>
             <div id="gasChart" style="height: 500px;width: auto"></div>
-            <el-table :data="state.tableData.data" style="width: 100%;margin-top: 20px">
+            <el-table :data="state.tableData.data" style="width: 100%;margin-top: 20px" v-loading="loading">
                 <el-table-column type="index" label="序号" width="80" />
                 <el-table-column align="center" prop="time" label="采集时间"/>
                 <el-table-column align="center" prop="windSpeed" label="风速"/>
@@ -112,6 +112,7 @@
         }
     }
 }
+const loading = ref(false);
 const dataZoomEnd = ref();
 const xData = ref([]);
 const yData = ref([]);
@@ -140,14 +141,20 @@
     }
     let resChart = await gasDataApi().getGasLineChart(chartParam);
     if(resChart.data.code == 100) {
-        xData.value = resChart.data.data.map((item: any) => {
-            return item.time;
-        })
-        yData.value = resChart.data.data.map((item: any) => {
-            return item.gasValue;
-        })
-        dataZoomEnd.value = xData.value.length > 25 ? 30 : 100;
-        markLines.value = 110;
+        if (resChart.data.data) {
+            xData.value = resChart.data.data.map((item: any) => {
+                return item.time;
+            })
+            yData.value = resChart.data.data.map((item: any) => {
+                return item.gasValue;
+            })
+            dataZoomEnd.value = xData.value.length > 25 ? 30 : 100;
+        }else {
+            xData.value = [];
+            yData.value = [];
+            markLines.value = 0;
+            dataZoomEnd.value = 100;
+        }
         initCharts();
     }else {
         ElMessage({
@@ -156,6 +163,7 @@
         });
     }
 
+    loading.value = true;
     //表格
     const pageParam = {
         pageIndex: state.tableData.listQuery.pageIndex,
@@ -172,6 +180,7 @@
         state.tableData.total = res.data.total;
         state.tableData.listQuery.pageIndex = res.data.pageIndex;
         state.tableData.listQuery.pageSize = res.data.pageSize;
+        loading.value = false;
     }else {
         ElMessage({
             type: 'warning',
@@ -184,7 +193,10 @@
     let res = await gasManageApi().getGas({});
     if(res.data.code == 100) {
         state.tableData.gasList = res.data.data;
+        console.log("气体",state.tableData.gasList)
+        //默认选择第一个气体
         state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id;
+        markLines.value = state.tableData.gasList[0].threshold;
         initInfoData();
     }else {
         ElMessage({
@@ -204,12 +216,18 @@
     initInfoData();
 };
 const search = () => {
+    state.tableData.listQuery.pageIndex = 1;
+    const gasObj = state.tableData.gasList.filter(item => {
+        return item.id == state.tableData.listQuery.searchParams.gas
+    });
+    markLines.value = gasObj[0].threshold;
+
     initInfoData();
-    console.log("vla",state.tableData.listQuery.searchParams)
 }
 const reset = () => {
     getNowTime();
     state.tableData.listQuery.searchParams.gas = state.tableData.gasList[0].id;
+    markLines.value = state.tableData.gasList[0].threshold;
     state.tableData.listQuery.pageIndex = 1;
     initInfoData();
 }
@@ -238,6 +256,20 @@
             max: Math.max(markLines.value,...yData.value),
             min: Math.min(markLines.value,...yData.value)
         },
+        graphic: {
+            type: 'text',     // 类型:文本
+            left: 'center',
+            top: 'middle',
+            silent: true,     // 不响应事件
+            invisible: yData.value.length > 0,   // 有数据就隐藏
+            style: {
+                fill: '#9d9d9d',
+                fontWeight: 'bold',
+                text: '暂无数据',
+                fontFamily: 'Microsoft YaHei',
+                fontSize: '25px'
+            }
+        },
         series: [
             {
                 data: yData.value,
@@ -249,10 +281,10 @@
                             position: 'end', // 表现内容展示的位置
                             color: 'red'  // 展示内容颜色
                         },
-                        yAxis: markLines.value,
+                        yAxis: markLines.value == 0 ? '':markLines.value ,
                         lineStyle: {
                             color: "red",
-                            width: 1, // 0 的时候可以隐藏线
+                            width: markLines.value == 0 ? 0: 1, // 0 的时候可以隐藏线
                             type: "solid" // 实线,不写默认虚线
                         }
                     },],//type: 'average', 平均值,  min最小值,  max 最大值,  median中位数
@@ -278,7 +310,7 @@
     // 使用刚指定的配置项和数据显示图表。
     myChart.value.setOption(option,true);
     //自适应宽度
-    window.addEventListener('resize', function () {
+    window.addEventListener('resize',function () {
         myChart.value.resize();
     })
 }

--
Gitblit v1.9.2