Kaynağa Gözat

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

1. 调整表单标签宽度优化布局显示
2. 新增图片上传result-type参数适配组件新接口
3. 重构设备附件列表的数据格式转换逻辑,统一编辑、详情页回显和提交时的数据结构
4. 修复重置表单时附件列表类型不匹配的问题
5. 新增中间状态管理附件列表,确保提交数据格式符合后端要求
huoyi 1 ay önce
ebeveyn
işleme
3be23c7dda
1 değiştirilmiş dosya ile 32 ekleme ve 4 silme
  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
     <el-dialog :title="dialog.title" v-model="dialog.visible" width="1000px" :close-on-click-modal="false">
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
         <el-row :gutter="20">
76
         <el-row :gutter="20">
77
           <el-col :span="12">
77
           <el-col :span="12">
78
             <el-form-item label="设备名称" prop="equipmentName">
78
             <el-form-item label="设备名称" prop="equipmentName">
@@ -178,7 +178,7 @@
178
           </el-col>
178
           </el-col>
179
           <el-col :span="24">
179
           <el-col :span="24">
180
             <el-form-item label="设备图片" prop="baseAttachmentList">
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
             </el-form-item>
182
             </el-form-item>
183
           </el-col>
183
           </el-col>
184
         </el-row>
184
         </el-row>
@@ -260,6 +260,7 @@ const { proxy } = getCurrentInstance()
260
 const { equipment_usage_status, equipment_inspection_nature } = proxy.useDict('equipment_usage_status', 'equipment_inspection_nature')
260
 const { equipment_usage_status, equipment_inspection_nature } = proxy.useDict('equipment_usage_status', 'equipment_inspection_nature')
261
 
261
 
262
 const loading = ref(false)
262
 const loading = ref(false)
263
+
263
 const queryFormRef = ref()
264
 const queryFormRef = ref()
264
 const formRef = ref()
265
 const formRef = ref()
265
 const tableData = ref([])
266
 const tableData = ref([])
@@ -291,7 +292,7 @@ const form = reactive({
291
   manufacturingDate: '',
292
   manufacturingDate: '',
292
   acceptanceDate: '',
293
   acceptanceDate: '',
293
   commissioningDate: '',
294
   commissioningDate: '',
294
-  usageStatus: '1',
295
+  usageStatus: '',
295
   scrappingDate: '',
296
   scrappingDate: '',
296
   installationLocation: '',
297
   installationLocation: '',
297
   inspectionSelfCheckDate: '',
298
   inspectionSelfCheckDate: '',
@@ -304,6 +305,16 @@ const form = reactive({
304
   baseAttachmentList: [],
305
   baseAttachmentList: [],
305
   equipmentInspectionRecordList: []
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
 const rules = {
318
 const rules = {
308
   equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
319
   equipmentName: [{ required: true, message: '设备名称不能为空', trigger: 'blur' }],
309
   equipmentSerialNumber: [{ required: true, message: '设备序列号不能为空', trigger: 'blur' }]
320
   equipmentSerialNumber: [{ required: true, message: '设备序列号不能为空', trigger: 'blur' }]
@@ -354,6 +365,14 @@ function handleAdd() {
354
 function handleEdit(row) {
365
 function handleEdit(row) {
355
   getEquipLedger(row.id).then(response => {
366
   getEquipLedger(row.id).then(response => {
356
     Object.assign(form, response.data)
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
     if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
376
     if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
358
       form.equipmentInspectionRecordList = []
377
       form.equipmentInspectionRecordList = []
359
     }
378
     }
@@ -366,6 +385,14 @@ function handleEdit(row) {
366
 function handleDetail(row) {
385
 function handleDetail(row) {
367
   getEquipLedger(row.id).then(response => {
386
   getEquipLedger(row.id).then(response => {
368
     Object.assign(form, response.data)
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
     if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
396
     if (!form.equipmentInspectionRecordList || !Array.isArray(form.equipmentInspectionRecordList)) {
370
       form.equipmentInspectionRecordList = []
397
       form.equipmentInspectionRecordList = []
371
     }
398
     }
@@ -431,7 +458,7 @@ function resetForm() {
431
     inspectionTeamMember1Id: '',
458
     inspectionTeamMember1Id: '',
432
     inspectionTeamMember2Id: '',
459
     inspectionTeamMember2Id: '',
433
     initialAcceptanceStatus: '',
460
     initialAcceptanceStatus: '',
434
-    baseAttachmentList: '',
461
+    baseAttachmentList: [],
435
     equipmentInspectionRecordList: []
462
     equipmentInspectionRecordList: []
436
   })
463
   })
437
 }
464
 }
@@ -440,6 +467,7 @@ async function submitForm() {
440
   formRef.value?.validate(async valid => {
467
   formRef.value?.validate(async valid => {
441
     if (valid) {
468
     if (valid) {
442
       const submitData = { ...form }
469
       const submitData = { ...form }
470
+      submitData.baseAttachmentList = baseAttachmentListInternal.value
443
       
471
       
444
       try {
472
       try {
445
         if (submitData.inspectionTeamLeaderId) {
473
         if (submitData.inspectionTeamLeaderId) {