Browse Source

策略组

xiuli.gao 1 year ago
parent
commit
caff6b5322

+ 24 - 3
src/components/businessMoudle/batchGdt/configArea/index.vue

6
     <div class="areaTitle">
6
     <div class="areaTitle">
7
       配置区
7
       配置区
8
       <el-button class="lMar20" type="primary" @click="openStrategyGroups">选择策略组</el-button>
8
       <el-button class="lMar20" type="primary" @click="openStrategyGroups">选择策略组</el-button>
9
+      <div class="strategy-title" v-if="pageInfo.groupsConfig && pageInfo.groupsConfig?.id">
10
+        已选:{{ pageInfo.groupsConfig.name }} 
11
+        <el-icon class="lMar8 pointer" @click="closeSeletedGroup"><Close /></el-icon>
12
+      </div>
9
       <span class="smallTitle lMarauto">预览广告数 : <span class="c-theme">{{NumberHandle(pageInfo.num_total.adNum)||0}}</span></span>
13
       <span class="smallTitle lMarauto">预览广告数 : <span class="c-theme">{{NumberHandle(pageInfo.num_total.adNum)||0}}</span></span>
10
     </div>
14
     </div>
11
     <div class="areaCon">
15
     <div class="areaCon">
154
   <!-- 复用配置 -->
158
   <!-- 复用配置 -->
155
   <ResuseConfig ref="ResuseConfigRef" @aNewConfig="aNewConfigEvent" @reuse="reuseEvent"></ResuseConfig>
159
   <ResuseConfig ref="ResuseConfigRef" @aNewConfig="aNewConfigEvent" @reuse="reuseEvent"></ResuseConfig>
156
   <!-- 策略组列表 -->
160
   <!-- 策略组列表 -->
157
-  <StrategyGroupsList ref="StrategyGroupsListRef"></StrategyGroupsList>
161
+  <StrategyGroupsList ref="StrategyGroupsListRef" @close="strategyGroupsUse"></StrategyGroupsList>
158
   <!-- 保存策略组弹框 -->
162
   <!-- 保存策略组弹框 -->
159
   <StrategyGroupsDialog ref="StrategyGroupsDialogRef"></StrategyGroupsDialog>
163
   <StrategyGroupsDialog ref="StrategyGroupsDialogRef"></StrategyGroupsDialog>
160
 </template>
164
 </template>
244
     loadPageRule: 0, //0 全部相同 //1 按账户分配 //2 分配到计划 // 3分配到广告
248
     loadPageRule: 0, //0 全部相同 //1 按账户分配 //2 分配到计划 // 3分配到广告
245
   },
249
   },
246
   acc_plan_ad_count: {}, //各账户对应的计划数、广告数;用于微信视频号的配置
250
   acc_plan_ad_count: {}, //各账户对应的计划数、广告数;用于微信视频号的配置
251
+  groupsConfig: {},//已选择的策略组
247
 })
252
 })
248
 
253
 
249
 //创意基本信息
254
 //创意基本信息
613
   StrategyGroupsDialogRef,
618
   StrategyGroupsDialogRef,
614
   StrategyGroupsListRef,
619
   StrategyGroupsListRef,
615
   openStrategyGroups,
620
   openStrategyGroups,
616
-  openSaveStrategyGroups
621
+  openSaveStrategyGroups,
622
+  closeSeletedGroup,
623
+  strategyGroupsUse
617
 } = strategyGroupsEvent({
624
 } = strategyGroupsEvent({
625
+  targetRef,
626
+  accRef,
618
   cMaterial,
627
   cMaterial,
619
   basicInfoData,
628
   basicInfoData,
620
   pageInfo,
629
   pageInfo,
621
   isMock,
630
   isMock,
622
   originalityBasicInfoData,
631
   originalityBasicInfoData,
623
-  judgeEvent
632
+  judgeEvent,
633
+  aNewConfigEvent,
634
+  getAdPresetsInfo,
635
+  updateHaveContent,
636
+  clearOriginalityInfo
624
 })
637
 })
625
 /**E 策略组 */
