一、下载前接口请求
export function exportEntCouponList(params) {
return request({
url: '/xxxxx/xxxx/export',
method: 'get',
responseType: 'blob',
params
})
}
二、接口响应返回流地址
this.$modal
.confirm("是否确认导出条件查询数据项?")
.then(() => {
const loading = this.$loading({
lock: true,
text: "正在导出数据请稍后...",
spinner: "el-icon-loading",
background: "rgba(0, 0, 0, 0.7)",
});
exportCooperation(queryParams).then((resp) => {
const link = document.createElement("a");
const blob = new Blob([resp], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
link.style.display = "none";
link.href = URL.createObjectURL(blob);
link.setAttribute("download", decodeURI("表格.xls"));
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
loading.close();
});
})
.catch(() => {});