|
@@ -1,4 +1,4 @@
|
|
-import { MinusCircleOutlined, PlusOutlined } from "@ant-design/icons"
|
|
|
|
|
|
+import { DeleteOutlined, PlusOutlined } from "@ant-design/icons"
|
|
import { Button, Card, Dropdown, Form, Menu, Modal, Popconfirm, Space, message } from "antd"
|
|
import { Button, Card, Dropdown, Form, Menu, Modal, Popconfirm, Space, message } from "antd"
|
|
import React, { useEffect, useState } from "react"
|
|
import React, { useEffect, useState } from "react"
|
|
import styles from './index.less'
|
|
import styles from './index.less'
|
|
@@ -27,6 +27,7 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
|
|
|
const [form] = Form.useForm();
|
|
const [form] = Form.useForm();
|
|
const dynamicGroup = Form.useWatch('dynamicGroup', form)
|
|
const dynamicGroup = Form.useWatch('dynamicGroup', form)
|
|
|
|
+ const mediaType = Form.useWatch('mediaType', form)
|
|
|
|
|
|
const [materialConfig, setMaterialConfig] = useState<{
|
|
const [materialConfig, setMaterialConfig] = useState<{
|
|
adcreativeTemplateId?: number,
|
|
adcreativeTemplateId?: number,
|
|
@@ -104,7 +105,14 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
const { mediaType, dynamicGroup } = values
|
|
const { mediaType, dynamicGroup } = values
|
|
if (mediaType === 1 && dynamicGroup.length < adLength) {
|
|
if (mediaType === 1 && dynamicGroup.length < adLength) {
|
|
message.error({
|
|
message.error({
|
|
- content: `创意组分配规则选择创意组平均分配到广告时,创意组总数必须大于等于广告总数。当前广告总数:${adLength},创意组总数:${dynamicGroup.length}`,
|
|
|
|
|
|
+ content: `创意组分配规则选择“平均分配到广告”时,创意组总数必须大于等于广告总数。当前广告总数:${adLength},创意组总数:${dynamicGroup.length}`,
|
|
|
|
+ duration: 8
|
|
|
|
+ })
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ if (mediaType === 2 && dynamicGroup.length > adLength) {
|
|
|
|
+ message.error({
|
|
|
|
+ content: `创意组分配规则选择“顺序分配到广告”时,创意组总数必须小于等于广告总数。当前广告总数:${adLength},创意组总数:${dynamicGroup.length}`,
|
|
duration: 8
|
|
duration: 8
|
|
})
|
|
})
|
|
return
|
|
return
|
|
@@ -186,8 +194,15 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
<Card className="cardResetCss" style={{ marginBottom: 10 }}>
|
|
<Card className="cardResetCss" style={{ marginBottom: 10 }}>
|
|
- <Form.Item name="mediaType" label={<strong>创意组分配规则</strong>} style={{ marginBottom: 0 }} rules={[{ required: true, message: '请选择营销目的!' }]}>
|
|
|
|
- <New1Radio data={[{ label: '全账号复用', value: 0 }, { label: '创意组平均分配到广告', value: 1 }]} />
|
|
|
|
|
|
+ <Form.Item name="mediaType" label={<strong>创意组分配规则</strong>} style={{ marginBottom: 0 }} rules={[{ required: true, message: '请选择创意组分配规则!' }]}>
|
|
|
|
+ <New1Radio
|
|
|
|
+ data={[{ label: '全账号复用', value: 0 }, { label: '平均分配到广告', value: 1 }, { label: '顺序分配到广告', value: 2 }]}
|
|
|
|
+ onChange={(e) => {
|
|
|
|
+ if (e === 2 && dynamicGroup?.length > adLength) {
|
|
|
|
+ form.setFieldsValue({ dynamicGroup: dynamicGroup.slice(0, adLength) })
|
|
|
|
+ }
|
|
|
|
+ }}
|
|
|
|
+ />
|
|
</Form.Item>
|
|
</Form.Item>
|
|
</Card>
|
|
</Card>
|
|
<Form.List name="dynamicGroup">
|
|
<Form.List name="dynamicGroup">
|
|
@@ -248,6 +263,7 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
className="cardResetCss"
|
|
className="cardResetCss"
|
|
key={field.key}
|
|
key={field.key}
|
|
style={{ width: ([641, 642, 643, 720, 721, 722, 1529, 618].includes(creativeTemplateId) || dynamicGroup?.length === 1) ? '100%' : 'calc(50% - 5px)' }}
|
|
style={{ width: ([641, 642, 643, 720, 721, 722, 1529, 618].includes(creativeTemplateId) || dynamicGroup?.length === 1) ? '100%' : 'calc(50% - 5px)' }}
|
|
|
|
+ extra={fields?.length > 1 && <DeleteOutlined className={styles.clear} onClick={() => remove(field.name)} style={{ color: 'red' }} />}
|
|
>
|
|
>
|
|
<Space size={30} style={{ width: '100%' }} className={styles.space}>
|
|
<Space size={30} style={{ width: '100%' }} className={styles.space}>
|
|
{deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' ? Object.keys(materialData)?.map(key => {
|
|
{deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' ? Object.keys(materialData)?.map(key => {
|
|
@@ -372,14 +388,13 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
}) : <div>
|
|
}) : <div>
|
|
11111111111111
|
|
11111111111111
|
|
</div>}
|
|
</div>}
|
|
- {fields?.length > 1 && <MinusCircleOutlined className={styles.clear} onClick={() => remove(field.name)} style={{ marginBottom: 24, color: 'red' }} />}
|
|
|
|
</Space>
|
|
</Space>
|
|
</Card>))}
|
|
</Card>))}
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
- <Form.Item style={{ marginBottom: 0, marginTop: 10 }}>
|
|
|
|
|
|
+
|
|
|
|
+ {!(mediaType === 2 && dynamicGroup?.length >= adLength) && <Form.Item style={{ marginBottom: 0, marginTop: 10 }}>
|
|
<Button type="dashed" style={{ color: '#1890ff' }} onClick={() => add()} block icon={<PlusOutlined />}>添加创意组</Button>
|
|
<Button type="dashed" style={{ color: '#1890ff' }} onClick={() => add()} block icon={<PlusOutlined />}>添加创意组</Button>
|
|
- </Form.Item>
|
|
|
|
|
|
+ </Form.Item>}
|
|
</>)}
|
|
</>)}
|
|
</Form.List>
|
|
</Form.List>
|
|
<Form.Item className="submit_pull">
|
|
<Form.Item className="submit_pull">
|