67,513
社区成员
发帖
与我相关
我的任务
分享
btn1: function (e) {
if (!this.fileUpFlag) {
alert("请正确选择上传文件!");
} else {
this.msg2 = "文件正在解析中请稍等";
let formData = new FormData();
// console.log(this.file)
formData.append('file', this.file);
let config = {
headers: {
'Content-Type': 'multipart/form-data'
}
};
axios
.post("/excelUp", formData, config)
.then(response => {this.total = response.data.total;
this.errorIf = response.data.errorIf;
this.successSum = response.data.successSum;
this.errorSum = response.data.errorSum;
this.msg2 = "文件解析完成!上传数据总量:" + this.total + " 成功执行数量:" + this.successSum + " 失败数量:" + this.errorSum
})
.catch(function (error) {
console.log(error)
});
}
e.preventDefault()
}
@ResponseBody
@PostMapping("/excelUp")
public ExcelAnalyzeResult excelUp(@RequestParam("file") MultipartFile multipartFile) {
try {
return rootService.addUserExcel(multipartFile.getInputStream());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}