CzRger hace 2 meses
padre
commit
0c469662c3

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

@@ -5,7 +5,7 @@ import s from './index.module.css'
 import cn from '@/utils/classnames'
 import Modal from '@/app/components/base/modal'
 import Button from '@/app/components/base/button'
-import { addKnowledge, editKnowledge, fetchDepts } from '@/service/common'
+import { addDept, editDept, fetchDepts } from '@/service/common'
 import 'react-multi-email/dist/style.css'
 import Input from '@/app/components/base/input'
 import { TreeSelect as AntdTreeSelect } from 'antd'
@@ -15,11 +15,12 @@ const InviteModal = ({
   onCancel,
   onSend,
 }: any) => {
-  const [name, setName] = useState<string>(transfer.row?.name || '')
+  const [name, setName] = useState<string>(transfer.row?.dept_name || '')
+  const [parent, setParent] = useState<string>(transfer.row?.parent_id || '')
   const [options, setOptions] = useState<any>([])
   useEffect(() => {
     fetchDepts({
-      url: '/xxx',
+      url: '/dept',
       params: {
         page: 1,
         limit: 99999,
@@ -32,15 +33,15 @@ const InviteModal = ({
     try {
       let res: any = () => {}
       if (transfer.mode === 'add') {
-        res = await addKnowledge({
-          url: '/123',
-          body: { name, status: false },
+        res = await addDept({
+          url: '/depts',
+          body: { dept_name: name, parent_id: parent },
         })
       }
       else {
-        res = await editKnowledge({
-          url: `/123/${transfer.row.id}`,
-          body: { name },
+        res = await editDept({
+          url: `/depts/${transfer.row.dept_id}`,
+          body: { dept_name: name, parent_id: parent },
         })
       }
       const { id }: any = res
@@ -67,14 +68,14 @@ const InviteModal = ({
             <AntdTreeSelect
               showSearch
               style={{ width: '100%' }}
-              value={name}
+              value={parent}
               dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
               placeholder="请选择上级部门"
               allowClear
               treeDefaultExpandAll
-              onChange={v => setName(v || '')}
+              onChange={v => setParent(v || '')}
               treeData={options}
-              fieldNames={{ label: 'name', value: 'id' }}
+              fieldNames={{ label: 'dept_name', value: 'dept_id' }}
             />
           </div>
           <div className={cn('flex flex-wrap items-center justify-between')}>

+ 4 - 6
web/app/components/header/account-setting/dept-page/index.tsx

@@ -32,10 +32,8 @@ const DeptsPage = () => {
   const { userProfile, currentWorkspace, isCurrentWorkspaceOwner, isCurrentWorkspaceManager, systemFeatures } = useAppContext()
   const { data, mutate }: any = useSWR(
     {
-      url: '/external_applications',
+      url: '/dept',
       params: {
-        page: 1,
-        limit: 99999,
       },
     },
     fetchDepts,
@@ -105,12 +103,12 @@ const DeptsPage = () => {
         </div>
         <div className='overflow-visible lg:overflow-visible'>
           <AntdTable
-            rowKey="id"
+            rowKey="dept_id"
             dataSource={deptList}
             pagination={false}
           >
-            <AntdColumn title="部门名称" dataIndex="name" key="name"/>
-            <AntdColumn title="关联用户数量" dataIndex="relation" key="relation" align="center" width={120}/>
+            <AntdColumn title="部门名称" dataIndex="dept_name" key="dept_name"/>
+            {/* <AntdColumn title="关联用户数量" dataIndex="relation" key="relation" align="center" width={120}/> */}
             <AntdColumn title="操作" key="action" align="center" width={100} render={(_: any, record: any) => (
               <AntdSpace size="middle">
                 {!(record.children?.length > 0) && (

+ 11 - 33
web/service/common.ts

@@ -576,39 +576,17 @@ export const delBatchCorpusQuestion = ({ url, body }: any) => {
 
 export const fetchDepts = ({ 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)
-  })
+  return get(url, { params })
+}
+
+export const addDept = ({ url, body }: any) => {
+  console.log('新增部门', url, body)
+  return post(url, { body })
+}
+
+export const editDept = ({ url, body }: any) => {
+  console.log('编辑部门', url, body)
+  return post(url, { body })
 }
 export const fetchDeptUsers = ({ url, params }: any) => {
   console.log('查询部门用户列表', params, url)