zhaoke 1 жил өмнө
parent
commit
40ab6c5ec5

+ 45 - 20
src/views/bagDetailsPage/components/baggageMessage.vue

@@ -31,18 +31,10 @@
 import * as XLSX from 'xlsx'
 import XLSX_STYLE from 'xlsx-style'
 import FileSaver from 'file-saver'
+import { Query } from '@/api/webApi'
 export default {
   name: 'BaggageMessage',
-  props: {
-    query: {
-      type: Object,
-      default: () => { }
-    },
-    tagObj: {
-      type: Object,
-      default: () => { }
-    }
-  },
+  props: ['queryItem'],
   data () {
     return {
       messageList: [],
@@ -51,17 +43,15 @@ export default {
     }
   },
   watch: {
-    tagObj: {
-      handler (obj) {
-        this.dataContent = obj
-        this.queryDetails()
+    queryItem: {
+      handler (val) {
+        if (val) {
+          this.queryDetails()
+        }
       },
       deep: true
     }
   },
-  created () {
-    this.dataContent = this.tagObj
-  },
   mounted () {
     this.queryDetails()
   },
@@ -69,7 +59,38 @@ export default {
     async queryDetails () {
       try {
         this.loading = true
-        const { code, returnData } = await this.getQueryList(SERVICE_ID.bagDetailId, this.dataContent)
+        const bagQueryParams = JSON.parse(sessionStorage.getItem('bagQueryParams')) || ''
+        if (!bagQueryParams) return
+        const { PNRNO, luggageNum, carrierFlights, carrierFlightsDate } = bagQueryParams
+        let queryHttp = null
+        if (PNRNO) {
+          const parmas = {
+            page: 1,
+            serviceid: 121,
+            datacontent: {
+              filter: {
+                PNRNO,
+                luggageNum
+              }
+            },
+            event: '0'
+          }
+          queryHttp = await Query(parmas)
+        } else {
+          const parmas = {
+            page: 1,
+            serviceid: 120,
+            datacontent: {
+              filter: {
+                carrierFlights,
+                luggageNum
+              }
+            },
+            event: '0'
+          }
+          queryHttp = await Query(parmas)
+        }
+        const { code, returnData } = queryHttp
         if (code == 0 && returnData && returnData.length) {
           // this.messageList = [...returnData]
           const messageDatas = [...returnData]
@@ -101,6 +122,10 @@ export default {
       }
     },
     exportMessageToExcel () {
+      if (!this.messageList.length) {
+        this.$message.warning('暂无数据')
+        return
+      }
       const xlsxDatas = [['Date & Time', 'Message']]
       xlsxDatas.push(
         ...this.messageList.map(message => [
@@ -189,8 +214,8 @@ export default {
         cellStyles: true
       })
       // 下载表格
-      const { luggageNum, flightNo, flightDate } = this.query
-      const fileName = `行李原始报文-${luggageNum}-${flightNo}-${flightDate}.xlsx`
+      const { luggageNum, carrierFlights, carrierFlightsDate } = this.$route.query
+      const fileName = `行李原始报文-${luggageNum}-${carrierFlights}-${carrierFlightsDate}.xlsx`
       FileSaver.saveAs(new Blob([tableWrite], { type: 'application/octet-stream' }), fileName)
     },
   }