638
 /**E 策略组 */
626
 
639
 
745
   height: 60px;
758
   height: 60px;
746
   border-radius: 6px;
759
   border-radius: 6px;
747
 }
760
 }
761
+.strategy-title{
762
+  margin-left: 16px;
763
+  font-weight: 400;
764
+  color: #666;
765
+  display: flex;
766
+  align-items: center;
767
+  font-size: 14px;
768
+}
748
 </style>
769
 </style>

+ 18 - 5
src/components/businessMoudle/batchGdt/configArea/originalityBasic/index.vue

149
 const loading = ref<boolean>(true)
149
 const loading = ref<boolean>(true)
150
 const conLoading = ref<boolean>(false)
150
 const conLoading = ref<boolean>(false)
151
 const fullscreenLoading = ref<boolean>(false)
151
 const fullscreenLoading = ref<boolean>(false)
152
+const huxian_flag = ref(false)//解决 回显状态下 创意形式的问题
152
 const templateType = reactive<{ img: any[], video: any[] }>({
153
 const templateType = reactive<{ img: any[], video: any[] }>({
153
   img: [],
154
   img: [],
154
   video: []
155
   video: []
192
       'copywriting': copywriting
193
       'copywriting': copywriting
193
     }
194
     }
194
     if (i == 'originalityForm' && obj['originalityForm'] && obj['originalityForm'] != '') {//创意形式
195
     if (i == 'originalityForm' && obj['originalityForm'] && obj['originalityForm'] != '') {//创意形式
195
-      if (form_main['originalityForm'] != obj[i]) {
196
-        onClickTemplate(templateType[obj[i]][0])
196
+      if(huxian_flag.value){
197
+        huxian_flag.value = false
198
+      }else{
199
+        if (form_main['originalityForm'] != obj[i]) {
200
+          onClickTemplate(templateType[obj[i]][0])
201
+        }
197
       }
202
       }
198
     }
203
     }
204
+    
199
     form_main[i] = obj[i]
205
     form_main[i] = obj[i]
200
   }
206
   }
201
 }
207
 }
465
   } else {
471
   } else {
466
     site_set.value = props.adBasicInfo.site_ids.split(',')
472
     site_set.value = props.adBasicInfo.site_ids.split(',')
467
   }
473
   }
468
-
469
   loading.value = true;
474
   loading.value = true;
