From 9eae566958838f07a0e70ef20e7dca01db3e56f5 Mon Sep 17 00:00:00 2001 From: qushutong <1976590620@qq.com> Date: Mon, 4 Nov 2019 17:46:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=9A=E5=91=98=E5=BD=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mixins/view-module.js | 12 ++++- src/views/modules/user/partymembers.vue | 59 ++++++++++++++++++++++--- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/src/mixins/view-module.js b/src/mixins/view-module.js index df9684b9..8e26f528 100644 --- a/src/mixins/view-module.js +++ b/src/mixins/view-module.js @@ -126,8 +126,8 @@ export default { this.getDataList() } }) - }).catch(() => {}) - }).catch(() => {}) + }).catch(() => { }) + }).catch(() => { }) }, // 导出 exportHandle () { @@ -136,6 +136,14 @@ export default { ...this.dataForm }) window.location.href = `${window.SITE_CONFIG['apiURL']}${this.mixinViewModuleOptions.exportURL}?${params}` + }, + // 导出模板 + exportMoudleHandle () { + var params = qs.stringify({ + 'token': Cookies.get('token'), + ...this.dataForm + }) + window.location.href = `${window.SITE_CONFIG['apiURL']}${this.mixinViewModuleOptions.exportMoudle}?${params}` } } } diff --git a/src/views/modules/user/partymembers.vue b/src/views/modules/user/partymembers.vue index 6ba2e9c4..45571ef9 100755 --- a/src/views/modules/user/partymembers.vue +++ b/src/views/modules/user/partymembers.vue @@ -106,13 +106,19 @@ {{ $t('export') }} + + 导出模板 + + :on-success='uploadSuccess' + :on-error='errorExceed'> 点击上传 @@ -201,6 +207,26 @@ + + + + + + + + @@ -218,7 +244,8 @@ export default { getDataListIsPage: true, deleteURL: '/app-user/partymembers', deleteIsBatch: true, - exportURL: '/app-user/partymembers/export' + exportURL: '/app-user/partymembers/export', + exportMoudle: '/app-user/partymembers/exportMoudle' }, dataForm: { id: '', @@ -239,7 +266,9 @@ export default { registOptions: [], postOptions: [], timeRange: [], - upLoadUrl: '' + upLoadUrl: '', + faultDataVisible: false, + errordataList: [] } }, components: { @@ -350,11 +379,29 @@ export default { this.dataListLoading = false }) }, - handleExceed (files, fileList) { - this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`) - }, beforeRemove (file, fileList) { return this.$confirm(`确定移除 ${file.name}?`) + }, + errorExceed (file, fileList) { + this.$message.error('上传失败请重试') + }, + uploadSuccess (response, file, fileList) { + this.dataListLoading = false + console.log(response) + if (response.data !== null && response.data.length > 0) { + this.faultDataVisible = true + this.errordataList = response.data + console.log(this.faultDataVisible) + return + } + this.$message({ + message: this.$t('prompt.success'), + type: 'success', + duration: 500, + onClose: () => { + this.getDataList() + } + }) } } }