From f4062e41dfbe26ca7664a963357cc0b9bea37b44 Mon Sep 17 00:00:00 2001
From: zmc <zmc_li@foxmail.com>
Date: 星期五, 01 十二月 2023 16:10:44 +0800
Subject: [PATCH] 风险模型页面的折线图写成组件

---
 src/views/risk_assessment/components/CompDataRiskModel.vue |  188 +++++++++++++++++-----------------------------
 1 files changed, 71 insertions(+), 117 deletions(-)

diff --git a/src/views/risk_assessment/components/CompDataRiskModel.vue b/src/views/risk_assessment/components/CompDataRiskModel.vue
index 2141148..5a8cdaf 100644
--- a/src/views/risk_assessment/components/CompDataRiskModel.vue
+++ b/src/views/risk_assessment/components/CompDataRiskModel.vue
@@ -6,7 +6,7 @@
 
 import DustRadarChart from '@/views/risk_assessment/components/DustRadarChart.vue'
 import FYLineChart from '@/components/chart/FYLineChart.vue'
-
+import time from '@/utils/time.js'
 import index from '@/utils/risk_estimate_common_function/index.js'
 import ButtonClick from '@/sfc/ButtonClick.vue'
 import dayjs from 'dayjs'
@@ -15,6 +15,7 @@
 import riskValue from '@/utils/risk_estimate_common_function/riskValue.js'
 import lineChart from '@/utils/chartFunction/lineChart.js'
 import siteInfo from '@/api/site/siteInfo.js'
+import CompDailyStatistic from '@/views/risk_assessment/riskModel/components/CompDailyStatistic.vue'
 export default {
   props: {
     // 鐐逛綅鍚嶅瓧
@@ -39,7 +40,8 @@
     AreaAndmonitorType,
     DustRadarChart,
     ButtonClick,
-    MonthSelect
+    MonthSelect,
+    CompDailyStatistic
   },
   data() {
     return {
@@ -127,27 +129,26 @@
     //   }
     // },
     siteName() {
-      if(this.siteName!= ''){
-    // 鏇存柊绔欑偣鍚嶅瓧鍜屾椂闂�
-      this.form.name = this.siteName
-      this.screenLoading = true
-      siteInfo.queryMnCode(this.siteName).then((response) => {
-        this.form.number = response.data.data[0].mnCode
-        this.month = this.time
-        // 鍚屾椂鏇存柊鏈堣捣濮嬫椂闂�
-        this.form.beginTime = dayjs(this.month).startOf().format('YYYY-MM-DD HH:mm:ss')
-        this.form.endTime = dayjs(this.month).endOf('month').format('YYYY-MM-DD HH:mm:ss')
+      if (this.siteName != '') {
+        // 鏇存柊绔欑偣鍚嶅瓧鍜屾椂闂�
+        this.form.name = this.siteName
+        this.screenLoading = true
+        siteInfo.queryMnCode(this.siteName).then((response) => {
+          this.form.number = response.data.data[0].mnCode
+          this.month = this.time
+          // 鍚屾椂鏇存柊鏈堣捣濮嬫椂闂�
+          this.form.beginTime = dayjs(this.month).startOf().format('YYYY-MM-DD HH:mm:ss')
+          this.form.endTime = dayjs(this.month).endOf('month').format('YYYY-MM-DD HH:mm:ss')
 
-        // 鏇存柊璇ョ珯鐐圭殑鎵�灞炲満鏅拰杩愮淮鍟�
-        this.getSiteInfo(this.form.number)
-        // 鏇存柊缁熻鏁版嵁
-        this.getAnalysisData()
-        // 璁$畻椋庨櫓鍊�
-        this.calRiskValue()
-        this.screenLoading = false
-      })
+          // 鏇存柊璇ョ珯鐐圭殑鎵�灞炲満鏅拰杩愮淮鍟�
+          this.getSiteInfo(this.form.number)
+          // 鏇存柊缁熻鏁版嵁
+          this.getAnalysisData()
+          // 璁$畻椋庨櫓鍊�
+          this.calRiskValue()
+          this.screenLoading = false
+        })
       }
-   
     }
   },
 
@@ -157,12 +158,12 @@
       return riskApi.getRiskAdvice(this.weight)
     }
   },
-mounted(){
-    if(this.showAll){
-        // 鍔犺浇椋庨櫓鍊兼渶楂樼殑绔欑偣鏁版嵁
-        this.ShowDefaultData()
+  mounted() {
+    if (this.showAll) {
+      // 鍔犺浇椋庨櫓鍊兼渶楂樼殑绔欑偣鏁版嵁
+      this.ShowDefaultData()
     }
-},
+  },
   methods: {
     // 鏌ヨ绔欑偣缁熻淇℃伅
     async querySiteStaticsInfo(row) {
@@ -275,6 +276,7 @@
             this.isNoData = true
             return
           }
+          this.chartData.sort(time.compareByScore)
           // 鍒嗘瀽鏁版嵁涓殑鏈�鏃╂椂闂�
           let begin = this.chartData[0].lst
           // 鍒嗘瀽鏁版嵁涓殑鏈�鏅氭椂闂�
@@ -282,12 +284,6 @@
 
           // 绉婚櫎绌烘暟鎹姸鎬�
           this.isNoData = false
-
-          // 鏃犳暟鎹殑鏃堕棿娈�
-          let noDataTimeInteval = lineChart.backNoDataInteval(begin, end)
-          // 鏃犳暟鎹厤缃椂闂存
-          this.areaColor = lineChart.getMarkArea(noDataTimeInteval)
-          this.setChart()
 
           //  鎶樼嚎鍥炬暟鎹�
           let temp = index.calBillData(this.chartData, begin, end)
@@ -317,35 +313,6 @@
           this.bill.exceedingNearCount = obj['exceedingNearCount']
           this.bill.exceedingCriticalDegree = obj['exceedingCriticalDegree']
         })
-    },
-
-    // 閫夋嫨鍏朵粬鍊肩被鍨嬫椂
-    setChart() {
-      if (this.chartData.length) {
-        // 鏋勫缓鎶樼嚎鍥緓,y鏁版嵁
-        let obj = lineChart.getLineChartXYData(
-          this.chartData,
-          this.form.beginTime,
-          this.form.endTime
-        )
-
-        this.chartData1 = {
-          x: obj.xData,
-          y: obj.yAvg
-        }
-        this.chartData2 = {
-          x: obj.xData,
-          y: obj.yOnline
-        }
-        this.chartData3 = {
-          x: obj.xData,
-          y: obj.yValid
-        }
-        this.chartData4 = {
-          x: obj.xData,
-          y: obj.yExceed
-        }
-      }
     },
 
     // 寰楀埌鍓�10椋庨櫓鎺掑悕娓呭崟
