feat: integrate classroom real-time occupancy with schedule and rental data
This commit is contained in:
@@ -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: '操作',
|
||||
|
||||
Reference in New Issue
Block a user