add.vue
12.4 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
<!--
* @Author: yangming yangming@didihu.com.cn
* @Date: 2023-09-05 17:24:08
* @LastEditors: yangming yangming@didihu.com.cn
* @LastEditTime: 2024-01-16 15:13:29
* @FilePath: \scrm-micro-journey\src\views\journeyConfig\index.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
<div class="journey-main">
<div class="bg-fff pb20 journey-config gl-form-page">
<el-form ref="form" :model="addForm" label-width="150px" rules="rules">
<el-form-item label="旅程名称:" :size="size" prop="name">
<el-input v-model="addForm.name" maxLength="20"></el-input>
</el-form-item>
<el-form-item label="圈化人群的方式:" :size="size">
<el-select v-model="addForm.region" placeholder="请选择" @change="handleSelectType" :disabled="query.title">
<el-option :label="item.name" :value="item.code" :key="item.code" v-for="item in sopDataTypes"></el-option>
</el-select>
</el-form-item>
</el-form>
</div>
<div class="journey-step bg-fff pb20">
<div class="journey-step-title border-title">
客户旅程阶段配置
</div>
<div class="journey-step-body">
<div class="journey-step-title">
<span>旅程名称</span>
<span>操作</span>
</div>
<div class="journey-step-info" v-for="(val, k) in configList" :key="k">
<template v-if="val.label">
<collapse-item :stepItem="val" :activityName="addForm.name" :key="k" :ref="`collapse_${k}`">
<el-button type="text" @click.stop="openCondition(k, val)">新增条件</el-button>
<el-button type="text" @click.stop="handleEditJ(k)">编辑名称</el-button>
<el-button type="text" @click.stop="handleDelete(k)">删除阶段</el-button>
</collapse-item>
</template>
<div class="journey-add-panel" v-if="addStatus && k == addNo">
<div class="flex-column-center ">
<el-input v-model.trim="modelInput.label" maxLength="20"></el-input>
<div class="mark-item">
<label>手动标记:</label>
<el-radio-group v-model="modelInput.editable">
<el-radio :label="true">支持</el-radio>
<el-radio :label="false">不支持</el-radio>
</el-radio-group>
</div>
</div>
<div class="mark-operate">
<el-button type="text" @click.stop="saveStep">保存</el-button>
<el-button type="text" @click.stop="cancelStep">取消</el-button>
</div>
</div>
</div>
</div>
<div class="journey-add" @click="addStep" v-if="!addStatus">
<i class="el-icon-circle-plus-outline"></i>
新建旅程阶段
</div>
</div>
<div class="model-footer">
<el-button size="small" @click.stop="cancelModel">取消</el-button>
<el-button size="small" type="primary" @click.stop="saveModel" :disabled="addStatus">确认</el-button>
</div>
</div>
</template>
<script>
import CollapseItem from './components/CollapseItem'
export default {
components: {
CollapseItem
// concatActivity
// sopItem
},
data() {
return {
isEdit: false,
drawerVisible: false,
dataTypeCode: '',
sopDataTypes: [],
activityVisible: false,
addStatus: false,
journeyStatus: 1,
activityInfo: {},
configList: [],
modelInput: {},
query: {},
addForm: {
name: '',
region: ''
},
rules: {
name: [{ required: true, message: '请输入旅程名称', trigger: 'blur' }]
}
}
},
provide() {
return {
stepList: this.stepList,
app: this
}
},
mounted() {
this.query = this.$route.query || {}
if (this.query.title) {
this.addForm.name = this.query.title
this.getDetail()
}
this.sopDataTypesList()
},
watch: {
'addForm.region'(val) {
this.dataTypeCode = val
this.$apis.journeyModel.sopConditionList({ dataTypeCode: val }).then(res => {
this.stepList = res
})
}
},
computed: {
journeyList() {
return this.configList.map(i => i.label)
}
},
methods: {
showError(message) {
this.$message({
type: 'error',
message
})
},
closeActivity() {
this.activityVisible = false
},
openCondition(k, val) {
this.$refs[`collapse_${k}`][0].activityVisible = true
this.$refs[`collapse_${k}`][0].activityConfig = { ...val, name: this.addForm.name }
},
//保存模板
saveModel() {
if (!this.addForm.name) {
return this.showError('请输入旅程旅程名称!')
}
if (!this.addForm.region) {
return this.showError('请选择圈化人群的方式')
}
let stage = {}
const nodes = []
this.configList = this.configList.filter(item => item.label)
this.configList.forEach((item, index) => {
stage['stage' + (index + 1)] = {
editable: item.editable,
conditions: item.conditionsList,
value: item.label
}
item.sopList.forEach(days => {
days.forEach(k => {
nodes.push({
nodeParamDef: JSON.stringify({
stage: { defaultValue: k.stage },
day: { defaultValue: k.day },
time: { defaultValue: k.time }
}),
nodeProtoId: k.taskType
})
})
})
})
const dataTypeCode = {
dataTypeCode: { defaultValue: this.addForm.region },
stages: {
defaultValue: stage
}
}
let params = {
tplId: this.query.instId,
tplName: this.addForm.name,
tplParamDef: JSON.stringify(dataTypeCode),
nodes
}
this.$apis.journeyModel.sopTplsSave(params).then(res => {
if (res) {
this.$router.go(-1)
}
})
},
cancelModel() {
this.$confirm('内容尚未保存,是否确认返回到列表', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
})
.then(() => {
this.$router.go(-1)
})
.catch(() => {})
},
handleDelete(k) {
this.$confirm('删除旅程阶段不影响已经下发的旅程实例?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
})
.then(() => {
this.configList.splice(k, 1)
this.$message({
type: 'success',
message: '删除成功!'
})
})
.catch(() => {})
},
//保存客户旅程阶段配置
saveStep() {
const len = this.addNo,
{ label, editable } = this.modelInput
if (!label) {
this.$message({
type: 'error',
message: '请输入旅程阶段名称!'
})
return
}
Object.assign(this.configList[len], { label, editable })
this.addStatus = false
},
cancelStep() {
this.addStatus = false
if (this.isEdit) return
this.configList.splice(this.addNo, 1)
},
handleEditJ(i) {
this.addNo = i
this.isEdit = true
this.addStatus = true
this.modelInput = {
label: this.configList[i].label,
editable: this.configList[i].editable
}
},
//添加客户旅程阶段配置
addStep() {
this.isEdit = false
this.addStatus = true
this.modelInput = {
label: '',
editable: true
}
this.configList.push({
label: '',
isExpaned: false,
conditionsList: [],
sopList: []
})
this.addNo = this.configList.length - 1
},
//获取圈化人群的方式
sopDataTypesList() {
this.$apis.journeyModel.sopDataTypesList({}).then(res => {
this.sopDataTypes = res || [{}]
this.addForm.region = this.sopDataTypes[0].code
})
},
//获取详情
getDetail() {
this.$apis.journeyModel.getInstIdDetail({ instId: this.query.instId }).then(res => {
const instParam = JSON.parse(res.tplParamDef)
this.addForm.region = instParam.dataTypeCode.defaultValue
const stages = Object.values(instParam.stages.defaultValue)
const nodes = res.nodes
const configList = []
for (let i = 0; i < stages.length; i++) {
const s = stages[i]
if (!s) continue
let list = []
for (let v of nodes) {
console.log(v.nodeParamDef && JSON.parse(v.nodeParamDef).stage, 'v.nodeParamDef && JSON.parse(v.nodeParamDef).stage')
if (v.nodeParamDef && JSON.parse(v.nodeParamDef).stage.defaultValue == s.value) {
const nodeParamDef = JSON.parse(v.nodeParamDef)
list.push({
day: nodeParamDef.day?.defaultValue,
stage: nodeParamDef.stage?.defaultValue,
taskType: v.nodeProtoId,
stageid: nodeParamDef.stageid?.defaultValue,
time: nodeParamDef.time?.defaultValue
})
}
}
list = list.filter(item => item.day)
list.sort((a, b) => {
if (a.day == b.day) {
return a.time.replace(':', '') - b.time.replace(':', '')
} else {
return a.day - b.day
}
})
console.log(list, 'list')
const sopList = this.groupBy(list, 'day')
configList.push({
label: s.value,
isExpaned: false,
editable: s.editable,
conditionsList: s.conditions || [],
sopList
})
}
this.configList = configList
})
},
//清空sop任务
clearSop() {
this.configList.forEach(item => {
item.conditionsList = []
item.sopList = []
})
},
//修改圈化人群的方式
handleSelectType(e) {
const code = this.dataTypeCode
if (!code) return
this.$confirm('该操作将清空进入条件及SOP任务,是否确认修改?', '提示', {
confirmButtonText: '是',
cancelButtonText: '否',
type: 'warning'
})
.then(() => {
this.clearSop()
})
.catch(() => {
this.addForm.region = code
})
},
groupBy(list, name) {
const m = new Map()
list.map(item => {
m.set(item[name], [...(m.get(item[name]) || ''), item])
})
return [...m.values()]
}
}
}
</script>
<style lang="scss" scoped>
.concat-color {
/deep/ .el-icon-warning {
color: #5850ff;
}
}
.journey-main {
.journey-config {
margin-bottom: 16px;
padding: 20px;
}
.journey-step {
padding-bottom: 30px;
}
.journey-step-config {
&:first-child {
margin-bottom: 20px;
}
i {
font-size: 14px;
&.el-icon-warning {
color: #fdb757;
}
&.el-icon-success {
color: #2cca74;
}
}
span {
font-size: 14px;
color: #666666;
margin-left: 5px;
display: inline-block;
width: 166px;
}
}
.journey-step-body {
border: 1px solid #e5e5e5;
margin: 32px 20px 0px;
.journey-step-title {
height: 52px;
font-size: 14px;
color: #333333;
line-height: 52px;
padding: 0px 120px 0px 40px;
background: #f4f6fc;
display: flex;
justify-content: space-between;
}
}
.journey-add-panel {
padding: 0px 20px;
height: 52px;
background: #e9e8ff;
border: 1px solid #e5e5e5;
display: flex;
align-items: center;
justify-content: space-between;
/deep/ {
.el-input {
width: 232px;
height: 32px;
background: #ffffff;
border: 1px solid #e5e5e5;
border-radius: 4px;
}
.el-input__inner {
height: 32px;
}
}
.mark-item {
margin-left: 30px;
font-size: 14px;
color: #333333;
}
}
.journey-add {
display: flex;
align-items: center;
margin-left: 20px;
margin-top: 20px;
cursor: pointer;
i {
font-size: 20px;
margin-right: 6px;
}
font-size: 12px;
color: #5850ff;
}
}
</style>
<style lang="scss">
.concat-color {
.el-icon-warning {
color: #5850ff;
}
}
.model-footer {
margin: 30px auto;
text-align: center;
}
</style>