/* * @Author: Badguy * @Date: 2022-03-04 11:41:55 * @LastEditTime: 2022-05-13 15:45:14 * @LastEditors: your name * @Description: 航站视图通用部分 * have a nice day! */ import { queryMap, myQuery } from '@/api/dataIntegration' import { CurrentAirportQuery, RelatedAirportQuery, AirCompanyQuery, CraftTypeQuery, FlightAttrQuery, IntegratedQuery, IntegratedQueryTransfer } from '@/api/flight' export default { data() { return { // 表格数据 tableData: [], spanArr: [], pos: 0, loading: false } }, // created() { // this.currentAirportQuery() // }, mounted() { // this.queryDepartureAirport() }, computed: { dates() { return [this.startDate, this.endDate] }, flightQueryParams() { return [ this.startDate, this.endDate, this.departureAirPort, this.departureAirPort, this.landingAirport, this.landingAirport, this.carrier, this.carrier, this.craftType, this.craftType, this.flightAttr, this.flightAttr, this.search, this.search ] } }, methods: { // 数据处理 formatData(arr) { arr.forEach(item => { item['name'] = item['name'] + item['code3'] item.builds && item.builds.forEach(p => { p['code3'] = p.name }) }) return arr }, // 表格数据格式化 tableFormat(row, column, cellValue) { if (cellValue || cellValue === 0) { switch (column.property) { case 'FlightDate': return cellValue.split('-').slice(1).join('-') case 'PlanLandingTime': case 'PlanDepartureTime': case 'PrePlanLandingTime': case 'TransferFlightPlanDepartureTime': case 'ActualDepartureTime': case 'ActualLandingTime': // return cellValue.split('T')[1].split(':').slice(0, 2).join(':') return cellValue.replace('T', ' ') default: return cellValue } } else { return '' } }, // 合计行 summaryMethod({ columns, data }) { const sums = [] if (columns.length > 0) { columns.forEach((column, index) => { if (index === 0) { sums[index] = '航班数:'+this.tableData.length } else if ( // 需要计算的列 [ 'passagernum', 'checkNumber', 'not_actived', 'expect_load', 'security_all', 'sortNumber', 'loadNumber', 'waitfanj', 'unLoad', 'delbag', 'noBSM', 'transfer_all', 'reach', 'did_not_arrive', 'special', 'claim', 'uninstalled', 'to_be_uninstalled', 'terminateArrive', 'terminatedNotArrived', 'delivered', 'not_shipped', 'container', 'bulk', 'checkInTravellerNumber', 'checkInNumber', 'unActive', 'preLoad', 'noCheckInNumber', 'midIn', 'checkIns', 'projectedLoad', 'loadedQuantity', 'numberOfDestinationArrivals', 'endPointNotReached', 'specialQuantity', 'numberOfClaims', 'numberToBeUninstalled', 'terminateArrivalQuantity', 'terminateUnreachedQuantity', 'quantityShipped', 'undeliveredQuantity', 'numberOfBulk', 'inTransferBaggageCount', 'inTransferredBaggageCount', 'outTransferBaggageCount', 'outTransferredBaggageCount' ].includes(column.property) ) { const values = data.map(item => Number(item[column.property])) if (values.some(value => !isNaN(value))) { sums[index] = values.reduce((prev, curr) => { const value = Number(curr) if (!isNaN(value)) { return Number(prev) + Number(curr) } else { return Number(prev) } }, 0) } else { sums[index] = 0 } } else { // 过滤某些字段不参与计算 sums[index] = '-' } }) } return sums }, // 表格行点击跳转 rowClick({ FlightNO, FlightDate }) { this.$router.push({ path: `${this.$route.path}/flightView`, query: { FlightNO, FlightDate } }) // this.$router.push({ path: '/departure/flightView', query: row }) }, // 全部机场查询 async currentAirportQuery() { const params = { startDate: this.startDate, endDate: this.endDate } try { const res = await CurrentAirportQuery(params) if (res.code === 0) { if (res.returnData.length) { const datas = this.formatData(res.returnData) const datasCopy = this._.cloneDeep(datas) this.currentAirportList = datas const defaultData = datasCopy[0] // this.formData.currentAirport = [[defaultData.code3, defaultData.builds[0].code3]] // this.formData.currentAirport = [[defaultData.code3]] this.formData.currentAirport = [defaultData.code3] params.currentAirport = this.currentAirport this.getFormData(params) this.getTableData({ ...params, world: this.formData.search }) } } else { this.$message.error(res.message) } } catch (error) { console.log('出错了', error) } }, // 目的站/始飞站查询 async relatedAirportQuery(params = {}) { try { const res = await RelatedAirportQuery(params) if (res.code === 0) { const datas = this.formatData(res.returnData) this.relatedAirportList = datas } else { this.$message.error(res.message) } } catch (error) { console.log('出错了', error) } }, // 航司查询 async inboundCarrierQuery(params = {}) { try { const res = await AirCompanyQuery({ ...params, type: 'IN' }) if (res.code === 0) { this.carrierList = res.returnData } else { this.$message.error(res.message) } } catch (error) { console.log('出错了', error) } }, // 航司查询 async outgoingAirlineQuery(params = {}) { try { const res = await AirCompanyQuery({ ...params, type: 'OUT' }) if (res.code === 0) { this.carrierList = res.returnData } else { this.$message.error(res.message) } } catch (error) { console.log('出错了', error) } }, // 机型查询 async craftTypeQuery(params = {}) { try { const res = await CraftTypeQuery(params) if (res.code === 0) { this.craftTypeList = res.returnData.map(item => ({ code3: item, name: item })) } else { this.$message.error(res.message) } } catch (error) { console.log('出错了', error) } }, // 航线查询 async flightAttrQuery(params = {}) { try { const res = await FlightAttrQuery(params) if (res.code === 0) { this.flightAttrList = res.returnData } else { this.$message.error(res.message) } } catch (error) { console.log('出错了', error) } }, // 综合查询 async integratedQuery(params = {}) { try { this.loading = true const res = await IntegratedQuery(params) if (res.code === 0) { const tableData = res.returnData this.initTableData(tableData) this.loading = false } else { this.$message.error(res.message) this.loading = false } } catch (error) { console.log('出错了', error) this.loading = false } }, // 中转综合查询 async integratedQueryTransfer(params = {}) { try { this.loading = true const res = await IntegratedQueryTransfer(params) if (res.code === 0) { const tableData = res.returnData this.initTableData(tableData) this.loading = false } else { this.$message.error(res.message) this.loading = false } } catch (error) { console.log('出错了', error) this.loading = false } }, // 查询起飞机场 id: 31 queryDepartureAirport() { return myQuery(queryMap.departureAirPort, ...this.dates) }, // 查询降落机场 id: 32 queryLandingAirport() { return myQuery(queryMap.landingAirport, ...this.dates) }, // 按照降落机场查询起飞机场 id: 33 queryDepartureAirportByLandingAirport() { return myQuery(queryMap.departureAirPortBylandingAirport, this.currentAirport, ...this.dates) }, // 按照起飞机场查询降落机场 id: 34 queryLandingAirportByDepartureAirport() { return myQuery(queryMap.landingAirportBydepartureAirPort, this.currentAirport, ...this.dates) }, // 查询航司 id: 35 queryCarrier() { return myQuery(queryMap.carrier, ...this.dates) }, // 查询机型 id: 36 queryCraftType() { return myQuery(queryMap.craftType, ...this.dates) }, // 查询航线 id: 37 queryAirline() { return myQuery(queryMap.flightAttr, ...this.dates) }, // 查询进港航班 id: 38 queryLandingFlight() { return myQuery(queryMap.landingFlight, ...this.flightQueryParams) }, // 查询离港航班 id: 39 queryDepartureFlight() { return myQuery(queryMap.departureFlight, ...this.flightQueryParams) }, // 查询中转航班 id: 40 queryTrasferFlight() { return myQuery(queryMap.transferFlight, ...this.flightQueryParams) } } }