2019-12-06 17:36:33 +08:00
|
|
|
<style scoped>
|
2020-01-08 10:17:31 +08:00
|
|
|
.list {
|
2019-12-06 17:36:33 +08:00
|
|
|
height: 100%;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
<template>
|
2020-01-08 10:17:31 +08:00
|
|
|
<div class="list">
|
2019-12-10 17:00:28 +08:00
|
|
|
<div class="content-left">
|
|
|
|
|
<div class="sidebar-title">{{$t('alert.alert')}}</div>
|
|
|
|
|
<div class="sidebar-info">
|
|
|
|
|
<div class="sidebar-info-item sidebar-info-top sidebar-info-item-active">{{$t('alert.alertList')}}</div>
|
|
|
|
|
<div class="sidebar-info-item" @click="jumpTo('alertConfig')">{{$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 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"
|
2020-01-08 22:19:46 +08:00
|
|
|
v-for="(item, index) in tablelable"
|
2019-12-06 17:36:33 +08:00
|
|
|
v-if="item.show"
|
|
|
|
|
:width="item.width"
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
:label="item.label"
|
|
|
|
|
>
|
2020-01-08 22:19:46 +08:00
|
|
|
<template slot="header" slot-scope="scope">
|
|
|
|
|
<span v-if="index==0">
|
|
|
|
|
<span @click.stop="elementsetShow('shezhi',$event)">
|
|
|
|
|
<i class="el-icon-setting"></i>
|
|
|
|
|
</span>
|
|
|
|
|
<span>{{item.label}}</span>
|
|
|
|
|
</span>
|
|
|
|
|
<div v-else>
|
|
|
|
|
<span>{{item.label}}</span>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
2019-12-06 17:36:33 +08:00
|
|
|
<template slot-scope="scope" :column="item">
|
2020-01-09 14:57:44 +08:00
|
|
|
<span v-if="item.prop == 'alertRule'">
|
|
|
|
|
<span class="link" @click="viewRule(scope.row[item.prop].id)" v-if="scope.row[item.prop].alertName">{{scope.row[item.prop].alertName}}</span>
|
|
|
|
|
<span v-else>-</span>
|
2020-01-06 19:03:38 +08:00
|
|
|
</span>
|
2020-01-08 10:17:31 +08:00
|
|
|
<div v-else-if="item.prop == 'type'" class="content-right-options">
|
2020-01-06 19:03:38 +08:00
|
|
|
<span v-if="scope.row[item.prop] == 1" >Project</span>
|
|
|
|
|
<span v-if="scope.row[item.prop] == 2" >Module</span>
|
|
|
|
|
<span v-if="scope.row[item.prop] == 3" >Device</span>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
2019-12-17 17:17:30 +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>
|
2019-12-06 17:36:33 +08:00
|
|
|
<div v-else-if="item.prop == 'linkObject'">
|
2020-01-09 14:57:44 +08:00
|
|
|
<span v-if="(scope.row['type'] == 1 || scope.row['type'] == 2) && scope.row[item.prop]" class="link" @click="viewAlertType(scope.row['type'],scope.row[item.prop])">{{scope.row[item.prop].name}}</span>
|
|
|
|
|
<span v-else-if="scope.row['type'] == 3 && scope.row[item.prop]" class="link" @click="viewAlertType(scope.row['type'],scope.row[item.prop].id)">{{scope.row[item.prop].host}}</span>
|
|
|
|
|
<span v-else>-</span>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
|
|
|
|
<div v-else-if="item.prop == 'state'">
|
2020-01-08 10:17:31 +08:00
|
|
|
<span class="">
|
2019-12-06 17:36:33 +08:00
|
|
|
{{scope.row['state'] == 1 ? "Pending" : ""}}
|
|
|
|
|
{{scope.row['state'] == 2 ? "Expired" : ""}}
|
|
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
<span v-else>{{scope.row[item.prop]}}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-table-column>
|
|
|
|
|
</el-table>
|
2019-12-10 17:00:28 +08:00
|
|
|
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
2020-01-06 20:57:49 +08:00
|
|
|
<alert-config-box :parentAlertRule="viewRuleData" @reload="getAlertList" ref="alertConfigBox"></alert-config-box>
|
|
|
|
|
<project-box :project="viewProjectData" ref="projectBox" @reload="getAlertList"></project-box>
|
|
|
|
|
<module-box :module="viewModuleData" @reload="getAlertList" ref="moduleBox"></module-box>
|
2020-01-08 10:17:31 +08:00
|
|
|
<asset-edit-unit :edit-unit-show='viewAssetState' @refreshData="getAlertList" @sendStateData="tabControl" ref="assetEditUnit"></asset-edit-unit>
|
2020-01-08 22:19:46 +08:00
|
|
|
<element-set
|
|
|
|
|
v-clickoutside="elementsetHide"
|
|
|
|
|
:dropCol="dropCol"
|
|
|
|
|
@tablelable="tablelabelEmit"
|
|
|
|
|
ref="elementset"
|
|
|
|
|
></element-set>
|
2019-12-06 17:36:33 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
2019-12-10 17:00:28 +08:00
|
|
|
name: "alertList",
|
2019-12-06 17:36:33 +08:00
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
pageObj: {
|
|
|
|
|
pageNo: 1,
|
|
|
|
|
pageSize: 20,
|
|
|
|
|
total:13
|
|
|
|
|
},
|
|
|
|
|
tableTitle: [
|
|
|
|
|
{
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t("alert.alertName"),
|
2020-01-06 19:03:38 +08:00
|
|
|
prop: 'alertRule',
|
2019-12-06 17:36:33 +08:00
|
|
|
show: true
|
|
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t("alert.list.type"),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'type',
|
|
|
|
|
show: true,
|
|
|
|
|
}, {
|
2020-01-09 14:57:44 +08:00
|
|
|
label: this.$t("alert.list.linked"),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'linkObject',
|
|
|
|
|
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.summary'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'summary',
|
|
|
|
|
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.list.state'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'state',
|
|
|
|
|
show: true,
|
2019-12-27 17:53:17 +08:00
|
|
|
}, {
|
|
|
|
|
label: this.$t("alert.startAt"),
|
|
|
|
|
prop: 'startAt',
|
|
|
|
|
show: true,
|
2019-12-06 17:36:33 +08:00
|
|
|
}, {
|
2019-12-10 17:00:28 +08:00
|
|
|
label: this.$t('alert.endAt'),
|
2019-12-06 17:36:33 +08:00
|
|
|
prop: 'endAt',
|
|
|
|
|
show: true,
|
|
|
|
|
}
|
|
|
|
|
],
|
2019-12-17 17:17:30 +08:00
|
|
|
searchMsg: { //给搜索框子组件传递的信息
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
id: 2,
|
|
|
|
|
name: this.$t('alert.alertName'),
|
|
|
|
|
type: 'input',
|
|
|
|
|
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',
|
|
|
|
|
disabled: false
|
2020-01-10 20:09:33 +08:00
|
|
|
}, {
|
|
|
|
|
id: 11,
|
|
|
|
|
name: this.$t('asset.asset'),
|
|
|
|
|
type: 'asset',
|
|
|
|
|
label: 'asset',
|
|
|
|
|
disabled: true
|
2019-12-17 17:17:30 +08:00
|
|
|
}],
|
|
|
|
|
},
|
|
|
|
|
searchLabel: { //搜索参数
|
|
|
|
|
|
|
|
|
|
},
|
2020-01-08 22:19:46 +08:00
|
|
|
tablelable: [],
|
|
|
|
|
dropCol: [],
|
2019-12-17 17:17:30 +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")
|
|
|
|
|
}
|
|
|
|
|
],
|
2020-01-06 19:03:38 +08:00
|
|
|
tableData: [],
|
2020-01-06 20:57:49 +08:00
|
|
|
viewRuleData: {
|
|
|
|
|
id: '',
|
|
|
|
|
alertName: '',
|
|
|
|
|
type: '',
|
|
|
|
|
linkObject: {id: '', name: ''},
|
|
|
|
|
linkId: '',
|
|
|
|
|
expr: '',
|
|
|
|
|
last: '',
|
|
|
|
|
severity: '',
|
|
|
|
|
summary: '',
|
|
|
|
|
description: '',
|
|
|
|
|
receiver: '',
|
|
|
|
|
},
|
|
|
|
|
viewProjectData: {id: '', name: '', remark: ''},
|
|
|
|
|
viewModuleData: {id: '', name: '', project: {}, port: '', path: '', param: '', paramObj: []},
|
2020-01-06 19:03:38 +08:00
|
|
|
viewAssetState:false,
|
2019-12-06 17:36:33 +08:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
2020-01-08 22:19:46 +08:00
|
|
|
elementsetShow(s, e) {
|
|
|
|
|
var eventfixed = {
|
|
|
|
|
shezhi: 0,
|
|
|
|
|
screen: 0
|
|
|
|
|
};
|
|
|
|
|
eventfixed[s] = 1;
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
this.$store.commit('setHeaderTable', this.tablelable);
|
|
|
|
|
this.$store.commit('setEventfixed', eventfixed);
|
|
|
|
|
const h = document.documentElement.clientHeight;
|
|
|
|
|
const w = document.documentElement.clientWidth;
|
|
|
|
|
const dw = this.$refs.elementset.$el.offsetWidth;
|
|
|
|
|
const dh = this.$refs.elementset.$el.offsetHeight;
|
|
|
|
|
let positionx =
|
|
|
|
|
e.clientX + dw <= w - 10 ? e.clientX - 250 : e.clientX - 250 - dw;
|
|
|
|
|
let positiony =
|
|
|
|
|
e.clientY + dh <= h - 10
|
|
|
|
|
? e.clientY - 70
|
|
|
|
|
: e.clientY - 70 - (e.clientY + dh - h);
|
|
|
|
|
this.$store.commit('setPosition', { positionx, positiony });
|
|
|
|
|
},
|
|
|
|
|
elementsetHide() {
|
|
|
|
|
//悬浮点击空白隐藏
|
|
|
|
|
this.$refs.elementset.elementsetHide();
|
|
|
|
|
},
|
|
|
|
|
tablelabelEmit(data) {
|
|
|
|
|
//获取子组件传过来的参数
|
|
|
|
|
this.$store.commit('setHeaderTable', data);
|
|
|
|
|
this.tablelable = data;
|
|
|
|
|
},
|
2019-12-10 17:00:28 +08:00
|
|
|
getAlertList: 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/message', this.searchLabel).then(response => {
|
2019-12-06 17:36:33 +08:00
|
|
|
if (response.code == 200) {
|
|
|
|
|
this.tableData = response.data.list
|
|
|
|
|
this.pageObj.total = response.data.total
|
|
|
|
|
}
|
|
|
|
|
})
|
2019-12-10 17:00:28 +08:00
|
|
|
},
|
2020-01-08 10:17:31 +08:00
|
|
|
//asset弹框控制
|
|
|
|
|
tabControl(data) {
|
|
|
|
|
if (data === 'close') {
|
|
|
|
|
this.viewAssetState = false
|
|
|
|
|
this.$refs['assetEditUnit'].tabView = false
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-12-10 17:00:28 +08:00
|
|
|
jumpTo(data,id) {
|
|
|
|
|
this.$store.state.assetData.moduleData = data
|
|
|
|
|
this.$store.state.assetData.selectedData = id
|
|
|
|
|
this.$router.push({
|
|
|
|
|
path: "/" + data,
|
|
|
|
|
query: {
|
|
|
|
|
t: +new Date()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2019-12-13 17:08:35 +08:00
|
|
|
pageNo(val) {
|
|
|
|
|
this.pageObj.pageNo = val;
|
|
|
|
|
this.getAlertList();
|
|
|
|
|
},
|
|
|
|
|
pageSize(val) {
|
|
|
|
|
this.pageObj.pageSize = val;
|
|
|
|
|
this.getAlertList();
|
2019-12-17 17:17:30 +08:00
|
|
|
},
|
|
|
|
|
search: function(searchObj) {
|
|
|
|
|
this.searchLabel = {};
|
2020-01-09 14:57:44 +08:00
|
|
|
this.pageObj.pageNo = 1;
|
2019-12-17 17:17:30 +08:00
|
|
|
for (let item in searchObj) {
|
|
|
|
|
if (searchObj[item]) {
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.getAlertList();
|
2020-01-06 19:03:38 +08:00
|
|
|
},
|
|
|
|
|
viewRule:function(id){
|
|
|
|
|
this.closeViews();
|
|
|
|
|
this.$get('alert/rule', {"id":id}).then(response => {
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
this.viewRuleData = response.data.list[0];
|
|
|
|
|
this.$refs.alertConfigBox.show(true);
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
viewAlertType:function(type,typeObj){
|
|
|
|
|
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 19:03:38 +08:00
|
|
|
let tempObj=JSON.parse(typeObj.param)
|
|
|
|
|
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:
|
|
|
|
|
this.viewAssetState=true;
|
|
|
|
|
this.$refs.assetEditUnit.getAssetData(typeObj);
|
|
|
|
|
this.$refs.assetEditUnit.tabView=true;
|
|
|
|
|
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.viewAssetState=false;
|
2019-12-13 17:08:35 +08:00
|
|
|
}
|
2019-12-06 17:36:33 +08:00
|
|
|
},
|
|
|
|
|
mounted() {
|
2019-12-10 17:00:28 +08:00
|
|
|
this.getAlertList();
|
2020-01-08 22:19:46 +08:00
|
|
|
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path)
|
|
|
|
|
? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
|
|
|
|
|
: this.tableTitle;
|
|
|
|
|
this.dropCol = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path)
|
|
|
|
|
? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
|
|
|
|
|
: this.tableTitle;
|
2019-12-06 17:36:33 +08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|