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
+15 -3
View File
@@ -261,6 +261,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);
@@ -272,7 +284,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
@@ -280,7 +292,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -292,7 +304,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}
@@ -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
}
+15 -3
View File
@@ -345,6 +345,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);
@@ -356,7 +368,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
@@ -364,7 +376,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -376,7 +388,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}
+15 -3
View File
@@ -420,6 +420,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);
@@ -431,7 +443,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
@@ -439,7 +451,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -451,7 +463,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}
+15 -3
View File
@@ -271,6 +271,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);
@@ -282,7 +294,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
@@ -290,7 +302,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -302,7 +314,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}
+15 -3
View File
@@ -466,6 +466,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);
@@ -477,7 +489,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
@@ -485,7 +497,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -497,7 +509,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}
+15 -3
View File
@@ -448,6 +448,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);
@@ -459,7 +471,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
@@ -467,7 +479,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -479,7 +491,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}
+15 -3
View File
@@ -416,6 +416,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);
@@ -427,7 +439,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
@@ -435,7 +447,7 @@ function chooseAttachment() {
count: remaining,
type: 'file',
success: (result: any) => uploadFiles(result.tempFiles || []),
fail: () => undefined
fail: chooseFail
});
// #endif
// #ifdef APP-PLUS
@@ -447,7 +459,7 @@ function chooseAttachment() {
(result.tempFilePaths || []).forEach((path: string) =>
uploadFiles([{ path, name: path.split('/').pop() || '附件' }])
),
fail: () => undefined
fail: chooseFail
});
// #endif
}