|
@@ -22,6 +22,7 @@
|
|
|
<script>
|
|
|
export default {
|
|
|
name: 'organTree',
|
|
|
+ props: ['buildingType'],
|
|
|
data() {
|
|
|
return {
|
|
|
filterText: '',
|
|
@@ -39,23 +40,25 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
getOrgTreeList() {
|
|
|
- this.$http.get('/sc-community/assets/tree/community/find').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();
|
|
|
- });
|
|
|
- }
|
|
|
- });
|
|
|
+ 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();
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
dimension(arr) {
|
|
|
arr.map((item, index) => {
|
|
|
if (!!item.children & (item.type !== 'unit')) {
|
|
|
this.dimension(item.children);
|
|
|
} else {
|
|
|
- if (item.name.indexOf('单元') === -1) {
|
|
|
+ if (item.name.indexOf('单元') === -1 && item.type === 'unit') {
|
|
|
item.name = item.name + '单元';
|
|
|
}
|
|
|
}
|
|
@@ -78,6 +81,7 @@ export default {
|
|
|
houseId: '',
|
|
|
type: e.type
|
|
|
};
|
|
|
+ let newValueIds = e.id.split('-');
|
|
|
let thisObj = this.$refs.tree.getNode(e);
|
|
|
if (e.type == 'building') {
|
|
|
unitPa.communityName = thisObj.parent.data.name;
|
|
@@ -92,12 +96,12 @@ export default {
|
|
|
unitPa.unitName = e.name;
|
|
|
unitPa.unitId = e.value;
|
|
|
} else if (e.type == 'room') {
|
|
|
- unitPa.communityName = thisObj.parent.parent.parent.data.name;
|
|
|
- unitPa.communityId = thisObj.parent.parent.parent.data.value;
|
|
|
- unitPa.buildingName = thisObj.parent.parent.data.name;
|
|
|
- unitPa.buildingId = thisObj.parent.parent.data.value;
|
|
|
- unitPa.unitName = thisObj.parent.data.name;
|
|
|
- unitPa.unitId = thisObj.parent.data.value;
|
|
|
+ unitPa.communityName = newValueIds.length == 4 ? thisObj.parent.parent.parent.data.name : thisObj.parent.parent.data.name;
|
|
|
+ unitPa.communityId = newValueIds.length == 4 ? thisObj.parent.parent.parent.data.value : thisObj.parent.parent.data.value;
|
|
|
+ unitPa.buildingName = newValueIds.length == 4 ? thisObj.parent.parent.data.name : thisObj.parent.data.name;
|
|
|
+ unitPa.buildingId = newValueIds.length == 4 ? thisObj.parent.parent.data.value : thisObj.parent.data.value;
|
|
|
+ unitPa.unitName = newValueIds.length == 4 ? thisObj.parent.data.name : '';
|
|
|
+ unitPa.unitId = newValueIds.length == 4 ? thisObj.parent.data.value : '';
|
|
|
unitPa.houseName = e.name;
|
|
|
unitPa.houseId = e.value;
|
|
|
} else {
|