2019-12-24 17:31:51 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<transition name="right-box">
|
2020-02-25 18:59:23 +08:00
|
|
|
|
<div class="right-box right-box-alert-config" v-if="rightBox.show" v-clickoutside="clickos">
|
2019-12-24 17:31:51 +08:00
|
|
|
|
<!-- begin--顶部按钮-->
|
|
|
|
|
|
<div class="right-box-top-btns">
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<button type="button" v-if="alertRule.id != '' && rightBox.isEdit" id="alert-box-del" @click="del" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82">
|
|
|
|
|
|
<span class="right-box-top-btn-icon"><i class="el-icon-delete"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.delete')}}</span>
|
2020-01-02 18:10:24 +08:00
|
|
|
|
</button>
|
2020-03-17 20:21:48 +08:00
|
|
|
|
<button v-if="!rightBox.isEdit && alertRule.buildIn != 1" type="button" @click="saveOrToEdit" class="nz-btn nz-btn-size-normal nz-btn-size-alien nz-btn-style-light nz-btn-min-width-82" id="alert-box-edit">
|
2020-01-17 09:54:01 +08:00
|
|
|
|
<span class="right-box-top-btn-icon"><i class="nz-icon nz-icon-edit"></i></span>
|
|
|
|
|
|
<span class="right-box-top-btn-txt">{{$t('overall.edit')}}</span>
|
2020-01-02 18:10:24 +08:00
|
|
|
|
</button>
|
2019-12-24 17:31:51 +08:00
|
|
|
|
</div>
|
2020-01-02 18:10:24 +08:00
|
|
|
|
|
2019-12-24 17:31:51 +08:00
|
|
|
|
<!-- end--顶部按钮-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--标题-->
|
|
|
|
|
|
<div class="right-box-title">{{rightBox.title}}</div>
|
|
|
|
|
|
<!-- end--标题-->
|
|
|
|
|
|
|
|
|
|
|
|
<!-- begin--表单-->
|
2020-01-02 18:10:24 +08:00
|
|
|
|
<el-scrollbar class="right-box-form-box">
|
2020-06-04 15:09:19 +08:00
|
|
|
|
<el-form class="right-box-form right-box-form-left" :model="alertRule" label-position="right" label-width="120px" :rules="rules" ref="alertRuleForm">
|
2020-05-06 18:07:33 +08:00
|
|
|
|
<!--alertName-->
|
|
|
|
|
|
<el-form-item :label='$t("alert.config.name")' prop="alertName">
|
|
|
|
|
|
<el-input v-if="rightBox.isEdit" placeholder="" maxlength="64" show-word-limit v-model="alertRule.alertName" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.alertName}}</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--expr-->
|
|
|
|
|
|
<el-form-item :label="$t('alert.config.expr')" prop="expr">
|
|
|
|
|
|
<el-input maxlength="512" rows="4" show-word-limit v-if="rightBox.isEdit" type="textarea" placeholder="" v-model="alertRule.expr" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.expr}}</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--last-->
|
|
|
|
|
|
<el-form-item :label="$t('alert.config.for')" prop="last">
|
|
|
|
|
|
<el-input v-if="rightBox.isEdit" type="text" placeholder="" v-model.number="alertRule.last" size="small">
|
|
|
|
|
|
<template slot="append">second</template>
|
|
|
|
|
|
</el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.last}}s</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--severity-->
|
|
|
|
|
|
<el-form-item :label="$t('alert.severity')" prop="severity">
|
|
|
|
|
|
<el-select v-if="rightBox.isEdit" popper-class="config-dropdown" v-model="alertRule.severity" placeholder="" size="small">
|
|
|
|
|
|
<el-option :id="'alert-severity-'+item.key" v-for="item in severityData" :key="item.key" :label="item.value" :value="item.key">
|
|
|
|
|
|
<template v-if="!item.isEdit">{{item.value}}</template>
|
|
|
|
|
|
<span class="config-dropdown-label-input" v-if="item.isEdit" @click.stop>
|
|
|
|
|
|
<el-input type="text" v-model="item.name" size="mini"></el-input>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.severity}}</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--receiver-->
|
|
|
|
|
|
<el-form-item :label="$t('config.account.receiver')" prop="receiver">
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
v-model.trim="alertRule.receiverShow"
|
|
|
|
|
|
placeholder=""
|
|
|
|
|
|
multiple
|
|
|
|
|
|
filterable
|
|
|
|
|
|
size="small"
|
|
|
|
|
|
value-key="userId"
|
|
|
|
|
|
popper-class="no-style-class"
|
|
|
|
|
|
>
|
|
|
|
|
|
<el-option
|
|
|
|
|
|
v-for="item in userData"
|
|
|
|
|
|
:key="item.userId"
|
|
|
|
|
|
:label="item.username"
|
|
|
|
|
|
:value="item.userId">
|
|
|
|
|
|
</el-option>
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--summary-->
|
|
|
|
|
|
<el-form-item :label="$t('alert.summary')" prop="summary">
|
|
|
|
|
|
<el-input maxlength="512" rows="3" type="textarea" show-word-limit v-if="rightBox.isEdit" placeholder="" v-model="alertRule.summary" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.summary}}</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!--description-->
|
|
|
|
|
|
<el-form-item :label="$t('alert.description')" prop="description">
|
|
|
|
|
|
<el-input maxlength="512" rows="4" show-word-limit v-if="rightBox.isEdit" type="textarea" placeholder="" v-model="alertRule.description" size="small"></el-input>
|
|
|
|
|
|
<div v-if="!rightBox.isEdit" class="right-box-form-content-txt">{{alertRule.description}}</div>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
2020-01-02 18:10:24 +08:00
|
|
|
|
</el-scrollbar>
|
2019-12-24 17:31:51 +08:00
|
|
|
|
<!-- end--表单-->
|
2020-01-16 18:11:15 +08:00
|
|
|
|
|
|
|
|
|
|
<!--底部按钮-->
|
|
|
|
|
|
<div class="right-box-bottom-btns">
|
2020-02-17 17:29:15 +08:00
|
|
|
|
<button @click="esc" id="alert-box-esc" class="nz-btn nz-btn-size-normal nz-btn-style-light nz-btn-min-width-100">
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<span>{{$t('overall.cancel')}}</span>
|
|
|
|
|
|
</button>
|
2020-02-17 17:29:15 +08:00
|
|
|
|
<button v-if="rightBox.isEdit" @click="saveOrToEdit" id="alert-box-save" class="nz-btn nz-btn-size-normal nz-btn-style-normal nz-btn-min-width-100">
|
2020-01-16 18:11:15 +08:00
|
|
|
|
<span>{{$t('overall.save')}}</span>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</div>
|
2019-12-24 17:31:51 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</transition>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "alertConfigBox",
|
|
|
|
|
|
props: {
|
|
|
|
|
|
parentAlertRule: Object
|
|
|
|
|
|
},
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-05-06 18:07:33 +08:00
|
|
|
|
alertRule: {id: '', receiverShow: [], receiver: ''},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
rightBox: {show: false, isEdit: false, title: ''},
|
2020-01-02 18:10:24 +08:00
|
|
|
|
rules:{
|
|
|
|
|
|
alertName:[
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger:'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
expr:[
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger:'blur'}
|
|
|
|
|
|
],
|
|
|
|
|
|
last:[
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger:'blur'},
|
|
|
|
|
|
{type:'number',message:this.$t('validate.number')}
|
|
|
|
|
|
],
|
|
|
|
|
|
severity:[
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger:'change'},
|
|
|
|
|
|
],
|
|
|
|
|
|
summary:[
|
|
|
|
|
|
{required:true,message:this.$t('validate.required'),trigger:'blur'},
|
|
|
|
|
|
],
|
|
|
|
|
|
// description:[
|
|
|
|
|
|
// {required:true,message:this.$t('validate.required'),trigger:'blur'},
|
|
|
|
|
|
// ],
|
|
|
|
|
|
// receiver:[
|
|
|
|
|
|
// {required:true,message:this.$t('validate.required'),trigger:'change'},
|
|
|
|
|
|
// ]
|
|
|
|
|
|
},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
severityData: [
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'medium',
|
|
|
|
|
|
value: this.$t("alert.config.medium")
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'high',
|
|
|
|
|
|
value: this.$t("alert.config.high")
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
key: 'low',
|
|
|
|
|
|
value: this.$t("alert.config.low")
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
typeData: [
|
|
|
|
|
|
{
|
2019-12-25 17:15:09 +08:00
|
|
|
|
key: 1, //project
|
2019-12-24 17:31:51 +08:00
|
|
|
|
value: this.$t('alert.config.typeOption.project')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2019-12-25 17:15:09 +08:00
|
|
|
|
key: 2, //module
|
2019-12-24 17:31:51 +08:00
|
|
|
|
value: this.$t('alert.config.typeOption.module')
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2019-12-25 17:15:09 +08:00
|
|
|
|
key: 3, //asset
|
2019-12-24 17:31:51 +08:00
|
|
|
|
value: this.$t('alert.config.typeOption.asset')
|
|
|
|
|
|
}
|
|
|
|
|
|
],
|
2020-05-06 18:07:33 +08:00
|
|
|
|
userData: [],
|
2019-12-24 17:31:51 +08:00
|
|
|
|
linkObjList: []
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2020-02-25 18:59:23 +08:00
|
|
|
|
clickos() {
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
show(show, isEdit) {
|
|
|
|
|
|
this.rightBox.show = show;
|
|
|
|
|
|
this.rightBox.isEdit = isEdit;
|
|
|
|
|
|
},
|
|
|
|
|
|
save: function() {
|
2020-01-02 18:10:24 +08:00
|
|
|
|
this.$refs.alertRuleForm.validate((valid) => {
|
|
|
|
|
|
if (valid) {
|
2020-05-06 18:07:33 +08:00
|
|
|
|
this.alertRule.receiver = this.alertRule.receiverShow.join(",");
|
2020-01-02 18:10:24 +08:00
|
|
|
|
if (this.alertRule.id) {
|
|
|
|
|
|
this.$put('alert/rule', this.alertRule).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.$emit('reload');
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-24 17:31:51 +08:00
|
|
|
|
} else {
|
2020-01-02 18:10:24 +08:00
|
|
|
|
this.$post('alert/rule', this.alertRule).then(response => {
|
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({duration: 1000, type: 'success', message: this.$t("tip.saveSuccess")});
|
|
|
|
|
|
this.$emit('reload');
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2019-12-24 17:31:51 +08:00
|
|
|
|
}
|
2020-01-02 18:10:24 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2019-12-24 17:31:51 +08:00
|
|
|
|
},
|
2019-12-26 17:03:07 +08:00
|
|
|
|
del: function() {
|
2019-12-24 17:31:51 +08:00
|
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
|
type: 'warning'
|
|
|
|
|
|
}).then(() => {
|
2019-12-26 17:03:07 +08:00
|
|
|
|
this.$delete("alert/rule?ids=" + this.alertRule.id).then(response => {
|
2019-12-24 17:31:51 +08:00
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
|
this.$message({type: 'success', message: this.$t("tip.deleteSuccess")});
|
|
|
|
|
|
this.$emit('reload');
|
2019-12-26 17:03:07 +08:00
|
|
|
|
this.rightBox.show = false;
|
2019-12-24 17:31:51 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
saveOrToEdit: function() {
|
|
|
|
|
|
if (!this.rightBox.isEdit) {
|
|
|
|
|
|
this.rightBox.isEdit = true;
|
|
|
|
|
|
this.rightBox.title = this.$t("alert.config.editAlertConfig") + " ID:" + this.alertRule.id;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.save();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
esc: function() {
|
|
|
|
|
|
this.rightBox.show = false;
|
|
|
|
|
|
},
|
|
|
|
|
|
|
2019-12-25 17:15:09 +08:00
|
|
|
|
getProjectList() {
|
2020-04-15 19:40:09 +08:00
|
|
|
|
this.$get('project', {pageNo: 1, pageSize: -1}).then(response => {
|
2019-12-25 17:15:09 +08:00
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.linkObjList = response.data.list;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2020-05-06 18:07:33 +08:00
|
|
|
|
getUserList() {
|
|
|
|
|
|
this.$get('sys/user/list', {pageNo: 1, pageSize: -1}).then(response => {
|
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.userData = response.data.list;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2019-12-25 17:15:09 +08:00
|
|
|
|
getModuleList() {
|
2020-04-15 19:40:09 +08:00
|
|
|
|
this.$get('module', {pageNo: 1, pageSize: -1}).then(response => {
|
2019-12-25 17:15:09 +08:00
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.linkObjList = response.data.list;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
|
2019-12-25 17:15:09 +08:00
|
|
|
|
getAssetList() {
|
2020-04-15 19:40:09 +08:00
|
|
|
|
this.$get('asset', {pageNo: 1, pageSize: -1}).then(response => {
|
2019-12-25 17:15:09 +08:00
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
this.linkObjList = response.data.list;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
},
|
|
|
|
|
|
created() {
|
2020-05-06 18:07:33 +08:00
|
|
|
|
this.getUserList();
|
2019-12-24 17:31:51 +08:00
|
|
|
|
this.rightBox.title = this.$t("alert.config.createAlertConfig");
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
parentAlertRule: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n, o) {
|
|
|
|
|
|
this.alertRule = n;
|
2019-12-25 17:15:09 +08:00
|
|
|
|
if (this.alertRule.id) {
|
|
|
|
|
|
if (this.alertRule.type == 1) {
|
|
|
|
|
|
this.getProjectList();
|
|
|
|
|
|
} else if (this.alertRule.type == 2) {
|
|
|
|
|
|
this.getModuleList();
|
|
|
|
|
|
} else if (this.alertRule.type == 3) {
|
|
|
|
|
|
this.getAssetList();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2019-12-24 17:31:51 +08:00
|
|
|
|
if (this.rightBox.show) {
|
|
|
|
|
|
if (this.rightBox.isEdit && this.alertRule.id) {
|
|
|
|
|
|
this.rightBox.title = this.$t("alert.config.editAlertConfig") + " ID:" + this.alertRule.id;
|
|
|
|
|
|
} else if (this.rightBox.isEdit && !this.alertRule.id) {
|
|
|
|
|
|
this.rightBox.title = this.$t("alert.config.createAlertConfig");
|
|
|
|
|
|
} else if (!this.rightBox.isEdit && this.alertRule.id) {
|
|
|
|
|
|
this.rightBox.title = this.$t("alert.config.alertConfig") + " ID:" + this.alertRule.id;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
|
|
|
|
</style>
|