add.vue
13.1 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
<script>
import { add } from '@/api/groupMessage'
import { getMaterialMediaId } from '@/api/material'
import PhoneDialog from '@/components/PhoneDialog'
import SelectUser from '@/components/SelectUser'
import SelectTag from '@/components/SelectTag'
import SelectMaterial from '@/components/SelectMaterial/index'
export default {
components: { PhoneDialog, SelectTag, SelectUser, SelectMaterial },
props: {},
data() {
return {
loading: false,
// 表单参数
form: {
pushType: '0',
pushRange: '0',
tag: [],
department: [],
staffId: [],
settingTime: '',
messageType: '0',
imageMessage: {
media_id: '', // '图片的media_id',
pic_url: '', // '图片的链接',
},
linkMessage: {
title: '', // '图文消息标题',
picurl: '', // '图文消息封面的url',
desc: '', // '图文消息的描述,最多512个字节',
url: '', // '图文消息的链接',
},
textMessage: {
content: '', //'消息文本内容,最多4000个字节',
},
miniprogramMessage: {
title: '', // '小程序消息标题,最多64个字节',
pic_media_id: '', // '小程序消息封面的mediaid,封面图建议尺寸为520*416',
appid: '', // '小程序appid,必须是关联到企业的小程序应用',
page: '', // '小程序page路径',
},
},
userParty: [],
rules: {},
statusOptions: Object.freeze([
{ label: '发送给客户', value: '0' },
{ label: '发送给客户群', value: '1' },
]),
activeName: '0',
dialogVisibleSelectCustomer: false,
dialogVisibleSelectUser: false,
dialogVisibleSelectTag: false,
dialogVisibleSelectMaterial: false,
}
},
watch: {},
computed: {
// 是否显示选择的客户标签
isOnlyTag() {
return this.form.tag[0] && this.form.pushType == 0
},
// 是否显示选择范围后的文字说明
isSelectedText() {
return this.userParty[0] || this.isOnlyTag
},
// 选择范围后的文字说明
selectedText() {
return `将发送消息给${
this.userParty[0] ? this.userParty[0].name + '等部门或成员的' : ''
}${this.userParty[0] && this.isOnlyTag ? ',且' : ''}${
this.isOnlyTag ? '满足' + this.form.tag[0].name + '等标签的' : ''
}${this.form.pushType == 0 ? '客户' : '客户群'}`
},
},
created() {},
mounted() {},
methods: {
// 显示选择客户范围弹窗
showRangeDialog() {
this[
this.form.pushType == 0
? 'dialogVisibleSelectCustomer'
: 'dialogVisibleSelectUser'
] = true
},
// 选择添加人确认按钮
selectedUser(users) {
users.map((d) => {
d.userId && this.form.staffId.push(d.userId)
d.id && this.form.department.push(d.id)
})
this.userParty = users
},
// 选择标签确认按钮
submitSelectTag(data) {
this.form.tag = data
},
// 新建素材按钮
goRoute() {
let contentType = ['text', 'image', 'file']
window.open('#/material/' + contentType[this.activeName])
},
// 选择素材确认按钮
submitSelectMaterial(text, image, file) {
this.form.textMessage.content = text.content
// this.form.imageMessage.media_id = image.id
this.form.imageMessage.pic_url = image.materialUrl
this.form.imageMessage._materialName = image.materialName
},
submit() {
this.loading = true
let form = JSON.parse(JSON.stringify(this.form))
form.messageType = this.activeName
Promise.resolve()
.then(() => {
if (form.messageType == 1) {
// debugger
let dataMediaId = {
url: form.imageMessage.pic_url,
type: '0',
name: form.imageMessage._materialName,
}
return getMaterialMediaId(dataMediaId).then((res) => {
// debugger
form.imageMessage.media_id = res.data
})
}
})
.then(() => {
// debugger
form.tag = form.tag.map((d) => d.tagId) + ''
form.department += ''
form.staffId += ''
return add(form)
})
.then(({ data }) => {
this.msgSuccess('操作成功')
this.loading = false
this.$router.push('/groupMessage/record')
})
.catch(() => {
this.loading = false
})
},
},
}
</script>
<template>
<div v-loading="loading">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="群发类型" prop="pushType">
<el-radio-group v-model="form.pushType">
<el-radio
v-for="dict in statusOptions"
:key="dict.value"
:label="dict.value"
>{{ dict.label }}</el-radio
>
</el-radio-group>
</el-form-item>
<el-form-item label="发送范围" prop="pushRange">
<span v-show="isSelectedText">{{ selectedText }}</span>
<el-button type="text" size="medium" @click="showRangeDialog()">{{
isSelectedText
? '修改'
: form.pushType == 0
? '选择发送客户'
: '按群主选择客户群'
}}</el-button>
</el-form-item>
<el-form-item label="发送时间" prop="settingTime">
<el-date-picker
v-model="form.settingTime"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="datetime"
placeholder="选择日期时间"
></el-date-picker>
<span class="small-tip">设置时间定时发送,不设置立即发送</span>
</el-form-item>
<el-form-item label=" ">
<div class="flex content-wrap">
<div class="content-left">
<el-button class="create" @click="goRoute">新建素材</el-button>
<el-tabs v-model="activeName">
<el-tab-pane name="0">
<span slot="label"> <i class="el-icon-date"></i> 文本 </span>
<el-input
v-model="form.textMessage.content"
type="textarea"
maxlength="220"
show-word-limit
:autosize="{ minRows: 10, maxRows: 50 }"
placeholder="请输入"
></el-input>
</el-tab-pane>
<el-tab-pane name="1">
<span slot="label"> <i class="el-icon-date"></i> 图片 </span>
<el-image
v-if="form.imageMessage.pic_url"
style="width: 200px;"
:src="form.imageMessage.pic_url"
fit="fit"
></el-image>
</el-tab-pane>
<!-- <el-tab-pane name="2">
<span slot="label"> <i class="el-icon-date"></i> 文件 </span>
</el-tab-pane> -->
<el-button
type="primary"
class="mt20"
@click="dialogVisibleSelectMaterial = true"
>从素材库选择</el-button
>
<!-- <el-tab-pane label="配置管理" name="second">
<span slot="label"> <i class="el-icon-date"></i> 网页 </span>
配置管理
</el-tab-pane> -->
<!-- <el-tab-pane label="定时任务补偿" name="fourth">
<span slot="label"> <i class="el-icon-date"></i> 海报 </span>
定时任务补偿
</el-tab-pane> -->
</el-tabs>
<div class="mt15">
<el-button type="primary" @click="submit">通知成员发送</el-button>
<span class="small-tip"
>通知成员,向选中的客户发送以上企业消息</span
>
<el-popover
placement="top-start"
title="群发助手介绍"
width="500"
trigger="hover"
>
<div>
<h5>一、什么是群发助手?</h5>
<p>
成员可把通知、祝福、活动等消息批量发送给不同的客户,并进行后续的服务;管理员或负责人也可创建企业服务消息,由成员发送并进行后续的服务。
</p>
<h5>二、谁可以使用群发助手?</h5>
<p>
具有客户联系使用权限的成员,都可以使用群发助手给自己的客户发送消息;超级管理员和业务负责人还可向管理范围内成员的客户创建企业服务消息。
</p>
<h5>三、群发是否有频率限制?</h5>
<p>
每个自然月最多接收来自同一企业的管理员或业务负责人的4条群发消息。
</p>
<h5>四、群发助手其他注意事项</h5>
<p>
1、群发消息不得出现违反法律法规或侵犯他人合法权益的内容,企业应对其制作、发送和传播的群发消息内容承担全部法律责任。
</p>
<p>
2、不得以任何方式滥用群发助手实施恶意骚扰用户、开展过度营销等行为。
</p>
<p>
3、如企业微信帐号存在异常,则可能导致群发消息发送失败或异常等情况。
</p>
</div>
<i slot="reference" class="el-icon-warning-outline"></i>
</el-popover>
</div>
</div>
<!-- 预览 -->
<PhoneDialog
:message="form.textMessage.content || '请输入欢迎语'"
:isOther="!!form.imageMessage.pic_url"
>
<el-image
style="border-radius: 6px;"
:src="form.imageMessage.pic_url"
fit="fit"
>
</el-image
></PhoneDialog>
</div>
</el-form-item>
</el-form>
<!-- 选择发送客户弹窗 -->
<el-dialog title="选择发送客户" :visible.sync="dialogVisibleSelectCustomer">
<el-form :model="form" label-width="80px">
<el-form-item label="发送消息">
<el-radio-group v-model="form.pushRange">
<el-radio label="0">全部客户</el-radio>
<el-radio label="1">按条件筛选客户</el-radio>
</el-radio-group>
</el-form-item>
<div v-show="form.pushRange == 1">
<el-form-item label="添加人">
<div class="input-wrap" @click="dialogVisibleSelectUser = true">
<span class="placeholder" v-if="!userParty.length">请选择</span>
<template v-else>
<el-tag
type="info"
v-for="(unit, unique) in userParty"
:key="unique"
>{{ unit.name }}</el-tag
>
</template>
</div>
</el-form-item>
<el-form-item label="标签">
<div class="input-wrap" @click="dialogVisibleSelectTag = true">
<span class="placeholder" v-if="!form.tag.length">请选择</span>
<template v-else>
<el-tag
type="info"
v-for="(unit, unique) in form.tag"
:key="unique"
>{{ unit.name }}</el-tag
>
</template>
</div>
</el-form-item>
</div>
</el-form>
<div slot="footer">
<el-button @click="dialogVisibleSelectCustomer = false"
>取 消</el-button
>
<el-button type="primary" @click="dialogVisibleSelectCustomer = false"
>确 定</el-button
>
</div>
</el-dialog>
<!-- 选择添加人弹窗 -->
<SelectUser
:visible.sync="dialogVisibleSelectUser"
title="选择添加人"
:isOnlyLeaf="false"
@success="selectedUser"
></SelectUser>
<!-- 选择标签弹窗 -->
<SelectTag
:visible.sync="dialogVisibleSelectTag"
title="选择标签"
:selected="form.tag"
@success="submitSelectTag"
>
</SelectTag>
<SelectMaterial
:visible.sync="dialogVisibleSelectMaterial"
:type.sync="activeName"
@success="submitSelectMaterial"
></SelectMaterial>
</div>
</template>
<style lang="scss" scoped>
.small-tip {
font-size: 12px;
color: #999;
margin-left: 12px;
}
.content-wrap {
height: 500px;
align-items: stretch;
justify-content: space-between;
padding-right: 6%;
.content-left {
position: relative;
width: 60%;
.create {
position: absolute;
right: 10px;
top: 14px;
z-index: 1;
}
}
.el-tabs {
height: 90%;
background: #eee;
border-radius: 8px;
padding: 10px;
}
}
.input-wrap {
width: 240px;
display: inline-flex;
border-radius: 4px;
border: 1px solid #dcdfe6;
align-items: center;
padding: 0 15px;
overflow: hidden;
height: 32px;
.placeholder {
color: #bbb;
font-size: 14px;
}
}
</style>