<template>
|
<div>
|
<el-upload
|
class="upload-demo"
|
ref="upload"
|
action="/api/mdc/utilization/import19"
|
:on-change="handleChange"
|
name="file"
|
accept=".xls,.xlsx"
|
:on-preview="handlePreview"
|
:on-remove="handleRemove"
|
:on-success="handleSuccess"
|
:file-list="fileList"
|
:auto-upload="false">
|
<el-button style="margin-left: 10px; margin-top: 30px;" slot="trigger" size="small" type="primary">选择文件</el-button>
|
<el-button style="margin-left: 10px; margin-top: 30px;" size="small" type="success" @click="submitUpload">导入文件</el-button>
|
</el-upload>
|
</div>
|
</template>
|
|
<script>
|
export default {
|
name: 'Upload',
|
data() {
|
return {
|
fileList: []
|
}
|
},
|
methods: {
|
submitUpload(event) {
|
event.preventDefault()
|
this.$refs.upload.submit()
|
},
|
handleChange(file, fileList) {
|
this.fileList = fileList
|
},
|
handleRemove(file, fileList) {
|
console.log(file, fileList)
|
},
|
handlePreview(file) {
|
console.log(file)
|
},
|
handleSuccess(response, file, fileList) {
|
fileList.pop(file)
|
if (response.result === 'SUCCESS') {
|
this.$message.success('导入成功')
|
} else {
|
this.$message.success('导入失败')
|
}
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|