export function getParticipantList(param) {
return ecloudRequest({
url: "",
method: "get",
params: param,
responseType: param.isExport ? 'blob' : ''
});
}
接口返回处理
const blob = new Blob([res])
const fileName = ''
if (navigator.userAgent.indexOf("Trident") !== -1) {
window.navigator.msSaveOrOpenBlob(blob, fileName)
} else {
const a = document.createElement("a")
a.href = URL.createObjectURL(blob)
a.download = fileName
a.innerHTML = "导出"
a.style.display = "none"
document.body.appendChild(a) // 防止firefox无法触发click
a.click()
setTimeout(() => {
document.body.removeChild(a)
}, 10000)
}
解决火狐浏览器中下载格式xml的问题,加type,后缀
export function fileDownload(id, fileName,suffix) {
downloadFileById(id).then(res => {
if(navigator.userAgent.indexOf("Trident") !== -1) {
window.navigator.msSaveOrOpenBlob(new Blob([res]),fileName,suffix)
}else {
let link = document.createElement("a");
if(suffix) {
link.href = window.URL.createObjectURL(new Blob([res],{type:"text/"+suffix}));
}else {
link.href = window.URL.createObjectURL(new Blob([res]));
}
link.target = "_blank";
link.download = fileName;
document.body.appendChild(link); // Firefox 中必须这么写,不然不会起效果
link.click();
document.body.removeChild(link);
}
});
}