You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
3.3 KiB

<template>
<navigation-general :title="title">
<view class="building-list" >
<view class="house-c">
<view class="c-item" v-for="(item,index) in buildingInfo.floor" :key="index">{{buildingInfo.floor - index}}</view>
</view>
<scroll-view class="house-list" scroll-x="true" scroll-left="120">
<view class="list-scroll-x" :style="handlerWidth">
<view class="color-rows" v-for="(item,index) in groupedRooms" :key="index">
<color-item :showBuildingName="true" :showColorName="false" :item="house" v-for="house in item" :key="house.id"></color-item>
</view>
</view>
</scroll-view>
</view>
</navigation-general>
</template>
<script>
import {
getBuilding,
} from '@/api/taicangpop/building'
import {
handleColor
} from '@/utils/handlerColor.js'
import {
getNumNew
} from '@/api/taicangpop/data'
export default {
data() {
return {
boxTop: 0,
queryParams: {
buildingId: undefined
},
title: '',
buildingInfo: {},
newHouseList: [],
totalHouse: 0,
};
},
computed: {
handlerWidth(){
return{
width: (this.buildingInfo.house+1) * 122 + 'rpx'
}
},
groupedRooms() {
if (this.newHouseList.length == 0) return
// 初始化每层楼的数组
let floors = Array.from({
length: this.buildingInfo.floor
}, () => [])
// 遍历房间数据
this.newHouseList.forEach((room) => {
// 提取房间号前几位作为楼层号
let floor = (parseInt(room.name) / 100) | 0
// 将房间加入对应楼层数组
if (floor > 0 && floor <= this.buildingInfo.floor) {
floors[floor - 1].push(handleColor(room))
}
})
// 对每层楼的房间进行排序
floors.forEach((floorRooms) => {
floorRooms.sort((a, b) => parseInt(a.name) - parseInt(b.name))
})
uni.hideLoading()
return floors.reverse()
},
},
onLoad(option) {
const systemData = this.$u.sys()
this.boxTop = (systemData.statusBarHeight + 44) * 2
this.title = option.deptname
this.queryParams.buildingId = option.buildingId
this.getBuildingInfo()
},
methods: {
//楼信息
async getBuildingInfo() {
const res = await getBuilding(this.queryParams.buildingId)
this.buildingInfo = res.data
this.getAllHouse()
},
//获取所有的户
async getAllHouse() {
uni.showLoading({
title: '加载中',
mask:true,
})
let res = await getNumNew({
buildingId: this.queryParams.buildingId
})
this.newHouseList = res.data
this.totalHouse = this.newHouseList.length
},
}
}
</script>
<style lang="scss">
page{
background: #113666;
}
</style>
<style lang="scss" scoped>
.building-list {
width: 100%;
display: flex;
align-items: center;
// 楼层数样式/
.house-c{
.c-item{
width: 120rpx;
text-align: center;
line-height: 60rpx;
height: 60rpx;
font-size: 28rpx;
color: #fff;
background-color: rgb(64, 158, 255);
border-bottom: 1px solid rgba(255,255,255,0.1);
}
}
//所有户
.house-list{
background: #113666;
height: 100%;
.list-scroll-x{
height: 100%;
color: #fff;
.color-rows{
width: 100%;
display: flex;
height: 60rpx;
align-items: center;
.color-item{
width: 100rpx;
margin-left: 20rpx;
}
}
}
}
}
</style>