Pārlūkot izejas kodu

feat: 客服异常预警 - 预警规则 - 详情&编辑

zhengxy 2 gadi atpakaļ
vecāks
revīzija
8ce5f6d207

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

@@ -364,6 +364,7 @@ var api = {
364 364
   customerAlerts_setConf: "/api/abnormalAccount/setConf", // 客服异常预警 - 设置预警规则
365 365
   customerAlerts_confList: "/api/abnormalAccount/confList", // 客服异常预警 - 列表
366 366
   customerAlerts_updateConfStatus: "/api/abnormalAccount/updateConfStatus", // 客服异常预警 - 启用/禁用
367
+  customerAlerts_confDetail: "/api/abnormalAccount/confDetail", // 客服异常预警 - 规则详情
367 368
 
368 369
 };
369 370
 

+ 64 - 32
project/src/components/customerAlerts/dialog/warnDialog.vue

@@ -29,16 +29,16 @@
29 29
         </el-radio-group>
30 30
       </div>
31 31
       <!-- 预警人 -->
32
-      <div v-if="form.notice_type == noticeTypes.USER" class="form-item">
32
+      <div v-show="form.notice_type == noticeTypes.USER" class="form-item">
33 33
         <span class="lable"></span>
34 34
         <el-select v-model="form.warnUserList" size="small" placeholder="请选择预警人" clearable filterable multiple>
35 35
           <el-option v-for="item in warnUserOptions" :key="item.id" :label="item.name" :value="item.id" />
36 36
         </el-select>
37 37
       </div>
38 38
       <!-- 预警组 -->
39
-      <div v-if="form.notice_type == noticeTypes.GROUP" class="form-item">
39
+      <div v-show="form.notice_type == noticeTypes.GROUP" class="form-item">
40 40
         <span class="lable"></span>
41
-        <el-select v-model="form.warnGroupList" size="small" placeholder="请选择预警组" clearable filterable multiple>
41
+        <el-select v-model="form.warnGroup" size="small" placeholder="请选择预警组" clearable filterable>
42 42
           <el-option v-for="item in warnGroupOptions" :key="item.id" :label="item.name" :value="item.id" />
43 43
         </el-select>
44 44
       </div>
@@ -76,8 +76,8 @@
76 76
       </div>
77 77
     </div>
78 78
     <div slot="footer" class="dialog-footer">
79
-      <el-button size="mini" @click="handleCancel">取 消</el-button>
80
-      <el-button size="mini" type="primary" @click="handleConfirm">确 定</el-button>
79
+      <el-button size="mini" @click="handleCancel" :disabled="loading">取 消</el-button>
80
+      <el-button size="mini" type="primary" @click="handleConfirm" :disabled="loading">确 定</el-button>
81 81
     </div>
82 82
   </el-dialog>
83 83
 </template>
@@ -99,7 +99,7 @@ export default {
99 99
       default: () => false
100 100
     },
101 101
     // 规则ID
