From fd934f83afae1e3fce46db8610837d0e0f4d9393 Mon Sep 17 00:00:00 2001
From: zmc <zmc_li@foxmail.com>
Date: 星期四, 02 十一月 2023 10:44:56 +0800
Subject: [PATCH] 按开发清单已修改

---
 src/views/line_graph/SiteComprehensiveRskRanking.vue |  411 ++++++++++++++++++++++++++++++++--------------------------
 1 files changed, 228 insertions(+), 183 deletions(-)

diff --git a/src/views/line_graph/SiteComprehensiveRskRanking.vue b/src/views/line_graph/SiteComprehensiveRskRanking.vue
index cf6130c..e0c2597 100644
--- a/src/views/line_graph/SiteComprehensiveRskRanking.vue
+++ b/src/views/line_graph/SiteComprehensiveRskRanking.vue
@@ -1,36 +1,44 @@
 <script>
-import TimeSelectWithShortCuts from '@/sfc/TimeSelectWithShortCuts.vue';
-import InputSearch from '@/sfc/InputSearch.vue';
-import AreaAndmonitorType from '@/sfc/AreaAndmonitorType.vue';
-import exceptionApi from '@/api/exceptionApi.js';
-import {useCommonFunction} from '../../utils/common.js';
+import AreaAndmonitorType from '@/sfc/AreaAndmonitorType.vue'
+import exceptionApi from '@/api/exceptionApi.js'
+import { useCommonFunction } from '../../utils/common.js'
 import index from '@/utils/risk_estimate_common_function/index.js'
