mainInfo.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. <template>
  2. <a-form :model="currentFrom" label-align="left" @submit="handleSubmit">
  3. <strong class="strong before-flag">运单信息</strong>
  4. <a-row :gutter="16">
  5. <template v-for="item in mainOrderInfo" :key="item.field">
  6. <a-col v-if="!item.hidden || mainFlag" :span="item.clo">
  7. <a-form-item
  8. :field="item.field"
  9. :label="item.label"
  10. :rules="item.rules"
  11. :hide-asterisk="isDetail"
  12. :label-col-flex="labelWidth"
  13. >
  14. <p v-if="isDetail || !item.type">{{
  15. currentFrom[item.field]
  16. ? currentFrom[item.field] + (item.unit || '')
  17. : '--'
  18. }}</p>
  19. <a-input
  20. v-else
  21. v-model="currentFrom[item.field]"
  22. :disabled="isDisabled"
  23. :max-length="item['max-length']"
  24. :placeholder="item.placeholder"
  25. />
  26. </a-form-item>
  27. </a-col>
  28. </template>
  29. </a-row>
  30. <a-row v-if="mainFlag" :gutter="16">
  31. <a-col :span="24">
  32. <a-form-item label="货物尺寸" :label-col-flex="labelWidth">
  33. <a-table
  34. class="w-full"
  35. :columns="dimSizeColumns"
  36. :data="currentFrom.dimSizeList"
  37. :pagination="false"
  38. >
  39. </a-table>
  40. <template #extra>
  41. <div class="flex items-center justify-between text-base mt-3 px-1">
  42. <div>总计件数:{{ currentFrom.pcsDec || '0' }}</div>
  43. <div>总计重量:{{ currentFrom.wtDec || '0' }}KG</div>
  44. <div>总计体积:{{ currentFrom.volumeSum || '0' }}m³</div>
  45. <div>总计体积重量:{{ currentFrom.volumeAvg || '0' }}KG</div>
  46. </div>
  47. </template>
  48. </a-form-item>
  49. </a-col>
  50. </a-row>
  51. <strong class="strong before-flag">航班信息</strong>
  52. <a-row :gutter="16">
  53. <template v-for="item in mainFlyInfo" :key="item.field">
  54. <a-col v-if="!item.hidden || mainFlag" :span="item.clo">
  55. <a-form-item
  56. :field="item.field"
  57. :label="item.label"
  58. :label-col-flex="labelWidth"
  59. >
  60. <p v-if="isDetail">{{ currentFrom[item.field] || '--' }}</p>
  61. <a-input
  62. v-else
  63. v-model="currentFrom[item.field]"
  64. :disabled="isDisabled"
  65. />
  66. </a-form-item>
  67. </a-col>
  68. </template>
  69. </a-row>
  70. <article class="w-full flex justify-center mt-5">
  71. <!-- <a-button @click="emit('cancel')">取消</a-button> -->
  72. <a-button v-if="!isDetail" class="ml-4" type="primary" html-type="submit"
  73. >下一步</a-button
  74. >
  75. </article>
  76. </a-form>
  77. </template>
  78. <script lang="ts" setup>
  79. import { PropType, computed } from 'vue';
  80. import { MODEL_TYPE } from '@/constant/base';
  81. import { WAYBILL_TYPE } from '@/constant/waybill';
  82. import { useWaybillStore } from '@/store';
  83. import { dimSizeColumns } from './functions/table';
  84. import { mainFlyInfo, mainOrderInfo } from './functions/data';
  85. let valueKey: 'mawbDetail' | 'hawbDetail' = 'mawbDetail';
  86. const labelWidth = '100px';
  87. const props = defineProps({
  88. modelType: {
  89. type: Number,
  90. default: MODEL_TYPE.ADD,
  91. },
  92. orderType: {
  93. type: Number,
  94. default: WAYBILL_TYPE.MAIN,
  95. },
  96. isDisabled: {
  97. type: Boolean,
  98. default: true,
  99. },
  100. fromData: {
  101. type: Object,
  102. default: () => ({}),
  103. },
  104. });
  105. const { fromData, orderType, modelType } = toRefs(props);
  106. const emit = defineEmits(['nextTabs', 'cancel']);
  107. const waybillStore = useWaybillStore();
  108. const currentFrom = ref<Record<string, any>>({});
  109. const isDetail = computed(() => modelType.value === MODEL_TYPE.DETAIL);
  110. const mainFlag = computed(() => orderType.value === WAYBILL_TYPE.MAIN);
  111. const handleSubmit = async (res: any) => {
  112. const { errors, values } = res;
  113. if (!errors) {
  114. waybillStore.setValueByKey(valueKey, values);
  115. emit('nextTabs');
  116. }
  117. };
  118. onMounted(() => {
  119. valueKey =
  120. orderType.value === WAYBILL_TYPE.MAIN ? 'mawbDetail' : 'hawbDetail';
  121. currentFrom.value = fromData.value[valueKey];
  122. });
  123. </script>
  124. <style lang="less" scoped>
  125. :deep(.arco-form-item-extra) {
  126. width: 100%;
  127. }
  128. </style>