1、调整凭证
2、调整对账 3、解决正式结算冲突bug
This commit is contained in:
@@ -163,9 +163,10 @@
|
||||
import { exportBlob } from '@/api/common';
|
||||
import { getList as getContractList } from '@/api/business/contract-manage';
|
||||
import { getList as getProjectList } from '@/api/business/project-apply';
|
||||
import { importTransportPlan } from '@/api/business/transport-plan';
|
||||
import { importTransportPlan, validateTransportPlan } from '@/api/business/transport-plan';
|
||||
import { config } from '@/option/business/transport-plan';
|
||||
import { downloadXls } from '@/utils/util';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const importColumns = [
|
||||
['计划名称', 'planName'],
|
||||
@@ -362,6 +363,9 @@ export default {
|
||||
this.markDuplicates();
|
||||
this.$refs.importFormRef?.validateField('file');
|
||||
this.$message.success(`已读取${rows.length}条计划明细`);
|
||||
|
||||
// 调用后端校验接口
|
||||
await this.performValidation();
|
||||
} catch (error) {
|
||||
this.handleFileRemove();
|
||||
this.$message.error('计划明细表读取失败,请检查文件格式');
|
||||
@@ -376,6 +380,63 @@ export default {
|
||||
this.editingKey = '';
|
||||
this.editSnapshot = null;
|
||||
},
|
||||
async performValidation() {
|
||||
if (!this.rows.length || !this.form.file) return;
|
||||
|
||||
try {
|
||||
// 校验表单必填项
|
||||
await this.$refs.importFormRef?.validate();
|
||||
|
||||
const response = await validateTransportPlan({
|
||||
file: this.form.file,
|
||||
projectId: this.form.projectId,
|
||||
projectName: this.form.projectName,
|
||||
customerName: this.form.customerName,
|
||||
contractId: this.form.contractId,
|
||||
contractName: this.form.contractName,
|
||||
});
|
||||
|
||||
// 检查响应类型
|
||||
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);
|
||||
this.$message.warning('数据校验失败,已自动下载错误明细表,请修正后重新上传');
|
||||
} else if (blob.type.includes('application/json')) {
|
||||
// 可能是 JSON 响应被当作 Blob,需要解析
|
||||
const text = await blob.text();
|
||||
const json = JSON.parse(text);
|
||||
if (json.success) {
|
||||
this.$message.success('数据校验通过');
|
||||
} else {
|
||||
this.$message.error(json.msg || '校验失败');
|
||||
}
|
||||
} else {
|
||||
// 其他类型,默认认为是校验通过
|
||||
this.$message.success('数据校验通过');
|
||||
}
|
||||
} else {
|
||||
// 不是 Blob,直接判断
|
||||
this.$message.success('数据校验通过');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('校验失败:', error);
|
||||
// 表单校验失败时不提示错误,让表单自己显示错误信息
|
||||
if (error && error.message && !error.message.includes('validate')) {
|
||||
this.$message.error('校验接口调用失败');
|
||||
}
|
||||
}
|
||||
},
|
||||
duplicateKey(row) {
|
||||
return importColumns.map(([, prop]) => String(row[prop] || '').trim()).join('\u0001');
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user