-import dayjs from 'dayjs';
+import dayjs from 'dayjs'
+import ButtonExportExcel from '@/sfc/ButtonExportExcel.vue'
+import ButtonClick from '@/sfc/ButtonClick.vue'
+import { ElMessage } from 'element-plus'
+import MonthSelect from '@/sfc/MonthSelect.vue';
+import SiteDetail from '@/views/line_graph/components/SiteDetail.vue'
+import { useLoadingStore } from '@/stores/loadingStore';
+import { mapStores } from 'pinia';
 export default {
   components: {
-    TimeSelectWithShortCuts,
     AreaAndmonitorType,
-    InputSearch
+    ButtonExportExcel,
+    ButtonClick,
+    MonthSelect,
+    SiteDetail,
   },
   data() {
     return {
-        // 褰撳墠椤�
-        currentPage: 1,
-      // 姣忛〉鏉℃暟
-      pageSize: 20,
-      total: 0,
       //   琛ㄦ牸鏁版嵁
       tableData: [],
-      isNoData: false,
+      isNoData: true,
       loading: false,
-
+      // 缁熻鍒嗘瀽鎸夐挳鍔犺浇涓�
+      queryButton: false,
+      // 瀵煎嚭鎸夐挳鍔犺浇涓�
+      exportButton: false,
       form: {
         // 绔欑偣鍚嶇О
         name: '',
         // 寮�濮嬫椂闂�
         beginTime: '',
-        // 缁撴潫鏃堕棿
-        endTime: ''
+        // // 缁撴潫鏃堕棿
+        endTime: '',
+
+        // 閫夋嫨鐨勬湀浠�
+        month:''
       },
       bill: {
         min: '',
@@ -43,228 +51,265 @@
         //  鍏稿瀷寮傚父澶嶇幇鐜�
         exceptionRecurrence: '',
         // 寮傚父绫诲瀷鎹仛闆嗗害
-        exceptionTypeAggregation: '',
+        exceptionTypeAggregation: ''
       },
-      // {
-      //   siteName:'',
-      //   region:'',
-      //   monitorType:'',
-      //   riskValue:'',
-      //   riskGrage:'',
-      //   riskAdvice:'',
-      //   beginTime:'',
-      //   endTime:'',
-      // }
-      table:[]
-    };
-  },
-  setup(){
-     // 寮曞叆 鐧惧垎鍙锋瘮杈冨ぇ灏� 瀵煎嚭鍔熻兘
-     const {exportToExcel} = useCommonFunction()
-    return {exportToExcel} 
-  },
 
-  computed: {
-    weight() {
-      return (
-        (100 - this.bill.online) * 0.1 +
-        (100 - this.bill.valid) * 0.2 +
-        this.bill.exceeding * 0.2 +
-        this.bill.exceptionTypeAggregation * 0.2 +
-        this.bill.exceptionRecurrence * 0.3
-      ).toFixed(2);
+      // 琛ㄦ牸鏁版嵁
+      table: [],
+      // 琛ㄦ牸楂樺害
+      tableHeight: 600,
+      currentRow:[]
     }
   },
-  watch:{
-    weight(){
-      this.table[0].riskValue = this.weight
-    }
+  setup() {
+    // 寮曞叆 鐧惧垎鍙锋瘮杈冨ぇ灏� 瀵煎嚭鍔熻兘
+    const { exportToExcel } = useCommonFunction()
+    return { exportToExcel }
+  },
+    computed: {
+    ...mapStores(useLoadingStore),
+  },
+  mounted(){
+    // 
+    this.fetch()
+    this.calTableHeight()
   },
   methods: {
+
     /**
      * 灏嗕腑鍥芥爣鍑嗘椂闂磋浆涓烘寚瀹氭牸寮�
      * @param锛�
      * @returns锛�
      */
-     giveTime(val) {
+     giveMonth(val){
       //灏嗕腑鍥芥爣鍑嗘椂闂磋浆涓烘寚瀹氭牸寮�(璇ョ粍浠惰繑鍥炵殑鏍囧噯鏃堕棿鐨勬牸寮忥紝鎵�浠ュ繀椤荤殑鍔犺繖涓嚱鏁�)
-      this.form.beginTime = dayjs(val[0]).format('YYYY-MM-DD HH:mm:ss');
-      this.form.endTime = dayjs(val[1]).format('YYYY-MM-DD HH:mm:ss');
-    },
-    // 鐐瑰嚮灞曠ず鎸夐挳
-    fetchData() {
+      this.form.month = dayjs(val).format('YYYY-MM-DD');
+      // 鍚屾椂鏇存柊寮�濮嬪拰缁撴潫鏃堕棿 
+      this.form.beginTime = dayjs(this.form.month).startOf().format('YYYY-MM-DD HH:mm:ss')
+      this.form.endTime = dayjs(this.form.month).endOf('month').format('YYYY-MM-DD HH:mm:ss')
+      console.log(this.form.beginTime,this.form.endTime);
 
-      let params = {};
-      if (this.form.name) {
-        params['siteName'] = this.form.name;
-      }
-      if (this.form.beginTime) {
-        params['beginTime'] = this.form.beginTime;
-      }
-      if (this.form.endTime) {
-        params['endTime'] = this.form.endTime;
-      }
-      this.loading = true;
-      exceptionApi
-        .analysisdata(this.form.name, this.form.beginTime, this.form.endTime)
-        .then((response) => {
-          this.chartData = response.data.data;
-          this.loading = false;
-          if (response.data.data.length == 0) {
-            this.isNoData = true;
-            return;
-          }
-          // 绉婚櫎绌烘暟鎹姸鎬�
-          this.isNoData = false;
-          let temp = index.calBillData(this.chartData,this.form.beginTime,this.form.endTime);
-          this.bill.min = temp['min'];
-          this.bill.max = temp['max'];
-
-          this.bill.avg = temp['avg'];
-          this.bill.online = temp['online'];
-          this.bill.valid = temp['valid'];
-          this.bill.exceeding = temp['exceeding'];
-
-          this.begin = this.chartData[0].lst;
-          this.end = this.chartData[this.chartData.length - 1].lst;
-        const tempObj = {}
-        tempObj.region = '閲戝北鍖�' 
-        tempObj.monitorType = '鎵皹' 
-        tempObj.siteName = this.form.name
-        tempObj.beginTime = this.form.beginTime
-        tempObj.endTime = this.form.endTime
-
-        // this.table[0].region = '閲戝北鍖�'  
-        // this.table[0].monitorType = '鎵皹'  
-        // this.table[0].siteName = this.form.name
-        // this.table[0].beginTime = this.form.beginTime
-        // this.table[0].endTime = this.form.endTime
-
-        if(this.weight>=0.6){
-          tempObj.riskGrage = '楂橀闄�'
-          tempObj.riskAdvice = '寤鸿瀵硅绔欑偣杩涜绾夸笅鎵ф硶妫�鏌ワ紝涓撻」鏁版嵁瀵规瘮'
-          // this.table[0].riskGrage = '楂橀闄�'
-          // this.table[0].riskAdvice = '寤鸿瀵硅绔欑偣杩涜绾夸笅鎵ф硶妫�鏌ワ紝涓撻」鏁版嵁瀵规瘮'
-        }else if(this.weight<0.6 && this.weight>=0.2){
-          tempObj.riskGrage = '涓闄�'
-          tempObj.riskAdvice = '寤鸿寮�灞曞父鎬佽拷韪垎鏋�'
-          // this.table[0].riskGrage = '涓闄�'
-          // this.table[0].riskAdvice = '寤鸿寮�灞曞父鎬佽拷韪垎鏋�'
-        }else {
-          tempObj.riskGrage = '浣庨闄�'
-          tempObj.riskAdvice = '寤鸿寮曞浼佷笟闀挎�佷繚鎸�'
-          // this.table[0].riskGrage = '浣庨闄�'
-          // this.table[0].riskAdvice = '寤鸿寮曞浼佷笟闀挎�佷繚鎸�'
+     },
+     
+    // 鍔熻兘锛氭敼鍙樿〃鏍兼煇涓崟鍏冩牸鐨勯鑹�
+    tableCellClassName({ row, columnIndex }) {
+      // 骞冲潎鍊间笉婊¤冻鏍囧噯鏃�
+      if (columnIndex == 4) {
+        if (row.riskValue >= 0.8) {
+          return 'warning-row';
         }
-        this.table.push(tempObj)
-        });
-    },
+      }
 
-    // 浼佷笟寮傚父璇︽儏
-    exceptiondataCount() {
+     
+    },
+    // 鍔熻兘锛氳〃鏍奸珮搴︽牴鎹唴瀹硅嚜閫傚簲
+    calTableHeight() {
+      const h1 = this.$refs.h1.$el.offsetHeight
+      // 鍏朵腑涓�涓�40鏄洅瀛愮殑鎬诲杈硅窛
+      this.tableHeight = `calc(100vh - ${h1}px  - 40px - 40px - var(--el-main-padding) * 2`
+    },
+    // 鐐瑰嚮椋庨櫓鎺掑悕鎸夐挳
+    fetchData() {
+      this.loading = true
+      this.queryButton = true
       exceptionApi
-        .exceptiondata1({
-          siteName: this.form.name,
-          beginTime: this.form.beginTime,
-          endTime: this.form.endTime
+        .analysisdataByType(this.form.month, 'month')
+        .then((response) => {
+          this.chartData = response.data.data
+          this.queryButton = false
+          this.isNoData = false
+
+          if (response.data.data.length == 0) {
+            this.isNoData = true
+            return
+          }
+
+          exceptionApi
+            .exceptiondata1({
+              siteName: '',
+              beginTime: this.form.beginTime,
+              endTime: this.form.endTime
+            })
+            .then((res) => {
+              this.isNoData = false
+ 
+              this.table = index.merge(
+                this.chartData,
+                res.data.data,
+                this.form.beginTime,
+                this.form.endTime
+              )
+              this.loading = false
+
+              this.$nextTick(()=>{
+              this.$refs.table.sort('riskValue','descending')
+              
+            })
+
+            })
+            
         })
-        .then((res) => {
-          let obj = index.calRecur(res.data.data);
-          this.bill.exceptionRecurrence = obj['exceptionRecurrence'];
-          this.bill.exceptionTypeAggregation = obj['exceptionTypeAggregation'];
-        });
     },
 
     /**
      * 鍒濆鍔犺浇鍑芥暟
      */
-     fetch() {
+    fetch() {
       // 鍒嗘瀽鏁版嵁
-      this.fetchData();
+      this.fetchData()
       // 寮傚父鏁版嵁
-      this.exceptiondataCount();
+      // this.exceptiondataCount()
     },
 
     /**
      * 瀵煎嚭涓篍xcel
 
      */
-     exportData(){
-      if(this.table.length!=0){
-        const  tableColumns = ['siteName','region','monitorType','riskValue','riskGrage','riskAdvice','beginTime','endTime']
-        const excelColumns = [['A1','绔欑偣鍚嶇О'],
-      ['B1','鍖哄煙'],['C1','鐩戞祴绫诲瀷'],['D1','椋庨櫓鍊�'],
-      ['E1','椋庨櫓绛夌骇'],['F1','绠℃帶鎺柦'],['G1','寮�濮嬫棩鏈�'],
-      ['H1','缁撴潫鏃ユ湡']]
-
-      this.exportToExcel(this.table,tableColumns,excelColumns,'缁煎悎椋庨櫓鎺掑悕.xlsx')
-      } 
-
+    exportData() {
+      if (this.table.length != 0) {
+        const tableColumns = [
+          'siteName',
+          'region',
+          'monitorType',
+          'riskValue',
+          'riskGrage',
+          'riskAdvice',
+          'beginTime',
+          'endTime'
+        ]
+        const excelColumns = [
+          ['A1', '绔欑偣鍚嶇О'],
+          ['B1', '鍖哄煙'],
+          ['C1', '鐩戞祴绫诲瀷'],
+          ['D1', '椋庨櫓鍊�'],
+          ['E1', '椋庨櫓绛夌骇'],
+          ['F1', '绠℃帶鎺柦'],
+          ['G1', '寮�濮嬫棩鏈�'],
+          ['H1', '缁撴潫鏃ユ湡']
+        ]
+        this.exportButton = true
+        this.exportToExcel(this.table, tableColumns, excelColumns, '缁煎悎椋庨櫓鎺掑悕.xlsx')
+        this.exportButton = false
+      } else {
+        ElMessage('鏃犳暟鎹渶瑕佸鍑�')
+      }
     },
-
+    openDetail(row){
+      this.$router.push(`/detail/${row.siteName}/${this.form.month}`)
+    }
   }
-};
+}
 </script>
 
 <template>
-  <el-row>
+  <el-row ref="h1">
     <el-row>
       <el-form :inline="true" :model="form">
         <el-form-item>
           <AreaAndmonitorType></AreaAndmonitorType>
         </el-form-item>
+
         <el-form-item>
-            <InputSearch
-              isNeedDefaultSite="1"
-              @submit-value="(n) => (form.name = n)"
-            ></InputSearch>
-          </el-form-item>
-        <el-form-item>
-          <TimeSelectWithShortCuts
-            @submit-time="giveTime"
-          ></TimeSelectWithShortCuts>
+          <MonthSelect  @submit-value="giveMonth"></MonthSelect>
         </el-form-item>
+
         <el-form-item>
-          <el-button type="primary" @click="fetch">椋庨櫓鎺掑悕</el-button>
-          <el-button type="warning" @click="exportData">瀵煎嚭</el-button>
+          <ButtonClick
+            style="margin-right: 12px"
+            content="椋庨櫓鎺掑悕"
+            type="primary"
+            :loading="queryButton"
+            @do-search="fetch"
+          ></ButtonClick>
+          <ButtonExportExcel
+            content="瀵煎嚭鏁版嵁"
+            type="success"
+            :loading="exportButton"
+            @do-export="exportData"
+          ></ButtonExportExcel>
         </el-form-item>
       </el-form>
     </el-row>
   </el-row>
 
   <el-table
-          :data="table"
-          height="600px"
-          style="width: 100%"
-          v-loading="loading"
-          :cell-class-name="tableCellClassName"
+    ref="table"
+    :data="table"
+    :height="tableHeight"
+    v-loading="loading"
+    element-loading-text="鍚庡彴鍒嗘瀽涓�..."
+    style="width: 98%"
+    :cell-class-name="tableCellClassName"
+    :default-sort="{ prop: 'riskValue', order: 'descending' }"
+    v-show="!isNoData"
+    border
+  >
+    <el-table-column
+      type="index"
+      prop="name"
+      label="搴忓彿"
+      :index="indexMethod"
+      fixed
+      align="center"
+      width="55"
+      show-overflow-tooltip
+    />
+    <el-table-column prop="siteName" label="绔欑偣鍚嶇О" align="center" show-overflow-tooltip >
+      <template #default="{ row }">
+        <el-button type="primary" text class="table-button" @click="openDetail(row)"
+          >{{row.siteName}}</el-button
         >
-        <el-table-column
-            type="index"
-            prop="name"
-            label="搴忓彿"
-            :index="indexMethod"
-            fixed
-            show-overflow-tooltip
-          />
-          <el-table-column prop="siteName" label="绔欑偣鍚嶇О" show-overflow-tooltip />
-          <el-table-column prop="region" label="鍖哄煙" show-overflow-tooltip />
-          <el-table-column prop="monitorType" label="妫�娴嬬被鍨�" show-overflow-tooltip />
-          <el-table-column prop="riskValue" label="椋庨櫓鍊�" show-overflow-tooltip />
-          <el-table-column prop="riskGrage" label="椋庨櫓绛夌骇" show-overflow-tooltip />
-          <el-table-column prop="riskAdvice" label="绠℃帶鎺柦" show-overflow-tooltip />
-          <el-table-column prop="beginTime" label="寮�濮嬫棩鏈�" show-overflow-tooltip />
-          <el-table-column prop="endTime" label="缁撴潫鏃ユ湡" show-overflow-tooltip />
+      </template>
+      </el-table-column>
+    <el-table-column prop="region" label="鍖哄煙" align="center" width="80" show-overflow-tooltip />
+    <el-table-column prop="monitorType" label="妫�娴嬬被鍨�" align="center" width="80" show-overflow-tooltip />
+    <el-table-column
+      prop="riskValue"
+      label="椋庨櫓鍊�"
+      sortable
+      align="center"
+      width="100"
+      show-overflow-tooltip
+    />
+    <el-table-column prop="riskGrage" label="椋庨櫓绛夌骇" align="center" width="100" show-overflow-tooltip />
+    <el-table-column prop="riskAdvice" label="绠℃帶鎺柦" align="center" show-overflow-tooltip />
+    <el-table-column
+      prop="beginTime"
+      label="寮�濮嬫棩鏈�"
+      sortable
+      align="center"
+      width="160"
+      show-overflow-tooltip
+    />
+    <el-table-column
+      prop="endTime"
+      label="缁撴潫鏃ユ湡"
+      sortable
+      align="center"
+      width="160"
+      show-overflow-tooltip
+    />
   </el-table>
   <el-empty v-show="isNoData" :image-size="200" />
+
+
 
 </template>
 
 <style scoped>
-.el-row,.el-table  {
-  margin: 10px 0px 0px 10px
+.el-row,
+.el-table {
+  margin: 10px 0px 0px 10px;
 }
-.el-table{
- 
+
+:deep(.el-table__row .warning-row){
+  background-color: red;
+  /* color: rgb(241, 236, 236); */
 }
+.table-button {
+  letter-spacing: 1px;
+  text-decoration: underline;
+  border-radius: 0px;
+}
+
 </style>

--
Gitblit v1.9.3