'use client' import React, { useEffect, useState } from 'react' import { RiAddLine, RiCloseLine } from '@remixicon/react' import Modal from '@/app/components/base/modal' import Button from '@/app/components/base/button' import { deptAddUsers, deptDelUsers, fetchIntent, fetchNoDeptUsers } from '@/service/common' import 'react-multi-email/dist/style.css' import cn from '@/utils/classnames' import Confirm from '@/app/components/base/confirm' import { Select as AntdSelect } from 'antd' const UserModal = ({ onCancel, onSend, transfer, }: any) => { const [list, setList] = useState([]) const [total, setTotal] = useState(0) const handlePage = () => { fetchIntent({ url: `/dept/dept-accounts/${transfer.row.dept_id}`, params: {}, }).then((res: any) => { setList(res.data) setTotal(res.data.length) }) } useEffect(() => { handlePage() }, []) const [showConfirmDelete, setShowConfirmDelete] = useState(false) const [row, setRow] = useState({}) const handleDel = async () => { try { const { result }: any = await deptDelUsers({ url: '/dept/dept-accounts', body: { dept_id: transfer.row.dept_id, account_ids: [{ account_id: row.account_id }] }, }) if (result === 'success') { setShowConfirmDelete(false) handlePage() } } catch (e) { } } const [showDetail, setShowDetail] = useState(false) const [selectUser, setSelectUser] = useState([]) const [userOptions, setUserOptions] = useState([]) useEffect(() => { fetchNoDeptUsers({ url: '/account/nodept', params: {}, }).then((res: any) => { setUserOptions(res.data.map((v: any) => ({ label: v.email, value: v.account_id })) || []) }) }, []) const handleSave = async () => { try { const { result }: any = await deptAddUsers({ url: '/dept/dept-accounts', body: { dept_id: transfer.row.dept_id, account_ids: selectUser.map((v: any) => ({ account_id: v })) }, }) if (result === 'success') { setShowDetail(false) handlePage() } } catch (e) { } } return (
{ }} className="p-[24px 32px] w-[800px] max-w-[800px]">
关联用户
{/*
*/} {/*
*/} {/* 用户名称 */} {/* setName(e.target.value)} */} {/* onClear={() => setName('')} */} {/* /> */} {/*
*/} {/* */} {/* */} {/*
*/}
{list.map((item: any) => ( ))}
用户名称 用户账号 操作
{item.name} {item.email}
{/* Show Pagination only if the total is more than the limit */} {/* {total && ( */} {/* */} {/* )} */}
{showConfirmDelete && ( setShowConfirmDelete(false)} /> )} { showDetail && ( { }} className="p-[24px 32px] w-[400px]">
添加用户
setShowDetail(false)} />
选择用户
setSelectUser(v)} options={userOptions} />
) }
) } export default UserModal