Ver código fonte

fix(equipLedger): 修复设备图片上传和回显异常问题

1. 调整表单标签宽度优化布局显示
2. 新增图片上传result-type参数适配组件新接口
3. 重构设备附件列表的数据格式转换逻辑,统一编辑、详情页回显和提交时的数据结构
4. 修复重置表单时附件列表类型不匹配的问题
5. 新增中间状态管理附件列表,确保提交数据格式符合后端要求
huoyi 1 mês atrás
pai
commit
3be23c7dda
1 arquivos alterados com 32 adições e 4 exclusões
  1. 32 4
      src/views/equipManage/equipLedger/index.vue

+ 32 - 4
src/views/equipManage/equipLedger/index.vue

@@ -72,7 +72,7 @@
72 72
 
73 73
     <!-- 编辑/详情弹窗 -->
74 74
     <el-dialog :title="dialog.title" v-model="dialog.visible" width="1000px" :close-on-click-modal="false">
75
-      <el-form :model="form" ref="formRef" :rules="rules" label-width="140px">
75
+      <el-form :model="form" ref="formRef" :rules="rules" label-width="160px">
76 76
         <el-row :gutter="20">
77 77
           <el-col :span="12">
78 78
             <el-form-item label="设备名称" prop="equipmentName">
@@ -178,7 +178,7 @@
178 178
           </el-col>
179 179
           <el-col :span="24">
180 180
             <el-form-item label="设备图片" prop="baseAttachmentList">
181
-              <ImageUpload v-model="form.baseAttachmentList" :disabled="formDisabled" :limit="3" />
181
+              <ImageUpload v-model="form.baseAttachmentList" :disabled="formDisabled" :limit="3" result-type="object" />
182 182
             </el-form-item>
183 183
           </el-col>
184 184
         </el-row>
@@ -260,6 +260,7 @@ const { proxy } = getCurrentInstance()
260 260
 const { equipment_usage_status, equipment_inspection_nature } = proxy.useDict('equipment_usage_status', 'equipment_inspection_nature')
261 261
 
262 262
 const loading = ref(false)
263
+
263 264
 const queryFormRef = ref()
264 265
 const formRef = ref()
265 266
 const tableData = ref([])
@@ -291,7 +292,7 @@ const form = reactive({
291 292
   manufacturingDate: '',
292 293
   acceptanceDate: '',
293 294
   commissioningDate: '',
294
-  usageStatus: '1',
295
+  usageStatus: '',
295 296
   scrappingDate: '',
296 297
   installationLocation: '',
297 298
   inspectionSelfCheckDate: '',
@@ -304,6 +305,16 @@ const form = reactive({
304 305
   baseAttachmentList: [],
305 306
   equipmentInspectionRecordList: []
306 307
 })
308
+const baseAttachmentListInternal = ref([])
309
+
310
+watch(() => form.baseAttachmentList, (newVal) => {
311
+  if (newVal && Array.isArray(newVal)) {
312
+    baseAttachmentListInternal.value = newVal.map(item => ({
313
+      attachmentName: item.name || item.originalFilename || '',
314
+      attachmentUrl: item.url || ''
315
+    }))
316
+  }
317
+}, { deep: true, immediate: true })
307 318
 const rules = {
308 319
   equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
309 320
   equipmentSerialNumber: [{ required: true, message: '设备序列号不能为空', trigger: 'blur' }]
@@ -354,6 +365,14 @@ function handleAdd() {
354 365
 function handleEdit(row) {
355 366
   getEquipLedger(row.id).then(response => {
356 367
     Object.assign(form, response.data)
368
+    if (form.baseAttachmentList && Array.isArray(form.baseAttachmentList)) {
369
+      form.baseAttachmentList = form.baseAttachmentList.map(item => ({
370
+        name: item.attachmentName || item.name || '',
371
+        url: item.attachmentUrl || item.url || ''
372
+      }))
373
+    } else {
374
+      form.baseAttachmentList = []
375
+    }
357 376
     if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
358 377
       form.equipmentInspectionRecordList = []
359 378
     }
@@ -366,6 +385,14 @@ function handleEdit(row) {
366 385
 function handleDetail(row) {
367 386
   getEquipLedger(row.id).then(response => {
368 387
     Object.assign(form, response.data)
388
+    if (form.baseAttachmentList && Array.isArray(form.baseAttachmentList)) {
389
+      form.baseAttachmentList = form.baseAttachmentList.map(item => ({
390
+        name: item.attachmentName || item.name || '',
391
+        url: item.attachmentUrl || item.url || ''
392
+      }))
393
+    } else {
394
+      form.baseAttachmentList = []
395
+    }
369 396
     if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
370 397
       form.equipmentInspectionRecordList = []
371 398
     }
@@ -431,7 +458,7 @@ function resetForm() {
431 458
     inspectionTeamMember1Id: '',
432 459
     inspectionTeamMember2Id: '',
433 460
     initialAcceptanceStatus: '',
434
-    baseAttachmentList: '',
461
+    baseAttachmentList: [],
435 462
     equipmentInspectionRecordList: []
436 463
   })
437 464
 }
@@ -440,6 +467,7 @@ async function submitForm() {
440 467
   formRef.value?.validate(async valid => {
441 468
     if (valid) {
442 469
       const submitData = { ...form }
470
+      submitData.baseAttachmentList = baseAttachmentListInternal.value
443 471
       
444 472
       try {
445 473
         if (submitData.inspectionTeamLeaderId) {