<Upload ref="upload" :show-upload-list="false" accept=".xls, .xlsx" :before-upload="templateToImport"
type="drag" action="/chenfan_refuse/otherRecord/otherRecordExcelImport"
style="display:inline-block;width:100px;float:left"><Button> Excel模板导入</Button></Upload>
// Excel模板导入
templateToImport(file) {
if (!this.lenderName) {
this.$Message.warning(‘请选择借出人!‘);
return
}
let formData = new FormData();
formData.append("file", file);
this.$axios({
url: "/chenfan_refuse/otherRecord/otherRecordExcelImport",
method: "post",
data: formData
}).then((data) => {
if (data.obj.length) {
let lenderName = data.obj[0].lenderName
if (lenderName === this.lenderName) {
data.obj.forEach((ele, index) => {
this.tableData.push(ele)
})
// this.tableData = data.obj
} else {
this.$Message.warning(‘请选择与模板相同的借出人!‘);
}
// this.getDetailInfo()
} else {
this.$Message.warning(‘Excel导入的模板不正确!‘);
}
});
},
原文地址:https://www.cnblogs.com/wssdx/p/11468652.html