index.vue
8.49 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
<template>
<div class="sop-overview marketing edit-box">
<div class="container edit-container m-b-20">
<p class="edit-title">营销SOP</p>
<div class="sop-box">
<p class="box-txt">锁定目标客户群,设置触发时间、场景事件、策略内容和触点,自动触发场景营销SOP推送,完成保养提醒、事故车送修等智能线索推送、新用户培育、客户关怀、激活沉默客户、转化复购等。</p>
<div class="flex-center">
<p class="step-circle">1</p>
<p class="step-txt">创建SOP</p>
<p class="step-line"></p>
<p class="step-circle">2</p>
<p class="step-txt">添加推送客户</p>
<p class="step-line"></p>
<p class="step-circle">3</p>
<p class="step-txt">设置推送内容及时间</p>
<p class="step-line"></p>
<p class="step-circle">4</p>
<p class="step-txt">系统定时自动推送/任务下发</p>
</div>
</div>
</div>
<div class="container edit-container m-b-20">
<div class="edit-title flex p-r-20">
<p>SOP监测</p>
<div>
<GLButton :size="size" type="default" class="default-blue-btn" fn="创建SOP" @click="handleEdit('add')">创建SOP</GLButton>
<GLButton :size="size" type="default" class="default-blue-btn" fn="管理SOP" @click="handleJump('sopList')">管理全部SOP</GLButton>
</div>
</div>
<div class="sop-box" :style="{ 'padding-bottom': sopList.length ? '2px' : '12px', 'padding-right': sopList.length ? '0' : '20px' }">
<div class="chart-box sop-flex" v-show="sopList.length">
<div class="chart-item" v-for="item in sopList" :key="item.id">
<p class="sop-name">{{ item.sopName }}</p>
<div :id="'sopPie' + item.id" class="chart-pie"></div>
<p>{{ item.dateRange }}</p>
<div class="sop-btns">
<GLButton class="btn-item" :size="size" type="primary" display="disabled" fn="分析SOP" @click="handleJump('sopAnalysisList', item)">SOP分析</GLButton>
<GLButton class="btn-item" :size="size" type="primary" display="disabled" fn="编辑SOP" @click="handleEdit('edit', item)">编辑</GLButton>
<GLButton class="btn-item" :size="size" type="primary" display="disabled" fn="结束SOP" @click="handleEnd(item)">结束</GLButton>
</div>
</div>
</div>
<div v-show="!sopList.length" class="txt-center" style="height: 400px;">
<img style="margin-top: 140px;" src="@/assets/empty.png" />
<p class="m-t-10">暂无数据</p>
</div>
</div>
</div>
</div>
</template>
<script>
import * as echarts from 'echarts'
import * as moment from 'moment'
export default {
name: 'sopIndex',
data() {
return {
size: 'small',
// 环形图配置
pieOption: {
tooltip: {
trigger: 'item'
},
title: {
text: '0%',
left: 'center',
top: '40%',
textStyle: {
color: '#5850ff',
fontSize: 16,
align: 'center'
}
},
color: ['#7A80FF', '#F0F0F0'],
series: [
{
name: '',
type: 'pie',
radius: ['78%', '90%'],
avoidLabelOverlap: false,
label: {
show: false,
position: 'center'
},
emphasis: {
label: {
show: false
}
},
labelLine: {
show: false
},
data: []
}
]
},
sopList: []
}
},
mounted() {
this.getList()
},
methods: {
handleJump(path, row = {}) {
this.$router.push({
path: '/sop/' + path,
query: row ? { id: row.id, fromPage: '/marketing/sop/index' } : ''
})
},
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' ? '操作成功' : res.message,
type: res.code == '0' ? 'success' : 'error'
})
if (res.code == '0') {
fn && fn()
this.getList()
}
})
}
}
})
},
getList() {
var params = {
sopStatus: 2,
pageNum: 1,
pageSize: 999999
}
this.$apis.sop.getSopInfoListApi(params).then(res => {
this.sopList = res.list
this.dealListData()
this.$nextTick(() => {
this.drawPie()
})
})
},
// 数据处理
dealListData() {
this.sopList.forEach(item => {
item.completedPercent = Math.round((item.sopStatistics.finishEventCount / item.sopStatistics.eventCount) * 100).toFixed(0)
item.dateRange =
moment(item.startDate)
.format('YYYY-MM-DD')
.replace(/-/g, '.') +
(item.endDate
? '-' +
moment(item.endDate)
.format('YYYY-MM-DD')
.replace(/-/g, '.')
: '')
})
},
drawPie() {
this.sopList.forEach(item => {
let chartDom = document.getElementById('sopPie' + item.id)
let myChart = echarts.init(chartDom)
let option = JSON.parse(JSON.stringify(this.pieOption))
// option.title.text = item.completedPercent == '100' ? '√' : item.completedPercent + '%'
option.title.text = item.completedPercent + '%'
option.series[0].name = item.sopName
option.series[0].data = [
{
value: item.sopStatistics.finishEventCount,
name: '已触发的营销事件'
},
{
value: item.sopStatistics.eventCount - item.sopStatistics.finishEventCount,
name: '未触发的营销事件'
}
]
option && myChart.setOption(option)
})
},
// 结束
handleEnd(row) {
this.secondConfirm('结束', '结束SOP后,将不再进行营销任务自动推送,且不可恢复。是否确定结束?', 'sop', 'endSopEventApi', { sopId: row.id })
},
// 1-新增;2-编辑
handleEdit(addOrEdit, row) {
var params = {
addOrEdit: addOrEdit,
fromPage: '/marketing/sop/index',
$title: encodeURI(addOrEdit == 'add' ? '新建SOP' : '编辑SOP')
}
addOrEdit != 'add' && (params.id = row.id)
this.$router.push({
path: '/sop/editSop',
query: params
})
}
}
}
</script>
<style lang="scss">
.sop-overview {
.sop-box {
padding: 32px 20px 12px;
.box-txt {
line-height: 24px;
margin-bottom: 28px;
}
.step-circle {
width: 32px;
height: 32px;
line-height: 32px;
text-align: center;
color: #5058ff;
background: rgba(80, 88, 255, 0.1);
border: 1px solid #5058ff;
border-radius: 32px;
margin-right: 8px;
flex: 0 0 auto;
}
.step-line {
width: 120px;
height: 1px;
background: #5850ff;
margin: 0 20px;
}
.sop-flex {
display: flex;
flex-wrap: wrap;
}
.chart-box {
.chart-item {
position: relative;
box-sizing: border-box;
width: calc((100% - 80px) / 4);
min-width: 270px;
height: 184px;
text-align: center;
background: #ffffff;
border: 1px solid #eaeaea;
padding: 16px;
margin: 0 20px 20px 0;
.chart-pie {
height: 104px;
margin: 8px 0;
}
.sop-name {
font-weight: 600;
}
.sop-btns {
display: none;
box-sizing: border-box;
height: 100%;
width: 100%;
position: absolute;
top: 0;
left: 0;
background: rgba(244, 244, 252, 0.85);
padding: 28px 0;
.btn-item {
display: block;
width: 89px;
margin: 0 auto;
}
.btn-item:nth-child(2) {
margin: 16px auto;
}
}
}
// .chart-item:nth-child(4n + 0) {
// margin-right: 0px;
// }
.chart-item:hover .sop-btns {
display: block;
}
}
}
.p-r-20 {
padding-right: 20px;
}
}
</style>