2019-12-06 17:36:33 +08:00
|
|
|
<style scoped>
|
|
|
|
|
.account {
|
|
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<template>
|
|
|
|
|
<div class="account">
|
2019-12-09 19:23:20 +08:00
|
|
|
<div class="content-left">
|
2019-12-10 17:00:28 +08:00
|
|
|
<div class="sidebar-title">{{$t('alert.alert')}}</div>
|
|
|
|
|
<div class="sidebar-info">
|
|
|
|
|
<div class="sidebar-info-item sidebar-info-top" @click="jumpTo('alertList')">{{$t('alert.alertList')}}</div>
|
|
|
|
|
<div class="sidebar-info-item sidebar-info-item-active">{{$t('alert.alertConfig')}}</div>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
2019-12-10 17:00:28 +08:00
|
|
|
<div class="content-right">
|
|
|
|
|
<div class="top-tools">
|
2019-12-25 17:15:09 +08:00
|
|
|
<button @click="toAdd" class="nz-btn nz-btn-size-normal nz-btn-style-normal float-right">
|
2019-12-17 17:17:30 +08:00
|
|
|
<span class="top-tool-btn-txt">{{$t('overall.add')}}</span>
|
2019-12-25 17:15:09 +08:00
|
|
|
</button>
|
2019-12-25 20:33:58 +08:00
|
|
|
<div class="top-tool-search float-right"><search-input :searchMsg="searchMsg" @search="search"></search-input></div>
|
2019-12-10 17:00:28 +08:00
|
|
|
</div>
|
2019-12-06 17:36:33 +08:00
|
|
|
<el-table
|
|
|
|
|
:data="tableData"
|
|
|
|
|
border
|
|
|
|
|
height="calc(100% - 65px)"
|
|
|
|
|
style="width: 100%;">
|
|
|
|
|
<el-table-column
|
2019-12-26 16:31:53 +08:00
|
|
|
:resizable="false"
|
2019-12-06 17:36:33 +08:00
|
|
|
v-for="(item, index) in tableTitle"
|
|
|
|
|
v-if="item.show"
|
|
|
|
|
:width="item.width"
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
show-overflow-tooltip
|
|
|
|
|
>
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
<div v-if="item.prop == 'option'" class="account-list-options">
|
2020-01-06 20:57:49 +08:00
|
|
|
<span @click="del(scope.row)" class="content-right-option"><i class="el-icon-delete"></i></span>
|
|
|
|
|
<span @click="detail(scope.row)" class="content-right-option"><i class="el-icon-view"></i></span>
|
|
|
|
|
<span @click="toEdit(scope.row)" class="content-right-option"><i class="el-icon-edit-outline"></i></span>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
2019-12-13 17:08:35 +08:00
|
|
|
<span v-else-if="item.prop == 'severity'">
|
|
|
|
|
<span v-if="scope.row[item.prop] == 'high'"><i class="el-icon-arrow-up"></i> {{severityData[1].value}}</span>
|
|
|
|
|
<span style="padding-left: 18px;" v-if="scope.row[item.prop] == 'medium'">{{severityData[0].value}}</span>
|
|
|
|
|
<span v-if="scope.row[item.prop] == 'low'"><i class="el-icon-arrow-down"></i> {{severityData[2].value}}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<span v-else-if="item.prop == 'type'">
|
|
|
|
|
<template v-for="type in typeData" v-if="type.key == scope.row[item.prop]">{{type.value}}</template>
|
|
|
|
|
</span>
|
2020-01-06 19:03:38 +08:00
|
|
|
<!-- <span v-else-if="item.prop == 'linkObject' && scope.row[item.prop]">{{scope.row.type != 3 && scope.row.linkObject ? scope.row[item.prop].name : scope.row[item.prop].host}}</span>-->
|
|
|
|
|
<div v-else-if="item.prop == 'linkObject'">
|
|
|
|
|
<span v-if="(scope.row['type'] == 1 || scope.row['type'] == 2) && scope.row[item.prop]" class="account-list-option" @click="viewAlertType(scope.row['type'],scope.row[item.prop])">{{scope.row[item.prop].name}}</span>
|
|
|
|
|
<span v-if="scope.row['type'] == 3 && scope.row[item.prop]" class="account-list-option" @click="viewAlertType(scope.row['type'],scope.row[item.prop].id)">{{scope.row[item.prop].host}}</span>
|
|
|
|
|
</div>
|
2019-12-06 17:36:33 +08:00
|
|
|
<span v-else>{{scope.row[item.prop]}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
|
|
|
|
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
|
|
|
|
</div>
|
2019-12-24 17:31:51 +08:00
|
|
|
<alert-config-box :parentAlertRule="alertRule" @reload="getTableData" ref="alertConfigBox"></alert-config-box>
|
2020-01-06 20:57:49 +08:00
|
|
|
<project-box :project="viewProjectData" ref="projectBox" @reload="getTableData"></project-box>
|
|
|
|
|
<module-box :module="viewModuleData" @reload="getTableData" ref="moduleBox"></module-box>
|
2020-01-06 19:03:38 +08:00
|
|
|
<asset-edit-unit :edit-unit-show='viewAsset' @refreshData="" @sendStateData="" ref="assetEditUnit"></asset-edit-unit>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
2019-12-13 17:08:35 +08:00
|
|
|
name: "alert-config",
|
2019-12-06 17:36:33 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
2019-12-17 17:17:30 +08:00
|
|
|
searchMsg: { //给搜索框子组件传递的信息
|
2019-12-16 17:14:58 +08:00
|
|
|
zheze_none: true,
|
2019-12-17 17:17:30 +08:00
|
|
|
searchLabelList: [{
|
2019-12-16 17:14:58 +08:00
|
|
|
id: 1,
|
|
|
|
|
name: 'ID',
|
|
|
|
|
type: 'input',
|
|
|
|
|
label: 'id',
|
|
|
|
|
disabled: false
|
2019-12-17 17:17:30 +08:00
|
|
|
},{
|
2019-12-16 17:14:58 +08:00
|
|
|
id: 2,
|
2019-12-17 17:17:30 +08:00
|
|
|
name: this.$t('alert.alertName'),
|
2019-12-16 17:14:58 +08:00
|
|
|
type: 'input',
|
2019-12-17 17:17:30 +08:00
|
|
|
label: 'alertName',
|
|
|
|
|
disabled: false
|
|
|
|
|
},{
|
|
|
|
|
id: 3,
|
|
|
|
|
name: this.$t('alert.list.type'),
|
|
|
|
|
type: 'select',
|
|
|
|
|
label: 'alertType',
|
|
|
|
|
disabled: false
|
|
|
|
|
},{
|
|
|
|
|
id: 4,
|
|
|
|
|
name: this.$t('alert.severity'),
|
|
|
|
|
type: 'selectString',
|
|
|
|
|
label: 'severity',
|
2019-12-16 17:14:58 +08:00
|
|
|
disabled: false
|
|
|
|
|
}],
|
2019-12-17 17:17:30 +08:00
|
|
|
},
|
|
|
|
|
searchLabel: { //搜索参数
|
|
|
|
|
|
2019-12-16 17:14:58 +08:00
|
|
|
},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
2019-12-06 17:36:33 +08:00
|
|
|
alertRule: {
|
|
|
|
|
id: '',
|
|
|
|
|
alertName: '',
|
|
|
|
|
type: '',
|
2019-12-13 17:08:35 +08:00
|
|
|
linkObject: {id: '', name: ''},
|
2019-12-06 17:36:33 +08:00
|
|
|
linkId: '',
|
|
|
|
|
expr: '',
|
|
|
|
|
last: '',
|
|
|
|
|
severity: '',
|
|
|
|
|
summary: '',
|
|
|
|
|
description: '',
|
|
|
|
|
receiver: '',
|
|
|
|
|
},
|
|
|
|
|
pageObj: {
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 20,
|
2019-12-09 19:23:20 +08:00
|
|
|
total:0
|
2019-12-06 17:36:33 +08:00
|
|
|
},
|
2019-12-13 17:08:35 +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: [
|
|
|
|
|
{
|
|
|
|
|
key: 1,
|
|
|
|
|
value: this.$t('alert.config.typeOption.project')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 2,
|
|
|
|
|
value: this.$t('alert.config.typeOption.module')
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
key: 3,
|
|
|
|
|
value: this.$t('alert.config.typeOption.asset')
|
|
|
|
|
}
|
|
|
|
|
],
|
2019-12-06 17:36:33 +08:00
|
|
|
tableTitle: [
|
|
|
|
|
{
|
|
|
|
|
label: 'ID',
|
|
|
|
|
prop: 'id',
|
|
|
|
|
show: true,
|
|
|
|
|
width: 80
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t("alert.alertName"),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'alertName',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t("alert.config.expr"),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'expr',
|
|
|
|
|
show: true,
|
2019-12-13 17:08:35 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t("alert.list.type"),
|
|
|
|
|
prop: 'type',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
|
|
|
|
label: this.$t("alert.config.link"),
|
|
|
|
|
prop: 'linkObject',
|
|
|
|
|
show: true,
|
2019-12-06 17:36:33 +08:00
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t("alert.config.for"),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'last',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t('alert.severity'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'severity',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t('alert.description'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'description',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t('alert.config.receiver'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'receiver',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t('alert.config.option'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'option',
|
|
|
|
|
show: true,
|
|
|
|
|
}
|
|
|
|
|
],
|
2020-01-06 19:03:38 +08:00
|
|
|
tableData: [],
|
2020-01-06 20:57:49 +08:00
|
|
|
viewProjectData: {},
|
|
|
|
|
viewModuleData: {},
|
|
|
|
|
viewAsset: false,
|
2019-12-06 17:36:33 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2019-12-13 17:08:35 +08:00
|
|
|
toEdit: function(u) {
|
2019-12-06 17:36:33 +08:00
|
|
|
this.alertRule = Object.assign({}, u);
|
2019-12-24 17:31:51 +08:00
|
|
|
this.$refs.alertConfigBox.show(true, true);
|
2019-12-06 17:36:33 +08:00
|
|
|
},
|
|
|
|
|
del: function(u) {
|
2019-12-13 17:08:35 +08:00
|
|
|
this.$confirm(this.$t("tip.confirmDelete"), {
|
|
|
|
|
confirmButtonText: this.$t("tip.yes"),
|
|
|
|
|
cancelButtonText: this.$t("tip.no"),
|
|
|
|
|
type: 'warning'
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.$delete("alert/rule?ids=" + u.id).then(response => {
|
|
|
|
|
if (response.code === 200) {
|
|
|
|
|
this.$message({type: 'success', message: this.$t("tip.deleteSuccess")});
|
|
|
|
|
this.getTableData();
|
|
|
|
|
} else {
|
|
|
|
|
this.$message.error(response.msg);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
});
|
2019-12-06 17:36:33 +08:00
|
|
|
},
|
2019-12-10 17:00:28 +08:00
|
|
|
toAdd: function() {
|
|
|
|
|
this.cleanAlertRule();
|
2019-12-24 17:31:51 +08:00
|
|
|
this.$refs.alertConfigBox.show(true, true);
|
2019-12-10 17:00:28 +08:00
|
|
|
},
|
2019-12-06 17:36:33 +08:00
|
|
|
detail: function(u) {
|
|
|
|
|
this.alertRule = Object.assign({}, u);
|
2019-12-24 17:31:51 +08:00
|
|
|
this.$refs.alertConfigBox.show(true, false);
|
2019-12-06 17:36:33 +08:00
|
|
|
},
|
2019-12-24 17:31:51 +08:00
|
|
|
|
2019-12-06 17:36:33 +08:00
|
|
|
getTableData: function() {
|
2019-12-17 17:17:30 +08:00
|
|
|
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
|
|
|
|
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
|
|
|
|
this.$get('alert/rule', this.searchLabel).then(response => {
|
2019-12-06 17:36:33 +08:00
|
|
|
if (response.code == 200) {
|
2019-12-10 17:00:28 +08:00
|
|
|
this.tableData = response.data.list;
|
|
|
|
|
this.pageObj.total = response.data.total;
|
2019-12-06 17:36:33 +08:00
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
updateReceiverName: function(item) {
|
|
|
|
|
//TODO 请求接口改名
|
|
|
|
|
var code = 200;
|
|
|
|
|
//this.$set(item, 'errorMessage', 'err');
|
|
|
|
|
item.errorMessage = '';
|
|
|
|
|
item.oldName = item.name;
|
|
|
|
|
return code;
|
|
|
|
|
},
|
|
|
|
|
cleanAlertRule: function() {
|
|
|
|
|
this.alertRule = {
|
|
|
|
|
id: '',
|
|
|
|
|
alertName: '',
|
|
|
|
|
type: '',
|
|
|
|
|
linkId: '',
|
2019-12-13 17:08:35 +08:00
|
|
|
linkObject: {id: '', name: ''},
|
2019-12-06 17:36:33 +08:00
|
|
|
expr: '',
|
|
|
|
|
last: '',
|
|
|
|
|
severity: '',
|
|
|
|
|
summary: '',
|
|
|
|
|
description: '',
|
|
|
|
|
receiver: '',
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-12-10 17:00:28 +08:00
|
|
|
jumpTo(data,id) {
|
|
|
|
|
this.$router.push({
|
|
|
|
|
path: "/" + data,
|
|
|
|
|
query: {
|
|
|
|
|
t: +new Date()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2019-12-06 17:36:33 +08:00
|
|
|
pageNo(val) {
|
|
|
|
|
this.pageObj.pageNo = val;
|
2019-12-13 17:08:35 +08:00
|
|
|
this.getTableData();
|
2019-12-06 17:36:33 +08:00
|
|
|
},
|
|
|
|
|
pageSize(val) {
|
|
|
|
|
this.pageObj.pageSize = val;
|
2019-12-13 17:08:35 +08:00
|
|
|
this.getTableData();
|
2019-12-17 17:17:30 +08:00
|
|
|
},
|
|
|
|
|
search: function(searchObj) {
|
|
|
|
|
this.searchLabel = {};
|
|
|
|
|
for (let item in searchObj) {
|
|
|
|
|
if (searchObj[item]) {
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.getTableData();
|
2020-01-06 19:03:38 +08:00
|
|
|
},
|
2020-01-06 20:57:49 +08:00
|
|
|
viewAlertType: function(type, typeObj){
|
2020-01-06 19:03:38 +08:00
|
|
|
this.closeViews();
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 1:
|
2020-01-06 20:57:49 +08:00
|
|
|
this.viewProjectData = JSON.parse(JSON.stringify(typeObj));
|
2020-01-06 19:03:38 +08:00
|
|
|
this.$refs.projectBox.show(true);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
2020-01-07 17:41:46 +08:00
|
|
|
// this.fillProject(typeObj);
|
2020-01-06 20:57:49 +08:00
|
|
|
let tempObj = JSON.parse(typeObj.param)
|
2020-01-06 19:03:38 +08:00
|
|
|
this.$set(typeObj, 'paramObj', []);
|
|
|
|
|
for (let k in tempObj) {
|
|
|
|
|
typeObj.paramObj.push({key: k, value: tempObj[k]});
|
|
|
|
|
}
|
2020-01-06 20:57:49 +08:00
|
|
|
this.viewModuleData = JSON.parse(JSON.stringify(typeObj));
|
2020-01-06 19:03:38 +08:00
|
|
|
|
|
|
|
|
this.$refs.moduleBox.show(true);
|
|
|
|
|
break;
|
|
|
|
|
case 3:
|
2020-01-06 20:57:49 +08:00
|
|
|
this.viewAsset = true;
|
2020-01-06 19:03:38 +08:00
|
|
|
this.$refs.assetEditUnit.getAssetData(typeObj);
|
2020-01-06 20:57:49 +08:00
|
|
|
this.$refs.assetEditUnit.tabView = true;
|
2020-01-06 19:03:38 +08:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
fillProject:function(module){
|
|
|
|
|
this.$get('project', {"id":module.projectId}).then(response => {
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
module.project = response.data.list[0];
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
closeViews:function(){
|
|
|
|
|
this.$refs.alertConfigBox.show(false,false);
|
|
|
|
|
this.$refs.projectBox.show(false,false);
|
|
|
|
|
this.$refs.moduleBox.show(false,false);
|
|
|
|
|
this.viewAsset=false;
|
2019-12-06 17:36:33 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.getTableData();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|