Skip to content

Commit 9771ed8

Browse files
committed
feat: 优化查询部门成员方法
1 parent afa0f3b commit 9771ed8

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

src/pages/User/List/index.tsx

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,30 @@
1-
import React, { useRef } from 'react';
1+
import React, { useRef, useState } from 'react';
22
import CreateUserModal from '@/pages/User/components/CreateUserModal';
33
import { ListUserOptions, listUsers } from '@/services/user/listUsers';
44
import { deleteUser } from '@/services/user/deleteUser';
55
import { DeleteOutlined, EllipsisOutlined } from '@ant-design/icons';
66
import type { ActionType, ProColumns } from '@ant-design/pro-components';
77
import { ProTable } from '@ant-design/pro-components';
88
import { FormattedMessage, history, useIntl, useRequest } from '@umijs/max';
9-
import { App, Button, Card, Dropdown, message, Skeleton } from 'antd';
9+
import {
10+
App,
11+
Button,
12+
Card,
13+
Checkbox,
14+
Divider,
15+
Dropdown,
16+
message,
17+
Skeleton,
18+
Space,
19+
Typography,
20+
} from 'antd';
1021
import { BASIC_INTL } from '@/constant';
1122
import { transformSearchParams } from '@/utils';
1223

1324
import useStyle from './style';
1425

26+
const { Text } = Typography;
27+
1528
export type Props = {
1629
organization?: { id: string; name: string };
1730
};
@@ -32,6 +45,9 @@ const INTL = {
3245
LAST_LOGIN_TIME: {
3346
id: 'users.table.lastLoginTime',
3447
},
48+
ONLY_DIRECT_MEMBERS: {
49+
id: 'users.table.onlyDirectMembers',
50+
},
3551
};
3652

3753
const UserList: React.FC<Props> = (props) => {
@@ -43,6 +59,8 @@ const UserList: React.FC<Props> = (props) => {
4359
const { modal } = App.useApp();
4460
const intl = useIntl();
4561

62+
const [onlyDirectMembers, setOnlyDirectMembers] = useState(false);
63+
4664
const reloadTable = () => {
4765
if (actionRef.current) {
4866
actionRef.current.reload();
@@ -184,7 +202,7 @@ const UserList: React.FC<Props> = (props) => {
184202
) : (
185203
<ProTable<API.UserInfo, ListUserOptions>
186204
size="small"
187-
params={{ departmentId: organization.id }}
205+
params={{ departmentId: organization.id, includeChildrenDepartments: !onlyDirectMembers }}
188206
className={styles}
189207
headerTitle={organization.name}
190208
style={{
@@ -204,6 +222,17 @@ const UserList: React.FC<Props> = (props) => {
204222
pageSizeOptions: [10, 20, 30, 50],
205223
}}
206224
toolBarRender={() => [
225+
<Space key={'checkbox'} style={{ alignItems: 'flex-start' }}>
226+
<Checkbox
227+
checked={onlyDirectMembers}
228+
onChange={({ target: { checked } }) => {
229+
setOnlyDirectMembers(checked);
230+
actionRef.current?.reload();
231+
}}
232+
/>
233+
<Text ellipsis>{intl.formatMessage(INTL.ONLY_DIRECT_MEMBERS)}</Text>
234+
</Space>,
235+
<Divider key="divider" type="vertical" />,
207236
<CreateUserModal
208237
key="create"
209238
organization={organization}

src/pages/User/locales/zh-CN.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
export default {
22
'users.page.content': '管理组织中的用户,可以直接在 IAM 中进行维护,也可以同步外部身份源。',
3+
'users.table.onlyDirectMembers': '只展示部门直属成员',
34
'users.table.title': '用户列表',
45
'users.table.add': '新增',
56
'users.table.edit': '编辑',

src/services/user/listUsers.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { request } from '@@/exports';
22

33
export type ListUserOptions = {
4+
includeChildrenDepartments?: boolean;
45
departmentId?: string;
56
} & API.ListOptions;
67

0 commit comments

Comments
 (0)