|
|
|
@ -161,6 +161,8 @@ export default { |
|
|
|
|
|
|
|
importCode: "", |
|
|
|
importOption: { exist: {}, notExist: {} }, |
|
|
|
|
|
|
|
fileData: null, |
|
|
|
}; |
|
|
|
}, |
|
|
|
|
|
|
|
@ -374,6 +376,7 @@ export default { |
|
|
|
]; |
|
|
|
this.importOption = data.option; |
|
|
|
this.importCode = data.code; |
|
|
|
this.fileData = file; |
|
|
|
} else this.$message.error(res.data.msg); |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
@ -389,11 +392,6 @@ export default { |
|
|
|
async handleComfirm() { |
|
|
|
this.importLoading = true; |
|
|
|
this.importBtnTitle = "正在上传中..."; |
|
|
|
this.$message({ |
|
|
|
showClose: true, |
|
|
|
message: "导入中,请到系统管理-导入记录中查看进度", |
|
|
|
duration: 0, |
|
|
|
}); |
|
|
|
const { importOption, importCode, dataList } = this; |
|
|
|
dataList.forEach((item) => { |
|
|
|
if (!item.exist) { |
|
|
|
@ -411,8 +409,30 @@ export default { |
|
|
|
.then((res) => { |
|
|
|
console.log("res-up", res); |
|
|
|
if (res.data.code == 0 && res.data.msg == "success") { |
|
|
|
// this.$message.success('导入成功') |
|
|
|
this.dataList = []; |
|
|
|
this.upload2(this.fileData, this.importCode); |
|
|
|
} else this.$message.error(res.data.msg); |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
console.log("失败", err); |
|
|
|
file.onError(); //上传失败的文件会从文件列表中删除 |
|
|
|
// this.$message.error('导入失败') |
|
|
|
}); |
|
|
|
this.importLoading = false; |
|
|
|
this.importBtnTitle = "导入"; |
|
|
|
}, |
|
|
|
|
|
|
|
async upload2(file, code) { |
|
|
|
this.importLoading = true; |
|
|
|
this.importBtnTitle = "正在上次中..."; |
|
|
|
const formData = new FormData(); //FormData对象,添加参数只能通过append('key', value)的形式添加 |
|
|
|
formData.append("file", file.file); //添加文件对象 |
|
|
|
formData.append("code", code); //添加文件对象 |
|
|
|
await this.$http |
|
|
|
.post("/actual/base/residentBaseInfo/importExcel", formData) |
|
|
|
.then((res) => { |
|
|
|
console.log("res-up", res); |
|
|
|
if (res.data.code == 0 && res.data.msg == "success") { |
|
|
|
this.afterSuccess(); |
|
|
|
} else this.$message.error(res.data.msg); |
|
|
|
}) |
|
|
|
.catch((err) => { |
|
|
|
@ -422,6 +442,20 @@ export default { |
|
|
|
}); |
|
|
|
this.importLoading = false; |
|
|
|
this.importBtnTitle = "导入"; |
|
|
|
this.$refs.upload.clearFiles(); |
|
|
|
}, |
|
|
|
|
|
|
|
afterSuccess() { |
|
|
|
this.$message({ |
|
|
|
showClose: true, |
|
|
|
message: "导入成功,请到系统管理-导入记录中查看进度", |
|
|
|
duration: 0, |
|
|
|
}); |
|
|
|
|
|
|
|
this.dataList = []; |
|
|
|
this.importOption = {}; |
|
|
|
this.importCode = ""; |
|
|
|
this.fileData = null; |
|
|
|
}, |
|
|
|
|
|
|
|
// 取消 |
|
|
|
|