diff --git a/ui/src/api/types.ts b/ui/src/api/types.ts index 0a4e9c4..9b40a6a 100644 --- a/ui/src/api/types.ts +++ b/ui/src/api/types.ts @@ -767,6 +767,8 @@ export interface GetListChatRecordParams { page?: number; /** 每页多少条记录 */ size?: number; + /** 工作模式 */ + work_mode?: string; } export interface GetCompletionInfoParams { @@ -787,6 +789,8 @@ export interface GetListCompletionRecordParams { page?: number; /** 每页多少条记录 */ size?: number; + /** 工作模式 */ + work_mode?: string; } export interface GetCategoryStatDashboardParams { diff --git a/ui/src/pages/chat/index.tsx b/ui/src/pages/chat/index.tsx index d1759f1..d54b46f 100644 --- a/ui/src/pages/chat/index.tsx +++ b/ui/src/pages/chat/index.tsx @@ -4,7 +4,7 @@ import { getListChatRecord } from '@/api/Billing'; import dayjs from 'dayjs'; import Card from '@/components/card'; -import { Box } from '@mui/material'; +import { Autocomplete, Box, FormControl, InputLabel, MenuItem, Select, Stack, TextField } from '@mui/material'; import StyledLabel from '@/components/label'; import ChatDetailModal from './chatDetailModal'; @@ -12,6 +12,9 @@ import { ColumnsType } from '@c-x/ui/dist/Table'; import { DomainChatRecord, DomainUser } from '@/api/types'; import { addCommasToNumber } from '@/utils'; import User from '@/components/user'; +import { useRequest } from 'ahooks'; +import { getListUser } from '@/api/User'; +import { set } from 'react-hook-form'; const Chat = () => { const [page, setPage] = useState(1); @@ -22,11 +25,25 @@ const Chat = () => { const [chatDetailModal, setChatDetailModal] = useState< DomainChatRecord | undefined >(); + const [filterUser, setFilterUser] = useState(''); + const [filterMode, setfilterMode] = useState< + 'code' | 'architect' | 'ask' | 'debug' | 'orchestrator' + >(); + + const { data: userOptions = { users: [] } } = useRequest(() => + getListUser({ + page: 1, + size: 9999, + }) + ); + const fetchData = async () => { setLoading(true); const res = await getListChatRecord({ page: page, size: size, + work_mode: filterMode, + author: filterUser, }); setLoading(false); setTotal(res?.total_count || 0); @@ -34,9 +51,10 @@ const Chat = () => { }; useEffect(() => { + setPage(1); fetchData(); // eslint-disable-next-line - }, [page, size]); + }, [page, size, filterMode, filterUser]); const columns: ColumnsType = [ { @@ -137,6 +155,43 @@ const Chat = () => { ]; return ( + + option.username || ''} + value={ + userOptions.users?.find((item) => item.username === filterUser) || + null + } + onChange={(_, newValue) => + setFilterUser(newValue ? newValue.username! : '') + } + isOptionEqualToValue={(option, value) => + option.username === value.username + } + renderInput={(params) => } + clearOnEscape + /> + + 工作模式 + + + { }; useEffect(() => { + setPage(1); // 筛选变化时重置页码 fetchData(); // eslint-disable-next-line }, [page, size]);