<el-button class="button" type="primary" @click="importFile()" >导入</el-button>
<el-upload
ref="upload" v-show="false"
style="display:inline-block;"
action="/data-service/productAction/importExcel"
accept=".xls, .xlsx"
:headers="uploadHeaders"
:show-file-list="false"
:on-success="uploadSuccess"
:data="uploadData"
>
<el-button class="button" type="primary" @click="importDetail(scope.row)">导入</el-button>
</el-upload>
importFile() {
const that = this;
this.$confirm('导入会覆盖之前所有数据?','',{
confirmButtomText:'确定',
cancelButtomText:'取消',
type:'warning'
}).then(async ()=>{
that.$refs['upload'].$refs['upload-inner'].handleClick(); // upload-inner是固定的ref名称,upload可自行定义
}).catch(()=>{
})
},
uploadSuccess(response, file, fileList) {
if (response.success === true) {
this.$message.success('上传成功');
}else{
this.$message.error('上传失败');
}
}