From c56599e042c150452058630c4d759dc7f804e0a9 Mon Sep 17 00:00:00 2001 From: lenovo Date: Mon, 14 Nov 2022 09:39:17 +0800 Subject: [PATCH] fix --- src/components/GmhExcel.vue | 49 ++++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/components/GmhExcel.vue b/src/components/GmhExcel.vue index 493977b..6f71fc3 100644 --- a/src/components/GmhExcel.vue +++ b/src/components/GmhExcel.vue @@ -212,7 +212,7 @@ export default { this.$axios .get("/api/excel/cellNumSearch", { params: { - cellNum: this.model.cellNum + cellRowStr: this.model.cellNum } }) .then(res => { @@ -229,22 +229,37 @@ export default { }); }, executeTemplate() { - this.$axios - .get("/api/excel/executeTemplate", { - params: { - newCellData: this.model.newCellData - } - }) - .then(res => { - const { data } = res; - if (data.success) { - } else { - this.$message.error(data.msg); - } - }) - .catch(err => { - console.log(err); - }); + this.active++; + let a = document.createElement("a"); //创建一个a标签元素 + a.style.display = "none"; //设置元素不可见 + a.target = "_blank"; + a.href = `/api/excel/executeTemplate?newCellData=${encodeURIComponent( + this.model.newCellData + )}&cellRowStr=${this.model.cellNum}`; + document.body.appendChild(a); //加入 + a.click(); //触发点击,下载 + document.body.removeChild(a) / 释放; + setTimeout(() => { + this.active++; + }, 2000); + + // this.$axios + // .get("/api/excel/executeTemplate", { + // params: { + // newCellData: this.model.newCellData, + // cellRowStr: this.model.cellNum + // } + // }) + // .then(res => { + // const { data } = res; + // if (data.success) { + // } else { + // this.$message.error(data.msg); + // } + // }) + // .catch(err => { + // console.log(err); + // }); } } };