|
@@ -1,5 +1,5 @@
|
|
|
-import { DeleteOutlined, PlusOutlined } from "@ant-design/icons"
|
|
|
-import { Button, Card, Dropdown, Form, Menu, Modal, Popconfirm, Space, message } from "antd"
|
|
|
+import { CloseCircleOutlined, DeleteOutlined, PlusOutlined } from "@ant-design/icons"
|
|
|
+import { Button, Card, Dropdown, Empty, Form, Menu, Modal, Popconfirm, Space, message } from "antd"
|
|
|
import React, { useEffect, useState } from "react"
|
|
|
import styles from './index.less'
|
|
|
import VideoNews from "@/pages/launchSystemNew/components/newsModal/videoNews"
|
|
@@ -36,7 +36,8 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
list: any[],
|
|
|
index: number,
|
|
|
max: number,
|
|
|
- sliderImgContent: any
|
|
|
+ sliderImgContent: any,
|
|
|
+ isGroup?: boolean
|
|
|
}>({
|
|
|
type: '',//类型
|
|
|
cloudSize: [],//素材搜索条件
|
|
@@ -53,7 +54,6 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
/*********************************/
|
|
|
|
|
|
useEffect(() => {
|
|
|
- console.log('materialData--->', materialData)
|
|
|
if (materialData && Object.keys(materialData).length > 0) {
|
|
|
let fKey = Object.keys(materialData)[0];
|
|
|
let children = materialData[fKey]?.children
|
|
@@ -79,7 +79,6 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
setImgUploads({ ...data['children']['image'], arrayProperty: data.arrayProperty, name: 'element_story' })
|
|
|
}
|
|
|
}
|
|
|
- // setImgUploads(childrenKey?.find(item => item === 'cover_id' || item === 'list' || item === 'image_id'))
|
|
|
} else {
|
|
|
setVideoUploads({})
|
|
|
setImgUploads({})
|
|
@@ -128,35 +127,63 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
}
|
|
|
}, [value])
|
|
|
|
|
|
+ const clearTem = (index: number, count: number) => {
|
|
|
+ let newDynamicGroup = dynamicGroup?.map((item: any, i: number) => {
|
|
|
+ if (i === index) {
|
|
|
+ let oldList = item?.list?.filter((_: any, li: number) => count !== li)
|
|
|
+ return { list: oldList }
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ form.setFieldsValue({ dynamicGroup: newDynamicGroup })
|
|
|
+ }
|
|
|
+
|
|
|
+ const selectGroupImg = (index: number, num: number) => {
|
|
|
+ init({ mediaType: 'IMG', num, cloudSize: [[{ relation: '=', width: 800, height: 800 }]], maxSize: 400 * 1024 })
|
|
|
+ setMaterialConfig({
|
|
|
+ ...materialConfig,
|
|
|
+ type: 'image',
|
|
|
+ max: num,
|
|
|
+ index,
|
|
|
+ adcreativeTemplateId: creativeTemplateId,
|
|
|
+ isGroup: true
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ setSelectVideoVisible(true)
|
|
|
+ }, 100)
|
|
|
+ }
|
|
|
+
|
|
|
return <Modal
|
|
|
title={<Space>
|
|
|
<strong style={{ fontSize: 20 }}>创意素材</strong>
|
|
|
- {videoUploads && Object.keys(videoUploads)?.length > 0 && <Button type="link" onClick={() => {
|
|
|
- init({ mediaType: 'VIDEO', num: 100, cloudSize: creativeTemplateId === 1708 ? [[{ relation: '=', width: 1280, height: 720 }]] : [[{ relation: '=', width: videoUploads.restriction.videoRestriction.minWidth, height: videoUploads.restriction.videoRestriction.minHeight }]], maxSize: videoUploads.restriction.videoRestriction.fileSize * 1024 })
|
|
|
- setMaterialConfig({
|
|
|
- ...materialConfig,
|
|
|
- type: videoUploads.name,
|
|
|
- max: 1,
|
|
|
- index: 99999,
|
|
|
- adcreativeTemplateId: creativeTemplateId
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- setSelectVideoVisible(true)
|
|
|
- }, 100)
|
|
|
- }}>批量添加视频素材</Button>}
|
|
|
- {imgUploads && Object.keys(imgUploads)?.length > 0 && <Button type="link" onClick={() => {
|
|
|
- init({ mediaType: 'IMG', num: 100, cloudSize: [[{ relation: '=', width: imgUploads.restriction.imageRestriction.width, height: imgUploads.restriction.imageRestriction.height }]], maxSize: imgUploads.restriction.imageRestriction.fileSize * 1024 })
|
|
|
- setMaterialConfig({
|
|
|
- ...materialConfig,
|
|
|
- type: imgUploads.name,
|
|
|
- max: (imgUploads.name === 'image_list' || imgUploads.name === 'element_story') ? imgUploads.arrayProperty.maxNumber : 1,
|
|
|
- index: 99999,
|
|
|
- adcreativeTemplateId: creativeTemplateId
|
|
|
- })
|
|
|
- setTimeout(() => {
|
|
|
- setSelectVideoVisible(true)
|
|
|
- }, 100)
|
|
|
- }}>批量添加图片素材</Button>}
|
|
|
+ {deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' && <>
|
|
|
+ {videoUploads && Object.keys(videoUploads)?.length > 0 && <Button type="link" onClick={() => {
|
|
|
+ init({ mediaType: 'VIDEO', num: 100, cloudSize: creativeTemplateId === 1708 ? [[{ relation: '=', width: 1280, height: 720 }]] : [[{ relation: '=', width: videoUploads.restriction.videoRestriction.minWidth, height: videoUploads.restriction.videoRestriction.minHeight }]], maxSize: videoUploads.restriction.videoRestriction.fileSize * 1024 })
|
|
|
+ setMaterialConfig({
|
|
|
+ ...materialConfig,
|
|
|
+ type: videoUploads.name,
|
|
|
+ max: 1,
|
|
|
+ index: 99999,
|
|
|
+ adcreativeTemplateId: creativeTemplateId
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ setSelectVideoVisible(true)
|
|
|
+ }, 100)
|
|
|
+ }}>批量添加视频素材</Button>}
|
|
|
+ {imgUploads && Object.keys(imgUploads)?.length > 0 && <Button type="link" onClick={() => {
|
|
|
+ init({ mediaType: 'IMG', num: 100, cloudSize: [[{ relation: '=', width: imgUploads.restriction.imageRestriction.width, height: imgUploads.restriction.imageRestriction.height }]], maxSize: imgUploads.restriction.imageRestriction.fileSize * 1024 })
|
|
|
+ setMaterialConfig({
|
|
|
+ ...materialConfig,
|
|
|
+ type: imgUploads.name,
|
|
|
+ max: (imgUploads.name === 'image_list' || imgUploads.name === 'element_story') ? imgUploads.arrayProperty.maxNumber : 1,
|
|
|
+ index: 99999,
|
|
|
+ adcreativeTemplateId: creativeTemplateId
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ setSelectVideoVisible(true)
|
|
|
+ }, 100)
|
|
|
+ }}>批量添加图片素材</Button>}
|
|
|
+ </>}
|
|
|
{(dynamicGroup && dynamicGroup?.length > 1) && <Popconfirm
|
|
|
title="是否清空?"
|
|
|
onConfirm={() => form.setFieldsValue({ dynamicGroup: [undefined] })}
|
|
@@ -195,7 +222,7 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
>
|
|
|
<Card className="cardResetCss" style={{ marginBottom: 10 }}>
|
|
|
<Form.Item name="mediaType" label={<strong>创意组分配规则</strong>} style={{ marginBottom: 0 }} rules={[{ required: true, message: '请选择创意组分配规则!' }]}>
|
|
|
- <New1Radio
|
|
|
+ <New1Radio
|
|
|
data={[{ label: '全账号复用', value: 0 }, { label: '平均分配到广告', value: 1 }, { label: '顺序分配到广告', value: 2 }]}
|
|
|
onChange={(e) => {
|
|
|
if (e === 2 && dynamicGroup?.length > adLength) {
|
|
@@ -214,12 +241,25 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
{deliveryMode === 'DELIVERY_MODE_COMPONENT' && <>
|
|
|
<Dropdown
|
|
|
overlay={<Menu>
|
|
|
- <Menu.Item onClick={() => { console.log('添加9:16视频') }}>添加9:16视频</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('添加16:9视频') }}>添加16:9视频</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('添加9:16(720*1280)图片') }}>添加9:16(720*1280)图片</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('添加16:9(1280*720)图片') }}>添加16:9(1280*720)图片</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('添加1:1(800*800)图片') }}>添加1:1(800*800)图片</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('添加20:7(960*334)图片') }}>添加20:7(960*334)图片</Menu.Item>
|
|
|
+ <Menu.Item onClick={() => {
|
|
|
+ init({
|
|
|
+ mediaType: 'VIDEO', num: 15, cloudSize: [[
|
|
|
+ { relation: '=', width: 1280, height: 720 },
|
|
|
+ { relation: '=', width: 720, height: 1280 }
|
|
|
+ ]], maxSize: 512000 * 1024
|
|
|
+ })
|
|
|
+ setMaterialConfig({
|
|
|
+ ...materialConfig,
|
|
|
+ type: 'video',
|
|
|
+ max: 15 - (dynamicGroup?.[num]?.['list']?.length || 0),
|
|
|
+ index: num,
|
|
|
+ adcreativeTemplateId: creativeTemplateId,
|
|
|
+ isGroup: false
|
|
|
+ })
|
|
|
+ setTimeout(() => {
|
|
|
+ setSelectVideoVisible(true)
|
|
|
+ }, 100)
|
|
|
+ }}>添加视频</Menu.Item>
|
|
|
<Menu.Item onClick={() => {
|
|
|
init({
|
|
|
mediaType: 'IMG', num: 15, cloudSize: [[
|
|
@@ -233,14 +273,15 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
setMaterialConfig({
|
|
|
...materialConfig,
|
|
|
type: 'image',
|
|
|
- max: 15,
|
|
|
- index: 99999,
|
|
|
- adcreativeTemplateId: creativeTemplateId
|
|
|
+ max: 15 - (dynamicGroup?.[num]?.['list']?.length || 0),
|
|
|
+ index: num,
|
|
|
+ adcreativeTemplateId: creativeTemplateId,
|
|
|
+ isGroup: false
|
|
|
})
|
|
|
setTimeout(() => {
|
|
|
setSelectVideoVisible(true)
|
|
|
}, 100)
|
|
|
- }}>添加3:2(480*320)图片</Menu.Item>
|
|
|
+ }}>新增图片</Menu.Item>
|
|
|
</Menu>}
|
|
|
placement="bottomLeft"
|
|
|
arrow
|
|
@@ -249,9 +290,9 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
</Dropdown>
|
|
|
<Dropdown
|
|
|
overlay={<Menu>
|
|
|
- <Menu.Item onClick={() => { console.log('1:1 六图') }}>1:1 六图</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('1:1 三图') }}>1:1 三图</Menu.Item>
|
|
|
- <Menu.Item onClick={() => { console.log('1:1 四图') }}>1:1 四图</Menu.Item>
|
|
|
+ <Menu.Item disabled={dynamicGroup?.[num]?.['list']?.length >= 15} onClick={() => { selectGroupImg(num, 6) }}>1:1 六图</Menu.Item>
|
|
|
+ <Menu.Item disabled={dynamicGroup?.[num]?.['list']?.length >= 15} onClick={() => { selectGroupImg(num, 3) }}>1:1 三图</Menu.Item>
|
|
|
+ <Menu.Item disabled={dynamicGroup?.[num]?.['list']?.length >= 15} onClick={() => { selectGroupImg(num, 4) }}>1:1 四图</Menu.Item>
|
|
|
</Menu>}
|
|
|
placement="bottomLeft"
|
|
|
arrow
|
|
@@ -262,11 +303,11 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
</Space>}
|
|
|
className="cardResetCss"
|
|
|
key={field.key}
|
|
|
- style={{ width: ([641, 642, 643, 720, 721, 722, 1529, 618].includes(creativeTemplateId) || dynamicGroup?.length === 1) ? '100%' : 'calc(50% - 5px)' }}
|
|
|
+ style={{ width: deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' ? ([641, 642, 643, 720, 721, 722, 1529, 618].includes(creativeTemplateId) || dynamicGroup?.length === 1) ? '100%' : 'calc(50% - 5px)' : '100%' }}
|
|
|
extra={fields?.length > 1 && <DeleteOutlined className={styles.clear} onClick={() => remove(field.name)} style={{ color: 'red' }} />}
|
|
|
>
|
|
|
- <Space size={30} style={{ width: '100%' }} className={styles.space}>
|
|
|
- {deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' ? Object.keys(materialData)?.map(key => {
|
|
|
+ {deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' ? <Space size={30} style={{ width: '100%' }} className={styles.space}>
|
|
|
+ {Object.keys(materialData)?.map(key => {
|
|
|
let m = materialData[key]
|
|
|
let children = m.children
|
|
|
|
|
@@ -385,13 +426,60 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
|
|
|
return null
|
|
|
})
|
|
|
- }) : <div>
|
|
|
- 11111111111111
|
|
|
- </div>}
|
|
|
- </Space>
|
|
|
+ })}
|
|
|
+ </Space> : <Form.Item
|
|
|
+ {...field}
|
|
|
+ label={<strong>创意素材</strong>}
|
|
|
+ rules={[{ required: true, message: '请选择素材!' }]}
|
|
|
+ name={[field.name, 'list']}
|
|
|
+ >
|
|
|
+ <div className={`${styles.box} ${styles.video}`} style={{ width: '100%', height: 'auto', backgroundColor: 'rgb(247, 249, 252)' }}>
|
|
|
+ {dynamicGroup?.length && dynamicGroup?.[num]?.['list']?.length > 0 ? <div className={styles.boxList}>
|
|
|
+ <div className={styles.boxList_title}>
|
|
|
+ <span>上传素材</span>
|
|
|
+ <a onClick={() => {
|
|
|
+ let newDynamicGroup = dynamicGroup?.map((item: any, i: number) => {
|
|
|
+ if (i === num) {
|
|
|
+ return { list: [] }
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ form.setFieldsValue({ dynamicGroup: newDynamicGroup })
|
|
|
+ }}>清空</a>
|
|
|
+ </div>
|
|
|
+ <div className={styles.boxList_body}>
|
|
|
+ {dynamicGroup?.[num]?.['list']?.map((item: any, index: number) => {
|
|
|
+ if (Array.isArray(item)) {
|
|
|
+ let length = item.length
|
|
|
+ return <div className={styles.boxList_body_item} key={index}>
|
|
|
+ <div className={styles.tag}>{length}图</div>
|
|
|
+ <div className={styles.content}>
|
|
|
+ {item.map((l, i) => <img src={l?.url} key={i} style={{width: length === 6 ? 33.3 : 49.9}}/>)}
|
|
|
+ </div>
|
|
|
+ <div className={styles.clear} onClick={() => { clearTem(num, index) }}><CloseCircleOutlined /></div>
|
|
|
+ </div>
|
|
|
+ } else if (item?.url?.includes('mp4')) {
|
|
|
+ return <div className={styles.boxList_body_item} key={index}>
|
|
|
+ <div className={styles.content}>
|
|
|
+ <VideoNews src={item?.url} style={{ width: 100, height: 100 }} maskBodyStyle={{ backgroundColor: "rgba(242, 246, 254, 0.1)" }} />
|
|
|
+ </div>
|
|
|
+ <div className={styles.clear} onClick={() => { clearTem(num, index) }}><CloseCircleOutlined /></div>
|
|
|
+ </div>
|
|
|
+ } else {
|
|
|
+ return <div className={styles.boxList_body_item} key={index}>
|
|
|
+ <div className={styles.content}><img src={item?.url} /></div>
|
|
|
+ <div className={styles.clear} onClick={() => { clearTem(num, index) }}><CloseCircleOutlined /></div>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
+
|
|
|
+ })}
|
|
|
+ </div>
|
|
|
+ </div> : <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无素材内容,可通过上方添加" />}
|
|
|
+ </div>
|
|
|
+ </Form.Item>}
|
|
|
</Card>))}
|
|
|
</div>
|
|
|
-
|
|
|
+
|
|
|
{!(mediaType === 2 && dynamicGroup?.length >= adLength) && <Form.Item style={{ marginBottom: 0, marginTop: 10 }}>
|
|
|
<Button type="dashed" style={{ color: '#1890ff' }} onClick={() => add()} block icon={<PlusOutlined />}>添加创意组</Button>
|
|
|
</Form.Item>}
|
|
@@ -410,6 +498,7 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
|
|
|
{/* 选择视频素材 */}
|
|
|
{selectVideoVisible && <SelectCloud
|
|
|
+ isGroup={materialConfig?.isGroup}
|
|
|
visible={selectVideoVisible}
|
|
|
onClose={() => setSelectVideoVisible(false)}
|
|
|
sliderImgContent={materialConfig.index === 99999 ? undefined :
|
|
@@ -419,109 +508,126 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
|
|
|
}
|
|
|
onChange={(content: any) => {
|
|
|
if (content.length > 0) {
|
|
|
- if (materialConfig.index === 99999) {
|
|
|
- if (materialConfig.type === 'image_list' || materialConfig.type === 'element_story') {
|
|
|
- let urls = content?.map((item: any) => ({ id: item?.id, url: item?.url, materialType: 0 }))
|
|
|
- let max = materialConfig.max
|
|
|
- let materialsNew = dynamicGroup.map((item: any) => {
|
|
|
- let newItem = item || {}
|
|
|
- // 判断是否有字段,是否设置了值
|
|
|
- if (Object.keys(newItem).includes(materialConfig.type) && newItem[materialConfig.type]) {
|
|
|
- if (max > newItem[materialConfig.type].length && urls.length > 0) {
|
|
|
- let difference = max - newItem[materialConfig.type].length
|
|
|
- let material: any[] = []
|
|
|
- if (urls.length >= difference) {
|
|
|
- material = urls.splice(0, difference)
|
|
|
+ if (deliveryMode === 'DELIVERY_MODE_COMPONENT') { // 组件化创意
|
|
|
+ let newDynamicGroup = dynamicGroup?.map((item: any, index: number) => {
|
|
|
+ if (materialConfig.index === index) {
|
|
|
+ let oldList = item?.list || []
|
|
|
+ if (materialConfig.isGroup) {
|
|
|
+ oldList = oldList.concat([content.map((m: any) => ({ id: m?.id, url: m?.url, materialType: 0 }))])
|
|
|
+ return { list: oldList }
|
|
|
+ } else {
|
|
|
+ oldList = oldList.concat(content.map((m: any) => ({ id: m?.id, url: m?.url, materialType: 0 })))
|
|
|
+ return { list: oldList }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ form.setFieldsValue({ dynamicGroup: newDynamicGroup })
|
|
|
+ } else { // 自定义创意
|
|
|
+ if (materialConfig.index === 99999) {
|
|
|
+ if (materialConfig.type === 'image_list' || materialConfig.type === 'element_story') {
|
|
|
+ let urls = content?.map((item: any) => ({ id: item?.id, url: item?.url, materialType: 0 }))
|
|
|
+ let max = materialConfig.max
|
|
|
+ let materialsNew = dynamicGroup.map((item: any) => {
|
|
|
+ let newItem = item || {}
|
|
|
+ // 判断是否有字段,是否设置了值
|
|
|
+ if (Object.keys(newItem).includes(materialConfig.type) && newItem[materialConfig.type]) {
|
|
|
+ if (max > newItem[materialConfig.type].length && urls.length > 0) {
|
|
|
+ let difference = max - newItem[materialConfig.type].length
|
|
|
+ let material: any[] = []
|
|
|
+ if (urls.length >= difference) {
|
|
|
+ material = urls.splice(0, difference)
|
|
|
+ } else {
|
|
|
+ material = urls.splice(0, urls.length)
|
|
|
+ }
|
|
|
+ newItem[materialConfig.type] = [...newItem[materialConfig.type], ...material]
|
|
|
+ return newItem
|
|
|
} else {
|
|
|
- material = urls.splice(0, urls.length)
|
|
|
+ return newItem
|
|
|
}
|
|
|
- newItem[materialConfig.type] = [...newItem[materialConfig.type], ...material]
|
|
|
- return newItem
|
|
|
} else {
|
|
|
- return newItem
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (urls.length >= max) {
|
|
|
- let material = urls.splice(0, max)
|
|
|
- return { ...newItem, [materialConfig.type]: material }
|
|
|
- } else if (urls.length > 0) {
|
|
|
- let material = urls.splice(0, urls.length)
|
|
|
- return { ...newItem, [materialConfig.type]: material }
|
|
|
- } else {
|
|
|
- return newItem
|
|
|
+ if (urls.length >= max) {
|
|
|
+ let material = urls.splice(0, max)
|
|
|
+ return { ...newItem, [materialConfig.type]: material }
|
|
|
+ } else if (urls.length > 0) {
|
|
|
+ let material = urls.splice(0, urls.length)
|
|
|
+ return { ...newItem, [materialConfig.type]: material }
|
|
|
+ } else {
|
|
|
+ return newItem
|
|
|
+ }
|
|
|
}
|
|
|
+ })
|
|
|
+ if (urls.length > 0) {
|
|
|
+ let data = Array(Math.ceil(urls.length / max)).fill(undefined).map(item => {
|
|
|
+ if (urls.length >= max) {
|
|
|
+ let material = urls.splice(0, max)
|
|
|
+ return { [materialConfig.type]: material }
|
|
|
+ } else {
|
|
|
+ let material = urls.splice(0, urls.length)
|
|
|
+ return { [materialConfig.type]: material }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ materialsNew = [...materialsNew, ...data]
|
|
|
}
|
|
|
- })
|
|
|
- if (urls.length > 0) {
|
|
|
- let data = Array(Math.ceil(urls.length / max)).fill(undefined).map(item => {
|
|
|
- if (urls.length >= max) {
|
|
|
- let material = urls.splice(0, max)
|
|
|
- return { [materialConfig.type]: material }
|
|
|
- } else {
|
|
|
- let material = urls.splice(0, urls.length)
|
|
|
- return { [materialConfig.type]: material }
|
|
|
+ console.log('materialsNew-->', materialsNew)
|
|
|
+ form.setFieldsValue({ dynamicGroup: materialsNew })
|
|
|
+ } else {
|
|
|
+ let newMaterials = content?.map((item: any) => {
|
|
|
+ if (["short_video1", 'video_id'].includes(materialConfig.type) && mLength === 2) {
|
|
|
+ return { [materialConfig.type]: { url: item?.url, id: item?.id, materialType: 0 }, cover_id: { url: getVideoImgUrl(item?.url), id: null, materialType: 0 } }
|
|
|
}
|
|
|
+ return { [materialConfig.type]: { url: item?.url, id: item?.id, materialType: 0 } }
|
|
|
})
|
|
|
- materialsNew = [...materialsNew, ...data]
|
|
|
- }
|
|
|
- console.log('materialsNew-->', materialsNew)
|
|
|
- form.setFieldsValue({ dynamicGroup: materialsNew })
|
|
|
- } else {
|
|
|
- let newMaterials = content?.map((item: any) => {
|
|
|
- if (["short_video1", 'video_id'].includes(materialConfig.type) && mLength === 2) {
|
|
|
- return { [materialConfig.type]: { url: item?.url, id: item?.id, materialType: 0 }, cover_id: { url: getVideoImgUrl(item?.url), id: null, materialType: 0 } }
|
|
|
- }
|
|
|
- return { [materialConfig.type]: { url: item?.url, id: item?.id, materialType: 0 } }
|
|
|
- })
|
|
|
- if (newMaterials.length > 0) {
|
|
|
- if (dynamicGroup?.every((item: any) => !item)) { // 没设置过
|
|
|
- form.setFieldsValue({ dynamicGroup: newMaterials })
|
|
|
- } else { // 设置过
|
|
|
- let materialsNew = dynamicGroup.map((item: any) => {
|
|
|
- let newItem = item || {}
|
|
|
- if (Object.keys(newItem).includes(materialConfig.type) && newItem[materialConfig.type]) {
|
|
|
- return item
|
|
|
- } else {
|
|
|
- if (newMaterials.length > 0) {
|
|
|
- let material = newMaterials.splice(0, 1)
|
|
|
- return { ...newItem, ...material[0] }
|
|
|
- } else {
|
|
|
+ if (newMaterials.length > 0) {
|
|
|
+ if (dynamicGroup?.every((item: any) => !item)) { // 没设置过
|
|
|
+ form.setFieldsValue({ dynamicGroup: newMaterials })
|
|
|
+ } else { // 设置过
|
|
|
+ let materialsNew = dynamicGroup.map((item: any) => {
|
|
|
+ let newItem = item || {}
|
|
|
+ if (Object.keys(newItem).includes(materialConfig.type) && newItem[materialConfig.type]) {
|
|
|
return item
|
|
|
+ } else {
|
|
|
+ if (newMaterials.length > 0) {
|
|
|
+ let material = newMaterials.splice(0, 1)
|
|
|
+ return { ...newItem, ...material[0] }
|
|
|
+ } else {
|
|
|
+ return item
|
|
|
+ }
|
|
|
}
|
|
|
+ })
|
|
|
+ if (newMaterials.length > 0) {
|
|
|
+ materialsNew = [...materialsNew, ...newMaterials]
|
|
|
}
|
|
|
- })
|
|
|
- if (newMaterials.length > 0) {
|
|
|
- materialsNew = [...materialsNew, ...newMaterials]
|
|
|
+ form.setFieldsValue({ dynamicGroup: materialsNew })
|
|
|
}
|
|
|
- form.setFieldsValue({ dynamicGroup: materialsNew })
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else {
|
|
|
- let newDynamicGroup = dynamicGroup?.map((item: any, index: number) => {
|
|
|
- if (materialConfig.index === index) {
|
|
|
- if (materialConfig.type === 'image_list' || materialConfig.type === 'element_story') {
|
|
|
- if (item) {
|
|
|
- item[materialConfig.type] = content?.map((item: any) => ({ id: item?.id, url: item?.url, materialType: 0 }))
|
|
|
- return { ...item }
|
|
|
- } else {
|
|
|
- return { [materialConfig.type]: content?.map((item: any) => ({ id: item?.id, url: item?.url, materialType: 0 })) }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (item) {
|
|
|
- item[materialConfig.type] = { id: content[0]?.id, url: content[0]?.url, materialType: 0 }
|
|
|
- return { ...item }
|
|
|
+ } else {
|
|
|
+ let newDynamicGroup = dynamicGroup?.map((item: any, index: number) => {
|
|
|
+ if (materialConfig.index === index) {
|
|
|
+ if (materialConfig.type === 'image_list' || materialConfig.type === 'element_story') {
|
|
|
+ if (item) {
|
|
|
+ item[materialConfig.type] = content?.map((item: any) => ({ id: item?.id, url: item?.url, materialType: 0 }))
|
|
|
+ return { ...item }
|
|
|
+ } else {
|
|
|
+ return { [materialConfig.type]: content?.map((item: any) => ({ id: item?.id, url: item?.url, materialType: 0 })) }
|
|
|
+ }
|
|
|
} else {
|
|
|
- if (["short_video1", 'video_id'].includes(materialConfig.type) && mLength === 2) {
|
|
|
- return { [materialConfig.type]: { id: content[0]?.id, url: content[0]?.url, materialType: 0 }, cover_id: { id: null, url: getVideoImgUrl(content[0]?.url), materialType: 0 } }
|
|
|
+ if (item) {
|
|
|
+ item[materialConfig.type] = { id: content[0]?.id, url: content[0]?.url, materialType: 0 }
|
|
|
+ return { ...item }
|
|
|
+ } else {
|
|
|
+ if (["short_video1", 'video_id'].includes(materialConfig.type) && mLength === 2) {
|
|
|
+ return { [materialConfig.type]: { id: content[0]?.id, url: content[0]?.url, materialType: 0 }, cover_id: { id: null, url: getVideoImgUrl(content[0]?.url), materialType: 0 } }
|
|
|
+ }
|
|
|
+ return { [materialConfig.type]: { id: content[0]?.id, url: content[0]?.url, materialType: 0 } }
|
|
|
}
|
|
|
- return { [materialConfig.type]: { id: content[0]?.id, url: content[0]?.url, materialType: 0 } }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- return item
|
|
|
- })
|
|
|
- form.setFieldsValue({ dynamicGroup: newDynamicGroup })
|
|
|
+ return item
|
|
|
+ })
|
|
|
+ form.setFieldsValue({ dynamicGroup: newDynamicGroup })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
setSelectVideoVisible(false)
|