index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. <template>
  2. <div class="waybill">
  3. <div class="waybill-info">
  4. <div class="waybill-info-title">运单基本信息</div>
  5. <div class="waybill-info-content flex">
  6. <div
  7. v-for="(item, index) in waybillInfoItems"
  8. :key="index"
  9. class="waybill-info-item"
  10. >
  11. <div>{{ item.label }}:</div>
  12. <el-tooltip
  13. :disabled="!computedWaybillInfo(item) || !item.showOverflowTooltip"
  14. :content="computedWaybillInfo(item)"
  15. effect="light"
  16. >
  17. <div>{{ computedWaybillInfo(item) }}</div>
  18. </el-tooltip>
  19. </div>
  20. </div>
  21. </div>
  22. <div class="waybill-header flex">
  23. <div class="waybill-header-title flex-wrap">
  24. <div class="manageTitle">运单跟踪信息</div>
  25. <div class="status">正常</div>
  26. </div>
  27. <div class="waybill-header-operate flex-wrap">
  28. <Search @clear="clear" @search="search" />
  29. <el-button
  30. class="button-sqaure"
  31. :icon="Download"
  32. color="#ac014d"
  33. @click="downloadHandler"
  34. />
  35. <ColumnSet
  36. class="button-sqaure"
  37. :table-columns="tableColumns"
  38. @checked-submit="columnChecked"
  39. />
  40. </div>
  41. </div>
  42. <div
  43. v-show="trackAirlines.length"
  44. :style="{
  45. maxHeight: trackAirlines.length > 1 ? `${208 * 2 + 8}px` : '208px',
  46. }"
  47. class="waybill-track"
  48. >
  49. <el-scrollbar always>
  50. <div class="waybill-track-warpper">
  51. <div
  52. v-for="trackAirline in trackAirlines"
  53. :key="trackAirline.flightNO"
  54. class="waybill-track-row"
  55. >
  56. <div
  57. v-for="(trackAirport, index) in trackAirline.airports"
  58. :key="trackAirport.airport"
  59. class="waybill-track-box"
  60. :style="trackBoxStyle(trackAirline.airports, index)"
  61. >
  62. <div class="title flex-wrap">
  63. <span v-if="index === 0" class="title-span"
  64. >航班号:{{ trackAirline.flightNO }}</span
  65. >
  66. <span
  67. v-if="!name.includes('InternationalDeparture')"
  68. class="title-span"
  69. >{{ trackAirport.isDeparture ? '出港' : '进港' }}:{{
  70. trackAirport.airport
  71. }}</span
  72. >
  73. <span class="title-span"
  74. >日期:{{ trackAirline.flightDate }}</span
  75. >
  76. </div>
  77. <Steps :steps="trackAirport.trackSteps" />
  78. </div>
  79. </div>
  80. </div>
  81. </el-scrollbar>
  82. </div>
  83. <div class="goods-list">
  84. <SimpleTable
  85. ref="tableRef"
  86. :data="tableData"
  87. :columns="filteredColumns"
  88. scrollbar-always-on
  89. :row-class-name="rowClass"
  90. :cell-class-name="cellClass"
  91. @cell-click="cellClickHandler"
  92. :column-props="{ formatter, minWidth: 75 }"
  93. />
  94. </div>
  95. </div>
  96. </template>
  97. <script setup lang="ts">
  98. import { Download } from '@element-plus/icons-vue'
  99. import Search from '@/components/search/index.vue'
  100. import Steps from '@/components/steps/index.vue'
  101. import ColumnSet from '@/components/ColumnSet/index.vue'
  102. import SimpleTable from '@/components/SimpleTable/index.vue'
  103. import { useTrackData } from '../../hooks/useTrackData'
  104. import { useTable } from '../../hooks/useTable'
  105. import { useTableColumnSet } from '@/hooks/useTableColumnSet'
  106. import { useTableExport } from '../../hooks/useTableExport'
  107. import { useTableStyle } from '../../hooks/useTableStyle'
  108. import { useTableCellClick } from '../../hooks/useTableCellClick'
  109. import { useWaybillInfo } from './useWaybillInfo'
  110. import { CommonData, CommonTableFormatter } from '~/common'
  111. import { useLoop } from '@/hooks/useLoop'
  112. const props = defineProps({
  113. name: {
  114. type: String,
  115. required: true,
  116. },
  117. })
  118. const route = useRoute()
  119. const { flightDate, waybillNO } = route.query
  120. const dataContent = [flightDate, waybillNO] as string[]
  121. const {
  122. waybillInfoItems,
  123. waybillInfo,
  124. computedWaybillInfo,
  125. getWaybillInfo,
  126. } = useWaybillInfo(props.name, dataContent)
  127. const { tableColumns, tableData: trackData, getTableData } = useTable(
  128. `${props.name}Goods`,
  129. dataContent
  130. )
  131. // 判断是否有另外一个机场的节点信息,没有则隐藏那些列
  132. watch(trackData, data => {
  133. let anotherAirportNodes: string[] = []
  134. let currentAirportNodeFlag = ''
  135. if (props.name === 'DepartureWaybill') {
  136. anotherAirportNodes = [
  137. 'CARGOS_ARR_HANDOVER',
  138. 'CARGOS_HANDOVER_STATUS_01',
  139. '货站交接',
  140. 'IMP_TALLY',
  141. 'FSUDLV',
  142. ]
  143. currentAirportNodeFlag = 'node-departure'
  144. }
  145. if (props.name === 'ArrivalWaybill') {
  146. anotherAirportNodes = [
  147. 'DEH',
  148. 'ACC_CHECK',
  149. '安检',
  150. 'ACC_BUP',
  151. 'LS_CARGO',
  152. 'CARGOS_HANDOVER_STATUS_02',
  153. 'CARGOS_HANDOVER_STATUS_03',
  154. '出港货邮',
  155. '装载完成',
  156. '关闭舱门',
  157. 'CARGOS_OFFLOAD',
  158. 'OFFLOAD_CONFIRM',
  159. 'BILL_RETURN',
  160. ]
  161. currentAirportNodeFlag = 'node-arrival'
  162. }
  163. const hasAnotherAirportData = data.some(
  164. ({ nodeCode }) =>
  165. typeof nodeCode === 'string' && anotherAirportNodes.includes(nodeCode)
  166. )
  167. if (!hasAnotherAirportData) {
  168. console.log(1)
  169. tableColumns.value = tableColumns.value.filter(
  170. ({ className }) =>
  171. typeof className !== 'string' ||
  172. !className.includes('node-') ||
  173. className.includes(currentAirportNodeFlag)
  174. )
  175. }
  176. })
  177. useLoop([getWaybillInfo, getTableData], 'waybill')
  178. const { trackAirlines, trackBoxStyle } = useTrackData(props.name, trackData)
  179. const tableData = computed(() => {
  180. const mergedTableData = trackData.value.reduce(
  181. (data: CommonData[], current) => {
  182. const sameRow = data.find(row =>
  183. ['stockCode', 'flightNO', 'flightDate', 'cargoSN'].every(
  184. key => row[key] === current[key]
  185. )
  186. )
  187. const {
  188. stockCode,
  189. flightNO,
  190. flightDate,
  191. departureAirport, // 装载机场
  192. arriveAirport, // 卸载机场
  193. ULDNO,
  194. cargoSN,
  195. pullMark,
  196. returnMark,
  197. // transMark,
  198. exceptionCustomsMark,
  199. execPosition, // 读取位置
  200. nodeCode, // 节点名称
  201. ConsignmentItemPackagingQuantityQuantity, // 跟踪节点件数
  202. execResult,
  203. execTime,
  204. } = current
  205. const nodeValue = `${execPosition ?? ''}\n${
  206. execResult ? '通过' : '未通过'
  207. }\n${execTime ?? ''}`
  208. if (sameRow) {
  209. sameRow[String(nodeCode)] = nodeValue
  210. ;[
  211. 'ULDNO',
  212. // 'cargoSN'
  213. ].forEach(key => {
  214. const oldValue = sameRow[key]
  215. const currentValue = current[key]
  216. if (typeof currentValue === 'string' && currentValue !== oldValue) {
  217. if (typeof oldValue === 'string') {
  218. sameRow[key] = [
  219. ...new Set([
  220. ...oldValue.split(','),
  221. ...currentValue.split(','),
  222. ]),
  223. ].join(',')
  224. } else {
  225. sameRow[key] = currentValue
  226. }
  227. }
  228. })
  229. ;['pullMark', 'returnMark'].forEach(key => {
  230. sameRow[key] = sameRow[key] ?? current[key]
  231. })
  232. } else {
  233. data.push({
  234. ...current,
  235. [String(nodeCode)]: nodeValue,
  236. })
  237. }
  238. return data
  239. },
  240. []
  241. )
  242. return mergedTableData.reduce((data: CommonData[], current) => {
  243. const { cargoSN } = current
  244. if (typeof cargoSN === 'string') {
  245. const splitedRows = cargoSN.split(',').map(splitedCargoSN => ({
  246. ...current,
  247. cargoSN: splitedCargoSN,
  248. }))
  249. data.push(...splitedRows)
  250. } else {
  251. data.push(current)
  252. }
  253. return data
  254. }, [])
  255. })
  256. const formatter: CommonTableFormatter = (row, column, cellValue, index) => {
  257. const value = String(cellValue ?? '').split('\n')
  258. if (value[2]) {
  259. value[2] = value[2].split('T')[1].slice(0, -3)
  260. }
  261. return value.join('\n')
  262. }
  263. const search = (text: string) => {
  264. console.log(text)
  265. }
  266. const clear = () => {}
  267. const tableRef = ref<InstanceType<typeof SimpleTable> | null>(null)
  268. const { exportToExcel } = useTableExport()
  269. const downloadHandler = () => {
  270. const table = tableRef.value!.table!
  271. exportToExcel({ table })
  272. }
  273. const { filteredColumns, columnChecked } = useTableColumnSet(tableColumns)
  274. const { rowClass, cellClass } = useTableStyle(`${props.name}Goods`)
  275. const { cellClickHandler } = useTableCellClick(`${props.name}Goods`)
  276. </script>
  277. <style lang="scss" scoped>
  278. .waybill {
  279. height: 100%;
  280. display: flex;
  281. flex-direction: column;
  282. &-info {
  283. height: 144px;
  284. background: #410425;
  285. padding: 24px 30px;
  286. color: #ffffff;
  287. &-title {
  288. font-size: 18px;
  289. font-family: Microsoft YaHei;
  290. font-weight: bold;
  291. margin-bottom: 40px;
  292. }
  293. &-item {
  294. display: flex;
  295. .el-tooltip__trigger {
  296. max-width: 300px;
  297. overflow: hidden;
  298. white-space: nowrap;
  299. text-overflow: ellipsis;
  300. }
  301. }
  302. }
  303. &-header :deep {
  304. margin: 24px 0;
  305. line-height: 32px;
  306. .status {
  307. font-size: 16px;
  308. font-family: Microsoft YaHei;
  309. font-weight: bold;
  310. color: #519f6b;
  311. }
  312. .el-button {
  313. background-color: #d5327b;
  314. border: none;
  315. }
  316. .button-sqaure {
  317. width: 30px;
  318. height: 30px;
  319. border-radius: 4px;
  320. font-size: 16px;
  321. margin-left: 24px;
  322. &:first-of-type {
  323. margin-left: 35px;
  324. }
  325. }
  326. }
  327. &-track {
  328. height: 0;
  329. flex: 1.5;
  330. &-row {
  331. height: 208px;
  332. display: flex;
  333. &:not(:last-child) {
  334. margin-bottom: 8px;
  335. }
  336. }
  337. &-box {
  338. background: #ffffff;
  339. padding: 24px 24px 12px 24px;
  340. &:not(:last-child) {
  341. margin-right: 8px;
  342. }
  343. .title {
  344. font-size: 16px;
  345. font-family: Microsoft YaHei;
  346. font-weight: bold;
  347. color: #101116;
  348. margin-bottom: 10px;
  349. &-span:not(:last-of-type) {
  350. margin-right: 8px;
  351. }
  352. }
  353. }
  354. }
  355. .goods-list :deep {
  356. margin-top: 16px;
  357. height: 0;
  358. flex: 1;
  359. .el-table__body .el-table__cell .cell {
  360. padding: 4px 8px;
  361. }
  362. }
  363. }
  364. </style>