useFlightInfo.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. import { CommonData, CommonValue } from '~/common'
  2. import { Query } from '@/api/webApi'
  3. import { ElMessage } from 'element-plus'
  4. const flightInfoItemsMap = {
  5. departure: [
  6. [
  7. {
  8. label: '起飞机场简称',
  9. key: 'C0',
  10. },
  11. {
  12. label: '日期',
  13. key: 'C1',
  14. },
  15. {
  16. label: '时间',
  17. key: 'C2',
  18. },
  19. {
  20. label: '停机位',
  21. key: 'C3',
  22. },
  23. ],
  24. [
  25. {
  26. label: '特货信息/货物数',
  27. key: 'C4',
  28. },
  29. {
  30. label: '托运运单数/货物数',
  31. key: 'C5',
  32. },
  33. {
  34. label: '中转进运单/货物数',
  35. key: 'C6',
  36. },
  37. {
  38. label: '已配载集装器',
  39. key: 'C7',
  40. },
  41. {
  42. label: '货站已交接集装器',
  43. key: 'C7',
  44. },
  45. {
  46. label: '已装载集装器/运单/货物数',
  47. key: 'C7',
  48. },
  49. {
  50. label: '拉下集装器/运单/货物数',
  51. key: 'C8',
  52. },
  53. {
  54. label: '集装器数量',
  55. key: 'C9',
  56. },
  57. ],
  58. [
  59. {
  60. label: '降落机场简称',
  61. key: 'C10',
  62. },
  63. {
  64. label: '日期',
  65. key: 'C11',
  66. },
  67. {
  68. label: '时间',
  69. key: 'C12',
  70. },
  71. ],
  72. ],
  73. arrival: [
  74. [
  75. {
  76. label: '起飞机场简称',
  77. key: 'C0',
  78. },
  79. {
  80. label: '日期',
  81. key: 'C1',
  82. },
  83. {
  84. label: '时间',
  85. key: 'C2',
  86. },
  87. ],
  88. [
  89. {
  90. label: '特货信息/货物数',
  91. key: 'C3',
  92. },
  93. {
  94. label: '卸载运单数/货物数',
  95. key: 'C4',
  96. },
  97. {
  98. label: '中转进运单/货物数',
  99. key: 'C5',
  100. },
  101. {
  102. label: '已卸载集装器',
  103. key: 'C6',
  104. },
  105. {
  106. label: '卸载数量(板/箱/卡)',
  107. key: 'C7',
  108. },
  109. {
  110. label: '货站交接数量(板/箱/卡)',
  111. key: 'C8',
  112. },
  113. ],
  114. [
  115. {
  116. label: '降落机场简称',
  117. key: 'C9',
  118. },
  119. {
  120. label: '日期',
  121. key: 'C10',
  122. },
  123. {
  124. label: '时间',
  125. key: 'C11',
  126. },
  127. {
  128. label: '停机位',
  129. key: 'C12',
  130. },
  131. ],
  132. ],
  133. }
  134. const simulateFlightInfoMap = {
  135. departure: {
  136. C0: '深圳机场',
  137. C1: '2021-12-24',
  138. C2: '19 : 30 : 25',
  139. C3: '012',
  140. C4: '0',
  141. C5: '0',
  142. C6: '0',
  143. C7: '0',
  144. C8: '0',
  145. C9: '0',
  146. C10: '南京机场',
  147. C11: '2021-12-24',
  148. C12: '22 : 25 : 25',
  149. },
  150. arrival: {
  151. C0: '南京机场',
  152. C1: '2021-12-24',
  153. C2: '19 : 30 : 25',
  154. C3: '0',
  155. C4: '0',
  156. C5: '0',
  157. C6: '0',
  158. C7: '0',
  159. C8: '0',
  160. C9: '深圳机场',
  161. C10: '2021-12-24',
  162. C11: '19 : 30 : 25',
  163. C12: '012',
  164. },
  165. }
  166. export default function useFlightInfo(
  167. name: string,
  168. dataContent: CommonValue[]
  169. ) {
  170. const flightInfoItems = ref<{ label: string; key: string }[][]>([])
  171. const getFlightInfoItems = () => {
  172. flightInfoItems.value =
  173. flightInfoItemsMap[name.includes('Departure') ? 'departure' : 'arrival']
  174. }
  175. getFlightInfoItems()
  176. const flightInfo = reactive<CommonData>({})
  177. const getFlightInfo = async () => {
  178. try {
  179. const {
  180. code,
  181. returnData: { listValues },
  182. message,
  183. } = await Query({
  184. id: DATACONTENT_ID.flightInfo,
  185. dataContent,
  186. })
  187. if (Number(code) !== 0) {
  188. throw new Error(message ?? '失败')
  189. }
  190. if (!listValues.length) {
  191. ElMessage.error('未查询到航班信息')
  192. return
  193. }
  194. Object.assign(flightInfo, listValues[0])
  195. } catch (error) {
  196. console.error(error)
  197. }
  198. }
  199. const getSimulateFlightInfo = () => {
  200. const simulateFlightInfo =
  201. simulateFlightInfoMap[
  202. name.includes('Departure') ? 'departure' : 'arrival'
  203. ]
  204. Object.assign(flightInfo, simulateFlightInfo)
  205. }
  206. onMounted(() => {
  207. // getFlightInfo()
  208. getSimulateFlightInfo()
  209. })
  210. return {
  211. flightInfoItems,
  212. flightInfo,
  213. }
  214. }