/**
* @description: 导出数据
* @return {type}
* @author: jxh
*/
import axios from 'axios';
import util from '@/libs/util';
const {
acessToken = "",
refreshToken = ""
} = JSON.parse(util.cookies.get('token')) ;//获取需要的token
export function getExportXls(data) {
var url=`${netWork.productionURL}/custom/customFormData/exportXls`//请求地址
axios({
method:"post",
url:url,
responseType:"blob",
headers:{
post: {
'Content-Type': 'application/x-www-form-urlencoded'
},
'X-Requested-With': 'XMLHttpRequest',
acessToken,
refreshToken
},
data:data
}).then(res=>{
if(res.code){
this.$Message.error(res.msg)
}else{
var filename = "导出表.xls";
let blob = new Blob([res.data]);
const link = document.createElement('a');
link.style.display = 'none';
link.href = window.URL.createObjectURL(blob);
link.download = filename;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
})
}
前端文件导出—单独请求
最新推荐文章于 2022-10-23 20:55:14 发布