1、调整凭证
2、调整对账 3、解决正式结算冲突bug
This commit is contained in:
@@ -1095,7 +1095,8 @@ const fileChange = async (file, list) => {
|
||||
return text.slice(0, 10);
|
||||
};
|
||||
const count = new Map();
|
||||
rows.value = source.map((item, index) => {
|
||||
// 先解析数据,但不填充到 rows.value
|
||||
const parsedRows = source.map((item, index) => {
|
||||
const row = { _key: `${Date.now()}-${index}`, ...item, batchNo: form.batchNo };
|
||||
Object.entries(keyMap).forEach(([key, labels]) => {
|
||||
row[key] =
|
||||
@@ -1112,14 +1113,88 @@ const fileChange = async (file, list) => {
|
||||
row._duplicateKey = duplicateKey;
|
||||
return row;
|
||||
});
|
||||
rows.value.forEach(row => {
|
||||
parsedRows.forEach(row => {
|
||||
row._duplicate = count.get(row._duplicateKey) > 1;
|
||||
});
|
||||
|
||||
// 调用后端校验接口,校验通过才填充表格
|
||||
const isValid = await performValidation(parsedRows);
|
||||
|
||||
if (isValid) {
|
||||
// 校验通过,填充表格数据
|
||||
rows.value = parsedRows;
|
||||
} else {
|
||||
// 校验失败,清空数据
|
||||
rows.value = [];
|
||||
files.value = [];
|
||||
form.file = null;
|
||||
}
|
||||
};
|
||||
const fileRemove = () => {
|
||||
files.value = [];
|
||||
form.file = null;
|
||||
};
|
||||
|
||||
const performValidation = async (parsedRows) => {
|
||||
if (!parsedRows || !parsedRows.length) return false;
|
||||
|
||||
try {
|
||||
// 构建校验请求参数
|
||||
const payload = {
|
||||
...form,
|
||||
rows: parsedRows.map(row => {
|
||||
const { _key, _duplicate, _duplicateKey, _editing, _editSnapshot, ...data } = row;
|
||||
return data;
|
||||
})
|
||||
};
|
||||
|
||||
// 调用后端校验接口
|
||||
const response = await api.validateImport(payload);
|
||||
|
||||
// 检查响应类型
|
||||
const blob = response.data || response;
|
||||
|
||||
// 如果是 Blob,需要检查其 MIME 类型
|
||||
if (blob instanceof Blob) {
|
||||
// Excel 文件的 MIME 类型
|
||||
if (blob.type.includes('application/vnd.ms-excel') ||
|
||||
blob.type.includes('application/vnd.openxmlformats-officedocument.spreadsheetml.sheet')) {
|
||||
// 校验失败,下载错误明细
|
||||
const url = window.URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = `运单导入失败明细_${dayjs().format('YYYYMMDDHHmmss')}.xlsx`;
|
||||
link.click();
|
||||
window.URL.revokeObjectURL(url);
|
||||
ElMessage.warning('数据校验失败,已自动下载错误明细表,请修正后重新上传');
|
||||
return false;
|
||||
} else if (blob.type.includes('application/json')) {
|
||||
// 可能是 JSON 响应被当作 Blob,需要解析
|
||||
const text = await blob.text();
|
||||
const json = JSON.parse(text);
|
||||
if (json.success) {
|
||||
ElMessage.success('数据校验通过');
|
||||
return true;
|
||||
} else {
|
||||
ElMessage.error(json.msg || '校验失败');
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// 其他类型,默认认为是校验通过
|
||||
ElMessage.success('数据校验通过');
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// 不是 Blob,直接判断
|
||||
ElMessage.success('数据校验通过');
|
||||
return true;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('校验失败:', error);
|
||||
ElMessage.error('校验接口调用失败');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const formatCell = (row, column) => row[column.prop] || '';
|
||||
const updateEditorValue = (column, row, value) => {
|
||||
if (column.editor === 'number') {
|
||||
|
||||
Reference in New Issue
Block a user