Pārlūkot izejas kodu

Merge branch 'develop' of http://git.zanxiangnet.com/wjx/ad-manage

wjx 4 nedēļas atpakaļ
vecāks
revīzija
da4f8cb938

+ 11 - 1
src/pages/launchSystemV3/material/cloudNew/selectCloudNew.tsx

@@ -25,6 +25,7 @@ const SelectCloudNew: React.FC<CLOUDNEW.SelectCloudNewProps> = ({ visible, defau
 
     const [uploadVisible, setUploadVisible] = useState<boolean>(false)
     const [active, setActive] = useState<number>()
+    const [tabsList, setTabList] = useState<{label: string, value: string}[]>([])
     /************************************/
 
     useEffect(() => {
@@ -33,6 +34,15 @@ const SelectCloudNew: React.FC<CLOUDNEW.SelectCloudNewProps> = ({ visible, defau
         }
     }, [])
 
+    useEffect(() => {
+        if (isGroup && (componentCount && componentCount === 500) && deliveryMode === 'DELIVERY_MODE_COMPONENT') {
+            setSCKType('4')
+            setTabList([{ label: '业务单元组件', value: '4' }])
+        } else {
+            setTabList([{ label: '素材库', value: '1' }, { label: '账户组媒体素材', value: '2' }, { label: '业务单元素材', value: '3' }, ...(deliveryMode === 'DELIVERY_MODE_COMPONENT' ? [{ label: '业务单元组件', value: '4' }] : [])])
+        }
+    }, [isGroup, componentCount, deliveryMode])
+
 
     const handleOk = () => {
         if (isGroup && num && checkedFolderList && num > checkedFolderList?.length && SCKType !== '4') {
@@ -44,7 +54,7 @@ const SelectCloudNew: React.FC<CLOUDNEW.SelectCloudNewProps> = ({ visible, defau
 
     return <Modal
         title={<div className={'SCK_header'}>
-            {[{ label: '素材库', value: '1' }, { label: '账户组媒体素材', value: '2' }, { label: '业务单元素材', value: '3' }, ...(deliveryMode === 'DELIVERY_MODE_COMPONENT' ? [{ label: '业务单元组件', value: '4' }] : [])].map(item => <div
+            {tabsList.map(item => <div
                 className={item.value === SCKType ? 'selected' : ''}
                 key={item.value}
                 onClick={() => {

+ 70 - 33
src/pages/launchSystemV3/tencentAdPutIn/create/Material/addMaterial.tsx

@@ -7,7 +7,6 @@ import { chunkArray1, getVideoImgUrl } from "@/utils/utils"
 import VideoFrameSelect from "@/pages/launchSystemV3/components/VideoFrameSelect"
 import New1Radio from "@/pages/launchSystemV3/components/New1Radio"
 import SelectCloudNew from "@/pages/launchSystemV3/material/cloudNew/selectCloudNew"
-import ImageXXX from "@/pages/launchSystemV3/components/AdsComponent/ImageXXX"
 import ImageXXXC from "@/pages/launchSystemV3/components/AdsComponent/ImageXXXC"
 
 interface Props {
@@ -163,12 +162,28 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
         }, 100)
     }
 
+    const selectGroupListImg = (num: number) => {
+        setSelectCloudData({ defaultParams: { sizeQueries: [{ width: 800, height: 800, relation: '=' }], fileSize: 400 * 1024, materialType: 'image' }, num })
+        setMaterialConfig({
+            ...materialConfig,
+            type: 'image',
+            max: num,
+            index: 20000,
+            adcreativeTemplateId: creativeTemplateId,
+            isGroup: true,
+            componentCount: 500
+        })
+        setTimeout(() => {
+            setSelectVideoVisible(true)
+        }, 100)
+    }
+
     // 获取组件化创意素材数量
     const getComponentCount = (list: any[]): string => {
         console.log('list', list)
         let arrayImgCount = 0, imageCount = 0, videoCount = 0
         list?.forEach((item: any) => {
-            if(item?.componentSubType?.includes('IMAGE_LIST')) {
+            if (item?.componentSubType?.includes('IMAGE_LIST')) {
                 arrayImgCount++
             } else if (Array.isArray(item)) {
                 arrayImgCount++
@@ -266,6 +281,20 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
                         setSelectVideoVisible(true)
                     }, 100)
                 }}>批量添加视频素材</Button>
+                {deliveryMode === 'DELIVERY_MODE_COMPONENT' && <Dropdown
+                    menu={{
+                        items: [
+                            { label: '1:1 九图', key: '4', onClick: () => { selectGroupListImg(9) } },
+                            { label: '1:1 六图', key: '1', onClick: () => { selectGroupListImg(6) } },
+                            { label: '1:1 三图', key: '2', onClick: () => { selectGroupListImg(3) } },
+                            { label: '1:1 四图', key: '3', onClick: () => { selectGroupListImg(4) } },
+                        ]
+                    }}
+                    placement="bottomLeft"
+                    arrow
+                >
+                    <Button type="link">批量添加业务单元组图</Button>
+                </Dropdown>}
             </>}
             {(dynamicGroup && dynamicGroup?.length > 1) && <Popconfirm
                 title="是否清空?"
@@ -578,7 +607,7 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
                                             {dynamicGroup?.[num]?.['list']?.map((item: any, index: number) => {
                                                 if (item?.componentSubType?.includes('IMAGE_LIST')) {
                                                     return <div className={styles.boxList_body_item} key={index}>
-                                                         <div className={styles.tag}>{item?.urlList?.length}图</div>
+                                                        <div className={styles.tag}>{item?.urlList?.length}图</div>
                                                         <div className={styles.content}>
                                                             <ImageXXXC imageList={item?.urlList} placement="top" style={{ width: '100%', height: '100%' }} />
                                                         </div>
@@ -652,40 +681,40 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
                 if (content.length > 0) {
                     if (deliveryMode === 'DELIVERY_MODE_COMPONENT' && !dynamicCreativeSwitch) { // 组件化创意
                         if (materialConfig.index === 20000) {
-                            if (materialConfig.isGroup) {
-
-                            } else {
-                                const aContent = content.map((m: any) => {
-                                    if (m?.materialType === 4) { // 组件库
-                                        if (selectCloudData?.defaultParams?.materialType === 'video') {
-                                            return { id: m?.componentId, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: true, keyFrameImageUrl: m?.key_frame_image_url, accountId: m?.organizationId, componentSubType: m?.componentSubType }
-                                        } else {
-                                            return { id: m?.componentId, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: true, accountId: m?.organizationId, componentSubType: m?.componentSubType }
-                                        }
+                            const aContent = content.map((m: any) => {
+                                if (m?.materialType === 4) { // 组件库
+                                    if (materialConfig.isGroup) { // 业务单元组件
+                                        return { id: m?.componentId, urlList: m?.oss_url, materialType: m?.materialType || 0, isUnit: true, accountId: m?.organizationId, componentSubType: m?.componentSubType }
                                     }
-                                    if (selectCloudData?.defaultParams?.materialType === 'video' && m?.materialType === 1) {
-                                        return { id: m?.id, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: m?.isUnit || false, keyFrameImageUrl: m?.key_frame_image_url, accountId: m?.owner_account_id }
-                                    }
-                                    return { id: m?.id, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: m?.isUnit || false, accountId: m?.owner_account_id }
-                                })
-                                let newDynamicGroup = dynamicGroup?.map((item: any) => {
-                                    let oldList = item?.list || []
-                                    if (oldList.length < mCount) {
-                                        let diffCount = mCount - oldList.length
-                                        let cLength = aContent.length
-                                        oldList = oldList.concat(aContent.splice(0, cLength > diffCount ? diffCount : cLength))
+                                    if (selectCloudData?.defaultParams?.materialType === 'video') {
+                                        return { id: m?.componentId, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: true, keyFrameImageUrl: m?.key_frame_image_url, accountId: m?.organizationId, componentSubType: m?.componentSubType }
+                                    } else {
+                                        return { id: m?.componentId, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: true, accountId: m?.organizationId, componentSubType: m?.componentSubType }
                                     }
-                                    return { list: oldList }
-                                })
-                                if (aContent.length) {
-                                    let newSc = chunkArray1(aContent, mCount)
-                                    let newList: any[] = newSc.map((item: any) => {
-                                        return { list: item }
-                                    })
-                                    newDynamicGroup = (newDynamicGroup || []).concat(newList)
                                 }
-                                form.setFieldsValue({ dynamicGroup: newDynamicGroup })
+                                if (selectCloudData?.defaultParams?.materialType === 'video' && m?.materialType === 1) {
+                                    return { id: m?.id, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: m?.isUnit || false, keyFrameImageUrl: m?.key_frame_image_url, accountId: m?.owner_account_id }
+                                }
+                                return { id: m?.id, url: m?.oss_url, materialType: m?.materialType || 0, isUnit: m?.isUnit || false, accountId: m?.owner_account_id }
+                            })
+                            let newDynamicGroup = dynamicGroup?.map((item: any) => {
+                                let oldList = item?.list || []
+                                if (oldList.length < mCount) {
+                                    const diffCount = mCount - oldList.length
+                                    const cLength = aContent.length
+                                    oldList = oldList.concat(aContent.splice(0, cLength > diffCount ? diffCount : cLength))
+                                }
+                                return { list: oldList }
+                            })
+                            if (aContent.length) {
+                                const newSc = chunkArray1(aContent, mCount)
+                                const newList: any[] = newSc.map((item: any) => {
+                                    return { list: item }
+                                })
+                                newDynamicGroup = (newDynamicGroup || []).concat(newList)
                             }
+                            console.log('newDynamicGroup-------->', newDynamicGroup)
+                            form.setFieldsValue({ dynamicGroup: newDynamicGroup })
                         } else {
                             const newDynamicGroup = dynamicGroup?.map((item: any, index: number) => {
                                 if (materialConfig.index === index) {
@@ -838,6 +867,14 @@ const AddMaterial: React.FC<Props> = ({ creativeTemplateId, materialData, delive
                 }
                 setSelectVideoVisible(false)
                 setSelectCloudData(undefined)
+                setMaterialConfig({
+                    type: '',//类型
+                    cloudSize: [],//素材搜索条件
+                    list: [],//素材
+                    index: 0, // 素材组下标
+                    max: 1,//素材数量
+                    sliderImgContent: undefined
+                })
             }}
         />}
     </Modal>