|
@@ -1,7 +1,7 @@
|
|
|
import { inject, observer } from 'mobx-react';
|
|
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
|
import style from './index.less'
|
|
|
-import { App, Button, Card, Empty, Input, Popconfirm, Select, Space, Spin, Table, Tabs } from 'antd';
|
|
|
+import { App, Button, Card, Empty, Flex, Form, Input, Popconfirm, Select, Space, Spin, Table, Tabs } from 'antd';
|
|
|
import MassSending from './components/massSending';
|
|
|
import { useAjax } from '@/Hook/useAjax';
|
|
|
import { MediaContentProps, welcomeMsgJobTypeApi } from '@/pages/weComTask/API/weMaterial/weMaterial';
|
|
@@ -20,6 +20,7 @@ import { toJS } from 'mobx';
|
|
|
import Friends from './components/friends';
|
|
|
import SelectCwTag from '@/pages/weComTask/components/selectCwTag';
|
|
|
import SelectCorpUserGroup from '../../corpUserManage/selectCorpUserGroup';
|
|
|
+import { getBindMpListApi } from '@/pages/weComTask/API/corpUserAssign';
|
|
|
|
|
|
export const DispatchTaskCreate = React.createContext<TASK_CREATE.DispatchTaskCreate | null>(null);
|
|
|
/**
|
|
@@ -36,14 +37,17 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
const { message, modal } = App.useApp()
|
|
|
const [msgJobTypeList, setMsgJobTypeList] = useState<{ value: string, label: string }[]>([])
|
|
|
const [previewData, setPreviewData] = useState<TASK_CREATE.previewDataProps>({})
|
|
|
+ const [previewDataOld, setPreviewDataOld] = useState<TASK_CREATE.previewDataProps>({})
|
|
|
const [subVisible, setSubVisible] = useState<boolean>(false) // 选择设置名称弹窗控制
|
|
|
const [eaVisible, setEaVisible] = useState<boolean>(false)
|
|
|
const [qwVisible, setQwVisible] = useState<boolean>(false)
|
|
|
+ const [mpList, setMplist] = useState<{ label: string, value: number }[]>([])
|
|
|
const [previewContent, setPreviewContent] = useState<{ groupMsgContent?: any[], welcomeMsgContent?: any[], externalUserTransferContent?: any[] }>({})
|
|
|
|
|
|
const welcomeMsgJobType = useAjax(() => welcomeMsgJobTypeApi())//获取欢迎语类型
|
|
|
|
|
|
const addTask = useAjax((params) => addTaskApi(params))
|
|
|
+ const getBindMpList = useAjax(() => getBindMpListApi())
|
|
|
/***********************************************/
|
|
|
console.log('settings--->', settings, previewContent)
|
|
|
|
|
@@ -60,6 +64,9 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
setMsgJobTypeList(Object.keys(res.data).map(key => ({ value: key, label: res.data[key] })))
|
|
|
}
|
|
|
})
|
|
|
+ getBindMpList.run().then(res => {
|
|
|
+ setMplist(res?.data?.map((item: any) => ({ label: item.name, value: item.id })))
|
|
|
+ })
|
|
|
}, [])
|
|
|
|
|
|
// 预览
|
|
@@ -112,7 +119,10 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
platform: settings?.platform,
|
|
|
templateProductId: settings?.templateProductId,
|
|
|
id: i * row.length + (index + 1),
|
|
|
- rowSpan: index === 0 ? row.length : 0
|
|
|
+ rowSpan: index === 0 ? row.length : 0,
|
|
|
+ mpAccountId: item.corpUsers?.[0]?.mpAccountId,
|
|
|
+ mpAccountName: item.corpUsers?.[0]?.mpAccountName,
|
|
|
+ corpUserStrList: item.corpUsers?.map(item => item.corpId + '_' + item.corpUserId)
|
|
|
})
|
|
|
return true
|
|
|
})
|
|
@@ -177,7 +187,10 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
linkData,
|
|
|
miniProgramData,
|
|
|
userRowSpan: li % row.length === 0 ? row.length : 0,
|
|
|
- strategyRowSpan: strategyIndex !== dataItem.strategyIndex ? dataItem.strategyDataCount : 0
|
|
|
+ strategyRowSpan: strategyIndex !== dataItem.strategyIndex ? dataItem.strategyDataCount : 0,
|
|
|
+ mpAccountId: item.corpUsers?.[0]?.mpAccountId,
|
|
|
+ mpAccountName: item.corpUsers?.[0]?.mpAccountName,
|
|
|
+ corpUserStrList: item.corpUsers?.map(item => item.corpId + '_' + item.corpUserId)
|
|
|
})
|
|
|
strategyIndex = dataItem.strategyIndex
|
|
|
return true
|
|
@@ -372,6 +385,7 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
// }
|
|
|
if (newPreviewData && Object.keys(newPreviewData).length) {
|
|
|
setPreviewData(newPreviewData)
|
|
|
+ setPreviewDataOld(newPreviewData)
|
|
|
} else {
|
|
|
message.error('请填写至少填写一项内容')
|
|
|
}
|
|
@@ -507,7 +521,8 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
const { contentDTO, sendMode } = massSendingContent.massSendingContentDTO[settingsIndex]['sendContentDto'][sendIndex]
|
|
|
const detail: { [x: string]: any } = {
|
|
|
sendMode,
|
|
|
- contentDTO
|
|
|
+ contentDTO,
|
|
|
+ externalUserFilterName: sendItem?.externalUserFilterName
|
|
|
}
|
|
|
if (sendItem.externalUserType === 'specify') {
|
|
|
detail.externalUserFilter = {
|
|
@@ -725,8 +740,10 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+ // 重置表格
|
|
|
const onPreviewReset = () => {
|
|
|
setPreviewData({})
|
|
|
+ setPreviewDataOld({})
|
|
|
setPreviewContent({})
|
|
|
}
|
|
|
|
|
@@ -764,6 +781,31 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
setPreviewContent(newPreviewContent)
|
|
|
}, [previewContent])
|
|
|
|
|
|
+ const tableSearch = useCallback((values) => {
|
|
|
+ console.log(values)
|
|
|
+ if (values?.mpAccountIds?.length > 0 || values?.corpUserIds?.length > 0) {
|
|
|
+ const newPreviewData: TASK_CREATE.previewDataProps = {}
|
|
|
+ const corpUserStrList = values?.corpUserIds?.map(item => item.corpId + '_' + item.corpUserId)
|
|
|
+ if (previewDataOld?.welcome) {
|
|
|
+ newPreviewData.welcome = previewDataOld.welcome.filter(item => (
|
|
|
+ (values?.mpAccountIds?.length > 0 ? values.mpAccountIds.includes(item.mpAccountId) : true)
|
|
|
+ &&
|
|
|
+ (corpUserStrList?.length > 0 ? item.corpUserStrList.some(str => corpUserStrList.includes(str)) : true)
|
|
|
+ )).map(item => ({ ...item, rowSpan: 1 }))
|
|
|
+ }
|
|
|
+ if (previewDataOld?.massSending) {
|
|
|
+ newPreviewData.massSending = previewDataOld.massSending.filter(item => (
|
|
|
+ (values?.mpAccountIds?.length > 0 ? values.mpAccountIds.includes(item.mpAccountId) : true)
|
|
|
+ &&
|
|
|
+ (corpUserStrList?.length > 0 ? item.corpUserStrList.some(str => corpUserStrList.includes(str)) : true)
|
|
|
+ )).map(item => ({ ...item, userRowSpan: 1, strategyRowSpan: 1, sendDataRowSpan: 1 }))
|
|
|
+ }
|
|
|
+ setPreviewData(newPreviewData)
|
|
|
+ } else {
|
|
|
+ setPreviewData(previewDataOld)
|
|
|
+ }
|
|
|
+ }, [previewDataOld, previewData])
|
|
|
+
|
|
|
return <div className={style.create}>
|
|
|
<Spin spinning={false}>
|
|
|
<Card title={<strong>配置区</strong>} className={`${style.card} ${style.config}`}>
|
|
@@ -777,9 +819,9 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
setSettings({
|
|
|
...settings, corpUserGroups: corpUserGroups.map(item => {
|
|
|
return {
|
|
|
- ...item, corpUsers: item.corpUsers.map(item => {
|
|
|
- const { corpUserId, name, corpName, corpId, mpAccountId } = item
|
|
|
- return { corpUserId, name, corpName, corpId, mpAccountId }
|
|
|
+ ...item, corpUsers: item.corpUsers.map((item: any) => {
|
|
|
+ const { corpUserId, name, corpName, corpId, mpAccountId, mpAccountInfo } = item
|
|
|
+ return { corpUserId, name, corpName, corpId, mpAccountId, mpAccountName: mpAccountInfo.name }
|
|
|
})
|
|
|
}
|
|
|
})
|
|
@@ -915,6 +957,7 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
onConfirm={() => {
|
|
|
setSettings(undefined)
|
|
|
setPreviewData({})
|
|
|
+ setPreviewDataOld({})
|
|
|
localStorage.removeItem('TASK_CORP_CREATE')
|
|
|
}}
|
|
|
>
|
|
@@ -927,6 +970,38 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
|
|
|
<Card className={style.card} style={{ marginTop: 10, marginBottom: 10 }}>
|
|
|
{Object.keys(previewData).length > 0 ? <div style={{ minHeight: 300 }}>
|
|
|
+ <Form
|
|
|
+ layout={'inline'}
|
|
|
+ onFinish={tableSearch}
|
|
|
+ >
|
|
|
+ <Form.Item label={<strong>公众号</strong>} name="mpAccountIds">
|
|
|
+ <Select
|
|
|
+ showSearch
|
|
|
+ style={{ minWidth: 160 }}
|
|
|
+ maxTagCount={1}
|
|
|
+ placeholder="公众号"
|
|
|
+ filterOption={(input, option) =>
|
|
|
+ ((option?.label ?? '') as string).toLowerCase().includes(input.toLowerCase())
|
|
|
+ }
|
|
|
+ allowClear
|
|
|
+ mode='multiple'
|
|
|
+ options={mpList}
|
|
|
+ />
|
|
|
+ </Form.Item>
|
|
|
+
|
|
|
+ <Space.Compact>
|
|
|
+ <Button>客服组</Button>
|
|
|
+ <Form.Item name="corpUserIds">
|
|
|
+ <SelectCorpUser placeholder="请选择客服号" />
|
|
|
+ </Form.Item>
|
|
|
+ </Space.Compact>
|
|
|
+ <Form.Item>
|
|
|
+ <Space>
|
|
|
+ <Button htmlType="reset">重置</Button>
|
|
|
+ <Button type="primary" htmlType='submit'>搜索</Button>
|
|
|
+ </Space>
|
|
|
+ </Form.Item>
|
|
|
+ </Form>
|
|
|
<Tabs
|
|
|
defaultActiveKey="1"
|
|
|
items={Object.keys(previewData).map(key => ({
|
|
@@ -944,7 +1019,7 @@ const Create: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREATE.BookLis
|
|
|
</> : key === 'massSending' ? <>
|
|
|
<Table
|
|
|
dataSource={previewData[key]}
|
|
|
- columns={massSendingColumns(setContent, bookPlatForm, previewContent)}
|
|
|
+ columns={massSendingColumns(setContent, bookPlatForm, bookList, previewContent)}
|
|
|
rowKey={'id'}
|
|
|
bordered={true}
|
|
|
scroll={{ y: 550 }}
|