import { Suspense, lazy } from 'react'; import { enableStatusRecord, userGenderRecord } from '@/constants/business'; import { ATG_MAP } from '@/constants/common'; import { TableHeaderOperation, useTable, useTableOperate, useTableScroll } from '@/features/table'; import { fetchGetUserList } from '@/service/api'; import UserSearch from './modules/UserSearch'; const UserOperateDrawer = lazy(() => import('./modules/UserOperateDrawer')); const tagUserGenderMap: Record = { 1: 'processing', 2: 'error' }; const UserManage = () => { const { t } = useTranslation(); const { scrollConfig, tableWrapperRef } = useTableScroll(); const nav = useNavigate(); const isMobile = useMobile(); const { columnChecks, data, run, searchProps, setColumnChecks, tableProps } = useTable( { apiFn: fetchGetUserList, apiParams: { current: 1, nickName: null, size: 10, // if you want to use the searchParams in Form, you need to define the following properties, and the value is null // the value can not be undefined, otherwise the property in Form will not be reactive status: null, userEmail: null, userGender: null, userName: null, userPhone: null }, columns: () => [ { align: 'center', dataIndex: 'index', key: 'index', title: t('common.index'), width: 64 }, { align: 'center', dataIndex: 'userName', key: 'userName', minWidth: 100, title: t('page.manage.user.userName') }, { align: 'center', dataIndex: 'userGender', key: 'userGender', render: (_, record) => { if (record?.userGender === null) { return null; } const label = t(userGenderRecord[record.userGender]); return {label}; }, title: t('page.manage.user.userGender'), width: 100 }, { align: 'center', dataIndex: 'nickName', key: 'nickName', minWidth: 100, title: t('page.manage.user.nickName') }, { align: 'center', dataIndex: 'userPhone', key: 'userPhone', title: t('page.manage.user.userPhone'), width: 120 }, { align: 'center', dataIndex: 'userEmail', key: 'userEmail', minWidth: 200, title: t('page.manage.user.userEmail') }, { align: 'center', dataIndex: 'status', key: 'status', render: (_, record) => { if (record.status === null) { return null; } const label = t(enableStatusRecord[record.status]); return {label}; }, title: t('page.manage.user.userStatus'), width: 100 }, { align: 'center', key: 'operate', render: (_, record) => (
edit(record.id)} > {t('common.edit')} nav(`/manage/user/${record.id}`)} > 详情 handleDelete(record.id)} > {t('common.delete')}
), title: t('common.operate'), width: 195 } ] }, { showQuickJumper: true } ); const { checkedRowKeys, generalPopupOperation, handleAdd, handleEdit, onBatchDeleted, onDeleted, rowSelection } = useTableOperate(data, run, async (res, type) => { if (type === 'add') { // add request 调用新增的接口 console.log(res); } else { // edit request 调用编辑的接口 console.log(res); } }); async function handleBatchDelete() { // request console.log(checkedRowKeys); onBatchDeleted(); } function handleDelete(id: number) { // request console.log(id); onDeleted(); } function edit(id: number) { handleEdit(id); } return (
, key: '1', label: t('common.search') } ]} /> } >
); }; export default UserManage;