From e11aa7ce245141925c30d3dc25be369c877ebdbf Mon Sep 17 00:00:00 2001 From: wangqiujuan0808 <578331299@qq.com> Date: Sat, 11 May 2024 23:49:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E6=96=87=E4=BB=B6=E5=90=8D?= =?UTF-8?q?=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ViewPoint.vue | 13 ++++--------- src/utils/axios.js | 5 +++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/components/ViewPoint.vue b/src/components/ViewPoint.vue index cccb37f..2be66ff 100644 --- a/src/components/ViewPoint.vue +++ b/src/components/ViewPoint.vue @@ -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)); } diff --git a/src/utils/axios.js b/src/utils/axios.js index 32f9983..10a0bf3 100644 --- a/src/utils/axios.js +++ b/src/utils/axios.js @@ -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) {