useAirportTable.ts 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. import { Query } from '@/api/webApi'
  2. import { AnyColumn } from 'element-plus/es/components/table-v2/src/common'
  3. import { CommonData, CommonTableColumn } from '~/common'
  4. interface SimpleColumn {
  5. columnName: string
  6. columnLabel: string
  7. [x: string]: any
  8. }
  9. const columnGroupsMap: {
  10. [x: string]: {
  11. groupName: string
  12. children: SimpleColumn[]
  13. }[]
  14. } = {
  15. DepartureAirport: [
  16. {
  17. groupName: '航班相关',
  18. children: [
  19. {
  20. columnName: 'IATACode',
  21. columnLabel: '航司',
  22. needFilters: 1,
  23. fixed: true,
  24. },
  25. {
  26. columnName: 'flightNO',
  27. columnLabel: '航班号',
  28. needFilters: 1,
  29. fixed: true,
  30. },
  31. {
  32. columnName: 'flightDate',
  33. columnLabel: '执飞日期',
  34. width: 73,
  35. fixed: true,
  36. },
  37. {
  38. columnName: 'planDepartureTime',
  39. columnLabel: '起飞时间',
  40. width: 73,
  41. fixed: true,
  42. },
  43. {
  44. columnName: 'target',
  45. columnLabel: '目的站',
  46. needFilters: 1,
  47. fixed: true,
  48. },
  49. {
  50. columnName: 'takeOffStand',
  51. columnLabel: '停机位',
  52. fixed: true,
  53. },
  54. {
  55. columnName: 'lastflightNO',
  56. columnLabel: '前序航班',
  57. fixed: true,
  58. },
  59. {
  60. columnName: 'acLandingTime',
  61. columnLabel: '实际降落\n时间',
  62. width: 73,
  63. },
  64. ],
  65. },
  66. {
  67. groupName: '货站相关',
  68. children: [
  69. {
  70. columnName: 'speCargoInfo',
  71. columnLabel: '特货信息',
  72. },
  73. {
  74. columnName: 'transIn',
  75. columnLabel: '中转进\n(运单/件)',
  76. },
  77. {
  78. columnName: 'returns',
  79. columnLabel: '退运\n(板卡/件)',
  80. },
  81. ],
  82. },
  83. {
  84. groupName: '地服相关',
  85. children: [
  86. {
  87. columnName: 'preLoad',
  88. columnLabel: '运单申报\n(运单/件)',
  89. },
  90. {
  91. columnName: 'receiveSure',
  92. columnLabel: '收运核单\n(运单/件/重量)',
  93. },
  94. {
  95. columnName: 'receiveSureTime',
  96. columnLabel: '收运核单\n时间',
  97. },
  98. {
  99. columnName: 'receiveSure_No',
  100. columnLabel: '核单不通过\n(运单/件/重量)',
  101. },
  102. {
  103. columnName: 'receiveSureTime_No',
  104. columnLabel: '核单不通过\n时间',
  105. },
  106. {
  107. columnName: 'checks',
  108. columnLabel: '查验\n(拒运/查验)',
  109. },
  110. {
  111. columnName: 'checkTime',
  112. columnLabel: '查验时间',
  113. },
  114. {
  115. columnName: 'securityYes',
  116. columnLabel: '安检放行\n(运单/件)',
  117. },
  118. {
  119. columnName: 'securityTime',
  120. columnLabel: '安检放行\n时间',
  121. },
  122. {
  123. columnName: 'addCargo',
  124. columnLabel: '加货\n(运单/板卡/件/重量)',
  125. },
  126. {
  127. columnName: 'addCargoTime',
  128. columnLabel: '加货时间',
  129. },
  130. // {
  131. // columnName: 'wait',
  132. // columnLabel: '待运区\n(板卡/件)',
  133. // },
  134. // {
  135. // columnName: 'waitTime',
  136. // columnLabel: '待运区时间',
  137. // },
  138. {
  139. columnName: 'stowage',
  140. columnLabel: '预配载\n(板卡/件)',
  141. },
  142. {
  143. columnName: 'stowageTime',
  144. columnLabel: '预配载时间',
  145. },
  146. // {
  147. // columnName: 'planJoinTime',
  148. // columnLabel: '计划交接\n时间',
  149. // },
  150. // {
  151. // columnName: 'requestDepotJoin',
  152. // columnLabel: '发起货站交接\n(板卡/件)',
  153. // },
  154. // {
  155. // columnName: 'requestDepotJoinTime',
  156. // columnLabel: '发起货站交接\n时间',
  157. // },
  158. {
  159. columnName: 'depotJoin',
  160. columnLabel: '货站交接\n(板卡/件)',
  161. },
  162. {
  163. columnName: 'depotJoinTime',
  164. columnLabel: '货站交接\n时间',
  165. },
  166. {
  167. columnName: 'resure',
  168. columnLabel: '运输前复核\n(板卡/件)',
  169. },
  170. {
  171. columnName: 'resureTime',
  172. columnLabel: '运输前复核\n时间',
  173. },
  174. // {
  175. // columnName: 'planeDown',
  176. // columnLabel: '机下交接\n(板卡/件)',
  177. // columnDescribe: '根据运输前复核计算所得',
  178. // },
  179. {
  180. columnName: 'planeDownTime',
  181. columnLabel: '机下交接\n时间',
  182. },
  183. // {
  184. // columnName: 'loadPlaneSure',
  185. // columnLabel: '装机\n(板卡/件)',
  186. // },
  187. {
  188. columnName: 'loadPlaneSureTime',
  189. columnLabel: '装机时间',
  190. },
  191. // {
  192. // columnName: 'loadPlane',
  193. // columnLabel: '关闭舱门\n(板卡/件)',
  194. // },
  195. {
  196. columnName: 'loadPlaneTime',
  197. columnLabel: '关闭舱门\n时间',
  198. },
  199. {
  200. columnName: 'register',
  201. columnLabel: '拉下登记\n(板卡/件)',
  202. },
  203. {
  204. columnName: 'pullRegisterTime',
  205. columnLabel: '拉下登记\n时间',
  206. },
  207. {
  208. columnName: 'pullSure',
  209. columnLabel: '拉回确认\n(板卡/件)',
  210. },
  211. {
  212. columnName: 'pullSureTime',
  213. columnLabel: '拉回确认\n时间',
  214. },
  215. ],
  216. },
  217. ],
  218. InternationalDepartureAirport: [
  219. {
  220. groupName: '航班相关',
  221. children: [
  222. {
  223. columnName: 'IATACode',
  224. columnLabel: '航司',
  225. needFilters: 1,
  226. fixed: true,
  227. },
  228. {
  229. columnName: 'flightNO',
  230. columnLabel: '航班号',
  231. needFilters: 1,
  232. fixed: true,
  233. },
  234. {
  235. columnName: 'flightDate',
  236. columnLabel: '执飞日期',
  237. width: 73,
  238. fixed: true,
  239. },
  240. {
  241. columnName: 'planDepartureTime',
  242. columnLabel: '起飞时间',
  243. width: 73,
  244. fixed: true,
  245. },
  246. {
  247. columnName: 'target',
  248. columnLabel: '目的站',
  249. needFilters: 1,
  250. fixed: true,
  251. },
  252. {
  253. columnName: 'takeOffStand',
  254. columnLabel: '停机位',
  255. fixed: true,
  256. },
  257. {
  258. columnName: 'lastflightNO',
  259. columnLabel: '前序航班',
  260. fixed: true,
  261. },
  262. {
  263. columnName: 'acLandingTime',
  264. columnLabel: '实际降落\n时间',
  265. width: 73,
  266. },
  267. ],
  268. },
  269. {
  270. groupName: '货站相关',
  271. children: [
  272. {
  273. columnName: 'speCargoInfo',
  274. columnLabel: '特货信息',
  275. },
  276. {
  277. columnName: 'transIn',
  278. columnLabel: '中转进\n(运单/件)',
  279. },
  280. {
  281. columnName: 'returns1',
  282. columnLabel: '退运\n(板卡/件)',
  283. },
  284. ],
  285. },
  286. {
  287. groupName: '地服相关',
  288. children: [
  289. {
  290. columnName: 'preLoad',
  291. columnLabel: '运单申报\n(运单/件)',
  292. },
  293. {
  294. columnName: 'enterPark',
  295. columnLabel: '入园\n(运单/件)',
  296. },
  297. {
  298. columnName: 'enterParkTime',
  299. columnLabel: '入园时间',
  300. },
  301. {
  302. columnName: 'enterCustoms',
  303. columnLabel: '进入海关\n(运单/件)',
  304. },
  305. {
  306. columnName: 'enterCustomsTime',
  307. columnLabel: '进入海关时间',
  308. },
  309. {
  310. columnName: 'passCustoms',
  311. columnLabel: '海关放行\n(运单/件)',
  312. },
  313. {
  314. columnName: 'passCustomsTime',
  315. columnLabel: '海关放行\n时间',
  316. },
  317. {
  318. columnName: 'nopassCustoms',
  319. columnLabel: '海关不通过\n(运单/件)',
  320. },
  321. {
  322. columnName: 'nopassCustomsTime',
  323. columnLabel: '海关不通过\n时间',
  324. },
  325. {
  326. columnName: 'receiveSure1',
  327. columnLabel: '运抵货站\n(运单/件)',
  328. },
  329. {
  330. columnName: 'receiveSureTime',
  331. columnLabel: '运抵货站\n时间',
  332. },
  333. {
  334. columnName: 'returns2',
  335. columnLabel: '退运\n(板卡/件)',
  336. },
  337. {
  338. columnName: 'returnTime',
  339. columnLabel: '退运时间',
  340. },
  341. {
  342. columnName: 'securityYes',
  343. columnLabel: '安检放行\n(运单/件)',
  344. },
  345. {
  346. columnName: 'securityTime',
  347. columnLabel: '安检放行\n时间',
  348. },
  349. {
  350. columnName: 'receiveSure2',
  351. columnLabel: '收运核单\n(运单/件)',
  352. },
  353. {
  354. columnName: 'receiveSureResultTime',
  355. columnLabel: '收运核单\n时间',
  356. },
  357. {
  358. columnName: 'receiveSure_No',
  359. columnLabel: '核单不通过\n(运单/件)',
  360. },
  361. {
  362. columnName: 'receiveSureTime_No',
  363. columnLabel: '核单不通过\n时间',
  364. },
  365. {
  366. columnName: 'tally_out',
  367. columnLabel: '理货\n(板卡/运单/件)',
  368. },
  369. {
  370. columnName: 'tallyTime_out',
  371. columnLabel: '理货时间',
  372. },
  373. {
  374. columnName: 'planJoinTime',
  375. columnLabel: '计划交接\n时间',
  376. },
  377. {
  378. columnName: 'wait',
  379. columnLabel: '待运区\n(板卡/件)',
  380. },
  381. {
  382. columnName: 'waitTime',
  383. columnLabel: '待运区\n时间',
  384. },
  385. {
  386. columnName: 'stowage',
  387. columnLabel: '预配载\n(板卡/件)',
  388. },
  389. {
  390. columnName: 'stowageTime',
  391. columnLabel: '预配载时间',
  392. },
  393. {
  394. columnName: "concat(requestDepotJoinBoard,'/',requestDepotJoin)",
  395. columnLabel: '发起货站交接\n(板卡/件)',
  396. },
  397. {
  398. columnName: 'requestDepotJoinTime',
  399. columnLabel: '发起货站交接\n时间',
  400. },
  401. {
  402. columnName: 'depotJoin',
  403. columnLabel: '货站交接\n(板卡/件)',
  404. },
  405. {
  406. columnName: 'depotJoinTime',
  407. columnLabel: '货站交接\n时间',
  408. },
  409. {
  410. columnName: 'resure',
  411. columnLabel: '运输前复核\n(板卡/件)',
  412. },
  413. {
  414. columnName: 'resureTime',
  415. columnLabel: '运输前复核\n时间',
  416. },
  417. // {
  418. // columnName: 'planeDown',
  419. // columnLabel: '机下交接\n(板卡/件)',
  420. // columnDescribe: '根据运输前复核计算所得',
  421. // },
  422. {
  423. columnName: 'planeDownTime',
  424. columnLabel: '机下交接\n时间',
  425. },
  426. // {
  427. // columnName: "concat(loadPlaneSureBoard,'/',loadPlaneSure)",
  428. // columnLabel: '装机\n(板卡/件)',
  429. // },
  430. {
  431. columnName: 'loadPlaneSureTime',
  432. columnLabel: '装机时间',
  433. },
  434. // {
  435. // columnName: 'loadPlane',
  436. // columnLabel: '关闭舱门\n(板卡/件)',
  437. // },
  438. {
  439. columnName: 'loadPlaneTime',
  440. columnLabel: '关闭舱门\n时间',
  441. },
  442. {
  443. columnName: 'register',
  444. columnLabel: '拉下登记\n(板卡/运单/件)',
  445. },
  446. {
  447. columnName: 'pullregisterTime',
  448. columnLabel: '拉下登记\n时间',
  449. },
  450. ],
  451. },
  452. ],
  453. ArrivalAirport: [
  454. {
  455. groupName: '航班相关',
  456. children: [
  457. {
  458. columnName: 'IATACode',
  459. columnLabel: '航司',
  460. needFilters: 1,
  461. },
  462. {
  463. columnName: 'flightNO',
  464. columnLabel: '航班号',
  465. needFilters: 1,
  466. },
  467. {
  468. columnName: 'flightDate',
  469. columnLabel: '执飞日期',
  470. },
  471. {
  472. columnName: 'planLandingTime',
  473. columnLabel: '降落时间',
  474. },
  475. {
  476. columnName: 'target',
  477. columnLabel: '目的站',
  478. needFilters: 1,
  479. },
  480. {
  481. columnName: 'landingStand',
  482. columnLabel: '停机位',
  483. },
  484. ],
  485. },
  486. {
  487. groupName: '货站相关',
  488. children: [
  489. {
  490. columnName: 'speCargoInfo',
  491. columnLabel: '特货信息',
  492. },
  493. {
  494. columnName: 'preUnLoad',
  495. columnLabel: '预计卸载数\n(运单/件)',
  496. },
  497. {
  498. columnName: 'transOut',
  499. columnLabel: '中转出\n(运单/件)',
  500. },
  501. {
  502. columnName: 'receiveDiff',
  503. columnLabel: '收货差异\n(板卡/件)',
  504. },
  505. ],
  506. },
  507. {
  508. groupName: '地服相关',
  509. children: [
  510. // {
  511. // columnName: 'unloadBill',
  512. // columnLabel: '卸机单\n(板/箱/卡)',
  513. // },
  514. // {
  515. // columnName: 'unloadBillTime',
  516. // columnLabel: '卸机单确认\n时间',
  517. // },
  518. {
  519. columnName: 'unLoad',
  520. columnLabel: '卸机\n(板/箱/卡)',
  521. },
  522. {
  523. columnName: 'unLoadTime',
  524. columnLabel: '卸机时间',
  525. },
  526. {
  527. columnName: 'planeDown',
  528. columnLabel: '库区到达\n(板/箱/卡)',
  529. },
  530. {
  531. columnName: 'planeDownTime_IN',
  532. columnLabel: '库区到达\n时间',
  533. },
  534. {
  535. columnName: 'depotJoin',
  536. columnLabel: '货站交接\n(板/箱/卡)',
  537. },
  538. {
  539. columnName: 'depotJoinTime_IN',
  540. columnLabel: '货站交接\n时间',
  541. },
  542. {
  543. columnName: 'tally',
  544. columnLabel: '理货\n(运单/件/重量)',
  545. },
  546. {
  547. columnName: 'tallyTime_in',
  548. columnLabel: '理货时间',
  549. },
  550. {
  551. columnName: 'outWarehouse',
  552. columnLabel: '出库\n(批/运单/件)',
  553. },
  554. {
  555. columnName: 'outWarehouseTime',
  556. columnLabel: '出库时间',
  557. },
  558. ],
  559. },
  560. ],
  561. InternationalArrivalAirport: [
  562. {
  563. groupName: '航班相关',
  564. children: [
  565. {
  566. columnName: 'IATACode',
  567. columnLabel: '航司',
  568. needFilters: 1,
  569. },
  570. {
  571. columnName: 'flightNO',
  572. columnLabel: '航班号',
  573. needFilters: 1,
  574. },
  575. {
  576. columnName: 'flightDate',
  577. columnLabel: '执飞日期',
  578. },
  579. {
  580. columnName: 'planLandingTime',
  581. columnLabel: '降落时间',
  582. },
  583. {
  584. columnName: 'target',
  585. columnLabel: '目的站',
  586. needFilters: 1,
  587. },
  588. {
  589. columnName: 'landingStand',
  590. columnLabel: '停机位',
  591. },
  592. ],
  593. },
  594. {
  595. groupName: '货站相关',
  596. children: [
  597. {
  598. columnName: 'speCargoInfo',
  599. columnLabel: '特货信息',
  600. },
  601. {
  602. columnName: 'preUnLoad',
  603. columnLabel: '预计卸载数\n(运单/件)',
  604. },
  605. {
  606. columnName: 'transOut',
  607. columnLabel: '中转出\n(运单/件)',
  608. },
  609. {
  610. columnName: 'receiveDiff',
  611. columnLabel: '收货差异\n(板卡/件)',
  612. },
  613. ],
  614. },
  615. {
  616. groupName: '地服相关',
  617. children: [
  618. // {
  619. // columnName: 'unloadBill',
  620. // columnLabel: '卸机单\n(板/箱/卡)',
  621. // },
  622. // {
  623. // columnName: 'unloadBillTime',
  624. // columnLabel: '卸机时间',
  625. // },
  626. {
  627. columnName: 'unLoad',
  628. columnLabel: '卸机\n(板/箱/卡)',
  629. },
  630. {
  631. columnName: 'unLoadTime',
  632. columnLabel: '卸机时间',
  633. },
  634. {
  635. columnName: 'planeDown',
  636. columnLabel: '机下交接\n(板/箱/卡)',
  637. },
  638. {
  639. columnName: 'planeDownTime_IN',
  640. columnLabel: '机下交接\n时间',
  641. },
  642. {
  643. columnName: 'depotJoin',
  644. columnLabel: '货站交接\n(板/箱/卡)',
  645. },
  646. {
  647. columnName: 'depotJoinTime_IN',
  648. columnLabel: '货站交接\n时间',
  649. },
  650. {
  651. columnName: 'tally',
  652. columnLabel: '理货\n(板卡/运单/件/重量)',
  653. },
  654. {
  655. columnName: 'tallyTime_in',
  656. columnLabel: '理货时间',
  657. },
  658. {
  659. columnName: "concat(passCustomsList_in,'/',passCustoms_in)",
  660. columnLabel: '海关放行\n(运单/件)',
  661. },
  662. {
  663. columnName: 'passCustomsTime_in',
  664. columnLabel: '海关放行\n时间',
  665. },
  666. {
  667. columnName: 'outWarehouse',
  668. columnLabel: '出库\n(批/运单/件)',
  669. },
  670. {
  671. columnName: 'outWarehouseTime',
  672. columnLabel: '出库时间',
  673. },
  674. {
  675. columnName: "concat(punishCustomsList_in,'/',punishCustoms_in)",
  676. columnLabel: '海关罚没\n(运单/件)',
  677. },
  678. {
  679. columnName: 'punishCustomsTime_in',
  680. columnLabel: '海关罚没\n时间',
  681. },
  682. ],
  683. },
  684. ],
  685. }
  686. const headerClassMap = ['bg-yellow', 'bg-green', 'bg-cyan']
  687. const computedWidth = (column: SimpleColumn) => {
  688. let width = 0
  689. column.columnLabel.split('\n').forEach(line => {
  690. const len = line.length
  691. let realLength = 0
  692. for (let i = 0; i < len; i++) {
  693. realLength += line.charCodeAt(i) > 255 ? 2 : 1
  694. }
  695. if (width < realLength * 8) {
  696. width = realLength * 8
  697. }
  698. })
  699. if (column.needFilters || column.needSort) {
  700. width += 8
  701. }
  702. // border
  703. return width + 1
  704. }
  705. export function useAirportTable(name: string, formData: CommonData) {
  706. const tableColumns = ref<(CommonTableColumn & AnyColumn)[]>([])
  707. const tableData = ref<CommonData[]>([])
  708. const getTableColumns = () => {
  709. const groups = columnGroupsMap[name]
  710. tableColumns.value = groups.reduce(
  711. (columns: (CommonTableColumn & AnyColumn)[], group, groupIndex) => {
  712. group.children.forEach(column => {
  713. columns.push({
  714. key: column.columnName,
  715. dataKey: column.columnName,
  716. title: column.columnLabel,
  717. columnDescribe: '',
  718. dataType: '',
  719. listqueryTemplateID: null,
  720. needCount: null,
  721. needFilters: null,
  722. needGroup: null,
  723. needSearch: null,
  724. needShow: 1,
  725. needSort: null,
  726. orderNumber: null,
  727. queryTemplateColumnSetID: null,
  728. queryTemplateID: null,
  729. width: computedWidth(column),
  730. flexGrow: 1,
  731. align: 'center',
  732. headerClass: headerClassMap[groupIndex],
  733. groupName: group.groupName,
  734. ...column,
  735. })
  736. })
  737. return columns
  738. },
  739. []
  740. )
  741. }
  742. const getTableData = async () => {
  743. try {
  744. const {
  745. startDate,
  746. endDate,
  747. flightStatus,
  748. flightWarning,
  749. waybillType,
  750. } = formData
  751. const dataContent = [
  752. startDate,
  753. endDate,
  754. // flightStatus,
  755. // flightWarning
  756. ]
  757. // if (name.includes('International')) {
  758. // dataContent.push(waybillType)
  759. // }
  760. const {
  761. code,
  762. returnData: { columnSet, listValues },
  763. message,
  764. } = await Query<CommonData>({
  765. id: DATACONTENT_ID[name.slice(0, 1).toLowerCase() + name.slice(1)],
  766. dataContent,
  767. })
  768. if (Number(code) !== 0) {
  769. throw new Error(message || '失败')
  770. }
  771. // tableColumns.value = columnSet.map(column => ({
  772. // key: column.columnName,
  773. // dataKey: column.columnName,
  774. // title: column.columnLabel,
  775. // width: column.columnLabel.length * 50,
  776. // flexGrow: 1,
  777. // align: 'center',
  778. // ...column,
  779. // }))
  780. tableData.value = listValues.map(row => ({
  781. ...row,
  782. rowKey: `${row.IATACode}-${row.flightNO}-${row.flightDate}`,
  783. }))
  784. } catch (error) {
  785. console.error(error)
  786. }
  787. }
  788. onMounted(() => {
  789. getTableColumns()
  790. })
  791. return {
  792. tableColumns,
  793. tableData,
  794. getTableData,
  795. }
  796. }