|
@@ -152,6 +152,8 @@ export default {
|
152
|
152
|
name: '', // 标题
|
153
|
153
|
content: '', // 内容
|
154
|
154
|
attachments: [], // 内容附件
|
|
155
|
+
|
|
156
|
+ oldParams: {}, // 复制对象的参数 => 用于新旧参数比较 判断用户是否做出修改
|
155
|
157
|
}
|
156
|
158
|
},
|
157
|
159
|
created () {
|
|
@@ -213,6 +215,10 @@ export default {
|
213
|
215
|
this.name = res.rst.name;
|
214
|
216
|
this.content = res.rst.content;
|
215
|
217
|
this.attachments = res.rst.attachments && res.rst.attachments != '' && res.rst.attachments != 'null' ? JSON.parse(res.rst.attachments) : [];
|
|
218
|
+
|
|
219
|
+ if (this.isCopy) { // 复制操作 => 获取当前规则未修改时的参数
|
|
220
|
+ this.handleGetOldParams()
|
|
221
|
+ }
|
216
|
222
|
} else if (res.errno != 4002) {
|
217
|
223
|
this.$message({
|
218
|
224
|
message: res.err,
|
|
@@ -264,9 +270,8 @@ export default {
|
264
|
270
|
this.$message.error('请检查消息文本内容,最多4000个字节,已超出!')
|
265
|
271
|
return
|
266
|
272
|
}
|
267
|
|
- this.$loading(this.$loadingConfig)
|
|
273
|
+
|
268
|
274
|
let params = {
|
269
|
|
- rule_id: this.rule_id ? this.rule_id : '',
|
270
|
275
|
name: this.name,
|
271
|
276
|
is_all: this.is_all,
|
272
|
277
|
senders: this.is_all == 0 ? this.user_id_list.join(',') : '',
|
|
@@ -275,16 +280,28 @@ export default {
|
275
|
280
|
gender: this.gender && this.gender.join(','),
|
276
|
281
|
interval_type: this.addCustomerTime.type,
|
277
|
282
|
interval_time: interval_time,
|
278
|
|
- interval: this.addCustomerTime.type == 2 ? this.addCustomerTime.type2_hour : '',
|
|
283
|
+ interval: this.addCustomerTime.type == 2 ? Number(this.addCustomerTime.type2_hour) : '',
|
279
|
284
|
time_points: this.addCustomerTime.type == 1 ? JSON.stringify(this.addCustomerTime.type1_timeNums) : '',
|
280
|
285
|
tag_screen_type: this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0,
|
281
|
286
|
tag_list: this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : '',
|
282
|
287
|
exclude_tag_list: this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : '',
|
283
|
288
|
pay_status: this.payInfo.pay_status || this.payInfo.pay_status == 0 ? this.payInfo.pay_status : '',
|
284
|
|
- pay_num_min: this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? this.payInfo.pay_num_min : '',
|
285
|
|
- pay_num_max: this.payInfo.pay_num_max || this.payInfo.pay_num_max == 0 ? this.payInfo.pay_num_max : '',
|
|
289
|
+ pay_num_min: this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? Number(this.payInfo.pay_num_min) : '',
|
|
290
|
+ pay_num_max: this.payInfo.pay_num_max || this.payInfo.pay_num_max == 0 ? Number(this.payInfo.pay_num_max) : '',
|
|
291
|
+ }
|
|
292
|
+
|
|
293
|
+ if (this.isCopy) {
|
|
294
|
+ const isSameParams = this.handleGetIsSameParams(params)
|
|
295
|
+ console.log('isSameParams => ', isSameParams)
|
|
296
|
+ if (isSameParams) {
|
|
297
|
+ this.$message.warning('推送规则及内容重复!')
|
|
298
|
+ return
|
|
299
|
+ }
|
286
|
300
|
}
|
|
301
|
+ params.rule_id = this.isCopy ? '' : (this.rule_id ? this.rule_id : ''),
|
287
|
302
|
console.log('params => ', JSON.parse(JSON.stringify(params)))
|
|
303
|
+
|
|
304
|
+ this.$loading(this.$loadingConfig)
|
288
|
305
|
this.$axios.post(this.URL.BASEURL + this.URL.smartPush_set, params).then((res) => {
|
289
|
306
|
var res = res.data
|
290
|
307
|
this.$loading(this.$loadingConfig).close()
|
|
@@ -305,6 +322,94 @@ export default {
|
305
|
322
|
});
|
306
|
323
|
},
|
307
|
324
|
|
|
325
|
+ // 复制操作 => 获取当前规则未修改时的参数
|
|
326
|
+ handleGetOldParams() {
|
|
327
|
+ const interval_time = this.handleGetIntervalTime()
|
|
328
|
+ let oldParams = {
|
|
329
|
+ name: this.name,
|
|
330
|
+ is_all: this.is_all,
|
|
331
|
+ senders: this.is_all == 0 ? this.user_id_list.join(',') : '',
|
|
332
|
+ content: this.content,
|
|
333
|
+ attachments: this.attachments == '' || this.attachments.length == 0 ? '' : JSON.stringify(this.attachments),
|
|
334
|
+ gender: this.gender && this.gender.join(','),
|
|
335
|
+ interval_type: this.addCustomerTime.type,
|
|
336
|
+ interval_time: interval_time,
|
|
337
|
+ interval: this.addCustomerTime.type == 2 ? this.addCustomerTime.type2_hour : '',
|
|
338
|
+ time_points: this.addCustomerTime.type == 1 ? JSON.stringify(this.addCustomerTime.type1_timeNums) : '',
|
|
339
|
+ tag_screen_type: this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0,
|
|
340
|
+ tag_list: this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : '',
|
|
341
|
+ exclude_tag_list: this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : '',
|
|
342
|
+ pay_status: this.payInfo.pay_status || this.payInfo.pay_status == 0 ? this.payInfo.pay_status : '',
|
|
343
|
+ pay_num_min: this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? this.payInfo.pay_num_min : '',
|
|
344
|
+ pay_num_max: this.payInfo.pay_num_max || this.payInfo.pay_num_max == 0 ? this.payInfo.pay_num_max : '',
|
|
345
|
+ }
|
|
346
|
+ this.oldParams = JSON.parse(JSON.stringify(oldParams))
|
|
347
|
+ console.log('oldParams => ', this.oldParams)
|
|
348
|
+ },
|
|
349
|
+ handleGetIsSameParams(newParams) {
|
|
350
|
+ let isSameParams = true
|
|
351
|
+ // 先比较“非多选”的属性
|
|
352
|
+ const _newParams = JSON.parse(JSON.stringify(newParams))
|
|
353
|
+ delete _newParams.senders
|
|
354
|
+ delete _newParams.gender
|
|
355
|
+ delete _newParams.tag_list
|
|
356
|
+ delete _newParams.exclude_tag_list
|
|
357
|
+
|
|
358
|
+ const _oldParams = JSON.parse(JSON.stringify(this.oldParams))
|
|
359
|
+ delete _oldParams.senders
|
|
360
|
+ delete _oldParams.gender
|
|
361
|
+ delete _oldParams.tag_list
|
|
362
|
+ delete _oldParams.exclude_tag_list
|
|
363
|
+
|
|
364
|
+ const isEqual = _lodash.isEqual(_newParams, _oldParams)
|
|
365
|
+ if (!isEqual) { // “非多选”的属性不相同 => 直接返回结果
|
|
366
|
+ isSameParams = false
|
|
367
|
+ } else { // “非多选”的属性相同 => 比较"多选项"属性
|
|
368
|
+ const { senders, gender, tag_list, exclude_tag_list } = newParams
|
|
369
|
+ // 使用员工
|
|
370
|
+ if (senders.length !== this.oldParams.senders.length) {
|
|
371
|
+ isSameParams = false
|
|
372
|
+ } else {
|
|
373
|
+ const isNotSameS = senders.split(',').some(item => !this.oldParams.senders.includes(item))
|
|
374
|
+ if (isNotSameS) {
|
|
375
|
+ isSameParams = false
|
|
376
|
+ }
|
|
377
|
+ }
|
|
378
|
+
|
|
379
|
+ // 规则配置 => 性别
|
|
380
|
+ if (gender.length !== this.oldParams.gender.length) {
|
|
381
|
+ isSameParams = false
|
|
382
|
+ } else {
|
|
383
|
+ const isNotSameG = gender.split(',').some(item => !this.oldParams.gender.includes(item))
|
|
384
|
+ if (isNotSameG) {
|
|
385
|
+ isSameParams = false
|
|
386
|
+ }
|
|
387
|
+ }
|
|
388
|
+
|
|
389
|
+ // 规则配置 => 标签
|
|
390
|
+ if (tag_list.length !== this.oldParams.tag_list.length) {
|
|
391
|
+ isSameParams = false
|
|
392
|
+ } else {
|
|
393
|
+ const isNotSameTG = tag_list.split(',').some(item => !this.oldParams.tag_list.includes(item))
|
|
394
|
+ if (isNotSameTG) {
|
|
395
|
+ isSameParams = false
|
|
396
|
+ }
|
|
397
|
+ }
|
|
398
|
+
|
|
399
|
+ // 规则配置 => 排除客户
|
|
400
|
+ if (exclude_tag_list.length !== this.oldParams.exclude_tag_list.length) {
|
|
401
|
+ isSameParams = false
|
|
402
|
+ } else {
|
|
403
|
+ const isNotSameETL = exclude_tag_list.split(',').some(item => !this.oldParams.exclude_tag_list.includes(item))
|
|
404
|
+ if (isNotSameETL) {
|
|
405
|
+ isSameParams = false
|
|
406
|
+ }
|
|
407
|
+ }
|
|
408
|
+ }
|
|
409
|
+
|
|
410
|
+ return isSameParams
|
|
411
|
+ },
|
|
412
|
+
|
308
|
413
|
tagDefine (data) {//标签选择回调
|
309
|
414
|
if (data.tag == 1 || data.tag == 2) {
|
310
|
415
|
if (data.tag_id_list && data.tag_id_list.length != 0) {
|