index.tsx 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101
  1. import { Button, Card, Checkbox, Divider, Empty, Modal, Popconfirm, Radio, Select, Space, Spin, Table, Tabs, Tag, Tooltip, message, notification } from "antd"
  2. import React, { useEffect, useState } from "react"
  3. import style from './index.less'
  4. import '../index.less'
  5. import Selector from "@/pages/launchSystemNew/launchManage/createAd/selector"
  6. import { CheckOutlined, SearchOutlined } from "@ant-design/icons"
  7. import Ad from "./Ad"
  8. import Target from "./Target"
  9. import { getAccountListApi, getGroupListApi } from "@/services/launchAdq/subgroup"
  10. import { useAjax } from "@/Hook/useAjax"
  11. import { useModel } from "umi"
  12. import GoodsModal from "../../components/GoodsModal"
  13. import DataSourceModal from "../../components/DataSourceModal"
  14. import moment from "moment"
  15. import Dynamic from "./Dynamic"
  16. import Material from "./Material"
  17. import MaterialText from "./MaterialText"
  18. import PageList from "./PageList"
  19. import { cartesianProduct, distributeArray, processData, randomString, splitArrayIntoRandomChunks } from "@/utils/utils"
  20. import columns from "./tableConfig"
  21. import SubmitModal from "./submitModal"
  22. import { createAdgroupTaskApi, getSelectTaskDetailApi } from "@/services/adqV3"
  23. import WechatAccount from "../../components/WechatAccount"
  24. import Title from "antd/lib/typography/Title"
  25. import { getCreativeDetailsApi } from "@/services/adqV3/global"
  26. import ConversionSelect from "../../components/ConversionSelect"
  27. import VideoChannel from "../../components/VideoChannel"
  28. import Save from "./Save"
  29. import { useLocalStorageState } from "ahooks"
  30. export const DispatchAddelivery = React.createContext<PULLIN.DispatchAddelivery | null>(null);
  31. /**
  32. * 创建广告
  33. * @returns
  34. */
  35. const Create: React.FC = () => {
  36. /*******************************************/
  37. const { initialState } = useModel('@@initialState');
  38. const { getAllUserAccount } = useModel('useLaunchAdq.useAdAuthorize')
  39. const { initTargeting } = useModel('useLaunchV3.useTargeting')
  40. const [addelivery, setAddelivery] = useState<PULLIN.AddeliveryProps>({ adgroups: {}, targeting: [], dynamic: {}, dynamicMaterialDTos: {}, dynamicCreativesTextDTOS: {}, mediaType: 0 })
  41. const { marketingAssetOuterSpec, marketingCarrierType, marketingGoal, siteSet, automaticSiteEnabled, sceneSpec, isConversion } = addelivery.adgroups
  42. const { deliveryMode, creativeTemplateId, creativeComponents } = addelivery.dynamic
  43. const [accSearch, setAccSearch] = useState<string>()
  44. const [accountCreateLogs, setAccountCreateLogs] = useState<PULLIN.AccountCreateLogsProps[]>([]) // 账户
  45. const [goodsVisible, setGoodsVisible] = useState<boolean>(false) // 选择小说弹窗控制
  46. const [wechatVisible, setWechatVisible] = useState<boolean>(false) // 选择微信公众号弹窗控制
  47. const [channelsProfileVisible, setChannelsProfileVisible] = useState<boolean>(false) // 选择微信公众号弹窗控制
  48. const [sourceVisible, setSourceVisible] = useState<boolean>(false) // 选择数据源弹窗控制
  49. const [conversionVisible, setConversionVisible] = useState<boolean>(false) // 选择转化归因控制
  50. const [materialData, setMaterialData] = useState<any>({}) // 素材数据
  51. const [textData, setTextData] = useState<any>({})
  52. const [tableData, setTableData] = useState<any>({})
  53. const [activeKey, setActiveKey] = useState<string>()
  54. const [subVisible, setSubVisible] = useState<boolean>(false) // 选择设置名称弹窗控制
  55. const [adCount, setAdCount] = useState<number>(0)
  56. const [dynamicCount, setDynamicCount] = useState<number>(0)
  57. const [creativeTemplateAppellation, setCreativeTemplateAppellation] = useState<string>()
  58. const [creativeTemplateStyle, setCreativeTemplateStyle] = useState<string>()
  59. const [putInTypeList, setPutInTypeList] = useState<{ label: string, value: string }[]>([])
  60. const [putInType, setPutInType] = useLocalStorageState<'NOVEL' | 'GAME'>('PUTINTYPE');
  61. const [copyTask, setCopyTask] = useState<{ copyTaskId?: number, uuid?: string }>({})
  62. const getGroupList = useAjax(() => getGroupListApi())
  63. const createAdgroupTask = useAjax((params) => createAdgroupTaskApi(params))
  64. const getSelectTaskDetail = useAjax((params) => getSelectTaskDetailApi(params))
  65. const getCreativeDetails = useAjax((params) => getCreativeDetailsApi(params))
  66. /*******************************************/
  67. // 判断游戏还是小说短剧
  68. useEffect(() => {
  69. if (initialState?.menu?.data?.length) {
  70. const menu = initialState?.menu?.data
  71. const ADLAUNCH3 = menu.find((item: { path: string }) => item.path === "/launchSystemV3")
  72. const ADLAUNCH2 = menu.find((item: { path: string }) => item.path === "/launchSystemNew")
  73. const ACCOUNTLIST = ADLAUNCH3?.routes?.find((item: { path: string }) => item.path === "/launchSystemV3/account") || ADLAUNCH2?.routes?.find((item: { path: string }) => item.path === "/launchSystemNew/account")
  74. let newputInTypeList: { label: string, value: string }[] = []
  75. ACCOUNTLIST?.routes.forEach((item: { path: string }) => {
  76. if (item.path.includes('novel')) {
  77. newputInTypeList.push({ label: '小说/短剧投放', value: 'NOVEL' })
  78. } else if (item.path.includes('game')) {
  79. newputInTypeList.push({ label: '游戏投放', value: 'GAME' })
  80. }
  81. })
  82. setPutInTypeList(newputInTypeList);
  83. newputInTypeList.length > 0 && setPutInType(type => (type && newputInTypeList.some(item => item.value === type) ? type : newputInTypeList[0].value) as 'NOVEL' | 'GAME');
  84. }
  85. }, [initialState?.menu])
  86. useEffect(() => {
  87. // 获取账户组
  88. getGroupList.run()
  89. // 获取账户列表
  90. getAllUserAccount.run()
  91. initTargeting()
  92. }, [])
  93. useEffect(() => {
  94. if (creativeTemplateId) {
  95. let params: any = {
  96. marketingGoal,
  97. marketingTargetType: marketingAssetOuterSpec.marketingTargetType,
  98. marketingCarrierType,
  99. deliveryMode,
  100. creativeTemplateId,
  101. wechatSceneSpecPosition: sceneSpec?.wechatPosition,
  102. dynamicCreativeType: deliveryMode === 'DELIVERY_MODE_COMPONENT' ? 'DYNAMIC_CREATIVE_TYPE_PROGRAM' : 'DYNAMIC_CREATIVE_TYPE_COMMON'
  103. }
  104. if (automaticSiteEnabled) {
  105. params.automaticSiteEnabled = automaticSiteEnabled
  106. } else {
  107. params.siteSet = siteSet
  108. }
  109. getCreativeDetails.run(params).then(res => {
  110. if (res?.adcreativeTemplateStructAdpermits?.length > 0) {
  111. let adcreativeTemplateStructAdpermits = res?.adcreativeTemplateStructAdpermits[0]
  112. setCreativeTemplateAppellation(adcreativeTemplateStructAdpermits.creativeTemplateAppellation)
  113. setCreativeTemplateStyle(adcreativeTemplateStructAdpermits.creativeTemplateStyle)
  114. let creativeComponents = adcreativeTemplateStructAdpermits?.creativeComponents || []
  115. let result = processData(creativeComponents);
  116. let newMaterialData: any = {};
  117. let newTextData: any = {};
  118. Object.keys(result).forEach(key => {
  119. let data = result[key]
  120. if ((key === 'image_list' || key === 'short_video' || key === 'video' || key === 'image' || key === 'element_story') && data.required) {
  121. newMaterialData[key] = data
  122. } else if (key === 'title' || (data.required && key === 'description')) {
  123. newTextData[key] = data
  124. }
  125. })
  126. setMaterialData(newMaterialData)
  127. setTextData(newTextData)
  128. }
  129. })
  130. }
  131. }, [creativeTemplateId, deliveryMode, marketingGoal, marketingAssetOuterSpec, marketingCarrierType, siteSet, sceneSpec?.wechatPosition, automaticSiteEnabled])
  132. /** 获取分组里账号 */
  133. const getGroupAccountList = (ids: number[]) => {
  134. if (ids.length > 0) {
  135. let data = ids.map(id => getAccountListApi(id))
  136. Promise.all(data).then(res => {
  137. if (res?.length > 0 && res.every((item: { code: number }) => item.code === 200)) {
  138. let userArr: any[] = []
  139. res.forEach((item: { data: { adAccountList: { accountId: number, id: number }[] } }) => {
  140. item.data.adAccountList.forEach(acc => {
  141. let obj = userArr.find((item: { accountId: number }) => item.accountId === acc.accountId)
  142. if (!obj) {
  143. userArr.push(acc)
  144. }
  145. })
  146. })
  147. setAccountCreateLogs(userArr?.filter((item: any) => putInType === 'NOVEL' ? ['NOVEL', 'NOVEL_IAA'].includes(item.adUnitType) : putInType === 'GAME' ? ['GAME', 'GAME_IAA'].includes(item.adUnitType) : false)?.map((item) => ({ accountId: item?.accountId })))
  148. clearData()
  149. setAddelivery({ adgroups: {}, targeting: [], dynamic: {}, dynamicMaterialDTos: {}, dynamicCreativesTextDTOS: {}, mediaType: 0 })
  150. } else {
  151. message.error('操作异常')
  152. }
  153. })
  154. } else {
  155. setAccountCreateLogs([])
  156. }
  157. }
  158. /** 存为预设 */
  159. const severBd = () => {
  160. if (putInType) {
  161. localStorage.setItem(putInType === 'GAME' ? 'ADQADV3_GAME' : 'ADQADV3', JSON.stringify({
  162. addelivery,
  163. accountCreateLogs,
  164. materialData,
  165. textData,
  166. putInType
  167. }))
  168. message.success('存储成功')
  169. }
  170. }
  171. /** 清除 */
  172. const delBdPlan = ({ isRemoveItem = true }: { isRemoveItem?: boolean }) => {
  173. if (isRemoveItem) {
  174. localStorage.removeItem(putInType === 'GAME' ? 'ADQADV3_GAME' : 'ADQADV3')
  175. }
  176. setAccountCreateLogs([])
  177. setMaterialData({})
  178. setTextData({})
  179. setAddelivery({
  180. adgroups: {},
  181. targeting: [],
  182. dynamic: {},
  183. dynamicMaterialDTos: {},
  184. dynamicCreativesTextDTOS: {},
  185. mediaType: 0
  186. })
  187. setCopyTask({})
  188. setTableData({})
  189. }
  190. /**数据回填 */
  191. useEffect(() => {
  192. if (putInTypeList?.length > 0) {
  193. let taskId = sessionStorage.getItem('TASKID3.0')
  194. let adqAdData = localStorage.getItem(putInType === 'GAME' ? 'ADQADV3_GAME' : 'ADQADV3')
  195. if (taskId) {
  196. getSelectTaskDetail.run(taskId).then(res => {
  197. if (res) {
  198. const { adgroupDTO, accountIdParamVOMap, targetings, dynamicCreativesDTO: { mediaType, ...dynamic }, dynamicCreativesTextDTO, dynamicMaterialDTOS, taskType = 'NOVEL', id, uuid } = res
  199. setCopyTask({ copyTaskId: id, uuid })
  200. if (putInTypeList.some(item => item.value === taskType)) {
  201. setPutInType(() => taskType)
  202. let beginDate = adgroupDTO.beginDate
  203. let endDate = adgroupDTO.endDate
  204. if (adgroupDTO?.deepConversionSpec) {
  205. adgroupDTO.depthConversionEnabled = true
  206. } else {
  207. adgroupDTO.depthConversionEnabled = false
  208. }
  209. if (beginDate && moment(beginDate) < moment()) {
  210. beginDate = moment().format('YYYY-MM-DD')
  211. endDate = moment().add(7, 'day').format('YYYY-MM-DD')
  212. message.warning('请注意,检测投放开始日期小于今天,已自动改成今天,如需修改,请重新设置')
  213. }
  214. let dynamicGroup: any[] = []
  215. if (dynamic.deliveryMode === 'DELIVERY_MODE_CUSTOMIZE') {
  216. dynamicGroup = dynamicMaterialDTOS?.map((item: any[]) => {
  217. let { type, valueJson } = item[0]
  218. let value = JSON.parse(valueJson).value
  219. if (type === 'image') {
  220. return { image_id: { id: value.imageId, url: value.imageUrl, materialType: value.materialType } }
  221. } else if (type === 'image_list' || type === 'element_story') {
  222. return { [type]: value.list.map((l: { imageUrl: any; imageId: any; materialType: any }) => ({ url: l.imageUrl, id: l.imageId, materialType: l.materialType })) }
  223. } else if (type === 'short_video' || type === 'video') {
  224. let field = type === 'video' ? 'video_id' : 'short_video1'
  225. let videoData: any = {}
  226. videoData[field] = { materialType: value.materialType, url: value.videoUrl, id: value.videoId }
  227. if (value.imageUrl) {
  228. videoData['cover_id'] = { materialType: value.materialCoverType, url: value.imageUrl, id: value.iamgeId }
  229. }
  230. return videoData
  231. } else {
  232. return {}
  233. }
  234. })
  235. } else { // 组件化创意
  236. dynamicGroup = dynamicMaterialDTOS?.map((item: any[]) => {
  237. return {
  238. list: item?.map((i: any) => {
  239. let { type, valueJson } = i
  240. let value = JSON.parse(valueJson).value
  241. if (type === 'image') {
  242. return { id: value.imageId, url: value.imageUrl, materialType: value.materialType }
  243. } else if (type === 'image_list') {
  244. return value.list.map((l: { imageUrl: any; imageId: any; materialType: any }) => ({ url: l.imageUrl, id: l.imageId, materialType: l.materialType }))
  245. } else if (type === 'video') {
  246. return { materialType: value.materialType, url: value.videoUrl, id: value.videoId }
  247. } else {
  248. return {}
  249. }
  250. })
  251. }
  252. })
  253. }
  254. let isConversion = false
  255. setAccountCreateLogs(Object.keys(accountIdParamVOMap || {}).map(accountId => {
  256. const { productDTOS, wechatOfficialAccountsVO, pageList, landingPageVOS, userActionSetsList, conversionInfo, wechatChannelVO, wechatAppletList } = accountIdParamVOMap[accountId]
  257. let data: PULLIN.AccountCreateLogsProps = {
  258. accountId: Number(accountId),
  259. productList: productDTOS
  260. }
  261. if (wechatOfficialAccountsVO) {
  262. data.wechatChannelList = [wechatOfficialAccountsVO]
  263. }
  264. if (pageList || landingPageVOS || wechatAppletList) {
  265. data.pageList = pageList || landingPageVOS || wechatAppletList?.map((item: { appletName: any; id: any }) => ({ ...item, pageName: item.appletName, pageId: item.id }))
  266. }
  267. if (userActionSetsList) {
  268. data.userActionSetsList = userActionSetsList
  269. }
  270. if (conversionInfo) {
  271. isConversion = true
  272. data.newConversionList = [conversionInfo]
  273. }
  274. if (wechatChannelVO) {
  275. data.videoChannelList = [wechatChannelVO]
  276. }
  277. return data
  278. }))
  279. setAddelivery({
  280. adgroups: { ...adgroupDTO, isConversion, adgroupName: adgroupDTO.adgroupName + '_副本' + randomString(true, 3, 5), endDate, beginDate },
  281. targeting: targetings.map((item: any) => {
  282. const { targetingName, ...targeting } = item
  283. return { targetingName, targeting }
  284. }),
  285. dynamic,
  286. dynamicMaterialDTos: dynamicGroup.length > 0 ? { dynamicGroup } : {},
  287. dynamicCreativesTextDTOS: dynamicCreativesTextDTO,
  288. mediaType: mediaType || 0
  289. })
  290. } else {
  291. message.error(`没有${taskType === 'NOVEL' ? '小说/短剧' : taskType === 'GAME' ? '游戏' : taskType}投放权限`)
  292. }
  293. sessionStorage.removeItem('TASKID3.0')
  294. }
  295. })
  296. } else if (adqAdData) {
  297. const { addelivery, accountCreateLogs, materialData, textData } = JSON.parse(adqAdData)
  298. if (addelivery?.adgroups) {
  299. if (addelivery?.adgroups?.beginDate && moment(addelivery?.adgroups?.beginDate) < moment()) {
  300. addelivery.adgroups.beginDate = moment().format('YYYY-MM-DD')
  301. message.warning('请注意,检测投放开始日期小于今天,已自动改成今天,如需修改,请重新设置')
  302. }
  303. if (addelivery?.adgroups?.endDate && moment(addelivery?.adgroups?.endDate) < moment()) {
  304. addelivery.adgroups.endDate = moment().format('YYYY-MM-DD')
  305. message.warning('请注意,检测投放结束日期小于今天,已自动改成今天,如需修改,请重新设置')
  306. }
  307. }
  308. setAddelivery({ ...addelivery })
  309. setAccountCreateLogs(accountCreateLogs)
  310. setMaterialData(materialData)
  311. setTextData(textData)
  312. }
  313. }
  314. }, [putInType, putInTypeList])
  315. // 预览
  316. const preview = () => {
  317. if (accountCreateLogs?.length === 0) {
  318. message.error('请先选择媒体账户')
  319. return
  320. }
  321. const { adgroups, targeting, dynamic, dynamicMaterialDTos, dynamicCreativesTextDTOS, mediaType } = addelivery
  322. if (["OPTIMIZATIONGOAL_FOLLOW", "OPTIMIZATIONGOAL_PAGE_SCAN_CODE"].includes(adgroups?.optimizationGoal)) {
  323. if (!adgroups?.depthConversionEnabled) {
  324. message.error('应公司要求,”关注和加企微“请开启深度转化优化')
  325. return
  326. }
  327. if (adgroups?.deepConversionSpec?.deepConversionWorthSpec?.expectedRoi < 0.03) {
  328. notification.warning({
  329. message: '请注意',
  330. description: `当前ROI出价小于0.03,当前${adgroups?.deepConversionSpec?.deepConversionWorthSpec?.expectedRoi}`
  331. })
  332. }
  333. }
  334. if (!(adgroups && Object.keys(adgroups).length)) {
  335. message.error('请先配置广告信息')
  336. return
  337. }
  338. if (!(targeting?.length)) {
  339. message.error('请先添加定向')
  340. return
  341. }
  342. if (!(dynamic && Object.keys(dynamic).length)) {
  343. message.error('请先配置创意')
  344. return
  345. }
  346. if ((materialData && Object.keys(materialData).length) && !(dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length)) {
  347. message.error('请先配置创意素材')
  348. return
  349. }
  350. if ((textData && Object.keys(textData).length) && !(dynamicCreativesTextDTOS && Object.keys(dynamicCreativesTextDTOS).length)) {
  351. message.error('请先配置创意文案')
  352. return
  353. }
  354. if (['MARKETING_TARGET_TYPE_FICTION', 'MARKETING_TARGET_TYPE_SHORT_DRAMA'].includes(marketingAssetOuterSpec?.marketingTargetType) && !accountCreateLogs?.some(item => item?.productList?.length)) {
  355. message.error(marketingAssetOuterSpec?.marketingTargetType === 'MARKETING_TARGET_TYPE_FICTION' ? '请先选择小说' : '请先选择短剧')
  356. return
  357. }
  358. if ((['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(marketingAssetOuterSpec?.marketingTargetType) || marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT' || dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_OFFICIAL_ACCOUNT_DETAIL') && !accountCreateLogs?.some(item => item?.wechatChannelList?.length)) {
  359. message.error('请先选择公众号')
  360. return
  361. }
  362. if (creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE' && !accountCreateLogs?.some(item => item?.videoChannelList?.length)) {
  363. message.error('请先选择视频号')
  364. return
  365. }
  366. if (isConversion && !accountCreateLogs?.some(item => item?.newConversionList?.length)) {
  367. message.error('请先选择转化归因')
  368. return
  369. }
  370. if (!accountCreateLogs?.some(item => item?.pageList?.length)) {
  371. message.error('请先选择落地页')
  372. return
  373. }
  374. let newTableData: any = {}
  375. let newAdCount = 0, newdynamicCount = 0
  376. let textType = dynamicCreativesTextDTOS.type
  377. let textDto = dynamicCreativesTextDTOS?.dynamicCreativesTextDetailDTOList || []
  378. let textDtoLenth = textDto.length
  379. let dynamicGroupLength = dynamicMaterialDTos?.dynamicGroup?.length || 0
  380. let newDynamicGroup: any = []
  381. if (![910].includes(dynamic.creativeTemplateId)) {
  382. newDynamicGroup = dynamicMaterialDTos?.dynamicGroup || []
  383. if (newDynamicGroup.length > 0 && [0, 1, 2, 3, 4].includes(textType)) {
  384. if (textType === 0) {
  385. newDynamicGroup = newDynamicGroup.map((item: any) => ({ ...item, textDto: textDto?.[0] }))
  386. } else if (textType === 1) {
  387. newDynamicGroup = newDynamicGroup.map((item: any, index: number) => ({ ...item, textDto: textDto?.[index] }))
  388. } else if (textType === 2) {
  389. newDynamicGroup = newDynamicGroup.map((item: any, index: number) => ({ ...item, textDto: textDto?.[index % textDtoLenth] }))
  390. } else if ((textType === 3 && mediaType === 0) || (textType === 4 && mediaType === 1)) {
  391. newDynamicGroup = cartesianProduct(newDynamicGroup, textDto || [{}]).map((item) => {
  392. let [dynamicGroup, textDtoData] = item
  393. return {
  394. ...dynamicGroup as any,
  395. textDto: textDtoData
  396. }
  397. })
  398. }
  399. }
  400. }
  401. // 创意组平均分配到广告逻辑
  402. let averageAdDynamicList: any[] = []
  403. if ((mediaType === 1 || mediaType === 2) && newDynamicGroup.length) {
  404. let adLength = 0
  405. accountCreateLogs.forEach(item => {
  406. let productList: any[] = []
  407. if (['MARKETING_TARGET_TYPE_FICTION', 'MARKETING_TARGET_TYPE_SHORT_DRAMA'].includes(marketingAssetOuterSpec?.marketingTargetType)) { // 小说 短剧
  408. productList = item?.productList || []
  409. } else if (['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(marketingAssetOuterSpec?.marketingTargetType)) { // 公众号
  410. productList = item?.wechatChannelList || []
  411. } else {
  412. productList = [{}]
  413. }
  414. adLength += productList.length * targeting.length
  415. })
  416. if (mediaType === 1) {
  417. if (textType === 4) {
  418. if (adLength > newDynamicGroup.length) {
  419. message.error(`创意组分配规则选择“平均分配到广告”时,创意组总数必须大于等于广告总数。当前创意组数量:${dynamicGroupLength},广告数量:${adLength}`)
  420. return
  421. }
  422. averageAdDynamicList = splitArrayIntoRandomChunks(newDynamicGroup, adLength)
  423. } else {
  424. if (adLength > dynamicGroupLength) {
  425. message.error(`创意组分配规则选择“平均分配到广告”时,创意组总数必须大于等于广告总数。当前创意组数量:${dynamicGroupLength},广告数量:${adLength}`)
  426. return
  427. }
  428. averageAdDynamicList = distributeArray(newDynamicGroup, adLength)
  429. }
  430. } else if (mediaType === 2) {
  431. if (adLength < dynamicGroupLength) {
  432. message.error(`创意组分配规则选择“顺序分配到广告”时,创意组总数必须小于等于广告总数。当前创意组数量:${dynamicGroupLength},广告数量:${adLength}`)
  433. return
  434. }
  435. }
  436. }
  437. if (textType === 1) {
  438. if (dynamicGroupLength !== textDtoLenth) {
  439. message.error(`当前创意文案是“创意组一一对应”模式,创意组总数(${dynamicGroupLength})要等于创意文案总数(${textDtoLenth})`)
  440. return
  441. }
  442. if (!dynamicCreativesTextDTOS.dynamicCreativesTextDetailDTOList.every((item: {}) => item && Object.keys(item).length)) {
  443. message.error('创意文案配置错误,内容空')
  444. return
  445. }
  446. }
  447. // 落地页平均分配判断数量
  448. if ([910].includes(dynamic.creativeTemplateId) && dynamic?.landingPageType === 1) {
  449. let targetingLength = targeting.length
  450. if (accountCreateLogs.some(item => {
  451. let productListLength = item?.productList?.length || 1
  452. let total = targetingLength * productListLength
  453. let pageLength = item.pageList.length
  454. if (total > pageLength) {
  455. message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
  456. return true
  457. }
  458. return false
  459. })) {
  460. return
  461. }
  462. }
  463. let accountIndex = 0, accountIndex1 = 0
  464. accountCreateLogs.forEach(item => {
  465. let productList: any[] = [{}]
  466. if (['MARKETING_TARGET_TYPE_FICTION', 'MARKETING_TARGET_TYPE_SHORT_DRAMA'].includes(marketingAssetOuterSpec?.marketingTargetType)) { // 小说
  467. productList = item?.productList || []
  468. } else if (['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(marketingAssetOuterSpec?.marketingTargetType)) { // 公众号
  469. productList = item?.wechatChannelList || []
  470. }
  471. let data = cartesianProduct(productList, targeting).map(newD => {
  472. let [productDto, targetDto, index] = newD
  473. let suffix = '_' + item.accountId + '_' + index
  474. let averageAdDynamic = averageAdDynamicList?.[accountIndex]
  475. let dat: any = {
  476. id: item.accountId + '_' + index,
  477. accountId: item.accountId, // 账户
  478. userActionSetsList: item.userActionSetsList, // 数据源
  479. conversionList: item.newConversionList, // 转化归因
  480. pageListDto: item.pageList, // 落地页
  481. productDto, // 商品
  482. targetDto: { // 定向
  483. ...targetDto,
  484. targetingName: targetDto.targetingName + suffix
  485. },
  486. adgroupsDto: { // 广告信息
  487. ...adgroups,
  488. adgroupName: adgroups.adgroupName + suffix
  489. },
  490. dynamicDto: dynamic, // 创意信息
  491. averageAdDynamic,
  492. rowSpan: (mediaType === 1 && textType !== 4) ? averageAdDynamic.length : ([910].includes(dynamic.creativeTemplateId) ? item.pageList?.length : (textType === 3 ? textDtoLenth * dynamicGroupLength : dynamicGroupLength)) || 1
  493. }
  494. if (marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT') { // 营销载体
  495. dat.marketingCarrierDto = item?.wechatChannelList
  496. }
  497. accountIndex += 1
  498. return dat
  499. })
  500. newAdCount += data.length
  501. let newData: any[] = []
  502. if ([910].includes(dynamic.creativeTemplateId)) {
  503. if (dynamic?.landingPageType === 1) {
  504. let averageAdPageList: any[] = distributeArray(item.pageList, productList.length * targeting.length)
  505. data.forEach((item, aIndex) => {
  506. let aPageList: any[] = averageAdPageList[aIndex]
  507. aPageList.forEach((page, index) => {
  508. newData.push({
  509. ...item,
  510. id: item.id + '_' + index,
  511. pageListDto: [page],
  512. dynamicDto: {
  513. ...item.dynamicDto,
  514. dynamicCreativeName: item.dynamicDto.dynamicCreativeName + index
  515. },
  516. rowSpan: index === 0 ? aPageList.length : 0,
  517. adLength: data.length,
  518. isRowSpan: true
  519. })
  520. })
  521. })
  522. } else {
  523. newData = cartesianProduct(data, item.pageList).map((item, index) => {
  524. let [d1, pageList, num] = item
  525. return {
  526. ...d1,
  527. id: d1.id + '_' + index,
  528. pageListDto: [pageList],
  529. dynamicDto: {
  530. ...d1.dynamicDto,
  531. dynamicCreativeName: d1.dynamicDto.dynamicCreativeName + num
  532. }
  533. }
  534. })
  535. }
  536. } else {
  537. if (mediaType === 1) {
  538. data.forEach(item => {
  539. const { averageAdDynamic, ...ad } = item
  540. if (textType === 3) {
  541. let rowSpan = textDtoLenth * averageAdDynamic.length
  542. cartesianProduct(textDto, averageAdDynamic).forEach((taad: any, index) => {
  543. let [textValue, aad] = taad
  544. newData.push({
  545. ...ad,
  546. id: ad.id + '_' + index,
  547. dynamicGroup: aad,
  548. textDto: textValue,
  549. rowSpan: index === 0 ? rowSpan : 0,
  550. adLength: data.length,
  551. isRowSpan: true
  552. })
  553. })
  554. } else if (textType === 4) {
  555. averageAdDynamic.forEach((aad: any, index: number) => {
  556. newData.push({
  557. ...ad,
  558. id: ad.id + '_' + index,
  559. dynamicGroup: aad,
  560. textDto: aad?.textDto,
  561. adLength: data.length,
  562. rowSpan: index === 0 ? averageAdDynamic.length : 0,
  563. isRowSpan: true
  564. })
  565. })
  566. } else {
  567. averageAdDynamic.forEach((aad: any, index: number) => {
  568. newData.push({
  569. ...ad,
  570. id: ad.id + '_' + index,
  571. dynamicGroup: aad,
  572. textDto: aad?.textDto,
  573. adLength: data.length
  574. })
  575. })
  576. }
  577. })
  578. } else if (mediaType === 2) {
  579. data.forEach((item) => {
  580. const { averageAdDynamic, ...ad } = item
  581. if (textType === 3) {
  582. cartesianProduct(textDto, [newDynamicGroup[accountIndex1 % newDynamicGroup.length]]).forEach((taad: any, i) => {
  583. let [textValue, aad, index] = taad
  584. newData.push({
  585. ...ad,
  586. id: ad.id + '_' + index,
  587. dynamicGroup: aad,
  588. textDto: textValue,
  589. rowSpan: i === 0 ? textDto.length : 0,
  590. adLength: data.length,
  591. isRowSpan: true
  592. })
  593. })
  594. } else {
  595. let { textDto, ...dynamicGroup } = newDynamicGroup[accountIndex1 % newDynamicGroup.length]
  596. newData.push({
  597. ...ad,
  598. dynamicGroup,
  599. textDto,
  600. rowSpan: 1,
  601. adLength: data.length
  602. })
  603. }
  604. accountIndex1 += 1
  605. })
  606. } else { // 全账号复用创意组 所有广告一样的创意组
  607. newData = cartesianProduct(data, newDynamicGroup.length > 0 ? newDynamicGroup : [{}]).map((item, index) => {
  608. let [d1, group] = item
  609. return {
  610. ...d1,
  611. id: d1.id + '_' + index,
  612. dynamicGroup: group,
  613. textDto: (group as any)?.textDto,
  614. adLength: data.length
  615. }
  616. })
  617. }
  618. }
  619. newdynamicCount = newdynamicCount + newData.length
  620. newTableData[item.accountId] = newData
  621. })
  622. setAdCount(newAdCount)
  623. setDynamicCount(newdynamicCount)
  624. setActiveKey(accountCreateLogs?.[0].accountId?.toString())
  625. console.log('newTableData-->', newTableData)
  626. setTableData(newTableData)
  627. }
  628. // 提交
  629. const onSubmit = (values: any) => {
  630. const { adgroups, targeting, dynamic, dynamicMaterialDTos, dynamicCreativesTextDTOS, mediaType } = JSON.parse(JSON.stringify(addelivery)) as PULLIN.AddeliveryProps
  631. let dynamicMaterialDTOS = []
  632. if (dynamic.deliveryMode === 'DELIVERY_MODE_CUSTOMIZE') {
  633. if ((materialData && Object.keys(materialData).length && dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length)) {
  634. let mType = Object.keys(materialData)[0];
  635. dynamicMaterialDTOS = dynamicMaterialDTos.dynamicGroup?.map((item: any) => {
  636. if (mType === 'image') {
  637. return [{
  638. type: mType,
  639. valueJson: JSON.stringify({
  640. value: {
  641. imageUrl: item?.image_id?.url,
  642. imageId: item?.image_id?.id,
  643. materialType: item?.image_id?.materialType
  644. }
  645. })
  646. }]
  647. } else if (mType === 'image_list' || mType === 'element_story') {
  648. let key = 'image_list'
  649. if (mType === 'element_story') {
  650. key = 'element_story'
  651. }
  652. let list = item?.[key]?.map((l: any) => {
  653. return {
  654. imageUrl: l?.url,
  655. imageId: l?.id,
  656. materialType: l?.materialType
  657. }
  658. })
  659. return [{
  660. type: mType,
  661. valueJson: JSON.stringify({
  662. value: {
  663. list
  664. }
  665. })
  666. }]
  667. } else if (['short_video', 'video'].includes(mType)) {
  668. let value: any = {
  669. materialType: item?.video_id?.materialType || item?.short_video1?.materialType || 0,
  670. videoUrl: item?.video_id?.url || item?.short_video1?.url,
  671. videoId: item?.video_id?.id || item?.short_video1?.id
  672. }
  673. if (item?.cover_id?.url) {
  674. value.imageUrl = item?.cover_id?.url
  675. value.imageId = item?.cover_id?.id
  676. value.materialCoverType = item?.cover_id?.materialType
  677. }
  678. return [{
  679. type: mType,
  680. valueJson: JSON.stringify({
  681. value
  682. })
  683. }]
  684. }
  685. return [{
  686. type: mType,
  687. valueJson: ''
  688. }]
  689. })
  690. }
  691. } else {
  692. if (dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length) {
  693. dynamicMaterialDTOS = dynamicMaterialDTos.dynamicGroup?.map((item: { list: any[] }) => {
  694. return item.list.map(l => {
  695. if (Array.isArray(l)) {
  696. return {
  697. type: 'image_list',
  698. valueJson: JSON.stringify({
  699. value: {
  700. list: l?.map((i: any) => {
  701. return {
  702. imageUrl: i?.url,
  703. imageId: i?.id,
  704. materialType: i?.materialType
  705. }
  706. })
  707. }
  708. })
  709. }
  710. } else if (l?.url?.includes('mp4')) {
  711. return {
  712. type: 'video',
  713. valueJson: JSON.stringify({
  714. value: {
  715. materialType: l?.materialType,
  716. videoUrl: l?.url,
  717. videoId: l?.id
  718. }
  719. })
  720. }
  721. } else {
  722. return {
  723. type: 'image',
  724. valueJson: JSON.stringify({
  725. value: {
  726. imageUrl: l?.url,
  727. imageId: l?.id,
  728. materialType: l?.materialType
  729. }
  730. })
  731. }
  732. }
  733. })
  734. })
  735. }
  736. }
  737. let accountIdParamDTOMap: any = {}
  738. accountCreateLogs.forEach(item => {
  739. let { pageList, productList, userActionSetsList, accountId, wechatChannelList, newConversionList, videoChannelList } = item
  740. let userActionSetsListDto = userActionSetsList?.map((item: any) => ({ id: item?.userActionSetId, type: item?.type })) // dataSourceId
  741. let map: any = {
  742. userActionSetsList: userActionSetsListDto,
  743. pageList: pageList?.map((item: { pageId: any }) => item.pageId)
  744. }
  745. if (productList && ['MARKETING_TARGET_TYPE_FICTION', 'MARKETING_TARGET_TYPE_SHORT_DRAMA'].includes(marketingAssetOuterSpec?.marketingTargetType)) {
  746. map.productDTOS = productList?.map(item => {
  747. return { productId: item.marketingAssetId }
  748. })
  749. }
  750. if (wechatChannelList && (['MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT'].includes(marketingAssetOuterSpec?.marketingTargetType) || marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT' || dynamic?.creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_OFFICIAL_ACCOUNT_DETAIL')) {
  751. map.wechatChannelId = wechatChannelList?.[0]?.wechatOfficialAccountId
  752. }
  753. if (newConversionList && isConversion) {
  754. map.conversionId = newConversionList?.[0]?.conversionId
  755. }
  756. if (videoChannelList && creativeComponents?.brand?.[0]?.value?.jumpInfo?.pageType === 'PAGE_TYPE_WECHAT_CHANNELS_PROFILE') {
  757. map.videoChannelId = videoChannelList?.[0]?.wechatChannelsAccountId
  758. }
  759. accountIdParamDTOMap[accountId] = map
  760. })
  761. let dynamicCreativesDTO = { ...dynamic, mediaType }
  762. if (dynamic.deliveryMode === 'DELIVERY_MODE_COMPONENT') {
  763. dynamicCreativesDTO.creativeTemplateId = 711
  764. }
  765. delete adgroups?.isConversion // 前端控制新链路字段
  766. let params = {
  767. ...values,
  768. adgroupDTO: adgroups,
  769. targetings: targeting.map(item => ({ targetingName: item.targetingName, ...item?.targeting || {} })),
  770. dynamicCreativesDTO,
  771. dynamicCreativesTextDTOS,
  772. dynamicMaterialDTOS,
  773. accountIdParamDTOMap,
  774. taskType: putInType,
  775. ...copyTask
  776. }
  777. createAdgroupTask.run(params).then(res => {
  778. if (res) {
  779. Modal.success({
  780. content: '任务提交成功',
  781. bodyStyle: { fontWeight: 700 },
  782. okText: '跳转任务列表',
  783. closable: true,
  784. onOk: () => {
  785. sessionStorage.setItem('CAMPV3', values?.taskName)
  786. window.location.href = '/#/launchSystemV3/tencentAdPutIn/taskList'
  787. },
  788. onCancel: () => {
  789. setSubVisible(false)
  790. }
  791. })
  792. }
  793. })
  794. }
  795. const clearData = () => {
  796. setTableData({})
  797. }
  798. return <Space direction="vertical" style={{ width: '100%' }}>
  799. <Spin spinning={createAdgroupTask.loading || getSelectTaskDetail.loading || getCreativeDetails.loading}>
  800. <Card
  801. size="small"
  802. title={<Space size={18}>
  803. <div className={style.cardTitle}>配置区</div>
  804. {putInTypeList.length >= 1 && <Radio.Group
  805. buttonStyle="solid"
  806. value={putInType}
  807. onChange={(e) => {
  808. setPutInType(e.target.value)
  809. delBdPlan({ isRemoveItem: false })
  810. }}
  811. options={putInTypeList}
  812. optionType='button'
  813. size="small"
  814. />}
  815. </Space>}
  816. className={style.createAd}
  817. >
  818. <Space wrap>
  819. <Selector label="媒体账户组">
  820. <Select
  821. mode="multiple"
  822. style={{ minWidth: 200 }}
  823. placeholder="快捷选择媒体账户组"
  824. maxTagCount={1}
  825. allowClear
  826. bordered={false}
  827. filterOption={(input: any, option: any) => {
  828. return option!.children?.toString().toLowerCase().includes(input.toLowerCase())
  829. }}
  830. onChange={(e) => { getGroupAccountList(e) }}
  831. >
  832. {getGroupList?.data && getGroupList?.data?.map((item: any) => <Select.Option value={item.groupId} key={item.groupId}>{item.groupName}</Select.Option>)}
  833. </Select>
  834. </Selector>
  835. <Selector label="媒体账户">
  836. <Select
  837. mode="multiple"
  838. style={{ minWidth: 200, maxWidth: 500 }}
  839. placeholder="媒体账户(多个,,空格换行)"
  840. maxTagCount={1}
  841. allowClear
  842. bordered={false}
  843. maxTagPlaceholder={
  844. <Tooltip
  845. color="#FFF"
  846. title={<span style={{ color: '#000' }}>
  847. {accountCreateLogs?.filter((item, index) => index !== 0)
  848. ?.map((item, index) => <Tag
  849. key={index}
  850. closable
  851. onClose={() => {
  852. setAccountCreateLogs(accountCreateLogs?.filter(item1 => item1.accountId !== item.accountId))
  853. }}
  854. >{item.accountId}</Tag>)}</span>
  855. }
  856. >
  857. <span>+{accountCreateLogs?.length > 1 ? accountCreateLogs.length - 1 : 0}</span>
  858. </Tooltip>
  859. }
  860. autoClearSearchValue={false}
  861. filterOption={(input: any, option: any) => {
  862. let newInput: string[] = input ? input?.split(/[,,\n\s]+/ig).filter((item: any) => item) : []
  863. return newInput?.some(val => option!.children?.toString().toLowerCase()?.includes(val))
  864. }}
  865. value={accountCreateLogs?.map(item => item?.accountId)}
  866. onChange={(e) => {
  867. setAccountCreateLogs(e?.map((item: any) => ({ accountId: item })))
  868. }}
  869. searchValue={accSearch}
  870. onSearch={(val) => {
  871. setAccSearch(val)
  872. }}
  873. dropdownRender={menu => (
  874. <>
  875. {menu}
  876. <Divider style={{ margin: '8px 0' }} />
  877. <Space style={{ padding: '0 8px 4px' }}>
  878. <Checkbox onChange={(e) => {
  879. let data = []
  880. if (e.target.checked) {
  881. data = JSON.parse(JSON.stringify(getAllUserAccount?.data?.data?.filter((item: any) => putInType === 'NOVEL' ? ['NOVEL', 'NOVEL_IAA'].includes(item.adUnitType) : putInType === 'GAME' ? ['GAME', 'GAME_IAA'].includes(item.adUnitType) : false)))
  882. if (accSearch) {
  883. let newAccSearch = accSearch?.split(/[,,\n\s]+/ig).filter((item: any) => item)
  884. data = data?.filter((item: any) => newAccSearch?.some(val => item!.accountId?.toString().toLowerCase()?.includes(val)))
  885. }
  886. }
  887. setAccountCreateLogs(data?.map((item: any) => ({ accountId: item?.accountId })))
  888. }}>全选</Checkbox>
  889. </Space>
  890. </>
  891. )}
  892. >
  893. {getAllUserAccount?.data?.data?.filter((item: any) => putInType === 'NOVEL' ? ['NOVEL', 'NOVEL_IAA'].includes(item.adUnitType) : putInType === 'GAME' ? ['GAME', 'GAME_IAA'].includes(item.adUnitType) : false)?.map((item: any) => <Select.Option value={item.accountId} key={item.id}>{item.remark ? item.accountId + '_' + item.remark : item.accountId}</Select.Option>)}
  894. </Select>
  895. </Selector>
  896. {accountCreateLogs?.length > 0 && <>
  897. {['MARKETING_TARGET_TYPE_FICTION', 'MARKETING_TARGET_TYPE_SHORT_DRAMA'].includes(marketingAssetOuterSpec?.marketingTargetType) && <Button type="primary" danger={!accountCreateLogs?.some(item => item?.productList?.length)} onClick={() => { setGoodsVisible(true) }}>{accountCreateLogs?.some(item => item?.productList?.length) ? <>重新选择{marketingAssetOuterSpec?.marketingTargetType === 'MARKETING_TARGET_TYPE_FICTION' ? '小说' : '短剧'} <CheckOutlined style={{ color: '#FFFFFF' }} /></> : `请选择${marketingAssetOuterSpec?.marketingTargetType === 'MARKETING_TARGET_TYPE_FICTION' ? '小说' : '短剧'}`}</Button>}
  898. {(marketingAssetOuterSpec?.marketingTargetType === 'MARKETING_TARGET_TYPE_WECHAT_OFFICIAL_ACCOUNT' || marketingCarrierType === 'MARKETING_CARRIER_TYPE_WECHAT_OFFICIAL_ACCOUNT' || 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>}
  899. {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>}
  900. {!isConversion ?
  901. <Button onClick={() => { setSourceVisible(true) }}>精准匹配归因(选填){accountCreateLogs?.some(item => item?.userActionSetsList?.length) && <CheckOutlined style={{ color: accountCreateLogs?.every(item => item?.userActionSetsList?.length) ? '#1890ff' : '#52C41A' }} />}</Button>
  902. :
  903. <Button type="primary" danger={!accountCreateLogs?.some(item => item?.newConversionList?.length)} onClick={() => { setConversionVisible(true) }}>{accountCreateLogs?.some(item => item?.newConversionList?.length) ? <>重新选择转化归因<CheckOutlined style={{ color: '#FFF' }} /></> : '请选择转化归因'}</Button>
  904. }
  905. </>}
  906. </Space>
  907. <div className={style.settingsBody}>
  908. <div className={style.settingsBody_content}>
  909. <DispatchAddelivery.Provider
  910. value={{
  911. addelivery,
  912. setAddelivery,
  913. accountCreateLogs,
  914. setAccountCreateLogs,
  915. materialData,
  916. setMaterialData,
  917. textData,
  918. setTextData,
  919. clearData,
  920. putInType
  921. }}>
  922. <div className={style.settingsBody_content_right}>
  923. {/* 广告信息 */}
  924. <Ad />
  925. {/* 定向 */}
  926. <Target />
  927. {/* 创意 */}
  928. <Dynamic
  929. creativeTemplateAppellation={creativeTemplateAppellation}
  930. creativeTemplateStyle={creativeTemplateStyle}
  931. />
  932. {/* 创意素材 */}
  933. <Material />
  934. </div>
  935. <div className={style.settingsBody_content_left}>
  936. {/* 创意文案 */}
  937. <MaterialText />
  938. {/* 落地页 */}
  939. <PageList />
  940. </div>
  941. </DispatchAddelivery.Provider>
  942. </div>
  943. </div>
  944. <Space className={style.bts} wrap>
  945. <Save addelivery={addelivery} />
  946. <Button type='primary' onClick={severBd}>存为预设</Button>
  947. <Popconfirm
  948. title="确定清空?"
  949. onConfirm={() => delBdPlan({})}
  950. >
  951. <Button>清空配置/预设</Button>
  952. </Popconfirm>
  953. <Button type='primary' onClick={preview}><SearchOutlined />预览广告</Button>
  954. </Space>
  955. {/* 选择小说 */}
  956. {goodsVisible && <GoodsModal
  957. marketingTargetType={marketingAssetOuterSpec?.marketingTargetType}
  958. visible={goodsVisible}
  959. data={accountCreateLogs}
  960. onClose={() => setGoodsVisible(false)}
  961. onChange={(e) => {
  962. setAccountCreateLogs(e);
  963. setGoodsVisible(false);
  964. clearData()
  965. }}
  966. />}
  967. {/* 选择数据源 */}
  968. {sourceVisible && <DataSourceModal
  969. visible={sourceVisible}
  970. data={accountCreateLogs}
  971. onClose={() => setSourceVisible(false)}
  972. onChange={(e) => {
  973. setAccountCreateLogs(e);
  974. setSourceVisible(false);
  975. clearData()
  976. }}
  977. />}
  978. {/* 选择公众号 */}
  979. {wechatVisible && <WechatAccount
  980. visible={wechatVisible}
  981. data={accountCreateLogs}
  982. onClose={() => setWechatVisible(false)}
  983. onChange={(e) => {
  984. setAccountCreateLogs(e);
  985. setWechatVisible(false);
  986. clearData()
  987. }}
  988. />}
  989. {/* 选择视频号 */}
  990. {channelsProfileVisible && <VideoChannel
  991. visible={channelsProfileVisible}
  992. data={accountCreateLogs}
  993. onClose={() => setChannelsProfileVisible(false)}
  994. onChange={(e) => {
  995. setAccountCreateLogs(e);
  996. setChannelsProfileVisible(false);
  997. clearData()
  998. }}
  999. />}
  1000. {/* 转化归因 */}
  1001. {conversionVisible && <ConversionSelect
  1002. adgroups={addelivery.adgroups}
  1003. putInType={putInType}
  1004. visible={conversionVisible}
  1005. data={accountCreateLogs}
  1006. onClose={() => setConversionVisible(false)}
  1007. onChange={(e) => {
  1008. setAccountCreateLogs(e);
  1009. setConversionVisible(false);
  1010. clearData()
  1011. }}
  1012. />}
  1013. </Card>
  1014. </Spin>
  1015. <Card
  1016. className={style.createAd}
  1017. >
  1018. {activeKey && tableData && Object.keys(tableData)?.length > 0 ? <div className={style.cardBody}>
  1019. <Tabs
  1020. onChange={(e) => { setActiveKey(e) }}
  1021. type="card"
  1022. activeKey={activeKey}
  1023. tabBarExtraContent={<Space>
  1024. <span>广告总数:{adCount}</span>
  1025. <span>创意总数:{dynamicCount}</span>
  1026. <Button type='primary' onClick={() => {
  1027. setSubVisible(true)
  1028. }}>提交创建</Button>
  1029. </Space>}
  1030. items={accountCreateLogs.map(item => ({ label: item.accountId, key: item.accountId })) as any[]}
  1031. />
  1032. {addelivery?.dynamicCreativesTextDTOS?.type === 4 && <Title level={5} style={{ color: 'red', fontSize: 12 }}>因为选择的是“创意组和文案叉乘打乱后分配”模式,会随机打乱,当前预览广告下创意内容会与实际建出来的创意有偏差,请以建出来的为准</Title>}
  1033. <div className={style.content} style={{ marginTop: 20 }}>
  1034. <Table
  1035. columns={columns()}
  1036. dataSource={tableData[activeKey]}
  1037. size="small"
  1038. bordered
  1039. scroll={{ x: 1200, y: 600 }}
  1040. rowKey={'id'}
  1041. pagination={{
  1042. defaultPageSize: 50,
  1043. total: tableData[activeKey]?.length || 0,
  1044. showTotal: (total) => <Tag color="cyan">当前共{total}个创意,{tableData[activeKey]?.[0]?.adLength}个广告</Tag>,
  1045. }}
  1046. />
  1047. </div>
  1048. </div> : <div style={{ minHeight: 400, display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
  1049. <Empty description="请先完成模块配置后,再预览广告计划" />
  1050. </div>}
  1051. </Card>
  1052. {/* 提交任务 */}
  1053. {subVisible && <SubmitModal
  1054. ajax={createAdgroupTask}
  1055. visible={subVisible}
  1056. onChange={(e) => {
  1057. onSubmit(e)
  1058. }}
  1059. onClose={() => {
  1060. setSubVisible(false)
  1061. }}
  1062. />}
  1063. </Space>
  1064. }
  1065. export default Create