😎优化导入功能
This commit is contained in:
parent
4b80dfc2da
commit
7cc86ce424
@ -67,7 +67,26 @@ const handleImportData = (opt: UploadRequestOptions): any => {
|
|||||||
props
|
props
|
||||||
.import(opt.file)
|
.import(opt.file)
|
||||||
.then((res: any) => {
|
.then((res: any) => {
|
||||||
|
// 返回json数据的情况
|
||||||
|
const contentType = res.headers['content-type'];
|
||||||
|
if (contentType && contentType.toLowerCase().includes('application/json')) {
|
||||||
|
const decoder = new TextDecoder('utf-8');
|
||||||
|
const data = decoder.decode(res.data);
|
||||||
|
try {
|
||||||
|
const result = JSON.parse(data);
|
||||||
|
if (result.code == '200') {
|
||||||
|
ElMessage.success(result.message);
|
||||||
|
} else {
|
||||||
|
ElMessage.error(result.message);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.error('解析数据导入结果失败:', e);
|
||||||
downloadStreamFile(res);
|
downloadStreamFile(res);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
downloadStreamFile(res);
|
||||||
|
}
|
||||||
emit('refresh');
|
emit('refresh');
|
||||||
state.isShowDialog = false;
|
state.isShowDialog = false;
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user