From 9c1d136e4f5ed9b5bce100147edbb52486da985a Mon Sep 17 00:00:00 2001
From: zmc <zmc_li@foxmail.com>
Date: 星期五, 08 十二月 2023 13:57:32 +0800
Subject: [PATCH] 对飞行巡检和审核辅助对话框逻辑写成组件

---
 src/views/exception/components/CompDialogDetail.vue |  164 +++++++++++++++++++++++++++++++++++++++---------------
 1 files changed, 118 insertions(+), 46 deletions(-)

diff --git a/src/views/exception/components/CompDialogDetail.vue b/src/views/exception/components/CompDialogDetail.vue
index 67ef2a0..a83a4b9 100644
--- a/src/views/exception/components/CompDialogDetail.vue
+++ b/src/views/exception/components/CompDialogDetail.vue
@@ -1,31 +1,39 @@
 <!-- 鐐瑰嚮 鈥濇煡鐪嬭缁嗏�� 鐨勫璇濇 -->
 <!-- 涓婁竴鏉′笅涓�鏉$敱瀛愮粍浠朵紶閫掔粰鐖剁粍浠讹紝鐖剁粍浠剁洃鍚俊鍙� -->
-
 <script>
 import exceptionOption from '@/utils/chartFunction/exceptionOption.js'
 import index from '@/utils/exception_common_function/index.js'
 import DustLineChart from '@/views/exception/components/DustLineChart.vue'
 import historyApi from '@/api/historyApi.js'
