feat(approval): 文件选择失败时提示完整错误信息

8 张单据表单页原来把 chooseFile/chooseMessageFile/chooseImage 的 fail
吞成 () => undefined,手机上点上传附件没反应时无从判断。改为统一的
chooseFail:优先弹平台 errMsg,缺省时序列化整个 fail 入参。
This commit is contained in:
2026-11-01 17:20:18 +08:00
parent 457e8237e1
commit 3522957b10
8 changed files with 120 additions and 24 deletions
@@ -333,6 +333,18 @@ async function submit() {
});
}
/** 文件选择失败时把平台返回的完整错误信息提示出来,便于定位机型/平台限制 */
function chooseFail(res: any) {
let detail = '';
try {
detail =
res && typeof res.errMsg === 'string' ? res.errMsg : JSON.stringify(res);
} catch (error) {
detail = String(res);
}
showError('选择文件失败:' + (detail || '未知错误'), null);
}
function chooseAttachment() {
if (attachments.value.length >= 9) {
showError('每单最多上传9张附件', null);
@@ -344,7 +356,7 @@ function chooseAttachment() {
count: remaining,
extension: ['.jpg', '.jpeg', '.png', '.pdf', '.doc', '.docx', '.xls', '.xlsx'],
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef MP-WEIXIN
@@ -352,7 +364,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -364,7 +376,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}