feat(xispeak): 模板导入校验失败时弹窗展示逐行具体错误信息

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
wsm
2026-06-24 10:10:34 +08:00
co-authored by Claude Opus 4.7
parent b959837891
commit dc430b3d96
2 changed files with 59 additions and 1 deletions
+53
View File
@@ -0,0 +1,53 @@
import { h } from 'vue';
import { Modal } from 'ant-design-vue';
interface ValidationError {
row: number;
messages: string[];
}
const STYLES = {
wrapper: 'max-height: 450px; overflow-y: auto;',
hint: 'color: #666; margin-bottom: 12px;',
table: 'width: 100%; border-collapse: collapse; font-size: 13px;',
th: 'padding: 8px; border: 1px solid #e8e8e8; text-align: center; background: #fafafa;',
thRow: 'width: 80px;',
tdRow: 'padding: 8px; border: 1px solid #e8e8e8; text-align: center; vertical-align: top; color: #ff4d4f; font-weight: 500;',
tdMsg: 'padding: 8px; border: 1px solid #e8e8e8; vertical-align: top;',
ul: 'margin: 0; padding-left: 18px;',
li: 'line-height: 1.7; color: #333;',
};
export function showImportValidationErrors(title: string, errors: ValidationError[]) {
Modal.error({
title,
width: 720,
content: h('div', { style: STYLES.wrapper }, [
h('p', { style: STYLES.hint }, '以下行数据校验不通过,请修改后重新导入:'),
h('table', { style: STYLES.table }, [
h('thead', null, [
h('tr', null, [
h('th', { style: STYLES.th + STYLES.thRow }, '行号'),
h('th', { style: STYLES.th }, '错误信息'),
]),
]),
h(
'tbody',
null,
errors.map((err) =>
h('tr', { key: err.row }, [
h('td', { style: STYLES.tdRow }, err.row),
h('td', { style: STYLES.tdMsg }, [
h(
'ul',
{ style: STYLES.ul },
err.messages.map((msg, i) => h('li', { key: i, style: STYLES.li }, msg)),
),
]),
]),
),
),
]),
]),
});
}
+6 -1
View File
@@ -94,6 +94,7 @@
import { useModal } from '/@/components/Modal';
import { defHttp } from '/@/utils/http/axios';
import { useMessage } from '/@/hooks/web/useMessage';
import { showImportValidationErrors } from '/@/utils/helper/importError';
import { startProcessSchedules } from '/@/api/common/api';
import { dateUtil } from '/@/utils/dateUtil';
@@ -755,7 +756,11 @@ import { defHttp } from '/@/utils/http/axios';
const isReturn = (fileInfo) => {
try {
if (fileInfo.code === 500 || fileInfo.code === 510) {
createMessage.error(fileInfo.message || `${data.file.name} 导入失败`);
if (fileInfo.result && Array.isArray(fileInfo.result) && fileInfo.result.length > 0) {
showImportValidationErrors(fileInfo.message || `${data.file.name} 导入失败`, fileInfo.result);
} else {
createMessage.error(fileInfo.message || `${data.file.name} 导入失败`);
}
} else {
createMessage.success(fileInfo.message || `${data.file.name} 导入成功`);
}