2019-12-06 17:36:33 +08:00
|
|
|
|
<style scoped>
|
2020-01-08 10:17:31 +08:00
|
|
|
|
.config {
|
2019-12-06 17:36:33 +08:00
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
2020-01-17 17:08:10 +08:00
|
|
|
|
<div class="config">
|
2020-04-14 19:33:57 +08:00
|
|
|
|
<left-menu >
|
|
|
|
|
|
<div slot="content-left" class="slot-content">
|
2020-01-17 17:08:10 +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')" id="alert-jump-alertlist">
|
|
|
|
|
|
{{$t('alert.alertList')}}
|
2019-12-06 17:36:33 +08:00
|
|
|
|
</div>
|
2020-01-17 17:08:10 +08:00
|
|
|
|
<div class="sidebar-info-item sidebar-info-item-active">{{$t('alert.alertConfig')}}</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-04-14 19:33:57 +08:00
|
|
|
|
<div slot="content-right" class="slot-content">
|
2020-03-30 14:14:09 +08:00
|
|
|
|
<div class="main-list main-and-sub-transition" :class="{'main-list-with-sub': showSubList}">
|
2020-03-20 21:05:31 +08:00
|
|
|
|
<div class="top-tools" v-show="mainResizeShow">
|
|
|
|
|
|
<div class="top-tool-main-right" :class="{'top-tool-main-right-to-left': showSubList}">
|
|
|
|
|
|
<div class="top-tool-search float-right">
|
2020-03-23 21:46:19 +08:00
|
|
|
|
<search-input :searchMsg="searchMsg" @search="search" :inTransform="inTransform"></search-input>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<button id="alert-add" @click="toAdd" :title="$t('overall.createAlertRule')"
|
|
|
|
|
|
class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20">
|
|
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
|
</button>
|
2020-02-03 21:30:07 +08:00
|
|
|
|
</div>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
2019-12-06 17:36:33 +08:00
|
|
|
|
</div>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
<el-table
|
|
|
|
|
|
class="nz-table"
|
|
|
|
|
|
:data="tableData"
|
|
|
|
|
|
border
|
|
|
|
|
|
v-show="mainResizeShow"
|
|
|
|
|
|
ref="alertRuleTable"
|
|
|
|
|
|
tooltip-effect="light"
|
|
|
|
|
|
:height="mainTableHeight"
|
2020-04-19 21:48:03 +08:00
|
|
|
|
v-scrollBar:el-table="'large'"
|
|
|
|
|
|
v-loading="loading"
|
2020-03-28 20:44:29 +08:00
|
|
|
|
:cell-class-name="messageStyle"
|
2020-07-15 18:32:25 +08:00
|
|
|
|
style="width: 100%;"
|
|
|
|
|
|
@sort-change="tableDataSort"
|
|
|
|
|
|
>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
v-for="(item, index) in tablelable"
|
|
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:width="item.width"
|
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
show-overflow-tooltip
|
|
|
|
|
|
min-width="110px"
|
2020-07-15 18:32:25 +08:00
|
|
|
|
:sortable="sortableShow(item.prop)"
|
|
|
|
|
|
:prop="propTitle(item.prop)"
|
2020-03-20 21:05:31 +08:00
|
|
|
|
>
|
|
|
|
|
|
<template slot-scope="scope" :column="item">
|
|
|
|
|
|
<div v-if="item.prop == 'option'" class="content-right-options">
|
|
|
|
|
|
<span :title="$t('overall.view')" @click="detail(scope.row)" class="content-right-option" :id="'alert-detail-'+scope.row.id"><i class="nz-icon nz-icon-view"></i></span>
|
|
|
|
|
|
<span v-if="scope.row.buildIn != 1" :title="$t('overall.edit')" @click="toEdit(scope.row)" class="content-right-option" :id="'alert-edit-'+scope.row.id"><i class="nz-icon nz-icon-edit"></i></span>
|
|
|
|
|
|
<span :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" :id="'alert-del-'+scope.row.id"><i class="el-icon-delete"></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> {{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>
|
2020-03-24 19:22:24 +08:00
|
|
|
|
<template v-else-if="item.prop == 'alertNum'">
|
2020-03-31 17:22:15 +08:00
|
|
|
|
<span class="link" @click="queryMessage(scope.row)">{{scope.row.alertNum + ' ' + $t('overall.active')}}</span>
|
2020-03-24 19:22:24 +08:00
|
|
|
|
</template>
|
2020-06-04 19:14:04 +08:00
|
|
|
|
<template v-else-if="item.prop == 'threshold'">
|
|
|
|
|
|
<span >{{formatThreshold(scope.row[item.prop],scope.row.unit)}}</span>
|
|
|
|
|
|
</template>
|
2020-05-06 15:23:00 +08:00
|
|
|
|
<template v-else-if="item.prop == 'receivers'">
|
2020-06-28 18:48:03 +08:00
|
|
|
|
<el-tag effect="dark" v-if="user.userName" :key="index" size="mini" v-for="(user, index) in scope.row[item.prop]" class="alert-rule-tag">{{user.userName}} </el-tag>
|
2020-05-06 15:23:00 +08:00
|
|
|
|
</template>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
|
<template v-else>-</template>
|
2020-01-19 18:31:18 +08:00
|
|
|
|
</template>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column width="28" :resizable="false">
|
|
|
|
|
|
<template slot="header" slot-scope="scope">
|
|
|
|
|
|
<span @click.stop="elementsetShow('shezhi',$event)" class="nz-table-gear">
|
|
|
|
|
|
<i class="nz-icon nz-icon-gear"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
2020-04-21 18:00:21 +08:00
|
|
|
|
<template v-slot="scope">
|
|
|
|
|
|
<button v-if="scope.$index == 0" class="to-top" :style="{top: toTopBtnTop}" :class="{'to-top-is-hover': tableHover}" v-show="showTopBtn && mainResizeShow" @click="$toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button>
|
|
|
|
|
|
</template>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
<div class="pagination-bottom" v-show="!showSubList">
|
2020-03-24 19:22:24 +08:00
|
|
|
|
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2020-04-19 22:03:18 +08:00
|
|
|
|
<bottom-box v-if="showSubList" :show-sub-list="showSubList" :subResizeShow="subResizeShow" :obj="alertRuleForMessage" :isFullScreen="isFullScreen" :from="'alertRule'" :targetTab.sync="targetTab" :detail="ruleDetail"
|
2020-03-28 20:44:29 +08:00
|
|
|
|
@closeSubList="showSubList = false" @fullScreen="fullScreen" @exitFullScreen="exitFullScreen" @listResize="listResize" ></bottom-box>
|
2019-12-06 17:36:33 +08:00
|
|
|
|
</div>
|
2020-04-14 19:33:57 +08:00
|
|
|
|
</left-menu>
|
2020-01-17 17:08:10 +08:00
|
|
|
|
<alert-config-box :parentAlertRule="alertRule" @reload="getTableData" ref="alertConfigBox"></alert-config-box>
|
|
|
|
|
|
<project-box :project="viewProjectData" ref="projectBox" @reload="getTableData"></project-box>
|
|
|
|
|
|
<module-box :module="viewModuleData" @reload="getTableData" ref="moduleBox"></module-box>
|
2020-07-06 19:49:04 +08:00
|
|
|
|
<!--<asset-box :edit-unit-show='viewAsset' @refreshData="getTableData" @sendStateData="tabControl" v-if="assetBoxShow"
|
|
|
|
|
|
ref="assetEditUnit"></asset-box>-->
|
2020-01-17 17:08:10 +08:00
|
|
|
|
<element-set
|
2020-03-24 19:22:24 +08:00
|
|
|
|
v-if="showElementSet"
|
|
|
|
|
|
@close="elementsetHide"
|
2020-01-17 17:08:10 +08:00
|
|
|
|
v-clickoutside="elementsetHide"
|
|
|
|
|
|
:table-title="tableTitle"
|
|
|
|
|
|
:dropCol="dropCol"
|
|
|
|
|
|
@tablelable="tablelabelEmit"
|
|
|
|
|
|
ref="elementset"
|
|
|
|
|
|
></element-set>
|
|
|
|
|
|
</div>
|
2019-12-06 17:36:33 +08:00
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2020-03-30 14:14:09 +08:00
|
|
|
|
var vm;
|
2020-04-06 22:11:25 +08:00
|
|
|
|
import bus from '../../../libs/bus';
|
2020-06-04 19:14:04 +08:00
|
|
|
|
import chartDataFormat from "../../charts/chartDataFormat";
|
2020-01-17 17:08:10 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "alert-config",
|
|
|
|
|
|
data() {
|
2020-03-30 14:14:09 +08:00
|
|
|
|
vm = this;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
return {
|
2020-04-19 21:48:03 +08:00
|
|
|
|
loading: false,
|
2020-03-28 20:44:29 +08:00
|
|
|
|
/*二级列表相关*/
|
|
|
|
|
|
ruleDetail: {},
|
|
|
|
|
|
targetTab: '', //展示二级列表中的哪个页签
|
2020-03-24 19:22:24 +08:00
|
|
|
|
showElementSet: false, //控制自定义列的弹框
|
2020-03-23 21:46:19 +08:00
|
|
|
|
inTransform: false, //搜索框相关,搜索条件下拉框是否在transform里
|
2020-03-20 21:05:31 +08:00
|
|
|
|
mainResizeShow: true, //dom高度改变时部分内容是否展示
|
|
|
|
|
|
subResizeShow: true,
|
|
|
|
|
|
isFullScreen: false,
|
|
|
|
|
|
showSubList: false, //是否展示二级列表
|
2020-03-28 20:44:29 +08:00
|
|
|
|
alertRuleForMessage: {}, //传给alertMessage上滑框的对象
|
|
|
|
|
|
|
2020-04-21 18:00:21 +08:00
|
|
|
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
|
|
|
|
|
tableHover: false, //控制滚动条和top按钮同时出现
|
|
|
|
|
|
|
2020-03-13 12:20:02 +08:00
|
|
|
|
tableId: 'alertRuleTable', //需要分页的table的id,用于记录每页数量
|
2020-03-05 21:30:45 +08:00
|
|
|
|
showTopBtn: false,
|
2020-03-20 21:05:31 +08:00
|
|
|
|
mainTableHeight: this.$tableHeight.normal, //主列表table高度
|
2020-01-17 17:08:10 +08:00
|
|
|
|
searchMsg: { //给搜索框子组件传递的信息
|
|
|
|
|
|
zheze_none: true,
|
|
|
|
|
|
searchLabelList: [{
|
|
|
|
|
|
id: 1,
|
|
|
|
|
|
name: 'ID',
|
|
|
|
|
|
type: 'input',
|
|
|
|
|
|
label: 'id',
|
|
|
|
|
|
disabled: false
|
|
|
|
|
|
}, {
|
|
|
|
|
|
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
|
|
|
|
|
|
}],
|
2019-12-13 17:08:35 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
searchLabel: { //搜索参数
|
|
|
|
|
|
|
2019-12-13 17:08:35 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
|
|
|
|
|
|
alertRule: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
alertName: '',
|
|
|
|
|
|
type: '',
|
|
|
|
|
|
linkObject: {id: '', name: ''},
|
|
|
|
|
|
linkId: '',
|
2020-06-10 11:10:43 +08:00
|
|
|
|
operator:'>',
|
2020-06-04 19:14:04 +08:00
|
|
|
|
threshold:'',
|
|
|
|
|
|
unit:2,
|
2020-01-17 17:08:10 +08:00
|
|
|
|
expr: '',
|
2020-06-10 11:10:43 +08:00
|
|
|
|
last: 60,
|
2020-01-17 17:08:10 +08:00
|
|
|
|
severity: '',
|
|
|
|
|
|
summary: '',
|
|
|
|
|
|
description: '',
|
2020-05-06 15:23:00 +08:00
|
|
|
|
receivers: '',
|
2019-12-13 17:08:35 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
tablelable: [],
|
|
|
|
|
|
dropCol: [],
|
|
|
|
|
|
pageObj: {
|
|
|
|
|
|
pageNo: 1,
|
2020-07-13 17:26:06 +08:00
|
|
|
|
pageSize: 50,
|
2020-01-17 17:08:10 +08:00
|
|
|
|
total: 0
|
2019-12-13 17:08:35 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +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")
|
2019-12-13 17:08:35 +08:00
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
],
|
|
|
|
|
|
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,
|
|
|
|
|
|
width: 120
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("alert.config.expr"),
|
|
|
|
|
|
prop: 'expr',
|
|
|
|
|
|
show: true,
|
2020-04-06 22:11:25 +08:00
|
|
|
|
}, /*{
|
2020-01-17 17:08:10 +08:00
|
|
|
|
label: this.$t("alert.list.type"),
|
|
|
|
|
|
prop: 'type',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("alert.config.link"),
|
|
|
|
|
|
prop: 'linkObject',
|
|
|
|
|
|
show: true,
|
2020-01-19 18:31:18 +08:00
|
|
|
|
width: 140
|
2020-04-06 22:11:25 +08:00
|
|
|
|
}, */{
|
2020-06-04 19:14:04 +08:00
|
|
|
|
label: this.$t("alert.config.operator"),
|
|
|
|
|
|
prop: 'operator',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("alert.config.threshold"),
|
|
|
|
|
|
prop: 'threshold',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
2020-01-17 17:08:10 +08:00
|
|
|
|
label: this.$t("alert.config.for"),
|
|
|
|
|
|
prop: 'last',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.severity'),
|
|
|
|
|
|
prop: 'severity',
|
|
|
|
|
|
show: true,
|
2020-05-28 17:32:23 +08:00
|
|
|
|
},{
|
|
|
|
|
|
label: this.$t('alert.summary'),
|
|
|
|
|
|
prop: 'summary',
|
|
|
|
|
|
show: true,
|
2020-01-17 17:08:10 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t('alert.description'),
|
|
|
|
|
|
prop: 'description',
|
|
|
|
|
|
show: true,
|
2020-03-28 20:44:29 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("alert.message"),
|
|
|
|
|
|
prop: 'alertNum',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 90
|
2020-05-06 15:23:00 +08:00
|
|
|
|
}, {
|
2020-01-17 17:08:10 +08:00
|
|
|
|
label: this.$t('alert.config.receiver'),
|
2020-05-06 15:23:00 +08:00
|
|
|
|
prop: 'receivers',
|
2020-01-17 17:08:10 +08:00
|
|
|
|
show: true,
|
2020-05-06 15:23:00 +08:00
|
|
|
|
}, {
|
2020-01-17 17:08:10 +08:00
|
|
|
|
label: this.$t('alert.config.option'),
|
|
|
|
|
|
prop: 'option',
|
|
|
|
|
|
show: true,
|
2020-02-18 11:05:57 +08:00
|
|
|
|
width: 120
|
2020-01-17 17:08:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
],
|
|
|
|
|
|
tableData: [],
|
|
|
|
|
|
viewProjectData: {},
|
|
|
|
|
|
viewModuleData: {},
|
|
|
|
|
|
viewAsset: false,
|
2020-01-08 10:17:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
methods: {
|
2020-03-20 21:05:31 +08:00
|
|
|
|
queryMessage(alertRule) {
|
2020-03-24 19:22:24 +08:00
|
|
|
|
this.alertRuleForMessage = alertRule;
|
2020-03-20 21:05:31 +08:00
|
|
|
|
this.showSubList = true;
|
2020-03-28 20:44:29 +08:00
|
|
|
|
this.targetTab = 'alertMessage';
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
elementsetShow(s, e) {
|
2020-03-24 19:22:24 +08:00
|
|
|
|
this.showElementSet = true;
|
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
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 + 14 : e.clientX + 14 - dw;
|
|
|
|
|
|
let positiony =
|
|
|
|
|
|
e.clientY + dh <= h - 10
|
|
|
|
|
|
? e.clientY + 20
|
|
|
|
|
|
: e.clientY + 20 - (e.clientY + dh - h);
|
|
|
|
|
|
this.$store.commit('setPosition', {positionx, positiony});
|
|
|
|
|
|
});
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
elementsetHide() {
|
|
|
|
|
|
//悬浮点击空白隐藏
|
2020-03-24 19:22:24 +08:00
|
|
|
|
//this.$refs.elementset.elementsetHide();
|
|
|
|
|
|
this.showElementSet = false;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
tablelabelEmit(data) {
|
|
|
|
|
|
//获取子组件传过来的参数
|
|
|
|
|
|
this.$store.commit('setHeaderTable', data);
|
|
|
|
|
|
this.tablelable = data;
|
2020-03-24 19:22:24 +08:00
|
|
|
|
this.dropCol = data;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
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);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-06-04 19:14:04 +08:00
|
|
|
|
formatThreshold:function(value,unit){
|
|
|
|
|
|
let unitMethod=chartDataFormat.getUnit(unit)
|
2020-06-04 19:19:50 +08:00
|
|
|
|
if(unitMethod&&value){
|
2020-06-04 19:14:04 +08:00
|
|
|
|
return unitMethod.compute(value,null,2);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return value
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
toAdd: function () {
|
|
|
|
|
|
this.cleanAlertRule();
|
|
|
|
|
|
this.$refs.alertConfigBox.show(true, true);
|
|
|
|
|
|
},
|
|
|
|
|
|
detail: function (u) {
|
2020-03-28 20:44:29 +08:00
|
|
|
|
this.alertRuleForMessage = Object.assign({}, u);
|
2020-06-05 19:31:14 +08:00
|
|
|
|
this.targetTab = "panel";
|
2020-03-28 20:44:29 +08:00
|
|
|
|
this.showSubList = true;
|
|
|
|
|
|
},
|
|
|
|
|
|
messageStyle(e) {
|
2020-07-22 16:33:53 +08:00
|
|
|
|
if (e.column.label == 'Message' || e.column.label == this.$t('alert.message')) {
|
2020-03-28 20:44:29 +08:00
|
|
|
|
if (e.row.alertNum > 0) {
|
2020-04-25 12:07:36 +08:00
|
|
|
|
return 'danger';
|
2020-03-28 20:44:29 +08:00
|
|
|
|
} else {
|
2020-04-25 12:07:36 +08:00
|
|
|
|
return 'success';
|
2020-03-28 20:44:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return '';
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
getTableData: function () {
|
|
|
|
|
|
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
|
|
|
|
|
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
2020-04-19 21:48:03 +08:00
|
|
|
|
this.loading = true;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.$get('alert/rule', this.searchLabel).then(response => {
|
2020-04-19 21:48:03 +08:00
|
|
|
|
this.loading = false;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
if (response.code == 200) {
|
2020-05-06 18:07:33 +08:00
|
|
|
|
response.data.list.forEach(item => {
|
|
|
|
|
|
let temp = [];
|
|
|
|
|
|
if (item.receiver) {
|
|
|
|
|
|
temp = item.receiver.split(",").map(t => {
|
|
|
|
|
|
return parseInt(t);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
item.receiverShow = temp;
|
|
|
|
|
|
});
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.tableData = response.data.list;
|
|
|
|
|
|
this.pageObj.total = response.data.total;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
cleanAlertRule: function () {
|
|
|
|
|
|
this.alertRule = {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
alertName: '',
|
|
|
|
|
|
linkObject: {id: '', name: ''},
|
|
|
|
|
|
expr: '',
|
2020-06-10 11:10:43 +08:00
|
|
|
|
unit:2,
|
|
|
|
|
|
operator: '>',
|
|
|
|
|
|
last: 60,
|
|
|
|
|
|
severity: 'medium',
|
2020-01-17 17:08:10 +08:00
|
|
|
|
summary: '',
|
|
|
|
|
|
description: '',
|
2019-12-06 17:36:33 +08:00
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
jumpTo(data, id) {
|
2020-04-06 22:11:25 +08:00
|
|
|
|
bus.$emit("menu-change", data);
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.$router.push({
|
|
|
|
|
|
path: "/" + data,
|
|
|
|
|
|
query: {
|
|
|
|
|
|
t: +new Date()
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
|
|
|
|
|
pageNo(val) {
|
|
|
|
|
|
this.pageObj.pageNo = val;
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
pageSize(val) {
|
|
|
|
|
|
this.pageObj.pageSize = val;
|
2020-03-13 12:20:02 +08:00
|
|
|
|
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val);
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
|
|
|
|
|
search: function (searchObj) {
|
2020-07-15 18:32:25 +08:00
|
|
|
|
let orderBy='';
|
|
|
|
|
|
if(this.searchLabel.orderBy){
|
|
|
|
|
|
orderBy=this.searchLabel.orderBy
|
|
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.searchLabel = {};
|
|
|
|
|
|
this.pageObj.pageNo = 1;
|
|
|
|
|
|
for (let item in searchObj) {
|
|
|
|
|
|
if (searchObj[item]) {
|
|
|
|
|
|
this.$set(this.searchLabel, item, searchObj[item]);
|
|
|
|
|
|
}
|
2019-12-10 17:00:28 +08:00
|
|
|
|
}
|
2020-07-15 18:32:25 +08:00
|
|
|
|
if(orderBy){
|
|
|
|
|
|
this.$set(this.searchLabel, 'orderBy', orderBy);
|
|
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2020-03-30 14:14:09 +08:00
|
|
|
|
// 全屏
|
|
|
|
|
|
fullScreen() {
|
|
|
|
|
|
this.$bottomBoxWindow.fullScreen(vm);
|
|
|
|
|
|
},
|
|
|
|
|
|
// 退出全屏
|
2020-03-20 21:05:31 +08:00
|
|
|
|
exitFullScreen() {
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.exitFullScreen(vm);
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
2020-03-30 14:14:09 +08:00
|
|
|
|
// 鼠标拖动二级列表
|
|
|
|
|
|
listResize(e) {
|
|
|
|
|
|
this.$bottomBoxWindow.listResize(vm, e);
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
viewAlertType: function (type, typeObj) {
|
|
|
|
|
|
this.closeViews();
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case 1:
|
|
|
|
|
|
this.viewProjectData = JSON.parse(JSON.stringify(typeObj));
|
|
|
|
|
|
this.$refs.projectBox.show(true);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 2:
|
|
|
|
|
|
// this.fillProject(typeObj);
|
2020-03-16 14:14:31 +08:00
|
|
|
|
if (typeObj.param) {
|
|
|
|
|
|
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-17 17:08:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
this.viewModuleData = JSON.parse(JSON.stringify(typeObj));
|
|
|
|
|
|
this.$refs.moduleBox.show(true);
|
|
|
|
|
|
break;
|
|
|
|
|
|
case 3:
|
|
|
|
|
|
this.viewAsset = true;
|
|
|
|
|
|
this.$refs.assetEditUnit.getAssetData(typeObj);
|
|
|
|
|
|
this.$refs.assetEditUnit.tabView = true;
|
|
|
|
|
|
break;
|
2019-12-17 17:17:30 +08:00
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
|
|
|
|
|
fillProject: function (module) {
|
|
|
|
|
|
this.$get('project', {"id": module.projectId}).then(response => {
|
|
|
|
|
|
if (response.code == 200) {
|
|
|
|
|
|
module.project = response.data.list[0];
|
2020-01-06 19:03:38 +08:00
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
closeViews: function () {
|
|
|
|
|
|
this.$refs.alertConfigBox.show(false, false);
|
|
|
|
|
|
this.$refs.projectBox.show(false, false);
|
|
|
|
|
|
this.$refs.moduleBox.show(false, false);
|
|
|
|
|
|
this.viewAsset = false;
|
2020-03-28 20:44:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
convertToDetail(obj) {
|
2020-06-15 22:23:56 +08:00
|
|
|
|
let detail = {
|
|
|
|
|
|
id: obj.id,
|
|
|
|
|
|
alertName: obj.alertName,
|
|
|
|
|
|
expr: obj.expr
|
|
|
|
|
|
};
|
|
|
|
|
|
/*detail.push({label: "ID", value: obj.id});
|
2020-03-28 20:44:29 +08:00
|
|
|
|
detail.push({label: this.$t("alert.alertName"), value: obj.alertName});
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.push({label: this.$t("alert.config.expr"), value: obj.expr});*/
|
2020-03-28 20:44:29 +08:00
|
|
|
|
let type = "";
|
|
|
|
|
|
for (let i = 0; i < this.typeData.length; i++) {
|
|
|
|
|
|
if (obj.type == this.typeData[i].key) {
|
|
|
|
|
|
type = this.typeData[i].value;
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.type = type;
|
|
|
|
|
|
//detail.push({label: this.$t("alert.list.type"), value: type});
|
2020-03-28 20:44:29 +08:00
|
|
|
|
let link = "";
|
|
|
|
|
|
if (obj.type == 1 || obj.type == 2) {
|
|
|
|
|
|
link = obj.linkObject.name;
|
|
|
|
|
|
} else if (obj.type == 3) {
|
|
|
|
|
|
link = obj.linkObject.host;
|
|
|
|
|
|
}
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.link = link;
|
|
|
|
|
|
detail.last = obj.last;
|
|
|
|
|
|
/*detail.push({label: this.$t("alert.config.link"), value: link});
|
|
|
|
|
|
detail.push({label: this.$t("alert.config.for"), value: obj.last});*/
|
2020-03-28 20:44:29 +08:00
|
|
|
|
let severity = this.severityData.filter((item, index) => {
|
|
|
|
|
|
return obj.severity == item.key;
|
|
|
|
|
|
})[0].value;
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.severity = severity;
|
|
|
|
|
|
detail.alertNum = obj.alertNum;
|
|
|
|
|
|
detail.description = obj.description;
|
|
|
|
|
|
/*detail.push({label: this.$t("alert.severity"), value: severity});
|
2020-03-28 20:44:29 +08:00
|
|
|
|
detail.push({label: this.$t("alert.description"), value: obj.description});
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.push({label: this.$t("alert.message"), value: obj.alertNum});*/
|
2020-03-28 20:44:29 +08:00
|
|
|
|
return detail;
|
|
|
|
|
|
},
|
2020-07-15 18:32:25 +08:00
|
|
|
|
//是否需要排序
|
|
|
|
|
|
sortableShow(prop){
|
|
|
|
|
|
switch(prop){
|
|
|
|
|
|
case 'id':
|
|
|
|
|
|
case 'alertName':
|
|
|
|
|
|
case 'threshold':
|
|
|
|
|
|
case 'severity':
|
|
|
|
|
|
return'custom';
|
|
|
|
|
|
default : return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// prop字段
|
|
|
|
|
|
propTitle(prop){
|
|
|
|
|
|
switch(prop){
|
|
|
|
|
|
case 'id': return'ar.id';
|
|
|
|
|
|
case 'alertName': return'ar.alert_name';
|
|
|
|
|
|
case 'threshold': return'ar.threshold';
|
|
|
|
|
|
case 'severity': return'ar.severity';
|
|
|
|
|
|
default : return prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
// 数据排序
|
|
|
|
|
|
tableDataSort(item){
|
|
|
|
|
|
let orderBy='';
|
|
|
|
|
|
if(item.order==='ascending'){
|
|
|
|
|
|
orderBy=item.prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(item.order==='descending'){
|
|
|
|
|
|
orderBy='-'+item.prop;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.$set(this.searchLabel, "orderBy", orderBy);
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2020-01-06 19:03:38 +08:00
|
|
|
|
},
|
2020-03-20 21:05:31 +08:00
|
|
|
|
watch: {
|
|
|
|
|
|
showSubList(n) {
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.showSubListWatch(vm, n);
|
2020-03-28 20:44:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
alertRuleForMessage: {
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n) {
|
|
|
|
|
|
this.ruleDetail = this.convertToDetail(n);
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
|
|
|
|
|
destroyed() {
|
|
|
|
|
|
window.onresize = null;
|
|
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
mounted() {
|
2020-03-13 12:20:02 +08:00
|
|
|
|
//是否存在分页缓存
|
|
|
|
|
|
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
2020-03-20 18:22:44 +08:00
|
|
|
|
if (pageSize != 'undefined' && pageSize != null) {
|
2020-03-13 12:20:02 +08:00
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.getTableData();
|
2020-03-05 21:30:45 +08:00
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
|
//绑定滚动条事件,控制top按钮
|
|
|
|
|
|
let el = this.$refs.alertRuleTable.$el.querySelector(".el-table__body-wrapper");
|
|
|
|
|
|
if (el._ps_) {
|
|
|
|
|
|
el.addEventListener("ps-scroll-y", () => {
|
2020-03-06 17:53:36 +08:00
|
|
|
|
if (el._ps_.scrollbarYTop > 50) {
|
2020-03-05 21:30:45 +08:00
|
|
|
|
this.showTopBtn = true;
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this.showTopBtn = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-04-21 18:00:21 +08:00
|
|
|
|
el.addEventListener("mouseenter", () => {
|
|
|
|
|
|
this.tableHover = true;
|
|
|
|
|
|
});
|
|
|
|
|
|
el.addEventListener("mouseleave", () => {
|
|
|
|
|
|
this.tableHover = false;
|
|
|
|
|
|
});
|
2020-03-05 21:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-01-17 17:08:10 +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>
|