This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
nezha-nezha-fronted/nezha-fronted/src/components/page/alert/config.vue

319 lines
9.4 KiB
Vue
Raw Normal View History

<style scoped>
.account {
height: 100%;
}
2019-12-16 17:14:58 +08:00
.right-box::-webkit-scrollbar-track {
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
border-radius: 0;
background: rgba(0,0,0,0.1);
}
.right-box::-webkit-scrollbar-thumb {
border-radius: 5px;
-webkit-box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
background: rgba(0,0,0,0.2);
}
.right-box::-webkit-scrollbar {
width: 4px;
height: 4px;
}
.right-box {
overflow: auto;
}
.account-list-option {
cursor: pointer;
display: inline-block;
margin-right: 6px;
}
.account-list-option .el-icon-delete {
color: #F98D9A;
}
.account-list-option .el-icon-delete:hover {
color: #D96D7A;
}
.account-list-option .el-icon-view {
color: #60BEFF;
}
.account-list-option .el-icon-view:hover {
color: #409EFF;
}
</style>
<template>
<div class="account">
2019-12-09 19:23:20 +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" @click="jumpTo('alertList')">{{$t('alert.alertList')}}</div>
<div class="sidebar-info-item sidebar-info-item-active">{{$t('alert.alertConfig')}}</div>
</div>
</div>
<div class="content-right">
<div class="top-tools">
<button @click="toAdd" class="nz-btn nz-btn-size-normal nz-btn-style-normal float-right">
<span class="top-tool-btn-txt">{{$t('overall.add')}}</span>
</button>
<div class="top-tool-search float-right"><search-input :searchMsg="searchMsg" @search="search"></search-input></div>
</div>
<el-table
:data="tableData"
border
height="calc(100% - 65px)"
style="width: 100%;">
<el-table-column
:resizable="false"
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">
<span @click="del(scope.row)" class="account-list-option"><i class="el-icon-delete"></i></span>
<span @click="detail(scope.row)" class="account-list-option"><i class="el-icon-view"></i></span>
<span @click="toEdit(scope.row)" class="account-list-option"><i class="el-icon-edit-outline"></i></span>
</div>
<span v-else-if="item.prop == 'severity'">
<span v-if="scope.row[item.prop] == 'high'"><i class="el-icon-arrow-up"></i>&nbsp;{{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>&nbsp;{{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>
<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>
<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>
<alert-config-box :parentAlertRule="alertRule" @reload="getTableData" ref="alertConfigBox"></alert-config-box>
</div>
</template>
<script>
export default {
name: "alert-config",
data() {
return {
searchMsg: { //给搜索框子组件传递的信息
2019-12-16 17:14:58 +08:00
zheze_none: true,
searchLabelList: [{
2019-12-16 17:14:58 +08:00
id: 1,
name: 'ID',
type: 'input',
label: 'id',
disabled: false
},{
2019-12-16 17:14:58 +08:00
id: 2,
name: this.$t('alert.alertName'),
2019-12-16 17:14:58 +08:00
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',
2019-12-16 17:14:58 +08:00
disabled: false
}],
},
searchLabel: { //搜索参数
2019-12-16 17:14:58 +08:00
},
alertRule: {
id: '',
alertName: '',
type: '',
linkObject: {id: '', name: ''},
linkId: '',
expr: '',
last: '',
severity: '',
summary: '',
description: '',
receiver: '',
},
pageObj: {
pageNo: 1,
pageSize: 20,
2019-12-09 19:23:20 +08:00
total:0
},
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')
}
],
tableTitle: [
{
label: 'ID',
prop: 'id',
show: true,
width: 80
}, {
label: this.$t("alert.alertName"),
prop: 'alertName',
show: true,
}, {
label: this.$t("alert.config.expr"),
prop: 'expr',
show: true,
}, {
label: this.$t("alert.list.type"),
prop: 'type',
show: true,
}, {
label: this.$t("alert.config.link"),
prop: 'linkObject',
show: true,
}, {
label: this.$t("alert.config.for"),
prop: 'last',
show: true,
}, {
label: this.$t('alert.severity'),
prop: 'severity',
show: true,
}, {
label: this.$t('alert.description'),
prop: 'description',
show: true,
}, {
label: this.$t('alert.config.receiver'),
prop: 'receiver',
show: true,
}, {
label: this.$t('alert.config.option'),
prop: 'option',
show: true,
}
],
tableData: []
}
},
methods: {
toEdit: function(u) {
this.alertRule = Object.assign({}, u);
this.$refs.alertConfigBox.show(true, true);
},
del: function(u) {
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);
}
})
});
},
toAdd: function() {
this.cleanAlertRule();
this.$refs.alertConfigBox.show(true, true);
},
detail: function(u) {
this.alertRule = Object.assign({}, u);
this.$refs.alertConfigBox.show(true, false);
},
getTableData: function() {
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
this.$get('alert/rule', this.searchLabel).then(response => {
if (response.code == 200) {
this.tableData = response.data.list;
this.pageObj.total = response.data.total;
}
})
},
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: '',
linkObject: {id: '', name: ''},
expr: '',
last: '',
severity: '',
summary: '',
description: '',
receiver: '',
}
},
jumpTo(data,id) {
this.$router.push({
path: "/" + data,
query: {
t: +new Date()
}
});
},
pageNo(val) {
this.pageObj.pageNo = val;
this.getTableData();
},
pageSize(val) {
this.pageObj.pageSize = val;
this.getTableData();
},
search: function(searchObj) {
this.searchLabel = {};
for (let item in searchObj) {
if (searchObj[item]) {
this.$set(this.searchLabel, item, searchObj[item]);
}
}
this.getTableData();
}
},
mounted() {
this.getTableData();
}
}
</script>