Browse Source

进港视图添加已到达背景色

zhongxiaoyu 2 years ago
parent
commit
ec9ee8c207

+ 0 - 15
src/main.js

@@ -26,21 +26,6 @@ Vue.use(ElementUI)
 import elTableInfiniteScroll from 'el-table-infinite-scroll';
 
 Vue.use(elTableInfiniteScroll)
-Vue.directive('loadmore', {
-  bind(el, binding) {
-    if (!binding.value) {
-      return
-    }
-    const selectWrap = el.querySelector('.el-table__body-wrapper')
-    selectWrap.addEventListener('scroll', function () {
-      const sign = 0
-      const scrollDistance = this.scrollHeight - this.scrollTop - this.clientHeight
-      if (scrollDistance <= sign) {
-        binding.value()
-      }
-    })
-  }
-})
 
 Vue.prototype.$echarts = echarts
 Vue.config.productionTip = false

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

@@ -1,7 +1,7 @@
 <!--
  * @Author: zk
  * @Date: 2022-01-17 10:39:22
- * @LastEditTime: 2022-06-10 09:15:33
+ * @LastEditTime: 2022-06-14 10:44:04
  * @LastEditors: your name
  * @Description: 进港01
 -->
@@ -264,6 +264,7 @@ import tableColsMixin from '../../mixins/tableCols'
 import { getQuery } from '@/api/flight'
 import TableHeaderCell from '@/components/TableHeaderCell'
 import { setTableFilters } from '@/utils/table'
+// import { parseTime } from '@/utils'
 
 export default {
   name: 'DepartureTerminalView',
@@ -431,14 +432,19 @@ export default {
           ]
         }
       ],
+      tableDataSortRules: {
+        flightCanceled: 'ascending'
+      },
       AirportList: [],
       loopEvent: null,
-      leaveCount: 0,
+      arrivalCount: 0,
       baggageCount: 0
     }
   },
-  mounted() {
+  created() {
     this.getAirPortData()
+  },
+  mounted() {
     const that = this
     this.loopEvent = setInterval(function () {
       that.getTableData()
@@ -446,6 +452,7 @@ export default {
   },
   beforeDestroy() {
     clearInterval(this.loopEvent)
+    this.loopEvent = null
   },
   methods: {
     airPortChange() {
@@ -470,8 +477,14 @@ export default {
       }
     },
     tableRowClassName({ row, rowIndex }) {
+      if (row.flightStatus === 'DLY') {
+        return 'bgl-delayed'
+      }
+      if (row.flightStatus === 'CAN') {
+        return 'bgl-canceled'
+      }
       if (row.hasTakenOff === 0) {
-        if (rowIndex === this.leaveCount - 1) {
+        if (rowIndex === this.arrivalCount - 1) {
           return 'bgl-hui redBorder'
         } else {
           return 'bgl-hui'
@@ -521,15 +534,16 @@ export default {
       }
     },
     initTableData(tableData) {
-      this.leaveCount = 0
+      this.arrivalCount = 0
       this.baggageCount = 0
       tableData.forEach(item => {
-        if (item.hasTakenOff === 0) {
-          this.leaveCount++
-        }
+        // if (this.hasArrived(item)) {
+        //   this.arrivalCount++
+        // }
+        item['flightCanceled'] = item['flightStatus'] === 'CAN' ? 1 : 0
         this.baggageCount = this.baggageCount + item.projectedLoad
       })
-      this.tableData = this._.sortBy(tableData, ['FlightDate', 'arrivalTime'])
+      this.tableData = this._.sortBy(tableData, ['hasArrived', 'arrivalTime'])
       setTableFilters(this.tableData, this.tableDataFilters)
       this.toOrderNum(this.baggageCount)
       // setInterval(() => {
@@ -537,6 +551,12 @@ export default {
       //    // 这里输入数字即可调用
       // }, 2000);
     },
+    hasArrived(flight) {
+      const now = new Date()
+      const arrivalTime = new Date(flight.arrivalTime)
+        flight['hasArrived'] = now > arrivalTime
+        return flight['hasArrived']
+    },
     setNumberTransform() {
       const numberItems = this.$refs.numberItem // 拿到数字的ref,计算元素数量
       const numberArr = this.orderNum.filter(item => !isNaN(item))
@@ -734,6 +754,12 @@ export default {
           }
         }
       }
+      tr.bgl-delayed td {
+        background: #fcf0b1;
+      }
+      tr.bgl-canceled td {
+        background: #f7babe;
+      }
     }
     .el-table__cell.is-hidden > * {
       visibility: visible;

+ 28 - 5
src/views/baggageManagement/components/departure/index.vue

@@ -1,7 +1,7 @@
 <!--
  * @Author: zk
  * @Date: 2022-01-17 10:39:22
- * @LastEditTime: 2022-06-10 09:14:24
+ * @LastEditTime: 2022-06-13 17:56:26
  * @LastEditors: your name
  * @Description: 离港01
 -->
@@ -385,7 +385,8 @@ export default {
       AirportList: [],
       loopEvent: null,
       leaveCount: 0,
-      baggageCount: 0
+      baggageCount: 0,
+      hasSetTableScroll: false
     }
   },
   created() {
@@ -398,11 +399,20 @@ export default {
     }, 3000)
   },
   beforeDestroy() {
-    clearInterval(this.loopEvent)
+    if (this.loopEvent) {
+      clearInterval(this.loopEvent)
+      this.loopEvent = null
+    }
   },
   methods: {
     airPortChange() {
-      this.getTableData()
+      if (this.loopEvent) {
+        clearInterval(this.loopEvent)
+      }
+      const that = this
+      this.loopEvent = setInterval(function () {
+        that.getTableData()
+      }, 3000)
     },
     async getAirPortData() {
       try {
@@ -474,7 +484,10 @@ export default {
           console.log(res.message)
         }
       } catch (error) {
-        clearInterval(this.loopEvent)
+        if (this.loopEvent) {
+          clearInterval(this.loopEvent)
+          this.loopEvent = null
+        }
         console.log('出错了', error)
       }
     },
@@ -496,6 +509,16 @@ export default {
       //   this.baggageCount = this.baggageCount+1;
       //    // 这里输入数字即可调用
       // }, 2000);
+      this.setTableScroll()
+    },
+    setTableScroll() {
+      if (this.hasSetTableScroll) {
+        return
+      }
+      const table = this.$refs['table']
+      console.dir(table.$el)
+      // this.$refs['table'].setCurrentRow(this.tableData[this.leaveCount - 1])
+      this.hasSetTableScroll = true
     },
     setNumberTransform() {
       const numberItems = this.$refs.numberItem // 拿到数字的ref,计算元素数量