From 5330eb812cdcc02cace0648b008092b24c6e2236 Mon Sep 17 00:00:00 2001
From: zhuzhuanzhuan
Date: 星期三, 06 十二月 2023 17:44:50 +0800
Subject: [PATCH] 1、利用率走势分析和利用率分段分析页面优化表格数据加载方式,实现滚动条触底加载,解决数据量较大时网页请求速度慢问题 2、报警分析页面调整图表样式,更换表格组件为ant-design表格 3、登录页面登录后若用户密码为初始密码或密码已过期则出现修改密码弹窗

---
 src/views/mdc/base/modules/openRateTrendAnalysis/openRateTrendAnalysisMain.vue |   61 +++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 2 deletions(-)

diff --git a/src/views/mdc/base/modules/openRateTrendAnalysis/openRateTrendAnalysisMain.vue b/src/views/mdc/base/modules/openRateTrendAnalysis/openRateTrendAnalysisMain.vue
index 6056ac3..fadbf53 100644
--- a/src/views/mdc/base/modules/openRateTrendAnalysis/openRateTrendAnalysisMain.vue
+++ b/src/views/mdc/base/modules/openRateTrendAnalysis/openRateTrendAnalysisMain.vue
@@ -108,7 +108,10 @@
         },
         tableHeads: [],
         XData: [0],
-        YData: [0]
+        YData: [0],
+        isLazyRequest: '',// 鏄惁寮�鍚噿鍔犺浇
+        requestAlldataSize: 8,// 鎬诲叡璇锋眰鐨勫垪琛ㄩ」鏁扮洰
+        everyRequestDataSize: 15// 姣忔璇锋眰鐨勫垪琛ㄩ」鏁扮洰
       }
     },
     props: { nodeTree: '', Type: '', nodePeople: '' },
@@ -121,6 +124,12 @@
       this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
       this.queryParam.typeTree = '1'
       this.loadData1()
+    },
+    mounted() {
+      this.tableScroll = document.querySelector('.table2')
+    },
+    beforeDestroy() {
+      this.tableScroll.removeEventListener('scroll', this.tableScrollX)
     },
     watch: {
       Type(valmath) {
@@ -221,9 +230,13 @@
       dateParamChange(v1, v2) {
         this.queryParam.startDate = v2[0]
         this.queryParam.endDate = v2[1]
+        this.dates = [v1[0], v1[1]]
       },
       searchQuery() {
-        if (this.dates && this.dates.length > 0) {
+        console.log('dates', this.dates)
+        this.queryParam.startDate = moment(this.dates[0]).format('YYYYMMDD')
+        this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
+        if (this.dates[0] && this.dates[1]) {
           if (this.queryParam.typeTree == '1') {
             this.queryParam.parentId = this.queryParamEquip.parentId
             this.queryParam.equipmentId = this.queryParamEquip.equipmentId
@@ -231,6 +244,7 @@
             this.queryParam.parentId = this.queryParamPeople.parentId
             this.queryParam.equipmentId = ''
           }
+          this.requestAlldataSize = moment.duration(moment(this.queryParam.endDate) - moment(this.queryParam.startDate), 'millisecond').asDays() + 1
           this.loadData1()
         } else {
           this.$notification.warning({
@@ -313,6 +327,13 @@
         this.loading = true
         this.tableHeads = []
         this.dataList = []
+        // 鑻ユ棩鏈熼�夋嫨鍣ㄨ缃殑鏌ヨ璇锋眰鏁伴噺瓒呰繃15鏉″垯寮�鍚噿鍔犺浇
+        if (this.requestAlldataSize > 15) {
+          // 寮�鍚噿鍔犺浇鍚庡皢缁撴潫鏃ユ湡璁剧疆涓哄紑濮嬫棩鏈熶箣鍚庣殑14澶╋紝鍗冲厛鏌ヨ15澶╁唴鐨勬暟鎹�
+          this.queryParam.endDate = moment(this.queryParam.startDate).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD')
+          this.isLazyRequest = true
+          this.tableScroll.removeEventListener('scroll', this.tableScrollX) // 涓洪伩鍏嶆粴鍔ㄦ潯鏈夋粴鍔ㄨ窛绂诲悗鍚庣偣鍑绘煡璇㈡寜閽Е鍙戞粴鍔ㄤ簨浠讹紝鍥犳鍦ㄨЕ鍙戜簨浠跺墠绉婚櫎浜嬩欢
+        }
         getAction(this.url.efficiencyList, this.queryParam).then(res => {
           if (res.success) {
             this.tableHeads = res.result.dates
@@ -323,6 +344,7 @@
             // this.checkSameData2(this.dataList)
             // this.combineCell();
             // this.initDeviceType(this.dataList)
+            this.tableScroll.addEventListener('scroll', this.tableScrollX)
           }
         }).finally(() => {
           this.loading = false
@@ -385,6 +407,41 @@
           ]
         }
         openRateTrendAnalysisChart.setOption(openRateTrendChartOptions, true)
+      },
+
+      /**
+       * 婊氬姩鏉¤Е搴曞埛鏂拌〃鏍兼暟鎹�
+       */
+      tableScrollX() {
+        // 褰撴粴鍔ㄦ潯瑙﹀簳涓旀噿鍔犺浇寮�鍚椂瑙﹀彂婊氬姩鏉¤Е搴曞埛鏂�
+        if (Math.ceil(this.tableScroll.scrollLeft + this.tableScroll.clientWidth) + 1 >= this.tableScroll.scrollWidth && this.isLazyRequest) {
+          this.loading = true
+          this.queryParam.startDate = moment(this.queryParam.endDate).add(1, 'days').format('YYYYMMDD')
+          // 鍒ゆ柇璁剧疆鎳掑姞杞藉悗鐨勭粨鏉熸椂闂存槸鍚﹁秴杩囨椂闂撮�夋嫨鍣ㄤ腑璁剧疆鐨勭粨鏉熸椂闂�
+          if (moment(this.queryParam.endDate).add(this.everyRequestDataSize - 1, 'days').format('YYYYMMDD') - moment(this.dates[1]).format('YYYYMMDD') < 0) {
+            //鍐嶆鏌ヨ鍚�15澶╁唴鐨勬暟鎹�
+            this.queryParam.endDate = moment(this.queryParam.endDate).add(this.everyRequestDataSize, 'days').format('YYYYMMDD')
+          } else {
+            // 濡傛灉涓嶅皬浜庢椂闂撮�夋嫨鍣ㄤ腑璁剧疆鐨勬椂闂村垯璁剧疆璇锋眰缁撴潫鏃ユ湡涓烘椂闂撮�夋嫨鍣ㄤ腑璁剧疆鐨勭粨鏉熸椂闂村苟涓斿叧闂噿鍔犺浇锛堟剰鍛崇潃鏈�鍚庝竴娆¤Е搴曞埛鏂帮級
+            this.queryParam.endDate = moment(this.dates[1]).format('YYYYMMDD')
+            this.isLazyRequest = false
+          }
+          getAction(this.url.efficiencyList, this.queryParam).then(res => {
+            if (res.success) {
+              this.tableHeads = [...this.tableHeads, ...res.result.dates]
+              this.dataList.forEach(item1 => {
+                res.result.mdcEfficiencyList.forEach(item2 => {
+                  if (item1.equipmentId === item2.equipmentId) {
+                    item1.dataList = [...item1.dataList, ...item2.dataList]
+                  }
+                })
+              })
+              this.draw()
+            }
+          }).finally(() => {
+            this.loading = false
+          })
+        }
       }
     }
   }

--
Gitblit v1.9.3