@@ -417,7 +384,6 @@
     <el-form-item v-show="showAll">
       <MonthSelect @submit-value="giveMonth"></MonthSelect>
     </el-form-item>
-    
 
     <el-form-item v-show="showAll">
       <ButtonClick
@@ -440,12 +406,18 @@
         <el-tag class="mx-1">鍦烘櫙</el-tag>{{ siteInfo.typename }}
 
         <el-tag class="mx-1">杩愮淮鍟�</el-tag>{{ siteInfo.dutyCompany }}
-        <el-button type="primary" size="default" class="exception-button" v-show="showAll" @click="openDetail">
+        <el-button
+          type="primary"
+          size="default"
+          class="exception-button"
+          v-show="showAll"
+          @click="openDetail"
+        >
           鏁版嵁寮傚父璇︽儏
         </el-button>
       </el-card>
 
-      <el-row :gutter="10" >
+      <el-row :gutter="10">
         <el-col :span="5" v-show="showAll">
           <el-card shadow="never" class="table-class">
             <el-table
@@ -494,7 +466,7 @@
           </el-card>
         </el-col>
 
-        <el-col :span="showAll ?11:14" >
+        <el-col :span="showAll ? 11 : 14">
           <el-card shadow="never" class="table-class">
             <DustRadarChart
               :name="[
@@ -509,28 +481,31 @@
           </el-card>
         </el-col>
 
-        <el-col :span="showAll ?4: 5" >
+        <el-col :span="showAll ? 4 : 5">
           <el-card shadow="never" class="card-height risk-card">
             <template #header>
+              <span class="title-16"> 椋庨櫓鍊�(0~1)锛� </span>
               <span
-              class="title-16"
+                :class="{
+                  'weightColor-low': weight < 0.15,
+                  'weightColor-medium': weight >= 0.15 && weight <= 0.6,
+                  'weightColor-heigh': weight > 0.6
+                }"
               >
-                椋庨櫓鍊�(0~1)锛�
-              </span>
-              <span  :class="{
-                'weightColor-low': weight < 0.15,
-                'weightColor-medium': weight >= 0.15 && weight <= 0.6,
-                'weightColor-heigh': weight > 0.6
-              }"> {{ weight }}</span>
+                {{ weight }}</span
+              >
             </template>
             <div class="risk-text-container">
               <div class="risk-grade">
                 <h1 class="sub-title">椋庨櫓绛夌骇锛�</h1>
-                <span  :class="{
-                  'weightColor-low': weight < 0.15,
-                  'weightColor-medium': weight >= 0.15 && weight <= 0.6,
-                  'weightColor-heigh': weight > 0.6
-                }" >{{ riskGradeAndAdvice.riskGrade }} </span>
+                <span
+                  :class="{
+                    'weightColor-low': weight < 0.15,
+                    'weightColor-medium': weight >= 0.15 && weight <= 0.6,
+                    'weightColor-heigh': weight > 0.6
+                  }"
+                  >{{ riskGradeAndAdvice.riskGrade }}
+                </span>
               </div>
 
               <div class="risk-advice">
