فهرست منبع

keepAlive修改

zhongxiaoyu 2 سال پیش
والد
کامیت
c587453d43

+ 28 - 12
src/layout/components/AppMain.vue

@@ -9,12 +9,20 @@
 <template>
   <section class="app-main">
     <div class="app-main-content">
-      <transition name="fade-transform" mode="out-in">
-        <keep-alive v-if="$route.meta && $route.meta.keepAlive" :max="6">
-          <router-view :key="key" class="router-view">
-          </router-view>
+      <transition
+        name="fade-transform"
+        mode="out-in"
+      >
+        <keep-alive
+          v-if="$route.meta && $route.meta.keepAlive"
+          :max="6"
+        >
+          <router-view :key="key" />
         </keep-alive>
-        <router-view :key="key" v-else class="router-view"></router-view>
+        <router-view
+          v-else
+          :key="key"
+        />
       </transition>
     </div>
   </section>
@@ -22,13 +30,18 @@
 
 <script>
 export default {
-  name: "AppMain",
+  name: 'AppMain',
   computed: {
-    key () {
-      return this.$route.name;
-    },
-  },
-};
+    key() {
+      return Object.keys(this.$route.query).reduce((string, currentKey, index) => {
+        if (currentKey !== 'fastFilter') {
+          string += `${index ? '&' : '?'}${currentKey}=${this.$route.query[currentKey]}`
+        }
+        return string
+      }, this.$route.path)
+    }
+  }
+}
 </script>
 
 <style scoped>
@@ -51,7 +64,10 @@ export default {
 }
 </style>
 
