From 9712c947bebeece9da709a8a07f7625e5c2d58cd Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Wed, 15 Feb 2023 16:27:38 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E5=B1=8B=E5=B7=A6=E4=BE=A7=E6=A0=91?= =?UTF-8?q?=E6=87=92=E5=8A=A0=E8=BD=BD=E4=B8=8E=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/components/resiForm.vue | 6 +- .../modules/base/community/community.vue | 129 ++++++++++++++---- 2 files changed, 102 insertions(+), 33 deletions(-) diff --git a/src/views/components/resiForm.vue b/src/views/components/resiForm.vue index 288b75729..9f40b73b9 100644 --- a/src/views/components/resiForm.vue +++ b/src/views/components/resiForm.vue @@ -1618,9 +1618,9 @@ export default { this.getHouseList() }, async handleClick (tab, event) { - console.log(tab); - console.log(event); - console.log(tab._props.label ); + // console.log(tab); + // console.log(event); + // console.log(tab._props.label ); if (tab._props.label == '教育') { if (!this.form.resiId) { this.newForm.eduInfoDto = this.form.eduInfoDto diff --git a/src/views/modules/base/community/community.vue b/src/views/modules/base/community/community.vue index 59a6ae2da..17c6603fd 100644 --- a/src/views/modules/base/community/community.vue +++ b/src/views/modules/base/community/community.vue @@ -4,7 +4,7 @@
+ v-model="filterText" @keydown.native.enter="handleChangeSerch()"> @@ -15,10 +15,11 @@ :props="defaultProps" :highlight-current="true" node-key="id" - :default-expanded-keys="openNodes" :expand-on-click-node="false" :filter-node-method="filterNode" - @node-click="handleNodeClick"> + @node-click="handleNodeClick" + lazy + :load="lazyLoadTree"> @@ -140,10 +141,19 @@ + + item.label == val) + // this.optionsV.forEach( function(item){ + // if(item.label==val){ + // console.log(1); + // } + // }) + // console.log(this.optionsV ); + // }, handleChangeB (val) { this.buildingUnitId = ""; @@ -443,7 +468,21 @@ export default { this.houseId = ""; this.getHouseList(); }, - + async lazyLoadTree(node, resolve) { + const url = `/actual/base/communityBuilding/tree/nextTreeNode?id=${node.data.id}&level=${node.data.level}`; + const { data, code, msg } = await requestGet(url); + if (code === 0) { + data.forEach((element) => { + if (element.level === "building") { + element.isLeaf = true; + } + }); + resolve(data); + } else { + this.$message.error(msg); + } + // } + }, async getValiheList () { const { user } = this.$store.state; if (!this.selGridId) { @@ -493,6 +532,42 @@ export default { } + }, + //回车搜索组织 + async handleChangeSerch (){ + this.startLoading() + this.$refs.ref_tree.$data.store.lazy = !this.filterText + if(this.filterText.length > 0 && this.filterText!=''){ + const url = `/actual/base/communityBuilding/tree/search?keyword=${this.filterText}` + const {data,code,msg} = await requestGet(url) + if(data[0].children.length>0){ + this.treeData = data + }else{ + this.treeData = [] + setTimeout(() => { + this.loadTree() + }, 5) + this.$message.error('暂未找到!') + } + }else { + this.treeData = [] + this.loadTree() + } + this.endLoading() + } , + startLoading () { + loading = Loading.service({ + lock: true, // 是否锁定 + text: '正在加载……', // 加载中需要显示的文字 + background: 'rgba(0,0,0,.7)' // 背景颜色 + }) + }, + // 结束加载动画 + endLoading () { + // clearTimeout(timer); + if (loading) { + loading.close() + } }, async getUniList () { @@ -584,30 +659,24 @@ export default { } }, async loadTree (isRefresh) { - const url = "/actual/base/communityBuilding/listBuildingTree" - let params = {} - - const { data, code, msg } = await requestPost(url, params) - + const url = "/actual/base/communityBuilding/tree/initTree" + const { data, code, msg } = await requestGet(url) if (code === 0) { this.openNodes = [] - this.openNodes.push(data[0].id) + this.openNodes.push(data.id) - this.treeData = data - this.handleTreeData(this.treeData) + this.treeData = [] + this.treeData.push(data) + if (!isRefresh && data) { + this.selTreeObj = data; + if (!this.selTreeObj.latitude) { + this.selTreeObj.latitude = this.centerPoint[0]; + } - - if (!isRefresh && data.length > 0) { - - this.selTreeObj = data[0] - if (!this.selTreeObj.latitude) { - this.selTreeObj.latitude = this.centerPoint[0] - } - - if (!this.selTreeObj.longitude) { - this.selTreeObj.longitude = this.centerPoint[1] - } - } + if (!this.selTreeObj.longitude) { + this.selTreeObj.longitude = this.centerPoint[1]; + } + } } else { this.$message.error(msg) @@ -820,9 +889,9 @@ export default { } }, watch: { - filterText (val) { - this.$refs.ref_tree.filter(val); - }, + // filterText (val) { + // this.$refs.ref_tree.filter(val); + // }, }, components: {