470
   getAdcreativeTemplateList({
475
   getAdcreativeTemplateList({
471
     account_ids: props.accIdsList.map((v) => v.id),
476
     account_ids: props.accIdsList.map((v) => v.id),
526
   visible.value = val
531
   visible.value = val
527
   if (val) {
532
   if (val) {
528
     if (obj.fillback && JSON.stringify(obj.fillback) != '{}') { //回显状态下
533
     if (obj.fillback && JSON.stringify(obj.fillback) != '{}') { //回显状态下
534
+      huxian_flag.value = true
529
       fillBackInfo.value = _.cloneDeep(obj.fillback)
535
       fillBackInfo.value = _.cloneDeep(obj.fillback)
530
       templateCurr.value = _.cloneDeep(obj?.apiResult?.templateCurr)
536
       templateCurr.value = _.cloneDeep(obj?.apiResult?.templateCurr)
531
       adTemplateItem.value = _.cloneDeep(obj?.apiResult?.adTemplateItem)
537
       adTemplateItem.value = _.cloneDeep(obj?.apiResult?.adTemplateItem)
532
-      form_main['originalityForm'] = obj.fillback.originalityForm.api_value.originalityForm
533
-      JsonInfo.originalityForm.data.defaultValue = obj.fillback.originalityForm.api_value.originalityForm
538
+      if(obj.fillback.originalityForm && obj.fillback.originalityForm.api_value){
539
+        form_main['originalityForm'] = obj.fillback.originalityForm.api_value.originalityForm
540
+        JsonInfo.originalityForm.data.defaultValue = obj.fillback.originalityForm.api_value.originalityForm
541
+      }
542
+      if(JsonInfo.originalityForm.data.defaultValue == '' || !JsonInfo.originalityForm.data.defaultValue){
543
+        JsonInfo.originalityForm.data.defaultValue = templateCurr.value?.adcreative_template_style == '图片' ? 'img' : 'video'
544
+      }
545
+    }else{
546
+      huxian_flag.value = false
534
     }
547
     }
535
     initEvent()
548
     initEvent()
536
   }
549
   }

+ 147 - 45
src/components/businessMoudle/batchGdt/configArea/strategyGroups/list.vue

5
       <div class="flex tMar15 bMar15">
5
       <div class="flex tMar15 bMar15">
6
         <Select ref="targetRef" :clearFlag="true" title="推广目标" selectWidth="160px"
6
         <Select ref="targetRef" :clearFlag="true" title="推广目标" selectWidth="160px"
7
           :optObj="{ k: 'name', la: 'desc', val: 'name' }" @changeEvent="targetChange" :options="pageInfo.targetList" />
7
           :optObj="{ k: 'name', la: 'desc', val: 'name' }" @changeEvent="targetChange" :options="pageInfo.targetList" />
8
-        <el-input v-model="pageInfo.name" clearable @clear="handleCurrentChange(1)" @change="handleCurrentChange(1)" placeholder="搜索策略组名称" style="width: 230px;">
8
+        <el-input v-model="pageInfo.name" clearable @clear="handleCurrentChange(1)" @change="handleCurrentChange(1)"
9
+          placeholder="搜索策略组名称" style="width: 230px;">
9
           <template #append>
10
           <template #append>
10
-            <el-button :icon="Search" @click="handleCurrentChange(1)"/>
11
+            <el-button :icon="Search" @click="handleCurrentChange(1)" />
11
           </template>
12
           </template>
12
         </el-input>
13
         </el-input>
13
       </div>
14
       </div>
14
       <el-table ref="tableRef" :data="pageInfo?.list" :header-cell-style="tableHeaderStyle" border empty-text="暂无数据"
15
       <el-table ref="tableRef" :data="pageInfo?.list" :header-cell-style="tableHeaderStyle" border empty-text="暂无数据"
15
         height="60vh" style="width:100%">
16
         height="60vh" style="width:100%">
16
-          <template v-for="item in pageInfo.descol">
17
-            <el-table-column :fixed="item.fixed" :prop="item.prop" :width="item.width ? item.width : 'auto'" :align="item.align || 'left'">
18
-              <template #header>
19
-                <div class="flex" :style="`justify-content:${item.align || 'left'}`">
20
-                  <span>{{ item.label }}</span>
21
-                </div>
22
-              </template>
23
-              <template #default="scope">
24
-                <div v-if="item.prop == 'radio'">
25
-                  <el-radio v-model="pageInfo.radioModel" :label="scope.row.id" size="large"><span></span></el-radio>
26
-                </div>
27
-                <!-- 操作 -->
28
-                <div v-else-if="item.prop == 'operate'">
29
-                  <span class="c-theme pointer">复制</span>
17
+        <template v-for="item in pageInfo.descol">
18
+          <el-table-column :fixed="item.fixed" :prop="item.prop" :width="item.width ? item.width : 'auto'"
19
+            :align="item.align || 'left'">
20
+            <template #header>
21
+              <div class="flex" :style="`justify-content:${item.align || 'left'}`">
22
+                <span>{{ item.label }}</span>
23
+              </div>
24
+            </template>
25
+            <template #default="scope">
26
+              <div v-if="item.prop == 'radio'">
27
+                <el-radio v-model="pageInfo.radioModel" @change="radioChange(scope.row)" :label="scope.row.id" size="large"><span></span></el-radio>
28
+              </div>
29
+              <!-- 操作 -->
30
+              <div v-else-if="item.prop == 'operate'">
31
+                <span class="c-theme pointer" @click="copyGroup(scope.row)">复制</span>
32
+                <span v-if="pageInfo.inUseGroup?.id != scope.row.id">
30
                   <Popconfirm key="dele" @confirm="deleteGroup(scope.row.id)" :slotFlag="true">
33
                   <Popconfirm key="dele" @confirm="deleteGroup(scope.row.id)" :slotFlag="true">
31
-                    <template #con>
32
-                      <span class="pointer lMar10 c-red">删除</span>
33
-                    </template>
34
-                  </Popconfirm>
35
-                </div>
36
-                <!-- 其他 -->
37
-                <div class="cellDiv" v-else>
38
-                  <el-tooltip :disabled="!(scope.row[item.prop] && scope.row[item.prop].length > 30)" effect="dark"
39
-                    :content="scope.row[item.prop] + ''">
40
-                    <div class="clampTwo line21" style="flex: 1">
41
-                      {{ scope.row[item.prop] || scope.row[item.prop] == 0 ? scope.row[item.prop] : '-' }}
42
-                    </div>
43
-                  </el-tooltip>
44
-                </div>
45
-              </template>
46
-            </el-table-column>
47
-          </template>
34
+                  <template #con>
35
+                    <span class="pointer lMar10 c-red">删除</span>
36
+                  </template>
37
+                </Popconfirm>
38
+                </span>
39
+                <span class="pointerDrop lMar10 c-666" v-else>删除</span>
40
+              </div>
41
+              <!-- 其他 -->
42
+              <div class="cellDiv" v-else>
43
+                <el-tooltip :disabled="!(scope.row[item.prop] && scope.row[item.prop].length > 30)" effect="dark"
44
+                  :content="scope.row[item.prop] + ''">
45
+                  <div class="clampTwo line21" style="flex: 1">
46
+                    {{ scope.row[item.prop] || scope.row[item.prop] == 0 ? scope.row[item.prop] : '-' }}
47
+                  </div>
48
+                </el-tooltip>
49
+              </div>
50
+            </template>
51
+          </el-table-column>
52
+        </template>
48
       </el-table>
53
       </el-table>
49
       <el-pagination class="tMar10" v-model:current-page="pageInfo.pagination.page"
54
       <el-pagination class="tMar10" v-model:current-page="pageInfo.pagination.page"
50
         v-model:page-size="pageInfo.pagination.page_size" :page-sizes="[20, 50, 100, 200]" :small="true"
55
         v-model:page-size="pageInfo.pagination.page_size" :page-sizes="[20, 50, 100, 200]" :small="true"
66
 import { exportDefine } from '@/components/businessMoudle/adTask/ts/define';
71
 import { exportDefine } from '@/components/businessMoudle/adTask/ts/define';
67
 import { nextTick, onBeforeMount, reactive, ref, watch } from 'vue';
72
 import { nextTick, onBeforeMount, reactive, ref, watch } from 'vue';
68
 import Popconfirm from '@/components/capsulationMoudle/_popconfirm.vue'
73
 import Popconfirm from '@/components/capsulationMoudle/_popconfirm.vue'
69
-import { getStrategyGroupsList } from './ts/api'
70
-import { ElMessage } from 'element-plus';
74
+import { getStrategyGroupsList, getStrategyDetail, addStrategyGroups, strategyGroupsDel, getAccountStatus } from './ts/api'
75
+import { ElMessage, ElMessageBox } from 'element-plus';
76
+import _ from 'lodash';
71
 
77
 
72
 const emit = defineEmits<{
78
 const emit = defineEmits<{
73
   (event: "close", val?: any): void;
79
   (event: "close", val?: any): void;
75
 const loading = ref(false)
81
 const loading = ref(false)
76
 const visible = ref(false)
82
 const visible = ref(false)
77
 const targetRef = ref()
83
 const targetRef = ref()
78
-const pageInfo = reactive({
84
+const pageInfo = reactive<any>({
79
   targetList: [],
85
   targetList: [],
80
   radioModel: '',
86
   radioModel: '',
87
+  radioModelInfo: {},
81
   targetValue: '',
88
   targetValue: '',
82
   name: '',
89
   name: '',
90
+  inUseGroup: {},//正在使用的策略组
83
   pagination: {
91
   pagination: {
84
     page: 1,
92
     page: 1,
85
     total: 0,
93
     total: 0,
87
     page_size: 20,
95
     page_size: 20,
88
   },
96
   },
89
   descol: [
97
   descol: [
90
-    { prop: 'radio', label: '',align: 'center',  fixed: '', width: '60' },
91
-    { prop: 'name', label: '策略组', fixed: ''},
98
+    { prop: 'radio', label: '', align: 'center', fixed: '', width: '60' },
99
+    { prop: 'name', label: '策略组', fixed: '' },
92
     { prop: 'promoted_object_type_desc', label: '推广目标', fixed: '', width: '180' },
100
     { prop: 'promoted_object_type_desc', label: '推广目标', fixed: '', width: '180' },
93
     { prop: 'note', label: '描述', fixed: '' },
101
     { prop: 'note', label: '描述', fixed: '' },
94
-    { prop: 'operate', label: '操作', align: 'center',fixed: '' ,width: '120'},
102
+    { prop: 'operate', label: '操作', align: 'center', fixed: '', width: '120' },
95
   ],
103
   ],
96
   list: []
104
   list: []
97
 })
105
 })
107
   getList()
115
   getList()
108
 }
116
 }
109
 /**点击确定 */
117
 /**点击确定 */
110
-const submitEvent = () => {
111
-
118
+const submitEvent = async () => {
119
+  if(pageInfo.radioModel=='' || !pageInfo.radioModel || !pageInfo.radioModelInfo.id){
120
+    ElMessage.error('请选择策略组')
121
+    return
122
+  }
123
+  await getAccountStatus({ account_ids: pageInfo.radioModelInfo.account_ids })
124
+  emit('close', pageInfo.radioModelInfo)
125
+  visible.value = false
126
+}
127
+/**radio change */
128
+const radioChange = (info)=>{
129
+  pageInfo.radioModelInfo = info
112
 }
130
 }
113
 
131
 
114
 const {
132
 const {
144
 }
162
 }
145
 /**删除策略组 */
163
 /**删除策略组 */
146
 const deleteGroup = (id) => {
164
 const deleteGroup = (id) => {
147
-
165
+  loading.value = true;
166
+  strategyGroupsDel({ id }).then((res) => {
167
+    loading.value = false;
168
+    ElMessage.success('操作成功!')
169
+    getList()
170
+  }).catch(() => { loading.value = false; })
171
+}
172
+/**复制策略组 */
173
+const copyGroup = (info) => {
174
+  let title = info.name + '_副本'
175
+  loading.value = true;
176
+  getStrategyGroupsList({
177
+    page: 1,
178
+    pageSize: Number(pageInfo.pagination.page_size),
179
+    name: title,
180
+    promoted_object_type: pageInfo.targetValue
181
+  }).then((res: any) => {
182
+    if (res.data && Array.isArray(res.data) && res.data.length > 0) {
183
+      loading.value = false;
184
+      ElMessage.error('策略组名称重复!')
185
+    } else {
186
+      getStrategyDetailEvent(info.id, title)
187
+    }
188
+  }).catch(() => { loading.value = false; })
148
 }
189
 }
190
+/**获取策略组详情 */
191
+const getStrategyDetailEvent = (id, name?) => {
192
+  loading.value = true;
193
+  getStrategyDetail({ id }).then(async (res: any) => {
194
+    loading.value = false;
195
+    await getAccountStatus({ account_ids: res.account_ids })
196
+    addStrategyGroupsEvent(Object.assign(res, { name }))
197
+  }).catch(() => { loading.value = false; })
198
+}
199
+/**新增策略组 */
200
+const addStrategyGroupsEvent = (info) => {
201
+  loading.value = true;
202
+  addStrategyGroups({
203
+    name: info.name,
204
+    note: info.note,
205
+    promoted_object_type: info.promoted_object_type,
206
+    account_ids: info.account_ids,
207
+    rule_conf: info.rule_conf,
208
+    ad_base: info.ad_base,
209
+    targetings_info: info.targetings_info,
210
+    creative_base: info.creative_base,
211
+    creative_info: info.creative_info,
212
+    paperwork: info.paperwork,
213
+    landing_page: info.landing_page,
214
+    user_action_sets: info.user_action_sets,
215
+    start_audience: info.start_audience,
216
+    wechat_channels: info.wechat_channels,
217
+    union_position: info.union_position
218
+  }).then((res:any) => {
219
+    loading.value = false;
220
+    pageInfo.pagination.page = 1;
221
+    getList()
222
+    ElMessageBox.confirm(
223
+      `<div>
224
+          <p style="margin-bottom: 12px;font-size: 16px;font-weight: 700;">策略组:${info.name} 复制成功</p>
225
+          <p style="color:#666;">你可以使用该策略组并调整广告内容,调整后再保存为新的策略</p>
226
+      </div>`,
227
+      '操作成功',
228
+      {
229
+        type: 'success',
230
+        dangerouslyUseHTMLString: true,
231
+        confirmButtonText: '立即使用',
232
+        cancelButtonText: '跳过',
233
+      }
234
+    ).then(() => {
235
+      pageInfo.radioModel = res.id
236
+      pageInfo.radioModelInfo = res
237
+      emit('close', pageInfo.radioModelInfo)
238
+      visible.value = false
239
+    }).catch(() => { })
240
+  }).catch(() => { loading.value = false; })
241
+}
242
+
149
 /**初始化 */
243
 /**初始化 */
150
-const initFun = async (flag) => {
244
+const initFun = async (flag, groupsConfig) => {
151
   visible.value = flag
245
   visible.value = flag
152
   if (flag) {
246
   if (flag) {
153
-    getList()
247
+    if (groupsConfig && groupsConfig.id) {
248
+      pageInfo.radioModel = groupsConfig.id
249
+      pageInfo.inUseGroup = _.cloneDeep(groupsConfig)
250
+      pageInfo.radioModelInfo = _.cloneDeep(groupsConfig)
251
+    }
154
     if (pageInfo.targetList.length == 0) { //获取推广目标类型
252
     if (pageInfo.targetList.length == 0) { //获取推广目标类型
155
       await getPromotedObjectType().then((res) => {
253
       await getPromotedObjectType().then((res) => {
156
         pageInfo.targetList = res
254
         pageInfo.targetList = res
157
       })
255
       })
256
+      getList()
158
     }
257
     }
159
-
160
   }
258
   }
161
 }
259
 }
162
 // 暴露自己的属性供父组件使用
260
 // 暴露自己的属性供父组件使用
170
 :deep(.spanTitle) {
268
 :deep(.spanTitle) {
171
   font-size: 13px;
269
   font-size: 13px;
172
 }
270
 }
271
+
272
+.box-hint {
273
+  color: #666;
274
+}
173
 </style>
275
 </style>

+ 31 - 0
src/components/businessMoudle/batchGdt/configArea/strategyGroups/ts/api.ts

48
     }
48
     }
49
   })
