'use client' import { useCallback, useEffect, useState } from 'react' import { RiCloseLine } from '@remixicon/react' 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 'react-multi-email/dist/style.css' import Input from '@/app/components/base/input' import { TreeSelect as AntdTreeSelect } from 'antd' const InviteModal = ({ transfer, onCancel, onSend, }: any) => { const [name, setName] = useState(transfer.row?.name || '') const [options, setOptions] = useState([]) useEffect(() => { fetchDepts({ url: '/xxx', params: { page: 1, limit: 1000, }, }).then((res: any) => { setOptions(res.data || []) }) }, []) const handleSave = useCallback(async () => { try { let res: any = () => {} if (transfer.mode === 'add') { res = await addKnowledge({ url: '/123', body: { name, status: false }, }) } else { res = await editKnowledge({ url: `/123/${transfer.row.id}`, body: { name }, }) } const { id }: any = res if (id) { onCancel() onSend() } } catch (e) { } }, [name, onCancel, onSend, transfer]) return (
{ }} className={cn(s.modal)}>
{transfer.mode === 'add' ? '新增' : '编辑'}部门
上级部门
setName(v || '')} treeData={options} fieldNames={{ label: 'name', value: 'id' }} />
部门名称
setName(e.target.value)} className='h-9' placeholder='请输入部门名称' />
) } export default InviteModal