123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775 |
- import { Button, Card, Drawer, Empty, Modal, Popconfirm, Space, Spin, Table, Tabs, Typography, message } from "antd"
- import React, { useEffect, useState } from "react"
- import '../index.less'
- import style from './index.less'
- import Dynamic from "./Dynamic";
- import Material from "./Material";
- import MaterialText from "./MaterialText";
- import PageList from "./PageList";
- import { DispatchAddelivery } from ".";
- import { CheckOutlined, SearchOutlined } from "@ant-design/icons";
- import WechatAccount from "../../components/WechatAccount";
- import { cartesianProduct, distributeArray, processData, splitArrayIntoRandomChunks } from "@/utils/utils";
- import { columnsAddDynamic } from "./tableConfig";
- import { useAjax } from "@/Hook/useAjax";
- import { createDynamicTaskApi } from "@/services/adqV3";
- import TacticsS from "./TacticsS";
- import VideoChannel from "../../components/VideoChannel";
- import { getCreativeDetailsApi } from "@/services/adqV3/global";
- const { Text, Title } = Typography;
- /**
- * 新增创意
- * @returns
- */
- const AddDynamic: React.FC<PULLIN.NewAddDynamic> = ({ visible, onChange, onClose, adData: selectData, tactics, putInType }) => {
- /****************************************/
- const [addelivery, setAddelivery] = useState<PULLIN.AddeliveryProps>({ adgroups: {}, targeting: [], dynamic: {}, dynamicMaterialDTos: {}, dynamicCreativesTextDTOS: {}, mediaType: 0 })
- const { adgroups, dynamic } = addelivery
- const { marketingAssetOuterSpec, marketingCarrierType, marketingGoal, marketingSubGoal, siteSet, automaticSiteEnabled, sceneSpec } = addelivery.adgroups
- const { deliveryMode, creativeTemplateId, dynamicCreativeSwitch } = addelivery.dynamic
- const [wechatVisible, setWechatVisible] = useState<boolean>(false) // 选择微信公众号弹窗控制
- const [channelsProfileVisible, setChannelsProfileVisible] = useState<boolean>(false) // 选择微信公众号弹窗控制
- const [materialData, setMaterialData] = useState<any>({}) // 素材数据
- const [textData, setTextData] = useState<any>({})
- const [accountCreateLogs, setAccountCreateLogs] = useState<PULLIN.AccountCreateLogsProps[]>([]) // 账户
- const [tableData, setTableData] = useState<any>({})
- const [activeKey, setActiveKey] = useState<string>()
- const [dynamicCount, setDynamicCount] = useState<number>(0)
- const [adData, setAdData] = useState<any[]>(selectData)
- const [adLength, setAdLength] = useState<number>(0)
- const [adDataGroup, setAdDataGroup] = useState<{ [x: number]: any[] }>({})
- const [creativeTemplateAppellation, setCreativeTemplateAppellation] = useState<string>()
- const [creativeTemplateStyle, setCreativeTemplateStyle] = useState<string>()
- const getCreativeDetails = useAjax((params) => getCreativeDetailsApi(params))
- const createDynamicTask = useAjax((params) => createDynamicTaskApi(params))
- /****************************************/
- // 获取广告总数
- useEffect(() => {
- if (adData && adData?.length > 0) {
- setAdLength(adData.length)
- }
- }, [adData])
- useEffect(() => {
- if (creativeTemplateId) {
- let params: any = {
- marketingGoal,
- marketingTargetType: marketingAssetOuterSpec.marketingTargetType,
- marketingCarrierType,
- deliveryMode,
- creativeTemplateId,
- wechatSceneSpecPosition: sceneSpec?.wechatPosition,
- dynamicCreativeType: (deliveryMode === 'DELIVERY_MODE_COMPONENT' && !dynamicCreativeSwitch) ? 'DYNAMIC_CREATIVE_TYPE_PROGRAM' : 'DYNAMIC_CREATIVE_TYPE_COMMON'
- }
- if (automaticSiteEnabled) {
- params.automaticSiteEnabled = automaticSiteEnabled
- } else {
- params.siteSet = siteSet
- }
- params.taskType = putInType
- if (putInType === 'GAME') {
- params.marketingSubGoal = marketingSubGoal
- }
- getCreativeDetails.run(params).then(res => {
- if (res?.adcreativeTemplateStructAdpermits?.length > 0) {
- let adcreativeTemplateStructAdpermits = res?.adcreativeTemplateStructAdpermits[0]
- setCreativeTemplateAppellation(adcreativeTemplateStructAdpermits.creativeTemplateAppellation)
- setCreativeTemplateStyle(adcreativeTemplateStructAdpermits.creativeTemplateStyle)
- let creativeComponents = adcreativeTemplateStructAdpermits?.creativeComponents || []
- let result = processData(creativeComponents);
- let newMaterialData: any = {};
- let newTextData: any = {};
- Object.keys(result).forEach(key => {
- let data = result[key]
- if ((key === 'image_list' || key === 'short_video' || key === 'video' || key === 'image' || key === 'element_story') && data.required) {
- newMaterialData[key] = data
- } else if (key === 'title' || (data.required && key === 'description')) {
- newTextData[key] = data
- }
- })
- setMaterialData(newMaterialData)
- setTextData(newTextData)
- }
- })
- }
- }, [creativeTemplateId, deliveryMode, dynamicCreativeSwitch, marketingGoal, marketingAssetOuterSpec, marketingCarrierType, siteSet, sceneSpec?.wechatPosition, automaticSiteEnabled, putInType])
- useEffect(() => {
- if (adData && adData.length) {
- let adDataGroup: { [x: number]: any[] } = {}
- adData.forEach(item => {
- let accountId = item.accountId
- if (adDataGroup?.[accountId]?.length) {
- adDataGroup[accountId].push(item)
- } else {
- adDataGroup[accountId] = [item]
- }
- })
- setAdDataGroup(adDataGroup)
- }
- }, [adData])
- useEffect(() => {
- if (tactics) {
- const {
- adData,
- addelivery,
- accountCreateLogs,
- materialData,
- textData
- } = JSON.parse(tactics.strategyValue)
- setAccountCreateLogs(accountCreateLogs)
- setAddelivery(addelivery)
- setAdData(adData)
- setMaterialData(materialData)
- setTextData(textData)
- } else if (selectData?.length > 0) {
- const { siteSet, marketingCarrierType, marketingGoal, marketingTargetType, sceneSpec, automaticSiteEnabled, marketingSubGoal } = selectData[0]
- setAddelivery({ ...addelivery, adgroups: { marketingGoal, marketingSubGoal, marketingCarrierType, siteSet, automaticSiteEnabled, sceneSpec, marketingAssetOuterSpec: { marketingTargetType } } })
- let AccountSet = new Set(selectData.map(item => item.accountId))
- setAccountCreateLogs([...AccountSet].map(accountId => ({ accountId })))
- }
- }, [selectData, tactics])
- const clearData = () => {
- setTableData([])
- }
- // 预览
- const preview = () => {
- if (accountCreateLogs?.length === 0) {
- message.error('请先选择媒体账户')
- return
- }
- const { adgroups, dynamic, dynamicMaterialDTos, dynamicCreativesTextDTOS, mediaType } = addelivery
- if (!(adgroups && Object.keys(adgroups).length)) {
- message.error('请先配置广告信息')
- return
- }
- if (!(dynamic && Object.keys(dynamic).length)) {
- message.error('请先配置创意')
- return
- }
- if ((materialData && Object.keys(materialData).length) && !(dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length)) {
- message.error('请先配置创意素材')
- return
- }
- if ((textData && Object.keys(textData).length) && !(dynamicCreativesTextDTOS && Object.keys(dynamicCreativesTextDTOS).length)) {
- message.error('请先配置创意文案')
- return
- }
- if (!accountCreateLogs?.some(item => item?.pageList?.length) && !['PAGE_TYPE_WECHAT_MINI_GAME'].includes(dynamic?.creativeComponents?.mainJumpInfo?.[0]?.value?.pageType)) {
- message.error('请先选择落地页')
- return
- }
- if ((['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(adgroups?.marketingAssetOuterSpec?.marketingTargetType) || adgroups?.marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT') && !accountCreateLogs?.some(item => item?.wechatChannelList?.length)) {
- message.error('请先选择公众号')
- return
- }
- if (dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE' && !accountCreateLogs?.some(item => item?.videoChannelList?.length)) {
- message.error('请先选择视频号')
- return
- }
- let newTableData: any = {}, newDynamicCount = 0
- const textType = dynamicCreativesTextDTOS.type
- const textDto = dynamicCreativesTextDTOS?.dynamicCreativesTextDetailDTOList || []
- const textDtoLenth = textDto.length
- const dynamicGroupLength = dynamicMaterialDTos?.dynamicGroup?.length || 0
- let newDynamicGroup: any = []
- if (![910].includes(dynamic.creativeTemplateId)) {
- newDynamicGroup = dynamicMaterialDTos?.dynamicGroup || []
- if (newDynamicGroup.length > 0 && [0, 1, 2, 3, 4].includes(textType)) {
- if (textType === 0) {
- newDynamicGroup = newDynamicGroup.map((item: any) => ({ ...item, textDto: textDto?.[0] }))
- } else if (textType === 1) {
- newDynamicGroup = newDynamicGroup.map((item: any, index: number) => ({ ...item, textDto: textDto?.[index] }))
- } else if (textType === 2) {
- newDynamicGroup = newDynamicGroup.map((item: any, index: number) => ({ ...item, textDto: textDto?.[index % textDtoLenth] }))
- } else if ((textType === 3 && mediaType === 0) || (textType === 4 && mediaType === 1) || (textType === 4 && mediaType === 3)) {
- newDynamicGroup = cartesianProduct(newDynamicGroup, textDto || [{}]).map((item) => {
- let [dynamicGroup, textDtoData] = item
- return {
- ...dynamicGroup as any,
- textDto: textDtoData
- }
- })
- }
- }
- }
- // 创意组平均分配到广告逻辑
- let averageAdDynamicList: any[] = []
- if ((mediaType === 1 || mediaType === 2 || mediaType === 3) && newDynamicGroup.length) {
- let adLength = adData.length
- if (mediaType === 1) {
- if (textType === 4) {
- if (adLength > newDynamicGroup.length) {
- message.error(`创意组分配规则选择“平均分配到广告”时,创意组总数必须大于等于广告总数。当前创意组数量:${dynamicGroupLength},广告数量:${adLength}`)
- return
- }
- averageAdDynamicList = splitArrayIntoRandomChunks(newDynamicGroup, adLength)
- } else {
- if (adLength > dynamicGroupLength) {
- message.error(`创意组分配规则选择“平均分配到广告”时,创意组总数必须大于等于广告总数。当前创意组数量:${dynamicGroupLength},广告数量:${adLength}`)
- return
- }
- averageAdDynamicList = distributeArray(newDynamicGroup, adLength)
- }
- } else if (mediaType === 2) {
- if (adLength < dynamicGroupLength) {
- message.error(`创意组分配规则选择“顺序分配到广告”时,创意组总数必须小于等于广告总数。当前创意组数量:${dynamicGroupLength},广告数量:${adLength}`)
- return
- }
- } else if (mediaType === 3) {
- const dynamicDataLength = textType === 4 ? newDynamicGroup.length : dynamicGroupLength
- if (Object.keys(adDataGroup).some(key => {
- const adLength = adDataGroup[key as any].length
- if (adLength > dynamicDataLength) {
- message.error(`创意组分配规则选择“账号下平均分配到广告”时,创意组总数必须大于等于每个账号广告总数。当前创意组数量:${dynamicDataLength},当前账号(${key})下广告数量:${adLength}`)
- return true
- }
- return false
- })) {
- return
- }
- }
- }
- // 落地页平均分配判断数量
- if ([910].includes(dynamic.creativeTemplateId) && dynamic?.landingPageType === 1) {
- if (accountCreateLogs.some(item => {
- let total = adDataGroup[item.accountId].length
- let pageLength = item.pageList.length
- if (total > pageLength) {
- message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
- return true
- }
- return false
- })) {
- return
- }
- } else if (textType === 5) {
- if (dynamicGroupLength * accountCreateLogs.length !== textDtoLenth) {
- message.error(`创意文案配置错误,内容数量和所有创意数量对不上,所有创意数量:${dynamicGroupLength * accountCreateLogs.length},文案数量:${textDtoLenth}`)
- return
- }
- }
- if (textType === 1) {
- if (dynamicGroupLength !== textDtoLenth) {
- message.error(`当前创意文案是“创意组一一对应”模式,创意组总数(${dynamicGroupLength})要等于创意文案总数(${textDtoLenth})`)
- return
- }
- if (!dynamicCreativesTextDTOS.dynamicCreativesTextDetailDTOList.every((item: {}) => item && Object.keys(item).length)) {
- message.error('创意文案配置错误,内容空')
- return
- }
- }
- let accountIndex1 = 0, accountIndex2 = 0
- if (dynamic?.landingPageType === 1 && [910].includes(dynamic.creativeTemplateId)) {
- accountCreateLogs.forEach(item => {
- let adData = adDataGroup[item.accountId]
- let averageAdPageList: any[] = distributeArray(item.pageList, adData.length)
- let newData: any[] = []
- adData.forEach((ad, index) => {
- let data = [{
- id: ad.adgroupId + '_' + index,
- adgroupsDto: ad,
- dynamicDto: dynamic, // 创意信息
- }]
- newData = cartesianProduct(data, averageAdPageList[index]).map((item, index) => {
- let [d1, pageList, num] = item
- return {
- ...d1,
- id: d1.id + '_' + index,
- pageListDto: [pageList],
- dynamicDto: {
- ...d1.dynamicDto,
- dynamicCreativeName: d1.dynamicDto.dynamicCreativeName + num
- },
- rowSpan: index === 0 ? averageAdPageList[index].length : 0,
- isRowSpan: true
- }
- })
- newTableData[ad.adgroupId] = newData
- })
- newDynamicCount += item.pageList.length
- })
- } else {
- const handleDynamic = (adData: any[], averageAdDynamicList: any[]) => {
- adData.forEach((ad, index) => {
- let item = accountCreateLogs.find(a => a.accountId === ad.accountId) as PULLIN.AccountCreateLogsProps
- let averageAdDynamic = averageAdDynamicList?.[index]
- let data = [{
- id: ad.adgroupId + '_' + index,
- pageListDto: item.pageList, // 落地页
- adgroupsDto: ad,
- dynamicDto: dynamic, // 创意信息
- averageAdDynamic,
- rowSpan: ((mediaType === 1 || mediaType === 3) && textType !== 4) ? averageAdDynamic.length : ([910].includes(dynamic.creativeTemplateId) ? item.pageList?.length : (textType === 3 ? textDtoLenth * dynamicGroupLength : dynamicGroupLength)) || 1
- }]
- let newData: any[] = []
- if ([910].includes(dynamic.creativeTemplateId)) {
- newData = cartesianProduct(data, item.pageList).map((item, index) => {
- let [d1, pageList, num] = item
- return {
- ...d1,
- id: d1.id + '_' + index,
- pageListDto: [pageList],
- dynamicDto: {
- ...d1.dynamicDto,
- dynamicCreativeName: d1.dynamicDto.dynamicCreativeName + num
- }
- }
- })
- } else {
- if (mediaType === 1 || mediaType === 3) {
- data.forEach(item => {
- const { averageAdDynamic, ...ad } = item
- if (textType === 3) {
- let rowSpan = textDtoLenth * averageAdDynamic.length
- cartesianProduct(textDto, averageAdDynamic).forEach((taad: any, index) => {
- let [textValue, aad] = taad
- newData.push({
- ...ad,
- id: ad.id + '_' + index,
- dynamicGroup: aad,
- textDto: textValue,
- rowSpan
- })
- })
- } else if (textType === 4) {
- averageAdDynamic.forEach((aad: any, index: number) => {
- newData.push({
- ...ad,
- id: ad.id + '_' + index,
- dynamicGroup: aad,
- textDto: aad?.textDto,
- rowSpan: index === 0 ? averageAdDynamic.length : 0,
- isRowSpan: true
- })
- })
- } else {
- averageAdDynamic.forEach((aad: any, index: number) => {
- newData.push({
- ...ad,
- id: ad.id + '_' + index,
- dynamicGroup: aad,
- textDto: textType === 2 ? textDto?.[index % textDtoLenth] : textType === 5 ? textDto?.[accountIndex2] : aad?.textDto
- })
- accountIndex2 += 1
- })
- }
- })
- } else if (mediaType === 2) {
- data.forEach((item) => {
- const { averageAdDynamic, ...ad } = item
- if (textType === 3) {
- cartesianProduct(textDto, [newDynamicGroup[accountIndex1 % newDynamicGroup.length]]).forEach((taad: any) => {
- let [textValue, aad, index] = taad
- newData.push({
- ...ad,
- id: ad.id + '_' + index,
- dynamicGroup: aad,
- textDto: textValue,
- rowSpan: textDto.length
- })
- })
- } else {
- let { textDto: nowTextDto, ...dynamicGroup } = newDynamicGroup[accountIndex1 % newDynamicGroup.length]
- newData.push({
- ...ad,
- dynamicGroup,
- textDto: textType === 2 ? textDto?.[0] : nowTextDto,
- rowSpan: 1
- })
- }
- accountIndex1 += 1
- })
- } else {
- newData = cartesianProduct(data, newDynamicGroup.length > 0 ? newDynamicGroup : [{}]).map((item, index) => {
- let [d1, group] = item
- return {
- ...d1,
- id: d1.id + '_' + index,
- dynamicGroup: group,
- textDto: (group as any)?.textDto
- }
- })
- }
- }
- newDynamicCount += newData.length
- newTableData[ad.adgroupId] = newData
- })
- }
- if (mediaType === 3) {
- Object.keys(adDataGroup).forEach(key => {
- const newAdData = adDataGroup[key as any]
- const adLength = newAdData.length
- if (textType === 4) {
- averageAdDynamicList = splitArrayIntoRandomChunks(newDynamicGroup, adLength)
- } else {
- averageAdDynamicList = distributeArray(newDynamicGroup, adLength)
- }
- handleDynamic(newAdData, averageAdDynamicList)
- })
- } else {
- handleDynamic(adData, averageAdDynamicList)
- }
- }
- setDynamicCount(newDynamicCount)
- setActiveKey(adData?.[0].adgroupId?.toString())
- console.log('newTableData-->', newTableData)
- setTableData(newTableData)
- }
- // 提交
- const onSubmit = () => {
- const { dynamic, dynamicMaterialDTos, dynamicCreativesTextDTOS, mediaType } = addelivery
- let dynamicMaterialDTOS = []
- if (dynamic.deliveryMode === 'DELIVERY_MODE_CUSTOMIZE' || dynamic?.dynamicCreativeSwitch) {
- if ((materialData && Object.keys(materialData).length && dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length)) {
- let mType = Object.keys(materialData)[0];
- dynamicMaterialDTOS = dynamicMaterialDTos.dynamicGroup?.map((item: any) => {
- if (mType === 'image') {
- return [{
- type: mType,
- valueJson: JSON.stringify({
- value: {
- imageUrl: item?.image_id?.url,
- imageId: item?.image_id?.id,
- materialType: item?.image_id?.materialType,
- accountId: item?.image_id?.accountId
- }
- })
- }]
- } else if (mType === 'image_list' || mType === 'element_story') {
- let key = 'image_list'
- if (mType === 'element_story') {
- key = 'element_story'
- }
- let list = item?.[key]?.map((l: any) => {
- return {
- imageUrl: l?.url,
- imageId: l?.id,
- materialType: l?.materialType,
- accountId: l?.accountId
- }
- })
- return [{
- type: mType,
- valueJson: JSON.stringify({
- value: {
- list
- }
- })
- }]
- } else if (['short_video', 'video'].includes(mType)) {
- let value: any = {
- materialType: item?.video_id?.materialType || item?.short_video1?.materialType || 0,
- videoUrl: item?.video_id?.url || item?.short_video1?.url,
- videoId: item?.video_id?.id || item?.short_video1?.id,
- keyFrameImageUrl: item?.video_id?.keyFrameImageUrl || item?.short_video1?.keyFrameImageUrl,
- accountId: item?.video_id?.accountId || item?.short_video1?.accountId,
- }
- if (item?.cover_id?.url) {
- value.imageUrl = item?.cover_id?.url
- value.imageId = item?.cover_id?.id
- value.materialCoverType = item?.cover_id?.materialType
- value.accountId = item?.cover_id?.accountId
- }
- return [{
- type: mType,
- valueJson: JSON.stringify({
- value
- })
- }]
- }
- return [{
- type: mType,
- valueJson: ''
- }]
- })
- }
- } else {
- if (dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length) {
- dynamicMaterialDTOS = dynamicMaterialDTos.dynamicGroup?.map((item: { list: any[] }) => {
- return item.list.map(l => {
- if (Array.isArray(l)) {
- return {
- type: 'image_list',
- valueJson: JSON.stringify({
- value: {
- list: l?.map((i: any) => {
- return {
- imageUrl: i?.url,
- imageId: i?.id,
- materialType: i?.materialType,
- accountId: i?.accountId
- }
- })
- }
- })
- }
- } else if (l?.url?.includes('mp4') || l?.keyFrameImageUrl) {
- return {
- type: 'video',
- valueJson: JSON.stringify({
- value: {
- materialType: l?.materialType,
- videoUrl: l?.url,
- videoId: l?.id,
- keyFrameImageUrl: l?.keyFrameImageUrl,
- accountId: l?.accountId
- }
- })
- }
- } else {
- return {
- type: 'image',
- valueJson: JSON.stringify({
- value: {
- imageUrl: l?.url,
- imageId: l?.id,
- materialType: l?.materialType,
- accountId: l?.accountId
- }
- })
- }
- }
- })
- })
- }
- }
- let accountIdParamDTOMap: any = {}
- accountCreateLogs.forEach(item => {
- let { pageList, userActionSetsList, accountId, wechatChannelList, videoChannelList } = item
- let userActionSetsListDto = userActionSetsList?.map((item: any) => ({ id: item?.userActionSetId, type: item?.type })) // dataSourceId
- let map: any = {
- userActionSetsList: userActionSetsListDto,
- pageList: pageList?.map((item: { pageId: any }) => item.pageId)
- }
- if (wechatChannelList && (['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(adgroups?.marketingAssetOuterSpec?.marketingTargetType) || adgroups?.marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT' || dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_OFFICIAL_ACCOUNT_DETAIL')) {
- map.wechatChannelId = wechatChannelList?.[0]?.wechatOfficialAccountId
- }
- if (videoChannelList && dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE') {
- map.videoChannelId = videoChannelList?.[0]?.wechatChannelsAccountId
- }
- accountIdParamDTOMap[accountId] = map
- })
- dynamic.dynamicCreativeType = 'DYNAMIC_CREATIVE_TYPE_COMMON'
- if (dynamic.deliveryMode === 'DELIVERY_MODE_COMPONENT') {
- dynamic.dynamicCreativeType = dynamic?.dynamicCreativeSwitch ? 'DYNAMIC_CREATIVE_TYPE_COMMON' : 'DYNAMIC_CREATIVE_TYPE_PROGRAM'
- }
- let dynamicCreativesDTO = { ...dynamic, mediaType }
- if (dynamic.deliveryMode === 'DELIVERY_MODE_COMPONENT' && !dynamic?.dynamicCreativeSwitch) {
- dynamicCreativesDTO.creativeTemplateId = 711
- }
- let params = {
- accountAdgroupMaps: adData.map(item => `${item.accountId},${item.adgroupId}`),
- dynamicCreativesDTO,
- dynamicCreativesTextDTOS,
- dynamicMaterialDTOS,
- accountIdParamDTOMap
- }
- createDynamicTask.run(params).then(res => {
- if (res) {
- Modal.success({
- content: '创建任务提交成功',
- bodyStyle: { fontWeight: 700 },
- okText: '返回上一页',
- closable: true,
- onOk: () => {
- onChange?.()
- },
- onCancel: () => { }
- })
- }
- })
- }
- return <Drawer
- title={<strong>添加创意</strong>}
- open={visible}
- width={1500}
- onClose={onClose}
- bodyStyle={{ backgroundColor: '#f1f4fc', padding: '0 10px 10px' }}
- >
- <Space direction="vertical" style={{ width: '100%' }}>
- <Spin spinning={false}>
- <Card
- size="small"
- title={<div className={style.cardTitle}>配置区</div>}
- className={style.createAd}
- >
- <Space wrap>
- {(adgroups?.marketingAssetOuterSpec?.marketingTargetType === 'MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT' || adgroups?.marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT' || addelivery?.dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_OFFICIAL_ACCOUNT_DETAIL') && <Button type="primary" danger={!accountCreateLogs?.some(item => item?.wechatChannelList?.length)} onClick={() => { setWechatVisible(true) }}>{accountCreateLogs?.some(item => item?.wechatChannelList?.length) ? <>重新选择公众号 <CheckOutlined style={{ color: '#FFFFFF' }} /></> : '请选择公众号'}</Button>}
- {dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE' && <Button type="primary" danger={!accountCreateLogs?.some(item => item?.videoChannelList?.length)} onClick={() => { setChannelsProfileVisible(true) }}>{accountCreateLogs?.some(item => item?.videoChannelList?.length) ? <>重新选择视频号 <CheckOutlined style={{ color: '#FFFFFF' }} /></> : '请选择视频号'}</Button>}
- </Space>
- <div className={style.settingsBody}>
- <div className={style.settingsBody_content}>
- <DispatchAddelivery.Provider
- value={{
- addelivery,
- setAddelivery,
- accountCreateLogs,
- setAccountCreateLogs,
- materialData,
- setMaterialData,
- textData,
- setTextData,
- clearData,
- putInType,
- adLength
- }}>
- <div className={style.settingsBody_content_right}>
- <div className={`${style.settingsBody_content_row} ${style.row1}`}>
- <div className={style.title}>
- <span>广告信息</span>
- </div>
- <div className={style.detail}>
- <div className={style.detail_body}>
- <Title level={5} style={{ fontSize: 12 }}>已选广告</Title>
- {Object.keys(adDataGroup).map((key: any) => {
- return <div key={key}>
- <Title level={5} style={{ fontSize: 12 }}>{key}</Title>
- {adDataGroup[key]?.map((item: any) => {
- return <div key={item.adgroupId}>
- <div className={style.text}><Text ellipsis={{ tooltip: true }}>{item.adgroupName}</Text></div>
- </div>
- })}
- </div>
- })}
- </div>
- </div>
- </div>
- {/* 创意 */}
- <Dynamic
- creativeTemplateAppellation={creativeTemplateAppellation}
- creativeTemplateStyle={creativeTemplateStyle}
- />
- {/* 创意素材 */}
- <Material adData={adData} />
- </div>
- <div className={style.settingsBody_content_left}>
- {/* 创意文案 */}
- <MaterialText adDataGroup={adDataGroup} />
- {/* 落地页 */}
- <PageList adDataGroup={adDataGroup} />
- </div>
- </DispatchAddelivery.Provider>
- </div>
- </div>
- <Space className={style.bts} wrap>
- <TacticsS
- strategyValue={{
- adData: adData.map(item => {
- const { accountId, adgroupName, adgroupId, siteSet, marketingCarrierType, marketingGoal, marketingTargetType, sceneSpec, automaticSiteEnabled, marketingSubGoal } = item
- return {
- siteSet, marketingCarrierType, marketingGoal, marketingSubGoal, marketingTargetType, sceneSpec, automaticSiteEnabled,
- accountId,
- adgroupId,
- adgroupName
- }
- }),
- addelivery,
- accountCreateLogs,
- materialData,
- textData
- }}
- putInType={putInType}
- />
- <Button type='primary' onClick={preview}><SearchOutlined />预览广告</Button>
- </Space>
- {/* 选择公众号 */}
- {wechatVisible && <WechatAccount
- visible={wechatVisible}
- data={accountCreateLogs}
- onClose={() => setWechatVisible(false)}
- onChange={(e) => {
- setAccountCreateLogs(e);
- setWechatVisible(false);
- clearData()
- }}
- />}
- {/* 选择视频号 */}
- {channelsProfileVisible && <VideoChannel
- visible={channelsProfileVisible}
- data={accountCreateLogs}
- onClose={() => setChannelsProfileVisible(false)}
- onChange={(e) => {
- setAccountCreateLogs(e);
- setChannelsProfileVisible(false);
- clearData()
- }}
- />}
- </Card>
- </Spin>
- <Card
- className={style.createAd}
- >
- {activeKey && tableData && Object.keys(tableData)?.length > 0 ? <div className={style.cardBody}>
- <Tabs
- onChange={(e) => { setActiveKey(e) }}
- type="card"
- activeKey={activeKey}
- tabBarExtraContent={<Space>
- <span>创意总数:{dynamicCount}</span>
- <Popconfirm
- title="确定提交?"
- onConfirm={onSubmit}
- >
- <Button type='primary' loading={createDynamicTask.loading}>提交创建</Button>
- </Popconfirm>
- </Space>}
- >
- {adData.map(item => <Tabs.TabPane tab={item.adgroupId} key={item.adgroupId} />)}
- </Tabs>
- {addelivery?.dynamicCreativesTextDTOS?.type === 4 && <Title level={5} style={{ color: 'red', fontSize: 12 }}>因为选择的是“创意组和文案叉乘打乱后分配”模式,会随机打乱,当前预览广告下创意内容会与实际建出来的创意有偏差,请以建出来的为准</Title>}
- <div className={style.content} style={{ marginTop: 20 }}>
- <Table
- columns={columnsAddDynamic()}
- dataSource={tableData[activeKey]}
- size="small"
- bordered
- scroll={{ x: 1200 }}
- rowKey={'id'}
- pagination={{
- defaultPageSize: 50
- }}
- />
- </div>
- </div> : <div style={{ minHeight: 400, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
- <Empty description="请先完成模块配置后,再预览广告计划" />
- </div>}
- </Card>
- </Space>
- </Drawer>
- }
- export default React.memo(AddDynamic)
|