// 下载zip
downloadFile(method = 'get', url, params, filename, baseURL = baseUrl,) {
return new Promise((resolve, reject) => {
axios({
method,
url: url,
baseURL,
filename:filename,
[method == 'get' ? 'params' : 'data']: params,
responseType: 'blob',
headers: {
'Content-Type': 'application/json'
}
}).then(res => {
resolve();
const blob = new Blob([res.data], { type: "application/zip" });
const date = new Date();
// console.log(params);
// let fileName ='报表数据.zip'
const ua = navigator.userAgent.toLowerCase();
if (/(ie|edge)/.test(ua) || "ActiveXObject" in window)
navigator.msSaveBlob(blob, filename);
// console.log(1)
else {
console.log(2)
const fileName = filename;
const elink = document.createElement('a');
elink.download = fileName;
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
URL.revokeObjectURL(elink.href); // 释放URL 对象
document.body.removeChild(elink);
}
}, err => {
reject(err);
})
})
}