-
+import lineChartFunc from '@/utils/chartFunction/lineChart.js'
+import time from '@/utils/time.js'
 export default {
   props: {
     // 琛ㄦ牸鐨勪竴琛屾暟鎹�
     row: {
       type: Object,
-      default: {}
+      default() {
+        return {}
+      }
     },
     // 瀵硅瘽妗嗘槸鍚︽樉绀�
     dialogTableVisible: {
       type: Boolean,
       default: false
+    },
+    buttonDisabled: {
+      type: Object,
+      default() {
+        return { pre: false, next: false }
+      }
     }
   },
   components: {
     DustLineChart
   },
-  emits: ['update:dialogTableVisible'],
+  emits: ['update:dialogTableVisible', 'getPreRowData', 'getNextRowData'],
   computed: {
-    dialogTableVisible: {
+    visible: {
       get() {
         return this.dialogTableVisible
       },
@@ -36,7 +44,7 @@
   },
   watch: {
     row: {
-      handler(newValue) {
+      handler() {
         this.display()
       },
       deep: true
@@ -48,33 +56,34 @@
       historyData: [],
       //  鎶樼嚎鍥鹃厤缃」
       lineChartOption: {},
+
+      // 鎸夐挳锛屽浘褰㈠姞杞戒腑
       loading: {
         // 涓婁竴鏉℃寜閽�
         preButton: false,
         // 涓嬩竴鏉℃寜閽�
-        afterButton: false,
+        nextButton: false,
         // 鎶樼嚎鍥�
         lineChart: false
       },
-
 
       // 鏍囪浣�
       flag: {
         // 鏁版嵁鍔犺浇鏃� 涓婁笅鏉℃寜閽笉鑳藉啀鐐瑰嚮
         banTouch: 0,
+        pre: false,
+        next: false
       },
 
-      isPreCantouch:false,
-      isNextCantouch:false
-
+      isPreCanTouch: false,
+      isNextCanTouch: false
     }
   },
 
-  mounted() {},
   methods: {
-    display() {
+    async display() {
       // 琛ㄦ牸鏁版嵁
-      this.getExceptionTableDataByCurrenrRow(this.row)
+      await this.getExceptionTableDataByCurrentRow(this.row)
 
       // 鎶樼嚎鍥炬暟鎹�
       this.setLineChart(this.row)
@@ -85,15 +94,23 @@
      * @param锛� 鐐逛綅鍚嶇О锛屽紓甯稿紑濮嬫椂闂达紝寮傚父缁撴潫鏃堕棿
      * @returns锛�
      */
-    async getExceptionTableDataByCurrenrRow({ name, beginTime, endTime, exceptionType }) {
+    async getExceptionTableDataByCurrentRow({ name, exceptionType, beginTime, endTime }) {
       if (!name || !beginTime || !endTime) {
         return
       }
+      console.log('寮傚父涓�', exceptionType)
       // 鏁版嵁缂哄け寮傚父鏃讹紝鏋勯�犺〃鏍兼暟鎹�
-      if (this.exceptionType == '0') {
-        this.setOfflineTbleData(this.row)
+      if (exceptionType == '0') {
+        this.setOfflineTableData(this.row)
         return
       }
+      // 鏈夋晥鐜囧紓甯告椂 璁剧疆鎶樼嚎鍥惧姞杞戒腑鏁堟灉
+      if (exceptionType == '8') {
+        this.loading.lineChart = true
+      }
+
+      this.loading.preButton = true
+      this.loading.nextButton = true
 
       // 鏍规嵁寮傚父鐨勭偣浣嶅悕绉般�佸紑濮嬨�佺粨鏉熸椂闂达紝鏌ヨ璇ユ椂娈电殑棰楃矑鐗╂祿搴︽暟鎹�
       const response = await historyApi.queryHistoryData({
@@ -103,6 +120,12 @@
       })
       //  寮傚父琛ㄦ牸寰楀埌鏁版嵁
       this.historyData = response.data.data
+
+      this.flag.pre = false
+      this.flag.next = false
+
+      this.loading.preButton = false
+      this.loading.nextButton = false
     },
 
     /* ***********************************************************************************  鎶樼嚎鍥� */
@@ -111,19 +134,20 @@
      * @param锛�
      * @returns锛�
      */
-    async setLineChart({ beginTime, endTime }) {
+    async setLineChart({ exception, exceptionType, beginTime, endTime }) {
+      if (exceptionType == '8') {
+        this.validProcess(this.historyData, { exception, exceptionType, beginTime, endTime })
+        this.loading.lineChart = false
+        return
+      }
       // 璁$畻寮傚父鍖洪棿鐨勫墠鍚�45鍒嗛挓
       const beforeAndAfterTime = index.before45AndAfter45(beginTime, endTime)
       // 璇锋眰鏁存鏃堕棿娈电殑棰楃矑鐗╂祿搴︽暟鎹�
-     
 
       // 瀵硅姹傚洖鐨勬暟鎹繘琛屽垝鍒�
       const chartParams = await this.organizeLineChartsOptionParams(beforeAndAfterTime, this.row)
       this.lineChartOption = exceptionOption.setExceptionChartOption(chartParams)
-
     },
-
-
 
     /**
      * 鏋勫缓鎶樼嚎鍥剧殑閰嶇疆椤圭殑鍙傛暟
@@ -187,7 +211,7 @@
     /**
      * description锛氭暟鎹己澶卞紓甯告椂锛岃缃殑琛ㄦ牸鏁版嵁
      */
-    setOfflineTbleData({ name, mnCode, dutyCompany, beginTime, endTime }) {
+    setOfflineTableData({ name, mnCode, dutyCompany, beginTime, endTime }) {
       // 鏃犳暟鎹椂鐨勬椂闂存暟缁� 鏃堕棿鐩稿樊15鍒嗛挓
       const abnormalTimeTenMinute = index.descFiftyTime(beginTime, endTime)
 
@@ -202,6 +226,65 @@
           yData: ''
         })
       }
+    },
+    /**
+     * 鏈夋晥鐜囧紓甯� 璁剧疆鎶樼嚎鍥鹃厤缃」
+     * @param锛�
+     * @returns锛�
+     */
+    validProcess(historyData, { exception, exceptionType, beginTime, endTime }) {
+      // x杞存暟鎹�
+      let xData = time.ascTime(beginTime, endTime, 15)
+      // y杞存暟鎹�
+      let yData = []
+      xData.forEach((item) => {
+        // 鏌ユ壘璇ユ椂闂寸殑鏁版嵁
+        let r = lineChartFunc.findDate(historyData, item)
+        if (r) {
+          yData.push(r.dustValue)
+        } else {
+          yData.push(null)
+        }
+      })
+      // 寰楀埌鏈夋晥鏁版嵁鐨勬椂闂寸偣
+      let DataTime = time.validTime(historyData)
+      let rangeTime = time.getMissingDays(xData[0], xData[xData.length - 1], DataTime, 15)
+      console.log('鏃犳暟鎹椂闂�', rangeTime)
+      // 寰楀埌鑳屾櫙鍖洪棿鐨勯厤缃�
+      let areaObj = lineChartFunc.getMarkArea(rangeTime, '寮傚父')
+      let lineColor = []
+      // 浼犲叆鍙傛暟
+      this.lineChartOption = exceptionOption.setExceptionChartOption({
+        xData,
+        yData,
+        exceptionBeginTime: beginTime,
+        exceptionEndTime: endTime,
+        beginIndex: '',
+        endIndex: '',
+        exceptionName: exception,
+        areaObj,
+        lineColor,
+        exceptionType
+      })
+    },
+
+    /**
+     * 鐐瑰嚮鈥滀笂涓�鏉♀��
+     * @param锛�
+     * @returns锛�
+     */
+    clickPre() {
+      this.flag.pre = true
+      this.$emit('getPreRowData')
+    },
+    /**
+     * 鐐瑰嚮鈥滀笅涓�鏉♀��
+     * @param锛�
+     * @returns锛�
+     */
+    clickNext() {
+      this.flag.next = true
+      this.$emit('getNextRowData')
     }
   }
 }
@@ -210,14 +293,12 @@
 <template>
   <el-dialog
     class="exception-dialog"
-    v-model="dialogTableVisible"
+    v-model="visible"
     draggable
     align-center
     height="700px"
     width="700px"
   >
-
-
     <!-- 澶� -->
     <template #header>
       <div class="diag-head">
@@ -231,28 +312,25 @@
           </div>
         </div>
       </div>
-      
 
-      <!-- <div class="chart-jump-button">
+      <div class="chart-jump-button">
         <el-button
           type="danger"
-          :loading="loading.preButton"
-          :disabled="isPreCantouch || flag.banTouch"
-          @click="getNextRowData"
+          :loading="flag.pre && loading.preButton"
+          :disabled="buttonDisabled.pre"
+          @click="clickPre"
           >涓婃潯寮傚父</el-button
         >
+
         <el-button
           type="danger"
-          :loading="loading.afterButton"
-          :disabled="isNextCantouch || flag.banTouch"
-          @click="getPreviousRowData"
+          :loading="flag.next && loading.nextButton"
+          :disabled="buttonDisabled.next"
+          @click="clickNext"
           >涓嬫潯寮傚父</el-button
         >
-      </div> -->
-
-
+      </div>
     </template>
-
 
     <!-- 鍥惧舰 -->
     <DustLineChart :option="lineChartOption" v-loading="loading.lineChart"></DustLineChart>
@@ -277,7 +355,7 @@
     <template #footer>
       <div class="dialog-footer">
         <el-tag type="success" class="mx-1" effect="dark" round
-          ><span class="table-line-lable" v-show="row.exceptionType == '0'">缂哄け鏁版嵁锛� </span>
+          ><span v-show="row.exceptionType == '0'">缂哄け鏁版嵁锛� </span>
           <span
             v-show="
               row.exceptionType == '1' ||
@@ -291,7 +369,7 @@
             "
             >寮傚父鏁版嵁锛�</span
           >
-          <span class="table-line-num">{{ historyData.length }}鏉�</span>
+          <span class="table-line-num">{{ historyData?.length }}鏉�</span>
           <span v-show="row.exceptionType == '0'"> (閫昏緫璁$畻)</span>
         </el-tag>
         <el-text v-show="row.exceptionType == '8'" type="warning" class="dialog-footer-text"
@@ -299,14 +377,11 @@
         >
       </div>
     </template>
-
-
   </el-dialog>
 </template>
 
 <style scoped>
 /* 鏌ョ湅璇︽儏瀵硅瘽妗嗘ā鍧楃殑鏍峰紡 */
-
 .diag-head {
   /* 瀵硅瘽妗嗗ご閮ㄥ尯鍩� */
   min-height: 200px;
@@ -332,9 +407,6 @@
 }
 
 .mx-1 {
-  /* position: absolute;
-  left: 10px;
-  bottom: 10px; */
   justify-content: flex-start;
 }
 .dialog-footer {

--
Gitblit v1.9.3