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%;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.severity .P1{
|
2020-10-13 14:47:50 +08:00
|
|
|
|
background: #F5846A;
|
2020-10-12 14:03:29 +08:00
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.severity .P2{
|
2020-10-13 14:47:50 +08:00
|
|
|
|
background: #F7A54A;
|
2020-10-12 14:03:29 +08:00
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
}
|
2020-10-14 14:24:07 +08:00
|
|
|
|
.severity .P3{
|
2020-10-13 14:47:50 +08:00
|
|
|
|
background: #F1C13D;
|
2020-10-12 14:03:29 +08:00
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 2px 6px;
|
|
|
|
|
|
}
|
2019-12-06 17:36:33 +08:00
|
|
|
|
</style>
|
|
|
|
|
|
<template>
|
2020-01-17 17:08:10 +08:00
|
|
|
|
<div class="config">
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<div class="main-list" :class="{'main-list-with-sub': bottomBox.showSubList}">
|
|
|
|
|
|
<div class="main-modal"></div>
|
|
|
|
|
|
<div class="top-tools" v-show="bottomBox.mainResizeShow">
|
|
|
|
|
|
<div class="top-tool-main-right" :class="{'top-tool-main-right-to-left': bottomBox.showSubList}">
|
|
|
|
|
|
<div class="top-tool-search float-right">
|
2020-09-08 19:02:59 +08:00
|
|
|
|
<search-input :searchMsg="searchMsg" @search="search" :inTransform="bottomBox.inTransform"></search-input>
|
2020-07-30 18:37:04 +08:00
|
|
|
|
</div>
|
2020-09-09 11:15:35 +08:00
|
|
|
|
<export-excel
|
|
|
|
|
|
export-file-name="AlertRule"
|
|
|
|
|
|
export-url="/alert/rule/export"
|
|
|
|
|
|
import-url="/alert/rule/import"
|
|
|
|
|
|
:params="searchLabel"
|
|
|
|
|
|
@afterImport="getTableData"
|
|
|
|
|
|
class="margin-l-20"
|
|
|
|
|
|
>
|
|
|
|
|
|
<template slot="optionZone">
|
|
|
|
|
|
<button id="alert-add" @click="add" :title="$t('overall.createAlertRule')"
|
|
|
|
|
|
class="nz-btn nz-btn-size-normal nz-btn-style-light">
|
|
|
|
|
|
<i class="nz-icon-create-square nz-icon"></i>
|
|
|
|
|
|
</button>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</export-excel>
|
2020-10-29 19:11:46 +08:00
|
|
|
|
<delete-button :delete-objs="batchDeleteObjs" api="alert/rule" @after="getTableData"></delete-button>
|
2019-12-06 17:36:33 +08:00
|
|
|
|
</div>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<div class="pagination-top pagination-top-hide display-none"></div>
|
2020-01-17 17:08:10 +08:00
|
|
|
|
</div>
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<!-- 自定义table列 -->
|
|
|
|
|
|
<transition name="el-zoom-in-top">
|
|
|
|
|
|
<element-set
|
|
|
|
|
|
v-if="tools.showCustomTableTitle"
|
|
|
|
|
|
@close="tools.showCustomTableTitle = false"
|
|
|
|
|
|
:custom-table-title.sync="tools.customTableTitle"
|
|
|
|
|
|
:original-table-title="tableTitle"
|
|
|
|
|
|
ref="customTableTitle"
|
|
|
|
|
|
></element-set>
|
|
|
|
|
|
</transition>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<el-table
|
|
|
|
|
|
class="nz-table"
|
|
|
|
|
|
:data="tableData"
|
|
|
|
|
|
border
|
|
|
|
|
|
v-show="bottomBox.mainResizeShow"
|
|
|
|
|
|
ref="alertRuleTable"
|
|
|
|
|
|
tooltip-effect="light"
|
|
|
|
|
|
:height="mainTableHeight"
|
|
|
|
|
|
v-scrollBar:el-table="'large'"
|
|
|
|
|
|
v-loading="tools.loading"
|
|
|
|
|
|
:cell-class-name="messageStyle"
|
|
|
|
|
|
style="width: 100%;"
|
|
|
|
|
|
@sort-change="tableDataSort"
|
2020-09-24 11:38:13 +08:00
|
|
|
|
@row-dblclick="detail"
|
2020-10-29 19:11:46 +08:00
|
|
|
|
@selection-change="(selection)=>{this.batchDeleteObjs=selection}"
|
2020-08-02 22:43:53 +08:00
|
|
|
|
>
|
2020-10-29 19:11:46 +08:00
|
|
|
|
<el-table-column
|
|
|
|
|
|
:resizable="false"
|
|
|
|
|
|
type="selection"
|
|
|
|
|
|
width="40"
|
|
|
|
|
|
align="center">
|
|
|
|
|
|
</el-table-column>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<el-table-column
|
2020-11-04 15:38:34 +08:00
|
|
|
|
:resizable="true"
|
2020-08-04 21:53:06 +08:00
|
|
|
|
v-for="(item, index) in tools.customTableTitle"
|
2020-08-02 22:43:53 +08:00
|
|
|
|
v-if="item.show"
|
|
|
|
|
|
:key="`col-${index}`"
|
|
|
|
|
|
:label="item.label"
|
|
|
|
|
|
show-overflow-tooltip
|
|
|
|
|
|
:sort-orders="['ascending', 'descending']"
|
2020-08-07 11:11:43 +08:00
|
|
|
|
:sortable="$tableSet.sortableShow(item.prop,'alertRules')"
|
|
|
|
|
|
:prop="$tableSet.propTitle(item.prop,'alertRules')"
|
2020-08-02 22:43:53 +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="edit(scope.row)" class="content-right-option" :id="'alert-edit-'+scope.row.id"><i class="nz-icon nz-icon-edit"></i></span>
|
2020-09-10 17:00:32 +08:00
|
|
|
|
<span :title="$t('overall.delete')" @click="del(scope.row)" class="content-right-option" :id="'alert-del-'+scope.row.id"><i class="nz-icon nz-icon-delete"></i></span>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
</div>
|
2020-10-12 14:03:29 +08:00
|
|
|
|
<span v-else-if="item.prop == 'severity'" class="severity">
|
2020-10-14 14:24:07 +08:00
|
|
|
|
<span v-if="scope.row[item.prop] == 'P1'" class="P1">P1</span>
|
2020-10-12 14:03:29 +08:00
|
|
|
|
<!--<i class="nz-icon nz-icon-arrow-up"></i> {{returnSeverityLabel(scope.row[item.prop])}}-->
|
2020-10-14 14:24:07 +08:00
|
|
|
|
<span v-if="scope.row[item.prop] == 'P2'" class="P2">P2</span>
|
2020-10-12 14:03:29 +08:00
|
|
|
|
<!--{{returnSeverityLabel(scope.row[item.prop])}}-->
|
2020-10-14 14:24:07 +08:00
|
|
|
|
<span v-if="scope.row[item.prop] == 'P3'" class="P3">P3</span>
|
2020-10-12 14:03:29 +08:00
|
|
|
|
<!--<i class="nz-icon nz-icon-arrow-down"></i> {{returnSeverityLabel(scope.row[item.prop])}}-->
|
|
|
|
|
|
</span>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<template v-else-if="item.prop == 'alertNum'">
|
|
|
|
|
|
<span class="link" @click="queryMessage(scope.row)">{{scope.row.alertNum + ' ' + $t('overall.active')}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="item.prop == 'threshold'">
|
|
|
|
|
|
<span >{{formatThreshold(scope.row[item.prop],scope.row.unit)}}</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<template v-else-if="item.prop == 'receivers'">
|
|
|
|
|
|
<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>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<span v-else-if="scope.row[item.prop]">{{scope.row[item.prop]}}</span>
|
|
|
|
|
|
<template v-else>-</template>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
<el-table-column width="28" :resizable="false">
|
|
|
|
|
|
<template slot="header" slot-scope="scope">
|
2020-08-04 21:53:06 +08:00
|
|
|
|
<span @mousedown.stop="!tools.showCustomTableTitle && (tools.showCustomTableTitle = true)" class="nz-table-gear">
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<i class="nz-icon nz-icon-gear"></i>
|
|
|
|
|
|
</span>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</el-table-column>
|
|
|
|
|
|
</el-table>
|
2020-11-21 15:33:40 +08:00
|
|
|
|
<button class="to-top" :style="{top: tools.toTopBtnTop}" :class="{'to-top-is-hover': tools.tableHover}" v-show="tools.showTopBtn && bottomBox.mainResizeShow" @click="$toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
<div class="pagination-bottom" v-show="!bottomBox.showSubList">
|
|
|
|
|
|
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
|
2020-03-20 21:05:31 +08:00
|
|
|
|
</div>
|
2020-08-02 22:43:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="el-zoom-in-bottom">
|
|
|
|
|
|
<bottom-box v-if="bottomBox.showSubList" :sub-resize-show="bottomBox.subResizeShow" :obj="bottomBox.alertRule" :is-full-screen="bottomBox.isFullScreen" :from="'alertRule'" :target-tab.sync="bottomBox.targetTab" :detail="bottomBox.ruleDetail"
|
|
|
|
|
|
@closeSubList="bottomBox.showSubList = false" @fullScreen="fullScreen" @exitFullScreen="exitFullScreen" @listResize="listResize" ></bottom-box>
|
|
|
|
|
|
</transition>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
<transition name="right-box">
|
2020-07-30 18:37:04 +08:00
|
|
|
|
<alert-config-box v-if="rightBox.show" :alert-rule="alertRule" @close="closeRightBox" ref="alertConfigBox"></alert-config-box>
|
2020-07-24 19:22:52 +08:00
|
|
|
|
</transition>
|
2020-01-17 17:08:10 +08:00
|
|
|
|
</div>
|
2019-12-06 17:36:33 +08:00
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
<script>
|
2020-04-06 22:11:25 +08:00
|
|
|
|
import bus from '../../../libs/bus';
|
2020-09-09 11:15:35 +08:00
|
|
|
|
import exportXLSX from "../../common/exportXLSX";
|
2020-06-04 19:14:04 +08:00
|
|
|
|
import chartDataFormat from "../../charts/chartDataFormat";
|
2020-10-29 19:11:46 +08:00
|
|
|
|
import deleteButton from "../../common/deleteButton";
|
2020-01-17 17:08:10 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name: "alert-config",
|
2020-09-09 11:15:35 +08:00
|
|
|
|
components: {
|
|
|
|
|
|
'export-excel': exportXLSX,
|
2020-10-29 19:11:46 +08:00
|
|
|
|
'delete-button':deleteButton,
|
2020-09-09 11:15:35 +08:00
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
//侧滑
|
|
|
|
|
|
rightBox: {
|
|
|
|
|
|
show: false,
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
/*二级页面相关*/
|
|
|
|
|
|
bottomBox: {
|
|
|
|
|
|
ruleDetail: {},
|
|
|
|
|
|
alertRule: {},
|
|
|
|
|
|
mainResizeShow: true, //dom高度改变时是否展示|隐藏
|
|
|
|
|
|
subResizeShow: true,
|
|
|
|
|
|
isFullScreen: false, //全屏状态
|
|
|
|
|
|
showSubList: false, //是否显示二级列表
|
|
|
|
|
|
targetTab: '', //显示二级列表中的哪个页签
|
|
|
|
|
|
inTransform: false, //搜索框相关,搜索条件下拉框是否在transform里
|
|
|
|
|
|
},
|
2020-03-28 20:44:29 +08:00
|
|
|
|
|
2020-07-24 19:22:52 +08:00
|
|
|
|
/*工具参数*/
|
|
|
|
|
|
tools: {
|
|
|
|
|
|
loading: false, //是否显示table加载动画
|
|
|
|
|
|
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
|
|
|
|
|
|
tableHover: false, //控制滚动条和top按钮同时出现
|
|
|
|
|
|
showTopBtn: false, //显示To top按钮
|
2020-08-04 21:53:06 +08:00
|
|
|
|
showCustomTableTitle: false, //自定义列弹框是否显示
|
|
|
|
|
|
customTableTitle: [], //自定义列工具的数据
|
2020-07-24 19:22:52 +08:00
|
|
|
|
},
|
|
|
|
|
|
mainTableHeight: this.$tableHeight.normal, //主列表table高度
|
2020-10-29 19:11:46 +08:00
|
|
|
|
batchDeleteObjs:[],
|
2020-03-13 12:20:02 +08:00
|
|
|
|
tableId: 'alertRuleTable', //需要分页的table的id,用于记录每页数量
|
2020-07-24 19:22:52 +08:00
|
|
|
|
alertRule: {},
|
|
|
|
|
|
blankAlertRule: {
|
|
|
|
|
|
id: '',
|
|
|
|
|
|
alertName: '',
|
|
|
|
|
|
linkObject: {id: '', name: ''},
|
|
|
|
|
|
expr: '',
|
|
|
|
|
|
unit:2,
|
|
|
|
|
|
operator: '>',
|
|
|
|
|
|
last: 60,
|
2020-10-14 14:24:07 +08:00
|
|
|
|
severity: 'P2',
|
2020-07-24 19:22:52 +08:00
|
|
|
|
summary: '',
|
|
|
|
|
|
description: '',
|
|
|
|
|
|
},
|
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
|
2020-10-16 09:37:19 +08:00
|
|
|
|
}, {
|
2020-01-17 17:08:10 +08:00
|
|
|
|
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
|
|
|
|
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
|
|
|
|
tableTitle: [
|
|
|
|
|
|
{
|
|
|
|
|
|
label: 'ID',
|
|
|
|
|
|
prop: 'id',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
width: 80
|
|
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("alert.alertName"),
|
|
|
|
|
|
prop: 'alertName',
|
|
|
|
|
|
show: true,
|
2020-08-07 09:37:58 +08:00
|
|
|
|
// width: 120
|
2020-01-17 17:08:10 +08:00
|
|
|
|
}, {
|
|
|
|
|
|
label: this.$t("alert.config.expr"),
|
|
|
|
|
|
prop: 'expr',
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
}, {
|
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-07-24 19:22:52 +08:00
|
|
|
|
this.bottomBox.alertRule = alertRule;
|
|
|
|
|
|
this.bottomBox.showSubList = true;
|
|
|
|
|
|
this.bottomBox.targetTab = 'alertMessage';
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
edit(u) {
|
|
|
|
|
|
this.alertRule = JSON.parse(JSON.stringify(u));
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.rightBox.show = true;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
closeRightBox(refresh) {
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.rightBox.show = false;
|
2020-07-24 19:22:52 +08:00
|
|
|
|
if (refresh) {
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
del(u) {
|
2020-01-17 17:08:10 +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);
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
});
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
formatThreshold(value,unit) {
|
|
|
|
|
|
let unitMethod = chartDataFormat.getUnit(unit);
|
|
|
|
|
|
if (unitMethod&&value) {
|
|
|
|
|
|
return unitMethod.compute(value, null, 2);
|
|
|
|
|
|
} else {
|
2020-06-04 19:14:04 +08:00
|
|
|
|
return value
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
add() {
|
|
|
|
|
|
this.alertRule = this.newAlertRule();
|
2020-07-30 18:37:04 +08:00
|
|
|
|
this.rightBox.show = true;
|
2020-07-24 19:22:52 +08:00
|
|
|
|
},
|
|
|
|
|
|
newAlertRule() {
|
|
|
|
|
|
return JSON.parse(JSON.stringify(this.blankAlertRule));
|
2020-01-17 17:08:10 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
detail(u) {
|
|
|
|
|
|
this.bottomBox.alertRule = JSON.parse(JSON.stringify(u));
|
|
|
|
|
|
this.bottomBox.targetTab = "panel";
|
|
|
|
|
|
this.bottomBox.showSubList = true;
|
2020-03-28 20:44:29 +08:00
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
getTableData() {
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
|
|
|
|
|
|
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.tools.loading = true;
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.$get('alert/rule', this.searchLabel).then(response => {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.tools.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;
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
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();
|
|
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
search(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-11-17 09:05:43 +08:00
|
|
|
|
if(this.$refs.alertRuleTable && this.$refs.alertRuleTable.bodyWrapper){
|
|
|
|
|
|
this.$refs.alertRuleTable.bodyWrapper.scrollTop = 0;
|
|
|
|
|
|
}
|
2020-01-17 17:08:10 +08:00
|
|
|
|
this.getTableData();
|
|
|
|
|
|
},
|
2020-03-30 14:14:09 +08:00
|
|
|
|
// 全屏
|
|
|
|
|
|
fullScreen() {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.fullScreen(vm);
|
|
|
|
|
|
},
|
|
|
|
|
|
// 退出全屏
|
2020-03-20 21:05:31 +08:00
|
|
|
|
exitFullScreen() {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
let vm = this;
|
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) {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.listResize(vm, e);
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
viewAlertType(type, typeObj) {
|
2020-01-17 17:08:10 +08:00
|
|
|
|
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
|
|
|
|
|
|
};
|
2020-03-28 20:44:29 +08:00
|
|
|
|
let type = "";
|
2020-07-31 20:57:04 +08:00
|
|
|
|
for (let i = 0; i < this.$CONSTANTS.alertMessage.typeData.length; i++) {
|
|
|
|
|
|
if (obj.type == this.$CONSTANTS.alertMessage.typeData[i].value) {
|
|
|
|
|
|
type = this.$CONSTANTS.alertMessage.typeData[i].label;
|
2020-03-28 20:44:29 +08:00
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.type = 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;
|
2020-08-04 11:41:31 +08:00
|
|
|
|
let severity = this.$CONSTANTS.alertMessage.severityData.find(s => {return s.value == obj.severity});
|
2020-06-15 22:23:56 +08:00
|
|
|
|
detail.severity = severity;
|
|
|
|
|
|
detail.alertNum = obj.alertNum;
|
|
|
|
|
|
detail.description = obj.description;
|
2020-03-28 20:44:29 +08:00
|
|
|
|
return detail;
|
|
|
|
|
|
},
|
2020-07-15 18:32:25 +08:00
|
|
|
|
// 数据排序
|
|
|
|
|
|
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-08-03 21:33:13 +08:00
|
|
|
|
initEvent() {
|
|
|
|
|
|
bus.$on("alert-rule-list-change", () => {
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
});
|
|
|
|
|
|
bus.$on("dc-list-change", () => {
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
});
|
2020-11-17 17:14:12 +08:00
|
|
|
|
bus.$on('alert-message-change',()=>{
|
|
|
|
|
|
this.getTableData();
|
|
|
|
|
|
})
|
2020-11-20 15:02:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
plpsscrolly(el,self){
|
|
|
|
|
|
if (el._ps_.scrollbarYTop > 50) {
|
|
|
|
|
|
self.tools.showTopBtn = true;
|
2020-11-21 15:33:40 +08:00
|
|
|
|
self.tools.tableHover = true;
|
2020-11-20 15:02:36 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
self.tools.showTopBtn = false;
|
2020-11-21 15:33:40 +08:00
|
|
|
|
self.tools.tableHover = false;
|
2020-11-20 15:02:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-07-30 18:37:04 +08:00
|
|
|
|
},
|
2020-03-20 21:05:31 +08:00
|
|
|
|
watch: {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
'bottomBox.showSubList': function(n) {
|
|
|
|
|
|
let vm = this;
|
2020-03-30 14:14:09 +08:00
|
|
|
|
this.$bottomBoxWindow.showSubListWatch(vm, n);
|
2020-03-28 20:44:29 +08:00
|
|
|
|
},
|
2020-07-24 19:22:52 +08:00
|
|
|
|
'bottomBox.alertRule': {
|
2020-03-28 20:44:29 +08:00
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n) {
|
2020-07-24 19:22:52 +08:00
|
|
|
|
this.bottomBox.ruleDetail = this.convertToDetail(n);
|
2020-03-28 20:44:29 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
|
|
|
|
|
destroyed() {
|
|
|
|
|
|
window.onresize = null;
|
2020-11-20 10:15:17 +08:00
|
|
|
|
bus.$off("alert-rule-list-change");
|
|
|
|
|
|
bus.$off("dc-list-change");
|
|
|
|
|
|
bus.$off('alert-message-change')
|
2020-03-20 21:05:31 +08:00
|
|
|
|
},
|
2020-11-21 12:21:27 +08:00
|
|
|
|
created(){
|
|
|
|
|
|
//是否存在分页缓存
|
|
|
|
|
|
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
|
|
|
|
|
|
if (pageSize != 'undefined' && pageSize != null) {
|
|
|
|
|
|
this.pageObj.pageSize = pageSize
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-01-17 17:08:10 +08:00
|
|
|
|
mounted() {
|
2020-08-04 21:53:06 +08:00
|
|
|
|
//初始化表头
|
|
|
|
|
|
this.tools.customTableTitle = 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;
|
2020-10-30 15:54:47 +08:00
|
|
|
|
this.tableTitleReset(this.tableTitle,this.tools.customTableTitle);
|
2020-08-03 21:33:13 +08:00
|
|
|
|
this.initEvent();
|
2020-03-13 12:20:02 +08:00
|
|
|
|
|
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_) {
|
2020-11-20 15:02:36 +08:00
|
|
|
|
el.addEventListener("ps-scroll-y", this.plpsscrolly.bind('',el,this));
|
2020-03-05 21:30:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
2020-11-20 15:02:36 +08:00
|
|
|
|
},
|
|
|
|
|
|
beforeDestroy(){
|
2020-11-20 15:52:06 +08:00
|
|
|
|
let el = this.$refs.alertRuleTable.$el.querySelector(".el-table__body-wrapper");
|
2020-11-20 15:02:36 +08:00
|
|
|
|
if (el._ps_) {
|
|
|
|
|
|
el.removeEventListener("ps-scroll-y", this.plpsscrolly.bind('',el,this));
|
2020-11-20 16:55:21 +08:00
|
|
|
|
el._ps_.destroy();
|
2020-11-20 15:02:36 +08:00
|
|
|
|
}
|
2019-12-06 17:36:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|