Browse Source

高级查询-表格筛选项排序

zhongxiaoyu 2 years ago
parent
commit
38ffbb6b83
1 changed files with 220 additions and 141 deletions
  1. 220 141
      src/views/advancedQuery/views/advancedHome.vue

+ 220 - 141
src/views/advancedQuery/views/advancedHome.vue

@@ -68,16 +68,20 @@
         <el-table-column
           prop="index"
           label="序号"
+          :width="60"
         />
         <el-table-column
           prop="FlightNO"
           label="航班号"
-          :filters="FlightNOItem"
+          :filters="tableFilters.FlightNO"
           :filter-method="filterHandler"
         >
           <template slot-scope="scope">
             <el-button
               size="mini"
+              style="text-overflow: ellipsis;
+                white-space: normal;
+                word-break: break-all;"
               @click="flightClickHandler(scope.row)"
             >{{ scope.row.FlightNO }}</el-button>
           </template>
@@ -85,30 +89,31 @@
         <el-table-column
           prop="FlightDate"
           label="航班日期"
-          :filters="FlightDateItem"
+          :filters="tableFilters.FlightDate"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="SourceAirport"
           label="起飞站"
-          :filters="SourceAirportItem"
+          :filters="tableFilters.SourceAirport"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="TargetAirport"
           label="目的地"
-          :filters="TargetAirportItem"
+          :filters="tableFilters.TargetAirport"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="PassengerNameUpcase"
           label="旅客姓名"
-          :filters="PassengerNameUpcaseItem"
+          :filters="tableFilters.PassengerNameUpcase"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="BagSN"
           label="行李牌号"
+          :width="130"
         >
           <template slot-scope="scope">
             <el-button
@@ -120,19 +125,20 @@
         <el-table-column
           prop="SpecialType"
           label="特殊行李类型"
-          :filters="SpecialTypeItem"
+          :width="130"
+          :filters="tableFilters.SpecialType"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="checkIn"
           label="值机"
-          :filters="checkInItem"
+          :filters="tableFilters.checkIn"
           :filter-method="filterHandler"
         />
         <el-table-column
           label="删除"
           prop="deleted"
-          :filters="deletedItem"
+          :filters="tableFilters.deleted"
           :filter-method="filterHandler"
         >
           <!-- <template slot-scope="scope">
@@ -142,7 +148,7 @@
         <el-table-column
           label="激活"
           prop="activated"
-          :filters="activatedItem"
+          :filters="tableFilters.activated"
           :filter-method="filterHandler"
         >
           <!-- <template slot-scope="scope">
@@ -156,19 +162,19 @@
         <el-table-column
           prop="latestStatus"
           label="最新状态"
-          :filters="latestStatusItem"
+          :filters="tableFilters.latestStatus"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="bagLocation"
           label="最新位置"
-          :filters="bagLocationItem"
+          :filters="tableFilters.bagLocation"
           :filter-method="filterHandler"
         />
         <el-table-column
           prop="TransferFlightNO"
           label="中转进航班"
-          :filters="TransferFlightNOItem"
+          :filters="tableFilters.TransferFlightNO"
           :filter-method="filterHandler"
         />
       </el-table>
@@ -401,18 +407,32 @@ export default {
         //   { required: true, message: "请输入有效航班号", trigger: "blur" },
         // ],
       },
-      PassengerNameUpcaseItem: [],
-      FlightNOItem: [],
-      FlightDateItem: [],
-      SourceAirportItem: [],
-      TargetAirportItem: [],
-      SpecialTypeItem: [],
-      checkInItem: [],
-      deletedItem: [],
-      activatedItem: [],
-      latestStatusItem: [],
-      bagLocationItem: [],
-      TransferFlightNOItem: []
+      // PassengerNameUpcaseItem: [],
+      // FlightNOItem: [],
+      // FlightDateItem: [],
+      // SourceAirportItem: [],
+      // TargetAirportItem: [],
+      // SpecialTypeItem: [],
+      // checkInItem: [],
+      // deletedItem: [],
+      // activatedItem: [],
+      // latestStatusItem: [],
+      // bagLocationItem: [],
+      // TransferFlightNOItem: [],
+      tableFilters: {
+        FlightNO: [],
+        FlightDate: [],
+        SourceAirport: [],
+        TargetAirport: [],
+        PassengerNameUpcase: [],
+        SpecialType: [],
+        checkIn: [],
+        deleted: [],
+        activated: [],
+        latestStatus: [],
+        bagLocation: [],
+        TransferFlightNO: []
+      }
     }
   },
   created() {
@@ -564,11 +584,24 @@ export default {
       }
     },
     // 表格行点击处理
