wjx před 1 měsícem
rodič
revize
072140c8e6

+ 3 - 1
src/pages/weComTask/components/groupChatGroups/index.tsx

@@ -11,6 +11,7 @@ interface GroupChatGroupsProps {
     value?: OFFICIAL_CHAT_CREATE.GroupsProps[];
     onChange?: (value?: OFFICIAL_CHAT_CREATE.GroupsProps[]) => void;
     placeholder?: React.ReactNode
+    isOwnerUser?: boolean  // 是否可选择群主
     disabled?: boolean
 }
 
@@ -19,7 +20,7 @@ interface GroupChatGroupsProps {
  * @param param0 
  * @returns 
  */
-const GroupChatGroups: React.FC<GroupChatGroupsProps> = ({ corpList, mpList, value, onChange, placeholder, disabled }) => {
+const GroupChatGroups: React.FC<GroupChatGroupsProps> = ({ corpList, mpList, value, onChange, placeholder, isOwnerUser, disabled }) => {
 
     /************************************************************/
     const { token } = useNewToken()
@@ -73,6 +74,7 @@ const GroupChatGroups: React.FC<GroupChatGroupsProps> = ({ corpList, mpList, val
 
         {/* 选择关联主体 */}
         {visible && <SelectMpCorp
+            isOwnerUser={isOwnerUser}
             corpList={corpList}
             mpList={mpList}
             visible={visible}

+ 50 - 6
src/pages/weComTask/page/groupChatSend/official/create/components/SelectMpCorp/index.tsx

@@ -3,6 +3,7 @@ import React, { useState } from "react";
 import style from '../../../../../../components/selectExternalAccount/index.less'
 import { CheckOutlined, CloseOutlined } from '@ant-design/icons'
 import { DefaultOptionType } from "antd/es/select";
+import SelectGroupLeaderModal from "@/pages/weComTask/page/groupLeaderManage/selectGroupLeaderModal";
 const { Text, Title } = Typography;
 
 interface Props {
@@ -12,6 +13,7 @@ interface Props {
     visible?: boolean;
     onClose?: () => void;
     onChange?: (value: OFFICIAL_CHAT_CREATE.GroupsProps[]) => void;
+    isOwnerUser?: boolean;  // 是否可选择群主
     disabled?: boolean;
 }
 /**
@@ -19,12 +21,14 @@ interface Props {
  * @param param0 
  * @returns 
  */
-const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClose, onChange, disabled }) => {
+const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClose, onChange, isOwnerUser, disabled }) => {
 
     /***************************************/
     const [data, setData] = useState<OFFICIAL_CHAT_CREATE.GroupsProps[]>(group && group?.length > 0 ? group : [{}]);
     const [selectAdz, setSelectAdz] = useState<number>(1)   // 选择广告主
     const [queryForm, setQueryForm] = useState<any>({})
+
+    const [ownerUserVisible, setOwnerUserVisible] = useState<boolean>(false) // 选择群主弹窗
     /***************************************/
 
     const handleOk = () => {
@@ -47,7 +51,7 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
         open={visible}
         onCancel={onClose}
         onOk={handleOk}
-        width={1100}
+        width={1200}
         className={`${style.SelectPackage}`}
         okButtonProps={{ disabled }}
         styles={{
@@ -91,17 +95,17 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
                         allowClear
                         options={mpList}
                     />
-                    {data[selectAdz - 1]?.mpAccount?.value && <a 
+                    {data[selectAdz - 1]?.mpAccount?.value && <a
                         style={{ color: 'red' }}
                         onClick={() => {
                             let newData = JSON.parse(JSON.stringify(data))
                             let dataIten = newData[selectAdz - 1]?.mpAccount || {}
-                             dataIten = undefined
+                            dataIten = undefined
                             newData[selectAdz - 1].mpAccount = dataIten
                             setData(newData)
                         }}
                     >删除</a>}
-                    
+
                 </Space>
                 <Table
                     tableLayout='fixed'
@@ -182,6 +186,7 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
                                 dataIten = dataIten.filter((item: { value: string }) => item.value !== record.value)
                             }
                             newData[selectAdz - 1].corp = dataIten
+                            delete newData[selectAdz - 1]?.ownerUsers
                             setData(newData)
                         },
                         onSelectAll: (selected: boolean, selectedRowss: { value: string }[], changeRows: { value: string }[]) => {
@@ -197,6 +202,7 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
                                     }
                                 })
                                 newData[selectAdz - 1].corp = newSelectAccData
+                                delete newData[selectAdz - 1].ownerUsers
                             } else {
                                 let newSelectAccData = dataIten.filter((item: { value: string }) => {
                                     let index = changeRows.findIndex((ite: { value: string }) => ite.value === item.value)
@@ -207,6 +213,7 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
                                     }
                                 })
                                 newData[selectAdz - 1].corp = newSelectAccData
+                                delete newData[selectAdz - 1].ownerUsers
                             }
                             setData(newData)
                         }
@@ -215,7 +222,7 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
             </div>
             <div className={style.center}>
                 <div style={{ margin: '0 0 5px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
-                    <Title level={5} style={{ margin: 0 }}>已选:{data[selectAdz - 1]?.corp?.length || 0}</Title>
+                    <Title level={5} style={{ margin: 0 }}>已选主体:{data[selectAdz - 1]?.corp?.length || 0}</Title>
                     {data.length > 1 && <a style={{ color: 'red' }} onClick={() => {
                         if (selectAdz === data.length) {
                             handleSelectAdz(selectAdz - 1)
@@ -237,7 +244,44 @@ const SelectMpCorp: React.FC<Props> = ({ corpList, mpList, group, visible, onClo
                     </div>)}
                 </div>
             </div>
+            {(isOwnerUser && data[selectAdz - 1]?.corp?.length === 1) && <div className={style.center} style={{ width: 200 }}>
+                <div style={{ margin: '0 0 5px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
+                    <Title level={5} style={{ margin: 0 }}>已选群主:{data[selectAdz - 1]?.ownerUsers?.length || 0}</Title>
+                    {data[selectAdz - 1]?.ownerUsers?.length > 0 && <a style={{ color: 'red' }} onClick={() => {
+                        let newData = JSON.parse(JSON.stringify(data))
+                        delete newData[selectAdz - 1].ownerUsers
+                        setData(newData)
+                    }}>清空</a>}
+                    <a onClick={() => { setOwnerUserVisible(true) }}>选择</a>
+                </div>
+                <div className={style.select_content}>
+                    {data[selectAdz - 1]?.ownerUsers?.map(item => <div key={item.corpUserId}>
+                        <Text ellipsis={{ tooltip: true }} className={style.marketingAssetName}>{item.name}</Text>
+                        <CloseOutlined className={style.close} onClick={() => {
+                            let newData = JSON.parse(JSON.stringify(data))
+                            newData[selectAdz - 1].ownerUsers = newData[selectAdz - 1]?.ownerUsers?.filter((i: any) => i?.corpUserId !== item.corpUserId)
+                            setData(newData)
+                        }} />
+                    </div>)}
+                </div>
+            </div>}
         </div>
+
+        {/* 选择群主 */}
+        {ownerUserVisible && <SelectGroupLeaderModal
+            corpIds={data[selectAdz - 1]?.corp?.map(i => i.value) || []}
+            visible={ownerUserVisible}
+            value={data[selectAdz - 1]?.ownerUsers || []}
+            onClose={() => {
+                setOwnerUserVisible(false)
+            }}
+            onChange={(value) => {
+                let newData = JSON.parse(JSON.stringify(data))
+                newData[selectAdz - 1].ownerUsers = value
+                setData(newData)
+                setOwnerUserVisible(false)
+            }}
+        />}
     </Modal>
 }
 

+ 1 - 0
src/pages/weComTask/page/groupChatSend/official/typings.d.ts

@@ -16,6 +16,7 @@ declare namespace OFFICIAL_CHAT_CREATE {
             appid: string; // 公众号appid
         }
         corp?: any[];
+        ownerUsers?: any[]; // 群主
     }
     // 官方群发创建参数配置
     interface SettingsProps {

+ 8 - 2
src/pages/weComTask/page/groupChatSend/robot/create/index.tsx

@@ -70,7 +70,8 @@ const OfficialCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE
                                 value: m?.mpAccountVO?.id || '',
                                 appId: m?.mpAccountVO?.appId || '',
                             } : undefined,
-                            corp: m?.corpVOList?.map(c => ({ label: c.corpName, value: c.corpId })) || []
+                            corp: m?.corpVOList?.map(c => ({ label: c.corpName, value: c.corpId })) || [],
+                            ownerUsers: m?.corpUserVOList?.map(u => ({ name: u.name, corpUserId: u.corpUserId, corpId: u.corpId, corpName: u.corpName })) || []
                         }
                     })
                     let newSettings: ROBOT_CHAT_CREATE.SettingsProps = {
@@ -377,12 +378,16 @@ const OfficialCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE
                     if (!groupChatMsgContent[strategyIndex][sendIndex]) groupChatMsgContent[strategyIndex][sendIndex] = [];
                     groupChatMsgContent[strategyIndex][sendIndex][contentIndex] = previewContent?.[id] || {};
                 })
-                return {
+                const mpAccount: any = {
                     mpAccountId: item?.mpAccount?.value,
                     corpIds: item.corp?.map(c => c.value) || [],
                     groupChatMsgContent,
                     corpGroupChat: corpGroupChatData[index]
                 }
+                if (item.ownerUsers?.length) {
+                    mpAccount.ownerUserIds = item.ownerUsers.map(u => u.corpUserId)
+                }
+                return mpAccount
             }),
             robotChatSendTaskAddDTO: {
                 ...strategyDTO,
@@ -452,6 +457,7 @@ const OfficialCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE
                     <Space.Compact>
                         <Button>群发组</Button>
                         <GroupChatGroups
+                            isOwnerUser
                             mpList={mpList}
                             corpList={corpList}
                             value={settings?.group}

+ 11 - 0
src/pages/weComTask/page/groupChatSend/robot/taskList/components/groupTask/index.tsx

@@ -61,6 +61,17 @@ const GroupTask: React.FC<Props> = ({ robotGroupChatSendTaskVOList }) => {
                     return value?.map(item => item.corpName)?.join('、') || '--'
                 },
             },
+            {
+                title: '群主号',
+                dataIndex: 'corpUserVOList',
+                key: 'corpUserVOList',
+                width: 100,
+                ellipsis: true,
+                align: 'center',
+                render(value) {
+                    return value?.map(item => item.name)?.join('、') || '--'
+                },
+            },
             {
                 title: '状态',
                 dataIndex: 'status',

+ 1 - 0
src/pages/weComTask/page/groupChatSend/robot/typings.d.ts

@@ -16,6 +16,7 @@ declare namespace ROBOT_CHAT_CREATE {
             appid: string; // 公众号appid
         }
         corp?: any[];
+        ownerUsers?: any[]; // 群主
     }
     // 官方群发创建参数配置
     interface SettingsProps {

+ 222 - 0
src/pages/weComTask/page/groupLeaderManage/selectGroupLeaderModal.tsx

@@ -0,0 +1,222 @@
+import React, { useEffect, useState } from 'react';
+import { Modal, Button, App, Input, Select, Table } from 'antd';
+import { getCorpUserChatListApi, getCorpUserChatListProps } from '../../API/groupLeaderManage';
+import { useAjax } from '@/Hook/useAjax';
+import { SearchOutlined } from '@ant-design/icons';
+import { getAdAccountAllOfMember } from '@/API/global';
+import { STATUSENUM } from '.';
+
+interface SelectGroupLeaderModalProps {
+    corpIds: string[]
+    visible?: boolean;
+    value?: any[]
+    onChange?: (value: any[]) => void;
+    onClose?: () => void;
+}
+
+const SelectGroupLeaderModal: React.FC<SelectGroupLeaderModalProps> = ({ corpIds, visible, value, onChange, onClose }) => {
+
+    /*****************************************/
+    const [editSelectedRow, setEditSelectedRow] = useState<any[]>(value || [])
+    const { message } = App.useApp()
+    const [queryParams, setQueryParams] = useState<getCorpUserChatListProps>({ pageNum: 1, pageSize: 20, corpIds })
+    const [queryParamsNew, setQueryParamsNew] = useState<getCorpUserChatListProps>({ pageNum: 1, pageSize: 20, corpIds })
+
+    const getCorpUserChatList = useAjax((params) => getCorpUserChatListApi(params))
+    const allOfMember = useAjax(() => getAdAccountAllOfMember())
+    /*****************************************/
+
+    useEffect(() => {
+        allOfMember.run()
+    }, [])
+
+    useEffect(() => {
+        getCorpUserChatList.run(queryParamsNew)
+    }, [queryParamsNew])
+
+    const handleOk = () => {
+        if (editSelectedRow.length) {
+            onChange?.(editSelectedRow.map(item => ({
+                label: `${item.name}(${item.corpName})`,
+                id: item.id,
+                name: item.name,
+                corpName: item.corpName,
+                corpId: item.corpId,
+                corpUserId: item.corpUserId
+            })))
+        } else {
+            message.error('请至少选择一条数据')
+        }
+    }
+
+    return <Modal
+        title={<strong>请选择群主</strong>}
+        open={visible}
+        width={900}
+        onCancel={onClose}
+        onOk={handleOk}
+    >
+        <div className='selectCorpUserBody' style={{ width: '100%' }}>
+            <div className='selectCorpUserBody_search'>
+                <Input style={{ width: 150 }} onChange={(e) => setQueryParams({ ...queryParams, corpUserName: e.target.value as any })} value={queryParams?.corpUserName} placeholder="客服号名称" allowClear />
+                <Input style={{ width: 150 }} onChange={(e) => setQueryParams({ ...queryParams, corpUserIds: e.target.value as any })} value={queryParams?.corpUserIds} placeholder="客服ID(多个,,空格换行)" allowClear />
+                <Select
+                    value={queryParams?.operUserId}
+                    onChange={(e) => setQueryParams({ ...queryParams, operUserId: 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 }))}
+                />
+                <Select
+                    value={queryParams?.putUserId}
+                    onChange={(e) => 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 }))}
+                />
+                <Select
+                    style={{ width: 90 }}
+                    showSearch
+                    placeholder="状态"
+                    value={queryParams?.status}
+                    onChange={(value) => setQueryParams({ ...queryParams, status: value })}
+                    filterOption={(input, option) =>
+                        ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
+                    }
+                    allowClear
+                    options={[{ label: '已激活', value: 1 }, { label: '已禁用', value: 2 }, { label: '未激活', value: 4 }, { label: '退出企业', value: 5 }]}
+                />
+                <Button type="primary" onClick={() => {
+                    setQueryParamsNew({ ...queryParams, pageNum: 1 })
+                }} loading={getCorpUserChatList.loading} icon={<SearchOutlined />}>搜索</Button>
+            </div>
+            <div className='selectCorpUserBody_content'>
+                <Table
+                    columns={[
+                        {
+                            title: '群主主体',
+                            dataIndex: 'corpName',
+                            key: 'corpName',
+                            align: 'center',
+                            width: 70,
+                            ellipsis: true,
+                        },
+                        {
+                            title: '群主企微主体ID',
+                            dataIndex: 'corpId',
+                            key: 'corpId',
+                            align: 'center',
+                            width: 70,
+                            ellipsis: true,
+                        },
+                        {
+                            title: '群主企微号',
+                            dataIndex: 'name',
+                            key: 'name',
+                            align: 'center',
+                            width: 70,
+                            ellipsis: true,
+                        },
+                        {
+                            title: '群主企微号ID',
+                            dataIndex: 'corpUserId',
+                            key: 'corpUserId',
+                            align: 'center',
+                            width: 70,
+                            ellipsis: true,
+                        },
+                        {
+                            title: '主运营',
+                            dataIndex: 'operUser',
+                            key: 'operUser',
+                            align: 'center',
+                            width: 70,
+                            ellipsis: true,
+                            render: (value) => {
+                                return value?.nickname || '--'
+                            }
+                        },
+                        {
+                            title: '投手',
+                            dataIndex: 'putUser',
+                            key: 'putUser',
+                            align: 'center',
+                            width: 70,
+                            ellipsis: true,
+                            render: (value) => {
+                                return value?.nickname || '--'
+                            }
+                        },
+                        {
+                            title: '运营助理',
+                            dataIndex: 'userList',
+                            key: 'userList',
+                            width: 120,
+                            ellipsis: true,
+                            render: (value) => {
+                                return value?.map(item => item.nickname)?.join('、') || '--'
+                            }
+                        },
+                        {
+                            title: '状态',
+                            dataIndex: 'status',
+                            key: 'status',
+                            width: 70,
+                            align: 'center',
+                            render: (value) => {
+                                return STATUSENUM[value]
+                            }
+                        }
+                    ]}
+                    dataSource={getCorpUserChatList?.data?.data?.records}
+                    scroll={{ y: 350 }}
+                    rowKey={'corpUserId'}
+                    size='small'
+                    loading={getCorpUserChatList?.loading}
+                    pagination={{
+                        total: getCorpUserChatList?.data?.data?.total,
+                        showTotal: (total) => `共 ${total} 条数据`,
+                        showQuickJumper: true,
+                        showSizeChanger: true,
+                        pageSizeOptions: ['10', '20', '50', '100'],
+                        onChange: (pageNum, pageSize) => {
+                            setQueryParams({ ...queryParams, pageNum, pageSize })
+                            setQueryParamsNew({ ...queryParamsNew, pageNum, pageSize })
+                        }
+                    }}
+                    rowSelection={{
+                        type: 'checkbox',
+                        selectedRowKeys: editSelectedRow?.map(item => item.corpUserId),
+                        onSelect: (record, selected: any) => {
+                            if (selected) {
+                                setEditSelectedRow([...editSelectedRow, record])
+                            } else {
+                                setEditSelectedRow(editSelectedRow?.filter(item => item.corpUserId !== record.corpUserId))
+                            }
+                        },
+                        onSelectAll: (selected: any, rows: any, changeRows: any[]) => {
+                            if (selected) {
+                                setEditSelectedRow([...editSelectedRow, ...changeRows])
+                            } else {
+                                let newArr = editSelectedRow?.filter(item => changeRows.every(i => i?.corpUserId !== item?.corpUserId))
+                                setEditSelectedRow(newArr)
+                            }
+                        }
+                    }}
+                />
+            </div>
+        </div>
+    </Modal>;
+};
+
+export default SelectGroupLeaderModal;