|
|
|
|
23
|
<!-- 预警人员类型 -->
|
23
|
<!-- 预警人员类型 -->
|
24
|
<div class="form-item">
|
24
|
<div class="form-item">
|
25
|
<span class="lable required">预警人员:</span>
|
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>
|
|
|
|
|
26
|
+ <el-radio-group v-model="form.notice_type" style="margin-top: 3px;">
|
|
|
27
|
+ <el-radio :label="noticeTypes.USER">预警人</el-radio>
|
|
|
28
|
+ <el-radio :label="noticeTypes.GROUP">预警组</el-radio>
|
29
|
</el-radio-group>
|
29
|
</el-radio-group>
|
30
|
</div>
|
30
|
</div>
|
31
|
- <!-- 预警人 (渲染条件 form.type == 1) -->
|
|
|
32
|
- <div v-if="form.type == 1" class="form-item">
|
|
|
|
|
31
|
+ <!-- 预警人 -->
|
|
|
32
|
+ <div v-if="form.notice_type == noticeTypes.USER" class="form-item">
|
33
|
<span class="lable"></span>
|
33
|
<span class="lable"></span>
|
34
|
<el-select v-model="form.warnUserList" size="small" placeholder="请选择预警人" clearable filterable multiple>
|
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" />
|
35
|
<el-option v-for="item in warnUserOptions" :key="item.id" :label="item.name" :value="item.id" />
|
36
|
</el-select>
|
36
|
</el-select>
|
37
|
</div>
|
37
|
</div>
|
38
|
- <!-- 预警组 (渲染条件 form.type === 2) -->
|
|
|
39
|
- <div v-if="form.type == 2" class="form-item">
|
|
|
|
|
38
|
+ <!-- 预警组 -->
|
|
|
39
|
+ <div v-if="form.notice_type == noticeTypes.GROUP" class="form-item">
|
40
|
<span class="lable"></span>
|
40
|
<span class="lable"></span>
|
41
|
<el-select v-model="form.warnGroupList" size="small" placeholder="请选择预警组" clearable filterable multiple>
|
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" />
|
42
|
<el-option v-for="item in warnGroupOptions" :key="item.id" :label="item.name" :value="item.id" />
|
|
|
|
|
47
|
<span class="lable required">预警规则:</span>
|
47
|
<span class="lable required">预警规则:</span>
|
48
|
<div class="rules-wrap">
|
48
|
<div class="rules-wrap">
|
49
|
<div v-for="(item, idx) in form.rules" :key="idx" class="rules-item">
|
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 />
|
|
|
|
|
50
|
+ <el-input v-model.trim="item.minute" size="mini" placeholder="请输入" maxlength="3" clearable @input="onInputMinute($event, idx)" @change="onChangeMinute($event, idx)" />
|
51
|
<span class="text">分钟内,添加人数</span>
|
51
|
<span class="text">分钟内,添加人数</span>
|
52
|
<el-select v-model="item.contrast" size="mini">
|
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" />
|
53
|
<el-option v-for="contrast in contrastOptions" :key="contrast.value" :label="contrast.label" :value="contrast.value" />
|
54
|
</el-select>
|
54
|
</el-select>
|
55
|
- <el-input v-model.trim="item.personCount" size="mini" placeholder="请输入" maxlength="5" clearable />
|
|
|
|
|
55
|
+ <el-input v-model.trim="item.personCount" size="mini" placeholder="请输入" maxlength="5" clearable @input="onInputPersonCount($event, idx)" @change="onChangePersonCount($event, idx)" />
|
56
|
<span class="text">人</span>
|
56
|
<span class="text">人</span>
|
57
|
<i v-if="idx > 0" class="el-icon-error" @click="onClickDelRules(idx)" />
|
57
|
<i v-if="idx > 0" class="el-icon-error" @click="onClickDelRules(idx)" />
|
58
|
</div>
|
58
|
</div>
|
|
|
|
|
72
|
|
72
|
|
73
|
<script>
|
73
|
<script>
|
74
|
import customerServiceCorp from '@/components/assembly/screen/customerServiceCorp.vue'
|
74
|
import customerServiceCorp from '@/components/assembly/screen/customerServiceCorp.vue'
|
|
|
75
|
+import { getIntegerNumber } from '@/assets/js/common'
|
75
|
|
76
|
|
76
|
const contrastOptions = [
|
77
|
const contrastOptions = [
|
77
|
{ label: '低于', value: 1 },
|
78
|
{ label: '低于', value: 1 },
|
78
|
{ label: '高于', value: 2 },
|
79
|
{ label: '高于', value: 2 },
|
79
|
]
|
80
|
]
|
80
|
|
81
|
|
|
|
82
|
+const noticeTypes = { // 预警类型
|
|
|
83
|
+ 'USER': 1, // 预警人
|
|
|
84
|
+ 'GROUP': 2, // 预警组
|
|
|
85
|
+}
|
|
|
86
|
+
|
81
|
export default {
|
87
|
export default {
|
82
|
name: "warnDialog",
|
88
|
name: "warnDialog",
|
83
|
components: {
|
89
|
components: {
|
|
|
|
|
99
|
return {
|
105
|
return {
|
100
|
loading: false,
|
106
|
loading: false,
|
101
|
contrastOptions: Object.freeze(contrastOptions),
|
107
|
contrastOptions: Object.freeze(contrastOptions),
|
|
|
108
|
+ noticeTypes: Object.freeze(noticeTypes),
|
102
|
warnUserOptions: [], // 预警人选项
|
109
|
warnUserOptions: [], // 预警人选项
|
103
|
warnGroupOptions: [], // 预警组选项
|
110
|
warnGroupOptions: [], // 预警组选项
|
104
|
form: {
|
111
|
form: {
|
105
|
afferent_djuser_list: [], // 预警客服 [{ user_id: 888, corpid: 666 }]
|
112
|
afferent_djuser_list: [], // 预警客服 [{ user_id: 888, corpid: 666 }]
|
106
|
djuser_list: [], // 预警客服
|
113
|
djuser_list: [], // 预警客服
|
107
|
- type: 1, // 预警人员类型 1预警人 2预警组
|
|
|
|
|
114
|
+ notice_type: noticeTypes.USER, // 预警人员类型 1预警人 2预警组
|
108
|
warnUserList: [], // 预警人
|
115
|
warnUserList: [], // 预警人
|
109
|
warnGroupList: [], // 预警组
|
116
|
warnGroupList: [], // 预警组
|
110
|
rules: [ // 预警规则
|
117
|
rules: [ // 预警规则
|
|
|
|
|
182
|
},
|
189
|
},
|
183
|
async handleConfirm() {
|
190
|
async handleConfirm() {
|
184
|
try {
|
191
|
try {
|
|
|
192
|
+ console.log('form => ', JSON.parse(JSON.stringify(this.form)))
|
185
|
// 表单校验
|
193
|
// 表单校验
|
186
|
await this.handleFormValidate()
|
194
|
await this.handleFormValidate()
|
|
|
195
|
+ console.log('通过!')
|
|
|
196
|
+ return // mock
|
187
|
const url = `${this.URL.BASEURL}${this.URL.dataBoardHS_bindAdq}`
|
197
|
const url = `${this.URL.BASEURL}${this.URL.dataBoardHS_bindAdq}`
|
188
|
const params = {}
|
198
|
const params = {}
|
189
|
this.loading = true
|
199
|
this.loading = true
|
|
|
|
|
208
|
// 执行表单校验
|
218
|
// 执行表单校验
|
209
|
handleFormValidate() {
|
219
|
handleFormValidate() {
|
210
|
return new Promise((resolve, reject) => {
|
220
|
return new Promise((resolve, reject) => {
|
211
|
- // mock
|
|
|
212
|
- console.log('form => ', JSON.parse(JSON.stringify(this.form)))
|
|
|
213
|
- reject('表单校验未通过')
|
|
|
214
|
- return
|
|
|
215
|
- // mock
|
|
|
|
|
221
|
+ const { noticeTypes, form: { djuser_list, notice_type, warnUserList, warnGroupList, rules } } = this
|
|
|
222
|
+ const isHasNullRules = rules.some(rule => !rule.minute || !rule.personCount)
|
216
|
|
223
|
|
217
|
- if (!this.form.xxxList || !this.form.xxxList.length) {
|
|
|
218
|
- this.$message.warning('请选择ADQ账号')
|
|
|
|
|
224
|
+ if (!djuser_list || !djuser_list.length) {
|
|
|
225
|
+ this.$message.warning('请选择预警客服')
|
|
|
226
|
+ reject('表单校验未通过')
|
|
|
227
|
+ } else if ((notice_type == noticeTypes.USER) && !warnUserList.length) {
|
|
|
228
|
+ this.$message.warning('请选择预警人')
|
|
|
229
|
+ reject('表单校验未通过')
|
|
|
230
|
+ } else if ((notice_type == noticeTypes.GROUP) && !warnGroupList.length) {
|
|
|
231
|
+ this.$message.warning('请选择预警组')
|
|
|
232
|
+ reject('表单校验未通过')
|
|
|
233
|
+ } else if (isHasNullRules) {
|
|
|
234
|
+ this.$message.warning('请完善"预警规则"')
|
219
|
reject('表单校验未通过')
|
235
|
reject('表单校验未通过')
|
220
|
} else {
|
236
|
} else {
|
221
|
resolve('表单校验通过')
|
237
|
resolve('表单校验通过')
|
|
|
|
|
237
|
handleClearFormData() {
|
253
|
handleClearFormData() {
|
238
|
this.form.afferent_djuser_list = []
|
254
|
this.form.afferent_djuser_list = []
|
239
|
this.form.djuser_list = []
|
255
|
this.form.djuser_list = []
|
240
|
- this.form.type = 1
|
|
|
|
|
256
|
+ this.form.notice_type = noticeTypes.USER
|
241
|
this.form.warnUserList = []
|
257
|
this.form.warnUserList = []
|
242
|
this.form.warnGroupList = []
|
258
|
this.form.warnGroupList = []
|
243
|
this.form.rules = [
|
259
|
this.form.rules = [
|
|
|
|
|
248
|
}
|
264
|
}
|
249
|
]
|
265
|
]
|
250
|
},
|
266
|
},
|
|
|
267
|
+ // 监听输入"规则 - 分钟"
|
|
|
268
|
+ onInputMinute(inputVal, idx) {
|
|
|
269
|
+ this.form.rules[idx].minute = getIntegerNumber(inputVal)
|
|
|
270
|
+ },
|
|
|
271
|
+ onChangeMinute(inputVal, idx) {
|
|
|
272
|
+ if (inputVal !== '' && Number(inputVal) === 0) {
|
|
|
273
|
+ this.form.rules[idx].minute = ''
|
|
|
274
|
+ this.$message.warning('分钟数不能为0')
|
|
|
275
|
+ }
|
|
|
276
|
+ },
|
|
|
277
|
+ // 监听输入"规则 - 人数"
|
|
|
278
|
+ onInputPersonCount(inputVal, idx) {
|
|
|
279
|
+ this.form.rules[idx].personCount = getIntegerNumber(inputVal)
|
|
|
280
|
+ },
|
|
|
281
|
+ onChangePersonCount(inputVal, idx) {
|
|
|
282
|
+ if (inputVal !== '' && Number(inputVal) === 0) {
|
|
|
283
|
+ this.form.rules[idx].personCount = ''
|
|
|
284
|
+ this.$message.warning('人数不能为0')
|
|
|
285
|
+ }
|
|
|
286
|
+ },
|
251
|
// 监听点击“添加规则”
|
287
|
// 监听点击“添加规则”
|
252
|
onClickAddRules() {
|
288
|
onClickAddRules() {
|
253
|
this.form.rules.push({
|
289
|
this.form.rules.push({
|