diff --git a/src/pages/user-management/constants.tsx b/src/pages/user-management/constants.tsx new file mode 100644 index 0000000..fb76b31 --- /dev/null +++ b/src/pages/user-management/constants.tsx @@ -0,0 +1,117 @@ +import React from 'react'; +import { Button, Typography, Badge, Space } from '@arco-design/web-react'; +import { IconEye, IconEdit, IconDelete } from '@arco-design/web-react/icon'; +import dayjs from 'dayjs'; + +const { Text } = Typography; + +export const RoleType = ['管理员', '普通用户', '访客']; +export const Status = ['禁用', '启用']; + +export function getColumns( + t: any, + callback: (record: Record, type: string) => Promise +) { + return [ + { + title: t['userManagement.columns.id'], + dataIndex: 'id', + width: 100, + render: (value) => {value}, + }, + { + title: t['userManagement.columns.name'], + dataIndex: 'name', + width: 100, + }, + { + title: t['userManagement.columns.username'], + dataIndex: 'username', + width: 120, + }, + { + title: t['userManagement.columns.email'], + dataIndex: 'email', + width: 200, + }, + { + title: t['userManagement.columns.phone'], + dataIndex: 'phone', + width: 130, + }, + { + title: t['userManagement.columns.role'], + dataIndex: 'role', + width: 100, + render: (value) => { + const roleMap = { + 0: { text: t['userManagement.role.admin'], color: 'red' }, + 1: { text: t['userManagement.role.user'], color: 'blue' }, + 2: { text: t['userManagement.role.guest'], color: 'gray' }, + }; + const role = roleMap[value] || roleMap[1]; + return ; + }, + }, + { + title: t['userManagement.columns.department'], + dataIndex: 'department', + width: 120, + }, + { + title: t['userManagement.columns.createdTime'], + dataIndex: 'createdTime', + width: 180, + render: (x) => dayjs().subtract(x, 'days').format('YYYY-MM-DD HH:mm:ss'), + sorter: (a, b) => b.createdTime - a.createdTime, + }, + { + title: t['userManagement.columns.status'], + dataIndex: 'status', + width: 100, + render: (x) => { + if (x === 0) { + return ; + } + return ; + }, + }, + { + title: t['userManagement.columns.operations'], + dataIndex: 'operations', + width: 240, + fixed: 'right' as const, + render: (_, record) => ( + + + + + + ), + }, + ]; +} + +export default () => RoleType; diff --git a/src/pages/user-management/form.tsx b/src/pages/user-management/form.tsx new file mode 100644 index 0000000..cfb5fc7 --- /dev/null +++ b/src/pages/user-management/form.tsx @@ -0,0 +1,160 @@ +import React, { useContext } from 'react'; +import dayjs from 'dayjs'; +import { + Form, + Input, + Select, + DatePicker, + Button, + Grid, +} from '@arco-design/web-react'; +import { GlobalContext } from '@/context'; +import locale from './locale'; +import useLocale from '@/utils/useLocale'; +import { IconRefresh, IconSearch } from '@arco-design/web-react/icon'; +import { RoleType, Status } from './constants'; +import styles from './style/index.module.less'; + +const { Row, Col } = Grid; +const { useForm } = Form; + +function SearchForm(props: { + onSearch: (values: Record) => void; +}) { + const { lang } = useContext(GlobalContext); + + const t = useLocale(locale); + const [form] = useForm(); + + const handleSubmit = () => { + const values = form.getFieldsValue(); + props.onSearch(values); + }; + + const handleReset = () => { + form.resetFields(); + props.onSearch({}); + }; + + const colSpan = lang === 'zh-CN' ? 8 : 12; + + return ( +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +