|
@@ -1,18 +1,349 @@
|
1
|
1
|
<template>
|
2
|
|
- <div>
|
3
|
|
- 新建群活码
|
|
2
|
+ <div class="create-wrap">
|
|
3
|
+ <!-- S 返回 -->
|
|
4
|
+ <div class="backBox" @click="$router.go(-1)">
|
|
5
|
+ <div class="back">
|
|
6
|
+ <i class="el-icon-back" />
|
|
7
|
+ <span>返回</span>
|
|
8
|
+ </div>
|
|
9
|
+ </div>
|
|
10
|
+ <!-- E 返回 -->
|
|
11
|
+ <!-- S 表单内容 -->
|
|
12
|
+ <div v-loading="loading" class="bg-ffffff createMassMsg" style="padding: 15px 30px;">
|
|
13
|
+ <!-- S 基础信息 -->
|
|
14
|
+ <h3 class="bigTitle">基础信息</h3>
|
|
15
|
+ <div class="regulations">
|
|
16
|
+ <label><em>*</em>渠道名称</label>
|
|
17
|
+ <el-input
|
|
18
|
+ v-model.trim="groupForm.name"
|
|
19
|
+ placeholder="请输入渠道名称"
|
|
20
|
+ style="width:300px"
|
|
21
|
+ maxlength="32"
|
|
22
|
+ size="small"
|
|
23
|
+ show-word-limit
|
|
24
|
+ clearable
|
|
25
|
+ />
|
|
26
|
+ </div>
|
|
27
|
+ <div class="regulations" style="align-items: center">
|
|
28
|
+ <label><em style="opacity: 0;">*</em>选择分组</label>
|
|
29
|
+ <el-select
|
|
30
|
+ v-model="groupForm.group_id"
|
|
31
|
+ size="small"
|
|
32
|
+ clearable
|
|
33
|
+ filterable
|
|
34
|
+ placeholder="请选择分组"
|
|
35
|
+ style="width: 300px"
|
|
36
|
+ >
|
|
37
|
+ <el-option v-for="item in groupOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
38
|
+ </el-select>
|
|
39
|
+ <div class="newGroupCss" @click="$refs.dialogGroupRef.dialogVisible = true">新建分组</div>
|
|
40
|
+ </div>
|
|
41
|
+ <div class="regulations">
|
|
42
|
+ <label><em>*</em>选择群聊</label>
|
|
43
|
+ <chatGroupOptions
|
|
44
|
+ ref="chatGroupOptions"
|
|
45
|
+ style="margin: 0;"
|
|
46
|
+ width="300px"
|
|
47
|
+ :chatListResult="groupForm.chat_id_list"
|
|
48
|
+ @change="onChangeChatGroup"
|
|
49
|
+ />
|
|
50
|
+ </div>
|
|
51
|
+ <div class="regulations">
|
|
52
|
+ <label><em style="opacity: 0;">*</em>进群方式</label>
|
|
53
|
+ <el-radio-group v-model="groupForm.join_type">
|
|
54
|
+ <el-radio :label="1">顺序进群</el-radio>
|
|
55
|
+ <el-radio :label="2">随机进群</el-radio>
|
|
56
|
+ </el-radio-group>
|
|
57
|
+ </div>
|
|
58
|
+ <div class="regulations" style="align-items: center">
|
|
59
|
+ <label>渠道群管理</label>
|
|
60
|
+ <div @click="handleShowLimitTips" class="limitBox">
|
|
61
|
+ <el-switch
|
|
62
|
+ v-model="groupForm.is_limit"
|
|
63
|
+ :disabled="!groupForm.chat_id_list.length"
|
|
64
|
+ active-color="#13ce66"
|
|
65
|
+ inactive-color="#ddd"
|
|
66
|
+ :active-value="1"
|
|
67
|
+ :inactive-value="0"
|
|
68
|
+ @change="onChangeSwitchLimit"
|
|
69
|
+ />
|
|
70
|
+ </div>
|
|
71
|
+ </div>
|
|
72
|
+ <div v-show="groupForm.is_limit" class="listBox">
|
|
73
|
+ <el-table border :data="groupForm.chat_id_list" tooltip-effect="dark" :header-cell-style="()=>{return { backgroundColor: '#f9f9f9 !important' }}" style="width: 100%">
|
|
74
|
+ <el-table-column label="群名称" align="center" prop="name" />
|
|
75
|
+ <el-table-column label="人数上限" align="center">
|
|
76
|
+ <template slot="header" slot-scope="scope">
|
|
77
|
+ <em style="color: #ff0000;">*</em>人数上限
|
|
78
|
+ </template>
|
|
79
|
+ <template slot-scope="{ row }">
|
|
80
|
+ <el-input size="mini" v-model="row.user_limit" />
|
|
81
|
+ </template>
|
|
82
|
+ </el-table-column>
|
|
83
|
+ <el-table-column label="状态" align="center">
|
|
84
|
+ <template slot-scope="{ row }">
|
|
85
|
+ <el-switch
|
|
86
|
+ v-model="row.status"
|
|
87
|
+ :active-value="1"
|
|
88
|
+ :inactive-value="0"
|
|
89
|
+ active-color="#13ce66"
|
|
90
|
+ inactive-color="#ddd"
|
|
91
|
+ />
|
|
92
|
+ </template>
|
|
93
|
+ </el-table-column>
|
|
94
|
+ <el-table-column label="操作" align="center" width="80px">
|
|
95
|
+ <template slot-scope="{ row, $index }">
|
|
96
|
+ <div class="c-00B38A pointer lMar8" @click="onClickDelChat(row, $index)">删除</div>
|
|
97
|
+ </template>
|
|
98
|
+ </el-table-column>
|
|
99
|
+ </el-table>
|
|
100
|
+ </div>
|
|
101
|
+ <!-- E 基础信息 -->
|
|
102
|
+
|
|
103
|
+ <!-- S 客服设置 -->
|
|
104
|
+ <div class="line" style="margin-top:20px"></div>
|
|
105
|
+ <h3 class="bigTitle">客服设置</h3>
|
|
106
|
+ <div class="regulations" style="align-items: center">
|
|
107
|
+ <label><em>*</em>生效成员</label>
|
|
108
|
+ <self-customerservice
|
|
109
|
+ title=''
|
|
110
|
+ width="300px"
|
|
111
|
+ source="channelCode"
|
|
112
|
+ ref="selfKefu"
|
|
113
|
+ style="margin:0;"
|
|
114
|
+ :afferent_users="groupForm.user_list"
|
|
115
|
+ @customerDefine="onChangeUserList"
|
|
116
|
+ />
|
|
117
|
+ <div class="user-tips">当客户点击客服时,会引导客户随机添加一名客服成员的企业微信</div>
|
|
118
|
+ </div>
|
|
119
|
+ <div class="regulations">
|
|
120
|
+ <label><em>*</em>引导话术</label>
|
|
121
|
+ <el-input
|
|
122
|
+ v-model.trim="groupForm.leading_words"
|
|
123
|
+ placeholder="请输入引导话术"
|
|
124
|
+ style="width:300px"
|
|
125
|
+ maxlength="20"
|
|
126
|
+ size="small"
|
|
127
|
+ show-word-limit
|
|
128
|
+ clearable
|
|
129
|
+ />
|
|
130
|
+ </div>
|
|
131
|
+ <!-- E 客服设置 -->
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+ <!-- S 按钮 -->
|
|
135
|
+ <div class="line" style="margin-top:20px" />
|
|
136
|
+ <div style="margin-top: 20px"><el-button type="primary" @click="onClickSave">保存</el-button></div>
|
|
137
|
+ <!-- E 按钮 -->
|
|
138
|
+ </div>
|
|
139
|
+ <!-- E 表单内容 -->
|
|
140
|
+
|
|
141
|
+ <!-- S 新建分组 - 弹框 -->
|
|
142
|
+ <dialogGroup
|
|
143
|
+ ref="dialogGroupRef"
|
|
144
|
+ :propsData="{ dialogTitle:'新建' }"
|
|
145
|
+ @init="handleGetGroupOptions"
|
|
146
|
+ />
|
|
147
|
+ <!-- E 新建分组 - 弹框 -->
|
4
|
148
|
</div>
|
5
|
149
|
</template>
|
6
|
150
|
|
7
|
151
|
<script>
|
|
152
|
+import dialogGroup from './components/dialogGroup.vue'
|
|
153
|
+import chatGroupOptions from './components/chatGroupOptions.vue'
|
|
154
|
+import selfCustomerservice from '@/components/assembly/screen/customerService.vue'
|
|
155
|
+import Sortable from 'sortablejs'
|
|
156
|
+
|
8
|
157
|
export default {
|
9
|
158
|
name: "createGroupCode",
|
10
|
|
- components: {},
|
|
159
|
+ components: {
|
|
160
|
+ dialogGroup,
|
|
161
|
+ chatGroupOptions,
|
|
162
|
+ selfCustomerservice,
|
|
163
|
+ },
|
11
|
164
|
data() {
|
12
|
|
- return {}
|
|
165
|
+ return {
|
|
166
|
+ loading: false,
|
|
167
|
+ groupOptions: [], // 分组选项
|
|
168
|
+ groupForm: {
|
|
169
|
+ name: '', // 渠道名称
|
|
170
|
+ group_id: '', // 分组id
|
|
171
|
+ chat_id_list: [], // 客户群列表
|
|
172
|
+ join_type: 1, // 进群方式
|
|
173
|
+ is_limit: 0, // 渠道群管理(是否设置群上限)
|
|
174
|
+ user_list: [], // 客服(生效成员) 数组回显 'a,b' => ['a', 'b']
|
|
175
|
+ leading_words: '', // 引导话术
|
|
176
|
+ }
|
|
177
|
+ }
|
|
178
|
+ },
|
|
179
|
+ computed: {
|
|
180
|
+ isEdit() {
|
|
181
|
+ const { id = '', type = '' } = this.$route.query
|
|
182
|
+ return id && type === 'edit'
|
|
183
|
+ },
|
|
184
|
+ isCopy() {
|
|
185
|
+ const { id = '', type = '' } = this.$route.query
|
|
186
|
+ return id && type === 'copy'
|
|
187
|
+ },
|
|
188
|
+ },
|
|
189
|
+ created() {
|
|
190
|
+ // 获取分组列表
|
|
191
|
+ this.handleGetGroupOptions()
|
|
192
|
+ },
|
|
193
|
+ mounted() {
|
|
194
|
+ // 表格行拖拽
|
|
195
|
+ this.handleRowDrop()
|
|
196
|
+ },
|
|
197
|
+ methods: {
|
|
198
|
+ // 注册表格行拖拽事件
|
|
199
|
+ handleRowDrop() {
|
|
200
|
+ const tbody = document.querySelector('.el-table__body-wrapper tbody')
|
|
201
|
+ const _this = this
|
|
202
|
+ Sortable.create(tbody, {
|
|
203
|
+ onEnd({ newIndex, oldIndex }) {
|
|
204
|
+ if (newIndex == oldIndex) return
|
|
205
|
+ _this.groupForm.chat_id_list.splice(
|
|
206
|
+ newIndex,
|
|
207
|
+ 0,
|
|
208
|
+ _this.groupForm.chat_id_list.splice(oldIndex, 1)[0]
|
|
209
|
+ )
|
|
210
|
+ const newArray = _this.groupForm.chat_id_list.slice(0)
|
|
211
|
+ _this.groupForm.chat_id_list = []
|
|
212
|
+ _this.$nextTick(() => {
|
|
213
|
+ _this.groupForm.chat_id_list = newArray
|
|
214
|
+ _this.$refs.chatGroupOptions.chatListSelected = [] // 重置群聊组件"已选列表"
|
|
215
|
+ })
|
|
216
|
+ }
|
|
217
|
+ })
|
|
218
|
+ },
|
|
219
|
+ // 点击保存按钮
|
|
220
|
+ async onClickSave() {
|
|
221
|
+ console.log('onClickSave this.groupForm => ', JSON.parse(JSON.stringify(this.groupForm)))
|
|
222
|
+ try {
|
|
223
|
+ // 表单判空校验
|
|
224
|
+ await this.handleFormValidate()
|
|
225
|
+ // 获取请求地址 & 参数
|
|
226
|
+ const { url, params } = this.handleGetParams()
|
|
227
|
+
|
|
228
|
+ console.log('params => ', JSON.parse(JSON.stringify(params)))
|
|
229
|
+ console.log('url => ', url)
|
|
230
|
+
|
|
231
|
+ this.loading = true
|
|
232
|
+ const { data: res } = await this.$axios.post(url, params)
|
|
233
|
+ console.log('res => ', res)
|
|
234
|
+ if (res && res.errno == 0) {
|
|
235
|
+ this.$message.success('保存成功')
|
|
236
|
+ this.$router.go(-1)
|
|
237
|
+ } else if (res.errno != 4002) {
|
|
238
|
+ this.$message.warning(res.err || '操作失败')
|
|
239
|
+ }
|
|
240
|
+ } catch (error) {
|
|
241
|
+ console.log('error => ', error)
|
|
242
|
+ } finally {
|
|
243
|
+ this.loading = false
|
|
244
|
+ }
|
|
245
|
+ },
|
|
246
|
+ // 表单校验
|
|
247
|
+ handleFormValidate() {
|
|
248
|
+ const { name, chat_id_list, is_limit, user_list, leading_words } = this.groupForm
|
|
249
|
+ const isEmpty = chat_id_list.some(chat => Number(chat.user_limit) === 0)
|
|
250
|
+ return new Promise((resolve, reject) => {
|
|
251
|
+ if (!name) {
|
|
252
|
+ this.$message.warning('请输入渠道名称')
|
|
253
|
+ reject('表单校验未通过')
|
|
254
|
+ } else if (!chat_id_list.length) {
|
|
255
|
+ this.$message.warning('请选择群聊')
|
|
256
|
+ reject('表单校验未通过')
|
|
257
|
+ } else if (is_limit === 1 && isEmpty) {
|
|
258
|
+ this.$message.warning('请输入人数上限')
|
|
259
|
+ reject('表单校验未通过')
|
|
260
|
+ } else if (!user_list.length) {
|
|
261
|
+ this.$message.warning('请选择生效成员')
|
|
262
|
+ reject('表单校验未通过')
|
|
263
|
+ } else if (!leading_words) {
|
|
264
|
+ this.$message.warning('请输入引导话术')
|
|
265
|
+ reject('表单校验未通过')
|
|
266
|
+ } else {
|
|
267
|
+ resolve('表单校验通过')
|
|
268
|
+ }
|
|
269
|
+ })
|
|
270
|
+ },
|
|
271
|
+ // 整理请求参数
|
|
272
|
+ handleGetParams() {
|
|
273
|
+ const url = `${this.URL.BASEURL}${this.URL[this.isEdit ? 'groupCode_editRule' : 'groupCode_setRule']}`
|
|
274
|
+ const { name, group_id, join_type, is_limit, user_list, leading_words, chat_id_list } = this.groupForm
|
|
275
|
+ const params = {
|
|
276
|
+ name,
|
|
277
|
+ group_id,
|
|
278
|
+ join_type,
|
|
279
|
+ is_limit,
|
|
280
|
+ user_list: user_list.join(','),
|
|
281
|
+ leading_words,
|
|
282
|
+ chat_id_list: JSON.stringify(chat_id_list),
|
|
283
|
+ }
|
|
284
|
+
|
|
285
|
+ return { url, params }
|
|
286
|
+ },
|
|
287
|
+ // 获取分组列表
|
|
288
|
+ async handleGetGroupOptions() {
|
|
289
|
+ const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.channel_groupList, {
|
|
290
|
+ params: {
|
|
291
|
+ type: 2, // 1:渠道活码 2:群活码
|
|
292
|
+ page: 1,
|
|
293
|
+ pagesize: 500,
|
|
294
|
+ }
|
|
295
|
+ })
|
|
296
|
+ if (res && res.errno == 0) {
|
|
297
|
+ this.groupOptions = res.rst.data
|
|
298
|
+ } else if (res.errno != 4002) {
|
|
299
|
+ this.$message.warning(res.err)
|
|
300
|
+ }
|
|
301
|
+ },
|
|
302
|
+ // 渠道群管理提示
|
|
303
|
+ handleShowLimitTips() {
|
|
304
|
+ if (!this.groupForm.chat_id_list.length) {
|
|
305
|
+ this.$message.error('请先选择群聊')
|
|
306
|
+ }
|
|
307
|
+ },
|
|
308
|
+ onChangeSwitchLimit(){
|
|
309
|
+ if (!this.groupForm.chat_id_list.length) {
|
|
310
|
+ this.$message.error('请先选择群聊')
|
|
311
|
+ return
|
|
312
|
+ }
|
|
313
|
+ },
|
|
314
|
+ // 渠道群管理列表 - 删除
|
|
315
|
+ onClickDelChat(row, idx) {
|
|
316
|
+ this.groupForm.chat_id_list.splice(idx, 1)
|
|
317
|
+ this.$refs.chatGroupOptions.chatListSelected = [] // 重置群聊组件"已选列表"
|
|
318
|
+ // 列表为空 => 关闭"渠道群管理"按钮
|
|
319
|
+ if (!this.groupForm.chat_id_list.length) {
|
|
320
|
+ this.groupForm.is_limit = 0
|
|
321
|
+ }
|
|
322
|
+ },
|
|
323
|
+ // 监听"选择客服"(生效成员)变化
|
|
324
|
+ onChangeUserList(val) {
|
|
325
|
+ this.groupForm.user_list = Array.isArray(val) && val.length ? val : []
|
|
326
|
+ },
|
|
327
|
+ // 监听"选择群聊"变化
|
|
328
|
+ onChangeChatGroup(selectedChat) {
|
|
329
|
+ const { chat_id_list: currentChats } = this.groupForm
|
|
330
|
+ // 整理数据结构 => 初始化新选择的群聊数据
|
|
331
|
+ const newChats = selectedChat.map(s => ({
|
|
332
|
+ chat_id: s.chat_id,
|
|
333
|
+ name: s.name,
|
|
334
|
+ user_limit: 0,
|
|
335
|
+ enable: 1,
|
|
336
|
+ status: 1,
|
|
337
|
+ }))
|
|
338
|
+ // 在"当前页面的群聊列表"中查找是否已存在 => 去重后得到当前页面新群聊列表
|
|
339
|
+ newChats.forEach((newChat, idx) => {
|
|
340
|
+ const isFoundChat = currentChats.find(c => newChat.chat_id === c.chat_id)
|
|
341
|
+ if (isFoundChat) newChats.splice(idx, 1, isFoundChat)
|
|
342
|
+ })
|
|
343
|
+ this.groupForm.chat_id_list = [...newChats]
|
|
344
|
+ console.log('this.groupForm.chat_id_list => ', this.groupForm.chat_id_list)
|
|
345
|
+ },
|
13
|
346
|
},
|
14
|
|
- created(){},
|
15
|
|
- methods:{},
|
16
|
347
|
}
|
17
|
348
|
</script>
|
18
|
349
|
<style lang="scss">
|
|
@@ -28,7 +359,98 @@ export default {
|
28
|
359
|
}
|
29
|
360
|
</style>
|
30
|
361
|
<style lang="scss" scoped>
|
31
|
|
-@import "../customOperate/create.scss";
|
|
362
|
+.backBox {
|
|
363
|
+ background: #ffffff;
|
|
364
|
+ padding: 15px;
|
|
365
|
+ margin-bottom: 10px;
|
|
366
|
+ .back {
|
|
367
|
+ font-size: 16px;
|
|
368
|
+ font-weight: bold;
|
|
369
|
+ color: #333333;
|
|
370
|
+ cursor: pointer;
|
|
371
|
+ display: inline-block;
|
|
372
|
+ }
|
|
373
|
+}
|
|
374
|
+.bigTitle {
|
|
375
|
+ color: #333333;
|
|
376
|
+ font-size: 16px;
|
|
377
|
+ line-height: 22px;
|
|
378
|
+ font-weight: bold;
|
|
379
|
+}
|
|
380
|
+.createMassMsg{
|
|
381
|
+ width: 100%;
|
|
382
|
+ min-height: 400px;
|
|
383
|
+
|
|
384
|
+ .line {
|
|
385
|
+ width: 730px;
|
|
386
|
+ height: 1px;
|
|
387
|
+ background: #e9e9e9;
|
|
388
|
+ margin: 40px 0 20px;
|
|
389
|
+ }
|
|
390
|
+ .regulations {
|
|
391
|
+ display: flex;
|
|
392
|
+ align-items: flex-start;
|
|
393
|
+ margin-top: 28px;
|
|
394
|
+ label {
|
|
395
|
+ width: 100px;
|
|
396
|
+ color: #333333;
|
|
397
|
+ font-size: 14px;
|
|
398
|
+ line-height: 28px;
|
|
399
|
+ em {
|
|
400
|
+ color: #ff0000;
|
|
401
|
+ }
|
|
402
|
+ }
|
|
403
|
+ .user-tips {
|
|
404
|
+ color: #AAAAAA;
|
|
405
|
+ font-size: 13px;
|
|
406
|
+ margin-left: 20px;
|
|
407
|
+ }
|
|
408
|
+ }
|
|
409
|
+ .regulations2 {
|
|
410
|
+ label {
|
|
411
|
+ width: 70px;
|
|
412
|
+ line-height: 30px;
|
|
413
|
+ }
|
|
414
|
+ }
|
|
415
|
+}
|
|
416
|
+.detail_status{
|
|
417
|
+ line-height: 30px;
|
|
418
|
+ height: 30px;
|
|
419
|
+ padding: 3px 10px;
|
|
420
|
+ border-radius: 21px;
|
|
421
|
+ font-size: 12px;
|
|
422
|
+ margin-left: 20px;
|
|
423
|
+}
|
|
424
|
+.status_wait{
|
|
425
|
+ background: #FFF2ED;
|
|
426
|
+ border: 1px solid #FF864F;
|
|
427
|
+ color: #FF864F;
|
|
428
|
+}
|
|
429
|
+.status_del{
|
|
430
|
+ background: #FFF5F5;
|
|
431
|
+ border: 1px solid #FF604D;
|
|
432
|
+ color: #FF604D;
|
|
433
|
+}
|
|
434
|
+.status_fail{
|
|
435
|
+ background: #F4F4F4;
|
|
436
|
+ border: 1px solid #ADADAD;
|
|
437
|
+ color: #ADADAD;
|
|
438
|
+}
|
|
439
|
+.status_ing{
|
|
440
|
+ background: #F4FAFF;
|
|
441
|
+ border: 1px solid #007AFE;
|
|
442
|
+ color: #007AFE;
|
|
443
|
+}
|
|
444
|
+.status_success{
|
|
445
|
+ background: #EEFFF3;
|
|
446
|
+ border: 1px solid #00B38A;
|
|
447
|
+ color: #00B38A;
|
|
448
|
+}
|
|
449
|
+.splitLine {
|
|
450
|
+ width: 100%;
|
|
451
|
+ height: 10px;
|
|
452
|
+ background: #f5f6f8;
|
|
453
|
+}
|
32
|
454
|
.listBox{
|
33
|
455
|
margin-left: 90px;
|
34
|
456
|
width: 730px;
|