feat: integrate classroom real-time occupancy with schedule and rental data

This commit is contained in:
2026-07-06 01:14:58 +08:00
parent 3bcb7d41c0
commit 8453e62088
2 changed files with 92 additions and 5 deletions

View File

@@ -12,6 +12,7 @@ import {
Tag,
Popconfirm,
Upload,
Tooltip,
} from 'antd';
import {
PlusOutlined,
@@ -25,9 +26,18 @@ import PermissionButton from '../../components/PermissionButton';
const statusMap: Record<string, { text: string; color: string }> = {
available: { text: '可用', color: 'green' },
in_use: { text: '使用中', color: 'blue' },
maintenance: { text: '维护中', color: 'orange' },
archived: { text: '已归档', color: '#999' },
};
interface CurrentUsage {
type: 'schedule' | 'rental';
title: string;
startTime: string;
endTime: string;
}
const typeColor: Record<string, string> = {
: 'volcano',
: 'geekblue',
@@ -142,7 +152,14 @@ const ClassroomsPage: React.FC = () => {
{
title: '状态',
dataIndex: 'status',
render: (s: string) => <Tag color={statusMap[s]?.color}>{statusMap[s]?.text || s}</Tag>,
render: (s: string, record: { currentUsage?: CurrentUsage | null }) => {
const effectiveStatus = record.currentUsage ? 'in_use' : s;
return (
<Tooltip title={record.currentUsage ? `${record.currentUsage.title} (${record.currentUsage.startTime}-${record.currentUsage.endTime})` : undefined}>
<Tag color={statusMap[effectiveStatus]?.color}>{statusMap[effectiveStatus]?.text || s}</Tag>
</Tooltip>
);
},
},
{
title: '操作',