<el-upload
class="upload-demo"
action=""
:http-request="addExcel"
:show-file-list='false'>
<el-button size="mini" type="primary">导入</el-button>
</el-upload>
addExcel(files){
let that = this
var form = new FormData();
form.append("file", files.file);
var xhr = new XMLHttpRequest();
xhr.timeout = 30000;
xhr.open("post", '/yxcAdmin/hospital/add/excel', true);
let token = sessionStorage.getItem('token')
xhr.setRequestHeader('token', token);
xhr.responseType = "json";
xhr.onload = function () {
if (xhr.response.status != 0) {
that.$message.error(response.message)
return false;
}
that.$message.success('上传文件成功!')
};
xhr.ontimeout = function () {
that.$message.error('数据加载失败,请刷新页面')
};
xhr.onerror = function (res) {
that.$message.error('数据加载失败,请刷新页面')
};
xhr.send(form);
},