feat: add bed occupancy stats to RoomVisual cards and API
This commit is contained in:
@@ -86,11 +86,9 @@ const RoomVisualPage: React.FC = () => {
|
||||
const emptyRooms = rooms.filter(
|
||||
(r: any) => r.currentCount === 0 && r.status !== 'maintenance',
|
||||
).length;
|
||||
const availableBeds = rooms.reduce(
|
||||
(sum: number, r: any) =>
|
||||
r.status !== 'maintenance' ? sum + (r.capacity - r.currentCount) : sum,
|
||||
0,
|
||||
);
|
||||
const totalBeds = rooms.reduce((sum: number, r: any) => sum + (r.totalBeds || 0), 0);
|
||||
const occupiedBeds = rooms.reduce((sum: number, r: any) => sum + (r.occupiedBeds || 0), 0);
|
||||
const availableBedsCount = totalBeds - occupiedBeds;
|
||||
const fullRooms = rooms.filter((r: any) => r.currentCount >= r.capacity).length;
|
||||
|
||||
/* getCardStyle, getStatusLabel, getTenantTags are now standalone functions outside the component */
|
||||
@@ -180,7 +178,7 @@ const RoomVisualPage: React.FC = () => {
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small">
|
||||
<Statistic title="可安排床位" value={availableBeds} styles={{ value: { color: '#007AFF' } }} />
|
||||
<Statistic title="可安排床位" value={availableBedsCount} styles={{ value: { color: '#007AFF' } }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
@@ -230,6 +228,11 @@ const RoomVisualPage: React.FC = () => {
|
||||
{room.building && <span>{room.building} </span>}
|
||||
{room.floor && <span>{room.floor}F</span>}
|
||||
</div>
|
||||
{room.totalBeds > 0 && (
|
||||
<div style={{ fontSize: 12, color: room.occupiedBeds >= room.totalBeds ? '#FF3B30' : '#34C759', marginBottom: 6 }}>
|
||||
床位: {room.occupiedBeds}/{room.totalBeds}
|
||||
</div>
|
||||
)}
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 4, marginBottom: 8 }}>
|
||||
<Badge
|
||||
count={`${room.currentCount}/${room.capacity}`}
|
||||
|
||||
Reference in New Issue
Block a user