選擇檔案
<label
for="upload"
class="label">選擇檔案</label>
<input
id="upload"
ref="clearFile"
type="file"
style="display:none"
multiple="multiplt"
class="upload-file-input"
accept=".xls,.xlsx"
@change="handleFileChange" />
handleFileChange() {
let inputDOM = this.$refs.clearFile.files[0];
this.$message({
message: `已選擇檔案${inputDOM.name},請點選上傳檔案`,
type: 'success'
});
},
檔案上傳
<el-button
type="primary"
size="small"
style="padding:14px;"
@click="submitFile">
開始上傳
</el-button>
submitFile() {
let formData = new window.FormData();
formData.append('multipartFile', document.querySelector('input[type=file]').files[0]);
if (document.querySelector('input[type=file]').files[0] == undefined) {
this.$message({
message: '請選擇上傳的檔案',
type: 'warning'
});
} else {
this.$http({
url: this.$http.adornScsApi('/excel/po/salein/poOrderImport'),
method: 'post',
data: formData
}).then(({data}) => {
if (data != null && data.code == 200) {
this.$notify.success({
title: '提示',
message: '導入成功'
});
}
})
}
},
模闆下載下傳
<el-button
type="primary"
size="small"
style="padding:14px;"
@click="getFile">
下載下傳模闆
</el-button>
getFile() {
window.location.href = this.$http.adornScsApi('/excel/po/salein/poOrderDownload')
},