// 导出列表
exportExcel(flag) {
this.creditService.exportCreditGrantingResultList({
...this.fifterForm,
...this.httpOptionOne,
pageSize: this.pageSize,
currentPageNo: this.currentPageNo,
}).then(res => {
let blob = new Blob([res], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
let fr = new FileReader();
fr.readAsText(blob)
const _this = this
fr.onload = () => {
try {
const jsonData = JSON.parse(fr.result as string)
_this.message.warning(jsonData['resultMsg'])
} catch (e) {
const link = document.createElement("a"); // 创建元素
link.style.display = "none";
link.href = URL.createObjectURL(blob); // 创建下载的链接
let Time = this.getYear() + '-' + this.getMonth() + '-' + this.getDay()//自己处理的时间,可注释
link.setAttribute("download", `授信结果列表${Time}.xlsx`); // 给下载后的文件命名
document.body.appendChild(link);
link.click(); // 点击下载
document.body.removeChild(link); // 下载完成移除元素
window.URL.revokeObjectURL(link.href); // 释放掉blob对象
}
}
})
}
请求时 responseType: 'blob' as 'json'