49
   })
50
 }
50
 }
51
+/**更新策略组 */
52
+interface IEditStrategyGroups extends IAddStrategyGroups {
53
+  id: string
54
+}
55
+export function editStrategyGroups(params: IEditStrategyGroups) {
56
+  return new Promise(async (resolve,reject)=>{
57
+    const res: any = await http.post('/api/ad/editStrategyGroups', params)
58
+    if (res.errNo == 0) {
59
+      resolve(res.rst)
60
+    } else {
61
+      ElMessage.error(res.errMsg)
62
+      reject()
63
+    }
64
+  })
65
+}
51
 
66
 
52
 /**策略组详情 */
67
 /**策略组详情 */
53
 interface IGetStrategyDetail {
68
 interface IGetStrategyDetail {
80
     }
95
     }
81
   })
96
   })
82
 }
97
 }
98
+
99
+/**获取账户投放状态 */
100
+interface IGetAccountStatus {
101
+  account_ids: string,
102
+}
103
+export function getAccountStatus(params: IGetAccountStatus) {
104
+  return new Promise(async (resolve,reject)=>{
105
+    const res: any = await http.get('/api/ad/getAccountStatus', params)
106
+    if (res.errNo == 0) {
107
+      resolve(res.rst)
108
+    } else {
109
+      ElMessage.error(res.errMsg)
110
+      reject()
111
+    }
112
+  })
113
+}

