From 322c8fc725907c32740acfc85aa34bde200bbf0d Mon Sep 17 00:00:00 2001 From: songyunpeng Date: Wed, 2 Sep 2020 13:28:12 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=85=E6=B0=91=E4=BF=A1=E6=81=AF=E9=87=87?= =?UTF-8?q?=E9=9B=86-Excel=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/user/housinginformation.vue | 82 ++++++++++++++++++- 1 file changed, 80 insertions(+), 2 deletions(-) diff --git a/src/views/modules/user/housinginformation.vue b/src/views/modules/user/housinginformation.vue index 1801da5..c5fcfbb 100644 --- a/src/views/modules/user/housinginformation.vue +++ b/src/views/modules/user/housinginformation.vue @@ -45,6 +45,21 @@ 导出模板 + + + 点击上传 + + + + {{ $t('export') }} + @@ -83,6 +98,30 @@ + + + + + + + + + @@ -91,6 +130,8 @@ import mixinViewModule from '@/mixins/view-module' import AddOrUpdate from './housinginformation-add-or-update' import HousinginformationDetail from './housinginformation-detail' +import Cookies from 'js-cookie' + export default { mixins: [mixinViewModule], data () { @@ -104,7 +145,8 @@ export default { exportMoudle: '/app-user/housinginformation/exportModule' }, dataForm: { - id: '' + id: '', + gridId: '' }, deptIdList: [], options: [], @@ -122,7 +164,10 @@ export default { label: '经营' } ], - detailVisible: false + detailVisible: false, + uploadUrl: '', + faultDataVisible: false, + errorDataList: [] } }, components: { @@ -150,6 +195,7 @@ export default { this.dataForm.streetId = this.deptIdList[0] this.dataForm.communityId = this.deptIdList[1] this.dataForm.gridId = this.deptIdList[2] + this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/app-user/housinginformation/importExcel?gridId=${this.deptIdList[2]}&token=${Cookies.get('token')}` } } }, @@ -164,6 +210,7 @@ export default { }) .catch(() => { }) this.getDataList() + this.uploadUrl = `${window.SITE_CONFIG['apiURL']}/app-user/housinginformation/importExcel?gridId=${this.dataForm.gridId}&token=${Cookies.get('token')}` }, methods: { houseUseFormatter: function (row, column) { @@ -186,6 +233,37 @@ export default { lookResidentInfo (id) { this.$parent.selectComponent = 'Househeadedit' this.$router.push({ path: '/user-houseinfomationroute', query: { id: id } }) + }, + errorExceed (file, fileList) { + this.$message.error('上传失败请重试') + }, + uploadError (error, file, fileList) { + this.$message.error(error) + }, + handlePreview (file) { + if (this.dataForm.gridId === undefined || this.dataForm.gridId === '') { + this.$message.error('请选择网格后导入') + return false + } + }, + uploadSuccess (response, file, fileList) { + this.$refs.upload.clearFiles() + if (response.code !== 0) { + return this.$message.error(response.msg) + } + if (response.data !== null && response.data.length > 0) { + this.faultDataVisible = true + this.errorDataList = response.data + return + } + this.$message({ + message: this.$t('prompt.success'), + type: 'success', + duration: 500, + onClose: () => { + this.getDataList() + } + }) } } }