From 7f21cbca36ec6a1b6e17d9163f71effc4ac33ad7 Mon Sep 17 00:00:00 2001 From: Jackwang Date: Wed, 11 May 2022 16:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/plugins/change/changedeath.vue | 31 +++++++++++++++++++ .../plugins/change/changerelocation.vue | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/views/modules/plugins/change/changedeath.vue b/src/views/modules/plugins/change/changedeath.vue index 965084d6..20ca3bc2 100644 --- a/src/views/modules/plugins/change/changedeath.vue +++ b/src/views/modules/plugins/change/changedeath.vue @@ -163,6 +163,37 @@ export default { peopleMore }, methods: { + exportHandle () { + const url = this.mixinViewModuleOptions.exportURL + + this.$http({ + method: 'GET', + url, + responseType: 'blob', + data: this.formData + }) + .then(res => { + // this.download(res.data, title + '.xls') + if (res.headers["content-disposition"]) { + let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1]) + console.log('filename', fileName) + 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('下载失败') + }) + .catch(err => { + console.log('err', err) + return this.$message.error('网络错误') + }) + }, resetForm(formName) { for(const n in this.dataForm) { this.dataForm[n] = '' diff --git a/src/views/modules/plugins/change/changerelocation.vue b/src/views/modules/plugins/change/changerelocation.vue index b5fc3f4e..608e42a4 100644 --- a/src/views/modules/plugins/change/changerelocation.vue +++ b/src/views/modules/plugins/change/changerelocation.vue @@ -169,6 +169,7 @@ + @@ -176,7 +177,6 @@ -