diff --git a/src/views/data/ComplaintCollection.vue b/src/views/data/ComplaintCollection.vue index 3b2812c..717968c 100644 --- a/src/views/data/ComplaintCollection.vue +++ b/src/views/data/ComplaintCollection.vue @@ -550,8 +550,31 @@ const updateForm = ref({ handleMethod: "", involveProblemIdList: [], tags: [], + thingFiles:[], }) +function normalizeThingFiles(val) { + if (!val) return [] + if (Array.isArray(val)) return val + + // 后端可能返回 JSON 字符串 + if (typeof val === 'string' && val.trim().startsWith('[')) { + try { return JSON.parse(val) } catch { /* ignore */ } + } + + // 后端可能返回 "path1,path2" + if (typeof val === 'string') { + return val.split(/[,,]/).map(s => s.trim()).filter(Boolean).map(p => ({ + filePath: p, + fileName: p.split('/').pop() || p, + loading: false, + percent: 100, + })) + } + + return [] +} + // 修改按钮点击事件 const handleUpdate = async (row) => { const r = JSON.parse(JSON.stringify(row || {})) @@ -580,6 +603,12 @@ const handleUpdate = async (row) => { tags: splitToArray(r.tags ?? r.tag), businessTypeName: r.businessTypeName ?? '', businessTypeCode: r.businessTypeCode ?? '', + thingFiles: normalizeThingFiles(r.thingFiles).map(f => ({ + ...f, + loading: false, + percent: 100, + uid: f.uid || `${f.filePath}-${Math.random()}`, + })), }; updateShow.value = true }