Explorar el Código

知识库查询条件

CzRger hace 2 meses
padre
commit
200d547264

+ 37 - 26
web/app/(commonLayout)/datasets/Container.tsx

@@ -16,10 +16,7 @@ import Doc from './Doc'
 import TabSliderNew from '@/app/components/base/tab-slider-new'
 import TagManagementModal from '@/app/components/base/tag-management'
 import TagFilter from '@/app/components/base/tag-management/filter'
-import Button from '@/app/components/base/button'
 import Input from '@/app/components/base/input'
-import { ApiConnectionMod } from '@/app/components/base/icons/src/vender/solid/development'
-import CheckboxWithLabel from '@/app/components/datasets/create/website/base/checkbox-with-label'
 
 // Services
 import { fetchDatasetApiBaseUrl } from '@/service/datasets'
@@ -108,15 +105,18 @@ const Container = () => {
   const [optionsDept, setOptionsDept] = useState<any>([])
   useEffect(() => {
     fetchDepts({
-      url: '/xxx',
-      params: {
-        page: 1,
-        limit: 99999,
-      },
+      url: '/depts',
     }).then((res: any) => {
       setOptionsDept(res.data || [])
     })
   }, [])
+  const [authType, setAuthType] = useState<any>('')
+  const optionsAuthType = [
+    { name: '创建', value: '1' },
+    { name: '编辑', value: '2' },
+    { name: '授权编辑', value: '3' },
+    { name: '授权可见', value: '4' },
+  ]
   return (
     <div ref={containerRef} className='scroll-container relative flex grow flex-col overflow-y-auto bg-background-body'>
       <div className='sticky top-0 z-10 flex flex-wrap justify-between gap-y-2 bg-background-body px-12 pb-2 pt-4 leading-[56px]'>
@@ -127,6 +127,16 @@ const Container = () => {
         />
         {activeTab === 'dataset' && (
           <div className='flex items-center justify-center gap-2'>
+            <SimpleSelect
+              wrapperClassName="h-[32px] w-[200px]"
+              defaultValue={authType}
+              onSelect={(i) => {
+                setAuthType(i.value)
+              }}
+              items={optionsAuthType}
+              allowSearch={false}
+              placeholder="请选择权限类型"
+            />
             <AntdTreeSelect
               showSearch
               style={{ width: '200px' }}
@@ -137,7 +147,7 @@ const Container = () => {
               treeDefaultExpandAll
               onChange={v => setDept(v || '')}
               treeData={optionsDept}
-              fieldNames={{ label: 'name', value: 'id' }}
+              fieldNames={{ label: 'dept_name', value: 'dept_id' }}
             />
             <SimpleSelect
               wrapperClassName="h-[32px] w-[200px]"
@@ -148,15 +158,16 @@ const Container = () => {
               }}
               items={optionsType}
               allowSearch={false}
+              placeholder="请选择类型"
             />
-            {isCurrentWorkspaceOwner && <CheckboxWithLabel
-              isChecked={includeAll}
-              onChange={toggleIncludeAll}
-              label={t('dataset.allKnowledge')}
-              labelClassName='system-md-regular text-text-secondary'
-              className='mr-2'
-              tooltip={t('dataset.allKnowledgeDescription') as string}
-            />}
+            {/* {isCurrentWorkspaceOwner && <CheckboxWithLabel */}
+            {/*  isChecked={includeAll} */}
+            {/*  onChange={toggleIncludeAll} */}
+            {/*  label={t('dataset.allKnowledge')} */}
+            {/*  labelClassName='system-md-regular text-text-secondary' */}
+            {/*  className='mr-2' */}
+            {/*  tooltip={t('dataset.allKnowledgeDescription') as string} */}
+            {/* />} */}
             <TagFilter type='knowledge' value={tagFilterValue} onChange={handleTagsChange} />
             <Input
               showLeftIcon
@@ -166,21 +177,21 @@ const Container = () => {
               onChange={e => handleKeywordsChange(e.target.value)}
               onClear={() => handleKeywordsChange('')}
             />
-            <div className="h-4 w-[1px] bg-divider-regular" />
-            <Button
-              className='shadows-shadow-xs gap-0.5'
-              onClick={() => setShowExternalApiPanel(true)}
-            >
-              <ApiConnectionMod className='h-4 w-4 text-components-button-secondary-text' />
-              <div className='system-sm-medium flex items-center justify-center gap-1 px-0.5 text-components-button-secondary-text'>{t('dataset.externalAPIPanelTitle')}</div>
-            </Button>
+            {/* <div className="h-4 w-[1px] bg-divider-regular" /> */}
+            {/* <Button */}
+            {/*  className='shadows-shadow-xs gap-0.5' */}
+            {/*  onClick={() => setShowExternalApiPanel(true)} */}
+            {/* > */}
+            {/*  <ApiConnectionMod className='h-4 w-4 text-components-button-secondary-text' /> */}
+            {/*  <div className='system-sm-medium flex items-center justify-center gap-1 px-0.5 text-components-button-secondary-text'>{t('dataset.externalAPIPanelTitle')}</div> */}
+            {/* </Button> */}
           </div>
         )}
         {activeTab === 'api' && data && <ApiServer apiBaseUrl={data.api_base_url || ''} />}
       </div>
       {activeTab === 'dataset' && (
         <>
-          <Datasets containerRef={containerRef} tags={tagIDs} keywords={searchKeywords} includeAll={includeAll} type={searchType} dept={dept} />
+          <Datasets containerRef={containerRef} tags={tagIDs} keywords={searchKeywords} includeAll={includeAll} type={searchType} dept={dept} authType={authType} />
           <DatasetFooter />
           {showTagManagementModal && (
             <TagManagementModal type='knowledge' show={showTagManagementModal} />

+ 7 - 2
web/app/(commonLayout)/datasets/Datasets.tsx

@@ -18,6 +18,7 @@ const getKey = (
   includeAll: boolean,
   type: string,
   dept: string,
+  authType: string,
 ) => {
   if (!pageIndex || previousPageData.has_more) {
     const params: FetchDatasetsParams = {
@@ -35,7 +36,9 @@ const getKey = (
     if (type)
       params.params.category_ids = [type]
     if (dept)
-      params.params.dept = dept
+      params.params.creatorDept = dept
+    if (authType)
+      params.params.authType = authType
     return params
   }
   return null
@@ -48,6 +51,7 @@ type Props = {
   includeAll: boolean,
   type: string,
   dept: string,
+  authType: string,
 }
 
 const Datasets = ({
@@ -57,10 +61,11 @@ const Datasets = ({
   includeAll,
   type,
   dept,
+  authType,
 }: Props) => {
   const { isCurrentWorkspaceEditor } = useAppContext()
   const { data, isLoading, setSize, mutate } = useSWRInfinite(
-    (pageIndex: number, previousPageData: DataSetListResponse) => getKey(pageIndex, previousPageData, tags, keywords, includeAll, type, dept),
+    (pageIndex: number, previousPageData: DataSetListResponse) => getKey(pageIndex, previousPageData, tags, keywords, includeAll, type, dept, authType),
     fetchDatasets,
     { revalidateFirstPage: false, revalidateAll: true },
   )

+ 0 - 1
web/app/components/header/account-setting/dept-page/detail-modal/index.tsx

@@ -71,7 +71,6 @@ const InviteModal = ({
               allowClear
               treeDefaultExpandAll
               onChange={(v) => {
-                console.log('dept', v)
                 setParent(v || '')
               }}
               treeData={options}