|
@@ -3,7 +3,7 @@ import { useAjax } from "@/Hook/useAjax"
|
|
|
import { createAdBatchApi, CreateAdProps } from "@/services/launchAdq/createAd"
|
|
|
import { getSysAdcreativeInfo } from "@/services/launchAdq/creative"
|
|
|
import { PromotedObjectType } from "@/services/launchAdq/enum"
|
|
|
-import { getTagsList } from "@/services/launchAdq/global"
|
|
|
+import { getTagsList, get_adcreative_template } from "@/services/launchAdq/global"
|
|
|
import { getSysAdgroupsInfo } from "@/services/launchAdq/localAd"
|
|
|
import { getsysTargetingInfo } from "@/services/launchAdq/targeting"
|
|
|
import { CheckOutlined, CloseOutlined, SearchOutlined } from "@ant-design/icons"
|
|
@@ -80,19 +80,43 @@ const CreateAd: React.FC = () => {
|
|
|
const getSysAdcreative = useAjax((params) => getSysAdcreativeInfo(params))
|
|
|
const createAdBatch = useAjax((params) => createAdBatchApi(params))
|
|
|
const getTaskDetails = useAjax((params) => getTaskDetailsApi(params))
|
|
|
+ const getAdcreativeTemplate = useAjax((params) => get_adcreative_template(params))
|
|
|
/*************************/
|
|
|
|
|
|
+ console.log('==========>', queryForm);
|
|
|
+
|
|
|
+
|
|
|
/**数据回填 */
|
|
|
useEffect(() => {
|
|
|
let taskId = sessionStorage.getItem('TASKID')
|
|
|
if (taskId) {
|
|
|
- getTaskDetails.run(taskId).then(res => {
|
|
|
+ getTaskDetails.run(taskId).then(async res => {
|
|
|
console.log('res----->', res)
|
|
|
- // setLaunchMode(1)
|
|
|
- console.log('launchMode--->', launchMode);
|
|
|
-
|
|
|
const { adCreateLogs, campaignType, promotedObjectType, speedMode, sysAdgroup, sysAdgroupId, sysTargeting, sysTargetingId } = res
|
|
|
-
|
|
|
+ let adcreativeTemplateId = adCreateLogs[0]?.sysAdcreative?.adcreativeTemplateId
|
|
|
+ let sysPageId = adCreateLogs[0]?.sysPageId
|
|
|
+ let pageId = adCreateLogs[0]?.pageId
|
|
|
+ let type: 1 | 2 = 1
|
|
|
+ if (sysPageId && pageId) {
|
|
|
+ type = 1
|
|
|
+ } else if (sysPageId) {
|
|
|
+ if (adCreateLogs?.every((item: { sysAdcreative: { adcreativeTemplateId: number }, sysPageId: number }) => item.sysAdcreative.adcreativeTemplateId === adcreativeTemplateId && (item.sysPageId === sysPageId))) {
|
|
|
+ type = 2
|
|
|
+ } else {
|
|
|
+ type = 1
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (adCreateLogs?.every((item: { sysAdcreative: { adcreativeTemplateId: number }, pageId: number }) => item.sysAdcreative.adcreativeTemplateId === adcreativeTemplateId && item.pageId === pageId)) {
|
|
|
+ type = 2
|
|
|
+ } else {
|
|
|
+ type = 1
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('adcreativeTemplateId--->', adcreativeTemplateId, type);
|
|
|
+ // type = 1
|
|
|
+ setLaunchMode(type)
|
|
|
+
|
|
|
+
|
|
|
// 账号信息相关
|
|
|
let adCreateLogsData = adCreateLogs?.map((item: any) => {
|
|
|
return {
|
|
@@ -112,72 +136,141 @@ const CreateAd: React.FC = () => {
|
|
|
}).filter((item: any, index: number, self: any) => self.findIndex((i: any) => i.id == item.id) === index)
|
|
|
|
|
|
console.log('adCreateLogsData--->', adCreateLogsData);
|
|
|
-
|
|
|
+
|
|
|
setAccountCreateLogs(adCreateLogsData)
|
|
|
|
|
|
- if (launchMode === 1) {
|
|
|
|
|
|
- } else {
|
|
|
+ /** 本地落地页处理 */
|
|
|
+ let pageList: any = []
|
|
|
+ /** 云端落地页 */
|
|
|
+ let adqPageList: any[] = []
|
|
|
+ let taskMediaMaps: any[] = []
|
|
|
+ const sorted = groupBy(adCreateLogs, (item) => [item.accountId])
|
|
|
+ let type2Data = {}
|
|
|
+ console.log('sorted---->', sorted);
|
|
|
|
|
|
- }
|
|
|
- return
|
|
|
-
|
|
|
- const sorted = groupBy(adCreateLogs, (item) => [item.sysAdcreativeId])
|
|
|
- let taskMediaMaps = sorted[0]?.map((item: any) => {
|
|
|
- let pageElementsSpecList = item?.sysPage?.pageSpecsList[0]?.pageElementsSpecList // 内容区
|
|
|
- let globalSpec = item?.sysPage?.globalSpec // 悬浮组件
|
|
|
- /** 处理客服 */
|
|
|
- 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: [] })
|
|
|
+ if (type === 1) {
|
|
|
+ pageList = sorted[0]?.map((item: any) => {
|
|
|
+ if (item?.sysPageId) {
|
|
|
+ return item.sysPage
|
|
|
+ } else {
|
|
|
+ return null
|
|
|
}
|
|
|
- cropUserGroupMap = sorted[0]?.map((item: any) => {
|
|
|
- let corpUserGroup1s = item?.corpUserGroup1s
|
|
|
- let corpUserGroup2s = item?.corpUserGroup2s
|
|
|
+ })
|
|
|
+ adqPageList = sorted[0]?.map((item: any) => {
|
|
|
+ if (item?.pageId) {
|
|
|
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 }] : [] }
|
|
|
- })
|
|
|
+ pageList: [{ ...item.page, id: item.page.pageId }],
|
|
|
+ adAccountId: item?.accountId,
|
|
|
+ id: item?.adAccountId,
|
|
|
}
|
|
|
-
|
|
|
- })
|
|
|
- }
|
|
|
- let accountPageIdMap: any = {}
|
|
|
- adCreateLogs?.forEach((item: any) => {
|
|
|
- if (item?.pageId) {
|
|
|
- accountPageIdMap[item.accountId] = item?.pageId
|
|
|
+ } else {
|
|
|
+ return null
|
|
|
}
|
|
|
})
|
|
|
- return { sysAdcreative: item?.sysAdcreative, sysPageId: item?.sysPageId, cropUserGroupMap, accountPageIdMap }
|
|
|
- })
|
|
|
+ taskMediaMaps = sorted[0]?.map((item: any, index: number) => {
|
|
|
+ let pageElementsSpecList = item?.sysPage?.pageSpecsList[0]?.pageElementsSpecList // 内容区
|
|
|
+ let globalSpec = item?.sysPage?.globalSpec // 悬浮组件
|
|
|
+ /** 处理客服 */
|
|
|
+ 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 = groupBy(adCreateLogs, (item) => [item.sysAdcreativeId])[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 pageList = sorted?.map((item: any[]) => {
|
|
|
- if (item.some((item1: { sysPageId: number }) => item1.sysPageId)) {
|
|
|
- return item[0].sysPage
|
|
|
+ })
|
|
|
+ }
|
|
|
+ // 落地页信息
|
|
|
+ let accountPageIdMap: any = {}
|
|
|
+ adCreateLogs?.forEach((item: any) => {
|
|
|
+ if (item?.pageId) {
|
|
|
+ accountPageIdMap[item.accountId] = item?.pageId
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return { sysAdcreative: item?.sysAdcreative, sysPageId: item?.sysPageId, cropUserGroupMap, accountPageIdMap }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ let adCreateLog = adCreateLogs[0]
|
|
|
+ if (adCreateLog?.sysPageId) {
|
|
|
+ pageList = [adCreateLog?.sysPageId]
|
|
|
} else {
|
|
|
- return null
|
|
|
+ pageList = [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,
|
|
|
- }))
|
|
|
+ if (adCreateLog?.pageId) {
|
|
|
+ adqPageList = [{
|
|
|
+ pageList: [{ ...adCreateLog.page, id: adCreateLog.page.pageId }],
|
|
|
+ adAccountId: adCreateLog?.accountId,
|
|
|
+ id: adCreateLog?.adAccountId,
|
|
|
+ }]
|
|
|
} else {
|
|
|
- return null
|
|
|
+ adqPageList = [null]
|
|
|
}
|
|
|
- })
|
|
|
+ let template = await getAdcreativeTemplate.run({ promotedObjectType, adcreativeTemplateId, siteSet: sysAdgroup.siteSet })
|
|
|
+ console.log('template--->', template);
|
|
|
+ // type2Data['textData'] = template[0]?.adcreativeElements?.filter((item: any) => item.name === 'title' || (item.required && item.name === 'description')).map((item: any) => ({ ...item, pupState }))
|
|
|
+ type2Data['materialData'] = template[0]?.adcreativeElements?.filter((item: any) => item.required && item.name === 'image_list' || item.name === 'short_video1' || item.name === 'video' || item.name === 'image' || item.name === 'element_story').map((item: any) => {
|
|
|
+ return {
|
|
|
+ label: item.description === '图片' && res[0]?.adcreativeElements?.some((item: any) => item.name === 'video') ? '视频封面图' : item.description,
|
|
|
+ name: item.name,
|
|
|
+ restriction: item.restriction,
|
|
|
+ arrayProperty: item?.arrayProperty
|
|
|
+ }
|
|
|
+ })
|
|
|
+ taskMediaMaps = [sorted[0][0]].map(async (item: any) => {
|
|
|
+ let pageElementsSpecList = item?.sysPage?.pageSpecsList[0]?.pageElementsSpecList // 内容区
|
|
|
+ let globalSpec = item?.sysPage?.globalSpec // 悬浮组件
|
|
|
+ /** 处理客服 */
|
|
|
+ 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 = groupBy(adCreateLogs, (item) => [item.sysAdcreativeId])[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 }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ console.log('taskMediaMaps--->', taskMediaMaps);
|
|
|
|
|
|
+ // return
|
|
|
setQueryForm({
|
|
|
...queryForm,
|
|
|
campaignType,
|
|
@@ -191,7 +284,7 @@ const CreateAd: React.FC = () => {
|
|
|
configuredStatus: sysAdgroup?.configuredStatus,
|
|
|
expandEnabled: sysAdgroup?.expandEnabled || false,
|
|
|
expandTargeting: sysAdgroup?.expandTargeting || [],
|
|
|
- taskMediaMaps: taskMediaMaps || [],
|
|
|
+ // taskMediaMaps: taskMediaMaps || [],
|
|
|
pageList,
|
|
|
adqPageList
|
|
|
})
|
|
@@ -207,12 +300,6 @@ const CreateAd: React.FC = () => {
|
|
|
setAccountCreateLogs(accountCreateLogs)
|
|
|
}
|
|
|
}
|
|
|
- // let adqAdData = localStorage.getItem('ADQAD')
|
|
|
- // if (adqAdData) {
|
|
|
- // const { queryForm, accountCreateLogs } = JSON.parse(adqAdData)
|
|
|
- // setQueryForm({ ...queryForm })
|
|
|
- // setAccountCreateLogs(accountCreateLogs)
|
|
|
- // }
|
|
|
}, [])
|
|
|
// 设置地域
|
|
|
useEffect(() => {
|