@@ -4,7 +4,14 @@ import { getUserListChatRecord } from '@/api/UserRecord';
44import dayjs from 'dayjs' ;
55
66import Card from '@/components/card' ;
7- import { Box } from '@mui/material' ;
7+ import {
8+ Box ,
9+ FormControl ,
10+ InputLabel ,
11+ MenuItem ,
12+ Select ,
13+ Stack ,
14+ } from '@mui/material' ;
815import StyledLabel from '@/components/label' ;
916
1017import ChatDetailModal from './chatDetailModal' ;
@@ -19,14 +26,24 @@ const Chat = () => {
1926 const [ total , setTotal ] = useState ( 0 ) ;
2027 const [ loading , setLoading ] = useState ( false ) ;
2128 const [ dataSource , setDataSource ] = useState < DomainChatRecord [ ] > ( [ ] ) ;
29+ const [ filterMode , setfilterMode ] = useState <
30+ 'code' | 'architect' | 'ask' | 'debug' | 'orchestrator'
31+ > ( ) ;
2232 const [ chatDetailModal , setChatDetailModal ] = useState <
2333 DomainChatRecord | undefined
2434 > ( ) ;
25- const fetchData = async ( ) => {
35+
36+ const fetchData = async ( params : {
37+ page ?: number ;
38+ size ?: number ;
39+ work_mode ?: string ;
40+ author ?: string ;
41+ } ) => {
2642 setLoading ( true ) ;
2743 const res = await getUserListChatRecord ( {
28- page : page ,
29- size : size ,
44+ page : params . page || page ,
45+ size : params . size || size ,
46+ work_mode : params . work_mode || filterMode ,
3047 } ) ;
3148 setLoading ( false ) ;
3249 setTotal ( res ?. total_count || 0 ) ;
@@ -35,9 +52,11 @@ const Chat = () => {
3552
3653 useEffect ( ( ) => {
3754 setPage ( 1 ) ; // 筛选变化时重置页码
38- fetchData ( ) ;
39- // eslint-disable-next-line
40- } , [ page , size ] ) ;
55+ fetchData ( {
56+ page : 1 ,
57+ work_mode : filterMode ,
58+ } ) ;
59+ } , [ filterMode ] ) ;
4160
4261 const columns : ColumnsType < DomainChatRecord > = [
4362 {
@@ -138,8 +157,34 @@ const Chat = () => {
138157 ] ;
139158 return (
140159 < Card sx = { { flex : 1 , height : '100%' } } >
160+ < Stack direction = 'row' spacing = { 2 } sx = { { mb : 2 } } >
161+ < FormControl size = 'small' sx = { { minWidth : 180 } } >
162+ < InputLabel > 工作模式</ InputLabel >
163+ < Select
164+ label = '工作模式'
165+ value = { filterMode }
166+ onChange = { ( e ) =>
167+ setfilterMode (
168+ e . target . value as
169+ | 'code'
170+ | 'ask'
171+ | 'architect'
172+ | 'debug'
173+ | 'orchestrator'
174+ )
175+ }
176+ >
177+ < MenuItem value = '' > 全部</ MenuItem >
178+ < MenuItem value = 'code' > 编程模式</ MenuItem >
179+ < MenuItem value = 'ask' > 问答模式</ MenuItem >
180+ < MenuItem value = 'architect' > 架构模式</ MenuItem >
181+ < MenuItem value = 'debug' > 调试模式</ MenuItem >
182+ < MenuItem value = 'orchestrator' > 编排模式</ MenuItem >
183+ </ Select >
184+ </ FormControl >
185+ </ Stack >
141186 < Table
142- height = '100%'
187+ height = 'calc( 100% - 52px) '
143188 sx = { { mx : - 2 } }
144189 PaginationProps = { {
145190 sx : {
@@ -158,6 +203,10 @@ const Chat = () => {
158203 onChange : ( page : number , size : number ) => {
159204 setPage ( page ) ;
160205 setSize ( size ) ;
206+ fetchData ( {
207+ page : page ,
208+ size : size ,
209+ } ) ;
161210 } ,
162211 } }
163212 />
0 commit comments