'use client' import { 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 { 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' const InviteModal = ({ transfer, onCancel, onSend, }: any) => { const [name, setName] = useState(transfer.row?.dept_name || '') const [parent, setParent] = useState(transfer.row?.parent_dept_id || '') console.log(transfer) const [options, setOptions] = useState([]) useEffect(() => { fetchDepts({ url: '/depts', }).then((res: any) => { setOptions(res.data || []) }) }, []) const handleSave = async () => { try { let res: any = () => {} if (transfer.mode === 'add') { res = await addDept({ url: '/depts', body: { dept_name: name, parent_dept_id: parent }, }) } else { res = await editDept({ url: '/depts', body: { dept_name: name, parent_dept_id: parent, dept_id: transfer.row.dept_id }, }) } const { result }: any = res if (result === 'success') { onCancel() onSend() } } catch (e) { } } return (
{ }} className={cn(s.modal)}>
{transfer.mode === 'add' ? '新增' : '编辑'}部门
上级部门
{ console.log('dept', v) setParent(v || '') }} treeData={options} fieldNames={{ label: 'dept_name', value: 'dept_id' }} />
部门名称
setName(e.target.value)} className='h-9' placeholder='请输入部门名称' />
) } export default InviteModal