ContainerWaybillDialog.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <Dialog
  3. :flag="flag"
  4. width="1440px"
  5. :msg-title="msgTitle"
  6. :with-footer="false"
  7. @reset-form="dialogHide"
  8. >
  9. <div class="dialog-content">
  10. <SimpleTable
  11. :data="tableData"
  12. :columns="tableColumns"
  13. :column-props="{ formatter }"
  14. />
  15. </div>
  16. </Dialog>
  17. </template>
  18. <script setup lang="ts">
  19. import Dialog from '@/components/dialog/index.vue'
  20. import SimpleTable from '@/components/SimpleTable/index.vue'
  21. import { Query } from '@/api/webApi'
  22. import { PropType } from 'vue'
  23. import { CommonData, CommonTableColumn, CommonValue } from '~/common'
  24. const props = defineProps({
  25. flag: {
  26. type: Boolean,
  27. required: true,
  28. },
  29. dataContent: {
  30. type: Array as PropType<CommonValue[]>,
  31. required: true,
  32. },
  33. isDeparture: {
  34. type: Boolean,
  35. default: true,
  36. },
  37. })
  38. const emit = defineEmits(['update:flag'])
  39. const dialogHide = () => {
  40. emit('update:flag', false)
  41. }
  42. const tableColumnsMap = {
  43. departure: [
  44. { columnLabel: '运单号', columnName: 'stockCode', width: 120 },
  45. // { columnLabel: '集装器数量', columnName: 'stowageNum', needCount: 1 },
  46. {
  47. columnLabel: '品名',
  48. columnName: 'typeCode',
  49. width: 300,
  50. showOverflowTooltip: true,
  51. },
  52. { columnLabel: '特货信息', columnName: 'speCargoInfo' },
  53. { columnLabel: '货物件数', columnName: 'luggageCount', needCount: 1 },
  54. { columnLabel: '拉下件数', columnName: 'pullNum', needCount: 1 },
  55. { columnLabel: '退运件数', columnName: 'returnNum', needCount: 1 },
  56. { columnLabel: '最新节点', columnName: 'nodeCode' },
  57. { columnLabel: '最新位置', columnName: 'execPosition' },
  58. { columnLabel: '处理结果', columnName: 'execResult' },
  59. { columnLabel: '处理时间', columnName: 'execTime', width: 130 },
  60. ],
  61. arrival: [
  62. { columnLabel: '运单号', columnName: 'stockCode', width: 120 },
  63. {
  64. columnLabel: '品名',
  65. columnName: 'typeCode',
  66. width: 300,
  67. showOverflowTooltip: true,
  68. },
  69. { columnLabel: '特货信息', columnName: 'speCargoInfo', needCount: 1 },
  70. {
  71. columnLabel: '进港报文货物件数',
  72. columnName: 'messageCargos_in',
  73. needCount: 1,
  74. },
  75. {
  76. columnLabel: '进港实际货物件数',
  77. columnName: 'acCargos_in',
  78. needCount: 1,
  79. },
  80. { columnLabel: '最新节点', columnName: 'nodeCode' },
  81. { columnLabel: '最新位置', columnName: 'execPosition' },
  82. { columnLabel: '处理结果', columnName: 'execResult' },
  83. { columnLabel: '处理时间', columnName: 'execTime', width: 130 },
  84. ],
  85. }
  86. const msgTitle = computed(() => props.dataContent.join('-'))
  87. const tableColumns = ref<CommonTableColumn[]>([])
  88. const getTableColumns = () => {
  89. tableColumns.value = tableColumnsMap[
  90. props.isDeparture ? 'departure' : 'arrival'
  91. ].map(column => ({
  92. columnDescribe: '',
  93. dataType: '',
  94. listqueryTemplateID: null,
  95. needCount: null,
  96. needFilters: null,
  97. needGroup: null,
  98. needSearch: null,
  99. needShow: 1,
  100. needSort: null,
  101. orderNumber: null,
  102. queryTemplateColumnSetID: null,
  103. queryTemplateID: null,
  104. ...column,
  105. }))
  106. }
  107. const tableData = ref<CommonData[]>([])
  108. const getTableData = async () => {
  109. try {
  110. const {
  111. code,
  112. returnData: { listValues },
  113. message,
  114. } = await Query<CommonData>({
  115. id:
  116. DATACONTENT_ID[
  117. `${props.isDeparture ? 'departure' : 'arrival'}ContainerWaybill`
  118. ],
  119. dataContent: props.dataContent,
  120. })
  121. if (Number(code) !== 0) {
  122. throw new Error(message || '失败')
  123. }
  124. tableData.value = listValues.filter(
  125. row =>
  126. !Object.values(row).some(
  127. cellValue =>
  128. typeof cellValue === 'string' && cellValue.includes('undefined')
  129. )
  130. )
  131. } catch (error) {
  132. console.error(error)
  133. }
  134. }
  135. const resetTable = () => {
  136. tableColumns.value = []
  137. tableData.value = []
  138. }
  139. watch(
  140. () => props.flag,
  141. val => {
  142. resetTable()
  143. if (val) {
  144. getTableColumns()
  145. getTableData()
  146. }
  147. }
  148. )
  149. const formatter = (row, column, cellValue, index) => {
  150. if (column.property.includes('Time') && typeof cellValue === 'string') {
  151. return cellValue.replace('T', '\n')
  152. }
  153. return String(cellValue ?? '')
  154. }
  155. </script>
  156. <style scoped lang="scss">
  157. .dialog-content {
  158. padding: 0 22px;
  159. min-height: 300px;
  160. }
  161. </style>