diff --git a/zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/my/complaintSuggestion.vue b/zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/my/complaintSuggestion.vue index 3013f9fe..7856e3f4 100644 --- a/zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/my/complaintSuggestion.vue +++ b/zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/my/complaintSuggestion.vue @@ -425,7 +425,7 @@ const onAfterReadImage = (file) => { uploadFile(f, (res) => { // 直接取返回的 data 字段(字符串路径) const data = res && res.data ? res.data : res; - const filePath = typeof data === 'string' ? data : (data && (data.url || data.fileUrl || data.path)) || ''; + const filePath = data.data || ''; if (filePath) { // 设置文件对象的 url 属性,保持预览显示 f.url = filePath; @@ -434,16 +434,24 @@ const onAfterReadImage = (file) => { }); }); }; - -// 将 form.images 转换为提交用的 fileList(纯字符串数组) +// 从上传组件项中解析文件保存路径 +const getFileUploadPath = (img) => { + if (!img) return ''; + const url = img.uploadPath || img.url || img.content || ''; + if (typeof url === 'string') return url; + if (typeof url === 'object' && url) { + return url.uploadPath || url.url || url.fileUrl || url.path || + (typeof url.data === 'string' ? url.data : url.data?.uploadPath) || ''; + } + return ''; +}; +// 将 form.images 转换为提交用的 fileList +// 后端期望格式:[{ uploadPath: "/profile/..." }, ...] const buildFileList = () => { - return (form.value.images || []) - .filter(img => img && (img.url || img.content)) - .map(img => { - // 转换为纯字符串路径 - return img.url || ''; - }) + const paths = (form.value.images || []) + .map(getFileUploadPath) .filter(Boolean); + return paths.map(uploadPath => (uploadPath)); }; // ========== 提交表单 ==========