Browse Source

投诉附件提交

dev-V1.0.5.1
wangmingyong@163.com 2 months ago
parent
commit
747f0a7a26
  1. 26
      zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/my/complaintSuggestion.vue

26
zdxt-web-client/zdxt-efcode-enterprise-app/src/views/enterprise/my/complaintSuggestion.vue

@ -425,7 +425,7 @@ const onAfterReadImage = (file) => {
uploadFile(f, (res) => { uploadFile(f, (res) => {
// 直接取返回的 data 字段(字符串路径) // 直接取返回的 data 字段(字符串路径)
const data = res && res.data ? res.data : res; 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) { if (filePath) {
// 设置文件对象的 url 属性,保持预览显示 // 设置文件对象的 url 属性,保持预览显示
f.url = filePath; 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 = () => { const buildFileList = () => {
return (form.value.images || []) const paths = (form.value.images || [])
.filter(img => img && (img.url || img.content)) .map(getFileUploadPath)
.map(img => {
// 转换为纯字符串路径
return img.url || '';
})
.filter(Boolean); .filter(Boolean);
return paths.map(uploadPath => (uploadPath));
}; };
// ========== 提交表单 ========== // ========== 提交表单 ==========

Loading…
Cancel
Save