Parcourir la source

审核状态筛选条件

CzRger il y a 3 mois
Parent
commit
6d92d44136

+ 30 - 1
web/app/components/datasets/documents/index.tsx

@@ -5,7 +5,7 @@ import { useTranslation } from 'react-i18next'
 import { useRouter } from 'next/navigation'
 import { useDebounce, useDebounceFn } from 'ahooks'
 import { groupBy } from 'lodash-es'
-import { PlusIcon } from '@heroicons/react/24/solid'
+import { ArrowDownTrayIcon, BookOpenIcon, PlusIcon } from '@heroicons/react/24/solid'
 import { RiDraftLine, RiExternalLinkLine } from '@remixicon/react'
 import AutoDisabledDocument from '../common/document-status-with-action/auto-disabled-document'
 import List from './list'
@@ -29,6 +29,7 @@ import { useChildSegmentListKey, useSegmentListKey } from '@/service/knowledge/u
 import useEditDocumentMetadata from '../metadata/hooks/use-edit-dataset-metadata'
 import DatasetMetadataDrawer from '../metadata/metadata-dataset/dataset-metadata-drawer'
 import StatusWithAction from '../common/document-status-with-action/status-with-action'
+import { SimpleSelect } from '@/app/components/base/select'
 
 const FolderPlusIcon = ({ className }: React.SVGProps<SVGElement>) => {
   return <svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg" className={className ?? ''}>
@@ -87,6 +88,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
   const { plan } = useProviderContext()
   const isFreePlan = plan.type === 'sandbox'
   const [inputValue, setInputValue] = useState<string>('') // the input value
+  const [status, setStatus] = useState<any>('')
   const [searchValue, setSearchValue] = useState<string>('')
   const [currPage, setCurrPage] = React.useState<number>(0)
   const [limit, setLimit] = useState<number>(DEFAULT_LIMIT)
@@ -98,6 +100,11 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
   const isDataSourceWeb = dataset?.data_source_type === DataSourceType.WEB
   const isDataSourceFile = dataset?.data_source_type === DataSourceType.FILE
   const embeddingAvailable = !!dataset?.embedding_available
+  const optionsStatus = [
+    { name: '待审核', value: 1 },
+    { name: '审核不通过', value: 2 },
+    { name: '无', value: 3 },
+  ]
 
   const debouncedSearchValue = useDebounce(searchValue, { wait: 500 })
 
@@ -107,6 +114,7 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
       page: currPage + 1,
       limit,
       keyword: debouncedSearchValue,
+      status,
     },
     refetchInterval: (isDataSourceNotion && timerCanRun) ? 2500 : 0,
   })
@@ -276,7 +284,28 @@ const Documents: FC<IDocumentsProps> = ({ datasetId }) => {
             onChange={e => handleInputChange(e.target.value)}
             onClear={() => handleInputChange('')}
           />
+          <div className="ml-2 mr-auto h-[32px]">
+            <SimpleSelect
+              className="h-[32px] w-[200px]"
+              defaultValue={status}
+              onSelect={(i) => {
+                setStatus(i.value)
+              }}
+              items={optionsStatus}
+              allowSearch={false}
+              placeholder="请选择审核状态"
+            />
+          </div>
           <div className='flex !h-8 items-center justify-center gap-2'>
+            <Button variant='primary' onClick={routeToDocCreate} className='shrink-0'>
+              <BookOpenIcon className={cn('mr-2 h-4 w-4 stroke-current')} />
+              模板管理
+            </Button>
+            <Button variant='primary' onClick={routeToDocCreate} className='shrink-0'>
+              <ArrowDownTrayIcon className={cn('mr-2 h-4 w-4 stroke-current')} />
+              模板下载
+            </Button>
+
             {!isFreePlan && <AutoDisabledDocument datasetId={datasetId} />}
             <IndexFailed datasetId={datasetId} />
             {!embeddingAvailable && <StatusWithAction type='warning' description={t('dataset.embeddingModelNotAvailable')} />}

+ 3 - 2
web/service/knowledge/use-document.ts

@@ -19,13 +19,14 @@ export const useDocumentList = (payload: {
     page: number
     limit: number
     sort?: SortType
+    status: any
   },
   refetchInterval?: number | false
 }) => {
   const { query, datasetId, refetchInterval } = payload
-  const { keyword, page, limit, sort } = query
+  const { keyword, page, limit, sort, status } = query
   return useQuery<DocumentListResponse>({
-    queryKey: [...useDocumentListKey, datasetId, keyword, page, limit, sort],
+    queryKey: [...useDocumentListKey, datasetId, keyword, page, limit, sort, status],
     queryFn: () => get<DocumentListResponse>(`/datasets/${datasetId}/documents`, {
       params: query,
     }),