+ 23 - 16
src/components/businessMoudle/batchGdt/configArea/ts/adBasic.ts

115
     basicInfoData.visible = false
115
     basicInfoData.visible = false
116
   }
116
   }
117
   /**广告预存信息获取 */
117
   /**广告预存信息获取 */
118
-  const getAdPresetsInfo = () => {
119
-    getAdPresets({ 'promoted_object_type': targetRef.value?.value }).then((res) => {
120
-      getButtonBasicOuter(res)
121
-      FillBackData({
122
-        data: res,
123
-        type: 'api',
124
-        cb: (data: { params: any, copywriting: [] }) => {
125
-          if (data.copywriting && Array.isArray(data.copywriting) && data.copywriting.length > 0) {
126
-            basicInfoData.copywriting = data.copywriting
127
-            for(let key in data.params) {
128
-              if(data.params[key] === null) {
129
-                data.params[key] = ''
130
-              }
118
+  const getAdPresetsInfo = (type?, info?) => {
119
+    if(type == 'strategyGroups'){
120
+      getAdBasicInfo(info)
121
+    }else{
122
+      getAdPresets({ 'promoted_object_type': targetRef.value?.value }).then((res) => {
123
+        getAdBasicInfo(res)
124
+      })
125
+    }
126
+  }
127
+  const getAdBasicInfo = (res) => {
128
+    getButtonBasicOuter(res)
129
+    FillBackData({
130
+      data: res,
131
+      type: 'api',
132
+      cb: (data: { params: any, copywriting: [] }) => {
133
+        if (data.copywriting && Array.isArray(data.copywriting) && data.copywriting.length > 0) {
134
+          basicInfoData.copywriting = data.copywriting
135
+          for(let key in data.params) {
136
+            if(data.params[key] === null) {
137
+              data.params[key] = ''
131
             }
138
             }
132
-            basicInfoData.fillBack = data.params
133
-            updateHaveContent(2, -1, false)
134
           }
139
           }
140
+          basicInfoData.fillBack = data.params
141
+          updateHaveContent(2, -1, false)
135
         }
142
         }
136
-      })
143
+      }
137
     })
144
     })
138
   }
145
   }
