zhaoke 1 жил өмнө
parent
commit
3a27fed8df

+ 9 - 2
src/components/SimpleTable/index.vue

@@ -107,7 +107,11 @@ export default {
     selected: {
       type: Number,
       default: 0
-    }
+    },
+    fastFilter: {
+      type: Function,
+      default: () => () => true
+    },
   },
   data () {
     return {
@@ -124,8 +128,11 @@ export default {
     filteredTableCols () {
       return this.tableCols.filter(col => col.isdisplay != 0)
     },
+    fastFilteredTableData () {
+      return this.tableData.filter(this.fastFilter)
+    },
     dealedTableData () {
-      const filtered = this.tableData.filter(item => {
+      const filtered = this.fastFilteredTableData.filter(item => {
         let flag = true
         Object.entries(this.filterValues).forEach(([key, arr]) => {
           if (arr.length && !arr.includes(String(item[key]))) {

+ 16 - 7
src/components/Table/index.vue

@@ -1,13 +1,13 @@
 <template>
   <div class="TablePage">
-    <PublicPageTable ref="table" :loading="loading" :selected="selected" :table-cols="tableCols" :table-btns="authBtns" :data="tableData" :header-cell-class-name="headerCellClass" :row-class-name="rowClass" :cell-class-name="cellClass" :formatter="tableFormatter" :selectedDatas="selectedDatas" :selectedCheck="selectedDataCheck" :show-summary="summaryFlag" @mounted="tableMountedHandler" @load="load" @cell-click="cellClickHandler" />
+    <PublicPageTable ref="table" :loading="loading" :fast-filter="fastFilter" :selected="selected" :table-cols="tableCols" :table-btns="authBtns" :data="tableData" :header-cell-class-name="headerCellClass" :row-class-name="rowClass" :cell-class-name="cellClass" :formatter="tableFormatter" :selectedDatas="selectedDatas" :selectedCheck="selectedDataCheck" :show-summary="summaryFlag" @mounted="tableMountedHandler" @load="load" @cell-click="cellClickHandler" />
   </div>
 </template>
 
 <script>
 import PublicPageTable from '@/components/SimpleTable'
 import { Query } from "@/api/webApi"
-import { mapGetters } from 'vuex'
+import { listToTree } from '@/utils/validate'
 export default {
   name: 'TablePage',
   components: { PublicPageTable },
@@ -15,7 +15,11 @@ export default {
     msgContent: {
       type: Array,
       default: () => new Array()
-    }
+    },
+    fastFilter: {
+      type: Function,
+      default: () => () => true
+    },
   },
   data () {
     return {
@@ -88,7 +92,7 @@ export default {
       const authTableObj = pageAuthtables[0]
       //获取当前页面table的配置
       const { pagename, pageconfigurationid, serviceid, pagecode, userpermissionsid, nfilter, selected, triggerserviceid } = authTableObj
-      this.pageServiceId = serviceid;
+      this.pageServiceId = serviceid
       this.pageTitle = pagename
       this.selected = selected
       this.triggerserviceid = triggerserviceid
@@ -103,6 +107,7 @@ export default {
       const tableColsCopy = _.cloneDeep(returnData).filter((item) => item.isdisplay != 0)
       const tableColsCopyOrder = _.orderBy(tableColsCopy, ['displaynumber'], ['asc'])
       const msgCounts = tableColsCopyOrder.filter(item => item.enablecount)
+      this.tableCols = listToTree(tableColsCopyOrder, 'groupid', 'pagecode')
       if (msgCounts.length) {
         this.summaryFlag = true
       }
@@ -112,6 +117,7 @@ export default {
       if (columncode && Object.keys(columncode).length) {
         this.tableKey = columncode['pagecode']
       }
+      this.queryTableData(true)
     },
     //格式化传递参数数据
     formatDefault (item, data = {}) {
@@ -270,10 +276,12 @@ export default {
       this.tableData = [];
     },
     load () {
-      if (this.noMore || this.loading) {
-        return
+      if (this.pageServiceId) {
+        if (this.noMore || this.loading) {
+          return
+        }
+        this.queryTableData()
       }
-      this.queryTableData()
     },
     async queryTableData (jumpSing = false) {
       if (jumpSing) {
@@ -299,6 +307,7 @@ export default {
             this.noMore = true
           }
           this.tableData.push(...returnData)
+          this.$emit('tableLoad', [...this.tableData])
         } else {
           this.page--
           this.noMore = true

+ 5 - 2
src/views/flightPage/components/containerTable.vue

@@ -1,5 +1,5 @@
 <template>
-  <div>
+  <div class="containerTable">
     <tablePage :msgContent="msgContent" />
   </div>
 </template>
@@ -17,5 +17,8 @@ export default {
 }
 </script>
 
-<style>
+<style lang="scss" scoped>
+.containerTable {
+  height: 100%;
+}
 </style>

+ 134 - 2
src/views/flightPage/components/flightTable.vue

@@ -14,13 +14,26 @@
       </div>
     </div>
     <div class="newFlightView-right-bottom">
-      11
+      <tablePage ref="table" @tableLoad="tableLoad" :fast-filter="fastFilter" :msgContent="msgContent" />
     </div>
   </div>
 </template>
 
 <script>
+import tablePage from '@/components/Table'
+import { exportToExcel } from '@/utils/table'
 export default {
+  components: { tablePage },
+  props: {
+    msgContent: {
+      type: Array,
+      default: () => new Array()
+    },
+    msgObj: {
+      type: Object,
+      default: () => new Object()
+    }
+  },
   data () {
     return {
       selectedFilter: [],
@@ -87,9 +100,128 @@ export default {
         },
       ],
     }
+  },
+  computed: {
+    fastFilter () {
+      const [key, value] = this.selectedFilter;
+      // console.log(this.selectedFilter)
+      if (!key) {
+        return () => true;
+      }
+      return (row) => {
+        switch (key) {
+          case "inflightNo":
+          case "transferFlightNO":
+            return value ? row[key] === value : (row[key] ?? "") !== "";
+          case "check_in_baggage_number":
+            return row["No_BSM"] != 1;
+          case "NO_activate_number":
+            return row["activeState"] == 1;
+          case "estimated_load_number":
+            return row["dataState"] != "DEL" && row["activeState"] != 1;
+          case "screened_number":
+            return row["securityInspectionResults"];
+          case "sorted_number":
+            return row["sorting_time"];
+          case "loaded_number":
+            return (
+              row["loading_time"] &&
+              (row["abnormalType"] == "OFF" || !row["abnormalType"])
+            );
+          case "onaiecraft_number":
+            return row["installation_time"];
+          case "NO_check_number":
+            return (
+              row["dataState"] == "DEL" &&
+              row["loading_time"] &&
+              (row["abnormalType"] != "OFF" || !row["abnormalType"])
+            );
+          case "checked_number":
+            return row["dataState"] == "DEL" && row["abnormalType"] == "OFF";
+          case "cancel_consignment_number":
+            return row["dataState"] == "DEL";
+          case "NO_BSM_number":
+            return row["No_BSM"] == 1;
+          case "transfer_baggage_number":
+            return row["inflightNo"] && row["dataState"] != "DEL";
+          default:
+            return (row[key] ?? "") !== "";
+        }
+      };
+    },
+  },
+  methods: {
+    // 获取行李列表后设置快捷筛选
+    tableLoad (tableData) {
+      this.setFastFilterOptions(tableData);
+    },
+    setFastFilterOptions (tableData) {
+      const viewDatas = [];
+      const inFlightNOList = new Set();
+      const transferFlightNOList = new Set();
+      tableData.forEach((item) => {
+        item["inflightNo"] && inFlightNOList.add(item["inflightNo"]);
+        item["transferFlightNO"] &&
+          transferFlightNOList.add(item["transferFlightNO"]);
+      });
+      this.fastFilterOptions.splice(
+        this.fastFilterOptions.length - 2,
+        2,
+        {
+          label: "中转进航班",
+          value: "inflightNo",
+          children: [...inFlightNOList].map((value) => ({
+            label: value,
+            value,
+          })),
+        },
+        {
+          label: "中转出航班",
+          value: "transferFlightNO",
+          children: [...transferFlightNOList].map((value) => ({
+            label: value,
+            value,
+          })),
+        }
+      );
+      this.viewClassName.forEach((item) => {
+        viewDatas.push({
+          label: item.label,
+          value: item.value,
+        });
+      });
+      this.fastFilterOptions = this.fastFilterOptions.concat(viewDatas);
+    },
+    // 导出
+    exportHandler (refName, tableName) {
+      const { carrierFlights, carrierFlightsDate, outAirport, landAirport } =
+        this.msgObj
+      const table = this.$refs[refName].$el.cloneNode(true);
+      const fileName = `${tableName}-${carrierFlights}-${carrierFlightsDate}-${outAirport}-${landAirport}.xlsx`;
+      exportToExcel(table, tableName, fileName);
+    },
   }
 }
 </script>
 
-<style>
+<style lang="scss" scoped>
+.newFlightView-right {
+  flex: 1;
+  height: 100%;
+  width: calc(100% - 416px);
+  &-top {
+    padding: 18px 0;
+    &-left {
+      line-height: 30px;
+    }
+    &-right {
+      .btn-img {
+        margin-left: 10px;
+      }
+    }
+  }
+  &-bottom {
+    height: calc(100% - 68px);
+  }
+}
 </style>

+ 71 - 39
src/views/flightPage/index.vue

@@ -82,7 +82,7 @@
         <containerTable :msgContent="legTable" />
       </div>
     </div>
-    <flightTable />
+    <flightTable :msgObj="infoObj" :msgContent="flightTable" />
   </div>
 </template>
 
@@ -105,7 +105,9 @@ export default {
       deArrs: [],
       deArrsNum: [],
       loading: false,
-      legTable: []
+      legTable: [],
+      flightTable: [],
+      pageAuthtables: []
     }
   },
   computed: {
@@ -113,7 +115,44 @@ export default {
   },
   methods: {
     //选中
-    checkChange () { },
+    async checkChange (arr) {
+      try {
+        const ndata = []
+        const result = [...arr]
+        if (result?.length) {
+          this.loading = true
+          const setData = Array.from(new Set(result.join("-").split("-")))
+          this.deArrsNum.forEach((item) => {
+            setData.forEach((p) => {
+              if (item.item == p) {
+                const obj = {
+                  name: item.item,
+                  index: item.index,
+                };
+                ndata.push(obj)
+              }
+            })
+          })
+          const caps = ndata.sort((a, b) => a.index - b.index)
+          const [c4, c5] = [caps[0].name, caps[caps.length - 1].name]
+          const newPrams = _.cloneDeep(this.flightObj)
+          const [tb1, tb2] = [_.cloneDeep(this.legTable), _.cloneDeep(this.flightTable)]
+          newPrams.outAirport = c4
+          newPrams.landAirport = c5
+          tb1[0].nfilter = newPrams
+          this.legTable = tb1
+          tb2[0].nfilter = newPrams
+          this.flightTable = tb2
+          const res = await this.getLegInfo(111, newPrams)
+          if (res && res.length) {
+            this.infoObj = res[0]
+          }
+          this.loading = false
+        }
+      } catch (error) {
+        console.log(error)
+      }
+    },
     // 显示日期
     formatTime (datetime) {
       return datetime?.replace("T", " ") ?? "";
@@ -133,9 +172,9 @@ export default {
       }
       return query;
     },
-    async getLegInfo (dataParams, event = 0, key = '') {
+    async getLegInfo (id, dataParams, event = 0, key = '') {
       const params = {
-        serviceid: 114,
+        serviceid: id,
         datacontent: { filter: dataParams },
         event,
       }
@@ -160,7 +199,7 @@ export default {
         }
       }
       this.deArrs = infoArrs
-      const m = combine(this.deArrs, "outAirport", "landAirport");
+      const m = combine(this.deArrs, "outAirport", "landAirport")
       m.forEach((item, index) => {
         checkDatas.push(`${m[index]}-${m[index + 1]}`);
         const obj = {
@@ -169,13 +208,25 @@ export default {
         };
         this.deArrsNum.push(obj);
       });
-      this.checkStates = m;
-      const [a1, a2] = [m[0], m[m.length - 1]];
-      const { outAirport, landAirport } = this.infoObj;
+      this.checkStates = m
+    },
+    setCheckInfo (infos) {
+      const m = [...infos]
+      const [a1, a2] = [m[0], m[m.length - 1]]
+      const { outAirport, landAirport } = this.infoObj
       if (a1 == outAirport && a2 == landAirport) {
-        this.checkList = checkDatas.splice(0, m.length - 1);
+        this.checkList = checkDatas.splice(0, m.length - 1)
       } else {
-        this.checkList = [`${outAirport}-${landAirport}`];
+        this.checkList = [`${outAirport}-${landAirport}`]
+      }
+    },
+    setTableData (dataParams) {
+      if (this.pageAuthtables?.length) {
+        this.pageAuthtables.map(item => {
+          item.nfilter = dataParams
+        })
+        this.legTable = this.pageAuthtables.filter(item => item.serviceid == 112)
+        this.flightTable = this.pageAuthtables.filter(item => item.serviceid == 113)
       }
     }
   },
@@ -191,6 +242,7 @@ export default {
     if (!pageAuthArrs.length) return
     //获取table权限
     const pageAuthtables = pageAuthArrs.filter(item => item.pagetype == 'table')
+    this.pageAuthtables = pageAuthtables
     const np = [
       {
         k1: "inflightNo",
@@ -212,16 +264,16 @@ export default {
     this.loading = true
     const nq = this.formatParams(np, { ...query })
     this.flightObj = { ...nq }
-    if (pageAuthtables?.length) {
-      pageAuthtables.map(item => {
-        item.nfilter = { ...nq }
-      })
-      this.legTable = pageAuthtables.filter(item => item.serviceid == 112)
-    }
-    const legInfo = await this.getLegInfo(nq)
+    const legInfo = await this.getLegInfo(114, nq)
     if (legInfo?.length) {
-      this.infoObj = [...legInfo][0]
       this.setLegInfo([...legInfo])
+      const dataParams = Object.assign({ ...nq }, { outAirport: this.checkStates[0], landAirport: this.checkStates[1] })
+      this.setTableData(dataParams)
+      const dataInfo = await this.getLegInfo(111, dataParams)
+      if (dataInfo?.length) {
+        this.infoObj = dataInfo[0]
+        this.setCheckInfo(this.checkStates)
+      }
     }
     this.loading = false
   }
@@ -283,25 +335,5 @@ export default {
       margin-top: 8px;
     }
   }
-  &-right {
-    flex: 1;
-    height: 100%;
-    width: calc(100% - 416px);
-    &-top {
-      padding: 18px 0;
-      &-left {
-        line-height: 30px;
-      }
-      &-right {
-        padding-right: 70px;
-        .btn-img {
-          margin-left: 10px;
-        }
-      }
-    }
-    &-bottom {
-      height: calc(100% - 68px);
-    }
-  }
 }
 </style>