index.vue
16.2 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
<template>
<div class="main-container">
<div class="top">
<el-button type="primary" @click="addMaterial(1)" :size="size">
<i class="el-icon-plus"></i>
创建营销素材
</el-button>
<span @click="showIntroductionDialog">
功能介绍
<i class="el-icon-arrow-right"></i>
</span>
</div>
<div class="container">
<div class="search-form">
<glsx-combi-form ref="materialFormRef1" :isEdit="isEdit" :formObj="searchForm" :formData="materialFormData1" :inline="true"></glsx-combi-form>
<glsx-combi-form ref="materialFormRef2" :isEdit="isEdit" :formObj="searchForm" :formData="materialFormData2" :inline="true">
<span slot="footer" slot-scope="scope" class="select-pro">
<el-button type="primary" :size="size" @click="handleSearch(scope)">查询</el-button>
<el-button type="default" :size="size" @click="handleReset(scope)">重置</el-button>
</span>
</glsx-combi-form>
</div>
<div class="tabelList">
<el-row :style="{ height: boxHeight }">
<el-col :span="5">
<div class="left" :style="{ height: boxHeight }">
<MaterialGroup @openAddDialog="addDialogShow" :eventBus="eventBus" @getList="getList"></MaterialGroup>
</div>
</el-col>
<el-col :span="19">
<div class="right" :style="{ height: boxHeight }">
<div class="groupTitle">{{ materialGroupName ? materialGroupName : '新车素材组' }}(共{{ materialTableData.length }}条数据)</div>
<GLTable ref="materialRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :tableData="materialTableData" :pageConf="pageConf" :tableTotal="tableTotal" @sortChange="sortChange" :isCustomHead="true" :customHeadShowList="customHeadShowList">
<!-- 素材内容 -->
<div slot="materialContentRpcResponse" slot-scope="scope">
<!-- 素材为PDF -->
<span v-if="scope.scope.materialType == 1">
<span>{{ scope.scope.materialContentRpcResponse.materialName }}</span>
<img src="@/assets/material/pdf.png" alt="">
</span>
<!-- 素材为自定义链接 -->
<span v-if="scope.scope.materialType == 2"></span>
<!-- 图文 -->
<span v-if="scope.scope.materialType == 3">
<span>{{ scope.scope.materialContentRpcResponse.materialName }}</span>
<img src="@/assets/material/car.png" alt="">
</span>
</div>
<!-- 状态 -->
<div slot="status" slot-scope="scope">
<span v-if="scope.scope.status == 0">启用</span>
<span v-if="scope.scope.status == -1">禁用</span>
<span v-if="scope.scope.status == 1">存草稿</span>
</div>
<!-- 类型 -->
<div slot="materialType" slot-scope="scope">
<span v-if="scope.scope.materialType == 1">pdf</span>
<span v-if="scope.scope.materialType == 2">自定义链接</span>
<span v-if="scope.scope.materialType == 3">图文</span>
</div>
<span slot="auth-button" slot-scope="scope">
<el-button type="text" @click="handleDetail(scope.scope)">详情</el-button>
<el-button type="text" @click="addMaterial(2, scope.scope)">编辑</el-button>
<el-popover placement="right" trigger="click">
<ul>
<li @click="handleForbid(scope.scope)">{{ scope.scope.status == 0 ? '禁用' : '启用' }}</li>
<li @click="handleDelete(scope.scope)">删除</li>
</ul>
<el-button type="text" slot="reference" class="btn-more">更多</el-button>
</el-popover>
</span>
</GLTable>
</div>
</el-col>
</el-row>
</div>
</div>
<AddMaterialGroupDia :businessTypes="businessTypes" ref="addMaterialGroup" :dialogVisible="materialGroupDialog" :eventBus="eventBus"></AddMaterialGroupDia>
<FunctionIntroduc :introductionDialog="introductionDialog" @closeIntroductDia="closeIntroductDia"></FunctionIntroduc>
</div>
</template>
<script>
const iconUrl =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAFoTx1HAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAADqADAAQAAAABAAAADgAAAAC98Dn6AAAB7klEQVQoFVVSQUhUURQ9981sVFyYRRHuFFq1CGlZC3etnBlMRhMXQwhtCqIQJBA3gSSi1EpkNqkjCjOjm1YWuGojBVO7Fi0K2qQLF6H453bO+/ODLvz37z333PvOu+8BtImCf0K56J8VYKLoC9HRMlnwRxaRgB0kOHDDz5gl/0hZBaaFwGl3H65j577nygV/ITCM71pinRo1GiF4zm8jqzkr5dEtluiTJZ9zx8fYTEBmbP5D/tSY3wnaRUwB0rbdsAH5SYK3sW2l4r1/jnFIsUMElmsNmxdB7JGsUnGUWvQz+XkHXtXqNsxx/KL/Zg+oS5xxi8A2T8SqNe0az3NANyfVJD4N5ripZDTDrc1da8kn/i1QxGya4eq4Kl8aui7hblRLUd/JXCSxxXarBJ9T8fuYFLsztiqTv4NjXUTh2rZteEhiP8OKiiIez3+CFoWubdXtpUDe1XAbmJEfQLxpRxFPRz7T1ccz6BFkl6okRzHFOJ5ccbnkr8l5LF8mrl5Pnv5gJksJjmlD/wclv9121ClxeqthH4TJQh5fLhIMaa7LOrRuIk2la89lfO29ghuU/69IHBatqIZfOhgWv2OXhUIOi/FCnDpoZuYqaCaYpYJ5gvf+m6pInUE9Y5NRhoPCdGl80fscyFK1aqfCZH8B0rPa9foo7e4AAAAASUVORK5CYII='
import Vue from 'vue'
import url from '@/assets/empty.png'
import AddMaterialGroupDia from '@/views/material/components/addMaterialGroupDia'
import MaterialGroup from '@/views/material/components/materialGroup'
import FunctionIntroduc from '@/views/material/components/functionIntroduc'
export default {
name: 'materialList',
components: {
AddMaterialGroupDia,
MaterialGroup,
FunctionIntroduc
},
data() {
return {
url,
eventBus: new Vue(),
searchForm: {
groupId: '',
materialType: '',
businessType: '',
status: '',
materialName: ''
},
materialTableData: [],
materialGroupDialog: false,
introductionDialog: false,
boxHeight: '',
businessTypes: [],
getListApi: this.$apis.material.materialList,
materialGroupName: '',
materialFormData1: [
{
label: '业务类型:',
name: 'businessType',
type: 'select',
placeholder: '全部',
optionList: [],
optionId: 'dictValue',
optionLabel: 'dictLabel',
optionsName: 'dictValue'
},
{
label: '素材类型:',
name: 'materialType',
type: 'select',
placeholder: '全部类型',
optionList: [
{
optionId: 1,
optionLabel: 'pdf'
},
{
optionId: 2,
optionLabel: '自定义链接'
},
{
optionId: 3,
optionLabel: '图文'
}
],
optionId: 'optionId',
optionLabel: 'optionLabel',
optionsName: 'optionLabel'
},
{
label: '状态:',
name: 'status',
type: 'select',
placeholder: '全部(不包括删除)',
optionList: [
{
optionId: 0,
optionLabel: '启用'
},
{
optionId: -1,
optionLabel: '禁用'
},
{
optionId: 2,
optionLabel: '草稿'
}
],
optionId: 'optionId',
optionLabel: 'optionLabel',
optionsName: 'optionLabel'
}
],
materialFormData2: [
{
label: '素材名称:',
name: 'materialName',
type: 'input',
placeholder: '输入素材关键字'
}
],
tableParams: {
listName: 'data',
tableOption: true,
tableColumns: [
{
label: '素材内容',
prop: 'materialContentRpcResponse',
addHtml: 'materialContentRpcResponse',
width: 240
},
{
label: '状态',
prop: 'status',
addHtml: 'status'
},
{
label: '类型',
prop: 'materialType',
addHtml: 'materialType'
},
{
label: '发送次数',
prop: 'sendNum',
sortable: true,
width: 150,
renderHeader: (h, { column, $index }) => {
return h(
'div',
{
style: {
display: 'inline-flex',
'align-items': 'center'
}
},
[
'发送次数',
h(
'el-popover',
{
attrs: {
placement: 'top-start',
width: '240',
trigger: 'hover',
content: '用户购买活动商品的总销售额。'
}
},
[
h('img', {
style: {
width: '14px',
height: '14px',
'margin-left': '4px'
},
attrs: {
src: iconUrl
},
slot: 'reference'
})
]
)
]
)
}
},
{
label: '阅读人数',
prop: 'readNum',
width: 150,
sortable: true,
renderHeader: (h, { column, $index }) => {
return h(
'div',
{
style: {
display: 'inline-flex',
'align-items': 'center'
}
},
[
'阅读人数',
h(
'el-popover',
{
attrs: {
placement: 'top-start',
width: '240',
trigger: 'hover',
content: '用户购买活动商品的总销售额。'
}
},
[
h('img', {
style: {
width: '14px',
height: '14px',
'margin-left': '4px'
},
attrs: {
src: iconUrl
},
slot: 'reference'
})
]
)
]
)
}
},
{
label: '更新时间',
prop: 'updatedTime',
width: 180,
sortable: true
}
]
},
pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
tableTotal: 4
}
},
mounted() {
let clientHeight = document.documentElement.clientHeight
let offTop = document.querySelector('.tabelList').offsetTop
this.boxHeight = clientHeight - offTop + 'px'
this.findAllDictData('business_type')
this.firstCome()
},
methods: {
// 判断是否第一次进入
firstCome() {
if (!window.sessionStorage.getItem('firstLogin')) {
this.introductionDialog = true
window.sessionStorage.setItem('firstLogin', 'true')
}
},
// 搜索
handleSearch() {
this.$refs.materialRef.refreshTable()
},
// 重置
handleReset() {
this.searchForm = {
applicationType: '',
materialType: '',
status: '',
materialName: ''
}
this.handleSearch()
},
// 获取所有业务类型
findAllDictData(dictType) {
var params = {
dictType
}
this.$apis.material.findAllDictData(params).then(res => {
if (res) {
this.businessTypes = res
this.materialFormData1[0].optionList = res
console.log(this.businessTypes)
}
})
},
// 新增或编辑素材弹框打开
addDialogShow(addOrEdit, value, group) {
this.materialGroupDialog = true
this.$refs.addMaterialGroup.init(addOrEdit, value, group)
},
// 素材详情
handleDetail(scope) {
console.log(scope.id)
this.$router.push({
path: '/material/materialDetail',
query: {
id: scope.id
}
})
},
// 素材禁用
handleForbid(scope) {
console.log(scope)
var params = {}
params.id = scope.id
params.status = -1
console.log(params)
this.secondConfirm('提示', '禁用素材,所有已经发送给客户的素材链接均会失效,是否继续禁用?', 'material', 'materialEdit', params )
},
// 素材删除
handleDelete(scope) {
this.secondConfirm('提示', '删除素材,所有已经发送给客户的素材链接均会失效,是否继续删除?', 'material', 'materialDelete', { id: scope.id })
},
// 1-新增素材,2-编辑素材
addMaterial(addOrEdit, scope) {
console.log(addOrEdit, scope)
var params = {
addOrEdit: addOrEdit,
$title: encodeURI(addOrEdit == 1 ? '创建营销素材' : '编辑营销素材')
}
addOrEdit != 1 && (params.id = scope.id)
this.$router.push({
path: '/material/addMaterial',
query: params
})
},
// 排序
sortChange(sort) {
console.log(sort)
// 获取字段名称和排序类型
var fieldName = sort.prop
var sortingType = sort.order
//如果字段名称为“创建时间”,将“创建时间”转换为时间戳,才能进行大小比较
if (fieldName == 'updatedTime') {
this.materialTableData.map(item => {
item.updatedTime = this.$moment(item.updatedTime).valueOf()
})
}
//按照降序排序
if (sortingType == 'descending') {
this.materialTableData = this.materialTableData.sort((a, b) => b[fieldName] - a[fieldName])
}
//按照升序排序
else {
this.materialTableData = this.materialTableData.sort((a, b) => a[fieldName] - b[fieldName])
}
},
// 点击素材组获取素材组素材
getList(params, item) {
console.log(item, '7758')
this.materialGroupName = item.materialGroupName
this.searchForm.groupId = item.id
this.$apis.material.materialList(params).then(res => {
this.materialTableData = res.data
})
this.handleSearch()
},
// 功能介绍弹框
showIntroductionDialog() {
this.introductionDialog = true
},
closeIntroductDia(val) {
this.introductionDialog = false
},
// 二次确认
secondConfirm(title, txt, apiModule, apiName, apiParams, fn) {
this.$confirm(txt, title, {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
callback: action => {
if (action == 'confirm') {
this.$apis[apiModule][apiName](apiParams).then(res => {
this.$message({
message: res.code == '0' ? '操作成功' : '操作失败',
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
fn && fn()
this.handleSearch()
}
})
}
}
})
}
}
}
</script>
<style lang="scss" scoped>
.search-form,
.left,
.right {
background-color: #fff;
}
.main-container {
height: 100%;
.top {
span {
margin-left: 16px;
font-size: 16px;
color: #5850ff;
}
}
}
.container {
margin-top: 10px;
height: 100%;
.search-form {
padding: 20px 68px 0 68px;
}
.tabelList {
margin-top: 10px;
height: 100%;
.left {
height: 100%;
position: relative;
border-right: 1px solid #e8e8ea;
}
.right {
.groupTitle {
padding: 20px 0 16px 19px;
font-weight: 600;
}
.glsx-table {
margin: 0 20px;
}
}
}
}
.btn-more {
margin-left: 10px;
}
</style>>