From 03cec15c5f30cb7eda1e76bbf4183ad9c89e4f83 Mon Sep 17 00:00:00 2001
From: zhaowei <zhaowei>
Date: 星期五, 05 九月 2025 15:39:54 +0800
Subject: [PATCH] 1、设备TEEP页面删除滚动加载功能 2、mdc首页工段级看板调整样式及功能

---
 src/views/mdc/base/modules/efficiencyReport/EfficiencyList.vue |  143 ++++++++++++++++++++++++-----------------------
 1 files changed, 74 insertions(+), 69 deletions(-)

diff --git a/src/views/mdc/base/modules/efficiencyReport/EfficiencyList.vue b/src/views/mdc/base/modules/efficiencyReport/EfficiencyList.vue
index 8acbf86..709ad90 100644
--- a/src/views/mdc/base/modules/efficiencyReport/EfficiencyList.vue
+++ b/src/views/mdc/base/modules/efficiencyReport/EfficiencyList.vue
@@ -38,7 +38,9 @@
           </a-col>
           <a-col :md="6" :sm="6">
             <a-form-item label="鏃堕棿">
-              <a-range-picker @change="dateParamChange" :disabledDate="disabledDate" format="YYYYMMDD"
+              <a-range-picker @change="dateParamChange" :disabledDate="disabledDate"
+                              @calendarChange="handleCalendarChange" @openChange="handleCalendarOpenChange"
+                              format="YYYYMMDD"
                               v-model="dates" :allowClear="false"/>
             </a-form-item>
           </a-col>
@@ -95,8 +97,13 @@
                 <a-button type="primary" @click="searchQuery" icon="search">鏌ヨ</a-button>
                 <a-button type="primary" @click="searchReset" icon="reload">閲嶇疆</a-button>
                 <a-button type="primary" @click="exportExcel" icon="download">瀵煎嚭</a-button>
-                <!--<a-button type="primary" @click="exportOneYearExcel('璁惧TEEP')" icon="download">澶ф暟鎹鍑�</a-button>-->
-                <a-button type="primary" @click="handleShowFeedbackModal" icon="plus" v-has="'efficiency:feedback'">寮傚父鍙嶉</a-button>
+                <a-button type="primary" @click="exportLongTimeExcel('璁惧TEEP')" icon="download"
+                          :loading="longTimeExportButtonLoading">
+                  澶ф暟鎹鍑�
+                </a-button>
+                <a-button type="primary" @click="handleShowFeedbackModal" icon="plus" v-has="'efficiency:feedback'">
+                  寮傚父鍙嶉
+                </a-button>
                 <a-button type="primary" icon="printer" v-print="'#Efficiency'"
                           v-has="'efficiency:print'">鎵撳嵃
                 </a-button>
@@ -275,7 +282,7 @@
           list: '/mdc/efficiencyReport/efficiencyList',
           listByType: '/mdc/MdcUtilizationRate/getByType',
           queryEquipmentType: '/mdc/mdcEquipmentType/queryEquipmentType',
-          exportOneYearXlsUrl: ''
+          exportLongTimeXlsUrl: '/mdc/efficiencyReport/exportEfficiencyXls'
         },
         tableHeads: [],
         utilizationRateRowAverage: '',
@@ -289,7 +296,9 @@
         requestAllDataSize: 8,// 鎬诲叡璇锋眰鐨勫垪琛ㄩ」鏁扮洰(榛樿鍊间负榛樿鏃ユ湡鐨勫樊鍊�+1)
         everyRequestDataSize: 15,// 姣忔璇锋眰鐨勫垪琛ㄩ」鏁扮洰
         toggleSearchStatus: false,
-        modalVisible: false// 寮傚父鍙嶉寮圭獥鏄惁寮瑰嚭
+        modalVisible: false,// 寮傚父鍙嶉寮圭獥鏄惁寮瑰嚭
+        preSelectFirstDate: null,
+        longTimeExportButtonLoading: false
       }
     },
     props: { nodeTree: '', Type: '', nodePeople: '' },
@@ -469,10 +478,42 @@
         }
         return list
       },
