diff --git a/apps/admin/src/pages/Users/index.tsx b/apps/admin/src/pages/Users/index.tsx index 9f3d75a..3a0464d 100644 --- a/apps/admin/src/pages/Users/index.tsx +++ b/apps/admin/src/pages/Users/index.tsx @@ -10,9 +10,8 @@ import { Tag, Popconfirm, message, - TreeSelect, } from 'antd'; -import { PlusOutlined, EditOutlined, DeleteOutlined, KeyOutlined, IdcardOutlined, CloudDownloadOutlined, InboxOutlined } from '@ant-design/icons'; +import { PlusOutlined, EditOutlined, DeleteOutlined, KeyOutlined, IdcardOutlined, InboxOutlined } from '@ant-design/icons'; import dayjs from 'dayjs'; import api from '../../api'; import PermissionButton from '../../components/PermissionButton'; @@ -30,27 +29,9 @@ const UsersPage: React.FC = () => { const [profileForm] = Form.useForm(); const [form] = Form.useForm(); const [pwdForm] = Form.useForm(); - const [syncing, setSyncing] = useState(false); const [saving, setSaving] = useState(false); const [showArchived, setShowArchived] = useState(false); - // 组织树同步 - const [syncDeptId, setSyncDeptId] = useState(undefined); - const [orgTree, setOrgTree] = useState }>>([]); - const loadOrgTree = async () => { - try { - const res = await api.get<{ success: boolean; data: Array<{ id: number; name: string; children: Array<{ id: number; name: string; children: unknown[] }> }> }>('/sync/dingtalk/org-tree'); - const toTreeNode = (nodes: Array<{ id: number; name: string; children: unknown[] }>): Array<{ title: string; value: number; children?: unknown[] }> => - nodes.map((n) => ({ - title: n.name, - value: n.id, - children: n.children?.length > 0 ? toTreeNode(n.children as Array<{ id: number; name: string; children: unknown[] }>) : undefined, - })); - setOrgTree(toTreeNode(res.data)); - } catch { - // org tree may not be available - } - }; const handleOpenProfile = async (record: any) => { setProfileUser(record); @@ -93,24 +74,6 @@ const UsersPage: React.FC = () => { setLoading(false); }, [showArchived]); - const handleSyncDingTalk = async () => { - setSyncing(true); - try { - const params: Record = {}; - if (syncDeptId) params.rootDeptId = String(syncDeptId); - const res = await api.post('/sync/trigger?platform=dingtalk', undefined as unknown as null, { params }) as { - synced: number; logs: Array<{ recordsCount?: number }>; - }; - const log = res.logs?.[0]; - message.success(`同步完成:${log?.recordsCount || 0} 条记录`); - fetchData(); - } catch (e: unknown) { - const err = e as { message?: string }; - message.error(err?.message || '同步失败'); - } finally { - setSyncing(false); - } - }; useEffect(() => { fetchData(); @@ -184,16 +147,6 @@ const UsersPage: React.FC = () => { } }; - const handleMarkStaff = async (id: number, toStaff: boolean) => { - try { - await api.put(`/rbac/users/${id}/${toStaff ? 'mark-staff' : 'mark-student'}`); - message.success(toStaff ? '已标记为教职工' : '已恢复为学员'); - fetchData(); - } catch (e: unknown) { - const err = e as { message?: string }; - message.error(err?.message || '操作失败'); - } - }; const handleResetPwd = (record: any) => { setResetTarget(record); @@ -255,7 +208,7 @@ const UsersPage: React.FC = () => { }, { title: '操作', - width: 320, + width: 240, fixed: 'right' as const, render: (_: unknown, record: any) => ( @@ -295,16 +248,6 @@ const UsersPage: React.FC = () => { 归档 )} - {record.studentStatus === 'active' && ( - handleMarkStaff(record.id, true)}> - 标记教职工 - - )} - {record.studentStatus === 'staff' && ( - handleMarkStaff(record.id, false)}> - 恢复学员 - - )} {record.username !== 'admin' && ( handleDelete(record.id)}> }> @@ -330,16 +273,6 @@ const UsersPage: React.FC = () => { }}>

账号管理

- setSyncDeptId(v)} - placeholder="选择同步部门(不选=全部)" - allowClear - treeDefaultExpandAll - style={{ minWidth: 260 }} - onDropdownVisibleChange={(open) => { if (open) loadOrgTree(); }} - /> { > 新增账号 - } - loading={syncing} - onClick={handleSyncDingTalk} - > - 同步钉钉用户 - 归档