Browse Source

登记页面文件上传路径不存在问题

dev-V1.0.1
蟑螂恶霸 5 months ago
parent
commit
065b91de20
  1. 10
      zdxt-web-client/zdxt-efcode-enforcement-app/src/components/enforcement/register/EnforcementInfoSection.vue
  2. 10
      zdxt-web-client/zdxt-efcode-enforcement-app/src/components/enforcement/register/NonEnforcementInfoSection.vue
  3. 26
      zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/enforce/enforcementRegister.vue

10
zdxt-web-client/zdxt-efcode-enforcement-app/src/components/enforcement/register/EnforcementInfoSection.vue

@ -214,10 +214,16 @@ const onAfterReadImage = (file) => {
f.status = 'uploading'; f.status = 'uploading';
f.message = '上传中...'; f.message = '上传中...';
uploadFile(f, (res) => { uploadFile(f, (res) => {
const uploadPath = res?.url || '';
if (!uploadPath) {
f.status = 'failed';
f.message = '上传失败';
return;
}
f.status = 'done'; f.status = 'done';
f.message = '上传成功'; f.message = '上传成功';
const data = res && res.data ? res.data : res; f.url = uploadPath;
f.url = data; f.uploadPath = uploadPath;
}); });
}); });
}; };

10
zdxt-web-client/zdxt-efcode-enforcement-app/src/components/enforcement/register/NonEnforcementInfoSection.vue

@ -169,10 +169,16 @@ const onAfterReadImage = (file) => {
f.status = 'uploading'; f.status = 'uploading';
f.message = '上传中...'; f.message = '上传中...';
uploadFile(f, (res) => { uploadFile(f, (res) => {
const uploadPath = res?.url || '';
if (!uploadPath) {
f.status = 'failed';
f.message = '上传失败';
return;
}
f.status = 'done'; f.status = 'done';
f.message = '上传成功'; f.message = '上传成功';
const data = res && res.data ? res.data : res; f.url = uploadPath;
f.url = data; f.uploadPath = uploadPath;
}); });
}); });
}; };

26
zdxt-web-client/zdxt-efcode-enforcement-app/src/views/enforcement/enforce/enforcementRegister.vue

@ -434,14 +434,28 @@ const handleSave = () => {
}); });
}; };
// 将 formData.fileList 转换为提交用的 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 '';
};
// 将 formData.fileList 转换为提交用的 fileList
// 行政执法:{ uploadPath } 对象数组;非行政执法:路径字符串数组
const buildFileList = () => { const buildFileList = () => {
return (formData.fileList || []) const paths = (formData.fileList || [])
.filter(img => img && (img.url || img.content)) .map(getFileUploadPath)
.map(img => {
return img.url || (img.content || '');
})
.filter(Boolean); .filter(Boolean);
if (isNonEnforcement.value) {
return paths;
}
return paths.map(uploadPath => ({ uploadPath }));
}; };
// 提交表单 // 提交表单

Loading…
Cancel
Save