//Trial Balance 导出
const triEx = data => {
return serviceJson({
url: "/rbTrialBalanceUpload/exportData",
method: "POST",
data,
responseType: "arraybuffer"
});
};
// 导出
expt(){
let params = {
period: this.date,
company: this.company,
}
ReApi.triEx(params, {
responseType: "blob"
})
.then(res => {
const blob = new Blob([res.data]);
//对于<a>标签,只有 Firefox 和 Chrome(内核) 支持 download 属性
//IE10以上支持blob但是依然不支持download
if ("download" in document.createElement("a")) {
//支持a标签download的浏览器
const link = document.createElement("a"); //创建a标签
link.download = res.headers["content-disposition"].substring(20); //a标签添加属性
link.style.display = "none";
link.href = URL.createObjectURL(blob);
document.body.appendChild(link);
link.click(); //执行下载
URL.revokeObjectURL(link.href); //释放url
document.body.removeChild(link); //释放标签
} else {
this.$openWarning(`Browser does not support download`);
}
})
.catch(err => {});
}
网友评论