From c5ab3fe3511226cd957efc4a8199371f0f36017d Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Tue, 2 Apr 2024 14:57:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E5=AF=BC=E5=85=A5=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/smartImport/cpts/createdTask.vue | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/views/modules/base/smartImport/cpts/createdTask.vue b/src/views/modules/base/smartImport/cpts/createdTask.vue index 4169783a0..bce9db97d 100644 --- a/src/views/modules/base/smartImport/cpts/createdTask.vue +++ b/src/views/modules/base/smartImport/cpts/createdTask.vue @@ -418,51 +418,51 @@ export default { }, // 下载单个模板 async handelClickDownModule() { - let url = "/actual/base/intelligentImportData/autoGenerateExcelModule"; + let url = "/actual/base/intelligentImportData/downloadImportModule"; let params = { importCategory: this.form.importCategory, }; await this.$http({ method: "POST", url, - // responseType: "blob", + responseType: "blob", data: params, }) .then((res) => { - // if (res.status==200) { + if (res.status==200) { // let fileName = window.decodeURI( // res.headers["content-disposition"] // .split(";")[1] // .split("=")[1] // ); - // let fileName = `${ - // this.$store.state.user.agencyName + this.categoryName - // }导入模板`; - // let blob = new Blob([res.data], { - // type: "application/vnd.ms-excel", - // }); - // var url = window.URL.createObjectURL(blob); - // var aLink = document.createElement("a"); - // aLink.style.display = "none"; - // aLink.href = url; - // aLink.setAttribute("download", fileName); - // document.body.appendChild(aLink); - // aLink.click(); - // document.body.removeChild(aLink); //下载完成移除元素 - // window.URL.revokeObjectURL(url); //释放掉blob对象 - // } else this.$message.error("下载失败"); - let fileName = `${ + let fileName = `${ this.$store.state.user.agencyName + this.categoryName }导入模板`; - const url = res.data.data; - const aLink = document.createElement("a"); - aLink.style.display = "none"; - aLink.href = url; - aLink.setAttribute("download",`${fileName}.xlsx`); - document.body.appendChild(aLink); - aLink.click(); - document.body.removeChild(aLink); - window.URL.revokeObjectURL(url); + let blob = new Blob([res.data], { + type: "application/vnd.ms-excel", + }); + var url = window.URL.createObjectURL(blob); + var aLink = document.createElement("a"); + aLink.style.display = "none"; + aLink.href = url; + aLink.setAttribute("download", fileName); + document.body.appendChild(aLink); + aLink.click(); + document.body.removeChild(aLink); //下载完成移除元素 + window.URL.revokeObjectURL(url); //释放掉blob对象 + } else this.$message.error("下载失败"); + // let fileName = `${ + // this.$store.state.user.agencyName + this.categoryName + // }导入模板`; + // const url = res.data.data; + // const aLink = document.createElement("a"); + // aLink.style.display = "none"; + // aLink.href = url; + // aLink.setAttribute("download",`${fileName}.xlsx`); + // document.body.appendChild(aLink); + // aLink.click(); + // document.body.removeChild(aLink); + // window.URL.revokeObjectURL(url); }) .catch((err) => { console.log(err);