Browse Source

机器人额外配置

CzRger 2 months ago
parent
commit
094a00dea0
2 changed files with 90 additions and 2 deletions
  1. 54 2
      web/app/components/explore/create-app-modal/index.tsx
  2. 36 0
      web/service/common.ts

+ 54 - 2
web/app/components/explore/create-app-modal/index.tsx

@@ -1,5 +1,5 @@
 'use client'
 'use client'
-import React, { useState } from 'react'
+import React, { useEffect, useState } from 'react'
 import { useTranslation } from 'react-i18next'
 import { useTranslation } from 'react-i18next'
 import { RiCloseLine } from '@remixicon/react'
 import { RiCloseLine } from '@remixicon/react'
 import AppIconPicker from '../../base/app-icon-picker'
 import AppIconPicker from '../../base/app-icon-picker'
@@ -13,6 +13,9 @@ import AppIcon from '@/app/components/base/app-icon'
 import { useProviderContext } from '@/context/provider-context'
 import { useProviderContext } from '@/context/provider-context'
 import AppsFull from '@/app/components/billing/apps-full-in-dialog'
 import AppsFull from '@/app/components/billing/apps-full-in-dialog'
 import type { AppIconType } from '@/types/app'
 import type { AppIconType } from '@/types/app'
+import { SimpleSelect } from '@/app/components/base/select'
+import { TreeSelect as AntdTreeSelect } from 'antd'
+import { fetchDeptUsers } from '@/service/common'
 
 
 export type CreateAppModalProps = {
 export type CreateAppModalProps = {
   show: boolean
   show: boolean
@@ -80,7 +83,24 @@ const CreateAppModal = ({
     })
     })
     onHide()
     onHide()
   }
   }
-
+  const optionsEditAuth = [
+    { name: '本账号', value: 1 },
+    { name: '本部门', value: 2 },
+  ]
+  const [editAuth, setEditAuth] = useState()
+  const [lookUserIds, setLookUserIds] = useState([])
+  const [optionsDeptUser, setOptionsDeptUser] = useState<any>([])
+  useEffect(() => {
+    fetchDeptUsers({
+      url: '/xxx',
+      params: {
+        page: 1,
+        limit: 1000,
+      },
+    }).then((res: any) => {
+      setOptionsDeptUser(res.data || [])
+    })
+  }, [])
   return (
   return (
     <>
     <>
       <Modal
       <Modal
@@ -143,6 +163,38 @@ const CreateAppModal = ({
             </div>
             </div>
           )}
           )}
           {!isEditModal && isAppsFull && <AppsFull loc='app-explore-create' />}
           {!isEditModal && isAppsFull && <AppsFull loc='app-explore-create' />}
+          <div className='pt-2'>
+            <div className='py-2 text-sm font-medium leading-[20px] text-text-primary'>编辑授权</div>
+            <div className="h-[32px]">
+              <SimpleSelect
+                className="h-[32px]"
+                defaultValue={editAuth}
+                onSelect={(i) => {
+                  setEditAuth(i.value)
+                }}
+                items={optionsEditAuth}
+                allowSearch={false}
+                placeholder="请选择编辑授权"
+              />
+            </div>
+          </div>
+          <div className='pt-2'>
+            <div className='py-2 text-sm font-medium leading-[20px] text-text-primary'>可见授权</div>
+            <AntdTreeSelect
+              showSearch
+              style={{ width: '100%' }}
+              value={lookUserIds}
+              dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
+              placeholder="请选择可见授权"
+              allowClear
+              treeDefaultExpandAll
+              onChange={v => setLookUserIds(v)}
+              treeData={optionsDeptUser}
+              fieldNames={{ label: 'name', value: 'id' }}
+              multiple={true}
+              treeCheckable={true}
+            />
+          </div>
         </div>
         </div>
         <div className='flex flex-row-reverse'>
         <div className='flex flex-row-reverse'>
           <Button disabled={!isEditModal && isAppsFull} className='ml-2 w-24' variant='primary' onClick={submit}>{!isEditModal ? t('common.operation.create') : t('common.operation.save')}</Button>
           <Button disabled={!isEditModal && isAppsFull} className='ml-2 w-24' variant='primary' onClick={submit}>{!isEditModal ? t('common.operation.create') : t('common.operation.save')}</Button>

+ 36 - 0
web/service/common.ts

@@ -649,3 +649,39 @@ export const fetchDepts = ({ url, params }: any) => {
     }, 1000)
     }, 1000)
   })
   })
 }
 }
+export const fetchDeptUsers = ({ url, params }: any) => {
+  console.log('查询部门用户列表', params, url)
+  // return get(url, { params })
+  return new Promise((resolve) => {
+    setTimeout(() => {
+      const arr: any = []
+      for (let i = 1; i < 3; i++) {
+        const dept1: any = {
+          id: `${i}`,
+          name: `部门_${i}`,
+          children: [],
+        }
+        for (let j = 1; j < 4; j++) {
+          const dept2: any = {
+            id: `${i}_${j}`,
+            name: `部门_${i}-${j}`,
+            children: [],
+          }
+          for (let k = 1; k < 5; k++) {
+            const dept3: any = {
+              id: `${i}_${j}_${k}`,
+              name: `用户_${i}-${j}-${k}`,
+              relation: k % 2,
+            }
+            dept2.children.push(dept3)
+          }
+          dept1.children.push(dept2)
+        }
+        arr.push(dept1)
+      }
+      resolve({
+        data: arr,
+      })
+    }, 1000)
+  })
+}