no message

main
huojin\hj 2025-07-29 17:41:41 +08:00
parent 031a187db2
commit c7c8ae9adc
1 changed files with 32 additions and 41 deletions

View File

@ -725,58 +725,49 @@ export default {
},
async confirmImport() {
// tab
let hasFile = false;
let fileName = '';
let currentFile = null; //
// tab
const getFileFromTab = (tab) => {
const fileMap = {
template1: this.fileList1,
template2: this.fileList2,
template3: this.fileList3,
};
const list = fileMap[tab] || [];
return list.length > 0 ? list[0] : null;
};
if (this.activeImportTab === 'template1') {
hasFile = this.fileList1.length > 0;
if (hasFile) {
currentFile = this.fileList1[0]; //
fileName = currentFile.name;
}
} else if (this.activeImportTab === 'template2') {
hasFile = this.fileList2.length > 0;
if (hasFile) {
currentFile = this.fileList2[0];
fileName = currentFile.name;
}
} else if (this.activeImportTab === 'template3') {
hasFile = this.fileList3.length > 0;
if (hasFile) {
currentFile = this.fileList3[0];
fileName = currentFile.name;
}
}
if (!hasFile || !currentFile) {
this.$message.warning('请先上传文件');
const currentFile = getFileFromTab(this.activeImportTab);
if (!currentFile || !currentFile.raw) {
this.crud.notify('请先上传文件', CRUD.NOTIFICATION_TYPE.WARNING);
return;
}
const fileName = currentFile.name;
this.importLoading = true;
console.log('开始导入...' + this.activeImportTab + '文件:' + fileName);
console.log(`开始导入 ${this.activeImportTab} 文件: ${fileName}`);
const formData = new FormData();
// 使 currentFile.raw
formData.append('file', currentFile.raw);
formData.append('templateType', this.activeImportTab);
const response = await importData.importAsnData(formData);
if (response.status === 200) {
this.crud.notify(response.message, CRUD.NOTIFICATION_TYPE.SUCCESS)
this.importDialogVisible = false;
this.importLoading = false;
this.crud.toQuery(); //
// fileList
this.fileList1 = [];
this.fileList2 = [];
this.fileList3 = [];
} else {
this.crud.notify(response.message, CRUD.NOTIFICATION_TYPE.ERROR)
}
try {
const response = await importData.importAsnData(formData);
console.log(response);
if (response.status === 200) {
this.crud.notify(response.message, CRUD.NOTIFICATION_TYPE.SUCCESS);
this.importDialogVisible = false;
this.crud.toQuery(); //
// fileList
['fileList1', 'fileList2', 'fileList3'].forEach(key => {
this[key] = [];
});
}
} catch (error) {
console.error('导入失败:', error);
} finally {
this.importLoading = false;
}
},
cancelImport() {
this.fileList1 = [];