Browse Source

报文过滤

zhaoke 7 months ago
parent
commit
7aa1696370
1 changed files with 69 additions and 8 deletions
  1. 69 8
      src/views/newBagDetails/components/baggageMessage.vue

+ 69 - 8
src/views/newBagDetails/components/baggageMessage.vue

@@ -21,6 +21,10 @@
         <el-empty :image-size="1" description="暂无数据" />
       </template>
     </div>
+    <div class="checkBtns">
+      <el-switch v-model="switchs" @change="switchsChange" active-color="#409EFF" :active-text="switchsTxt">
+      </el-switch>
+    </div>
     <div class="btns">
       <img class="btn-square btn-shadow" src="@/assets/baggage/ic_export.png" title="导出" @click="exportMessageToExcel">
     </div>
@@ -49,7 +53,10 @@ export default {
     return {
       messageList: [],
       loading: false,
-      dataContent: []
+      switchs: false,
+      switchsTxt: '未过滤',
+      dataContent: [],
+      messageListCopy: []
     }
   },
   watch: {
@@ -77,18 +84,41 @@ export default {
           const messageDatas = [...returnData]
           messageDatas.map(item => {
             const { dataObjectId, dataType } = item
-            const other = dataType == ('BSM' || 'bsm') ? '(航信)' : '(BRS)'
             if (dataObjectId && dataObjectId.length) {
               const len = dataObjectId.length
-              const popNums = [100, 101, 102].map(item => item.toString())
-              const target = dataObjectId.substring(len - 3, len)
-              const place = popNums.includes(target) ? '(国航)' : dataObjectId.substring(len - 5, len) == '10000' ? '(国航)' : dataObjectId.substring(len - 5, len) == '20021' ? other : other
+              let place = null
+              function popNums (num) {
+                return dataObjectId.substring(len - num, len)
+              }
+              // const popNums = [100, 101, 102].map(item => item.toString())
+              // const target = dataObjectId.substring(len - 3, len)
+              // const place = popNums.includes(target) ? '(国航)' : dataObjectId.substring(len - 5, len) == '10000' ? '(国航)' : dataObjectId.substring(len - 5, len) == '20021' ? other : other
+              const [target3, target5, target6] = [popNums(3), popNums(5), popNums(6)]
+              if (target3 == '100' || target5 == '10000') {
+                place = '(星盟)'
+              }
+              if (target3 == '101') {
+                place = '(航易行)'
+              }
+              if (target3 == '102') {
+                place = '(首都机场)'
+              }
+              if (target5 == '20021') {
+                place = dataType == ('BSM' || 'bsm') ? '(航信)' : '(BRS)'
+              }
+              if (target6 == '218602') {
+                place = '(山航)'
+              }
+              if (target6 == '218604') {
+                place = '(深航)'
+              }
               item.readTime = item.readTime ? item.readTime.replace('T', ' ') + place : item.createAt.replace('T', ' ') + place
             } else {
-              item.readTime = item.readTime ? item.readTime.replace('T', ' ') + other : item.createAt.replace('T', ' ') + other
+              item.readTime = item.readTime.replace('T', ' ') || item.createAt.replace('T', ' ')
             }
           })
-          this.messageList = messageDatas
+          this.messageList = _.cloneDeep(messageDatas)
+          this.messageListCopy = _.cloneDeep(messageDatas)
           // this.messageList = returnData.map(message => ({
           //   ...message,
           //   readTime: message.readTime ? `${message.readTime.replace('T', ' ')}(广州)` : '(北京)'
@@ -228,6 +258,31 @@ export default {
       }
       FileSaver.saveAs(new Blob([tableWrite], { type: 'application/octet-stream' }), fileName)
     },
+    switchsChange (val) {
+      if (!val) {
+        this.switchsTxt = '未过滤'
+        this.messageList = [...this.messageListCopy]
+      } else {
+        const ndata = _.cloneDeep(this.messageListCopy)
+        const nmap = []
+        const pattern = /[`~!@#$^\-&*()=|{}':;',\\\[\]\.<>\/?~!@#¥……&*()——|{}【】';:""'。,、?\s]/g
+        ndata.map(item => {
+          const nitem = item['sourceData'].replace(pattern, "")
+          item['sourceDataNew'] = nitem
+          nmap.push(item)
+        })
+        const narr1 = _.uniqBy([...nmap], 'sourceDataNew')
+        //const narr2 = _.differenceBy([...nmap], [...narr1], 'ID')
+        if (!narr1.length) {
+          this.switchs = false
+          this.$message.warning('当前报文无数据可过滤')
+          return
+        } else {
+          this.switchsTxt = '已过滤'
+          this.messageList = [...narr1]
+        }
+      }
+    }
   }
 }
 </script>
@@ -250,7 +305,7 @@ export default {
     margin-bottom: 12px;
     > .message-date {
       // width: 180px;
-      width: 200px;
+      width: 220px;
       height: 26px;
       line-height: 14px;
       font-size: 14px;
@@ -277,5 +332,11 @@ export default {
       margin-right: 16px;
     }
   }
+  .checkBtns {
+    position: absolute;
+    top: -45px;
+    right: 84px;
+    z-index: 10;
+  }
 }
 </style>