139
   /**广告信息外部配置获取 */
146
   /**广告信息外部配置获取 */

+ 87 - 4
src/components/businessMoudle/batchGdt/configArea/ts/strategyGroups.ts

1
 import { ref } from "vue"
1
 import { ref } from "vue"
2
+import { getStrategyDetail } from '../strategyGroups/ts/api'
3
+import { ElLoading, ElMessage, ElMessageBox } from 'element-plus';
4
+import _ from "lodash";
2
 
5
 
3
 interface IStrategyGroupsEvent {
6
 interface IStrategyGroupsEvent {
4
   judgeEvent: (...args: any[]) => boolean,
7
   judgeEvent: (...args: any[]) => boolean,
8
+  aNewConfigEvent: (...args: any[]) => void,
9
+  getAdPresetsInfo: (...args: any[]) => void,
10
+  updateHaveContent: (...args: any[]) => void,
11
+  clearOriginalityInfo: (...args: any[]) => void,
5
   [propName: string]: any
12
   [propName: string]: any
6
 }
13
 }
7
 
14
 
11
   basicInfoData,
18
   basicInfoData,
12
   pageInfo,
19
   pageInfo,
13
   isMock,
20
   isMock,
14
-  judgeEvent
15
-}:IStrategyGroupsEvent) => {
21
+  accRef,
22
+  targetRef,
23
+  judgeEvent,
24
+  aNewConfigEvent,
25
+  getAdPresetsInfo,
26
+  updateHaveContent,
27
+  clearOriginalityInfo
28
+}: IStrategyGroupsEvent) => {
16
   const StrategyGroupsListRef = ref()
29
   const StrategyGroupsListRef = ref()
17
   const StrategyGroupsDialogRef = ref()
30
   const StrategyGroupsDialogRef = ref()
18
   /**打开策略组列表 */
31
   /**打开策略组列表 */
19
   const openStrategyGroups = () => {
32
   const openStrategyGroups = () => {
20
-    StrategyGroupsListRef.value?.initFun(true)
33
+    StrategyGroupsListRef.value?.initFun(true, pageInfo.groupsConfig)
21
   }
34
   }
22
 
35
 
23
   /**打开保存策略组弹框 */
36
   /**打开保存策略组弹框 */
31
     })
