const downloadTemplate = () => {
// http
// .get("/api/" + import.meta.env.VITE_APP_SERVICE + "/site/template")
// .then((res: any) => {
// downloadFile("./" + res);
// });
const tokenjeecg: any = localStorage.getItem("token");
axios({
method: 'GET',
url: "/api/" + import.meta.env.VITE_APP_SERVICE + "/site/template",
responseType: 'blob',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
"X-Access-Token": JSON.parse(tokenjeecg)
}
}).then((res: any) => {
console.log('res', res);
const responseText = res.data;
const elink = document.createElement('a');
elink.download = '测站基本信息表模板.xls';
elink.href = URL.createObjectURL(new Blob([responseText], {type: 'application/xls'}));
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
}).catch(() => {
message.error("导出失败");
});
};
const exportData = () => {
// http
// .post(
// "/api/" + import.meta.env.VITE_APP_SERVICE + "/site/export",
// form.value
// )
// .then((res: any) => {
// downloadFile("./" + res);
// });
const tokenjeecg: any = localStorage.getItem("token");
axios({
method: 'POST',
url: "/api/" + import.meta.env.VITE_APP_SERVICE + "/site/export",
responseType: 'blob',
headers: {
// eslint-disable-next-line quotes
'Content-Type': 'application/json',
"X-Access-Token": JSON.parse(tokenjeecg)
},
data: { ...form.value }
}).then((res: any) => {
console.log('res', res);
const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' });
const elink = document.createElement('a');
elink.download = '测站基本信息表' + '.xlsx';
elink.href = URL.createObjectURL(blob);
document.body.appendChild(elink);
elink.click();
document.body.removeChild(elink);
// window.URL.revokeObjectURL(elink);
}).catch(() => {
message.error("导出失败");
});
};
导出bolb
最新推荐文章于 2024-09-09 21:14:24 发布