//{ responseType:'blob',}注意一定要跟参数分开写,否则导出的excel打不开
http.get('/expressDetail/exportData',{
customerCode:this.listForm.customerCode,
jpOrgCodes:this.listForm.jpOrgCodes,
outStockTime:this.listForm.outStockTime,
},{ responseType:'blob',}
).then(response => {
this.exportLoading=false
const blob = new Blob([response], {
type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8"
});
let fileName='集配快递费'+ moment().format('YYYYMMDD HHmmss')
if (
"download" in document.createElement("a") &&
navigator.userAgent.indexOf("Edge") <= -1
) {
// 非IE 及edge下载
const elink = document.createElement("a");
elink.download = fileName;
elink.style.display = "none";
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href);
document.body.removeChild(elink);
} else {
// IE10+下载
navigator.msSaveOrOpenBlob(blob, fileName);
}
}).catch(function (error) {
console.log('error: ', error);
});