post请求 导出文件
axios.post(url, param, {
params: param,
responseType: 'blob'
}).then(res => {
// console.log(res)
// if(res.data.status == 'ERROR') return Message.error(res.data.errorMessage)
let blob = new Blob([res.data], {
type: "application/vnd.ms-excel"
});
let resUrl = URL.createObjectURL(blob);
// window.location.href = objectUrl;
let link = document.createElement("a");
link.style.display = "none";
link.href = resUrl;
if (filename != '导出文件') {
link.setAttribute("download", filename + ".xlsx");
} else {
let name = res.headers['content-disposition']
if (name) {
name = decodeURI(name.split('filename="')[1].split('"')[0])
link.setAttribute("download", name);
} else {
link.setAttribute("download", filename + ".xlsx");
}
}
document.body.appendChild(link);
link.click();
});