|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<div class="organ-tree">
|
|
|
- <el-input v-model="filterText" placeholder="请输入关键字" suffix-icon='el-icon-search'></el-input>
|
|
|
+ <el-input v-model="filterText" placeholder="请输入关键字" suffix-icon="el-icon-search"></el-input>
|
|
|
<div class="tree-style-box no-scrollbar">
|
|
|
<el-tree
|
|
|
class="tree-style"
|
|
@@ -22,7 +22,7 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
name: 'buildingTree',
|
|
|
- props:['buildingType'],
|
|
|
+ props: ['buildingType'],
|
|
|
data() {
|
|
|
return {
|
|
|
filterText: '',
|
|
@@ -39,20 +39,34 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- getOrgTreeList() {
|
|
|
- this.$http.get('/sc-community/assets/tree/community/find',{buildingType:this.buildingType}).then(({ status, data, msg }) => {
|
|
|
- if (status === 0 && data) {
|
|
|
- this.organList = data;
|
|
|
- this.$nextTick().then(() => {
|
|
|
- const firstNode = document.querySelector('.el-tree-node');
|
|
|
- firstNode.click();
|
|
|
- });
|
|
|
+ dimension(arr) {
|
|
|
+ arr.map((item, index) => {
|
|
|
+ if (!!item.children & (item.type !== 'unit')) {
|
|
|
+ this.dimension(item.children);
|
|
|
+ } else {
|
|
|
+ if (item.name.indexOf('单元') === -1) {
|
|
|
+ item.name = item.name + '单元';
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ getOrgTreeList() {
|
|
|
+ this.$http
|
|
|
+ .get('/sc-community/assets/tree/community/find', { buildingType: this.buildingType })
|
|
|
+ .then(({ status, data, msg }) => {
|
|
|
+ if (status === 0 && data) {
|
|
|
+ this.dimension(data);
|
|
|
+ this.organList = data;
|
|
|
+ this.$nextTick().then(() => {
|
|
|
+ const firstNode = document.querySelector('.el-tree-node');
|
|
|
+ firstNode.click();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
filterNode(value, data) {
|
|
|
if (!value) return true;
|
|
|
- return data.orgName.indexOf(value) !== -1;
|
|
|
+ return data.name.indexOf(value) !== -1;
|
|
|
},
|
|
|
treeClick(e) {
|
|
|
if (e.value == 0) return;
|
|
@@ -63,36 +77,36 @@ export default {
|
|
|
let unitPa = {};
|
|
|
if (e.value == 0) return;
|
|
|
|
|
|
- let onData='';
|
|
|
- if(e.type == "building"){
|
|
|
- onData={
|
|
|
- communityId:this.$refs.tree.getNode(e).parent.data.value,
|
|
|
- buildingId:e.value,
|
|
|
- unitId:'',
|
|
|
- roomId:'',
|
|
|
- }
|
|
|
+ let onData = '';
|
|
|
+ if (e.type == 'building') {
|
|
|
+ onData = {
|
|
|
+ communityId: this.$refs.tree.getNode(e).parent.data.value,
|
|
|
+ buildingId: e.value,
|
|
|
+ unitId: '',
|
|
|
+ roomId: ''
|
|
|
+ };
|
|
|
this.$emit('buildingInformation', onData);
|
|
|
- }else if (e.type == 'unit') {
|
|
|
- onData={
|
|
|
- communityId:this.$refs.tree.getNode(e).parent.parent.data.value,
|
|
|
- buildingId:this.$refs.tree.getNode(e).parent.data.value,
|
|
|
- unitId:e.value,
|
|
|
- roomId:'',
|
|
|
- }
|
|
|
+ } else if (e.type == 'unit') {
|
|
|
+ onData = {
|
|
|
+ communityId: this.$refs.tree.getNode(e).parent.parent.data.value,
|
|
|
+ buildingId: this.$refs.tree.getNode(e).parent.data.value,
|
|
|
+ unitId: e.value,
|
|
|
+ roomId: ''
|
|
|
+ };
|
|
|
this.$emit('buildingInformation', onData);
|
|
|
// this.$emit('organId', unitPa);
|
|
|
- }else if (e.type == "room") {
|
|
|
- onData={
|
|
|
- communityId:this.$refs.tree.getNode(e).parent.parent.parent.data.value,
|
|
|
- buildingId:this.$refs.tree.getNode(e).parent.parent.data.value,
|
|
|
- unitId:this.$refs.tree.getNode(e).parent.data.value,
|
|
|
- roomId:e.value,
|
|
|
- }
|
|
|
+ } else if (e.type == 'room') {
|
|
|
+ onData = {
|
|
|
+ communityId: this.$refs.tree.getNode(e).parent.parent.parent.data.value,
|
|
|
+ buildingId: this.$refs.tree.getNode(e).parent.parent.data.value,
|
|
|
+ unitId: this.$refs.tree.getNode(e).parent.data.value,
|
|
|
+ roomId: e.value
|
|
|
+ };
|
|
|
this.$emit('buildingInformation', onData);
|
|
|
} else {
|
|
|
this.$emit('buildingInformation', e);
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
},
|
|
|
created() {
|
|
|
this.getOrgTreeList();
|