contentManagerList.vue
17.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
<template>
<d2-container class="container">
<div class="header" slot="header">
<d2-search ref="showSearch" class="show-search" :search-form="searchForm" :form-data="showFormData">
<div slot="customerLabel">
<el-select v-model="searchForm.customerLabel" clearable value-key="labelId" @focus="focus('tag')"
placeholder="请选择">
<el-option-group v-for="group in tagList" :key="group.labelId" :label="group.labelName">
<el-option v-for="item in group.nextList" :key="item.labelId" :label="item.labelName" :value="item">
</el-option>
</el-option-group>
</el-select>
</div>
<div slot="receptionScene">
<el-select v-model="searchForm.receptionScene" clearable value-key="id" @focus="focus('reception')"
placeholder="请选择">
<el-option v-for="item in receptionSceneList" :key="item.id" :label="item.receptionSceneName" :value="item">
</el-option>
</el-select>
</div>
</d2-search>
<div class="up-btns">
<el-button :id="tableParams.btnId" size="small" type="primary" handle>
查询
</el-button>
<el-button size="small" @click="handleReset"> 重置 </el-button>
</div>
</div>
<div class="d2-container-content">
<d2-table-header>
<span>
<auth-button category="Button" :show-btn-ids="['9130101', '9130104', '9130105']" />
</span>
<!-- <span>
<el-button size="mini" @click="mutiStartOrStop(1)">
批量启用
</el-button>
</span>
<span>
<el-button size="mini" @click="mutiStartOrStop(2)">
批量停用
</el-button>
</span> -->
</d2-table-header>
<d2-table ref="contentTable" :search-form="searchFormSearch" :table-params="tableParams"
:get-list-api="getListApi" :before-search-fn="beforeSearchFn">
<div slot="merchantSlot" slot-scope="scope">
<div v-if="scope.scope.showMerchant == 0">全部门店</div>
<div v-else-if="scope.scope.showMerchant == null">-</div>
<el-popover v-else placement="top" width="245" trigger="hover">
<div class="merchant-wrap">
<div class="merchant-name" v-for="(item, index) in scope.scope.assignInfos || []" :key="index">
{{ item.assignName }}
</div>
</div>
<div slot="reference">
<span class="merchant-num">{{
scope.scope.assignInfos ? scope.scope.assignInfos.length : 0
}}</span>
</div>
</el-popover>
</div>
<div slot="statusSlot" slot-scope="scope">
<span :style="{
'background-color': statusEnum[scope.scope.status].color
}" class="circle"></span>
<span>{{ statusEnum[scope.scope.status].name }}</span>
</div>
<div slot="auth-button" slot-scope="scope">
<!-- <el-button type="text" size="mini" @click="handleDetail(scope.scope)">
查看
</el-button>
<el-button type="text" size="mini" @click="handleAdd(scope.scope)">
编辑
</el-button>
<el-button
type="text"
size="mini"
@click="handleDel(scope.scope)"
v-if="scope.scope.status == 0"
>
删除
</el-button>
<template v-else>
<el-button
type="text"
size="mini"
@click="operatStatus(scope.scope)"
>
{{ scope.scope.status == 1 ? "停用" : "启用" }}
</el-button>
<el-button
type="text"
size="mini"
@click="goStatisticsPage(scope.scope)"
>
统计
</el-button>
</template> -->
<!-- 查看 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope" :show-btn-ids="['9130102']" />
</span>
<!-- 编辑 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope" :show-btn-ids="['9130106']" />
</span>
<!-- 删除 -->
<span v-if="scope.scope.status == 0" style="margin-right: 10px">
<auth-button :data="scope.scope" :show-btn-ids="['9130107']" />
</span>
<!-- -->
<template v-else>
<!-- 停用/启用 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope" :show-btn-ids="['9130108']" />
</span>
<!-- 统计 -->
<span style="margin-right: 10px">
<auth-button :data="scope.scope" :show-btn-ids="['9130103']" />
</span>
</template>
<el-button v-show="scope.scope.showChannel == 2" type="text" size="mini"
@click="handleClone(scope.scope)">克隆</el-button>
</div>
</d2-table>
</div>
</d2-container>
</template>
<script>
import { deepClone } from "@/common/util"
import {
CONTENT_TYPE_OPTIONS,
SCENE_OPTIONS,
CHANNEL_OPTIONS,
STATUS_OPTIONS,
STATUS_ENUM
} from "./constant"
import {
getMerchantList,
getContenttList,
batchOperaterContent,
delContent,
getLabelList,
receptionSceneList
} from "@api/contentManager"
export default {
name: "ContentManagerList",
data() {
return {
statusEnum: STATUS_ENUM,
searchForm: {
title: "",
type: "",
scene: "",
showChannel: "",
merchantId: "",
status: "",
meal: ""
},
showFormData: [
{
label: "标题",
name: "title",
type: "input",
isClear: true,
maxlength: 20
},
{
label: "类型",
name: "type",
type: "select",
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "contentTypeOptions"
},
{
label: "业务场景",
name: "scene",
type: "select",
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "sceneOptions",
changeAttr: (value, targetItem) => {
console.log(value)
if (value !== "") {
this.getLabelList(value)
this.receptionList(value)
} else {
this.tagList = []
this.receptionSceneList = []
}
}
},
{
label: "可见渠道",
name: "showChannel",
type: "select",
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "channelOptions"
},
{
label: "可见门店",
name: "merchantId",
type: "select",
optionList: [],
optionId: "merchantId",
optionLabel: "merchantName"
},
{
label: "状态",
name: "status",
type: "select",
optionList: [],
optionId: "id",
optionLabel: "label",
optionsName: "statuslOptions"
},
{
label: "客户标签",
name: "customerLabel",
addHtml: "customerLabel"
},
{
label: "接待场景",
name: "receptionScene",
addHtml: "receptionScene"
// optionList: [],
// optionId: "id",
// optionLabel: "label",
// optionsName: "receptionSceneOptions"
}
],
// 基本数据
baseData: {
contentTypeOptions: [],
sceneOptions: [],
channelOptions: [],
statuslOptions: []
},
tableSearchForm: {},
getListApi: getContenttList,
searchFormSearch: {},
tableParams: {
btnId: new Date().getTime() + parseInt(Math.random() * 1000),
listName: "list",
mutiSelectUniqueKey: "id",
mutiSelectName: "contentIndex",
tableOption: {
width: "170"
},
tableColumns: [
{
label: "标题",
prop: "title",
minWidth: 120
},
{
label: "类型",
prop: "type",
formatter: (cellValue) => {
return {
0: "图片",
1: "视频",
2: "PDF",
3: "富文本",
4: "Excel",
5: "Word"
}[cellValue.type]
}
},
{
label: "业务场景",
prop: "scene",
width: "100px",
formatter: (cellValue) => {
return {
1: "精品升级",
2: "次新车转化",
3: "售后众筹",
0: "会员权益/升级",
4: "积分商城"
}[cellValue.scene]
}
},
{
label: "可见渠道",
prop: "showChannel",
width: "100px",
formatter: (cellValue) => {
return {
0: "培训资料",
1: "营销素材",
2: "展业助手",
3: "场景集市"
}[cellValue.showChannel]
}
},
{
label: "客户标签",
prop: "customerLabelInfoList",
minWidth: "300px",
formatter: (cellValue) => {
return cellValue.customerLabelInfoList &&
cellValue.customerLabelInfoList.length > 0
? cellValue.customerLabelInfoList
.map((item) => item.labelName)
.join(",")
: "-"
}
},
{
label: "关联商品",
prop: "productPackageInfoList",
width: "200px",
formatter: (cellValue) => {
return cellValue.productPackageInfoList &&
cellValue.productPackageInfoList.length > 0
? cellValue.productPackageInfoList
.map((item) => item.upgradeGoodsName)
.join(",")
: "-"
}
},
{
label: "接待场景",
prop: "receptionSceneInfoList",
width: "120px",
formatter: (cellValue) => {
return cellValue.receptionSceneInfoList &&
cellValue.receptionSceneInfoList.length > 0
? cellValue.receptionSceneInfoList
.map((item) => item.receptionSceneName)
.join(",")
: "-"
}
},
{
label: "可见门店",
prop: "showMerchant",
type: "slot",
addHtml: "merchantSlot"
},
{
label: "浏览次数",
prop: "browseCount",
formatter: (cell) => {
return cell.browseCount || 0
}
},
{
label: "状态",
prop: "status",
width: "80px",
type: "slot",
addHtml: "statusSlot"
},
{
label: "创建时间",
width: "200px",
prop: "createdDate"
}
]
},
// 客户档案相关内容
loading: false,
mealList: [
{
upgradeGoodsName: "test1",
id: 1
}
],
mealPage: {
pageSize: 10,
currentPage: 1
},
mealTotal: 0,
tagList: [],
receptionSceneList: []
}
},
mounted() {
var params = { currentPage: 1, pageSize: 2000, merchantIdName: "" }
this.getBaseData()
getMerchantList(params).then((res) => {
this.getSetMerchant(res || [])
})
},
methods: {
getSetMerchant(res) {
this.showFormData.forEach((item, index) => {
if (item.type === "select" && item.name === "merchantId") {
res.unshift({
merchantId: "",
merchantName: "全部"
})
this.$set(this.showFormData[index], "optionList", res)
}
})
},
getBaseData() {
const allOpt = {
id: "",
label: "全部"
}
this.baseData = {
contentTypeOptions: deepClone(CONTENT_TYPE_OPTIONS),
sceneOptions: deepClone(SCENE_OPTIONS),
channelOptions: deepClone(CHANNEL_OPTIONS),
statuslOptions: deepClone(STATUS_OPTIONS)
}
this.showFormData.forEach((item, index) => {
if (item.type === "select" && this.baseData[item.optionsName]) {
this.baseData[item.optionsName].unshift(allOpt)
this.$set(
this.showFormData[index],
"optionList",
this.baseData[item.optionsName]
)
}
})
},
handleReset() {
for (const key in this.searchForm) {
this.searchForm[key] = ""
}
this.tagList = []
this.receptionSceneList = []
this.$refs.contentTable.refreshTable(true, true)
},
beforeSearchFn() {
return new Promise((resolve) => {
this.searchFormSearch = this.getParams()
resolve()
})
},
getParams() {
console.log(this.searchForm)
var params = deepClone(this.searchForm)
// if (params.meal) {
// params.meal = params.meal.join(',')
// }
if (params.customerLabel) {
params.customerLabelList = [
{
labelId: params.customerLabel.labelId,
labelName: params.customerLabel.labelName,
level: 2,
parentId: params.customerLabel.parentId
}
]
delete params.customerLabel
}
if (params.receptionScene) {
params.receptionSceneInfoList = [
{
receptionSceneId: params.receptionScene.id,
receptionSceneName: params.receptionScene.receptionSceneName
}
]
delete params.receptionScene
}
return params
},
handleAdd(row) {
const query = {}
if (row?.id) {
query.id = row.id
query.status = row.status
}
this.$router.push({
name: "contentAdd",
query
})
},
handleDetail(row) {
this.$router.push({
name: "contentDetail",
query: {
id: row.id
}
})
},
goStatisticsPage(row) {
console.log(row)
this.$router.push({
name: "statisticsList",
query: {
id: row.id
}
})
},
handleDel(row) {
this.$confirm("删除后内容不可恢复", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then((end) => {
if (end == "confirm") {
delContent({ id: row.id }).then((res) => {
if (res) {
this.$message.success("删除成功")
this.$refs.contentTable.refreshTable(true, true)
}
})
}
})
},
handleClone(row) {
console.log(row)
this.$router.push({
name: "contentAdd",
params: {
id: row.id
}
})
},
// 批量启用
mutiStart() {
this.mutiStartOrStop(1)
},
// 批量停用
mutiStop() {
this.mutiStartOrStop(2)
},
operatStatus(row) {
this.mutiStartOrStop(row.status == 1 ? 2 : 1, [row])
},
mutiStartOrStop(type, data) {
// type 1启用 2停用
let selectedData = []
if (data) {
selectedData = data
} else if (this.$refs.contentTable.mutiSelectArr.contentIndex) {
selectedData = this.$refs.contentTable.mutiSelectArr.contentIndex
}
const status =
selectedData.map((v) => {
return v.status
}) || []
if (
status.includes(0) ||
!selectedData.length ||
(type == 1 && status.includes(1)) ||
(type == 2 && status.includes(2))
) {
// 包含0草稿 未选择
this.$message({
message: `请选择${type == 1 ? "已停用" : "已开启"}的内容`,
type: "warning",
showClose: true
})
return false
}
const title =
type == 2
? "停用内容,对应的渠道和门店将无法查看该内容"
: "启用内容,对应的渠道和门店可查看该内容"
this.$confirm(title, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
})
.then((end) => {
if (end == "confirm") {
const params = {
ids: selectedData.map((item) => {
return item.id
}),
operateType: type
}
batchOperaterContent(params).then((res) => {
if (res) {
this.$message.success("操作成功")
this.$refs.contentTable.refreshTable(true, true)
}
})
}
})
.catch((err) => {
console.log(err)
})
},
focus(name) {
console.log(this.searchForm.scene)
if (this.searchForm.scene === "") {
return this.$message.error(`请先选择业务场景`)
}
// if (name == 'tag') {
// this.getLabelList(this.searchForm.scene)
// } else if (name == 'reception') {
// this.receptionList(this.searchForm.scene)
// }
},
// 获取接待场景
async receptionList(scene) {
this.receptionSceneList = await receptionSceneList({ scene })
},
// 获取客户标签
async getLabelList(scene) {
this.tagList = await getLabelList({ scene })
}
}
}
</script>
<style scoped lang="scss">
.merchant-num {
color: #185efe;
}
.circle {
display: inline-block;
border-radius: 50%;
width: 8px;
height: 8px;
background: #2cca74;
margin-right: 6px;
vertical-align: middle;
}
.merchant-wrap {
max-height: 400px;
overflow-y: auto;
}
</style>