editForm.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. <template>
  2. <a-spin :spinning="confirmLoading">
  3. <!-- 主表单区域 -->
  4. <a-form class="antd-modal-form" ref="formRef" :model="model" :labelCol="labelCol" :wrapperCol="wrapperCol">
  5. <a-row :gutter="24">
  6. <a-col :span="12">
  7. <a-form-item label="铸机">
  8. <JSearchSelect placeholder="请选择" disabled v-model:value="model.ccmNo" dict="lg_zj" defaultValue="5" />
  9. </a-form-item>
  10. </a-col>
  11. </a-row>
  12. <a-row :gutter="24">
  13. <a-col :span="12">
  14. <a-form-item label="班组">
  15. <JSearchSelect type="list" v-model:value="model.shiftGroup" dict="lg_bz" placeholder="请选择" allowClear />
  16. </a-form-item>
  17. </a-col>
  18. <a-col :span="12">
  19. <a-form-item label="班别">
  20. <JSearchSelect type="list" v-model:value="model.shift" dict="lg_bb" placeholder="请选择" allowClear />
  21. </a-form-item>
  22. </a-col>
  23. </a-row>
  24. <a-row :gutter="24">
  25. <a-col :span="12">
  26. <a-form-item label="到站时间">
  27. <a-date-picker style="width: 100%" show-time v-model:value="model.arrivalTime" placeholder="到站时间" />
  28. </a-form-item>
  29. </a-col>
  30. <a-col :span="12">
  31. <a-form-item label="发车时间">
  32. <a-date-picker style="width: 100%" show-time v-model:value="model.outTime" placeholder="发车时间" />
  33. </a-form-item>
  34. </a-col>
  35. </a-row>
  36. <a-row :gutter="24">
  37. <a-col :span="12">
  38. <a-form-item label="钢种">
  39. <a-input v-model:value="model.steel" placeholder="请输入" allowClear />
  40. <!-- <JSearchSelect type="list" v-model:value="model.steel" dict="billet_spec" placeholder="请选择" /> -->
  41. </a-form-item>
  42. </a-col>
  43. <a-col :span="12">
  44. <a-form-item label="规格">
  45. <a-input v-model:value="model.spec" placeholder="请输入" allowClear />
  46. </a-form-item>
  47. </a-col>
  48. </a-row>
  49. <a-row :gutter="24">
  50. <a-col :span="12">
  51. <a-form-item label="定尺">
  52. <!-- <a-input v-model:value="model.size" placeholder="请输入" allowClear @input="(val) => formatFloatData(val, 'size')" /> -->
  53. <JSearchSelect type="list" v-model:value="model.size" dict="lg_dcgg" placeholder="请选择" allowClear />
  54. </a-form-item>
  55. </a-col>
  56. <a-col :span="12">
  57. <a-form-item label="类型">
  58. <JSearchSelect placeholder="请选择" v-model:value="model.btype" dict="lg_btype" allowClear />
  59. </a-form-item>
  60. </a-col>
  61. </a-row>
  62. <a-row :gutter="24">
  63. <a-col :span="12">
  64. <a-form-item label="目的地">
  65. <JSearchSelect
  66. type="list"
  67. v-model:value="model.destination"
  68. :disabled="Number(model.typeConfigId) !== 1024"
  69. :dictOptions="machineConfig[model.ccmNo]"
  70. placeholder="请选择"
  71. allowClear
  72. />
  73. </a-form-item>
  74. </a-col>
  75. <a-col :span="12">
  76. <a-form-item label="车牌号">
  77. <JSearchSelect type="list" v-model:value="model.licensePlate" dict="lg_car" placeholder="请选择" allowClear />
  78. </a-form-item>
  79. </a-col>
  80. </a-row>
  81. <a-row :gutter="24">
  82. <a-col :span="12">
  83. <a-form-item label="牌号">
  84. <JSearchSelect type="list" v-model:value="model.brandNum" dict="billet_spec" placeholder="请选择" allowClear />
  85. </a-form-item>
  86. </a-col>
  87. <a-col :span="12">
  88. <a-form-item label="新/旧站台">
  89. <a-select allowClear v-model:value="model.newOldPlatform" :options="platformOptions"></a-select>
  90. </a-form-item>
  91. </a-col>
  92. </a-row>
  93. <a-row :gutter="24">
  94. <a-col :span="12">
  95. <a-form-item label="车位号">
  96. <a-select style="width: 100%" disabled v-model:value="model.positionNum" placeholder="请选择" :options="carPosition" />
  97. </a-form-item>
  98. </a-col>
  99. <a-col :span="12">
  100. <a-form-item label="总支数">
  101. <a-input-number
  102. :disabled="!model.outTime"
  103. style="width: 100%"
  104. v-model:value="model.amountTotal"
  105. placeholder="请输入"
  106. allowClear
  107. :min="0"
  108. :max="100"
  109. />
  110. </a-form-item>
  111. </a-col>
  112. </a-row>
  113. <a-row :gutter="24">
  114. <a-col :span="24">
  115. <a-form-item label="备注" :labelCol="{ xs: { span: 24 }, sm: { span: 2 } }" :wrapperCol="{ xs: { span: 24 }, sm: { span: 22 } }">
  116. <a-textarea v-model:value="model.remarks" placeholder="请输入" allowClear />
  117. </a-form-item>
  118. </a-col>
  119. </a-row>
  120. </a-form>
  121. </a-spin>
  122. </template>
  123. <script lang="ts" setup>
  124. import { ref } from 'vue';
  125. import { defHttp } from '/@/utils/http/axios';
  126. import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
  127. // import { dictOptions } from '../shippingBill.data';
  128. import { queryBilletNameList } from '../../hotDelivery/hotDelivery.api';
  129. import { carPosition } from '../shippingBill.data';
  130. import { getDictItemsByCode } from '/@/utils/dict/index';
  131. import dayjs from 'dayjs';
  132. import { platformOptions } from '../../ShiftConfiguration/ShiftConfiguration.data';
  133. const props = defineProps({
  134. rowData: {
  135. type: Object,
  136. default: () => ({}),
  137. required: true,
  138. },
  139. });
  140. const labelCol = ref<any>({ xs: { span: 5 }, sm: { span: 5 } });
  141. const wrapperCol = ref<any>({ xs: { span: 17 }, sm: { span: 17 } });
  142. const formRef = ref();
  143. const model = ref<Record<string, any>>({});
  144. const confirmLoading = ref<boolean>(false);
  145. const edit = () => {
  146. //值回显
  147. model.value = {
  148. ...props.rowData,
  149. arrivalTime: props.rowData.arrivalTime ? dayjs(props.rowData.arrivalTime) : null,
  150. outTime: props.rowData.outTime ? dayjs(props.rowData.outTime) : null,
  151. positionNum: props.rowData.ccmNo == 6 ? props.rowData.positionNum || 3 : 1,
  152. };
  153. console.log(props.rowData);
  154. getMachineConfig(props.rowData.ccmNo);
  155. };
  156. // 根据铸机号获取配置信息
  157. const machineConfig = ref({
  158. '5': [],
  159. '6': [],
  160. });
  161. const getMachineConfig = async (machineNum) => {
  162. if (!machineNum) {
  163. return;
  164. }
  165. try {
  166. const res = await queryBilletNameList({ ccmNo: machineNum });
  167. if (!machineConfig.value[machineNum]) {
  168. machineConfig.value[machineNum] = {};
  169. }
  170. if (res.length) {
  171. machineConfig.value[machineNum] = res
  172. .filter((v) => v.isTrucking)
  173. .map((item) => {
  174. return {
  175. id: item.id,
  176. value: item.typeName,
  177. text: item.typeName,
  178. label: item.typeName,
  179. };
  180. });
  181. }
  182. } catch (error) {
  183. console.error('Error fetching data:', error);
  184. }
  185. };
  186. /**
  187. * 提交数据
  188. */
  189. async function submitForm() {
  190. const {
  191. id,
  192. dateTime,
  193. ccmNo,
  194. shiftGroup,
  195. shift,
  196. steel,
  197. spec,
  198. size,
  199. licensePlate,
  200. amountTotal,
  201. btype,
  202. arrivalTime,
  203. outTime,
  204. carNum,
  205. destination,
  206. typeConfigId,
  207. licensePlateStatus,
  208. brandNum,
  209. newOldPlatform,
  210. remarks,
  211. } = model.value;
  212. let objParams = {
  213. id,
  214. dateTime,
  215. ccmNo,
  216. shiftGroup,
  217. shift,
  218. steel,
  219. spec,
  220. size,
  221. licensePlate,
  222. amountTotal,
  223. btype,
  224. arrivalTime,
  225. outTime,
  226. carNum,
  227. destination,
  228. typeConfigId,
  229. remarks,
  230. brandNum,
  231. newOldPlatform,
  232. };
  233. confirmLoading.value = true;
  234. const newTypeConfigId = destination ? machineConfig.value[ccmNo].find((item) => item.label == destination).id : null;
  235. // 获取车辆字典
  236. const hasCar = (getDictItemsByCode('lg_car') || []).find((item) => item.value == licensePlate);
  237. defHttp
  238. .put(
  239. {
  240. url: '/storageBill/edit',
  241. params: { ...objParams, id: props.rowData.id, typeConfigId: newTypeConfigId, licensePlateStatus: !hasCar ? 1 : 0 },
  242. },
  243. { isTransformResponse: false }
  244. )
  245. .finally(() => {
  246. confirmLoading.value = false;
  247. });
  248. }
  249. defineExpose({
  250. edit,
  251. submitForm,
  252. });
  253. </script>
  254. <style lang="less" scoped>
  255. .antd-modal-form {
  256. padding: 24px 24px 24px 24px;
  257. }
  258. </style>