useTableData.ts 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452
  1. import { Column } from 'element-plus'
  2. import type { KeyType } from '../components/ColumnSet/index.vue'
  3. import { tableColumnInGroup } from '../components/ColumnSet/index.vue'
  4. type tableColumnsGroup = {
  5. groupTitle: string
  6. children: {
  7. key: KeyType
  8. title: string
  9. width?: number
  10. headerClass?: string
  11. }[]
  12. }
  13. enum Alignment {
  14. LEFT = 'left',
  15. CENTER = 'center',
  16. RIGHT = 'right',
  17. }
  18. const headerClassReflect = ['bg-yellow', 'bg-green', 'bg-cyan']
  19. const groupsObj = {
  20. departure: [
  21. {
  22. groupTitle: '航班相关',
  23. children: [
  24. {
  25. key: 'flightNO',
  26. title: '航班号',
  27. },
  28. {
  29. key: 'flightDate',
  30. title: '执飞日期',
  31. },
  32. {
  33. key: 'takeOffTime',
  34. title: '起飞时间',
  35. },
  36. {
  37. key: 'desitination',
  38. title: '目的站',
  39. },
  40. {
  41. key: 'gate',
  42. title: '停机位',
  43. },
  44. {
  45. key: 'preFlightNO',
  46. title: '前序航班',
  47. },
  48. {
  49. key: 'landingTime',
  50. title: '实际降落\n时间',
  51. },
  52. ],
  53. },
  54. {
  55. groupTitle: '货站相关',
  56. children: [
  57. {
  58. key: 'special',
  59. title: '特货信息',
  60. },
  61. {
  62. key: 'projectLoad',
  63. title: '预计装载数\n(运单/件)',
  64. width: 100,
  65. },
  66. {
  67. key: 'transferIn',
  68. title: '中转进\n(运单/件)',
  69. width: 100,
  70. },
  71. {
  72. key: 'cancel',
  73. title: '退运\n(板卡/件)',
  74. width: 100,
  75. },
  76. ],
  77. },
  78. {
  79. groupTitle: '地服相关',
  80. children: [
  81. {
  82. key: 'receive',
  83. title: '收运核单\n(运单/件/重量)',
  84. width: 140,
  85. },
  86. {
  87. key: 'check',
  88. title: '查验\n(拒运/查验)',
  89. width: 120,
  90. },
  91. {
  92. key: 'security',
  93. title: '安检\n(运单/件)',
  94. width: 100,
  95. },
  96. {
  97. key: 'add',
  98. title: '加货\n(运单/板卡/件/重量)',
  99. width: 160,
  100. },
  101. {
  102. key: 'wait',
  103. title: '待运区\n(板卡/件)',
  104. width: 100,
  105. },
  106. {
  107. key: 'stowage',
  108. title: '配载\n(板卡/件)',
  109. width: 100,
  110. },
  111. {
  112. key: 'handOverTime',
  113. title: '计划交接\n时间',
  114. },
  115. {
  116. key: 'stationHandOver',
  117. title: '货站交接\n(板卡/件)',
  118. width: 100,
  119. },
  120. {
  121. key: 'recheck',
  122. title: '运输前复核\n(板卡/件)',
  123. width: 100,
  124. },
  125. {
  126. key: 'flightHandOver',
  127. title: '机下交接\n(板卡/件)',
  128. width: 100,
  129. },
  130. {
  131. key: 'load',
  132. title: '装机\n(板卡/件)',
  133. width: 100,
  134. },
  135. {
  136. key: 'goodsRegister',
  137. title: '拉货登记\n(板卡/件)',
  138. width: 100,
  139. },
  140. {
  141. key: 'pullBack',
  142. title: '拉回确认\n(板卡/件)',
  143. width: 100,
  144. },
  145. ],
  146. },
  147. ],
  148. arrival: [
  149. {
  150. groupTitle: '航班相关',
  151. children: [
  152. {
  153. key: 'flightNO',
  154. title: '航班号',
  155. },
  156. {
  157. key: 'flightDate',
  158. title: '执飞日期',
  159. width: 100,
  160. },
  161. {
  162. key: 'landingTime',
  163. title: '降落时间',
  164. width: 100,
  165. },
  166. {
  167. key: 'desitination',
  168. title: '目的站',
  169. width: 100,
  170. },
  171. {
  172. key: 'gate',
  173. title: '停机位',
  174. },
  175. ],
  176. },
  177. {
  178. groupTitle: '货站相关',
  179. children: [
  180. {
  181. key: 'special',
  182. title: '特货信息',
  183. width: 100,
  184. },
  185. {
  186. key: 'projectUnload',
  187. title: '预计卸载数\n(运单/件)',
  188. width: 100,
  189. },
  190. {
  191. key: 'transferOut',
  192. title: '中转出\n(运单/件)',
  193. width: 100,
  194. },
  195. {
  196. key: 'difference',
  197. title: '收货差异\n(板卡/件)',
  198. width: 100,
  199. },
  200. ],
  201. },
  202. {
  203. groupTitle: '地服相关',
  204. children: [
  205. {
  206. key: 'unload',
  207. title: '卸机\n(板/箱/卡)',
  208. width: 160,
  209. },
  210. {
  211. key: 'flightHandOver',
  212. title: '机下交接\n(板/箱/卡)',
  213. width: 160,
  214. },
  215. {
  216. key: 'stationHandOver',
  217. title: '货站交接\n(板/箱/卡)',
  218. width: 160,
  219. },
  220. {
  221. key: 'settle',
  222. title: '理货\n(板卡/运单/件/重量)',
  223. width: 160,
  224. },
  225. {
  226. key: 'outCargo',
  227. title: '出库\n(批/运单/件)',
  228. width: 160,
  229. },
  230. ],
  231. },
  232. ],
  233. }
  234. const tableDatas = {
  235. departure: [
  236. {
  237. flightNO: 'ZH3423',
  238. flightDate: '2022/09/10',
  239. takeOffTime: '22/09/10 12:01',
  240. desitination: '-NGK-PEK',
  241. gate: '84',
  242. preFlightNO: 'HU2451',
  243. landingTime: '2022/09/10 11:01',
  244. special: '锂2/冷1',
  245. projectLoad: '365/536',
  246. transferIn: '1/2',
  247. cancel: '',
  248. receive: '364/534/1254KG',
  249. check: '0/7',
  250. security: '364/534',
  251. add: '8/365/536/1254KG',
  252. wait: '8/536',
  253. stowage: '8/536',
  254. handOverTime: '11:45',
  255. stationHandOver: '8/536',
  256. recheck: '8/536',
  257. flightHandOver: '8/536',
  258. load: '8/536',
  259. goodsRegister: '0/358/5',
  260. pullBack: '0/5',
  261. },
  262. {
  263. flightNO: 'CA1512',
  264. flightDate: '2022/09/10',
  265. takeOffTime: '22/09/10 12:01',
  266. desitination: '-NGK-PEK',
  267. gate: '84',
  268. preFlightNO: 'HU2451',
  269. landingTime: '2022/09/10 11:01',
  270. special: '锂2/冷1',
  271. projectLoad: '365/536',
  272. transferIn: '1/2',
  273. cancel: '',
  274. receive: '364/534/1254KG',
  275. check: '0/7',
  276. security: '364/534',
  277. add: '8/365/536/1254KG',
  278. wait: '4/243',
  279. stowage: '8/536',
  280. handOverTime: '11:45',
  281. stationHandOver: '8/536',
  282. recheck: '8/536',
  283. flightHandOver: '8/536',
  284. load: '8/536',
  285. goodsRegister: '0/358/5',
  286. pullBack: '0/5',
  287. },
  288. {
  289. flightNO: 'ZH3456',
  290. flightDate: '2022/09/10',
  291. takeOffTime: '22/09/10 12:01',
  292. desitination: '-NGK-PEK',
  293. gate: '84',
  294. preFlightNO: 'HU2451',
  295. landingTime: '2022/09/10 11:01',
  296. special: '锂2/冷1',
  297. projectLoad: '365/536',
  298. transferIn: '1/2',
  299. cancel: '',
  300. receive: '364/534/1254KG',
  301. check: '0/7',
  302. security: '364/534',
  303. add: '8/365/536/1254KG',
  304. wait: '8/536',
  305. stowage: '5/357',
  306. handOverTime: '11:45',
  307. stationHandOver: '8/536',
  308. recheck: '8/536',
  309. flightHandOver: '8/536',
  310. load: '8/536',
  311. goodsRegister: '0/358/5',
  312. pullBack: '0/5',
  313. },
  314. ],
  315. arrival: [
  316. {
  317. flightNO: 'ZH3423',
  318. flightDate: '2022/09/10',
  319. landingTime: '22/09/10 12:01',
  320. desitination: 'NKG-PEK-',
  321. gate: '84',
  322. special: '锂2/冷1',
  323. projectUnload: '363/543',
  324. transferOut: '',
  325. difference: '0/6',
  326. unload: '8/8/8',
  327. flightHandOver: '8/8/8',
  328. stationHandOver: '8/8/8',
  329. settle: '8/363/537/1254KG',
  330. outCargo: '3/363/537',
  331. },
  332. {
  333. flightNO: 'CA1512',
  334. flightDate: '2022/09/10',
  335. landingTime: '22/09/10 12:01',
  336. desitination: 'NKG-PEK-',
  337. gate: '84',
  338. special: '锂2/冷1',
  339. projectUnload: '363/543',
  340. transferOut: '',
  341. difference: '',
  342. unload: '8/8/8',
  343. flightHandOver: '8/8/8',
  344. stationHandOver: '8/8/8',
  345. settle: '8/363/537/1254KG',
  346. outCargo: '3/363/537',
  347. },
  348. {
  349. flightNO: 'ZH3456',
  350. flightDate: '2022/09/10',
  351. landingTime: '22/09/10 12:01',
  352. desitination: 'NKG-PEK-',
  353. gate: '84',
  354. special: '锂2/冷1',
  355. projectUnload: '363/543',
  356. transferOut: '',
  357. difference: '',
  358. unload: '8/8/8',
  359. flightHandOver: '8/8/8',
  360. stationHandOver: '8/8/8',
  361. settle: '8/363/537/1254KG',
  362. outCargo: '3/363/537',
  363. },
  364. ],
  365. }
  366. export default function useTableData(stationType: string = 'dearture') {
  367. const tableColumns = ref<tableColumnInGroup[] | Column[]>([])
  368. const tableData = ref<{}[]>([])
  369. const getTableData = () => {
  370. if (stationType === 'test') {
  371. tableColumns.value = [
  372. {
  373. key: 'flightNO',
  374. title: '航班号',
  375. },
  376. {
  377. key: 'flightDate',
  378. title: '执飞日期',
  379. },
  380. {
  381. key: 'takeOffTime',
  382. title: '起飞时间',
  383. },
  384. {
  385. key: 'desitination',
  386. title: '目的站',
  387. },
  388. {
  389. key: 'gate',
  390. title: '停机位',
  391. },
  392. {
  393. key: 'preFlightNO',
  394. title: '前序航班',
  395. },
  396. {
  397. key: 'landingTime',
  398. title: '实际降落\n时间',
  399. },
  400. ].map(({ key, title }) => ({
  401. key,
  402. dataKey: key,
  403. title,
  404. width: 80,
  405. align: Alignment.CENTER,
  406. }))
  407. tableData.value = tableDatas.arrival
  408. return
  409. }
  410. const groups: tableColumnsGroup[] = groupsObj[stationType].map(
  411. (group: tableColumnsGroup, groupIndex: number) => {
  412. group.children.forEach(column => {
  413. column.headerClass = headerClassReflect[groupIndex]
  414. })
  415. return group
  416. }
  417. )
  418. tableColumns.value = groups.reduce(
  419. (columns: tableColumnInGroup[], group) => {
  420. columns.push(
  421. ...group.children.map(({ key, title, width, headerClass }) => ({
  422. key,
  423. dataKey: key,
  424. title,
  425. width: width ?? 80,
  426. headerClass,
  427. align: Alignment.CENTER,
  428. groupTitle: group.groupTitle,
  429. }))
  430. )
  431. return columns
  432. },
  433. []
  434. )
  435. tableData.value = tableDatas[stationType]
  436. }
  437. onMounted(() => {
  438. getTableData()
  439. })
  440. return {
  441. tableColumns,
  442. tableData,
  443. }
  444. }