-    flightClickHandler(row) {
-      this.$router.push({ path: '/advance/flightView', query: row })
+    flightClickHandler({ FlightNO, FlightDate }) {
+      this.$router.push({
+        path: '/advance/flightView',
+        query: {
+          FlightNO,
+          FlightDate
+        }
+      })
     },
-    baggageClickHandler(row) {
-      this.$router.push({ path: '/advance/baggageView', query: row })
+    baggageClickHandler({ FlightNO, FlightDate, BagSN }) {
+      this.$router.push({
+        path: '/advance/baggageView',
+        query: {
+          FlightNO,
+          FlightDate,
+          BagSN
+        }
+      })
     },
     // 综合查询
     async integratedQuery(obj = {}) {
@@ -596,9 +629,12 @@ export default {
         if (res.code == 0) {
           this.tableData = res.returnData.map((item, index) => {
             item['index'] = index + 1
+            item['deleted'] = item['deleted'] === 'DEL' ? 'DEL' : ''
+            item['activated'] = item['activated'] === 'I' ? '未激活' : '已激活'
             return item
           })
-          this.getTableFilterItem()
+          // this.getTableFilterItem()
+          this.setTableFilters(this.tableData, this.tableFilters)
         } else {
           this.$message.error(res.message)
         }
@@ -622,126 +658,169 @@ export default {
         console.log('出错了', error)
       }
     },
+    // 表格添加过滤条件
+    setTableFilters(tableData, filters) {
+      const tempFilters = {}
+      const tempArrays = {}
+      Object.keys(filters).forEach(key => {
+        tempFilters[key] = []
+        tempArrays[key] = []
+      })
+      tableData.forEach(item => {
+        Object.keys(tempFilters).forEach(key => {
+          if ((item[key] ?? '') !== '' && !tempArrays[key].includes(item[key])) {
+            tempArrays[key].push(item[key])
+            tempFilters[key].push({
+              text: item[key],
+              value: item[key]
+            })
+          }
+        })
+      })
+      Object.keys(tempFilters).forEach(key => {
+        filters[key] = this._.orderBy(tempFilters[key], o => o.value)
+      })
+    },
     filterHandler(value, row, column) {
       const property = column['property']
       return row[property] === value
     },
-    getTableFilterItem() {
-      let PassengerNameUpcaseItemArr = [],
-        FlightNOItemArr = [],
-        FlightDateItemArr = [],
-        SourceAirportItemArr = [],
-        TargetAirportItemArr = [],
-        SpecialTypeItemArr = [],
-        checkInItemArr = [],
-        deletedItemArr = [],
-        activatedItemArr = [],
-        latestStatusItemArr = [],
-        bagLocationItemArr = [],
-        TransferFlightNOItemArr = []
+    // getTableFilterItem() {
+    //   let PassengerNameUpcaseItemArr = [],
+    //     FlightNOItemArr = [],
+    //     FlightDateItemArr = [],
+    //     SourceAirportItemArr = [],
+    //     TargetAirportItemArr = [],
+    //     SpecialTypeItemArr = [],
+    //     checkInItemArr = [],
+    //     deletedItemArr = [],
+    //     activatedItemArr = [],
+    //     latestStatusItemArr = [],
+    //     bagLocationItemArr = [],
+    //     TransferFlightNOItemArr = []
 
-      this.PassengerNameUpcaseItem.length = 0
-      this.FlightNOItem.length = 0
-      this.FlightDateItem.length = 0
-      this.SourceAirportItem.length = 0
-      this.TargetAirportItem.length = 0
-      this.SpecialTypeItem.length = 0
-      this.checkInItem.length = 0
-      this.deletedItem.length = 0
-      this.activatedItem.length = 0
-      this.latestStatusItem.length = 0
-      this.bagLocationItem.length = 0
-      this.TransferFlightNOItem.length = 0
+    //   this.PassengerNameUpcaseItem.length = 0
+    //   this.FlightNOItem.length = 0
+    //   this.FlightDateItem.length = 0
+    //   this.SourceAirportItem.length = 0
+    //   this.TargetAirportItem.length = 0
+    //   this.SpecialTypeItem.length = 0
+    //   this.checkInItem.length = 0
+    //   this.deletedItem.length = 0
+    //   this.activatedItem.length = 0
+    //   this.latestStatusItem.length = 0
+    //   this.bagLocationItem.length = 0
+    //   this.TransferFlightNOItem.length = 0
 
-      this.tableData.forEach(item => {
-        if (PassengerNameUpcaseItemArr.indexOf(item.PassengerNameUpcase) == -1 && item.PassengerNameUpcase != ''&& item.PassengerNameUpcase != null) {
-          PassengerNameUpcaseItemArr.push(item.PassengerNameUpcase)
-          this.PassengerNameUpcaseItem.push({
-            text: item.PassengerNameUpcase,
-            value: item.PassengerNameUpcase
-          })
-        }
-        if (FlightNOItemArr.indexOf(item.FlightNO) == -1 && item.FlightNO != ''&& item.FlightNO != null) {
-          FlightNOItemArr.push(item.FlightNO)
-          this.FlightNOItem.push({
-            text: item.FlightNO,
-            value: item.FlightNO
-          })
-        }
+    //   this.tableData.forEach(item => {
+    //     if (
+    //       PassengerNameUpcaseItemArr.indexOf(item.PassengerNameUpcase) == -1 &&
+    //       item.PassengerNameUpcase != '' &&
+    //       item.PassengerNameUpcase != null
+    //     ) {
+    //       PassengerNameUpcaseItemArr.push(item.PassengerNameUpcase)
+    //       this.PassengerNameUpcaseItem.push({
+    //         text: item.PassengerNameUpcase,
+    //         value: item.PassengerNameUpcase
+    //       })
+    //     }
+    //     if (FlightNOItemArr.indexOf(item.FlightNO) == -1 && item.FlightNO != '' && item.FlightNO != null) {
+    //       FlightNOItemArr.push(item.FlightNO)
+    //       this.FlightNOItem.push({
+    //         text: item.FlightNO,
+    //         value: item.FlightNO
+    //       })
+    //     }
 
-        if (FlightDateItemArr.indexOf(item.FlightDate) == -1 && item.FlightDate != ''&& item.FlightDate != null) {
-          FlightDateItemArr.push(item.FlightDate)
-          this.FlightDateItem.push({
-            text: item.FlightDate,
-            value: item.FlightDate
-          })
-        }
-        if (SourceAirportItemArr.indexOf(item.SourceAirport) == -1 && item.SourceAirport != ''&& item.SourceAirport != null) {
-          SourceAirportItemArr.push(item.SourceAirport)
-          this.SourceAirportItem.push({
-            text: item.SourceAirport,
-            value: item.SourceAirport
-          })
-        }
-        if (TargetAirportItemArr.indexOf(item.TargetAirport) == -1 && item.TargetAirport != ''&& item.TargetAirport != null) {
-          TargetAirportItemArr.push(item.TargetAirport)
-          this.TargetAirportItem.push({
-            text: item.TargetAirport,
-            value: item.TargetAirport
-          })
-        }
-        if (SpecialTypeItemArr.indexOf(item.SpecialType) == -1 && item.SpecialType != ''&& item.SpecialType != null) {
-          SpecialTypeItemArr.push(item.SpecialType)
-          this.SpecialTypeItem.push({
-            text: item.SpecialType,
-            value: item.SpecialType
-          })
-        }
+    //     if (FlightDateItemArr.indexOf(item.FlightDate) == -1 && item.FlightDate != '' && item.FlightDate != null) {
+    //       FlightDateItemArr.push(item.FlightDate)
+    //       this.FlightDateItem.push({
+    //         text: item.FlightDate,
+    //         value: item.FlightDate
+    //       })
+    //     }
+    //     if (
+    //       SourceAirportItemArr.indexOf(item.SourceAirport) == -1 &&
+    //       item.SourceAirport != '' &&
+    //       item.SourceAirport != null
+    //     ) {
+    //       SourceAirportItemArr.push(item.SourceAirport)
+    //       this.SourceAirportItem.push({
+    //         text: item.SourceAirport,
+    //         value: item.SourceAirport
+    //       })
+    //     }
+    //     if (
+    //       TargetAirportItemArr.indexOf(item.TargetAirport) == -1 &&
+    //       item.TargetAirport != '' &&
+    //       item.TargetAirport != null
+    //     ) {
+    //       TargetAirportItemArr.push(item.TargetAirport)
+    //       this.TargetAirportItem.push({
+    //         text: item.TargetAirport,
+    //         value: item.TargetAirport
+    //       })
+    //     }
+    //     if (SpecialTypeItemArr.indexOf(item.SpecialType) == -1 && item.SpecialType != '' && item.SpecialType != null) {
+    //       SpecialTypeItemArr.push(item.SpecialType)
+    //       this.SpecialTypeItem.push({
+    //         text: item.SpecialType,
+    //         value: item.SpecialType
+    //       })
+    //     }
 
-        if (checkInItemArr.indexOf(item.checkIn) == -1 && item.checkIn != ''&& item.checkIn != null) {
-          checkInItemArr.push(item.checkIn)
-          this.checkInItem.push({
-            text: item.checkIn,
-            value: item.checkIn
-          })
-        }
-        if (deletedItemArr.indexOf(item.deleted) == -1 && item.deleted != ''&& item.deleted != null) {
-          deletedItemArr.push(item.deleted)
-          this.deletedItem.push({
-            text: item.deleted,
-            value: item.deleted
-          })
-        }
-        if (activatedItemArr.indexOf(item.activated) == -1 && item.activated != ''&& item.activated != null) {
-          activatedItemArr.push(item.activated)
-          this.activatedItem.push({
-            text: item.activated,
-            value: item.activated
-          })
-        }
-        if (latestStatusItemArr.indexOf(item.latestStatus) == -1 && item.latestStatus != ''&& item.latestStatus != null) {
-          latestStatusItemArr.push(item.latestStatus)
-          this.latestStatusItem.push({
-            text: item.latestStatus,
-            value: item.latestStatus
-          })
-        }
-        if (bagLocationItemArr.indexOf(item.bagLocation) == -1 && item.bagLocation != ''&& item.bagLocation != null) {
-          bagLocationItemArr.push(item.bagLocation)
-          this.bagLocationItem.push({
-            text: item.bagLocation,
-            value: item.bagLocation
-          })
-        }
-        if (TransferFlightNOItemArr.indexOf(item.TransferFlightNO) == -1 && item.TransferFlightNO != ''&& item.TransferFlightNO != null) {
-          TransferFlightNOItemArr.push(item.TransferFlightNO)
-          this.TransferFlightNOItem.push({
-            text: item.TransferFlightNO,
-            value: item.TransferFlightNO
-          })
-        }
-      })
-    },
+    //     if (checkInItemArr.indexOf(item.checkIn) == -1 && item.checkIn != '' && item.checkIn != null) {
+    //       checkInItemArr.push(item.checkIn)
+    //       this.checkInItem.push({
+    //         text: item.checkIn,
+    //         value: item.checkIn
+    //       })
+    //     }
+    //     if (deletedItemArr.indexOf(item.deleted) == -1 && item.deleted != '' && item.deleted != null) {
+    //       deletedItemArr.push(item.deleted)
+    //       this.deletedItem.push({
+    //         text: item.deleted,
+    //         value: item.deleted
+    //       })
+    //     }
+    //     if (activatedItemArr.indexOf(item.activated) == -1 && item.activated != '' && item.activated != null) {
+    //       activatedItemArr.push(item.activated)
+    //       this.activatedItem.push({
+    //         text: item.activated,
+    //         value: item.activated
+    //       })
+    //     }
+    //     if (
+    //       latestStatusItemArr.indexOf(item.latestStatus) == -1 &&
+    //       item.latestStatus != '' &&
+    //       item.latestStatus != null
+    //     ) {
+    //       latestStatusItemArr.push(item.latestStatus)
+    //       this.latestStatusItem.push({
+    //         text: item.latestStatus,
+    //         value: item.latestStatus
+    //       })
+    //     }
+    //     if (bagLocationItemArr.indexOf(item.bagLocation) == -1 && item.bagLocation != '' && item.bagLocation != null) {
+    //       bagLocationItemArr.push(item.bagLocation)
+    //       this.bagLocationItem.push({
+    //         text: item.bagLocation,
+    //         value: item.bagLocation
+    //       })
+    //     }
+    //     if (
+    //       TransferFlightNOItemArr.indexOf(item.TransferFlightNO) == -1 &&
+    //       item.TransferFlightNO != '' &&
+    //       item.TransferFlightNO != null
+    //     ) {
+    //       TransferFlightNOItemArr.push(item.TransferFlightNO)
+    //       this.TransferFlightNOItem.push({
+    //         text: item.TransferFlightNO,
+    //         value: item.TransferFlightNO
+    //       })
+    //     }
+    //   })
+    // },
 
     // 统计行数
     summaryRow(num) {