|
@@ -5,46 +5,51 @@
|
5
|
5
|
<div class="flex tMar15 bMar15">
|
6
|
6
|
<Select ref="targetRef" :clearFlag="true" title="推广目标" selectWidth="160px"
|
7
|
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
|
10
|
<template #append>
|
10
|
|
- <el-button :icon="Search" @click="handleCurrentChange(1)"/>
|
|
11
|
+ <el-button :icon="Search" @click="handleCurrentChange(1)" />
|
11
|
12
|
</template>
|
12
|
13
|
</el-input>
|
13
|
14
|
</div>
|
14
|
15
|
<el-table ref="tableRef" :data="pageInfo?.list" :header-cell-style="tableHeaderStyle" border empty-text="暂无数据"
|
15
|
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
|
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
|
53
|
</el-table>
|
49
|
54
|
<el-pagination class="tMar10" v-model:current-page="pageInfo.pagination.page"
|
50
|
55
|
v-model:page-size="pageInfo.pagination.page_size" :page-sizes="[20, 50, 100, 200]" :small="true"
|
|
@@ -66,8 +71,9 @@ import { getPromotedObjectType } from '@/components/businessMoudle/batchGdt/conf
|
66
|
71
|
import { exportDefine } from '@/components/businessMoudle/adTask/ts/define';
|
67
|
72
|
import { nextTick, onBeforeMount, reactive, ref, watch } from 'vue';
|
68
|
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
|
78
|
const emit = defineEmits<{
|
73
|
79
|
(event: "close", val?: any): void;
|
|
@@ -75,11 +81,13 @@ const emit = defineEmits<{
|
75
|
81
|
const loading = ref(false)
|
76
|
82
|
const visible = ref(false)
|
77
|
83
|
const targetRef = ref()
|
78
|
|
-const pageInfo = reactive({
|
|
84
|
+const pageInfo = reactive<any>({
|
79
|
85
|
targetList: [],
|
80
|
86
|
radioModel: '',
|
|
87
|
+ radioModelInfo: {},
|
81
|
88
|
targetValue: '',
|
82
|
89
|
name: '',
|
|
90
|
+ inUseGroup: {},//正在使用的策略组
|
83
|
91
|
pagination: {
|
84
|
92
|
page: 1,
|
85
|
93
|
total: 0,
|
|
@@ -87,11 +95,11 @@ const pageInfo = reactive({
|
87
|
95
|
page_size: 20,
|
88
|
96
|
},
|
89
|
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
|
100
|
{ prop: 'promoted_object_type_desc', label: '推广目标', fixed: '', width: '180' },
|
93
|
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
|
104
|
list: []
|
97
|
105
|
})
|
|
@@ -107,8 +115,18 @@ const targetChange = () => {
|
107
|
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
|
132
|
const {
|
|
@@ -144,19 +162,99 @@ const handleCurrentChange = (val) => {
|
144
|
162
|
}
|
145
|
163
|
/**删除策略组 */
|
146
|
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
|
245
|
visible.value = flag
|
152
|
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
|
252
|
if (pageInfo.targetList.length == 0) { //获取推广目标类型
|
155
|
253
|
await getPromotedObjectType().then((res) => {
|
156
|
254
|
pageInfo.targetList = res
|
157
|
255
|
})
|
|
256
|
+ getList()
|
158
|
257
|
}
|
159
|
|
-
|
160
|
258
|
}
|
161
|
259
|
}
|
162
|
260
|
// 暴露自己的属性供父组件使用
|
|
@@ -170,4 +268,8 @@ defineExpose({
|
170
|
268
|
:deep(.spanTitle) {
|
171
|
269
|
font-size: 13px;
|
172
|
270
|
}
|
|
271
|
+
|
|
272
|
+.box-hint {
|
|
273
|
+ color: #666;
|
|
274
|
+}
|
173
|
275
|
</style>
|