22 deleteAdminKbKbIdDocumentDocId ,
33 getAdminKbKbIdDocument ,
44 getAdminKbKbIdDocumentDocId ,
5+ ModelFileType ,
56 ModelKBDocumentDetail ,
67 SvcDocListItem ,
78} from '@/api' ;
@@ -10,7 +11,7 @@ import { fileType } from '@/components/ImportDoc/const';
1011import StatusBadge from '@/components/StatusBadge' ;
1112import { useListQueryParams } from '@/hooks/useListQueryParams' ;
1213import { Ellipsis , message , Modal , Table } from '@ctzhian/ui' ;
13- import { Box , Button , Stack , TextField , Typography } from '@mui/material' ;
14+ import { Box , Button , FormControl , InputLabel , MenuItem , Select , Stack , TextField , Typography } from '@mui/material' ;
1415import { useRequest } from 'ahooks' ;
1516import { ColumnsType } from '@ctzhian/ui/dist/Table' ;
1617import dayjs from 'dayjs' ;
@@ -31,11 +32,14 @@ const fetchMarkdownContent = async (url: string): Promise<string> => {
3132} ;
3233
3334const AdminDocument = ( ) => {
34- const { query, page, size, setParams } = useListQueryParams ( ) ;
35+ const { query, page, size, setParams, setSearch } = useListQueryParams ( ) ;
3536 const [ searchParams ] = useSearchParams ( ) ;
3637 const kb_id = + searchParams . get ( 'id' ) ! ;
3738 const [ title , setTitle ] = useState ( query . title ) ;
38- const [ file_type , setFile_type ] = useState ( query . file_type ) ;
39+ const [ file_type , setFile_type ] = useState < ModelFileType | '' > ( ( ) => {
40+ if ( query . file_type === undefined || query . file_type === '' ) return '' ;
41+ return Number ( query . file_type ) as ModelFileType ;
42+ } ) ;
3943 const {
4044 data,
4145 loading,
@@ -106,9 +110,8 @@ const AdminDocument = () => {
106110 title : '类型' ,
107111 dataIndex : 'file_type' ,
108112 render : ( _ , record ) => {
109- return record ?. file_type !== undefined
110- ? fileType [ record . file_type ! ] || record ?. file_type
111- : '-' ;
113+ if ( record ?. file_type === undefined ) return '-' ;
114+ return fileType [ record . file_type as keyof typeof fileType ] || record . file_type ;
112115 } ,
113116 } ,
114117 {
@@ -159,25 +162,35 @@ const AdminDocument = () => {
159162 onChange = { e => setTitle ( e . target . value ) }
160163 onKeyDown = { e => {
161164 if ( e . key === 'Enter' ) {
162- setParams ( {
165+ setSearch ( {
163166 title,
164167 } ) ;
165168 }
166169 } }
167170 />
168- < TextField
169- label = "类型"
170- value = { file_type }
171- size = "small"
172- onChange = { e => setFile_type ( e . target . value ) }
173- onKeyDown = { e => {
174- if ( e . key === 'Enter' ) {
175- setParams ( {
176- file_type,
171+ < FormControl size = "small" sx = { { minWidth : 120 } } >
172+ < InputLabel > 类型</ InputLabel >
173+ < Select
174+ value = { file_type }
175+ label = "类型"
176+ onChange = { e => {
177+ const value = e . target . value as ModelFileType | '' ;
178+ setFile_type ( value ) ;
179+ setSearch ( {
180+ file_type : value || undefined ,
177181 } ) ;
178- }
179- } }
180- />
182+ } }
183+ >
184+ < MenuItem value = "" >
185+ < em > 全部</ em >
186+ </ MenuItem >
187+ { Object . entries ( fileType ) . map ( ( [ key , label ] ) => (
188+ < MenuItem key = { key } value = { Number ( key ) } >
189+ { label }
190+ </ MenuItem >
191+ ) ) }
192+ </ Select >
193+ </ FormControl >
181194 </ Stack >
182195 < DocImport refresh = { fetchData } allowedImportTypes = { [ 'OfflineFile' ] } />
183196 </ Stack >
0 commit comments