import NewSteps from '@/pages/weComTask/components/newSteps'; import { App, Button, Card, Form, Select } from 'antd'; import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'; import '../../global.less'; import { welcomeContentData } from '../../const'; import { PlusOutlined, MinusOutlined } from '@ant-design/icons' import MaterialNoTextMould from './materialNoTextMould'; import MaterialMould from '@/pages/weComTask/components/materialMould'; /** * 群发内容 * @param param0 * @returns */ const Content = forwardRef(({ massSendingStrategy, value, onChange }: TASK_CREATE.ContentProps, ref: React.ForwardedRef<{ handleOk: (type: string) => void }>) => { /****************************************/ const { message } = App.useApp() const ref1 = useRef(null) const [form] = Form.useForm(); const [stepsList, setStepsList] = useState([]) /****************************************/ useImperativeHandle(ref, () => ({ handleOk(type) { handleOk(type) } })); // 回填 useEffect(() => { if (!massSendingStrategy?.strategySettings) { message.error('请先设置群发策略') return } if (value && Object.keys(value).length) { filedUpdateChange(value) form.setFieldsValue(value) } else { const data = { massSendingContentDTO: massSendingStrategy.strategySettings.map(item => { return { sendContentDto: item.sendData.map(() => ({ contentDTO: [undefined], sendMode: undefined })) } }) } filedUpdateChange(data) form.setFieldsValue(data) } }, [value, massSendingStrategy]) const handleOk = (type: string) => { form.validateFields().then((values) => { console.log(values) onChange(values, type) }).catch(() => { form.submit() }); }; const filedUpdateChange = ({ massSendingContentDTO }: { massSendingContentDTO: { sendContentDto: any }[] }) => { const stepsData = massSendingContentDTO.map((item, index) => { const children = item.sendContentDto.map((ci, c_index) => { const content = ci?.contentDTO?.map((i, i_index) => { return { title: `内容${i_index + 1}`, checked: i?.length > 0, id: 'clientId' + '_' + index + '_' + c_index + 'contentDTO' } }) const contentChildren = [ { title: '发送模式', checked: ci?.sendMode || ci?.sendMode === 0, id: 'clientId' + '_' + index + '_' + c_index + 'sendMode' }, ...content ] return { title: `发送对象 ${c_index + 1}`, id: 'clientId' + '_' + index + '_' + c_index, children: contentChildren, checked: (ci?.sendMode || ci?.sendMode === 0) && contentChildren?.every(item => item.checked) } }) return { title: '策略' + (index + 1), id: 'clientId' + '_' + index, children: [ ...children, { title: '完成', checked: children?.every(item => item.checked) } ], checked: children?.every(item => item.checked) } }) setStepsList([ ...stepsData, { title: '完成', checked: stepsData?.every(item => item.checked) } ]) } return <>
{ if (e?.id) ref1.current?.querySelector('#' + e?.id)?.scrollIntoView({ behavior: 'smooth' }) }} />
{ message.error(errorFields?.[0]?.errors?.[0]) }} onFinish={handleOk} initialValues={{ massSendingContentDTO: [undefined] }} onFieldsChange={() => { console.log(form.getFieldsValue()) filedUpdateChange(form.getFieldsValue()) }} preserve={true} > {(fields) => ( <> {fields.map(({ key, name, ...restField }, index) => { return 策略 {index + 1}} style={{ background: '#fff', marginBottom: 10 }} id={'clientId' + '_' + index}> {(fields) => ( <> {fields.map(({ key, name, ...restField }, i) => { return 发送对象{i + 1} 内容配置} style={{ background: '#fff', marginBottom: 10 }} id={'clientId' + '_' + index + '_' + i} >
内容组发送模式} name={[name, 'sendMode']} rules={[{ required: true, message: '请选择内容组发送模式!' }]} >