chore: commit oxfmt formatting changes and verify artifacts
This commit is contained in:
@@ -14,27 +14,40 @@ const RoomVisualPage: React.FC = () => {
|
||||
try {
|
||||
const res: any = await api.get('/rooms/visual');
|
||||
setData(res);
|
||||
} catch (e) { console.error(e); }
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
useEffect(() => { fetchData(); }, []);
|
||||
useEffect(() => {
|
||||
fetchData();
|
||||
}, []);
|
||||
|
||||
if (loading || !data) return <Spin size="large" style={{ display: 'block', margin: '100px auto' }} />;
|
||||
if (loading || !data)
|
||||
return <Spin size="large" style={{ display: 'block', margin: '100px auto' }} />;
|
||||
|
||||
const rooms = selectedBuilding === 'all'
|
||||
? data.rooms
|
||||
: data.rooms.filter((r: any) => r.building === selectedBuilding);
|
||||
const rooms =
|
||||
selectedBuilding === 'all'
|
||||
? data.rooms
|
||||
: data.rooms.filter((r: any) => r.building === selectedBuilding);
|
||||
|
||||
const totalRooms = rooms.length;
|
||||
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 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 fullRooms = rooms.filter((r: any) => r.currentCount >= r.capacity).length;
|
||||
|
||||
const getCardStyle = (room: any): React.CSSProperties => {
|
||||
if (room.status === 'maintenance') return { background: '#f5f5f5', borderColor: '#d9d9d9' };
|
||||
if (room.currentCount === 0) return { background: '#f6ffed', borderColor: '#b7eb8f' };
|
||||
if (room.currentCount >= room.capacity) return { background: '#fff2f0', borderColor: '#ffccc7' };
|
||||
if (room.currentCount >= room.capacity)
|
||||
return { background: '#fff2f0', borderColor: '#ffccc7' };
|
||||
return { background: '#e6f4ff', borderColor: '#91caff' };
|
||||
};
|
||||
|
||||
@@ -47,7 +60,16 @@ const RoomVisualPage: React.FC = () => {
|
||||
|
||||
return (
|
||||
<div>
|
||||
<div style={{ marginBottom: 16, display: 'flex', justifyContent: 'space-between', alignItems: 'center', flexWrap: 'wrap', gap: 12 }}>
|
||||
<div
|
||||
style={{
|
||||
marginBottom: 16,
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
flexWrap: 'wrap',
|
||||
gap: 12,
|
||||
}}
|
||||
>
|
||||
<h2 style={{ margin: 0 }}>宿舍总览</h2>
|
||||
<Select
|
||||
value={selectedBuilding}
|
||||
@@ -63,16 +85,24 @@ const RoomVisualPage: React.FC = () => {
|
||||
{/* 统计栏 */}
|
||||
<Row gutter={[12, 12]} style={{ marginBottom: 20 }}>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small"><Statistic title="宿舍总数" value={totalRooms} prefix={<HomeOutlined />} /></Card>
|
||||
<Card size="small">
|
||||
<Statistic title="宿舍总数" value={totalRooms} prefix={<HomeOutlined />} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small"><Statistic title="空闲房间" value={emptyRooms} valueStyle={{ color: '#34C759' }} /></Card>
|
||||
<Card size="small">
|
||||
<Statistic title="空闲房间" value={emptyRooms} valueStyle={{ color: '#34C759' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small"><Statistic title="可安排床位" value={availableBeds} valueStyle={{ color: '#007AFF' }} /></Card>
|
||||
<Card size="small">
|
||||
<Statistic title="可安排床位" value={availableBeds} valueStyle={{ color: '#007AFF' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col xs={12} sm={6}>
|
||||
<Card size="small"><Statistic title="满员房间" value={fullRooms} valueStyle={{ color: '#FF3B30' }} /></Card>
|
||||
<Card size="small">
|
||||
<Statistic title="满员房间" value={fullRooms} valueStyle={{ color: '#FF3B30' }} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
@@ -83,11 +113,26 @@ const RoomVisualPage: React.FC = () => {
|
||||
<Card
|
||||
size="small"
|
||||
hoverable
|
||||
style={{ ...getCardStyle(room), borderRadius: 12, borderWidth: 2, cursor: 'pointer', height: '100%' }}
|
||||
style={{
|
||||
...getCardStyle(room),
|
||||
borderRadius: 12,
|
||||
borderWidth: 2,
|
||||
cursor: 'pointer',
|
||||
height: '100%',
|
||||
}}
|
||||
onClick={() => setDetailRoom(room)}
|
||||
>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 8 }}>
|
||||
<span style={{ fontSize: 16, fontWeight: 600, color: '#1d1d1f' }}>{room.roomNumber}</span>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
marginBottom: 8,
|
||||
}}
|
||||
>
|
||||
<span style={{ fontSize: 16, fontWeight: 600, color: '#1d1d1f' }}>
|
||||
{room.roomNumber}
|
||||
</span>
|
||||
{getStatusLabel(room)}
|
||||
</div>
|
||||
<div style={{ color: '#86868b', fontSize: 12, marginBottom: 6 }}>
|
||||
@@ -99,14 +144,21 @@ const RoomVisualPage: React.FC = () => {
|
||||
count={`${room.currentCount}/${room.capacity}`}
|
||||
showZero
|
||||
style={{
|
||||
backgroundColor: room.currentCount >= room.capacity ? '#FF3B30' : room.currentCount > 0 ? '#007AFF' : '#34C759',
|
||||
backgroundColor:
|
||||
room.currentCount >= room.capacity
|
||||
? '#FF3B30'
|
||||
: room.currentCount > 0
|
||||
? '#007AFF'
|
||||
: '#34C759',
|
||||
fontSize: 11,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
{room.orgLabel && (
|
||||
<div style={{ marginBottom: 6 }}>
|
||||
<Tag color="purple" style={{ fontSize: 11 }} icon={<BankOutlined />}>{room.orgLabel}</Tag>
|
||||
<Tag color="purple" style={{ fontSize: 11 }} icon={<BankOutlined />}>
|
||||
{room.orgLabel}
|
||||
</Tag>
|
||||
</div>
|
||||
)}
|
||||
{room.occupants.length > 0 && (
|
||||
@@ -137,9 +189,18 @@ const RoomVisualPage: React.FC = () => {
|
||||
{detailRoom && (
|
||||
<div>
|
||||
<Row gutter={16} style={{ marginBottom: 16 }}>
|
||||
<Col span={8}><Statistic title="额定人数" value={detailRoom.capacity} /></Col>
|
||||
<Col span={8}><Statistic title="当前入住" value={detailRoom.currentCount} /></Col>
|
||||
<Col span={8}><Statistic title="剩余床位" value={Math.max(0, detailRoom.capacity - detailRoom.currentCount)} /></Col>
|
||||
<Col span={8}>
|
||||
<Statistic title="额定人数" value={detailRoom.capacity} />
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Statistic title="当前入住" value={detailRoom.currentCount} />
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Statistic
|
||||
title="剩余床位"
|
||||
value={Math.max(0, detailRoom.capacity - detailRoom.currentCount)}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
<div style={{ marginBottom: 8, fontWeight: 500 }}>
|
||||
位置:{detailRoom.building || '-'} {detailRoom.floor ? `${detailRoom.floor}F` : ''}
|
||||
@@ -150,24 +211,38 @@ const RoomVisualPage: React.FC = () => {
|
||||
<h4 style={{ marginBottom: 8 }}>当前住户</h4>
|
||||
{detailRoom.occupants.map((o: any) => (
|
||||
<Card key={o.studentId} size="small" style={{ marginBottom: 8, borderRadius: 8 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<UserOutlined style={{ marginRight: 6 }} />
|
||||
<strong>{o.studentName}</strong>
|
||||
{o.organization && <Tag color="purple" style={{ marginLeft: 6, fontSize: 11 }}>{o.organization}</Tag>}
|
||||
{o.organization && (
|
||||
<Tag color="purple" style={{ marginLeft: 6, fontSize: 11 }}>
|
||||
{o.organization}
|
||||
</Tag>
|
||||
)}
|
||||
</div>
|
||||
<Tag color="blue">{o.days} 天</Tag>
|
||||
</div>
|
||||
<div style={{ color: '#86868b', fontSize: 12, marginTop: 4 }}>
|
||||
<CalendarOutlined style={{ marginRight: 4 }} />
|
||||
入住:{o.checkInDate} | 计费起:{o.billingStartDate}
|
||||
{o.supervisor && <span style={{ marginLeft: 8 }}>负责人:{o.supervisor}</span>}
|
||||
{o.supervisor && (
|
||||
<span style={{ marginLeft: 8 }}>负责人:{o.supervisor}</span>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<div style={{ textAlign: 'center', padding: 24, color: '#86868b' }}>当前无住户,可安排入住</div>
|
||||
<div style={{ textAlign: 'center', padding: 24, color: '#86868b' }}>
|
||||
当前无住户,可安排入住
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user