diff --git a/src/views/dataBoard/cpts/homeDetails/index.vue b/src/views/dataBoard/cpts/homeDetails/index.vue index fe272ba6c..a07ac8983 100644 --- a/src/views/dataBoard/cpts/homeDetails/index.vue +++ b/src/views/dataBoard/cpts/homeDetails/index.vue @@ -167,6 +167,7 @@ export default { }, getUnitList(id) { + this.loading = true; this.$http.get(`/actual/base/streetOverview/getUnitHouseList?unitId=` + id).then((res) => { const { code, @@ -189,35 +190,36 @@ export default { }, getList(buid) { - this.loading = true; const homeType = this.$route.query.typeB; if (homeType === "building") { - this.$http.get(`/actual/base/streetOverview/getUnitListByBuilding?buildingId=` + "1514914015259979777").then((res) => { + // 1514914015259979777 + this.$http.get(`/actual/base/streetOverview/getUnitListByBuilding?buildingId=` + this.$route.query.id).then((res) => { const { code, data } = res.data; if (code === 0) { this.buildingList = data; this.homeText = this.buildingList[0].buildingName + this.buildingList[0].unitName; - if (buid) { - this.buildingList.forEach((item, i) => { - console.log(item); - if (item.id === buid) { - item.ifActive = true; - this.getUnitList(item.id); - } else { - item.ifActive = false; - } - }); - } else { - this.buildingList.forEach((item, i) => { - if (i === 0) { - item.ifActive = true; - this.getUnitList(item.id); - } else { - item.ifActive = false; - } - }); + if (this.buildingList && this.buildingList.length > 0) { + if (buid) { + this.buildingList.forEach((item, i) => { + console.log(item); + if (item.id === buid) { + item.ifActive = true; + this.getUnitList(item.id); + } else { + item.ifActive = false; + } + }); + } else { + this.buildingList.forEach((item, i) => { + if (i === 0) { + item.ifActive = true; + this.getUnitList(item.id); + } else { + item.ifActive = false; + } + }); + } } - this.loading = false; } else { this.loading = false;