!57 feat(xispeak): 模板导入校验失败时弹窗展示逐行具体错误信息
Merge pull request !57 from new_new_new/feature/20260624_1
This commit is contained in:
@@ -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)),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]),
|
||||||
|
]),
|
||||||
|
});
|
||||||
|
}
|
||||||
@@ -94,6 +94,7 @@
|
|||||||
import { useModal } from '/@/components/Modal';
|
import { useModal } from '/@/components/Modal';
|
||||||
import { defHttp } from '/@/utils/http/axios';
|
import { defHttp } from '/@/utils/http/axios';
|
||||||
import { useMessage } from '/@/hooks/web/useMessage';
|
import { useMessage } from '/@/hooks/web/useMessage';
|
||||||
|
import { showImportValidationErrors } from '/@/utils/helper/importError';
|
||||||
import { startProcessSchedules } from '/@/api/common/api';
|
import { startProcessSchedules } from '/@/api/common/api';
|
||||||
import { dateUtil } from '/@/utils/dateUtil';
|
import { dateUtil } from '/@/utils/dateUtil';
|
||||||
|
|
||||||
@@ -755,7 +756,11 @@ import { defHttp } from '/@/utils/http/axios';
|
|||||||
const isReturn = (fileInfo) => {
|
const isReturn = (fileInfo) => {
|
||||||
try {
|
try {
|
||||||
if (fileInfo.code === 500 || fileInfo.code === 510) {
|
if (fileInfo.code === 500 || fileInfo.code === 510) {
|
||||||
|
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} 导入失败`);
|
createMessage.error(fileInfo.message || `${data.file.name} 导入失败`);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
createMessage.success(fileInfo.message || `${data.file.name} 导入成功`);
|
createMessage.success(fileInfo.message || `${data.file.name} 导入成功`);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user