Files
web-Iot/src/pages/Users.tsx

98 lines
2.5 KiB
TypeScript
Raw Normal View History

2026-04-17 17:20:41 +08:00
import React from 'react';
import {
Table,
Tag,
Space,
Button,
Input,
Typography,
Card,
Avatar
} from 'antd';
import {
PlusOutlined,
SearchOutlined,
EditOutlined,
DeleteOutlined,
UserOutlined
} from '@ant-design/icons';
import { MANAGED_USERS } from '../constants';
const { Text, Title } = Typography;
export default function Users() {
const columns = [
{
title: '用户信息',
key: 'userinfo',
render: (record: any) => (
<Space size="middle">
<Avatar src={record.avatar} icon={<UserOutlined />} />
<Space direction="vertical" size={0}>
<Text strong>{record.name}</Text>
<Text type="secondary" style={{ fontSize: 12 }}>{record.id}</Text>
</Space>
</Space>
),
},
{
title: '系统权限',
dataIndex: 'role',
key: 'role',
render: (role: string) => (
<Tag color={role === 'admin' ? 'blue' : 'gray'} style={{ borderRadius: 2, fontWeight: 'bold', textTransform: 'uppercase' }}>
{role}
</Tag>
),
},
{
title: '账户状态',
key: 'status',
render: () => <Tag color="success">ACTIVE</Tag>,
},
{
title: '最近登录',
key: 'lastLogin',
render: () => <Text type="secondary" style={{ fontSize: 12, fontFamily: 'monospace' }}>2024-03-24 10:22:45</Text>,
},
{
title: '操作',
key: 'action',
align: 'right' as const,
render: () => (
<Space>
<Button icon={<EditOutlined />} size="small" type="link">编辑</Button>
<Button icon={<DeleteOutlined />} size="small" type="link" danger>删除</Button>
</Space>
),
},
];
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<Title level={5} style={{ margin: 0 }}>用户管理权限控制</Title>
<Space>
<Input
prefix={<SearchOutlined style={{ color: 'rgba(0,0,0,0.25)' }} />}
placeholder="搜索用户名或工号..."
style={{ width: 250, borderRadius: 2 }}
/>
<Button type="primary" icon={<PlusOutlined />} style={{ borderRadius: 2 }}>
新增人员
</Button>
</Space>
</div>
<Card styles={{ body: { padding: 0 } }} className="overflow-hidden">
<Table
size="small"
columns={columns}
dataSource={MANAGED_USERS.map(u => ({ ...u, key: u.id }))}
pagination={false}
/>
</Card>
</div>
);
}