|
|
@@ -41,6 +41,7 @@ const GroupChatCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREAT
|
|
|
const [mpList, setMplist] = useState<{ label: string, value: string }[]>([])
|
|
|
const [subVisible, setSubVisible] = useState<boolean>(false) // 选择设置名称弹窗控制
|
|
|
const [projectId, setProjectId] = useState<number>()
|
|
|
+ const [estimateNumDto, setEstimateNumDto] = useState<Record<string, number>>({})
|
|
|
|
|
|
|
|
|
const welcomeMsgJobType = useAjax(() => welcomeMsgJobTypeApi())//获取业务类型
|
|
|
@@ -51,7 +52,6 @@ const GroupChatCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREAT
|
|
|
const getCreateDetails = useAjax((params) => getCreateDetailsApi(params))
|
|
|
const getPullGroupEstimateNum = useAjax((params) => getPullGroupEstimateNumApi(params))
|
|
|
/***********************************************/
|
|
|
- console.log('settings--->', settings)
|
|
|
|
|
|
useEffect(() => {
|
|
|
const project = sessionStorage.getItem('PG_OFFICIALTASKID')
|
|
|
@@ -161,19 +161,25 @@ const GroupChatCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREAT
|
|
|
return
|
|
|
}
|
|
|
const dto = settings.strategyDTO.strategyList.reduce((pre, cur, strategyIndex) => {
|
|
|
- const { groupObjectList, ...its } = cur
|
|
|
+ const { groupObjectList, id: strategyId, ...its } = cur
|
|
|
groupObjectList.forEach((item, index) => {
|
|
|
pre.push({
|
|
|
...item,
|
|
|
...its,
|
|
|
+ strategyId,
|
|
|
+ taskId: item.id,
|
|
|
strategyIndex,
|
|
|
goIndex: index,
|
|
|
+ strategyData: {
|
|
|
+ ...its,
|
|
|
+ id: strategyId
|
|
|
+ },
|
|
|
+ groupObjectData: item,
|
|
|
taskName: settings.strategyDTO.taskName
|
|
|
})
|
|
|
})
|
|
|
return pre
|
|
|
}, [])
|
|
|
- console.log('dto-->', dto)
|
|
|
let id = 1
|
|
|
const list = corpUsers.reduce((pre, corpUser) => {
|
|
|
return pre.concat(dto.map(item => {
|
|
|
@@ -189,10 +195,9 @@ const GroupChatCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREAT
|
|
|
}
|
|
|
}))
|
|
|
}, [])
|
|
|
- console.log('==================>', list)
|
|
|
setPreviewData(list)
|
|
|
setPreviewDataOld(list)
|
|
|
- getPullGroupEstimateNumFn()
|
|
|
+ setEstimateNumDto({})
|
|
|
}
|
|
|
|
|
|
// 重置表格
|
|
|
@@ -221,53 +226,60 @@ const GroupChatCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREAT
|
|
|
}, [previewDataOld, previewData])
|
|
|
|
|
|
//获取拉群预估人数
|
|
|
- const getPullGroupEstimateNumFn = useCallback(() => {
|
|
|
- const { bizType, platform, templateProductId, corpUsers, corpUserChat, robotCorpUsers, strategyDTO } = settings
|
|
|
- const params: { [x: string]: any } = {
|
|
|
- bizType,
|
|
|
- platform,
|
|
|
- templateProductId,
|
|
|
- corpChatUserIds: corpUserChat.map(item => item.value),
|
|
|
- corpRobots: robotCorpUsers?.map(item => ({
|
|
|
- corpId: item.corpId,
|
|
|
- corpUserId: item.corpUserId,
|
|
|
- corpUserName: item.name,
|
|
|
- corpName: item.corpName
|
|
|
- })),
|
|
|
- corpUsers: corpUsers.map(item => ({
|
|
|
- corpId: item.corpId,
|
|
|
- corpUserId: item.corpUserId,
|
|
|
- corpUserName: item.name,
|
|
|
- corpName: item.corpName
|
|
|
- })),
|
|
|
- strategyList: strategyDTO.strategyList.map(({ groupObjectList, ...item }) => {
|
|
|
- return {
|
|
|
- ...item,
|
|
|
- taskDetail: groupObjectList.map(go => {
|
|
|
+ const getPullGroupEstimateNumFn = useCallback((p?: Record<string, any>) => {
|
|
|
+ let params: Record<string, any> = {}
|
|
|
+ if (p) {
|
|
|
+ params = p
|
|
|
+ } else {
|
|
|
+ const { bizType, platform, templateProductId, corpUsers, corpUserChat, robotCorpUsers, strategyDTO } = settings
|
|
|
+ params ={
|
|
|
+ bizType,
|
|
|
+ platform,
|
|
|
+ templateProductId,
|
|
|
+ corpChatUserIds: corpUserChat.map(item => item.value),
|
|
|
+ corpRobots: robotCorpUsers?.map(item => ({
|
|
|
+ corpId: item.corpId,
|
|
|
+ corpUserId: item.corpUserId,
|
|
|
+ corpUserName: item.name,
|
|
|
+ corpName: item.corpName
|
|
|
+ })),
|
|
|
+ corpUsers: corpUsers.map(item => ({
|
|
|
+ corpId: item.corpId,
|
|
|
+ corpUserId: item.corpUserId,
|
|
|
+ corpUserName: item.name,
|
|
|
+ corpName: item.corpName
|
|
|
+ })),
|
|
|
+ strategyList: strategyDTO.strategyList.map(({ groupObjectList, ...item }) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ taskDetail: groupObjectList.map(go => {
|
|
|
|
|
|
- const { externalUserType, externalUserFilter, groupObjectName, tagDTO, weChatAppid, ...itgo } = go
|
|
|
- const detail = {
|
|
|
- ...itgo,
|
|
|
- groupName: groupObjectName,
|
|
|
- msgTagDTO: tagDTO
|
|
|
- }
|
|
|
- if (externalUserType === 'specify') {
|
|
|
- detail.externalUserFilter = {
|
|
|
- configName: externalUserFilter.configName,
|
|
|
- ...externalUserFilter.configContent
|
|
|
+ const { externalUserType, externalUserFilter, groupObjectName, tagDTO, weChatAppid, ...itgo } = go
|
|
|
+ const detail = {
|
|
|
+ ...itgo,
|
|
|
+ groupName: groupObjectName,
|
|
|
+ msgTagDTO: tagDTO
|
|
|
}
|
|
|
- }
|
|
|
- if (weChatAppid) {
|
|
|
- detail.mpAccountId = weChatAppid.split('_')[1]
|
|
|
- }
|
|
|
- return detail
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
+ if (externalUserType === 'specify') {
|
|
|
+ detail.externalUserFilter = {
|
|
|
+ configName: externalUserFilter.configName,
|
|
|
+ ...externalUserFilter.configContent
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (weChatAppid) {
|
|
|
+ detail.mpAccountId = weChatAppid.split('_')[1]
|
|
|
+ }
|
|
|
+ return detail
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
- console.log('getPullGroupEstimateNumApi--->', params)
|
|
|
+
|
|
|
getPullGroupEstimateNum.run(params).then(res => {
|
|
|
- console.log('getPullGroupEstimateNumApi--->', res)
|
|
|
+ if (res?.data) {
|
|
|
+ setEstimateNumDto(dto => ({ ...dto, ...res.data }))
|
|
|
+ }
|
|
|
})
|
|
|
}, [settings])
|
|
|
|
|
|
@@ -587,15 +599,23 @@ const GroupChatCreate: React.FC<{ weComTaskStore: { data: { bookList: TASK_CREAT
|
|
|
<Space>
|
|
|
<Button htmlType="reset">重置</Button>
|
|
|
<Button type="primary" htmlType='submit'>搜索</Button>
|
|
|
+ <Popconfirm
|
|
|
+ title="获取全部预计人数"
|
|
|
+ description="获取全部预计人数会很慢,确定获取全部预计人数吗?"
|
|
|
+ onConfirm={() => getPullGroupEstimateNumFn()}
|
|
|
+ >
|
|
|
+ <Button type="dashed" loading={getPullGroupEstimateNum.loading}>全部预计人数</Button>
|
|
|
+ </Popconfirm>
|
|
|
</Space>
|
|
|
</Form.Item>
|
|
|
</Form>
|
|
|
<Table
|
|
|
dataSource={previewData}
|
|
|
- columns={PreviewColumns(bookPlatForm, bookList)}
|
|
|
+ columns={PreviewColumns(bookPlatForm, bookList, estimateNumDto, getPullGroupEstimateNumFn)}
|
|
|
rowKey={'id'}
|
|
|
bordered={true}
|
|
|
scroll={{ y: 550 }}
|
|
|
+ loading={getPullGroupEstimateNum.loading}
|
|
|
pagination={{
|
|
|
showTotal(total, range) {
|
|
|
return `共 ${total} 条记录 第 ${range[0]}-${range[1]} 条`
|