|
@@ -29,6 +29,8 @@ import { useStore as useTagStore } from '@/app/components/base/tag-management/st
|
|
|
import TagManagementModal from '@/app/components/base/tag-management'
|
|
|
import TagFilter from '@/app/components/base/tag-management/filter'
|
|
|
import CheckboxWithLabel from '@/app/components/datasets/create/website/base/checkbox-with-label'
|
|
|
+import { fetchDepts } from '@/service/common'
|
|
|
+import { TreeSelect as AntdTreeSelect } from 'antd'
|
|
|
|
|
|
const getKey = (
|
|
|
pageIndex: number,
|
|
@@ -37,6 +39,7 @@ const getKey = (
|
|
|
isCreatedByMe: boolean,
|
|
|
tags: string[],
|
|
|
keywords: string,
|
|
|
+ dept: string,
|
|
|
) => {
|
|
|
if (!pageIndex || previousPageData.has_more) {
|
|
|
const params: any = { url: 'apps', params: { page: pageIndex + 1, limit: 30, name: keywords, is_created_by_me: isCreatedByMe } }
|
|
@@ -48,7 +51,8 @@ const getKey = (
|
|
|
|
|
|
if (tags.length)
|
|
|
params.params.tag_ids = tags
|
|
|
-
|
|
|
+ if (dept)
|
|
|
+ params.params.dept = dept
|
|
|
return params
|
|
|
}
|
|
|
return null
|
|
@@ -72,9 +76,21 @@ const Apps = () => {
|
|
|
const setTagIDs = useCallback((tagIDs: string[]) => {
|
|
|
setQuery(prev => ({ ...prev, tagIDs }))
|
|
|
}, [setQuery])
|
|
|
-
|
|
|
+ const [dept, setDept] = useState<any>()
|
|
|
+ const [optionsDept, setOptionsDept] = useState<any>([])
|
|
|
+ useEffect(() => {
|
|
|
+ fetchDepts({
|
|
|
+ url: '/xxx',
|
|
|
+ params: {
|
|
|
+ page: 1,
|
|
|
+ limit: 1000,
|
|
|
+ },
|
|
|
+ }).then((res: any) => {
|
|
|
+ setOptionsDept(res.data || [])
|
|
|
+ })
|
|
|
+ }, [])
|
|
|
const { data, isLoading, setSize, mutate } = useSWRInfinite(
|
|
|
- (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, isCreatedByMe, tagIDs, searchKeywords),
|
|
|
+ (pageIndex: number, previousPageData: AppListResponse) => getKey(pageIndex, previousPageData, activeTab, isCreatedByMe, tagIDs, searchKeywords, dept),
|
|
|
fetchAppList,
|
|
|
{ revalidateFirstPage: true },
|
|
|
)
|
|
@@ -146,6 +162,18 @@ const Apps = () => {
|
|
|
options={options}
|
|
|
/>
|
|
|
<div className='flex items-center gap-2'>
|
|
|
+ <AntdTreeSelect
|
|
|
+ showSearch
|
|
|
+ style={{ width: '200px' }}
|
|
|
+ value={dept}
|
|
|
+ dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
|
|
|
+ placeholder="请选择部门"
|
|
|
+ allowClear
|
|
|
+ treeDefaultExpandAll
|
|
|
+ onChange={v => setDept(v || '')}
|
|
|
+ treeData={optionsDept}
|
|
|
+ fieldNames={{ label: 'name', value: 'id' }}
|
|
|
+ />
|
|
|
<CheckboxWithLabel
|
|
|
className='mr-2'
|
|
|
label={t('app.showMyCreatedAppsOnly')}
|