|
@@ -0,0 +1,358 @@
|
|
1
|
+<template>
|
|
2
|
+ <el-dialog
|
|
3
|
+ :visible.sync="dialogVisible"
|
|
4
|
+ :before-close="handleCancel"
|
|
5
|
+ class="warn-dialog"
|
|
6
|
+ :title="title"
|
|
7
|
+ width="560px"
|
|
8
|
+ :close-on-click-modal="false"
|
|
9
|
+ >
|
|
10
|
+ <div class="form-wrap" v-loading="loading">
|
|
11
|
+ <!-- 预警客服 -->
|
|
12
|
+ <div class="form-item">
|
|
13
|
+ <span class="lable required">预警客服:</span>
|
|
14
|
+ <customerServiceCorp
|
|
15
|
+ title=""
|
|
16
|
+ :icon_arrow_bg="false"
|
|
17
|
+ width="410px"
|
|
18
|
+ style="margin:0;"
|
|
19
|
+ :afferent_users="form.afferent_djuser_list"
|
|
20
|
+ @customerDefine="onChangeDjuserList"
|
|
21
|
+ />
|
|
22
|
+ </div>
|
|
23
|
+ <!-- 预警人员类型 -->
|
|
24
|
+ <div class="form-item">
|
|
25
|
+ <span class="lable required">预警人员:</span>
|
|
26
|
+ <el-radio-group v-model="form.type" style="margin-top: 3px;">
|
|
27
|
+ <el-radio :label="1">预警人</el-radio>
|
|
28
|
+ <el-radio :label="2">预警组</el-radio>
|
|
29
|
+ </el-radio-group>
|
|
30
|
+ </div>
|
|
31
|
+ <!-- 预警人 (渲染条件 form.type == 1) -->
|
|
32
|
+ <div v-if="form.type == 1" class="form-item">
|
|
33
|
+ <span class="lable"></span>
|
|
34
|
+ <el-select v-model="form.warnUserList" size="small" placeholder="请选择预警人" clearable filterable multiple>
|
|
35
|
+ <el-option v-for="item in warnUserOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
36
|
+ </el-select>
|
|
37
|
+ </div>
|
|
38
|
+ <!-- 预警组 (渲染条件 form.type === 2) -->
|
|
39
|
+ <div v-if="form.type == 2" class="form-item">
|
|
40
|
+ <span class="lable"></span>
|
|
41
|
+ <el-select v-model="form.warnGroupList" size="small" placeholder="请选择预警组" clearable filterable multiple>
|
|
42
|
+ <el-option v-for="item in warnGroupOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
43
|
+ </el-select>
|
|
44
|
+ </div>
|
|
45
|
+ <!-- 预警规则 -->
|
|
46
|
+ <div class="form-item flex-align-start">
|
|
47
|
+ <span class="lable required">预警规则:</span>
|
|
48
|
+ <div class="rules-wrap">
|
|
49
|
+ <div v-for="(item, idx) in form.rules" :key="idx" class="rules-item">
|
|
50
|
+ <el-input v-model.trim="item.minute" size="mini" placeholder="请输入" maxlength="3" clearable />
|
|
51
|
+ <span class="text">分钟内,添加人数</span>
|
|
52
|
+ <el-select v-model="item.contrast" size="mini">
|
|
53
|
+ <el-option v-for="contrast in contrastOptions" :key="contrast.value" :label="contrast.label" :value="contrast.value" />
|
|
54
|
+ </el-select>
|
|
55
|
+ <el-input v-model.trim="item.personCount" size="mini" placeholder="请输入" maxlength="5" clearable />
|
|
56
|
+ <span class="text">人</span>
|
|
57
|
+ <i v-if="idx > 0" class="el-icon-error" @click="onClickDelRules(idx)" />
|
|
58
|
+ </div>
|
|
59
|
+ <div class="add-wrap" @click="onClickAddRules">
|
|
60
|
+ <i class="el-icon-plus" />
|
|
61
|
+ <span>添加规则</span>
|
|
62
|
+ </div>
|
|
63
|
+ </div>
|
|
64
|
+ </div>
|
|
65
|
+ </div>
|
|
66
|
+ <div slot="footer" class="dialog-footer">
|
|
67
|
+ <el-button size="mini" @click="handleCancel">取 消</el-button>
|
|
68
|
+ <el-button size="mini" type="primary" @click="handleConfirm">确 定</el-button>
|
|
69
|
+ </div>
|
|
70
|
+ </el-dialog>
|
|
71
|
+</template>
|
|
72
|
+
|
|
73
|
+<script>
|
|
74
|
+import customerServiceCorp from '@/components/assembly/screen/customerServiceCorp.vue'
|
|
75
|
+
|
|
76
|
+const contrastOptions = [
|
|
77
|
+ { label: '低于', value: 1 },
|
|
78
|
+ { label: '高于', value: 2 },
|
|
79
|
+]
|
|
80
|
+
|
|
81
|
+export default {
|
|
82
|
+ name: "warnDialog",
|
|
83
|
+ components: {
|
|
84
|
+ customerServiceCorp,
|
|
85
|
+ },
|
|
86
|
+ props: {
|
|
87
|
+ // 控制弹框是否显示
|
|
88
|
+ dialogVisible: {
|
|
89
|
+ type: Boolean,
|
|
90
|
+ default: () => false
|
|
91
|
+ },
|
|
92
|
+ // 规则ID
|
|
93
|
+ ruleId: {
|
|
94
|
+ type: [String, Number],
|
|
95
|
+ default: () => ''
|
|
96
|
+ },
|
|
97
|
+ },
|
|
98
|
+ data() {
|
|
99
|
+ return {
|
|
100
|
+ loading: false,
|
|
101
|
+ contrastOptions: Object.freeze(contrastOptions),
|
|
102
|
+ warnUserOptions: [], // 预警人选项
|
|
103
|
+ warnGroupOptions: [], // 预警组选项
|
|
104
|
+ form: {
|
|
105
|
+ afferent_djuser_list: [], // 预警客服 [{ user_id: 888, corpid: 666 }]
|
|
106
|
+ djuser_list: [], // 预警客服
|
|
107
|
+ type: 1, // 预警人员类型 1预警人 2预警组
|
|
108
|
+ warnUserList: [], // 预警人
|
|
109
|
+ warnGroupList: [], // 预警组
|
|
110
|
+ rules: [ // 预警规则
|
|
111
|
+ {
|
|
112
|
+ minute: '',
|
|
113
|
+ contrast: 1,
|
|
114
|
+ personCount: '',
|
|
115
|
+ }
|
|
116
|
+ ]
|
|
117
|
+ }
|
|
118
|
+ }
|
|
119
|
+ },
|
|
120
|
+ computed: {
|
|
121
|
+ isEdit() {
|
|
122
|
+ return !!this.ruleId
|
|
123
|
+ },
|
|
124
|
+ title() {
|
|
125
|
+ return `${this.isEdit ? '编辑' : '新建'}预警`
|
|
126
|
+ },
|
|
127
|
+ },
|
|
128
|
+ watch: {
|
|
129
|
+ dialogVisible(isShow) {
|
|
130
|
+ if (isShow) {
|
|
131
|
+ // 获取"预警人"选项
|
|
132
|
+ this.handleGetWarnUserOptions()
|
|
133
|
+ // 获取"预警组"选项
|
|
134
|
+ this.handleGetWarnGroupOptions()
|
|
135
|
+ // 获取表单数据
|
|
136
|
+ this.handleGetFormData()
|
|
137
|
+ }
|
|
138
|
+ },
|
|
139
|
+ },
|
|
140
|
+ methods: {
|
|
141
|
+ // 获取"预警人"选项列表
|
|
142
|
+ async handleGetWarnUserOptions () {
|
|
143
|
+ try {
|
|
144
|
+ const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.warn_userList, {
|
|
145
|
+ params: {
|
|
146
|
+ sys_group_id: this.$cookie.getCookie('isSuperManage') == 1 ? sessionStorage.getItem('company_session_defaultCorp_level_1').toString() : '',
|
|
147
|
+ page: 1,
|
|
148
|
+ page_size: 500
|
|
149
|
+ }
|
|
150
|
+ })
|
|
151
|
+ if (res && res.errno == 0) {
|
|
152
|
+ this.warnUserOptions = res.rst.data
|
|
153
|
+ } else if (res.errno != 4002) {
|
|
154
|
+ this.warnUserOptions = []
|
|
155
|
+ this.$message.warning(res.err)
|
|
156
|
+ }
|
|
157
|
+ } catch (error) {
|
|
158
|
+ this.warnUserOptions = []
|
|
159
|
+ console.log('error => ', error)
|
|
160
|
+ }
|
|
161
|
+ },
|
|
162
|
+ // 获取"预警组"选项列表
|
|
163
|
+ async handleGetWarnGroupOptions () {
|
|
164
|
+ try {
|
|
165
|
+ const { data: res = {} } = await this.$axios.get(this.URL.BASEURL + this.URL.warn_userList, {
|
|
166
|
+ params: {
|
|
167
|
+ sys_group_id: this.$cookie.getCookie('isSuperManage') == 1 ? sessionStorage.getItem('company_session_defaultCorp_level_1').toString() : '',
|
|
168
|
+ page: 1,
|
|
169
|
+ page_size: 500
|
|
170
|
+ }
|
|
171
|
+ })
|
|
172
|
+ if (res && res.errno == 0) {
|
|
173
|
+ this.warnGroupOptions = res.rst.data
|
|
174
|
+ } else if (res.errno != 4002) {
|
|
175
|
+ this.warnGroupOptions = []
|
|
176
|
+ this.$message.warning(res.err)
|
|
177
|
+ }
|
|
178
|
+ } catch (error) {
|
|
179
|
+ this.warnGroupOptions = []
|
|
180
|
+ console.log('error => ', error)
|
|
181
|
+ }
|
|
182
|
+ },
|
|
183
|
+ async handleConfirm() {
|
|
184
|
+ try {
|
|
185
|
+ // 表单校验
|
|
186
|
+ await this.handleFormValidate()
|
|
187
|
+ const url = `${this.URL.BASEURL}${this.URL.dataBoardHS_bindAdq}`
|
|
188
|
+ const params = {}
|
|
189
|
+ this.loading = true
|
|
190
|
+ const { data: res = {} } = await this.$axios.post(url, params)
|
|
191
|
+ if (res && res.errno == 0) {
|
|
192
|
+ this.$message.success('操作成功')
|
|
193
|
+ this.handleClearFormData()
|
|
194
|
+ this.$emit('confirm')
|
|
195
|
+ } else if (res.errno != 4002) {
|
|
196
|
+ this.$message.warning(res.err || '操作失败')
|
|
197
|
+ }
|
|
198
|
+ } catch (error) {
|
|
199
|
+ console.log('error => ', error)
|
|
200
|
+ } finally {
|
|
201
|
+ this.loading = false
|
|
202
|
+ }
|
|
203
|
+ },
|
|
204
|
+ handleCancel() {
|
|
205
|
+ this.handleClearFormData()
|
|
206
|
+ this.$emit('cancel')
|
|
207
|
+ },
|
|
208
|
+ // 执行表单校验
|
|
209
|
+ handleFormValidate() {
|
|
210
|
+ return new Promise((resolve, reject) => {
|
|
211
|
+ // mock
|
|
212
|
+ console.log('form => ', JSON.parse(JSON.stringify(this.form)))
|
|
213
|
+ reject('表单校验未通过')
|
|
214
|
+ return
|
|
215
|
+ // mock
|
|
216
|
+
|
|
217
|
+ if (!this.form.xxxList || !this.form.xxxList.length) {
|
|
218
|
+ this.$message.warning('请选择ADQ账号')
|
|
219
|
+ reject('表单校验未通过')
|
|
220
|
+ } else {
|
|
221
|
+ resolve('表单校验通过')
|
|
222
|
+ }
|
|
223
|
+ })
|
|
224
|
+ },
|
|
225
|
+ // 获取表单数据
|
|
226
|
+ handleGetFormData() {
|
|
227
|
+ this.handleClearFormData()
|
|
228
|
+ if (this.isEdit) { // 编辑 => 获取规则详情 => 回显表单数据
|
|
229
|
+ this.handleGetRuleDetail()
|
|
230
|
+ }
|
|
231
|
+ },
|
|
232
|
+ // 获取规则详情
|
|
233
|
+ handleGetRuleDetail() {
|
|
234
|
+ console.log('handleGetRuleDetail => ruleId ', this.ruleId)
|
|
235
|
+ },
|
|
236
|
+ // 清空弹框表单数据
|
|
237
|
+ handleClearFormData() {
|
|
238
|
+ this.form.afferent_djuser_list = []
|
|
239
|
+ this.form.djuser_list = []
|
|
240
|
+ this.form.type = 1
|
|
241
|
+ this.form.warnUserList = []
|
|
242
|
+ this.form.warnGroupList = []
|
|
243
|
+ this.form.rules = [
|
|
244
|
+ {
|
|
245
|
+ minute: '',
|
|
246
|
+ contrast: 1,
|
|
247
|
+ personCount: '',
|
|
248
|
+ }
|
|
249
|
+ ]
|
|
250
|
+ },
|
|
251
|
+ // 监听点击“添加规则”
|
|
252
|
+ onClickAddRules() {
|
|
253
|
+ this.form.rules.push({
|
|
254
|
+ minute: '',
|
|
255
|
+ contrast: 1,
|
|
256
|
+ personCount: '',
|
|
257
|
+ })
|
|
258
|
+ },
|
|
259
|
+ // 监听点击“删除规则”
|
|
260
|
+ onClickDelRules(idx) {
|
|
261
|
+ this.form.rules.splice(idx, 1)
|
|
262
|
+ },
|
|
263
|
+ // 监听“客服”
|
|
264
|
+ onChangeDjuserList(val) {
|
|
265
|
+ console.log('onChangeDjuserList => val ', val)
|
|
266
|
+ this.form.djuser_list = val
|
|
267
|
+ },
|
|
268
|
+ },
|
|
269
|
+};
|
|
270
|
+</script>
|
|
271
|
+
|
|
272
|
+<style lang="scss" scoped>
|
|
273
|
+.warn-dialog {
|
|
274
|
+ /deep/ .el-dialog__body {
|
|
275
|
+ max-height: 380px;
|
|
276
|
+ overflow-y: auto;
|
|
277
|
+ }
|
|
278
|
+ .form-wrap {
|
|
279
|
+ padding-right: 20px;
|
|
280
|
+ .form-item {
|
|
281
|
+ display: flex;
|
|
282
|
+ align-items: center;
|
|
283
|
+ margin-top: 20px;
|
|
284
|
+ &.flex-align-start {
|
|
285
|
+ align-items: flex-start;
|
|
286
|
+ }
|
|
287
|
+ &:first-child {
|
|
288
|
+ margin-top: 0;
|
|
289
|
+ }
|
|
290
|
+ .lable {
|
|
291
|
+ width: 80px;
|
|
292
|
+ font-weight: 500;
|
|
293
|
+ flex-shrink: 0;
|
|
294
|
+ text-align: right;
|
|
295
|
+ margin-right: 10px;
|
|
296
|
+
|
|
297
|
+ &.required {
|
|
298
|
+ &::before {
|
|
299
|
+ position: relative;
|
|
300
|
+ right: 2px;
|
|
301
|
+ content: "*";
|
|
302
|
+ color: #f56c6c;
|
|
303
|
+ }
|
|
304
|
+ }
|
|
305
|
+ }
|
|
306
|
+ .el-select {
|
|
307
|
+ width: 100%;
|
|
308
|
+ }
|
|
309
|
+ .rules-wrap {
|
|
310
|
+ background-color: #F2F2F2;
|
|
311
|
+ padding: 14px;
|
|
312
|
+ flex: 1;
|
|
313
|
+ .rules-item {
|
|
314
|
+ display: flex;
|
|
315
|
+ align-items: center;
|
|
316
|
+ flex-shrink: 0;
|
|
317
|
+ margin-bottom: 10px;
|
|
318
|
+ .el-input {
|
|
319
|
+ width: 70px;
|
|
320
|
+ margin-right: 6px;
|
|
321
|
+ /deep/ .el-input__inner {
|
|
322
|
+ padding: 0 24px 0 8px;
|
|
323
|
+ }
|
|
324
|
+ }
|
|
325
|
+ .el-select {
|
|
326
|
+ width: 70px;
|
|
327
|
+ margin-right: 6px;
|
|
328
|
+ }
|
|
329
|
+ .text {
|
|
330
|
+ margin-right: 6px;
|
|
331
|
+ font-size: 13px;
|
|
332
|
+ }
|
|
333
|
+ .el-icon-error {
|
|
334
|
+ color: #F56C6C;
|
|
335
|
+ font-size: 14px;
|
|
336
|
+ cursor: pointer;
|
|
337
|
+ }
|
|
338
|
+ }
|
|
339
|
+ .add-wrap {
|
|
340
|
+ margin-top: 16px;
|
|
341
|
+ display: flex;
|
|
342
|
+ align-items: center;
|
|
343
|
+ color: #00B38A;
|
|
344
|
+ font-size: 13px;
|
|
345
|
+ cursor: pointer;
|
|
346
|
+ i {
|
|
347
|
+ font-weight: 600;
|
|
348
|
+ margin-right: 2px;
|
|
349
|
+ }
|
|
350
|
+ }
|
|
351
|
+ }
|
|
352
|
+ }
|
|
353
|
+ }
|
|
354
|
+ .dialog-footer {
|
|
355
|
+ text-align: center;
|
|
356
|
+ }
|
|
357
|
+}
|
|
358
|
+</style>
|