From 1e18f0bcee0358e13c0e2cb750d17cd7ef5bf4d6 Mon Sep 17 00:00:00 2001
From: zmc <zmc_li@foxmail.com>
Date: 星期一, 07 八月 2023 17:55:21 +0800
Subject: [PATCH] 油烟检测系统

---
 src/views/analysis/graph/AllRate.vue |   43 +++++++++++++++++++++++++++++--------------
 1 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/src/views/analysis/graph/AllRate.vue b/src/views/analysis/graph/AllRate.vue
index 7992bda..b1139a3 100644
--- a/src/views/analysis/graph/AllRate.vue
+++ b/src/views/analysis/graph/AllRate.vue
@@ -45,9 +45,11 @@
      </el-form-item> 
      </el-form>
 
-    <el-card>
-      <div class="chart-container" ref="chart"></div>
+    <el-card v-loading="loading">
+      <div class="chart-container" ref="lineChart" v-show="!isNoData"></div>
+      <el-empty v-show="isNoData" :image-size="200" />
     </el-card>
+
   </el-main>
 </el-container>
   </div>
@@ -56,10 +58,13 @@
 <script>
 import * as echarts from 'echarts'
 
-import axiosInstance from '../../../utils/request.js'
+import axiosInstanceInstance from '../../../utils/request.js'
 export default {
   data() {
     return {
+      isNoData:false,
+      chart:null,
+      loading:false,
       chartData: [],     //淇濆瓨鏌ヨ鐨勭粨鏋�
       //devId:'',          //璁惧缂栧彿
       begin:'2023-05-01',         //寮�濮嬫椂闂�
@@ -192,6 +197,7 @@
   mounted(){
     //  榛樿鍔犺浇浠樺皬濮愬湪鎴愰兘 5鏈�1鍙峰埌15鍙风殑
       this.fetchData()
+      window.addEventListener('resize',this.updateChart)
     },
   methods: {
     
@@ -215,10 +221,18 @@
       if(this.end){
         params['end'] = this.end
       }
-
-      axiosInstance.get('/data/id',{params:params})
+      this.loading = true
+      axiosInstanceInstance.get('/data/id',{params:params})
         .then(response => {
           this.chartData = response.data.data
+          this.loading = false
+        if(response.data.data.length==0){
+          alert('璇ユ椂娈垫棤鏁版嵁')
+          this.isNoData = true
+          return
+        }
+        // 绉婚櫎绌烘暟鎹姸鎬�
+        this.isNoData = false
           this.drawChart()
         })
     },
@@ -271,8 +285,8 @@
         keyExceeding.push(item.keyExceedingRate.slice(0,-1))
       })
 
-      let chart = echarts.init(this.$refs.chart)
-      chart.setOption({
+      this.chart = echarts.init(this.$refs.lineChart)
+      this.chart.setOption({
         title: {
           text: '姣旂巼',
           //left: 'center'
@@ -394,12 +408,12 @@
           type: 'line',
           data: keyExceeding
         },
-
-       
-        
       ]
 
       })
+    },
+    updateChart(){
+      this.chart.resize()
     }
   }
 }
@@ -407,12 +421,13 @@
 
 <style scoped>
   .el-card {
-    margin-top: 40px;
+    margin-top: 50px;
+    width:90%;
+    border-radius: 9px;
   }
 .chart-container {
-    width: 100%;
-    height: 600px;
-
+    width:100%;
+    height: 540px;
   }
   .el-header {
     background-color: #010408;

--
Gitblit v1.9.3