-      disabledDate(current) {
-        //Can not slect days before today and today
-        return current && current > moment().subtract('days', 1)
+
+      dateParamChange(v1, v2) {
+        this.queryParam.startTime = v2[0]
+        this.queryParam.endTime = v2[1]
       },
+
+      /**
+       * 鏃堕棿閫夋嫨鍣ㄩ潰鏉夸笂鐨勫�煎彂鐢熸敼鍙樻椂瑙﹀彂
+       * @param dates 闈㈡澘涓婄殑涓や釜鍊肩粍鎴愮殑鏁扮粍
+       */
+      handleCalendarChange(dates) {
+        if (dates.length === 1) this.preSelectFirstDate = dates[0]
+      },
+
+      /**
+       * 鎺у埗鏃堕棿閫夋嫨鍣ㄩ潰鏉垮紑鍚笌鍏抽棴
+       * @param status 寮�鍚姸鎬�
+       */
+      handleCalendarOpenChange(status) {
+        if (status) this.preSelectFirstDate = null
+      },
+
+      /**
+       * 闈㈡澘涓婄姝㈤�夋嫨鐨勬棩鏈�
+       * @param current 绂佹鐨勬椂闂磋寖鍥�
+       */
+      disabledDate(current) {
+        if (!this.preSelectFirstDate) {
+          return current > moment().startOf('days')
+        } else {
+          return current < moment(this.preSelectFirstDate).subtract(365, 'days').startOf('days')
+            || current > moment().startOf('days')
+            || current > moment(this.preSelectFirstDate).add(365, 'days').endOf('days')
+        }
+      },
+
       exportExcel() {
         $('#Efficiency').table2excel({
           exclude: '.noExl',
@@ -484,10 +525,22 @@
           exclude_inputs: false
         })
       },
-      exportOneYearExcel(fileName) {
-        // let param = this.getQueryParams()
-        // console.log('瀵煎嚭鍙傛暟', param)
-        downFile(this.url.exportOneYearXlsUrl)
+      exportLongTimeExcel(fileName) {
+        let param = {
+          startTime: moment(this.dates[0]).format('YYYYMMDD'),
+          endTime: moment(this.dates[1]).format('YYYYMMDD')
+        }
+        Object.keys(this.queryParams).forEach(item => {
+          if (Array.isArray(this.queryParams[item])) {
+            param[item] = this.queryParams[item].join()
+            // 姝ゅ涓轰繚璇佹帴鍙e弬鏁颁笉澶氫綑锛屽彲鐪佺暐
+            if (this.queryParams[item].length === 0) delete param[item]
+          }
+        })
+        param = Object.assign({}, this.queryParam, param)
+
+        this.longTimeExportButtonLoading = true
+        downFile(this.url.exportLongTimeXlsUrl, param)
           .then((data) => {
             if (!data) {
               this.$notification.warning({
@@ -497,18 +550,25 @@
               return
             }
             if (typeof window.navigator.msSaveBlob !== 'undefined') {
-              window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xls')
+              window.navigator.msSaveBlob(new Blob([data], { type: 'application/vnd.ms-excel' }), fileName + '.xlsx')
             } else {
               let url = window.URL.createObjectURL(new Blob([data], { type: 'application/vnd.ms-excel' }))
               let link = document.createElement('a')
               link.style.display = 'none'
               link.href = url
-              link.setAttribute('download', fileName + '.xls')
+              link.setAttribute('download', fileName + '.xlsx')
               document.body.appendChild(link)
               link.click()
               document.body.removeChild(link) //涓嬭浇瀹屾垚绉婚櫎鍏冪礌
               window.URL.revokeObjectURL(url) //閲婃斁鎺塨lob瀵硅薄
             }
+          })
+          .finally(() => {
+            let timer = setTimeout(() => {
+              this.longTimeExportButtonLoading = false
+              clearTimeout(timer)
+              timer = null
+            }, 1000)
           })
       },
       showIdentifying() {
@@ -518,19 +578,10 @@
           }
         })
       },
-      dateParamChange(v1, v2) {
-        this.queryParam.startTime = v2[0]
-        this.queryParam.endTime = v2[1]
-        this.dates = [v1[0], v1[1]]
-      },
       efficiencyOptionsOnChange(checkedList) {
         this.checkedList = checkedList
       },
       searchQuery() {
-        // 鍥犺Е搴曞埛鏂颁細淇敼鍙傛暟鏃堕棿鍊硷紝鏁呭湪姝ょ敤鏃堕棿閫夋嫨鍣ㄧ殑鏃堕棿鍊煎鍙傛暟鏃堕棿鍊煎啀娆¤祴鍊硷紝鑻ヤ笉杩欐牱鍋氬垯鍙傛暟鏃堕棿鍊煎垯浼氫笌鏃堕棿閫夋嫨鍣ㄤ笂鐨勬椂闂村�间笉涓�鑷�
-        this.queryParam.startTime = moment(this.dates[0]).format('YYYYMMDD')
-        this.queryParam.endTime = moment(this.dates[1]).format('YYYYMMDD')
-
         if (this.queryParam.typeTree == '1') {
           this.queryParam.parentId = this.queryParamEquip.parentId
           this.queryParam.equipmentId = this.queryParamEquip.equipmentId
@@ -572,15 +623,6 @@
         this.tableHeads = []
         this.dataList = []
         this.spinning = true
-        console.log('requestAllDataSize', this.requestAllDataSize)
-        console.log('everyRequestDataSize', this.everyRequestDataSize)
-        // 鑻ユ棩鏈熼�夋嫨鍣ㄨ缃殑鏌ヨ璇锋眰鏁伴噺瓒呰繃15鏉″垯寮�鍚噿鍔犺浇
-        if (this.requestAllDataSize > this.everyRequestDataSize) {
-          // 寮�鍚噿鍔犺浇鍚庡皢缁撴潫鏃ユ湡璁剧疆涓哄紑濮嬫棩鏈熶箣鍚庣殑14澶╋紝鍗冲厛鏌ヨ15澶╁唴鐨勬暟鎹�
-          this.queryParam.endTime = moment(this.queryParam.startTime).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD')
-          this.isLazyRequest = true
-          this.tableScroll.removeEventListener('scroll', this.tableScrollX) // 涓洪伩鍏嶆粴鍔ㄦ潯鏈夋粴鍔ㄨ窛绂诲悗鍚庣偣鍑绘煡璇㈡寜閽Е鍙戞粴鍔ㄤ簨浠讹紝鍥犳鍦ㄨЕ鍙戜簨浠跺墠绉婚櫎浜嬩欢
-        }
 
         getAction(this.url.list, this.queryParam).then(res => {
           if (res.success) {
@@ -594,12 +636,10 @@
 
             this.tableHeads = res.result.dates
             this.dataList = res.result.mdcEfficiencyList
-            console.log('dataList', this.dataList)
             this.checkSameData(this.dataList)
             this.checkSameData1(this.dataList)
             this.checkSameData2(this.dataList)
             this.combineCell()
-            this.tableScroll.addEventListener('scroll', this.tableScrollX)
           }
         }).finally(() => {
           this.spinning = false
@@ -610,41 +650,6 @@
       handleShowFeedbackModal() {
         this.$refs.modalForm.formParams = {}
         this.modalVisible = true
-      },
-
-      // 婊氬姩鏉¤Е搴曞埛鏂拌〃鏍兼暟鎹�
-      tableScrollX() {
-        // 褰撴粴鍔ㄦ潯瑙﹀簳涓旀噿鍔犺浇寮�鍚椂瑙﹀彂婊氬姩鏉¤Е搴曞埛鏂�
-        if (Math.ceil(this.tableScroll.scrollLeft + this.tableScroll.clientWidth) + 1 >= this.tableScroll.scrollWidth && this.isLazyRequest) {
-          this.spinning = true
-          this.queryParam.startTime = moment(this.queryParam.endTime).add(1, 'days').format('YYYYMMDD')
-          // 鍒ゆ柇璁剧疆鎳掑姞杞藉悗鐨勭粨鏉熸椂闂存槸鍚﹁秴杩囨椂闂撮�夋嫨鍣ㄤ腑璁剧疆鐨勭粨鏉熸椂闂�
-          if (moment(this.queryParam.endTime).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD') - moment(this.dates[1]).format('YYYYMMDD') < 0) {
-            //鍐嶆鏌ヨ鍚�15澶╁唴鐨勬暟鎹�
-            this.queryParam.endTime = moment(this.queryParam.endTime).add(this.everyRequestDataSize, 'days').format('YYYYMMDD')
-          } else {
-            // 濡傛灉涓嶅皬浜庢椂闂撮�夋嫨鍣ㄤ腑璁剧疆鐨勬椂闂村垯璁剧疆璇锋眰缁撴潫鏃ユ湡涓烘椂闂撮�夋嫨鍣ㄤ腑璁剧疆鐨勭粨鏉熸椂闂村苟涓斿叧闂噿鍔犺浇锛堟剰鍛崇潃鏈�鍚庝竴娆¤Е搴曞埛鏂帮級
-            this.queryParam.endTime = moment(this.dates[1]).format('YYYYMMDD')
-            this.isLazyRequest = false
-          }
-          getAction(this.url.list, this.queryParam)
-            .then(res => {
-              if (res.success) {
-                this.tableHeads = [...this.tableHeads.slice(0, -2), ...res.result.dates]
-                console.log('dataList', this.dataList)
-                this.dataList.forEach(item1 => {
-                  res.result.mdcEfficiencyList.forEach(item2 => {
-                    if (item1.equipmentId === item2.equipmentId) {
-                      item1.dataList = [...item1.dataList.slice(0, -2), ...item2.dataList]
-                    }
-                  })
-                })
-              }
-            })
-            .finally(() => {
-              this.spinning = false
-            })
-        }
       },
 
       // 鑾峰彇璁惧绫诲瀷鍒楄〃

--
Gitblit v1.9.3