FassionSetting.vue
12.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
<template>
<div>
<el-row :gutter="20" type="flex" style="margin-top: 20px;">
<el-col>
<div class="g-card">
<el-form ref="baseForm" :rules="rules" :model="form" label-position="right" label-width="140px">
<el-form-item label="选择海报:" prop="posterId">
<el-button v-if="!isDetail" size="mini" type="primary" icon="el-icon-plus" @click="choseDialog = true">
{{ form.posterId ? '编辑' : '选择' }}海报
</el-button>
<div style="margin-top: 10px;" v-if="form.posterUrl">
<ul class="el-upload-list el-upload-list--picture-card">
<li class="el-upload-list__item is-success">
<img style="width: 100%; height: 100%;" :src="form.posterUrl" />
<span class="el-upload-list__item-actions" v-if="!isDetail">
<span class="el-upload-list__item-delete">
<i class="el-icon-delete" @click="handleRemove"></i>
</span>
</span>
</li>
</ul>
</div>
</el-form-item>
<template v-if="form.fassionType == 1">
<el-form-item label="添加员工" required>
<SelectMemberVue
ref="selectMember"
:isDetail="isDetail"
title="添加员工"
:initData="form.addWeUserOrGroupCode.addWeUser"
@update="getMember"
></SelectMemberVue>
<div class="sub-des">
引导新客户扫码时添加以上任意成员为好友
</div>
</el-form-item>
</template>
<template v-if="form.fassionType == 2">
<el-form-item label="添加客群:" prop="addWeUserOrGroupCode.addGroupCode.chatIdList">
<template v-for="(item, index) in groupList">
<el-tag v-if="item.groupName" size="medium" :key="index">{{ item.groupName }}</el-tag>
</template>
<div v-if="!isDetail">
<el-button size="mini" type="primary" icon="el-icon-plus" @click="selectGroupFn">
{{ '添加' }}客群
</el-button>
</div>
<div class="sub-des">最多选择五个客群</div>
</el-form-item>
<el-form-item label="群满是否自动建群:">
<el-switch
v-model="form.addWeUserOrGroupCode.addGroupCode.autoCreateRoom"
:active-value="1"
:inactive-value="0"
@change="setChange"
></el-switch>
<div class="sub-des">默认以第一个群的群主作为新建群的群主</div>
</el-form-item>
<el-form-item v-if="form.addWeUserOrGroupCode.addGroupCode.autoCreateRoom" label="">
<el-card>
<el-form-item label="群名前缀:" prop="addWeUserOrGroupCode.addGroupCode.roomBaseName">
<el-input
show-word-limit
maxlength="20"
v-model="form.addWeUserOrGroupCode.addGroupCode.roomBaseName"
placeholder="请输入群名前缀"
></el-input>
</el-form-item>
<el-form-item label="群起始序号:" prop="addWeUserOrGroupCode.addGroupCode.roomBaseId">
<el-input-number
v-model="form.addWeUserOrGroupCode.addGroupCode.roomBaseId"
controls-position="right"
:min="1"
></el-input-number>
</el-form-item>
</el-card>
</el-form-item>
</template>
<el-form-item label="任务文案" prop="content" style="margin-right: 200px !important;">
<div v-if="!isDetail" style="margin-bottom: 10px;">
<el-button type="primary" @click="welcomVisible = true">从模板库中选择</el-button>
</div>
<TextareaExtend
:disabled="isDetail"
v-model="form.content"
:toolbar="isDetail ? [] : ['emoji', 'insertCustomerNickName']"
maxlength="2000"
show-word-limit
placeholder="请输入"
:autosize="{ minRows: 5, maxRows: 20 }"
clearable
:autofocus="false"
/>
</el-form-item>
</el-form>
</div>
<div class="g-footer-sticky" v-if="!isDetail">
<el-button plain @click="gotoPre">上一步</el-button>
<el-button type="primary" @click="gotoNext">下一步</el-button>
</div>
</el-col>
<el-col style="width: 370px;" v-if="!isDetail">
<div class="g-card" style="height: 100%;">
<div class="info_title">消息预览</div>
<PreviewInPhone
:name="form.fassionType == 1 ? '客户' : '客群'"
:list="[posterObj]"
:templateInfo="form.content"
></PreviewInPhone>
</div>
</el-col>
</el-row>
<!-- 选择海报 -->
<SelectPoster :choseDialog.sync="choseDialog" @itemArry="getItemArry" :moduleType="5"></SelectPoster>
<el-dialog
title="选择模板"
:visible.sync="welcomVisible"
width="60%"
append-to-body
:close-on-click-modal="false"
v-if="welcomVisible"
>
<TemplateLibrary @changeObj="changeObj" />
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="selectModle">确 定</el-button>
<el-button @click="welcomVisible = false">取 消</el-button>
</div>
</el-dialog>
<select-group :visible.sync="showSelectModal" :defaults="groupList" @submit="setSelectData"></select-group>
</div>
</template>
<script>
import PreviewInPhone from '@/components/ContentCenter/PreviewInPhone'
import SelectGroup from '@/views/drainageCode/components/SelectGroup.vue'
import { templateDetail } from '@/api/contentCenter/modleCenter'
import SelectPoster from '@/views/drainageCode/components/IdentitySelect'
import SelectMemberVue from './SelectMember.vue'
import TemplateLibrary from '@/components/ContentCenter/TemplateLibrary'
import { getPosterInfo } from '@/api/material/poster'
export default {
name: 'task-steps-setting',
components: {
SelectPoster,
SelectMemberVue,
TemplateLibrary,
SelectGroup,
PreviewInPhone
},
props: {
isDetail: {
type: Boolean,
default: false
},
baseData: {
type: Object,
defalult: {}
}
},
data() {
return {
welcomVisible: false,
choseDialog: false,
form: {
posterId: '',
posterUrl: '',
fassionType: 1,
addWeUserOrGroupCode: {
addWeUser: {
executeUserCondit: {
change: false,
weUserIds: []
},
executeDeptCondit: {
change: false,
deptIds: [],
posts: []
}
},
addGroupCode: {
autoCreateRoom: 0, //当群满了后,是否自动新建群。0-否;1-是。 默认为0
roomBaseName: '', //自动建群的群名前缀,当auto_create_room为1时有效
roomBaseId: null, //自动建群的群起始序号,当auto_create_room为1时有效
chatIdList: '',
groupNames: ''
}
},
content: ''
},
rules: {
posterId: [{ required: true, message: '请选择海报', trigger: 'blur' }],
'addWeUserOrGroupCode.addGroupCode.chatIdList': [{ required: true, message: '请添加客群', trigger: 'blur' }],
'addWeUserOrGroupCode.addGroupCode.roomBaseName': [
{ required: true, message: '请输入群名前缀', trigger: 'blur' }
],
'addWeUserOrGroupCode.addGroupCode.roomBaseId': [
{ required: true, message: '请输入群起始序号', trigger: 'blur' }
],
content: [{ required: true, message: '请输入任务文案', trigger: 'blur' }]
},
posterObj: {},
groupList: [],
showSelectModal: false
}
},
watch: {
baseData: {
handler(val) {
this.form = val
this.$forceUpdate()
this.setData()
},
immediate: true
}
},
methods: {
setData() {
if (this.form.posterId) {
getPosterInfo(this.form.posterId).then((res) => {
this.posterObj = res.data
this.posterObj.materialName = this.form.fassionName
})
}
if (!this.form.addWeUserOrGroupCode) {
this.form.addWeUserOrGroupCode = {
addWeUser: {
executeUserCondit: {
change: false,
weUserIds: []
},
executeDeptCondit: {
change: false,
deptIds: [],
posts: []
}
},
addGroupCode: {
autoCreateRoom: 0, //当群满了后,是否自动新建群。0-否;1-是。 默认为0
roomBaseName: '', //自动建群的群名前缀,当auto_create_room为1时有效
roomBaseId: null, //自动建群的群起始序号,当auto_create_room为1时有效
chatIdList: '',
groupNames: ''
}
}
}
if (this.form.fassionType == 2) {
if (this.form.addWeUserOrGroupCode.addGroupCode && this.form.addWeUserOrGroupCode.addGroupCode.chatIdList) {
this.groupList = []
let arr1 = this.form.addWeUserOrGroupCode.addGroupCode.chatIdList.split(',')
let arr2 = this.form.addWeUserOrGroupCode.addGroupCode.groupNames.split(',')
arr1.forEach((dd, index) => {
let obj = {
chatId: dd,
groupName: arr2[index]
}
this.groupList.push(obj)
})
}
}
},
setChange(data) {
if (data == 0) {
this.form.addWeUserOrGroupCode.addGroupCode.roomBaseName = ''
this.form.addWeUserOrGroupCode.addGroupCode.roomBaseId = ''
}
},
gotoNext() {
this.$refs.baseForm.validate((validate) => {
if (validate) {
if (this.form.fassionType == 1) {
if (this.$refs.selectMember.validateFn()) {
this.$refs.selectMember.changeFn()
this.updateData()
this.$emit('next', 2)
}
} else {
this.updateData()
this.$emit('next', 2)
}
}
})
},
gotoPre() {
if (this.form.fassionType == 1) {
this.$refs.selectMember.changeFn()
}
this.updateData()
this.$emit('next', 0)
},
updateData() {
this.$emit('update', this.form)
},
selectGroupFn() {
this.showSelectModal = true
},
setSelectData(data) {
if (data && data.length) {
this.groupList = data
this.form.addWeUserOrGroupCode.addGroupCode.chatIdList = this.groupList
.map((dd) => {
return dd.chatId
})
.join(',')
this.form.addWeUserOrGroupCode.addGroupCode.groupNames = this.groupList
.map((dd) => {
return dd.groupName
})
.join(',')
console.log(this.form.addWeUserOrGroupCode.addGroupCode)
} else {
this.groupList = []
this.form.addWeUserOrGroupCode.addGroupCode.chatIdList = ''
this.form.addWeUserOrGroupCode.addGroupCode.groupNames = ''
}
this.updateData()
},
changeObj(id) {
if (id) {
templateDetail(id).then((res) => {
this.selectObj = res.data
})
}
},
selectModle() {
if (this.selectObj) {
this.welcomVisible = false
this.form.content = this.selectObj.templateInfo
} else {
this.$message.error('请选择模板')
}
},
handleRemove() {
this.form.posterId = ''
this.form.posterUrl = ''
},
getItemArry(data) {
console.log(data)
this.form.posterUrl = data[0].materialUrl
this.form.posterId = data[0].id
this.posterObj = data[0]
this.posterObj.materialName = this.form.fassionName
},
getMember(data) {
this.form.addWeUserOrGroupCode.addWeUser = data
}
}
}
</script>
<style lang="scss" scoped>
.sub-des {
font-size: 12px;
font-weight: 400;
color: #999999;
}
.info_title {
font-size: 16px;
font-weight: 600;
color: #1d2129;
margin-bottom: 10px;
}
</style>