-<style scoped lang="scss">
+<style
+  scoped
+  lang="scss"
+>
 // fix css style bug in open el-dialog
 .el-popup-parent--hidden {
   .fixed-header {

+ 36 - 42
src/views/baggageManagement/components/baggage/index.vue

@@ -447,27 +447,6 @@ export default {
     }
   },
   watch: {
-    $route: {
-      handler({ path, query }) {
-        this.infoBtn = ''
-        if (path.includes('baggageView')) {
-          const { flightNO, flightDate, bagSN } = query
-          if (flightNO && flightDate && bagSN) {
-            if (Object.keys(this.queryData).some(key => this.queryData[key] !== query[key])) {
-              this.resetSettings()
-            }
-            this.queryData = { flightNO, flightDate, bagSN }
-            this.queryBasicInfo()
-            this.queryAirline()
-            this.infoBtn = this.infoRadios[0]
-          } else {
-            this.$router.push('/')
-          }
-        }
-      },
-      deep: true,
-      immediate: true
-    },
     infoBtn: {
       handler(val) {
         this.stopLoopAll()
@@ -489,6 +468,15 @@ export default {
   },
   created() {
     this.resetStepNodes()
+    const { flightNO, flightDate, bagSN } = this.$route.query
+    if (flightNO && flightDate && bagSN) {
+      this.queryData = { flightNO, flightDate, bagSN }
+      this.queryBasicInfo()
+      this.queryAirline()
+      this.infoBtn = this.infoRadios[0]
+    } else {
+      this.$router.push('/')
+    }
   },
   activated() {
     this.resizeHandler()
@@ -499,25 +487,14 @@ export default {
     this.resizeHandler()
   },
   deactivated() {
-    window.removeEventListener('resize', this.debouncedResizeHandler)
-  },
-  beforeDestroy() {
     this.stopLoopAll()
+    window.removeEventListener('resize', this.debouncedResizeHandler)
   },
   methods: {
     resizeHandler() {
       this.basicInfoHeight = this.$refs['basicInfo'].offsetHeight
       this.$refs['table']?.doLayout()
     },
-    resetSettings() {
-      this.initTableCols()
-      // Object.keys(this.filterValues).forEach(key => {
-      //   this.filterValues[key] = []
-      // })
-      // Object.keys(this.tableDataSortRules).forEach(key => {
-      //   this.tableDataSortRules[key] = ''
-      // })
-    },
     baggageBasicInfoClickHandler(prop) {
       if (prop !== 'compensationSign') {
         return
@@ -810,6 +787,31 @@ export default {
       }
     },
     async queryDetails(queryData = this.queryData) {
+      function setDataSource(item) {
+        if (item['b_type'] !== 'BSM') {
+          const resourceCode = item['resourceFile']?.slice(-4)
+          switch (resourceCode) {
+            case '0100':
+              if (
+                (item['DeviceCode'] && item['DeviceCode'].toUpperCase() === 'STARHUB') ||
+                (!item['DeviceCode'] && !['LOAD', 'INFL'].includes(item['nodeCode']))
+              ) {
+                item['dataSource'] = 'Manual Load'
+              } else {
+                item['dataSource'] = 'BRS'
+              }
+              break
+            case '0101':
+              item['dataSource'] = 'RFID'
+              break
+            case '0102':
+              item['dataSource'] = '首都机场'
+              break
+            default:
+              break
+          }
+        }
+      }
       const { flightNO, flightDate, bagSN } = queryData
       const dataContent = [flightNO, flightDate, bagSN]
       try {
@@ -824,15 +826,7 @@ export default {
           item['landingInfo'] = `${item['landingAirport']}\n${
             item['landingTime'] ? item['landingTime'].replace('T', '\n') : ''
           }`
-          if (item['b_type'] !== 'BSM') {
-            const codeReflect = {
-              '0100': 'Manual Load',
-              '0101': 'RFID',
-              '0102': 'BRS'
-            }
-            const resourceCode = item['resourceFile']?.slice(-4)
-            item['dataSource'] = codeReflect[resourceCode] ?? ''
-          }
+          setDataSource(item)
           return item
         })
         this.initTableData(this.baggageTableData)

+ 7 - 43
src/views/baggageManagement/components/container/index.vue

@@ -294,37 +294,6 @@ export default {
     }
   },
   watch: {
-    $route: {
-      handler({ path, query }) {
-        if (path.includes('containerView')) {
-          const { flightNO, flightDate, departureAirport, landingAirport, containerID } = query
-          if (flightNO && flightDate && departureAirport && landingAirport && containerID) {
-            const {
-              flightNO: oldFlightNO,
-              flightDate: oldFlightDate,
-              departureAirport: oldDepartureAirport,
-              landingAirport: oldLandingAirport,
-              containerID: oldContainerID
-            } = this.queryData
-            if (
-              flightNO !== oldFlightNO ||
-              flightDate !== oldFlightDate ||
-              departureAirport !== oldDepartureAirport ||
-              landingAirport !== oldLandingAirport ||
-              containerID !== oldContainerID
-            ) {
-              this.resetSettings()
-              this.queryData = { flightNO, flightDate, departureAirport, landingAirport, containerID }
-              this.queryContainerBaggage([flightNO, flightDate, departureAirport, landingAirport, containerID])
-            }
-          } else {
-            this.$router.push('/')
-          }
-        }
-      },
-      deep: true,
-      immediate: true
-    },
     loading(val) {
       if (val) {
         this.fullscreenLoading = this.$loading({
@@ -339,6 +308,13 @@ export default {
     }
   },
   created() {
+    const { flightNO, flightDate, departureAirport, landingAirport, containerID } = this.$route.query
+    if (flightNO && flightDate && departureAirport && landingAirport && containerID) {
+      this.queryData = { flightNO, flightDate, departureAirport, landingAirport, containerID }
+      this.queryContainerBaggage([flightNO, flightDate, departureAirport, landingAirport, containerID])
+    } else {
+      this.$router.push('/')
+    }
     Object.values(this.tableCols).forEach(({ prop, filterable, sortable }) => {
       if (filterable) {
         this.$set(this.tableDataFilters, prop, [])
@@ -358,9 +334,6 @@ export default {
   deactivated() {
     this.fullscreenLoading?.close()
   },
-  beforeDestroy() {
-    this.fullscreenLoading?.close()
-  },
   methods: {
     setTableHeight() {
       const headerHeight = 80
@@ -374,15 +347,6 @@ export default {
         this.$refs['table']?.doLayout()
       })
     },
-    resetSettings() {
-      this.initTableCols()
-      Object.keys(this.filterValues).forEach(key => {
-        this.filterValues[key] = []
-      })
-      Object.keys(this.tableDataSortRules).forEach(key => {
-        this.tableDataSortRules[key] = ''
-      })
-    },
     rowClass({ row, rowIndex }) {
       const classes = []
       if (row['isDEL'] === 'DEL') {

+ 7 - 33
src/views/baggageManagement/components/containerHistory/index.vue

@@ -228,28 +228,14 @@ export default {
       return this._.orderBy(filtered, sortRules[0], sortRules[1])
     }
   },
-  watch: {
-    $route: {
-      handler({ path, query }) {
-        if (path.includes('containerHistory')) {
-          const { containerID } = query
-          if (containerID) {
-            this.resetSettings()
-            const { containerID: oldContainerID } = this.queryData
-            if (containerID !== oldContainerID) {
-              this.queryData = { containerID }
-              this.queryContainerHistory([containerID])
-            }
-          } else {
-            this.$router.push('/')
-          }
-        }
-      },
-      deep: true,
-      immediate: true
-    }
-  },
   created() {
+    const { containerID } = this.$route.query
+    if (containerID) {
+      this.queryData = { containerID }
+      this.queryContainerHistory([containerID])
+    } else {
+      this.$router.push('/')
+    }
     Object.values(this.tableCols).forEach(({ prop, filterable, sortable }) => {
       if (filterable) {
         this.$set(this.tableDataFilters, prop, [])
@@ -270,19 +256,7 @@ export default {
     this.treeLoading = false
     this.tableLoading = false
   },
-  beforeDestroy() {
-    this.treeLoading = false
-    this.tableLoading = false
-  },
   methods: {
-    resetSettings() {
-      Object.keys(this.filterValues).forEach(key => {
-        this.filterValues[key] = []
-      })
-      Object.keys(this.tableDataSortRules).forEach(key => {
-        this.tableDataSortRules[key] = ''
-      })
-    },
     currentChangeHandler({ index }) {
       if (index > -1) {
         this.selectedHistoryData = this.containerHistory[index]

+ 62 - 92
src/views/baggageManagement/components/flight/index.vue

@@ -377,7 +377,7 @@
         :style="draggableStyle"
       >
         <div
-          v-drag-height
+          ref="dragBox"
           class="drag-box"
           :class="{ active: dragActive }"
         >
@@ -521,43 +521,7 @@ import { throttledExportToExcel } from '@/utils/table'
 
 export default {
   name: 'FlightView',
-  directives: {
-    dragHeight: {
-      inserted(el, binding, vnode) {
-        const that = vnode.context
-        let mousedownY
-        let dragY
-        let dragHeight
-        const offsetTop = el.offsetParent.offsetTop
-        function mousemoveHandler(e) {
-          e.stopPropagation()
-          e.preventDefault()
-          dragY = dragHeight + mousedownY - e.screenY
-          dragY = dragY < 0 ? 0 : dragY > offsetTop ? offsetTop : dragY
-          that.dragY = dragY
-        }
-        function mouseupHandler(e) {
-          e.stopPropagation()
-          e.preventDefault()
-          that.dragHeight = that.dragY
-          that.dragY = 0
-          that.dragActive = false
-          document.removeEventListener('mousemove', mousemoveHandler)
-          document.removeEventListener('mouseup', mouseupHandler)
-        }
-        el.addEventListener('mousedown', e => {
-          that.dragActive = true
-          mousedownY = e.screenY
-          dragHeight = that.dragHeight
-          that.dragY = dragHeight
-          document.addEventListener('mousemove', mousemoveHandler)
-          document.addEventListener('mouseup', mouseupHandler)
-        })
-      }
-    }
-  },
   components: {
-    // BackButton,
     Dialog,
     TimeZoneSelector,
     TableHeaderCell
@@ -595,7 +559,6 @@ export default {
       //   { label: '中转数', prop: 'transferNumber' }
       // ],
       tableCols: [
-        // { label: '序号', prop: 'index' },
         {
           label: '旅客姓名',
           prop: 'PassengerNameUpcase',
@@ -878,46 +841,6 @@ export default {
     }
   },
   watch: {
-    $route: {
-      handler({ path, query }) {
-        if (path.includes('flightView')) {
-          const { flightNO, flightDate, departureAirport, landingAirport, fastFilter } = query
-          if (flightNO && flightDate) {
-            if (Object.keys(this.queryData).some(key => this.queryData[key] !== query[key])) {
-              this.resetSettings()
-            }
-            const {
-              flightNO: oldFlightNO,
-              flightDate: oldFlightDate,
-              departureAirport: oldDepartureAirport,
-              landingAirport: oldLandingAirport
-            } = this.queryData
-            if (flightNO !== oldFlightNO || flightDate !== oldFlightDate) {
-              this.queryAirline([flightNO, flightDate])
-            } else if (departureAirport !== oldDepartureAirport || landingAirport !== oldLandingAirport) {
-              if (this.airlineList.length) {
-                let currentIndex = this.airlineList.findIndex(
-                  ({ value }) => value === `${departureAirport}-${landingAirport}`
-                )
-                currentIndex = currentIndex > -1 ? currentIndex : 0
-                this.selectedAirline = this.airlineList[currentIndex].value
-              }
-            }
-            this.selectedFilter = fastFilter ? fastFilter.split(',') : []
-            this.queryData = {
-              flightNO,
-              flightDate,
-              departureAirport,
-              landingAirport
-            }
-          } else {
-            this.$router.push('/')
-          }
-        }
-      },
-      deep: true,
-      immediate: true
-    },
     loading(val) {
       if (val) {
         this.fullscreenLoading = this.$loading({
@@ -937,9 +860,33 @@ export default {
       const { flightNO, flightDate } = this.queryData
       const [departureAirport, landingAirport] = val.split('-')
       this.queryAll([flightNO, flightDate, departureAirport, landingAirport])
+    },
+    selectedFilter(val) {
+      const { path, query } = this.$route
+      const newQuery = { ...query }
+      delete newQuery.fastFilter
+      if (val.length) {
+        newQuery.fastFilter = val.join(',')
+      }
+      this.$router.replace({
+        path,
+        query: newQuery
+      })
     }
   },
   created() {
+    const { flightNO, flightDate, departureAirport, landingAirport } = this.$route.query
+    if (flightNO && flightDate) {
+      this.queryAirline([flightNO, flightDate])
+      this.queryData = {
+        flightNO,
+        flightDate,
+        departureAirport,
+        landingAirport
+      }
+    } else {
+      this.$router.push('/')
+    }
     Object.values(this.tableCols).forEach(({ prop, filterable, sortable }) => {
       if (filterable) {
         this.$set(this.flightBaggageTableFilters, prop, [])
@@ -950,40 +897,63 @@ export default {
       }
     })
   },
+  mounted() {
+    this.setDragBox()
+  },
   updated() {
     this.resizeHandler()
   },
   activated() {
+    const { fastFilter } = this.$route.query
+    this.selectedFilter = fastFilter ? fastFilter.split(',') : []
     this.getWarningData()
     this.resizeHandler()
     this.debouncedResizeHandler = this._.debounce(this.resizeHandler, this.debounceTime)
     window.addEventListener('resize', this.debouncedResizeHandler)
   },
   deactivated() {
-    this.dragHeight = 0
-    this.dragY = 0
     this.fullscreenLoading?.close()
     window.removeEventListener('resize', this.debouncedResizeHandler)
   },
-  beforeDestroy() {
-    this.fullscreenLoading?.close()
-  },
   methods: {
+    setDragBox() {
+      const dragBox = this.$refs['dragBox']
+      const offsetTop = dragBox.offsetParent.offsetTop
+      const that = this
+      let mousedownY
+      let dragY
+      let dragHeight
+      function mousemoveHandler(e) {
+        e.stopPropagation()
+        e.preventDefault()
+        dragY = dragHeight + mousedownY - e.screenY
+        dragY = dragY < 0 ? 0 : dragY > offsetTop ? offsetTop : dragY
+        that.dragY = dragY
+      }
+      function mouseupHandler(e) {
+        e.stopPropagation()
+        e.preventDefault()
+        that.dragHeight = that.dragY
+        that.dragY = 0
+        that.dragActive = false
+        document.removeEventListener('mousemove', mousemoveHandler)
+        document.removeEventListener('mouseup', mouseupHandler)
+      }
+      dragBox.addEventListener('mousedown', e => {
+        that.dragActive = true
+        mousedownY = e.screenY
+        dragHeight = that.dragHeight
+        that.dragY = dragHeight
+        document.addEventListener('mousemove', mousemoveHandler)
+        document.addEventListener('mouseup', mouseupHandler)
+      })
+    },
     resizeHandler() {
       this.$refs['containerTable']?.doLayout()
       // this.$refs['transferInBaggageTable']?.doLayout()
       // this.$refs['transferOutBaggageTable']?.doLayout()
       this.$refs['flightBaggageTable']?.doLayout()
     },
-    resetSettings() {
-      this.initTableCols()
-      Object.keys(this.filterValues).forEach(key => {
-        this.filterValues[key] = []
-      })
-      Object.keys(this.tableDataSortRules).forEach(key => {
-        this.tableDataSortRules[key] = ''
-      })
-    },
     setfastFilterValues() {
       const inFlightNOList = new Set()
       const transferFlightNOList = new Set()

+ 0 - 1
src/views/baggageManagement/mixins/tableCols.js

@@ -50,7 +50,6 @@ export default {
       setTableCols(this.tableCols)
       this.tableColsCopy = this._.cloneDeep(this.tableCols)
       this.checkedKeysTemp = [...this.checkedKeys]
-      this.$refs['columnSetTree']?.setCheckedKeys(this.checkedKeysTemp)
     },
     // 列设置-确定
     handleCheck(data, checked) {