//导出
exportExl() {
let url = process.env.VUE_APP_BASE_API + `/Approval/exportCheckApproval?pages=${this.pages}`;
url = url + `&villageName=${this.cz}`; // 导出的查询的条件
if (this.villageAreaId != "") {
url = url + `&addressId=${this.villageAreaId}`;
}
// window.location.href = url;
var xhr = new XMLHttpRequest();
xhr.open("get", url, true); // get、post都可
xhr.responseType = "blob"; // 转换流
xhr.setRequestHeader("Authorization", "Bearer"+" "+ getToken()); // token键值对
xhr.onload = function() {
if (this.status == 200) {
var blob = this.response;
var a = document.createElement("a")
var url = window.URL.createObjectURL(blob)
a.href = url
a.download = "xxx.xls" // 文件名
}
a.click()
window.URL.revokeObjectURL(url)
}
xhr.send();
},
后台页面数据导出
最新推荐文章于 2024-09-06 22:20:29 发布