Browse Source

航站视图表格滚动高度修改

zhongxiaoyu 2 years ago
parent
commit
8ca4361ab0

+ 13 - 9
src/views/baggageManagement/components/arrival/index.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: zk
  * @Date: 2022-01-17 10:39:22
- * @LastEditTime: 2022-06-15 14:00:22
+ * @LastEditTime: 2022-06-15 18:00:57
  * @LastEditors: your name
  * @Description: 进港01
 -->
@@ -591,15 +591,19 @@ export default {
       if (scrollParent.scrollHeight <= scrollParent.offsetHeight) {
         return
       }
-      let lastRow
-      if (this.arrivalCount === this.tableData.length) {
-        lastRow = table.querySelectorAll('.el-table__body tr')[this.arrivalCount - 1]
-      } else {
-        lastRow = table.querySelectorAll('.el-table__body tr')[this.arrivalCount]
-      }
+      const lastRow = table.querySelectorAll('.el-table__body tr')[this.arrivalCount]
+      // if (this.arrivalCount === this.tableData.length) {
+      //   lastRow = table.querySelectorAll('.el-table__body tr')[this.arrivalCount - 1]
+      // } else {
+      //   lastRow = table.querySelectorAll('.el-table__body tr')[this.arrivalCount]
+      // }
       setTimeout(() => {
-        const scrollTop = lastRow.offsetTop + lastRow.offsetHeight - scrollParent.offsetHeight
-        scrollParent.scrollTo(0, scrollTop)
+        const scrollMid = lastRow.offsetTop + (lastRow.offsetHeight - scrollParent.offsetHeight) / 2
+        const scrollMax = scrollParent.scrollHeight - scrollParent.offsetHeight
+        if (scrollMid > 0) {
+          const scrollHeight = Math.min(scrollMid, scrollMax)
+          scrollParent.scrollTo(0, scrollHeight)
+        }
       }, 0)
       this.hasSetTableScroll = true
     },

+ 15 - 11
src/views/baggageManagement/components/departure/index.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: zk
  * @Date: 2022-01-17 10:39:22
- * @LastEditTime: 2022-06-15 14:00:35
+ * @LastEditTime: 2022-06-15 17:59:29
  * @LastEditors: your name
  * @Description: 离港01
 -->
@@ -505,11 +505,11 @@ export default {
       this.leaveCount = 0
       this.baggageCount = 0
       tableData.forEach(item => {
-        if (item.hasTakenOff === 0) {
+        item['flightCanceled'] = item['flightStatus'] === 'CAN' ? 1 : 0
+        if (item['hasTakenOff'] === 0 && !item['flightCanceled']) {
           this.leaveCount++
         }
         item['landingNumber'] = item['loadNumber']
-        item['flightCanceled'] = item['flightStatus'] === 'CAN' ? 1 : 0
         this.baggageCount = this.baggageCount + item.preLoad
       })
       this.tableData = this._.sortBy(tableData, ['hasTakenOff', 'PlanDepartureTime'])
@@ -532,15 +532,19 @@ export default {
       if (scrollParent.scrollHeight <= scrollParent.offsetHeight) {
         return
       }
-      let lastRow
-      if (this.leaveCount === this.tableData.length) {
-        lastRow = table.querySelectorAll('.el-table__body tr')[this.leaveCount - 1]
-      } else {
-        lastRow = table.querySelectorAll('.el-table__body tr')[this.leaveCount]
-      }
+      const lastRow = table.querySelectorAll('.el-table__body tr')[this.leaveCount]
+      // if (this.leaveCount === this.tableData.length) {
+      //   lastRow = table.querySelectorAll('.el-table__body tr')[this.leaveCount - 1]
+      // } else {
+      //   lastRow = table.querySelectorAll('.el-table__body tr')[this.leaveCount]
+      // }
       setTimeout(() => {
-        const scrollTop = lastRow.offsetTop + lastRow.offsetHeight - scrollParent.offsetHeight
-        scrollParent.scrollTo(0, scrollTop)
+        const scrollMid = lastRow.offsetTop + (lastRow.offsetHeight - scrollParent.offsetHeight) / 2
+        const scrollMax = scrollParent.scrollHeight - scrollParent.offsetHeight
+        if (scrollMid > 0) {
+          const scrollHeight = Math.min(scrollMid, scrollMax)
+          scrollParent.scrollTo(0, scrollHeight)
+        }
       }, 0)
       this.hasSetTableScroll = true
     },