Browse Source

feat: 企微助手 - 智能推送 - 新建&接口联调

zhengxy 2 years ago
parent
commit
91ab0a0caf

+ 2 - 0
project/src/assets/config/interface_api.js

@@ -307,6 +307,8 @@ var api = {
307 307
   sop_setRule: "/api/userSop/setRule", // 企微助手 - SOP设置 - 保存sop规则
308 308
   sop_ruleDetail: "/api/userSop/ruleDetail", // 企微助手 - SOP设置 - sop规则详情
309 309
 
310
+  smartPush_set: "/api/CircleMassMsg/set", // 企微助手 - 智能推送 - 新建/编辑规则
311
+
310 312
 };
311 313
 
312 314
 export { api };

+ 41 - 31
project/src/components/smartPush/createMassMsg.vue

@@ -14,10 +14,10 @@
14 14
         <label><em>*</em>使用员工:</label>
15 15
         <div>
16 16
           <div style="display:flex">
17
-            <el-radio v-model="is_for_all" :label="1">全部员工</el-radio>
18
-            <el-radio v-model="is_for_all" :label="0">部分员工</el-radio>
17
+            <el-radio v-model="is_all" :label="1">全部员工</el-radio>
18
+            <el-radio v-model="is_all" :label="0">部分员工</el-radio>
19 19
           </div>
20
-          <self-customerservice v-if="is_for_all == 0" title='' width="300px" :afferent_users='user_id_list' @customerDefine="(val) => { user_id_list = val; }" />
20
+          <self-customerservice v-if="is_all == 0" title='' width="300px" :afferent_users='user_id_list' @customerDefine="(val) => { user_id_list = val; }" />
21 21
         </div>
22 22
       </div>
23 23
       <div class="regulations">
@@ -127,7 +127,7 @@ export default {
127 127
       resetFlag: false,
128 128
       processFlag: false,
129 129
 
130
-      is_for_all: 1, // 使用员工:1全部员工 0部分员工
130
+      is_all: 1, // 使用员工:1全部员工 0部分员工
131 131
       user_id_list: [], // 员工列表
132 132
       gender: [], // 规则配置 - 性别
133 133
       payInfo: {}, // 规则配置 - 付费情况
@@ -182,7 +182,7 @@ export default {
182 182
 
183 183
           this.user_id_list = res.rst.senders ? res.rst.senders.split(',') : [];
184 184
           if (res.rst.senders && res.rst.senders.length > 0) {//有值代表部分员工
185
-            this.is_for_all = 0
185
+            this.is_all = 0
186 186
           }
187 187
           this.gender = res.rst.gender ? res.rst.gender.split(',') : [];
188 188
           this.afferent_tag_obj = {
@@ -221,57 +221,67 @@ export default {
221 221
     getAttachment (val) {
222 222
       this.attachments = val
223 223
     },
224
-    massMsg_set () {//提交 通知成员发送
225
-      if (this.is_for_all == 0 && (!this.user_id_list || this.user_id_list.length == 0)) {
226
-        this.$message({
227
-          message: '请选择使用员工!',
228
-          type: "warning"
229
-        })
224
+
225
+    // 获取用户添加间隔时间(单位:分钟)
226
+    handleGetIntervalTime() {
227
+      const { days, hour, minute } = this.addCustomerTime
228
+      return (Number(days) * 24 * 60) + (Number(hour) * 60) + Number(minute)
229
+    },
230
+    //提交
231
+    massMsg_set () {
232
+      if (this.is_all == 0 && (!this.user_id_list || this.user_id_list.length == 0)) {
233
+        this.$message.warning('请选择使用员工!')
234
+        return
235
+      }
236
+
237
+      const interval_time =  this.handleGetIntervalTime()
238
+      if (!interval_time) {
239
+        this.$message.warning('请输入"添加客服时间"')
240
+        return
241
+      }
242
+
243
+      const { type, type1_timeNums, type2_hour } = this.addCustomerTime
244
+      const isHasNull = type1_timeNums.some(t => !t)
245
+      if ((type == 1 && isHasNull) || (type == 2 && !type2_hour)) {
246
+        this.$message.warning('请完善"添加客服时间"')
230 247
         return
231 248
       }
249
+
232 250
       if (this.name == '') {
233
-        this.$message({
234
-          message: '请输入群发标题!',
235
-          type: "warning"
236
-        })
251
+        this.$message.warning('请输入标题!')
237 252
         return
238 253
       }
239 254
 
240 255
       if (this.content == '' && (!this.attachments || this.attachments == '' || this.attachments.length == 0)) {
241
-        this.$message({
242
-          message: '请输入群发内容!',
243
-          type: "warning"
244
-        })
256
+        this.$message.warning('请输入内容!')
245 257
         return
246 258
       }
247 259
       if (this.content != '' && this.$getStrBytes(this.content) > 4000) {
248
-        this.$message({
249
-          message: '请检查消息文本内容,最多4000个字节,已超出!',
250
-          type: "error"
251
-        })
260
+        this.$message.error('请检查消息文本内容,最多4000个字节,已超出!')
252 261
         return
253 262
       }
254 263
       this.$loading(this.$loadingConfig)
255 264
       let params = {
256 265
         rule_id: this.rule_id ? this.rule_id : '',
257 266
         name: this.name,
258
-        chat_type: 1,//群发任务的类型,1:single,表示发送给客户 2:group表示发送给客户群.默认为1
267
+        is_all: this.is_all,
268
+        senders: this.is_all == 0 ? this.user_id_list.join(',') : '',
269
+        content: this.content,
270
+        attachments: this.attachments == '' || this.attachments.length == 0 ? '' : JSON.stringify(this.attachments),
259 271
         gender: this.gender && this.gender.join(','),
272
+        interval_type: this.addCustomerTime.type,
273
+        interval_time: interval_time,
274
+        interval: this.addCustomerTime.type == 2 ? this.addCustomerTime.type2_hour : '',
275
+        time_points: this.addCustomerTime.type == 1 ? JSON.stringify(this.addCustomerTime.type1_timeNums) : '',
260 276
         tag_screen_type: this.tag_info && this.tag_info.tag_type ? this.tag_info.tag_type : 0,
261 277
         tag_list: this.tag_info && this.tag_info.tag_id_list ? this.tag_info.tag_id_list.join(',') : '',
262 278
         exclude_tag_list: this.exclude_tag_info && this.exclude_tag_info.tag_id_list ? this.exclude_tag_info.tag_id_list.join(',') : '',
263
-        content: this.content,
264
-        attachments: this.attachments == '' || this.attachments.length == 0 ? '' : JSON.stringify(this.attachments),
265
-        senders: this.is_for_all == 0 ? this.user_id_list.join(',') : '',
266 279
         pay_status: this.payInfo.pay_status || this.payInfo.pay_status == 0 ? this.payInfo.pay_status : '',
267 280
         pay_num_min: this.payInfo.pay_num_min || this.payInfo.pay_num_min == 0 ? this.payInfo.pay_num_min : '',
268 281
         pay_num_max: this.payInfo.pay_num_max || this.payInfo.pay_num_max == 0 ? this.payInfo.pay_num_max : '',
269 282
       }
270
-
271 283
       console.log('params => ', JSON.parse(JSON.stringify(params)))
272
-      return // mock
273
-
274
-      this.$axios.post(this.URL.BASEURL + this.URL.massMsg_set, params).then((res) => {
284
+      this.$axios.post(this.URL.BASEURL + this.URL.smartPush_set, params).then((res) => {
275 285
         var res = res.data
276 286
         this.$loading(this.$loadingConfig).close()
277 287
         if (res && res.errno == 0) {