import useNewToken from '@/Hook/useNewToken'; import React, { useEffect, useState } from 'react'; import { App, Button, Input, Modal, Select, Table, Tag, Tooltip, Typography } from 'antd'; import { CloseCircleFilled, SearchOutlined } from '@ant-design/icons'; import '../corpUserManage/global.less' import { useAjax } from '@/Hook/useAjax'; import { getCorpUserChatListApi, getCorpUserChatListProps } from '../../API/groupLeaderManage'; import { getAdAccountAllOfMember, getCorpAllListApi } from '@/API/global'; import { STATUSENUM } from '.'; interface SelectCorpUserChatUserProps { value?: { label: string, value: number, name: string, corpName: string, corpId: string, corpUserId: string }[]; onChange?: (value: { label: string, value: number, name: string, corpName: string, corpId: string, corpUserId: string }[]) => void; placeholder?: React.ReactNode } /** * 选择群主 * @returns */ const SelectGroupLeader: React.FC = ({ value, onChange, placeholder, ...its }) => { /************************************************************/ const { token } = useNewToken() const [visible, setVisible] = useState(false); /************************************************************/ return <>
setVisible(true)} >
{(value && value?.length > 0) ? <> e.stopPropagation()} onClose={(e) => { e.preventDefault(); onChange(value?.filter(item => item.value !== value?.[0]?.value)) }} > {value?.[0]?.label || value?.[0]?.value} {value?.length > 1 && {value?.filter((_, index) => index !== 0)?.map((item) => e.stopPropagation()} onClose={(e) => { e.stopPropagation() onChange(value?.filter(item1 => item1.value !== item.value)) }} >{item.label || item?.value})} } > +{value.length - 1} ... } : {placeholder || '请选择群主号'}}
{(value && value?.length > 0) &&
{ e.stopPropagation() onChange?.([]) }} />
}
{visible && setVisible(false)} onChange={(values) => { onChange?.(values) setVisible(false) }} />} }; interface SelectCorpUserChatUserModalProps extends SelectCorpUserChatUserProps { visible?: boolean onClose?: () => void } const SelectCorpUserChatUserModal: React.FC = React.memo(({ placeholder, visible, onClose, onChange, value }) => { /**********************************************/ const [editSelectedRow, setEditSelectedRow] = useState([]) const { message } = App.useApp() const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 20 }) const [queryParamsNew, setQueryParamsNew] = useState({ pageNum: 1, pageSize: 20 }) const getCorpUserChatList = useAjax((params) => getCorpUserChatListApi(params)) const allOfMember = useAjax(() => getAdAccountAllOfMember()) const getCorpAllList = useAjax((params) => getCorpAllListApi(params)) /**********************************************/ useEffect(() => { allOfMember.run() getCorpAllList.run({}) }, []) useEffect(() => { getCorpUserChatList.run(queryParamsNew) }, [queryParamsNew]) useEffect(() => { if (visible) { setEditSelectedRow(value?.length ? value.map(item => ({ id: item.value, name: item.name, corpName: item.corpName, corpId: item.corpId, corpUserId: item.corpUserId })) : []) } }, [visible, value]) const handleOk = () => { if (editSelectedRow.length) { onChange?.(editSelectedRow.map(item => ({ label: `${item.name}(${item.corpName})`, value: item.id, name: item.name, corpName: item.corpName, corpId: item.corpId, corpUserId: item.corpUserId }))) } else { message.error('请至少选择一条数据') } } return {placeholder}} open={visible} width={900} onCancel={onClose} onOk={handleOk} >
setQueryParams({ ...queryParams, corpUserName: e.target.value as any })} value={queryParams?.corpUserName} placeholder="客服号名称" allowClear /> setQueryParams({ ...queryParams, corpUserIds: e.target.value as any })} value={queryParams?.corpUserIds} placeholder="客服ID(多个,,空格换行)" allowClear /> setQueryParams({ ...queryParams, putUserId: e })} showSearch style={{ width: 110 }} placeholder="投手" filterOption={(input, option) => ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase()) } allowClear options={allOfMember?.data?.data?.map((item: any) => ({ label: item.nickname, value: item.userId }))} />