diff --git a/src/apps/AppBuilding/detail.vue b/src/apps/AppBuilding/detail.vue index 8dd90f52..35649d37 100644 --- a/src/apps/AppBuilding/detail.vue +++ b/src/apps/AppBuilding/detail.vue @@ -39,7 +39,7 @@ - @@ -153,15 +153,13 @@ export default { selectList: [], selectCellIndex: 0, houseId: '', - detail: {} + detail: {}, + cellName: '', + eachUnitNumber: '' } }, computed: { ...mapState(['user']), - cellName() { - let building = this.selectList.find(e => e.id == this.detail.id) - return building?.cellName || "" - } }, created() { this.$dict.load('householdRelation', 'houselivingStatus', 'houseLeaseSituation', 'houseUseStatus', @@ -178,19 +176,22 @@ export default { methods: { getSelectList(communityId) { //通过小区ID获取楼栋列表,用来切换楼栋 - this.$http.post(`/app/appcommunitybuildinginfo/list`, null, { + this.$http.post(`/app/appcommunitybuildinginfo/listByUnitNumber`, null, { params: {communityId, size: 999} }).then(res => { if (res?.data) { this.selectList = [] res.data.records.forEach(e => { - for (let i = 0; i < e.unitNumber; i++) { - this.selectList.push({ - ...e, - cellName: `${e.communityName + e.buildingNumber}栋${i+1}单元` - }) - } + this.selectList.push({ + ...e, + cellName: `${e.communityName + e.buildingNumber}栋${e.eachUnitNumber}单元`, + valueId: `${e.id}${e.eachUnitNumber}` + }) }) + this.cellName = this.selectList[0].cellName + this.eachUnitNumber = this.selectList[0].eachUnitNumber + this.getStatistics() + this.getList() } }) }, @@ -202,17 +203,15 @@ export default { }).then(res => { if (res?.data) { this.detail = res.data - this.getStatistics() - this.getList() this.getSelectList(res.data.communityId) } }) }, getStatistics() { //获取楼栋统计信息 - let {id, unitNumber: unitNum} = this.detail + let {id} = this.detail this.$http.post(`app/appcommunitybuildinginfo/statistics`, null, { - params: {id, unitNum} + params: {id, unitNum: this.eachUnitNumber} }).then(res => { if (res?.data) { this.numInfo = res.data.unit @@ -221,9 +220,9 @@ export default { }, getList() { //获取房间列表 - let {id: buildingId, unitNumber} = this.detail + let {id: buildingId} = this.detail this.$http.post(`app/appcommunityhouseinfo/list`, null, { - params: {size: 10000, buildingId, unitNumber} + params: {size: 10000, buildingId, unitNumber: this.eachUnitNumber} }).then(res => { if (res?.data) { this.list = res.data.records @@ -245,10 +244,12 @@ export default { }, confirmSelect(e) { this.selectList.map((item, index) => { - if (item.id == e[0].value) { + if (item.valueId == e[0].value) { this.selectCellIndex = index } }) + this.cellName = this.selectList[this.selectCellIndex].cellName + this.eachUnitNumber = this.selectList[this.selectCellIndex].eachUnitNumber this.getStatistics() this.getList() },