index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  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. <span
  7. v-for="item in waybillInfoItems"
  8. :key="item.key"
  9. class="waybill-info-item"
  10. >
  11. <span>{{ item.label }}:</span>
  12. <el-tooltip
  13. v-if="item.key === 'typeCode'"
  14. effect="light"
  15. :content="computedWaybillInfo(item)"
  16. >
  17. <span class="waybill-info-item-value">{{
  18. computedWaybillInfo(item)
  19. }}</span>
  20. </el-tooltip>
  21. <span v-else>{{ computedWaybillInfo(item) }}</span>
  22. </span>
  23. </div>
  24. </div>
  25. <div class="waybill-header flex">
  26. <div class="waybill-header-title flex-wrap">
  27. <div class="manageTitle">运单跟踪信息</div>
  28. <div class="status">正常</div>
  29. </div>
  30. <div class="waybill-header-operate flex-wrap">
  31. <Search @clear="clear" @search="search" />
  32. <el-button
  33. class="button-sqaure"
  34. :icon="Download"
  35. color="#ac014d"
  36. @click="downloadHandler"
  37. />
  38. <ColumnSet
  39. class="button-sqaure"
  40. :table-columns="tableColumns"
  41. @checked-submit="columnChecked"
  42. />
  43. </div>
  44. </div>
  45. <div
  46. v-show="trackAirlines.length"
  47. :style="{
  48. maxHeight: trackAirlines.length > 1 ? `${208 * 2 + 8}px` : '208px',
  49. }"
  50. class="waybill-track"
  51. >
  52. <el-scrollbar always>
  53. <div class="waybill-track-warpper">
  54. <div
  55. v-for="trackAirline in trackAirlines"
  56. :key="trackAirline.flightNO"
  57. class="waybill-track-row"
  58. >
  59. <div
  60. v-for="(trackAirport, index) in trackAirline.airports"
  61. :key="trackAirport.airport"
  62. class="waybill-track-box"
  63. :style="trackBoxStyle(trackAirline.airports, index)"
  64. >
  65. <div class="title flex-wrap">
  66. <span v-if="index === 0" class="title-span"
  67. >航班号:{{ trackAirline.flightNO }}</span
  68. >
  69. <span class="title-span"
  70. >{{ trackAirport.isDeparture ? '出港' : '进港' }}:{{
  71. trackAirport.airport
  72. }}</span
  73. >
  74. <span class="title-span"
  75. >日期:{{ trackAirline.flightDate }}</span
  76. >
  77. </div>
  78. <Steps :steps="trackAirport.trackSteps" />
  79. </div>
  80. </div>
  81. </div>
  82. </el-scrollbar>
  83. </div>
  84. <div class="goods-list">
  85. <SimpleTable
  86. ref="tableRef"
  87. :data="tableData"
  88. :columns="filteredColumns"
  89. scrollbar-always-on
  90. :row-class-name="rowClass"
  91. :cell-class-name="cellClass"
  92. @cell-click="cellClickHandler"
  93. :column-props="{ formatter, minWidth: 75 }"
  94. />
  95. </div>
  96. </div>
  97. </template>
  98. <script setup lang="ts">
  99. import { Download } from '@element-plus/icons-vue'
  100. import Search from '@/components/search/index.vue'
  101. import Steps from '@/components/steps/index.vue'
  102. import ColumnSet from '../../components/ColumnSet/index.vue'
  103. import SimpleTable from '@/components/SimpleTable/index.vue'
  104. import { useTrackData } from '../../hooks/useTrackData'
  105. import { useTable } from '../../hooks/useTable'
  106. import { useTableColumnSet } from '../../hooks/useTableColumnSet'
  107. import { useTableExport } from '../../hooks/useTableExport'
  108. import { useTableStyle } from '../../hooks/useTableStyle'
  109. import { useTableCellClick } from '../../hooks/useTableCellClick'
  110. import { useWaybillInfo } from './useWaybillInfo'
  111. import { CommonData } from '~/common'
  112. const props = defineProps({
  113. name: {
  114. type: String,
  115. required: true,
  116. },
  117. })
  118. const route = useRoute()
  119. const { waybillNO } = route.query
  120. const {
  121. waybillInfoItems,
  122. waybillInfo,
  123. computedWaybillInfo,
  124. } = useWaybillInfo(props.name, [waybillNO as string])
  125. const { tableColumns, tableData: trackData } = useTable(`${props.name}Goods`, [
  126. waybillNO as string,
  127. ])
  128. const { trackAirlines, trackBoxStyle } = useTrackData(props.name, trackData)
  129. const tableData = computed(() =>
  130. trackData.value.reduce((data, current) => {
  131. const sameRow = data.find(row =>
  132. ['stockCode', 'flightNO', 'flightDate', 'ULDNO', 'CargoSN'].every(
  133. key => row[key] === current[key]
  134. )
  135. )
  136. const {
  137. stockCode,
  138. flightNO,
  139. flightDate,
  140. departureAirport, // 装载机场
  141. arriveAirport, // 卸载机场
  142. ULDNO,
  143. CargoSN,
  144. pullMark,
  145. returnMark,
  146. // transMark,
  147. // exceptionCustomsMark,
  148. execPosition, // 读取位置
  149. nodeCode, // 节点名称
  150. ConsignmentItemPackagingQuantityQuantity, // 跟踪节点件数
  151. execResult,
  152. execTime,
  153. } = current
  154. const nodeValue = `${execPosition ?? ''}\n${
  155. execResult ? '通过' : '未通过'
  156. }\n${execTime ?? ''}`
  157. if (sameRow) {
  158. sameRow[String(nodeCode)] = nodeValue
  159. } else {
  160. data.push({
  161. ...current,
  162. [String(nodeCode)]: nodeValue,
  163. })
  164. }
  165. return data
  166. }, [] as CommonData[])
  167. )
  168. const formatter = (row, column, cellValue, index) => {
  169. const value = String(cellValue ?? '').split('\n')
  170. if (value[2]) {
  171. value[2] = value[2].split('T')[1]
  172. }
  173. return value.join('\n')
  174. }
  175. const search = (text: string) => {
  176. console.log(text)
  177. }
  178. const clear = () => {}
  179. const tableRef = ref<InstanceType<typeof SimpleTable> | null>(null)
  180. const { exportToExcel } = useTableExport()
  181. const downloadHandler = () => {
  182. const table = tableRef.value!.table!
  183. exportToExcel({ table })
  184. }
  185. const { filteredColumns, columnChecked } = useTableColumnSet(tableColumns)
  186. const { rowClass, cellClass } = useTableStyle(`${props.name}Goods`)
  187. const { cellClickHandler } = useTableCellClick(`${props.name}Goods`)
  188. </script>
  189. <style lang="scss" scoped>
  190. .waybill {
  191. height: 100%;
  192. display: flex;
  193. flex-direction: column;
  194. &-info {
  195. height: 144px;
  196. background: #410425;
  197. padding: 24px 30px;
  198. color: #ffffff;
  199. &-title {
  200. font-size: 18px;
  201. font-family: Microsoft YaHei;
  202. font-weight: bold;
  203. margin-bottom: 40px;
  204. }
  205. &-item {
  206. display: flex;
  207. &-value {
  208. max-width: 300px;
  209. overflow: hidden;
  210. white-space: nowrap;
  211. text-overflow: ellipsis;
  212. }
  213. }
  214. }
  215. &-header :deep {
  216. margin: 24px 0;
  217. line-height: 32px;
  218. .status {
  219. font-size: 16px;
  220. font-family: Microsoft YaHei;
  221. font-weight: bold;
  222. color: #519f6b;
  223. }
  224. .el-button {
  225. background-color: #d5327b;
  226. border: none;
  227. }
  228. .button-sqaure {
  229. width: 30px;
  230. height: 30px;
  231. border-radius: 4px;
  232. font-size: 16px;
  233. margin-left: 24px;
  234. &:first-of-type {
  235. margin-left: 35px;
  236. }
  237. }
  238. }
  239. &-track {
  240. height: 0;
  241. flex: 1.5;
  242. &-row {
  243. height: 208px;
  244. display: flex;
  245. &:not(:last-child) {
  246. margin-bottom: 8px;
  247. }
  248. }
  249. &-box {
  250. background: #ffffff;
  251. padding: 24px 24px 12px 24px;
  252. &:not(:last-child) {
  253. margin-right: 8px;
  254. }
  255. .title {
  256. font-size: 16px;
  257. font-family: Microsoft YaHei;
  258. font-weight: bold;
  259. color: #101116;
  260. margin-bottom: 10px;
  261. &-span:not(:last-of-type) {
  262. margin-right: 30px;
  263. }
  264. }
  265. }
  266. }
  267. .goods-list :deep {
  268. margin-top: 16px;
  269. height: 0;
  270. flex: 1;
  271. .el-table__body .el-table__cell .cell {
  272. padding: 4px 8px;
  273. }
  274. }
  275. }
  276. </style>