소스 검색

高级查询缓存问题

zhongxiaoyu 2 년 전
부모
커밋
8ecd9d73be

+ 2 - 2
src/layout/components/AppMain.vue

@@ -10,7 +10,7 @@
   <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">
+        <keep-alive v-if="$route.meta && $route.meta.keepAlive" :max="10">
           <router-view  :key="key"  class="router-view">
           </router-view>
         </keep-alive>
@@ -25,7 +25,7 @@ export default {
   name: "AppMain",
   computed: {
     key() {
-      return this.$route.path;
+      return this.$route.name;
     },
   },
 };

+ 13 - 26
src/router/routes/routes-file-five.js

@@ -32,8 +32,6 @@ const departureRoutes = {
             roles: ['departure_page'],
             keepAlive: true
           },
-          redirect: '/departure',
-          // redirect: "/departure/baggageView",
           children: [
             {
               path: '/departure',
@@ -57,7 +55,7 @@ const departureRoutes = {
                   path: '/departure/baggageView',
                   name: 'DepartureBaggageView',
                   component: () => import('@/views/baggageManagement/components/departure/baggage'),
-                  meta: { title: '行李视图', keepAlive: false }
+                  meta: { title: '行李视图', keepAlive: true }
                 }
               ]
             }
@@ -87,7 +85,6 @@ const arrivalRoutes = {
           name: 'ArrivalOne',
           component: () => import('@/views/baggageManagement'),
           meta: { title: '进港视图', roles: ['inbound_search_page'], keepAlive: true },
-          redirect: '/arrival',
           children: [
             {
               path: '/arrival',
@@ -111,7 +108,7 @@ const arrivalRoutes = {
                   path: '/arrival/baggageView',
                   name: 'ArrivalBaggageView',
                   component: () => import('@/views/baggageManagement/components/arrival/baggage'),
-                  meta: { title: '行李视图', keepAlive: false }
+                  meta: { title: '行李视图', keepAlive: true }
                 }
               ]
             }
@@ -142,7 +139,6 @@ const transferRoutes = {
           name: 'TransferArrivalOne',
           component: () => import('@/views/baggageManagement'),
           meta: { title: '中转进港', roles: ['transit_inbound_page'], keepAlive: true },
-          redirect: '/transfer/arrival',
           children: [
             {
               path: '/transfer/arrival',
@@ -166,7 +162,7 @@ const transferRoutes = {
                   path: '/transfer/arrival/baggageView',
                   name: 'TransferArrivalBaggageView',
                   component: () => import('@/views/baggageManagement/components/transferArrival/baggage'),
-                  meta: { title: '行李视图', keepAlive: false }
+                  meta: { title: '行李视图', keepAlive: true }
                 }
               ]
             }
@@ -177,7 +173,6 @@ const transferRoutes = {
           name: 'TransferDepartureOne',
           component: () => import('@/views/baggageManagement'),
           meta: { title: '中转离港', roles: ['transit_departure_page'], keepAlive: true },
-          redirect: '/transfer/departure',
           children: [
             {
               path: '/transfer/departure',
@@ -201,7 +196,7 @@ const transferRoutes = {
                   path: '/transfer/departure/baggageView',
                   name: 'TransferDepartureBaggageView',
                   component: () => import('@/views/baggageManagement/components/transferDeparture/baggage'),
-                  meta: { title: '行李视图', keepAlive: false }
+                  meta: { title: '行李视图', keepAlive: true }
                 }
               ]
             }
@@ -223,41 +218,33 @@ const advanceRoutes = {
       component: () => import('@/views/advancedQuery/index.vue'),
       meta: {
         title: '高级查询',
-        icon: 'dataParser',
         imgstyle: 'ic_list_nav_search_default.png',
         imgstyleup: 'ic_list_nav_search_check.png'
       },
       children: [
         {
-          path: '/',
-          name: 'AdvancedHome',
-          component: {
-            render (c) {
-              return c('router-view')
-            }
-          },
-          redirect: '/',
+          path: '/advance',
+          name: 'AdvancedQuery',
+          component: () => import('@/views/advancedQuery/index.vue'),
           meta: { title: '高级查询', isPage: 'advance_page', keepAlive: true },
           children: [
             {
-              path: '/',
+              path: '/advance',
+              name: 'AdvancedHome',
               component: () => import('@/views/advancedQuery/views/advancedHome.vue'),
-              meta: {
-                title: '高级查询',
-                keepAlive: true
-              }
+              meta: { keepAlive: true }
             },
             {
               path: 'flightView',
-              name: 'advancedFlight',
+              name: 'AdvancedFlight',
               component: () => import('@/views/advancedQuery/views/advancedFlight.vue'),
               meta: { title: '航班视图', keepAlive: true }
             },
             {
               path: 'baggageView',
-              name: 'advancedBag',
+              name: 'AdvancedBag',
               component: () => import('@/views/advancedQuery/views/advancedBag.vue'),
-              meta: { title: '行李视图', keepAlive: false }
+              meta: { title: '行李视图', keepAlive: true }
             }
           ]
         }

+ 8 - 2
src/views/advancedQuery/index.vue

@@ -1,3 +1,9 @@
 <template>
-  <router-view></router-view>
-</template>
+  <router-view />
+</template>
+
+<script>
+export default {
+  name: 'AdvancedQuery'
+}
+</script>

+ 32 - 30
src/views/advancedQuery/views/advancedHome.vue

@@ -719,6 +719,34 @@ export default {
     }
   },
   watch: {
+    '$route.query': {
+      handler(query) {
+        let queryFlag = false
+        const { startDate, endDate, singleJump } = query
+        const queryEntries = Object.entries(query)
+        if (queryEntries.length) {
+          this.clearForm()
+        }
+        queryEntries.forEach(([key, value]) => {
+          if (!['startDate', 'endDate', 'singleJump'].includes(key) && (value ?? '') !== '') {
+            queryFlag = true
+            this.form[key] = ['unLoad', 'checkIn', 'active', 'transferIn', 'canceled', 'noBSM'].includes(key)
+              ? Number(value)
+              : value
+          }
+        })
+        if (startDate) {
+          this.$set(this.flightDate, 0, startDate)
+        }
+        if (endDate) {
+          this.$set(this.flightDate, 1, endDate)
+        }
+        if (queryFlag) {
+          this.onCheckGj(singleJump)
+        }
+      },
+      deep: true
+    },
     flightDate: {
       handler(val) {
         if (val === null) {
@@ -774,42 +802,16 @@ export default {
   },
   mounted() {
     this.baggageTypeQuery()
-    this.dom = this.$refs.table.bodyWrapper
     const that = this
+    this.dom = this.$refs.table.bodyWrapper
     this.dom.addEventListener('scroll', () => {
       that.scrollTop = this.dom.scrollTop
     })
+    console.log(1)
   },
   activated() {
-    let queryFlag = false
-    const query = this.$route.query
-    const { startDate, endDate, singleJump } = query
-    const queryEntries = Object.entries(query)
-    if (queryEntries.length) {
-      this.clearForm()
-    }
-    queryEntries.forEach(([key, value]) => {
-      if (!['startDate', 'endDate', 'singleJump'].includes(key) && (value ?? '') !== '') {
-        queryFlag = true
-        this.form[key] = ['unLoad', 'checkIn', 'active', 'transferIn', 'canceled', 'noBSM'].includes(key)
-          ? Number(value)
-          : value
-      }
-    })
-    if (startDate) {
-      this.$set(this.flightDate, 0, startDate)
-    }
-    if (endDate) {
-      this.$set(this.flightDate, 1, endDate)
-    }
-    // startDate && (this.flightDate[0] = startDate)
-    // endDate && (this.flightDate[1] = endDate)
-    if (queryFlag) {
-      this.onCheckGj(singleJump)
-    } else {
-      this.dom = this.$refs.table.bodyWrapper
-      this.dom.scrollTop = this.scrollTop
-    }
+    console.log(2)
+    this.dom.scrollTop = this.scrollTop
     // else if (this.queryForm) {
     //   Object.keys(this.form).forEach(key => {
     //     this.form[key] = this.queryForm[key]

+ 41 - 6
src/views/baggageManagement/components/baggage/index.vue

@@ -500,6 +500,27 @@ export default {
     }
   },
   watch: {
+    $route: {
+      handler({ path, query }) {
+        clearInterval(this.loopEvent)
+        this.loopEvent = null
+        clearInterval(this.queryMessageLoop)
+        this.queryMessageLoop = null
+
+        this.queryData = this._.cloneDeep(query)
+        const { flightNO, flightDate, bagSN } = this.queryData
+        if (flightNO && flightDate && bagSN) {
+          const that = this
+          this.queryBaggageAll()
+          this.loopEvent = setInterval(function () {
+            that.queryBaggageAll()
+          }, 3000)
+        } else if (path.includes('baggage')) {
+          this.$router.push('/advance')
+        }
+      },
+      deep: true
+    },
     infoBtn(val) {
       const that = this
       if (val === '跟踪报文') {
@@ -529,17 +550,31 @@ export default {
   },
   mounted() {
     this.queryData = this._.cloneDeep(this.$route.query)
-    // console.log(this.queryData)
-    const that = this
-    this.queryBaggageAll()
-    this.loopEvent = setInterval(function () {
-      that.queryBaggageAll()
-    }, 3000)
+    const { flightNO, flightDate, bagSN } = this.queryData
+    if (!flightNO || !flightDate || !bagSN) {
+      this.$router.push('/advance')
+    } else {
+      const that = this
+      this.queryBaggageAll()
+      this.loopEvent = setInterval(function () {
+        that.queryBaggageAll()
+      }, 3000)
+    }
+  },
+  activated() {
+    this.basicInfoHeight = this.$refs['basicInfo'].offsetHeight
+    this.$refs['table']?.doLayout()
   },
   updated() {
     this.basicInfoHeight = this.$refs['basicInfo'].offsetHeight
     this.$refs['table']?.doLayout()
   },
+  deactivated() {
+    clearInterval(this.loopEvent)
+    this.loopEvent = null
+    clearInterval(this.queryMessageLoop)
+    this.queryMessageLoop = null
+  },
   beforeDestroy() {
     clearInterval(this.loopEvent)
     this.loopEvent = null

+ 4 - 4
src/views/baggageManagement/components/flight/index.vue

@@ -681,12 +681,12 @@ export default {
   },
   watch: {
     $route: {
-      handler(val) {
-        this.queryData = this._.cloneDeep(val.query)
-        const { flightNO, flightDate } = this.queryData
+      handler({ path, query }) {
+        this.queryData = this._.cloneDeep(query)
+        const { flightNO, flightDate } = query
         if (flightNO && flightDate) {
           this.queryAll([flightNO, flightDate])
-        } else if (val.path.includes('flight')) {
+        } else if (path.includes('flight')) {
           this.$router.push('/advance')
         }
       },