1- import React , { useRef } from 'react' ;
1+ import React , { useRef , useState } from 'react' ;
22import CreateUserModal from '@/pages/User/components/CreateUserModal' ;
33import { ListUserOptions , listUsers } from '@/services/user/listUsers' ;
44import { deleteUser } from '@/services/user/deleteUser' ;
55import { DeleteOutlined , EllipsisOutlined } from '@ant-design/icons' ;
66import type { ActionType , ProColumns } from '@ant-design/pro-components' ;
77import { ProTable } from '@ant-design/pro-components' ;
88import { 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' ;
1021import { BASIC_INTL } from '@/constant' ;
1122import { transformSearchParams } from '@/utils' ;
1223
1324import useStyle from './style' ;
1425
26+ const { Text } = Typography ;
27+
1528export 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
3753const 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 }
0 commit comments