44
     })
32
   }
45
   }
33
 
46
 
47
+  /**关闭选中的策略组 */
48
+  const closeSeletedGroup = () => {
49
+    accRef.value.value = []
50
+    pageInfo.accIdsList = []
51
+    pageInfo.accIdsList_copy_last = _.cloneDeep(pageInfo.accIdsList)
52
+    pageInfo.groupsConfig = {}
53
+    aNewConfigEvent()
54
+  }
55
+
56
+  /**策略组回调 */
57
+  const strategyGroupsUse = (info) => {
58
+    pageInfo.groupsConfig = info;
59
+    if (info.id == '' || !info.id) {
60
+      ElMessage.error('此策略组不存在')
61
+      return
62
+    }
63
+    const loading = ElLoading.service({
64
+      lock: true,
65
+      text: '策略组配置中',
66
+      background: 'rgba(255, 255, 255, 0.5)',
67
+    })
68
+    getStrategyDetail({
69
+      id: info.id
70
+    }).then((res: any) => {
71
+      loading.close()
72
+      console.log('111', res)
73
+      if (res.rule_conf) {//规则配置
74
+        pageInfo.RuleConfigObj = JSON.parse(res.rule_conf)
75
+      }
76
+      if (res.ad_base) {//广告基本信息
77
+        basicInfoData.fillBack = JSON.parse(res.ad_base)
78
+        getAdPresetsInfo('strategyGroups', basicInfoData.fillBack)
79
+      }
80
+      if (res?.account_ids && accRef.value) {//媒体账户
81
+        accRef.value.value = res?.account_ids.split(',')
82
+        pageInfo.accIdsList = res?.account_ids?.split(',')?.map((v) => {
83
+          return { 'name': v, 'id': v }
84
+        })
85
+        pageInfo.accIdsList_copy_last = _.cloneDeep(pageInfo.accIdsList)
86
+      }
87
+      if(res?.promoted_object_type && targetRef.value){//推广目标
88
+        pageInfo.targetValue = res?.promoted_object_type
89
+        targetRef.value.value = pageInfo.targetValue;
90
+      }
91
+      if(res?.creative_base){//创意基本信息
92
+        let creative_base = JSON.parse(res?.creative_base)
93
+        for(let key in originalityBasicInfoData){
94
+          originalityBasicInfoData[key] = creative_base[key]
95
+        }
96
+        updateHaveContent(5)
97
+      }else{
98
+        clearOriginalityInfo()
99
+      }
100
+      if(res?.targetings_info){//定向包
101
+        pageInfo.directObj = JSON.parse(res?.targetings_info)
102
+      }
103
+      if(res?.creative_info){//创意素材
104
+        let creative_info = JSON.parse(res?.creative_info)
105
+        for(let key in cMaterial){
106
+          cMaterial[key] = creative_info[key]
107
+        }
108
+      }
109
+    }).catch((err) => {
110
+      console.log(err)
111
+      ElMessage.error('策略组配置失败!')
112
+      loading.close()
113
+    })
114
+  }
34
   return {
115
   return {
35
     StrategyGroupsDialogRef,
116
     StrategyGroupsDialogRef,
36
     StrategyGroupsListRef,
117
     StrategyGroupsListRef,
37
     openStrategyGroups,
118
     openStrategyGroups,
38
-    openSaveStrategyGroups
119
+    openSaveStrategyGroups,
120
+    closeSeletedGroup,
121
+    strategyGroupsUse
39
   }
122
   }
40
 }
123
 }