From 6f55b619db3cc36fc9150b8b31302fe6602ab0a5 Mon Sep 17 00:00:00 2001 From: 13176889840 <13176889840@163.com> Date: Fri, 17 Dec 2021 14:06:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/base/resi.vue | 31 ++++++++++--------- .../modules/communityParty/elegant/index.vue | 28 +++++++++++------ 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/src/views/modules/base/resi.vue b/src/views/modules/base/resi.vue index 2129d100..6a4af200 100644 --- a/src/views/modules/base/resi.vue +++ b/src/views/modules/base/resi.vue @@ -350,7 +350,7 @@ export default { }) .catch((err) => { console.log('获取导出情失败', err) - this.$message.error('网络错误') + this.$message.error('获取导出失败') }) this.exportBtnTitle = '导出' this.exportBtn = false @@ -396,24 +396,27 @@ export default { responseType: 'blob' }) .then((res) => { - - let fileName = window.decodeURI(res.headers["content-disposition"].split(";")[1].split("=")[1]) + 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对象 + 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对象 + } + this.getTableData() }) .catch( err => { console.log('失败', err) - err.onError() //上传失败的文件会从文件列表中删除 + file.onError() //上传失败的文件会从文件列表中删除 + this.$message.error('导入失败') }) this.importLoading = false this.importBtnTitle = '导入人员数据' diff --git a/src/views/modules/communityParty/elegant/index.vue b/src/views/modules/communityParty/elegant/index.vue index 91fcc877..66453605 100644 --- a/src/views/modules/communityParty/elegant/index.vue +++ b/src/views/modules/communityParty/elegant/index.vue @@ -34,7 +34,7 @@
新增 - 导出 + {{ exportBtnTitle }} { - this.importLoading = false - this.importBtnTitle = '导入人员数据' + // this.importLoading = false + // this.importBtnTitle = '导入人员数据' // 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' }) @@ -355,17 +357,23 @@ export default { }) .catch( err => { console.log('失败', err) - param.onError() //上传失败的文件会从文件列表中删除 + file.onError() //上传失败的文件会从文件列表中删除 + this.$message.error('导入失败') }) + this.importLoading = false + this.importBtnTitle = '导入人员数据' + this.$refs.upload.clearFiles() }, - handleExport() { + async handleExport() { + this.exportBtn = true + this.exportBtnTitle = '正在导出...' let params = { agencyId: this.$store.state.user.agencyId, pageSize: 9999, pageNo: this.currentPage } // .post('epmetuser/icresiuser/exportExcel', params) - axios({ + await axios({ url: window.SITE_CONFIG['apiURL'] + '/resi/partymember/icpartymemberstyle/export', // url: 'epmetuser/icresiuser/exportExcel', method: 'post', @@ -389,8 +397,10 @@ export default { }) .catch((err) => { console.log('获取导出情失败', err) - return this.$message.error('网络错误') + this.$message.error('获取导出失败') }) + this.exportBtn = false + this.exportBtnTitle = '导出' }, beforeImgUpload (file) { const isPNG = (file.type === 'image/png') || (file.type === 'image/jpeg')