|
@@ -1,5 +1,5 @@
|
1
|
1
|
<template>
|
2
|
|
- <div class="main-contain">
|
|
2
|
+ <div class="main-contain" v-loading="sending">
|
3
|
3
|
<div class="position">
|
4
|
4
|
<bread-crumb :crumbs="crumbs"></bread-crumb>
|
5
|
5
|
</div>
|
|
@@ -30,7 +30,7 @@
|
30
|
30
|
</div>
|
31
|
31
|
<div class="form-content">
|
32
|
32
|
<div class="input-panel">
|
33
|
|
- <el-input v-model="sms_content" type="textarea" :rows="4" resize="none"></el-input>
|
|
33
|
+ <el-input v-model="sms_content" type="textarea" :rows="4" resize="none" maxlength="500"></el-input>
|
34
|
34
|
<div class="hint-text">已输入{{ total_content_length }}字(含签名和尾缀)按{{ sms_charge_count }}条短信计费</div>
|
35
|
35
|
</div>
|
36
|
36
|
<div v-if="designated_targets.length == 0" class="filters-panel">
|
|
@@ -40,7 +40,7 @@
|
40
|
40
|
<p class="desc">将该短信推送给系统里的所有客户</p>
|
41
|
41
|
</div>
|
42
|
42
|
<div class="btn">
|
43
|
|
- <el-button type="primary">发送</el-button>
|
|
43
|
+ <el-button type="primary" @click="sendToAllCustomersAction">发送</el-button>
|
44
|
44
|
</div>
|
45
|
45
|
</div>
|
46
|
46
|
<div class="tag-filter-panel">
|
|
@@ -48,14 +48,14 @@
|
48
|
48
|
<p class="desc">将该短信推送给相应标签客户</p>
|
49
|
49
|
<div class="tag-panel">
|
50
|
50
|
<div v-for="(tag, index) in tags" class="item-panel" :key="index">
|
51
|
|
- <el-tag effect="plain">{{ tag.name }}</el-tag>
|
|
51
|
+ <el-tag :effect="tagEffect(tag)" @click="selectTagAction(tag)" @close="cancelSelectTagAction(tag)" :closable="isTagSelected(tag)">{{ tag.tag_name }}</el-tag>
|
52
|
52
|
</div>
|
53
|
53
|
</div>
|
54
|
54
|
<p class="hint-text">*选择标签发送可以帮助您精准营销</p>
|
55
|
55
|
<div class="send">
|
56
|
56
|
<p class="text">已为您筛选 {{ tag_filtered_count }} 位客户</p>
|
57
|
57
|
<div class="btn">
|
58
|
|
- <el-button type="primary">发送</el-button>
|
|
58
|
+ <el-button type="primary" @click="sendToTagCustomersAction">发送</el-button>
|
59
|
59
|
</div>
|
60
|
60
|
</div>
|
61
|
61
|
</div>
|
|
@@ -66,7 +66,7 @@
|
66
|
66
|
推送指定客户
|
67
|
67
|
</div>
|
68
|
68
|
<div class="btn">
|
69
|
|
- <el-button type="primary">发送</el-button>
|
|
69
|
+ <el-button type="primary" @click="sendToDesignatedCustomersAction">发送</el-button>
|
70
|
70
|
</div>
|
71
|
71
|
</div>
|
72
|
72
|
<el-table :data="designated_targets" border max-height="500px">
|
|
@@ -83,6 +83,7 @@
|
83
|
83
|
|
84
|
84
|
<script>
|
85
|
85
|
import BreadCrumb from "@/scrm_pages/components/bread-crumb"
|
|
86
|
+import { sendsInitData, tagFilterCustomerCount, send2AllCustomers, send2TagCustomers, send2SpecificCustomers } from "@/api/sms"
|
86
|
87
|
|
87
|
88
|
export default {
|
88
|
89
|
name: "SMSSend",
|
|
@@ -96,9 +97,14 @@ export default {
|
96
|
97
|
{ path: false, name: "群发短信" },
|
97
|
98
|
],
|
98
|
99
|
|
|
100
|
+ sending: false,
|
99
|
101
|
sms_content: "",
|
100
|
102
|
tags: [],
|
|
103
|
+ selecting_tags: [],
|
|
104
|
+ tag_filtered_count: 0,
|
101
|
105
|
|
|
106
|
+ action: 0,
|
|
107
|
+ id: 0,
|
102
|
108
|
designated_targets: [],
|
103
|
109
|
}
|
104
|
110
|
},
|
|
@@ -112,13 +118,173 @@ export default {
|
112
|
118
|
sms_charge_count: function() {
|
113
|
119
|
return parseInt(Math.ceil(this.total_content_length / 67.0))
|
114
|
120
|
},
|
115
|
|
- tag_filtered_count: function() {
|
116
|
|
- return 0
|
117
|
|
- },
|
118
|
121
|
},
|
119
|
122
|
mounted() {
|
120
|
123
|
this.designated_targets = this.$store.getters.sms_designated_targets.targets
|
121
|
|
- this.$store.dispatch("SMSClearTargets")
|
|
124
|
+ if (this.designated_targets.length > 0) {
|
|
125
|
+ this.$store.dispatch("SMSClearTargets")
|
|
126
|
+ } else {
|
|
127
|
+ var action = this.$route.query.action
|
|
128
|
+ var id = this.$route.query.id
|
|
129
|
+ if (action != undefined && id != undefined) {
|
|
130
|
+ this.action = action
|
|
131
|
+ this.id = id
|
|
132
|
+ }
|
|
133
|
+
|
|
134
|
+ this.getInitData()
|
|
135
|
+ }
|
|
136
|
+ },
|
|
137
|
+ methods: {
|
|
138
|
+ getInitData: function() {
|
|
139
|
+ sendsInitData(this.action, this.id).then(rs => {
|
|
140
|
+ var resp = rs.data
|
|
141
|
+ if (resp.state == 1) {
|
|
142
|
+ this.tags = resp.data.tags
|
|
143
|
+ this.sms_content = resp.data.default_content
|
|
144
|
+
|
|
145
|
+ } else {
|
|
146
|
+ this.$message.error(resp.msg)
|
|
147
|
+ }
|
|
148
|
+
|
|
149
|
+ }).catch(err => {
|
|
150
|
+ this.$message.error(err)
|
|
151
|
+ })
|
|
152
|
+ },
|
|
153
|
+ getTagCustomerCount: function() {
|
|
154
|
+ var tag_ids = []
|
|
155
|
+ for (let index = 0; index < this.selecting_tags.length; index++) {
|
|
156
|
+ tag_ids.push(this.selecting_tags[index].id)
|
|
157
|
+ }
|
|
158
|
+ if (tag_ids.length == 0) {
|
|
159
|
+ this.tag_filtered_count = 0
|
|
160
|
+ return
|
|
161
|
+ }
|
|
162
|
+ tagFilterCustomerCount(tag_ids.join(",")).then(rs => {
|
|
163
|
+ var resp = rs.data
|
|
164
|
+ if (resp.state == 1) {
|
|
165
|
+ this.tag_filtered_count = resp.data.count
|
|
166
|
+ } else {
|
|
167
|
+ console.log(resp.msg)
|
|
168
|
+ }
|
|
169
|
+ }).catch(err => {
|
|
170
|
+ console.log(err)
|
|
171
|
+ })
|
|
172
|
+ },
|
|
173
|
+
|
|
174
|
+ tagEffect: function(tag) {
|
|
175
|
+ if (this.isTagSelected(tag)) {
|
|
176
|
+ return "dark"
|
|
177
|
+ } else {
|
|
178
|
+ return "plain"
|
|
179
|
+ }
|
|
180
|
+ },
|
|
181
|
+ isTagSelected: function(tag) {
|
|
182
|
+ for (let index = 0; index < this.selecting_tags.length; index++) {
|
|
183
|
+ if (this.selecting_tags[index].id == tag.id) {
|
|
184
|
+ return true
|
|
185
|
+ }
|
|
186
|
+ }
|
|
187
|
+ return false
|
|
188
|
+ },
|
|
189
|
+ selectTagAction: function(tag) {
|
|
190
|
+ if (!this.isTagSelected(tag)) {
|
|
191
|
+ this.selecting_tags.push(tag)
|
|
192
|
+ this.getTagCustomerCount()
|
|
193
|
+ }
|
|
194
|
+ },
|
|
195
|
+ cancelSelectTagAction: function(tag) {
|
|
196
|
+ for (let index = 0; index < this.selecting_tags.length; index++) {
|
|
197
|
+ if (this.selecting_tags[index].id == tag.id) {
|
|
198
|
+ this.selecting_tags.splice(index, 1)
|
|
199
|
+ this.getTagCustomerCount()
|
|
200
|
+ break
|
|
201
|
+ }
|
|
202
|
+ }
|
|
203
|
+ },
|
|
204
|
+
|
|
205
|
+ isSMSContentValid: function() {
|
|
206
|
+ if (this.sms_content.length == 0) {
|
|
207
|
+ this.$message.error("请编辑短信内容")
|
|
208
|
+ return false
|
|
209
|
+ }
|
|
210
|
+ if (this.sms_content.indexOf("【") >= 0 || this.sms_content.indexOf("】") >= 0) {
|
|
211
|
+ this.$message.error("短信内容不得包含【】")
|
|
212
|
+ return false
|
|
213
|
+ }
|
|
214
|
+ return true
|
|
215
|
+ },
|
|
216
|
+ sendToAllCustomersAction: function() {
|
|
217
|
+ if (!this.isSMSContentValid()) {
|
|
218
|
+ return
|
|
219
|
+ }
|
|
220
|
+ this.sending = true
|
|
221
|
+ send2AllCustomers(this.sms_content).then(rs => {
|
|
222
|
+ this.sending = false
|
|
223
|
+ var resp = rs.data
|
|
224
|
+ if (resp.state == 1) {
|
|
225
|
+ this.$message.success("发送成功")
|
|
226
|
+ } else {
|
|
227
|
+ this.$message.error(resp.msg)
|
|
228
|
+ }
|
|
229
|
+
|
|
230
|
+ }).catch(err => {
|
|
231
|
+ this.sending = false
|
|
232
|
+ this.$message.error(err)
|
|
233
|
+ })
|
|
234
|
+ },
|
|
235
|
+ sendToTagCustomersAction: function() {
|
|
236
|
+ if (!this.isSMSContentValid()) {
|
|
237
|
+ return
|
|
238
|
+ }
|
|
239
|
+ if (this.selecting_tags.length == 0) {
|
|
240
|
+ this.$message.error("请选择标签")
|
|
241
|
+ return
|
|
242
|
+ }
|
|
243
|
+
|
|
244
|
+ var tag_ids = []
|
|
245
|
+ for (let index = 0; index < this.selecting_tags.length; index++) {
|
|
246
|
+ tag_ids.push(this.selecting_tags[index].id)
|
|
247
|
+ }
|
|
248
|
+
|
|
249
|
+ this.sending = true
|
|
250
|
+ send2TagCustomers(this.sms_content, tag_ids.join(",")).then(rs => {
|
|
251
|
+ this.sending = false
|
|
252
|
+ var resp = rs.data
|
|
253
|
+ if (resp.state == 1) {
|
|
254
|
+ this.$message.success("发送成功")
|
|
255
|
+ } else {
|
|
256
|
+ this.$message.error(resp.msg)
|
|
257
|
+ }
|
|
258
|
+
|
|
259
|
+ }).catch(err => {
|
|
260
|
+ this.sending = false
|
|
261
|
+ this.$message.error(err)
|
|
262
|
+ })
|
|
263
|
+ },
|
|
264
|
+ sendToDesignatedCustomersAction: function() {
|
|
265
|
+ if (!this.isSMSContentValid()) {
|
|
266
|
+ return
|
|
267
|
+ }
|
|
268
|
+ var customer_ids = []
|
|
269
|
+ for (let index = 0; index < this.designated_targets.length; index++) {
|
|
270
|
+ customer_ids.push(this.designated_targets[index].id)
|
|
271
|
+ }
|
|
272
|
+
|
|
273
|
+ this.sending = true
|
|
274
|
+ send2SpecificCustomers(this.sms_content, customer_ids.join(",")).then(rs => {
|
|
275
|
+ this.sending = false
|
|
276
|
+ var resp = rs.data
|
|
277
|
+ if (resp.state == 1) {
|
|
278
|
+ this.$message.success("发送成功")
|
|
279
|
+ } else {
|
|
280
|
+ this.$message.error(resp.msg)
|
|
281
|
+ }
|
|
282
|
+
|
|
283
|
+ }).catch(err => {
|
|
284
|
+ this.sending = false
|
|
285
|
+ this.$message.error(err)
|
|
286
|
+ })
|
|
287
|
+ },
|
122
|
288
|
},
|
123
|
289
|
}
|
124
|
290
|
</script>
|
|
@@ -302,6 +468,7 @@ export default {
|
302
|
468
|
.item-panel {
|
303
|
469
|
display: inline-block;
|
304
|
470
|
margin-bottom: 5px;
|
|
471
|
+ margin-right: 5px;
|
305
|
472
|
}
|
306
|
473
|
}
|
307
|
474
|
.hint-text {
|