@@ -562,7 +537,7 @@
           </el-card>
         </el-col>
 
-        <el-col :span="showAll ?4: 5"  >
+        <el-col :span="showAll ? 4 : 5">
           <el-card shadow="never" class="card-height">
             <template #header>
               <span class="title-16">椋庨櫓璇︽儏</span>
@@ -571,30 +546,35 @@
             <el-form>
               <el-form-item label="鏈�澶у�硷細"> {{ bill.max }} mg/m鲁 </el-form-item>
               <el-form-item label="鏈�灏忓�硷細"> {{ bill.min }} mg/m鲁 </el-form-item>
-              <el-form-item label="鏁版嵁鏈夋晥鐜囷細"> {{ bill.online*100 }}% </el-form-item>
-              <el-form-item label="鏁版嵁鍦ㄧ嚎鐜囷細"> {{ bill.valid*100 }}% </el-form-item>
-              <el-form-item label="鏁版嵁瓒呮爣鐜囷細"> {{ bill.exceeding*100 }}% </el-form-item>
+              <el-form-item label="鏁版嵁鏈夋晥鐜囷細"> {{ bill.online * 100 }}% </el-form-item>
+              <el-form-item label="鏁版嵁鍦ㄧ嚎鐜囷細"> {{ bill.valid * 100 }}% </el-form-item>
+              <el-form-item label="鏁版嵁瓒呮爣鐜囷細"> {{ bill.exceeding * 100 }}% </el-form-item>
               <el-form-item label="寮傚父绫诲瀷鑱氶泦搴︼細">
                 {{ exceptionRisk.exceptionTypeAggregation * 100 }}%
               </el-form-item>
 
-              <el-tag :size="small" v-show="bill.exception">鍏卞嚭鐜颁簡{{ bill.exception }}绫诲紓甯�</el-tag>
-              
+              <el-tag size="small" v-show="bill.exception"
+                >鍏卞嚭鐜颁簡{{ bill.exception }}绫诲紓甯�</el-tag
+              >
+
               <el-form-item label="鍏稿瀷寮傚父澶嶇幇鐜囷細">
                 {{ exceptionRisk.typicalExceptionRepetitionRate * 100 }}%
               </el-form-item>
-              
+
               <div>
-                <el-tag :size="small" v-show="bill.mutationCount">閲忕骇绐佸彉寮傚父:{{ bill.mutationCount }}鏉�</el-tag>
+                <el-tag size="small" v-show="bill.mutationCount"
+                  >閲忕骇绐佸彉寮傚父:{{ bill.mutationCount }}鏉�</el-tag
+                >
               </div>
 
               <div>
-                <el-tag :size="small" v-show="bill.exceedingNearCount">涓磋繎瓒呮爣寮傚父:{{ bill.exceedingNearCount }}鏉�</el-tag>
+                <el-tag size="small" v-show="bill.exceedingNearCount"
+                  >涓磋繎瓒呮爣寮傚父:{{ bill.exceedingNearCount }}鏉�</el-tag
+                >
               </div>
 
               <div>
-                <el-tag :size="small"
-                v-show="bill.exceedingCriticalDegree"
+                <el-tag size="small" v-show="bill.exceedingCriticalDegree"
                   >鍗曟棩瓒呮爣娆℃暟涓寸晫寮傚父:{{ bill.exceedingCriticalDegree }}鏉�</el-tag
                 >
               </div>
@@ -603,33 +583,7 @@
         </el-col>
       </el-row>
 
-      <el-row :gutter="20">
-        <el-col :span="12">
-          <el-card shadow="never" class="card-value">
-            <FYLineChart
-              title="鏃ュ潎鍊�"
-              :chartData="chartData1"
-              yName="mg/m鲁"
-              seriesName="鏃ュ潎鍊�"
-              :areaColor="areaColor"
-            >
-            </FYLineChart>
-          </el-card>
-        </el-col>
-
-        <el-col :span="12">
-          <el-card shadow="never" class="card-value">
-            <FYLineChart
-              title="鏃ユ湁鏁堢巼"
-              :chartData="chartData3"
-              yName="%"
-              seriesName="鏃ユ湁鏁堢巼"
-              :areaColor="areaColor"
-            >
-            </FYLineChart>
-          </el-card>
-        </el-col>
-      </el-row>
+      <CompDailyStatistic :fetch-params="form" />
     </div>
   </div>
   <el-empty description="鏆傛棤鏁版嵁" v-show="isNoData" :image-size="200" />

--
Gitblit v1.9.3