diff --git a/epmet-oper-web/src/views/modules/base/community/community.vue b/epmet-oper-web/src/views/modules/base/community/community.vue index b601307..8997700 100644 --- a/epmet-oper-web/src/views/modules/base/community/community.vue +++ b/epmet-oper-web/src/views/modules/base/community/community.vue @@ -110,7 +110,7 @@ export default { this.treeData = data if (!isRefresh && data.length > 0) { - debugger + this.selTreeObj = data[0] if (!this.selTreeObj.latitude) { this.selTreeObj.latitude = this.centerPoint[0] @@ -176,7 +176,6 @@ export default { //解析树数据 getTreeObj (obj) { - // debugger // 树接口: // 组织:组织id、组织名称、type、经度、纬度 // 小区:小区id、小区名称、type、所属网格id、所属网格名称、所属组织id、所属组织名称、经度、纬度 diff --git a/epmet-oper-web/src/views/modules/base/community/communityTable.vue b/epmet-oper-web/src/views/modules/base/community/communityTable.vue index edb74ad..b42c885 100644 --- a/epmet-oper-web/src/views/modules/base/community/communityTable.vue +++ b/epmet-oper-web/src/views/modules/base/community/communityTable.vue @@ -40,9 +40,24 @@ 下载小区模板 - + 导入小区数据 + +
@@ -246,8 +261,6 @@ export default { } }); - - }, async deleteCommunity (row) { @@ -271,15 +284,151 @@ export default { } }, - handleExport () { + + //导出表格 + async handleExport () { + let title = this.agencyObj.label + + if (this.agencyObj.level === 'building') {//点击楼栋 + title = title + '—房屋列表' + + } else if (this.agencyObj.level === 'neighbourHood') {//点击小区 + title = title + '—楼栋列表' + + } else { + title = title + '—小区列表' + } + + const url = "/gov/org/neighborhood/exportneighborhoodinfo" + let params = { + ownerName: this.ownerName, + ownerPhone: this.ownerPhone, + level: this.agencyObj.level, + id: this.agencyObj.id + } + + app.ajax.exportFilePost( + url, + params, + (data, rspMsg) => { + + this.download(data, title + '.xls') + }, + (rspMsg, data) => { + this.$message.error(rspMsg); + } + ); }, + // 下载文件 + download (data, fileName) { + if (!data) { + return + } + + var csvData = new Blob([data]) + + if (window.navigator && window.navigator.msSaveOrOpenBlob) { + window.navigator.msSaveOrOpenBlob(csvData, fileName); + } + // for Non-IE (chrome, firefox etc.) + else { + var a = document.createElement('a'); + document.body.appendChild(a); + a.style = 'display: none'; + var url = window.URL.createObjectURL(csvData); + a.href = url; + a.download = fileName; + a.click(); + a.remove(); + window.URL.revokeObjectURL(url); + } + + }, handleExportModule () { + let title = '' + + if (this.agencyObj.level === 'building') {//点击楼栋 + title = '房屋模板' + + } else if (this.agencyObj.level === 'neighbourHood') {//点击小区 + title = '楼栋模板' + + } else { + title = '小区模板' + } + + const url = "/gov/org/neighborhood/exporttemplate" + let params = {} + + app.ajax.exportFilePost( + url, + params, + (data, rspMsg) => { + + this.download(data, title + '.xls') + }, + (rspMsg, data) => { + this.$message.error(rspMsg); + } + ); + }, + // 上传文件之前的钩子 + beforeUpload (file) { + this.files = file; + + const isText = file.type === 'application/vnd.ms-excel' + const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' + + if (!isText && !isTextComputer) { + this.$message.error('请选择正确格式的文件') + return false + } else { + this.fileName = file.name; + return true + } + + }, + // 上传文件个数超过定义的数量 + handleExceed (files, fileList) { + this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`) }, - handleInport () { + + uploadFile () { + this.loading = true + + if (this.fileName == "") { + this.$message.warning('请选择要上传的文件!') + return false + } + + //清空上传列表 + this.$refs['upload'].clearFiles() + + var url = '/gov/org/neighborhood/import' + let fileFormData = new FormData(); + fileFormData.append('fileName', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名 + + app.ajax.importFilePut( + url, + fileFormData, + (data, rspMsg) => { + this.$nextTick(() => { + + this.loading = false + this.$message.success(rspMsg) + this.loadTable() + }) + }, + (rspMsg, data) => { + this.loading = false + this.$message.error('

' + rspMsg + '

'); + } + ) + },