102
-    ruleId: {
102
+    confId: {
103 103
       type: [String, Number],
104 104
       default: () => ''
105 105
     },
@@ -117,7 +117,7 @@ export default {
117 117
         monitor_user_list: [], // 预警客服
118 118
         notice_type: noticeTypes.USER, // 预警人员类型 1预警人 2预警组
119 119
         warnUserList: [], // 预警人
120
-        warnGroupList: [], // 预警组
120
+        warnGroup: '', // 预警组
121 121
         rules: [ // 预警规则
122 122
           {
123 123
             minute: '',
@@ -130,7 +130,7 @@ export default {
130 130
   },
131 131
   computed: {
132 132
     isEdit() {
133
-      return !!this.ruleId
133
+      return !!this.confId
134 134
     },
135 135
     title() {
136 136
       return `${this.isEdit ? '编辑' : '新建'}预警`
@@ -190,31 +190,13 @@ export default {
190 190
         console.log('error => ', error)
191 191
       }
192 192
     },
193
-    handleGetParams() {
194
-      const params = {
195
-        monitor_user_list: JSON.stringify(this.form.monitor_user_list),
196
-        notice_type: this.form.notice_type,
197
-        sys_group_id: this.sys_group_id,
198
-        content: JSON.stringify(this.form.rules),
199
-        conf_id: this.isEdit ? this.ruleId : '',
200
-      }
201
-
202
-      if (this.form.notice_type == noticeTypes.USER) { // 收集“预警人”参数
203
-        params.notice_list = this.form.warnUserList.join(',')
204
-      } else if (this.form.notice_type == noticeTypes.GROUP) { // 收集“预警组”参数
205
-        params.notice_list = this.form.warnGroupList.join(',')
206
-      }
207
-
208
-      return {...params}
209
-    },
193
+    // 确定
210 194
     async handleConfirm() {
211 195
       try {
212
-        console.log('form => ', JSON.parse(JSON.stringify(this.form)))
213 196
         // 表单校验
214 197
         await this.handleFormValidate()
215 198
         const url = `${this.URL.BASEURL}${this.URL.customerAlerts_setConf}`
216 199
         const params = this.handleGetParams()
217
-        console.log('params => ', JSON.parse(JSON.stringify(params)))
218 200
         this.loading = true
219 201
         const { data: res = {} } = await this.$axios.post(url, params)
220 202
         if (res && res.errno == 0) {
@@ -230,6 +212,7 @@ export default {
230 212
         this.loading = false
231 213
       }
232 214
     },
215
+    // 取消
233 216
     handleCancel() {
234 217
       this.handleClearFormData()
235 218
       this.$emit('cancel')
@@ -237,7 +220,7 @@ export default {
237 220
     // 执行表单校验
238 221
     handleFormValidate() {
239 222
       return new Promise((resolve, reject) => {
240
-        const { monitor_user_list, notice_type, warnUserList, warnGroupList, rules } = this.form
223
+        const { monitor_user_list, notice_type, warnUserList, warnGroup, rules } = this.form
241 224
         const isHasNullRules = rules.some(rule => !rule.minute || !rule.num)
242 225
 
243 226
         if (!monitor_user_list || !monitor_user_list.length) {
@@ -246,7 +229,7 @@ export default {
246 229
         } else if ((notice_type == noticeTypes.USER) && !warnUserList.length) {
247 230
           this.$message.warning('请选择预警人')
248 231
           reject('表单校验未通过')
249
-        } else if ((notice_type == noticeTypes.GROUP) && !warnGroupList.length) {
232
+        } else if ((notice_type == noticeTypes.GROUP) && !warnGroup) {
250 233
           this.$message.warning('请选择预警组')
251 234
           reject('表单校验未通过')
252 235
         } else if (isHasNullRules) {
@@ -257,6 +240,24 @@ export default {
257 240
         }
258 241
       })
259 242
     },
243
+    // 整理请求参数
244
+    handleGetParams() {
245
+      const params = {
246
+        monitor_user_list: JSON.stringify(this.form.monitor_user_list),
247
+        notice_type: this.form.notice_type,
248
+        sys_group_id: this.sys_group_id,
249
+        content: JSON.stringify(this.form.rules),
250
+        conf_id: this.isEdit ? this.confId : '',
251
+      }
252
+
253
+      if (this.form.notice_type == noticeTypes.USER) { // 收集“预警人”参数
254
+        params.notice_list = this.form.warnUserList.join(',')
255
+      } else if (this.form.notice_type == noticeTypes.GROUP) { // 收集“预警组”参数
256
+        params.notice_list = String(this.form.warnGroup)
257
+      }
258
+
259
+      return {...params}
260
+    },
260 261
     // 获取表单数据
261 262
     handleGetFormData() {
262 263
       this.handleClearFormData()
@@ -265,8 +266,39 @@ export default {
265 266
       }
266 267
     },
267 268
     // 获取规则详情
268
-    handleGetRuleDetail() {
269
-      console.log('handleGetRuleDetail => ruleId ', this.ruleId)
269
+    async handleGetRuleDetail() {
270
+      try {
271
+        const url = `${this.URL.BASEURL}${this.URL.customerAlerts_confDetail}`
272
+        const params = {
273
+          sys_group_id: this.sys_group_id,
274
+          conf_id: this.confId,
275
+        }
276
+        this.loading = true
277
+        const { data: res = {} } = await this.$axios.get(url, { params })
278
+        if (res && res.errno == 0) {
279
+          const detailInfo = res.rst
280
+
281
+          if (detailInfo.monitor_user_list && detailInfo.monitor_user_list.length) {
282
+            this.form.afferent_djuser_list = detailInfo.monitor_user_list.map(({ user_id, corpid }) => ({ user_id, corpid }))
283
+            this.form.monitor_user_list = [...this.form.afferent_djuser_list]
284
+          }
285
+
286
+          this.form.notice_type = Number(detailInfo.notice_type) // 预警人员类型
287
+          if (this.form.notice_type == noticeTypes.USER) { // 预警人回显 多选
288
+            this.form.warnUserList = detailInfo.notice_list.map(({ id }) => id)
289
+          } else if (this.form.notice_type == noticeTypes.GROUP) { // 预警组回显 单选 取第一项id
290
+            this.form.warnGroup = detailInfo.notice_list[0] ? detailInfo.notice_list[0].id : ''
291
+          }
292
+
293
+          this.form.rules = [...detailInfo.content]
294
+        } else if (res.errno != 4002) {
295
+          this.$message.warning(res.err || '操作失败')
296
+        }
297
+      } catch (error) {
298
+        console.log('error => ', error)
299
+      } finally {
300
+        this.loading = false
301
+      }
270 302
     },
271 303
     // 清空弹框表单数据
272 304
     handleClearFormData() {
@@ -274,7 +306,7 @@ export default {
274 306
       this.form.monitor_user_list = []
275 307
       this.form.notice_type = noticeTypes.USER
276 308
       this.form.warnUserList = []
277
-      this.form.warnGroupList = []
309
+      this.form.warnGroup = ''
278 310
       this.form.rules = [
279 311
         {
280 312
           minute: '',

+ 5 - 5
project/src/components/customerAlerts/index.vue

@@ -48,7 +48,7 @@
48 48
             <span v-if="row.status == statusTypes.ENABLE" class="btn c-FF604D" @click="onClickSetStatus({ conf_id: row.conf_id, status: statusTypes.DISABLE })">禁用</span>
49 49
             <span v-else-if="row.status == statusTypes.DISABLE" class="btn c-007AFF" @click="onClickSetStatus({ conf_id: row.conf_id, status: statusTypes.ENABLE })">启用</span>
50 50
           </template>
51
-          <span class="btn c-00b38a" @click="onClickEditWarnBtn(row.group_id)">编辑</span>
51
+          <span class="btn c-00b38a" @click="onClickEditWarnBtn(row.conf_id)">编辑</span>
52 52
         </template>
53 53
       </el-table-column>
54 54
     </el-table>
@@ -60,7 +60,7 @@
60 60
     <!-- S 新建预警/编辑预警 -->
61 61
     <warnDialog
62 62
       :dialogVisible="warnDialogVisible"
63
-      :ruleId="currentWarnRuleId"
63
+      :confId="currentWarnConfId"
64 64
       @confirm="onConfirmWarnDialog"
65 65
       @cancel="onCancelWarnDialog"
66 66
     />
@@ -96,7 +96,7 @@ export default {
96 96
       list: [],
97 97
 
98 98
       warnDialogVisible: false, // 控制是否显示“新建预警”、“编辑预警”弹框
99
-      currentWarnRuleId: '', // 当前预警规则id
99
+      currentWarnConfId: '', // 当前预警规则id
100 100
     }
101 101
   },
102 102
   created () {
@@ -178,12 +178,12 @@ export default {
178 178
     // S 新建预警、编辑预警
179 179
     // 监听点击“新建预警”
180 180
     onClickCreateWarnBtn() {
181
-      this.currentWarnRuleId = ''
181
+      this.currentWarnConfId = ''
182 182
       this.warnDialogVisible = true
183 183
     },
184 184
     // 监听点击“编辑预警”
185 185
     onClickEditWarnBtn(id) {
186
-      this.currentWarnRuleId = id
186
+      this.currentWarnConfId = id
187 187
       this.warnDialogVisible = true
188 188
     },
189 189
     // 监听新建预警 => 确定