导出文件名称

main
wangqiujuan0808 2024-05-11 23:49:48 +08:00
parent e2333edf17
commit e11aa7ce24
2 changed files with 9 additions and 9 deletions

View File

@ -202,6 +202,7 @@ export default {
}
const exportData = async () => {
axios({
method: "post",
url: '/template',
@ -211,19 +212,13 @@ export default {
},
responseType: 'blob',
}).then((response) => {
const url = window.URL.createObjectURL(new Blob([response]));
let fileName = response.headers['content-disposition'].split('filename=')[1];
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', props.formData.name +'_points.csv');
link.setAttribute('download', `${decodeURI(fileName.split('"')[1])}`);
document.body.appendChild(link);
link.click();
// const link = document.createElement('a');
// link.href = url;
// link.setAttribute('download', '_points.csv');
// link.click();
// document.body.removechild(link);
// window.URL.revokeobjectURL(url);
}).catch(error => console.log(error));
}

View File

@ -26,6 +26,7 @@ axios.interceptors.request.use(
axios.interceptors.response.use(
(res) => {
for (const key in res.headers) {
if (Object.hasOwnProperty.call(res.headers, "token")) {
const token = res.headers["token"];
@ -34,6 +35,10 @@ axios.interceptors.response.use(
}
}
}
if(res.config.headers['action'] == 53211) { //
return res;
}
console.log(res);
const ret = res.data;
// token
if (ret.code === 3004) {