vue導入excel表格


<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導入的模板不正確!');
}
});
},
 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM