From efff5c8410c9657915eb05615c13c2de7421c61a Mon Sep 17 00:00:00 2001 From: ludc Date: 星期四, 27 七月 2023 17:38:11 +0800 Subject: [PATCH] 修改文件下载不成功问题 --- Source/UBCS-WEB/src/components/Master/MasterTransfer.vue | 37 ++++++++++++++----------------------- 1 files changed, 14 insertions(+), 23 deletions(-) diff --git a/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue b/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue index 5af0fcb..fe85e28 100644 --- a/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue +++ b/Source/UBCS-WEB/src/components/Master/MasterTransfer.vue @@ -134,30 +134,21 @@ exportCode({codeClassifyOid:this.codeClassifyOid,'conditionMap[oid]':ids,...exportArr}).then(res=>{ console.log('res',res) const filename = '涓嬭浇.xlsx'; // 涓嬭浇鐨勬枃浠跺悕 - const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }); - const a = document.createElement('a'); - const url = window.URL.createObjectURL(blob); - a.href = url; - a.download = filename; - a.style.display = 'none'; - document.body.appendChild(a); - a.click(); - document.body.removeChild(a); - window.URL.revokeObjectURL(url); - - // const filename = '涓嬭浇.xlsx'; // 涓嬭浇鐨勬枃浠跺悕 - // const blob = new Blob([response.data], { type: 'application/vnd.ms-excel' }); - // - // const url = window.URL.createObjectURL(blob); - // const link = document.createElement('a'); - // link.href = url; - // link.setAttribute('download', filename); - // document.body.appendChild(link); - // link.click(); - // document.body.removeChild(link); - // URL.revokeObjectURL(url); + let blob = new Blob([res.data], { + type: res.data.type + ";charset=utf-8", + }); + let src = window.URL.createObjectURL(blob); + if (src) { + let link = document.createElement("a"); + link.style.display = "none"; + link.href = src; + link.setAttribute("download", "鏂囦欢鍚嶅瓧.xls"); + document.body.appendChild(link); + link.click(); + document.body.removeChild(link); //涓嬭浇瀹屾垚绉婚櫎鍏冪礌 + window.URL.revokeObjectURL(src); //閲婃斁鎺塨lob瀵硅薄 + } }) - } }; }, -- Gitblit v1.9.3