123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218 |
- import { CommonData, CommonValue } from '~/common'
- import { Query } from '@/api/webApi'
- import { ElMessage } from 'element-plus'
- const flightInfoItemsMap = {
- departure: [
- [
- {
- label: '起飞机场简称',
- key: 'C0',
- },
- {
- label: '日期',
- key: 'C1',
- },
- {
- label: '时间',
- key: 'C2',
- },
- {
- label: '停机位',
- key: 'C3',
- },
- ],
- [
- {
- label: '特货信息/货物数',
- key: 'C4',
- },
- {
- label: '托运运单数/货物数',
- key: 'C5',
- },
- {
- label: '中转进运单/货物数',
- key: 'C6',
- },
- {
- label: '已配载集装器',
- key: 'C7',
- },
- {
- label: '货站已交接集装器',
- key: 'C7',
- },
- {
- label: '已装载集装器/运单/货物数',
- key: 'C7',
- },
- {
- label: '拉下集装器/运单/货物数',
- key: 'C8',
- },
- {
- label: '集装器数量',
- key: 'C9',
- },
- ],
- [
- {
- label: '降落机场简称',
- key: 'C10',
- },
- {
- label: '日期',
- key: 'C11',
- },
- {
- label: '时间',
- key: 'C12',
- },
- ],
- ],
- arrival: [
- [
- {
- label: '起飞机场简称',
- key: 'C0',
- },
- {
- label: '日期',
- key: 'C1',
- },
- {
- label: '时间',
- key: 'C2',
- },
- ],
- [
- {
- label: '特货信息/货物数',
- key: 'C3',
- },
- {
- label: '卸载运单数/货物数',
- key: 'C4',
- },
- {
- label: '中转进运单/货物数',
- key: 'C5',
- },
- {
- label: '已卸载集装器',
- key: 'C6',
- },
- {
- label: '卸载数量(板/箱/卡)',
- key: 'C7',
- },
- {
- label: '货站交接数量(板/箱/卡)',
- key: 'C8',
- },
- ],
- [
- {
- label: '降落机场简称',
- key: 'C9',
- },
- {
- label: '日期',
- key: 'C10',
- },
- {
- label: '时间',
- key: 'C11',
- },
- {
- label: '停机位',
- key: 'C12',
- },
- ],
- ],
- }
- const simulateFlightInfoMap = {
- departure: {
- C0: '深圳机场',
- C1: '2021-12-24',
- C2: '19 : 30 : 25',
- C3: '012',
- C4: '0',
- C5: '0',
- C6: '0',
- C7: '0',
- C8: '0',
- C9: '0',
- C10: '南京机场',
- C11: '2021-12-24',
- C12: '22 : 25 : 25',
- },
- arrival: {
- C0: '南京机场',
- C1: '2021-12-24',
- C2: '19 : 30 : 25',
- C3: '0',
- C4: '0',
- C5: '0',
- C6: '0',
- C7: '0',
- C8: '0',
- C9: '深圳机场',
- C10: '2021-12-24',
- C11: '19 : 30 : 25',
- C12: '012',
- },
- }
- export default function useFlightInfo(
- name: string,
- dataContent: CommonValue[]
- ) {
- const flightInfoItems = ref<{ label: string; key: string }[][]>([])
- const getFlightInfoItems = () => {
- flightInfoItems.value =
- flightInfoItemsMap[name.includes('Departure') ? 'departure' : 'arrival']
- }
- getFlightInfoItems()
- const flightInfo = reactive<CommonData>({})
- const getFlightInfo = async () => {
- try {
- const {
- code,
- returnData: { listValues },
- message,
- } = await Query({
- id: DATACONTENT_ID.flightInfo,
- dataContent,
- })
- if (Number(code) !== 0) {
- throw new Error(message ?? '失败')
- }
- if (!listValues.length) {
- ElMessage.error('未查询到航班信息')
- return
- }
- Object.assign(flightInfo, listValues[0])
- } catch (error) {
- console.error(error)
- }
- }
- const getSimulateFlightInfo = () => {
- const simulateFlightInfo =
- simulateFlightInfoMap[
- name.includes('Departure') ? 'departure' : 'arrival'
- ]
- Object.assign(flightInfo, simulateFlightInfo)
- }
- onMounted(() => {
- // getFlightInfo()
- getSimulateFlightInfo()
- })
- return {
- flightInfoItems,
- flightInfo,
- }
- }
|