|
@@ -248,9 +248,11 @@ const Create: React.FC = () => {
|
|
|
dynamicGroup = dynamicMaterialDTOS?.map((item: any[]) => {
|
|
|
return {
|
|
|
list: item?.map((i: any) => {
|
|
|
- let { type, valueJson } = i
|
|
|
- let value = JSON.parse(valueJson).value
|
|
|
- if (type === 'image') {
|
|
|
+ const { type, valueJson } = i
|
|
|
+ const { value, componentId, componentValue } = JSON.parse(valueJson)
|
|
|
+ if (componentId) {
|
|
|
+ return componentValue
|
|
|
+ } else if (type === 'image') {
|
|
|
return { id: value.imageId, url: value.imageUrl, materialType: value.materialType, accountId: value?.accountId }
|
|
|
} else if (type === 'image_list') {
|
|
|
return value.list.map((l: { imageUrl: any; imageId: any; materialType: any, accountId: any }) => ({ url: l.imageUrl, id: l.imageId, materialType: l.materialType, accountId: l?.accountId }))
|
|
@@ -428,7 +430,7 @@ const Create: React.FC = () => {
|
|
|
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
|
|
|
+ const [dynamicGroup, textDtoData] = item
|
|
|
return {
|
|
|
...dynamicGroup as any,
|
|
|
textDto: textDtoData
|
|
@@ -510,11 +512,11 @@ const Create: React.FC = () => {
|
|
|
}
|
|
|
// 落地页平均分配判断数量
|
|
|
if ([910].includes(dynamic.creativeTemplateId) && dynamic?.landingPageType === 1) {
|
|
|
- let targetingLength = targeting.length
|
|
|
+ const targetingLength = targeting.length
|
|
|
if (accountCreateLogs.some(item => {
|
|
|
- let productListLength = item?.productList?.length || 1
|
|
|
- let total = targetingLength * productListLength
|
|
|
- let pageLength = item.pageList.length
|
|
|
+ const productListLength = item?.productList?.length || 1
|
|
|
+ const total = targetingLength * productListLength
|
|
|
+ const pageLength = item.pageList.length
|
|
|
if (total > pageLength) {
|
|
|
message.error(`当前${item.accountId}下的广告总数(${total})大于落地页总数(${pageLength}),平均分配需要落地页总数大于广告总数`)
|
|
|
return true
|
|
@@ -541,11 +543,11 @@ const Create: React.FC = () => {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- let data = cartesianProduct(productList, targeting).map((newD, dindex) => {
|
|
|
- let [productDto, targetDto, index] = newD
|
|
|
- let suffix = '_' + item.accountId + '_' + index
|
|
|
- let averageAdDynamic = (mediaType === 3 ? averageAdDynamicList?.[dindex] : averageAdDynamicList?.[accountIndex]) || []
|
|
|
- let dat: any = {
|
|
|
+ const data = cartesianProduct(productList, targeting).map((newD, dindex) => {
|
|
|
+ const [productDto, targetDto, index] = newD
|
|
|
+ const suffix = '_' + item.accountId + '_' + index
|
|
|
+ const averageAdDynamic = (mediaType === 3 ? averageAdDynamicList?.[dindex] : averageAdDynamicList?.[accountIndex]) || []
|
|
|
+ const dat: any = {
|
|
|
id: item.accountId + '_' + index,
|
|
|
accountId: item.accountId, // 账户
|
|
|
userActionSetsList: item.userActionSetsList, // 数据源
|
|
@@ -576,9 +578,9 @@ const Create: React.FC = () => {
|
|
|
// 激励
|
|
|
if ([910].includes(dynamic.creativeTemplateId)) {
|
|
|
if (dynamic?.landingPageType === 1) {
|
|
|
- let averageAdPageList: any[] = distributeArray(item.pageList, productList.length * targeting.length)
|
|
|
+ const averageAdPageList: any[] = distributeArray(item.pageList, productList.length * targeting.length)
|
|
|
data.forEach((item, aIndex) => {
|
|
|
- let aPageList: any[] = averageAdPageList[aIndex]
|
|
|
+ const aPageList: any[] = averageAdPageList[aIndex]
|
|
|
aPageList.forEach((page, index) => {
|
|
|
newData.push({
|
|
|
...item,
|
|
@@ -597,7 +599,7 @@ const Create: React.FC = () => {
|
|
|
})
|
|
|
} else {
|
|
|
newData = cartesianProduct(data, item.pageList).map((item, index) => {
|
|
|
- let [d1, pageList, num] = item
|
|
|
+ const [d1, pageList, num] = item
|
|
|
return {
|
|
|
...d1,
|
|
|
id: d1.id + '_' + index,
|
|
@@ -614,9 +616,9 @@ const Create: React.FC = () => {
|
|
|
data.forEach(item => {
|
|
|
const { averageAdDynamic, ...ad } = item
|
|
|
if (textType === 3) {
|
|
|
- let rowSpan = textDtoLenth * averageAdDynamic.length
|
|
|
+ const rowSpan = textDtoLenth * averageAdDynamic.length
|
|
|
cartesianProduct(textDto, averageAdDynamic).forEach((taad: any, index) => {
|
|
|
- let [textValue, aad] = taad
|
|
|
+ const [textValue, aad] = taad
|
|
|
newData.push({
|
|
|
...ad,
|
|
|
id: ad.id + '_' + index,
|
|
@@ -661,7 +663,7 @@ const Create: React.FC = () => {
|
|
|
const { averageAdDynamic, ...ad } = item
|
|
|
if (textType === 3) {
|
|
|
cartesianProduct(textDto, [newDynamicGroup[accountIndex1 % newDynamicGroup.length]]).forEach((taad: any, i) => {
|
|
|
- let [textValue, aad, index] = taad
|
|
|
+ const [textValue, aad, index] = taad
|
|
|
newData.push({
|
|
|
...ad,
|
|
|
id: ad.id + '_' + index,
|
|
@@ -673,7 +675,7 @@ const Create: React.FC = () => {
|
|
|
})
|
|
|
})
|
|
|
} else {
|
|
|
- let { textDto: nowTextDto, ...dynamicGroup } = newDynamicGroup[accountIndex1 % newDynamicGroup.length]
|
|
|
+ const { textDto: nowTextDto, ...dynamicGroup } = newDynamicGroup[accountIndex1 % newDynamicGroup.length]
|
|
|
newData.push({
|
|
|
...ad,
|
|
|
dynamicGroup,
|
|
@@ -715,7 +717,7 @@ const Create: React.FC = () => {
|
|
|
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];
|
|
|
+ const mType = Object.keys(materialData)[0];
|
|
|
dynamicMaterialDTOS = dynamicMaterialDTos.dynamicGroup?.map((item: any) => {
|
|
|
if (mType === 'image') {
|
|
|
return [{
|
|
@@ -734,7 +736,7 @@ const Create: React.FC = () => {
|
|
|
if (mType === 'element_story') {
|
|
|
key = 'element_story'
|
|
|
}
|
|
|
- let list = item?.[key]?.map((l: any) => {
|
|
|
+ const list = item?.[key]?.map((l: any) => {
|
|
|
return {
|
|
|
imageUrl: l?.url,
|
|
|
imageId: l?.id,
|
|
@@ -751,7 +753,7 @@ const Create: React.FC = () => {
|
|
|
})
|
|
|
}]
|
|
|
} else if (['short_video', 'video'].includes(mType)) {
|
|
|
- let value: any = {
|
|
|
+ const 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,
|
|
@@ -781,6 +783,15 @@ const Create: React.FC = () => {
|
|
|
if (dynamicMaterialDTos && Object.keys(dynamicMaterialDTos).length) {
|
|
|
dynamicMaterialDTOS = dynamicMaterialDTos.dynamicGroup?.map((item: { list: any[] }) => {
|
|
|
return item.list.map(l => {
|
|
|
+ if (l.materialType === 4) {
|
|
|
+ return {
|
|
|
+ type: l?.componentSubType?.includes('IMAGE_LIST') ? 'image_list' : l?.keyFrameImageUrl ? 'video' : 'image',
|
|
|
+ valueJson: JSON.stringify({
|
|
|
+ componentId: l.id,
|
|
|
+ componentValue: l
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
if (Array.isArray(l)) {
|
|
|
return {
|
|
|
type: 'image_list',
|
|
@@ -878,8 +889,6 @@ const Create: React.FC = () => {
|
|
|
taskType: putInType,
|
|
|
...copyTask
|
|
|
}
|
|
|
- console.log('2222222222---->', params)
|
|
|
- return
|
|
|
if (values?.submitRule !== 0) {
|
|
|
createAdgroupTaskV2.run(params).then(res => {
|
|
|
if (res) {
|