/**
* url 请求地址
* method 请求类型
* data 传入参数
* filename 下载的文件名称(例如:123.xlsx)
*/
function ajaxDownload(url, method, data, filename) {
let xhr = new XMLHttpRequest();
xhr.open(method, url)
xhr.responseType = 'blob';
xhr.setRequestHeader('Content-Type', 'application/json;charset=utf-8');
xhr.onload = function () {
if (this.status === 200) {
let blob = this.response;
let a = document.createElement('a');
a.href = window.URL.createObjectURL(blob);
a.download = filename;
a.click()
}
}
xhr.send(JSON.stringify(data))
}