修复部分楼层房间数不对问题

master
许宏杰 10 months ago
parent bfe31cbbe2
commit 883f1087d7

@ -9,7 +9,7 @@
v-show="item.color == 'HF' || item.color == 'NF'" v-show="item.color == 'HF' || item.color == 'NF'"
></div> ></div>
</div> </div>
<div class="house-number">{{ item.name }}</div> <div class="house-number">{{ item.name.replace("室", "") }}</div>
<div class="item-type"> <div class="item-type">
<el-tooltip effect="dark" content="党员" placement="top"> <el-tooltip effect="dark" content="党员" placement="top">
<img <img

@ -12,13 +12,13 @@
</div> </div>
<div class="building-house-container"> <div class="building-house-container">
<div class="building-name">{{ info.deptname }}{{ info.name }}</div> <div class="building-name">{{ info.deptname }}{{ info.name }}</div>
<div class="house" v-for="(item, index) in list" :key="index"> <div class="house" v-for="(item, index) in groupedRooms" :key="index">
<colorCell <colorCell
:active="currentIndex == house.keyId ? 'activeCell' : ''" :active="currentIndex == house.keyId ? 'activeCell' : ''"
:isClcik="true" :isClcik="true"
:item="house" :item="house"
v-for="house in item" v-for="(house, houseIndex) in item"
:key="house.keyId" :key="houseIndex"
@clickHouse="clickHouse(house, house.keyId)" @clickHouse="clickHouse(house, house.keyId)"
></colorCell> ></colorCell>
</div> </div>
@ -49,6 +49,29 @@ export default {
"rightTopColor", "rightTopColor",
"houseItem", "houseItem",
]), ]),
groupedRooms() {
//
let floors = Array.from({ length: this.info.floor }, () => []);
//
this.list.forEach((room) => {
//
let floor = (parseInt(room.name) / 100) | 0;
room.keyId = uuidv4();
//
if (floor > 0 && floor <= this.info.floor) {
floors[floor - 1].push(this.handleColor(room));
}
});
//
floors.forEach((floorRooms) => {
floorRooms.sort((a, b) => parseInt(a.name) - parseInt(b.name));
});
// 1
return floors;
},
}, },
components: { components: {
colorCell, colorCell,
@ -95,7 +118,6 @@ export default {
rightTopColor: item.rightTopColor, rightTopColor: item.rightTopColor,
}); });
this.currentIndex = keyId; this.currentIndex = keyId;
console.log(this.currentIndex);
}, },
async getBuildingInfo() { async getBuildingInfo() {
let info = await getBuilding(this.queryParamsXiaoqu.buildingId); let info = await getBuilding(this.queryParamsXiaoqu.buildingId);
@ -106,52 +128,31 @@ export default {
let res = await getNum({ let res = await getNum({
buildingId: this.queryParamsXiaoqu.buildingId, buildingId: this.queryParamsXiaoqu.buildingId,
}); });
this.list = res.data;
this.list = this.filterFloor(res.data); // this.list = this.groupedRooms(res.data);
// let num = 0;
// this.list.forEach((item) => {
// num = num + item.length;
// });
// console.log(num, res.data.length);
}, },
// //
handleColor(item) { handleColor(item) {
if (!item.color) { if (!item.color) {
item.leftColor = "#7b75ff"; item.leftColor = "#7b75ff";
item.rightTopColor = "#7b75ff"; item.rightTopColor = "#7b75ff";
return; } else {
}
for (let key in this.leftColor) { for (let key in this.leftColor) {
if (item.color == key) { if (item.color == key) {
item.leftColor = this.leftColor[key]; item.leftColor = this.leftColor[key];
item.rightTopColor = this.rightTopColor[key]; item.rightTopColor = this.rightTopColor[key];
} }
} }
return item;
},
filterFloor(list) {
const categorizedRooms = {};
list.forEach((room) => {
room.name = room.name.replace("室", "");
room.keyId = uuidv4();
const floor = (parseInt(room.name, 10) / 100) | 0;
if (!categorizedRooms[floor]) {
categorizedRooms[floor] = [];
} }
categorizedRooms[floor].push(this.handleColor(room)); return item;
});
const totalFloors = this.info.floor;
const sortedRoomsByFloor = [];
for (let floor = 1; floor <= totalFloors; floor++) {
const roomsForFloor = (categorizedRooms[floor] || []).sort((a, b) => {
return a.name - b.name;
});
const filteredArray = roomsForFloor.filter(
(element) => element !== undefined
);
sortedRoomsByFloor.push(filteredArray);
}
return sortedRoomsByFloor.reverse();
}, },
}, },
}; };

Loading…
Cancel
Save