@@ -8,41 +8,134 @@ import {
88 Td ,
99 Th ,
1010 Thead ,
11- Tr
11+ Tr ,
12+ HStack
1213} from '@chakra-ui/react' ;
13- import { useState } from 'react' ;
14+ import { useState , useEffect , useMemo } from 'react' ;
1415import { useTranslation } from 'next-i18next' ;
1516import MyBox from '@fastgpt/web/components/common/MyBox' ;
16- import SearchInput from '@fastgpt/web/components/common/Input/SearchInput' ;
1717import { useScrollPagination } from '@fastgpt/web/hooks/useScrollPagination' ;
1818import { getOperationLogs } from '@/web/support/user/team/operantionLog/api' ;
1919import { TeamPermission } from '@fastgpt/global/support/permission/user/controller' ;
2020import { operationLogI18nMap } from '@fastgpt/service/support/operationLog/constants' ;
2121import { OperationLogEventEnum } from '@fastgpt/global/support/operationLog/constants' ;
2222import { formatTime2YMDHMS } from '@fastgpt/global/common/string/time' ;
2323import UserBox from '@fastgpt/web/components/common/UserBox' ;
24+ import MultipleSelect , {
25+ useMultipleSelect
26+ } from '@fastgpt/web/components/common/MySelect/MultipleSelect' ;
27+ import Avatar from '@fastgpt/web/components/common/Avatar' ;
28+ import { getTeamMembers } from '@/web/support/user/team/api' ;
2429
2530function OperationLogTable ( { Tabs } : { Tabs : React . ReactNode } ) {
2631 const { t } = useTranslation ( ) ;
32+ const [ searchParams , setSearchParams ] = useState < {
33+ tmbIds ?: string [ ] ;
34+ events ?: OperationLogEventEnum [ ] ;
35+ } > ( { } ) ;
36+
37+ const {
38+ value : selectedTmbIds ,
39+ setValue : setSelectedTmbIds ,
40+ isSelectAll : isSelectAllTmb ,
41+ setIsSelectAll : setIsSelectAllTmb
42+ } = useMultipleSelect < string > ( ) ;
43+
44+ const {
45+ value : selectedEvents ,
46+ setValue : setSelectedEvents ,
47+ isSelectAll : isSelectAllEvent ,
48+ setIsSelectAll : setIsSelectAllEvent
49+ } = useMultipleSelect < OperationLogEventEnum > ( ) ;
50+
51+ const { data : members , ScrollData } = useScrollPagination ( getTeamMembers , { } ) ;
52+ const tmbList = useMemo (
53+ ( ) =>
54+ members . map ( ( item ) => ( {
55+ label : (
56+ < HStack spacing = { 1 } color = { 'myGray.500' } >
57+ < Avatar src = { item . avatar } w = { '1.2rem' } mr = { 1 } rounded = { 'full' } />
58+ < Box > { item . memberName } </ Box >
59+ </ HStack >
60+ ) ,
61+ value : item . tmbId
62+ } ) ) ,
63+ [ members ]
64+ ) ;
65+
66+ const eventOptions = useMemo (
67+ ( ) =>
68+ Object . values ( OperationLogEventEnum ) . map ( ( event ) => ( {
69+ label : t ( operationLogI18nMap [ event ] . typeLabel ) ,
70+ value : event
71+ } ) ) ,
72+ [ t ]
73+ ) ;
2774
28- const [ searchKey , setSearchKey ] = useState < string > ( '' ) ;
2975 const {
3076 data : operationLogs = [ ] ,
3177 isLoading : loadingLogs ,
3278 ScrollData : LogScrollData
3379 } = useScrollPagination ( getOperationLogs , {
3480 pageSize : 20 ,
35- refreshDeps : [ searchKey ] ,
3681 throttleWait : 500 ,
37- debounceWait : 200
82+ debounceWait : 200 ,
83+ refreshDeps : [ searchParams ] ,
84+ params : searchParams
3885 } ) ;
3986
87+ useEffect ( ( ) => {
88+ setSearchParams ( {
89+ tmbIds : selectedTmbIds . length > 0 && ! isSelectAllTmb ? selectedTmbIds : undefined ,
90+ events : selectedEvents . length > 0 && ! isSelectAllEvent ? selectedEvents : undefined
91+ } ) ;
92+ } , [ selectedTmbIds , selectedEvents , isSelectAllTmb , isSelectAllEvent ] ) ;
93+
4094 const isLoading = loadingLogs ;
4195
4296 return (
4397 < >
44- < Flex justify = { 'space-between ' } align = { 'center' } pb = { '1rem' } >
98+ < Flex justify = { 'flex-start ' } align = { 'center' } pb = { '1rem' } gap = { 2 } wrap = "wrap" >
4599 { Tabs }
100+ < Flex alignItems = { 'center' } gap = { 2 } >
101+ < Box fontSize = { 'mini' } fontWeight = { 'medium' } color = { 'myGray.900' } >
102+ { t ( 'account_team:log_user' ) }
103+ </ Box >
104+ < Box >
105+ < MultipleSelect < string >
106+ list = { tmbList }
107+ value = { selectedTmbIds }
108+ onSelect = { ( val ) => {
109+ setSelectedTmbIds ( val as string [ ] ) ;
110+ } }
111+ itemWrap = { false }
112+ height = { '32px' }
113+ bg = { 'myGray.50' }
114+ w = { '160px' }
115+ ScrollData = { ScrollData }
116+ isSelectAll = { isSelectAllTmb }
117+ setIsSelectAll = { setIsSelectAllTmb }
118+ />
119+ </ Box >
120+ </ Flex >
121+ < Flex alignItems = { 'center' } gap = { 2 } >
122+ < Box fontSize = { 'mini' } fontWeight = { 'medium' } color = { 'myGray.900' } >
123+ { t ( 'account_team:log_type' ) }
124+ </ Box >
125+ < Box >
126+ < MultipleSelect
127+ list = { eventOptions }
128+ value = { selectedEvents }
129+ onSelect = { setSelectedEvents }
130+ isSelectAll = { isSelectAllEvent }
131+ setIsSelectAll = { setIsSelectAllEvent }
132+ itemWrap = { false }
133+ height = { '32px' }
134+ bg = { 'myGray.50' }
135+ w = { '160px' }
136+ />
137+ </ Box >
138+ </ Flex >
46139 </ Flex >
47140
48141 < MyBox isLoading = { isLoading } flex = { '1 0 0' } overflow = { 'auto' } >
0 commit comments