|
@@ -27,6 +27,7 @@ import AddGroup from '../../components/addGroup'
|
|
import CustomerServiceModal from "../../components/customerServiceModal"
|
|
import CustomerServiceModal from "../../components/customerServiceModal"
|
|
import { getTaskDetailsApi } from "@/services/launchAdq/taskList"
|
|
import { getTaskDetailsApi } from "@/services/launchAdq/taskList"
|
|
import CreativeCL from "./creativeCL"
|
|
import CreativeCL from "./creativeCL"
|
|
|
|
+import { groupBy } from "@/utils/utils"
|
|
|
|
|
|
const CreateAd: React.FC = () => {
|
|
const CreateAd: React.FC = () => {
|
|
|
|
|
|
@@ -87,33 +88,76 @@ const CreateAd: React.FC = () => {
|
|
if (taskId) {
|
|
if (taskId) {
|
|
getTaskDetails.run(taskId).then(res => {
|
|
getTaskDetails.run(taskId).then(res => {
|
|
console.log('res----->', res)
|
|
console.log('res----->', res)
|
|
|
|
+ setLaunchMode(1)
|
|
const { adCreateLogs, campaignType, promotedObjectType, speedMode, sysAdgroup, sysAdgroupId, sysTargeting, sysTargetingId } = res
|
|
const { adCreateLogs, campaignType, promotedObjectType, speedMode, sysAdgroup, sysAdgroupId, sysTargeting, sysTargetingId } = res
|
|
- setAccountCreateLogs(adCreateLogs?.map((item: any) => {
|
|
|
|
|
|
+ let adCreateLogsData = adCreateLogs?.map((item: any) => {
|
|
|
|
+ return {
|
|
|
|
+ adAccountId: item?.accountId,
|
|
|
|
+ id: item?.adAccountId,
|
|
|
|
+ userActionSetsList: item?.userActionSetList?.map((item: any) => ({ ...item, id: item?.userActionSetId })),
|
|
|
|
+ productList: item?.product ? [{ ...item?.product, productCatalog: item?.productCatalog, id: Number(item?.product?.productOuterId?.replace(/\D/ig, '')) }] : undefined,
|
|
|
|
+ coldStartAudienceList: item?.coldStartAudienceList?.map((item: any) => ({ ...item, id: item.audienceId }))
|
|
|
|
+ // pageList: [item.page]
|
|
|
|
+ }
|
|
|
|
+ }).filter((item: any, index: number, self: any) => self.findIndex((i: any) => i.id == item.id) === index)
|
|
|
|
|
|
- return { adAccountId: item?.accountId, id: item?.adAccountId }
|
|
|
|
- }))
|
|
|
|
- let taskMediaMaps = adCreateLogs?.map((item: any) => {
|
|
|
|
|
|
+ setAccountCreateLogs(adCreateLogsData)
|
|
|
|
+ const sorted = groupBy(adCreateLogs, (item) => [item.sysAdcreativeId])
|
|
|
|
+ let taskMediaMaps = sorted[0]?.map((item: any) => {
|
|
let pageElementsSpecList = item?.sysPage?.pageSpecsList[0]?.pageElementsSpecList // 内容区
|
|
let pageElementsSpecList = item?.sysPage?.pageSpecsList[0]?.pageElementsSpecList // 内容区
|
|
let globalSpec = item?.sysPage?.globalSpec // 悬浮组件
|
|
let globalSpec = item?.sysPage?.globalSpec // 悬浮组件
|
|
/** 处理客服 */
|
|
/** 处理客服 */
|
|
let cropUserGroupMap: any[] = []
|
|
let cropUserGroupMap: any[] = []
|
|
- // if ((pageElementsSpecList as any[])?.some((item: { elementType: string }) => item?.elementType === 'ENTERPRISE_WX') || (globalSpec?.globalElementsSpecList?.length > 0 && globalSpec?.globalElementsSpecList?.some((item: { floatButtonSpec: { elementType: string } }) => item?.floatButtonSpec?.elementType === 'ENTERPRISE_WX'))) {
|
|
|
|
- // let groupList: { type: number, name: string, cropList: any[], cropId?: number, groupId?: number }[] = [];
|
|
|
|
- // (pageElementsSpecList as any[])?.forEach((item: { elementType: string, enterpriseWxSpec: { btnTitle: string } }) => {
|
|
|
|
- // if (item?.elementType === 'ENTERPRISE_WX') {
|
|
|
|
- // groupList.push({ type: 1, name: '联系商家', cropList: [] }) // item.enterpriseWxSpec.btnTitle
|
|
|
|
- // }
|
|
|
|
- // })
|
|
|
|
- // if ((globalSpec?.globalElementsSpecList?.length > 0 && globalSpec?.globalElementsSpecList)) {
|
|
|
|
- // groupList.push({ type: 2, name: '悬浮组件', cropList: [] })
|
|
|
|
- // }
|
|
|
|
- // cropUserGroupMap = adCreateLogs?.map((item: any) => ({ adAccountId: item.accountId, id: item.adAccountId, data: groupList }))
|
|
|
|
- // }
|
|
|
|
- return { sysAdcreative: item?.sysAdcreative, sysPageId: item?.sysPageId, cropUserGroupMap }
|
|
|
|
|
|
+ if ((pageElementsSpecList as any[])?.some((item: { elementType: string }) => item?.elementType === 'ENTERPRISE_WX') || (globalSpec?.globalElementsSpecList?.length > 0 && globalSpec?.globalElementsSpecList?.some((item: { floatButtonSpec: { elementType: string } }) => item?.floatButtonSpec?.elementType === 'ENTERPRISE_WX'))) {
|
|
|
|
+ let groupList: { type: number, name: string, cropList: any[], cropId?: number, groupId?: number }[] = [];
|
|
|
|
+ (pageElementsSpecList as any[])?.forEach((item: { elementType: string, enterpriseWxSpec: { btnTitle: string } }) => {
|
|
|
|
+ if (item?.elementType === 'ENTERPRISE_WX') {
|
|
|
|
+ groupList.push({ type: 1, name: '联系商家', cropList: [] }) // item.enterpriseWxSpec.btnTitle
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ if ((globalSpec?.globalElementsSpecList?.length > 0 && globalSpec?.globalElementsSpecList)) {
|
|
|
|
+ groupList.push({ type: 2, name: '悬浮组件', cropList: [] })
|
|
|
|
+ }
|
|
|
|
+ cropUserGroupMap = sorted[0]?.map((item: any) => {
|
|
|
|
+ let corpUserGroup1s = item?.corpUserGroup1s
|
|
|
|
+ let corpUserGroup2s = item?.corpUserGroup2s
|
|
|
|
+ return {
|
|
|
|
+ adAccountId: item.accountId, id: item.adAccountId, data: groupList.map((crop: any, index: number) => {
|
|
|
|
+ return { ...crop, cropList: crop.type === 1 ? corpUserGroup1s[index] ? [{ ...corpUserGroup1s[index], id: corpUserGroup1s[index].groupId }] : [] : corpUserGroup2s[0] ? [{ ...corpUserGroup2s[0], id: corpUserGroup2s[0].groupId }] : []}
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ let accountPageIdMap: any = {}
|
|
|
|
+ adCreateLogs?.forEach((item: any) => {
|
|
|
|
+ if (item?.pageId) {
|
|
|
|
+ accountPageIdMap[item.accountId] = item?.pageId
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return { sysAdcreative: item?.sysAdcreative, sysPageId: item?.sysPageId, cropUserGroupMap, accountPageIdMap }
|
|
|
|
+ })
|
|
|
|
+
|
|
|
|
+ /** 云端落地页处理 */
|
|
|
|
+ let pageList = sorted?.map((item: any[]) => {
|
|
|
|
+ if (item.some((item1: { sysPageId: number }) => item1.sysPageId)) {
|
|
|
|
+ return item[0].sysPage
|
|
|
|
+ } else {
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
})
|
|
})
|
|
- let pageList = adCreateLogs?.map((item: any) => {
|
|
|
|
- return item?.sysPage || null
|
|
|
|
|
|
+ let adqPageList = sorted?.map((item: any[]) => {
|
|
|
|
+ if (item.some((item1: { pageId: number }) => item1.pageId)) {
|
|
|
|
+ return item.map((item1: any) => ({
|
|
|
|
+ pageList: [{ ...item1.page, id: item1.page.pageId }],
|
|
|
|
+ adAccountId: item1?.accountId,
|
|
|
|
+ id: item1?.adAccountId,
|
|
|
|
+ }))
|
|
|
|
+ } else {
|
|
|
|
+ return null
|
|
|
|
+ }
|
|
})
|
|
})
|
|
|
|
+
|
|
setQueryForm({
|
|
setQueryForm({
|
|
...queryForm,
|
|
...queryForm,
|
|
campaignType,
|
|
campaignType,
|
|
@@ -129,8 +173,10 @@ const CreateAd: React.FC = () => {
|
|
expandTargeting: sysAdgroup?.expandTargeting || [],
|
|
expandTargeting: sysAdgroup?.expandTargeting || [],
|
|
taskMediaMaps: taskMediaMaps || [],
|
|
taskMediaMaps: taskMediaMaps || [],
|
|
pageList,
|
|
pageList,
|
|
|
|
+ adqPageList
|
|
})
|
|
})
|
|
})
|
|
})
|
|
|
|
+ sessionStorage.removeItem('TASKID')
|
|
} else {
|
|
} else {
|
|
let adqAdData = localStorage.getItem('ADQAD')
|
|
let adqAdData = localStorage.getItem('ADQAD')
|
|
if (adqAdData) {
|
|
if (adqAdData) {
|
|
@@ -627,7 +673,7 @@ const CreateAd: React.FC = () => {
|
|
value={accountCreateLogs?.map((item: { id: number }) => item?.id)}
|
|
value={accountCreateLogs?.map((item: { id: number }) => item?.id)}
|
|
onChange={(e, option) => {
|
|
onChange={(e, option) => {
|
|
console.log(option)
|
|
console.log(option)
|
|
- setQueryForm({ ...queryForm, adqPageList: [], pageList: [], taskMediaMaps: queryForm?.taskMediaMaps?.map((item: { sysPageId: number }) => ({ ...item, sysPageId: '', accountPageIdMap: {} })) })
|
|
|
|
|
|
+ setQueryForm({ ...queryForm, adqPageList: [], pageList: [], taskMediaMaps: queryForm?.taskMediaMaps?.map((item: { sysPageId: number }) => ({ ...item, sysPageId: '', accountPageIdMap: {}, cropUserGroupMap: [] })) })
|
|
setAccountCreateLogs(option?.map((item: any) => ({ adAccountId: item?.children?.toString()?.split('——')[0], id: item?.value })))
|
|
setAccountCreateLogs(option?.map((item: any) => ({ adAccountId: item?.children?.toString()?.split('——')[0], id: item?.value })))
|
|
clearData()
|
|
clearData()
|
|
}}
|
|
}}
|