|
@@ -21,41 +21,29 @@ export default {
|
|
|
addressName: '', //地址查询名称
|
|
|
poisArray: [],
|
|
|
loadding: true,
|
|
|
- mixins_query: {
|
|
|
- communityId: ''
|
|
|
- },
|
|
|
centet: []
|
|
|
};
|
|
|
},
|
|
|
mounted() {},
|
|
|
computed: {
|
|
|
- ...mapState(['homeCommunityAll']),
|
|
|
+ ...mapState(['globalCommunity', 'findCompanyCommunityTree']),
|
|
|
poisArrays() {
|
|
|
- return this.poisArray;
|
|
|
- // let arrs = [];
|
|
|
- // this.poisArray.map((item) => {
|
|
|
- // if (!!this.mixins_query.communityId) {
|
|
|
- // if (item.id == this.mixins_query.communityId) {
|
|
|
- // arrs = [item];
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // arrs = this.poisArray;
|
|
|
- // }
|
|
|
- // });
|
|
|
- // return arrs;
|
|
|
+ let arrs = [];
|
|
|
+ this.fitersValue(arrs, this.findCompanyCommunityTree);
|
|
|
+ return arrs;
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
- homeCommunityAll(val) {
|
|
|
- if (!!val) {
|
|
|
- this.mixins_query.communityId = val;
|
|
|
+ globalCommunity: {
|
|
|
+ handler(newVal, oldVal) {
|
|
|
if (!!this.map) {
|
|
|
this.map.clearMap();
|
|
|
}
|
|
|
- }
|
|
|
- if (this.poisArrays.length > 0) {
|
|
|
- this.addIcon(this.poisArrays);
|
|
|
- }
|
|
|
+ if (this.poisArrays.length > 0) {
|
|
|
+ this.addIcon(this.poisArrays);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true
|
|
|
}
|
|
|
},
|
|
|
|
|
@@ -98,7 +86,7 @@ export default {
|
|
|
});
|
|
|
self.marker.setLabel({
|
|
|
offset: new AMap.Pixel(-15, 50),
|
|
|
- content: `${item.communityName}`
|
|
|
+ content: `${item.name}`
|
|
|
});
|
|
|
if (self.poisArrays.length < 2) {
|
|
|
self.map.setFitView();
|
|
@@ -109,9 +97,36 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
setCommunity(its) {
|
|
|
- this.$store.commit('setHomeCommunityAll', its.id);
|
|
|
+ this.$store.commit('setGlobalCommunity', {
|
|
|
+ value: [its.value]
|
|
|
+ });
|
|
|
+ let newarr = this.finterParent(this.findCompanyCommunityTree, its.value);
|
|
|
+ newarr.push(its.value);
|
|
|
+ this.$store.commit('setThisArr', newarr);
|
|
|
this.$parent.showMap = false;
|
|
|
},
|
|
|
+ finterParent(data, id) {
|
|
|
+ // 深度遍历查找
|
|
|
+ function dfs(data, id, parents) {
|
|
|
+ for (var i = 0; i < data.length; i++) {
|
|
|
+ var item = data[i];
|
|
|
+ // 找到id则返回父级id
|
|
|
+ if (item.value === id) return parents;
|
|
|
+ // children不存在或为空则不递归
|
|
|
+ if (!item.children || !item.children.length) continue;
|
|
|
+ // 往下查找时将当前id入栈
|
|
|
+ parents.push(item.value);
|
|
|
+
|
|
|
+ if (dfs(item.children, id, parents).length) return parents;
|
|
|
+ // 深度遍历查找未找到时当前id 出栈
|
|
|
+ parents.pop();
|
|
|
+ }
|
|
|
+ // 未找到时返回空数组
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+
|
|
|
+ return dfs(data, id, []);
|
|
|
+ },
|
|
|
//搜索区域
|
|
|
districtMask(val) {
|
|
|
if (!this.district) {
|
|
@@ -157,10 +172,12 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
getPoin(resolve) {
|
|
|
- this.$http.get('/sc-community/assets/community/list').then(({ data, status, msg }) => {
|
|
|
+ this.$http.get('/sc-community/assets/tree/community/findCompanyCommunityTree').then(({ data, status, msg }) => {
|
|
|
if (status == 0) {
|
|
|
- this.poisArray = data;
|
|
|
- this.centet = this.getPointsCenter(data);
|
|
|
+ let arrs = [];
|
|
|
+ this.fitersValue(arrs, data);
|
|
|
+ this.centet = this.getPointsCenter(arrs);
|
|
|
+
|
|
|
resolve && resolve(true);
|
|
|
}
|
|
|
});
|
|
@@ -204,25 +221,24 @@ export default {
|
|
|
Math.floor(((tmp_lng * 180) / Math.PI) * 1000000) / 1000000,
|
|
|
Math.floor(((tmp_lat * 180) / Math.PI) * 1000000) / 1000000
|
|
|
];
|
|
|
+ },
|
|
|
+ fitersValue(arrs, value) {
|
|
|
+ let thisValue = this.globalCommunity.value;
|
|
|
+ value.map((item) => {
|
|
|
+ if (item.type == 'org') {
|
|
|
+ this.fitersValue(arrs, item.children);
|
|
|
+ } else {
|
|
|
+ if (thisValue.includes(item.parentId)) {
|
|
|
+ arrs.push(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
destroyed() {
|
|
|
this.map && this.map.destroy();
|
|
|
},
|
|
|
created() {
|
|
|
- // this.getPoin();
|
|
|
- // new Promise((resolve) => {
|
|
|
- // this.getLoc(resolve);
|
|
|
- // }).then(() => {
|
|
|
- // new Promise((resolve) => {
|
|
|
- // if (!!AMap) {
|
|
|
- // resolve(true);
|
|
|
- // }
|
|
|
- // }).then(() => {
|
|
|
- // this.init();
|
|
|
- // });
|
|
|
- // });
|
|
|
-
|
|
|
new Promise((resolve) => {
|
|
|
this.getPoin(resolve);
|
|
|
}).then(() => {
|