fix:处理 下拉框无法收回的问题 以及 alertRule 校验规则的添加

This commit is contained in:
zhangyu
2021-05-08 11:25:05 +08:00
parent c89e5315e1
commit 3e12acaddb
7 changed files with 53 additions and 17 deletions

View File

@@ -21,6 +21,7 @@
</span>
</el-popover>
<el-dropdown trigger="click" class="nz-chart-top" :key="'chartDropdown'+chartIndex" v-clickoutside="clickos" :class="{'move-able':!isLock}">
<el-dropdown-menu style="display: none"></el-dropdown-menu>
<span class="el-dropdown-link chart-title">
<span class="chart-title-text">{{chartData.name}}</span>
<span class="chart-title-icon" v-if="from !== 'chartTemp'" :class="{'visible':caretShow,'hidden':!caretShow}">

View File

@@ -679,7 +679,7 @@ const cn = {
type: 'Agent类型'
}
},
agent:{
agent: {
name: '名称',
type: '类型',
createProm: '创建代理服务',
@@ -963,7 +963,7 @@ const cn = {
}
},
assetType: {
name:'名称',
name: '名称',
assetType: '资产类型',
parent: '父级',
pname: '父级',
@@ -1060,6 +1060,7 @@ const cn = {
severity: '等级',
description: '描述',
summary: '概要',
notify: '通知', // "通知方式"
startAt: '开始时间',
endAt: '结束时间',
list: {
@@ -1107,7 +1108,7 @@ const cn = {
}
},
silence: {
name:'名称',
name: '名称',
silence: '告警静默',
create: '创建告警静默',
edit: '修改告警静默',
@@ -1121,7 +1122,10 @@ const cn = {
module: '模块',
endpoint: 'endpoint',
asset: '资产',
timeError: '结束时间必须大于开始时间'
timeError: '结束时间必须大于开始时间',
state: '状态',
startTime: '开始时间',
upTime: '更新时间'
},
P1Rule: 'P1: 万分紧急,可导致业务瘫痪的告警',
P2Rule: 'P2: 重要,需要紧急关注的警报,但还没有影响业务',

View File

@@ -1079,6 +1079,7 @@ const en = {
description: 'Description', // "描述"
summary: 'Summary', // "概要"
startAt: 'Start time', // "开始时间"
notify: 'Notification', // "通知方式"
endAt: 'End time', // "结束时间"
list: {
// 表头
@@ -1127,7 +1128,7 @@ const en = {
},
},
silence: {
name:'Name',
name: 'Name',
silence: 'Alert silence',
create: 'New alert silence',
edit: 'Edit alert silence',
@@ -1141,7 +1142,10 @@ const en = {
module: 'module',
endpoint: 'endpoint',
asset: 'asset',
timeError: 'The end time must be greater than the start time'
timeError: 'The end time must be greater than the start time',
state: 'State',
startTime: 'Start time',
upTime: 'Update Time'
},
P1Rule: 'P1: Critical, alert that can cause business paralysis',
P2Rule: 'P2: Major, alert that requires urgent attention, but does not affect the business yet',

View File

@@ -78,17 +78,18 @@
popper-class="no-style-class"
size="small"
value-key="userId"
@change="receiverShowChange"
>
<el-option
v-for="item in userData"
:key="item.userId"
:key="item.id"
:label="item.username"
:value="item.userId">
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<!--notify-->
<el-form-item :label="$t('alert.notify')" prop="severity" class="notify-box">
<el-form-item :label="$t('alert.notify')" prop="method" class="notify-box" :rules="[{ validator: validateNotify, trigger: 'change'},]">
<el-select id="alert-box-input-notify" v-model="editAlertRule.method" placeholder="" popper-class="config-dropdown notify-box" size="small" multiple>
<el-option v-for="item in notifyData" :id="'alert-severity-'+item.value" :key="item.id" :label="item.name" :value="item.id">
</el-option>
@@ -267,7 +268,7 @@ export default {
})
},
getUserList () {
this.$get('sys/user/list', { pageNo: 1, pageSize: -1 }).then(response => {
this.$get('sys/user', { pageNo: 1, pageSize: -1 }).then(response => {
if (response.code == 200) {
this.userData = response.data.list
}
@@ -289,6 +290,20 @@ export default {
this.notifyData = response.data.list
}
})
},
receiverShowChange (val) {
console.log(val)
if (!val.length) {
this.$refs.alertRuleForm.validateField('method')
}
},
validateNotify (rule, value, callback) {
console.log(value)
if (this.editAlertRule.receiverShow.length && value.length === 0) {
callback(new Error(this.$t('validate.required')))
} else {
callback()
}
}
},
mounted () {

View File

@@ -38,7 +38,10 @@
<i class="nz-icon nz-icon-circle" :style="{color:scope.row[item.prop].color,'font-size':'12px','margin-right':'5px'}"></i> {{scope.row[item.prop].name}}
</span>
<template v-else-if="item.prop === 'alertNum'">
<span class="link" @click="queryMessage(scope.row)">{{scope.row.alertNum + ' ' + $t('overall.active')}}</span>
<span class="link" @click="queryMessage(scope.row)">
<i class="nz-icon nz-icon-overview-alert" :class="scope.row[item.prop]>0?'colorEF7458':'color23BF9A'"/>
{{scope.row.alertNum}}
</span>
</template>
<template v-else-if="item.prop === 'threshold'">{{formatThreshold(scope.row[item.prop], scope.row.unit)}}</template>
<template v-else-if="item.prop === 'receivers'">
@@ -147,6 +150,14 @@ export default {
}
}
</script>
<style scoped>
.colorEF7458{
color: #EF7458;
}
.color23BF9A{
color: #23BF9A;
}
</style>
<style>
.severity .P1{
background: #F5846A;

View File

@@ -122,12 +122,12 @@ export default {
width: 80,
sortable: 'custom'
}, {
label: 'matchers',
label: 'Matchers',
prop: 'matchers',
show: true,
sortable: 'custom'
}, {
label: 'Start time',
label: this.$t('alert.silence.startTime'),
prop: 'startAt',
show: true,
width: 300,
@@ -143,12 +143,12 @@ export default {
show: true,
width: 120
}, {
label: 'Update time',
label: this.$t('alert.silence.upTime'),
prop: 'utime',
show: true,
width: 120
}, {
label: 'State',
label: this.$t('alert.silence.state'),
prop: 'state',
show: true,
width: 120

View File

@@ -23,6 +23,7 @@
</div>
</el-dropdown>
<el-dropdown>
<el-dropdown-menu></el-dropdown-menu>
<div class="header-menu__item" @click="centerDialogVisible = true"><i class="nz-icon nz-icon-guide"></i></div>
<!-- <el-dialog
title="Get started in 6 steps"