From 64eda390c641427b5c4e54b35979ad0e1fa3b055 Mon Sep 17 00:00:00 2001 From: dhy1725534722 <1725534722@qq.com> Date: Mon, 14 Aug 2023 09:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/cosmeticsArchives.vue | 36 ++++++++++++------- src/views/productsMsg/components/health.vue | 7 +++- src/views/productsMsg/index.vue | 28 ++++++--------- 3 files changed, 39 insertions(+), 32 deletions(-) diff --git a/src/views/productsMsg/components/cosmeticsArchives.vue b/src/views/productsMsg/components/cosmeticsArchives.vue index d7f1243..d5c7c45 100644 --- a/src/views/productsMsg/components/cosmeticsArchives.vue +++ b/src/views/productsMsg/components/cosmeticsArchives.vue @@ -224,20 +224,30 @@ export default { //备案编号 babm: this.form1.babm, }; - dchzpsj(query1).then((res) => { - const blob = new Blob([res],{type:res.type}); - const link = document.createElement("a"); - link.href = window.URL.createObjectURL(blob); - link.style.display = 'none' - //到时候判断是哪个化妆品数据 - link.download = this.filterTypes(this.types)+ '.xlsx' ; - link.click(); - this.loadA.close(); - this.$message({ - type: "success", - message: "导出成功", + dchzpsj(query1) + .then((res) => { + console.log(res); + const blob = new Blob([res], { type: res.type }); + // blob.text().then((res11) => console.log(res11)); + console.log(blob.stream()); + const link = document.createElement("a"); + link.href = window.URL.createObjectURL(blob); + link.style.display = "none"; + //到时候判断是哪个化妆品数据 + link.download = this.filterTypes(this.types) + ".xlsx"; + link.click(); + this.loadA.close(); + this.$message({ + type: "success", + message: "导出成功", + }); + }) + .catch((err) => { + this.$message({ + type: "info", + message: "导出失败", + }); }); - }); }, closeDC() { this.showCK = false; diff --git a/src/views/productsMsg/components/health.vue b/src/views/productsMsg/components/health.vue index 594d180..ab191a8 100644 --- a/src/views/productsMsg/components/health.vue +++ b/src/views/productsMsg/components/health.vue @@ -214,7 +214,12 @@ export default { type: "success", message: "导出成功", }); - }); + }) .catch((err) => { + this.$message({ + type: "info", + message: "导出失败", + }); + }); }, closeDC() { this.showCK = false; diff --git a/src/views/productsMsg/index.vue b/src/views/productsMsg/index.vue index 85f1814..7302162 100644 --- a/src/views/productsMsg/index.vue +++ b/src/views/productsMsg/index.vue @@ -213,19 +213,6 @@ export default { this.chinaCosmetics(1); }, methods: { - // convertFileStreamToBinary(fileStream) { - // return new Promise((resolve, reject) => { - // const reader = new FileReader(); - // reader.onload = function (event) { - // const binaryData = event.target.result; - // resolve(binaryData); - // }; - // reader.onerror = function (event) { - // reject(event.target.error); - // }; - // reader.readAsArrayBuffer(fileStream); - // }); - // }, openDC() { this.showCK = false; this.loadA = Loading.service({ @@ -234,16 +221,21 @@ export default { background: "rgba(0, 0, 0, 0.7)", }); dcyp(this.form1).then((res) => { - const blob = new Blob([res],{type:res.type}); + const blob = new Blob([res], { type: res.type }); const link = document.createElement("a"); link.href = window.URL.createObjectURL(blob); - link.style.display = 'none' - link.download = "药品"+ '.xlsx'; + link.style.display = "none"; + link.download = "药品" + ".xlsx"; link.click(); this.loadA.close(); this.$message({ type: "success", message: "导出成功", + }).catch((err) => { + this.$message({ + type: "info", + message: "导出失败", + }); }); }); }, @@ -300,8 +292,8 @@ export default { //重置 reset() { this.form1 = { - //产品名称 - cpmc: "", + //产品名称 + cpmc: "", //剂型 jx: "", //批准文号