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/list.vue

901 lines
31 KiB
Vue
Raw Normal View History

<style scoped>
.list {
height: 100%;
}
2020-07-28 14:26:51 +08:00
/deep/ .too-long-split{
cursor: pointer;
2020-07-27 19:02:30 +08:00
vertical-align: bottom;
}
span.el-tooltip {
display: inline-block;
}
/deep/.top-tools{
z-index: 1;
}
</style>
<style lang="scss">
2020-05-31 22:33:16 +08:00
@import '../../charts/chart';
</style>
<template>
<div class="list">
<div class="main-list main-and-sub-transition" :class="{'main-list-with-sub': showSubList}">
<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">
<search-input :searchMsg="searchMsg" @search="search" :inTransform="inTransform"></search-input>
</div>
<button type="button" @click="showExportDialog" :title="$t('overall.exportExcelLower')"
class="nz-btn nz-btn-size-normal nz-btn-style-light margin-l-20" id="alert-list-export">
<i class="el-icon-download"></i>
</button>
</div>
<div class="pagination-top pagination-top-hide display-none"></div>
</div>
<alertMessageTable
:tableData="tableData"
:loading="loading"
:tableHeight="mainTableHeight"
:tableId="tableId"
@tableDataSort="tableDataSort"
@deleteMessage="deleteMessage"
:form="'chartList'"
></alertMessageTable>
<div class="pagination-bottom" v-show="!showSubList">
<Pagination :tableId="tableId" :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
</div>
</div>
<bottom-box v-if="showSubList" :show-sub-list="showSubList" :subResizeShow="subResizeShow" :isFullScreen="isFullScreen" :from="'alertMessage'" :targetTab.sync="targetTab" :detailList="tabDetailList"
@closeSubList="showSubList = false" @fullScreen="fullScreen" @exitFullScreen="exitFullScreen" @listResize="listResize" :tabList="tabList"></bottom-box>
<element-set
v-clickoutside="elementsetHide"
:table-title="tableTitle"
:dropCol="dropCol"
@tablelable="tablelabelEmit"
ref="elementset"
></element-set>
2020-04-09 12:19:21 +08:00
<!--导出-->
2020-04-08 20:27:07 +08:00
<div class="export-xlsx">
<el-dialog :visible.sync="importBox.show" :title="importBox.title" :modal-append-to-body='false' :show-close="true" width="300px" @close="closeDialog" class="nz-dialog">
<div class="upload-body">
<button @click="exportCur" class="el-button el-button--default el-button--small">
<span>{{$t('overall.exportCur')}}</span>
</button>
2020-04-09 12:19:21 +08:00
<button @click="exportAll" class="el-button el-button--default el-button--small">
2020-04-08 20:27:07 +08:00
<span>{{$t('overall.exportAll')}}</span>
</button>
</div>
</el-dialog>
</div>
<!--export-->
2020-04-09 12:19:21 +08:00
<div class="export-xlsx">
<el-dialog :visible.sync="deleteBox.show" :title="$t('overall.delete')" :modal-append-to-body='false' :show-close="true" width="300px" @close="closeDialog" class="nz-message">
<div class="upload-body">
<el-input type="textarea" :placeholder="$t('alert.description')" v-model="deleteBox.remark"></el-input>
<div style="text-align: right; margin-top: 10px;">
<button @click="closeDialog" class="el-button el-button--default el-button--small">
<span>{{$t('tip.no')}}</span>
</button>
<button @click="deleteMessage" class="el-button el-button--default el-button--small el-button--primary">
<span>{{$t('tip.yes')}}</span>
</button>
</div>
</div>
</el-dialog>
</div>
<el-dialog class="line-chart-block-modal nz-dialog endpoint-dialog"
:title="$t('overall.detail')"
:visible.sync="graphShow"
width="90%"
id="viewGraphDialog"
@close="dialogClose">
<div slot="title">
{{$t("project.endpoint.dialogTitle")}}
<div class="float-right panel-calendar dialog-tool" style="display: flex">
<pick-time :refresh-data-func="queryChartDate" :use-refresh="false" :use-chart-unit="false" v-model="searchTime" style="height: 28px;" @unitChange="chartUnitChange"></pick-time>
</div>
</div>
<chart ref="messageChart" name="alertMessageChart" :unit="chartUnit"></chart>
</el-dialog>
</div>
</template>
<script>
import bus from '../../../libs/bus';
import axios from 'axios';
import nzAlertTag from './nzAlertTag';
import chart from '../../page/dashboard/overview/chart'
import chartDataFormat from "../../charts/chartDataFormat";
import alertRuleInfo from '../../common/alert/alertRuleInfo'
import alertLabel from '../../common/alert/alertLabel'
import alertMessageTable from '@/components/common/alert/alertMessageTable.vue'
export default {
name: "alertList",
components: {
'nz-alert-tag': nzAlertTag,
'chart': chart,
'alertRuleInfo':alertRuleInfo,
'alertLabel':alertLabel,
'alertMessageTable':alertMessageTable,
},
data() {
return {
loading: false,
/*二级列表相关*/
tabList: [], //二级列表的标签
tabDetailList: [], //多个详情
targetTab: '', //展示二级列表中的哪个页签
inTransform: false, //搜索框相关搜索条件下拉框是否在transform里
mainResizeShow: true, //dom高度改变时部分内容是否展示
subResizeShow: true,
isFullScreen: false,
showSubList: false, //是否展示二级列表
mainTableHeight: this.$tableHeight.normal, //主列表table高度
toTopBtnTop: this.$tableHeight.toTopBtnTop, //to-top按钮的top属性
tableHover: false, //控制滚动条和top按钮同时出现
2020-04-08 20:27:07 +08:00
//导出相关
2020-04-09 12:19:21 +08:00
importBox: {show: false, title:this.$t('overall.exportExcel')},
deleteBox: {show: false, ids: "", remark: '', state: 2},
2020-04-08 20:27:07 +08:00
//详情相关
graphShow: false,
chartDatas: [],
sameLabels: ['instance','module','project','asset','endpoint','datacenter'],
legend: [],
searchTime: [new Date().setHours(new Date().getHours() - 1), new Date()],
currentMsg: {},
chartUnit: 5,
tableId: 'alertListTable', //需要分页的table的id用于记录每页数量
showTopBtn: false,
pageObj: {
pageNo: 1,
pageSize: 50,
total: 0
},
tableTitle: [
{
label: 'ID',
prop: 'id',
show: true,
width: 80
}, {
label: this.$t("alert.alertName"),
prop: 'alertRule',
show: true,
width: 180
}, {
label: this.$t("alert.list.labels"),
prop: 'labels',
show: true,
width:350,
}, {
label: this.$t("alert.severity"),
prop: 'severity',
show: true,
width: 100,
}, {
label: this.$t('alert.summary'),
prop: 'summary',
show: true,
}, {
label: this.$t('alert.description'),
prop: 'description',
show: true,
}, {
label: this.$t('alert.list.state'),
prop: 'state',
show: true,
width: 100
}, {
label: this.$t("alert.startAt"),
prop: 'startAt',
show: true,
width: 150
}, {
label: this.$t('alert.endAt'),
prop: 'endAt',
show: true,
width: 150
}, {
label: this.$t('overall.value'),
prop: 'current',
show: true,
width: 100
}, {
label: this.$t('overall.option'),
prop: 'option',
show: true,
width: 90
}
],
searchMsg: { //给搜索框子组件传递的信息
zheze_none: true,
searchLabelList: [{
id: 1,
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: 20,
name: this.$t('alert.severity'),
type: 'selectString',
label: 'severity',
disabled: false
}, {
id: 21,
name: this.$t('asset.asset'),
type: 'asset',
label: 'asset',
disabled: false
}, {
id:22,
name: this.$t('project.project.project'),
type: 'project',
label: 'project',
disabled: false
}, {
id:23,
name: this.$t('project.module.module'),
type: 'module',
label: 'module',
disabled: false
}, {
id:24,
name: this.$t('project.endpoint.endpoint'),
type: 'input',
label: 'endpointId',
disabled: false
}, {
id:25,
name: this.$t('alert.list.state'),
type: 'select',
label: 'alertMessageState',
disabled: false
}],
},
searchLabel: { //搜索参数
},
tablelable: [],
dropCol: [],
tableData: [],
requestIndex:0,
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: []},
viewAssetState: false,
}
},
computed: {
tagType() {
return (key) => {
if (key == 'asset' || key == 'module' || key == 'project' || key == 'datacenter' || key == 'endpoint') {
return "normal";
} else {
return "info";
}
}
2020-04-09 17:00:32 +08:00
},
tagValue() {
return (key, value) => {
if (key == 'type') {
if (value == 1) {
value = this.$t("project.project.project");
} else if (value == 2) {
value = this.$t("module.module.module");
} else if (value == 3) {
value = this.$t("asset.asset");
}
}
return key + "" + value;
}
}
},
methods: {
labelsSort:function(obj){
let buildIn=['asset','endpoint','module','project','datacenter']
let labels=JSON.parse(JSON.stringify(obj));
let result=[];
for(let key of buildIn){
if(key in labels){
result.push({label:key,value:labels[key]})
delete labels[key]
}
}
Object.keys(labels).sort().forEach(key=>{
result.push({label:key,value:labels[key]})
})
return result;
},
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 + 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});
},
elementsetHide() {
//悬浮点击空白隐藏
this.$refs.elementset.elementsetHide();
},
tablelabelEmit(data) {
//获取子组件传过来的参数
this.$store.commit('setHeaderTable', data);
this.tablelable = data;
},
chartUnitChange:function(unit){
this.chartUnit=unit;
this.$nextTick(()=>{
this.queryChartDate()
})
},
formatThreshold:function(value,unit){
let unitMethod=chartDataFormat.getUnit(unit)
2020-06-04 19:19:50 +08:00
if(unitMethod&&value){
return unitMethod.compute(value,null,2);
}else{
return value
}
},
queryChartDate() {
let $temp=this;
let start = this.searchTime[0]?this.searchTime[0]:this.getTime(-1, 'h');
let end = this.searchTime[1]?this.searchTime[1]:this.getTime(0, 'h')
this.searchTime = [start, end];
let timeDiff = (new Date(end).getTime()-new Date(start).getTime())/1000/(24*60*60);
let step = '15s';
if(timeDiff< 1){
step='15s';
}else if(timeDiff < 7){
step='5m';
}else if(timeDiff<30){
step='10m';
}else{
step='30m';
}
this.$refs.messageChart.startLoading();
let axiosArr=[];
let paramStr = JSON.stringify(this.promQueryParamConvert(this.currentMsg));
axiosArr.push(axios.get("/prom/api/v1/query_range?query="+paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")+"&start="+this.$stringTimeParseToUnix(start)+"&end="+this.$stringTimeParseToUnix(end)+"&step="+step));
this.legend = [];
this.chartDatas = [];
axios.all(axiosArr).then(res =>{
try {
res.forEach((response, promIndex) => {
if (response.status == 200) {
if (response.data.status == 'success') {
let queryData = response.data.data.result[0];
if (queryData) {
let chartData = {
type: "line",
symbol: 'none', //去掉点
smooth: 0.2, //曲线变平滑
name: '',
lineStyle: {
width: 1,
opacity: 0.9
},
markLine: {
silent: true,
symbol: ['circle', 'circle'],
label: {
distance: this.computeDistance(chartDataFormat.getUnit(this.currentMsg.alertRule.unit ? this.currentMsg.alertRule.unit : 2).compute(this.currentMsg.alertRule.threshold)),
formatter: function (params) {
return chartDataFormat.getUnit($temp.currentMsg.alertRule.unit ? $temp.currentMsg.alertRule.unit : 2).compute(params.value)
}
},
lineStyle: {
color:'#d64f40',
width:2,
type:'dotted'
},
data: [{
yAxis: Number(this.currentMsg.alertRule.threshold)
}, ]
},
markArea:{
itemStyle:{
color:'#d64f40',
opacity:0.1
},
2020-06-05 19:16:01 +08:00
data:[this.returnMarkArea()]
}
};
if(this.currentMsg.alertRule.operator=='=='||this.currentMsg.alertRule.operator=='!='){
delete chartData.markArea;
}
chartData.name += "{";
alias += "{";
Object.keys(queryData.metric).forEach((item, index) => {
let label = item;
let value = queryData.metric[label];
chartData.name += label + "='" + value + "',";
});
chartData.name = chartData.name.charAt(chartData.name.length - 1) == "," ? chartData.name.substr(0, chartData.name.length - 1) : chartData.name;
chartData.name += "}";
let alias = chartData.name;
let legend = {
name: chartData.name,
alias: alias,
isGray: false
}
this.legend.push(legend);
chartData.data = queryData.values.map((dpsItem, dpsIndex) => {
return [bus.computeTimezone(dpsItem[0]) * 1000, parseFloat(dpsItem[1]).toFixed(2)];
});
this.chartDatas.push(chartData);
}
} else {
this.$message.error(response.data.error)
console.error(response.data)
2020-05-13 18:23:10 +08:00
}
}
});
this.$nextTick(() => {
this.$refs.messageChart.setRandomColors(this.chartDatas.length);
this.$refs.messageChart.setLegend(this.legend);
this.$refs.messageChart.setSeries(this.chartDatas);
this.$refs.messageChart.endLoading();
});
} catch(err) {
this.$message.error(err);
this.$refs.messageChart.endLoading();
}
})
},
computeDistance:function(str){
var width = 0;
var html = document.createElement('span');
html.innerText = str;
html.className = 'getTextWidth';
document.querySelector('body').appendChild(html);
width = document.querySelector('.getTextWidth').offsetWidth;
document.querySelector('.getTextWidth').remove();
return Number('-'+(width+5));
},
2020-06-05 19:16:01 +08:00
returnMarkArea:function(){
if(this.currentMsg){
if(this.currentMsg.alertRule.operator=='>'||this.currentMsg.alertRule.operator=='>='){
return[{yAxis:this.currentMsg.alertRule.threshold},{}]
}else{
return[{},{yAxis:this.currentMsg.alertRule.threshold}]
}
}
},
detail(obj) {
this.chartDatas = [];
this.legend = [];
this.graphShow = true;
this.currentMsg = obj;
this.chartUnit=obj.alertRule.unit?obj.alertRule.unit:5;
this.$nextTick(() => {
this.queryChartDate();
});
},
dialogClose() {
this.graphShow = false;
},
getAlertList: function () {
this.$set(this.searchLabel, "pageNo", this.pageObj.pageNo);
this.$set(this.searchLabel, "pageSize", this.pageObj.pageSize);
this.loading = true;
this.$get('alert/message', this.searchLabel).then(response => {
this.loading = false;
if (response.code == 200) {
this.tableData = response.data.list;
this.tableData.forEach((item) => {
item.labels = JSON.parse(item.labels);
2020-05-13 18:23:10 +08:00
let paramStr = JSON.stringify(this.promQueryParamConvert(item));
this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => {
let current = [];
if (response2.data && response2.data.result && response2.data.result.length > 0) {
current = response2.data.result[0].value.map((item, i) => {
if (i == 0) {
return bus.computeTimezone(item);
} else {
return parseFloat(item).toFixed(2);
}
});
}else{
2020-06-04 19:19:50 +08:00
current=[null,null]
}
this.requestIndex+=1;
item.current=current;
if(this.requestIndex===this.tableData.length){
this.$set(item, "current", current);
this.requestIndex=0;
}
});
});
2020-05-28 17:32:23 +08:00
this.deleteBox.ids='';
this.pageObj.total = response.data.total;
}
});
},
promQueryParamConvert(obj){
let result="(" + obj.alertRule.expr + ")";
if(obj.labels){
if(obj.labels.alertname){
delete obj.labels.alertname;
}
if(obj.labels.severity){
delete obj.labels.severity;
}
}
if(Object.keys(obj.labels).length>0){
result+=" and ("+function(){
let q = "{";
for (let k in obj.labels) {
2020-05-13 18:23:10 +08:00
q += k;
q += "=";
q += ("'" + obj.labels[k] + "',");
};
if (q.length > 1) {
q = q.substring(0, q.length-1);
2020-05-13 18:23:10 +08:00
}
q += "}";
return q;
}() + ")";
}
return result;
},
//asset弹框控制
tabControl(data) {
if (data === 'close') {
this.viewAssetState = false
this.$refs['assetEditUnit'].tabView = false
}
},
toDeleteMessage(obj) {
if (obj) {
this.deleteBox.ids = obj.id + "";
}
2020-04-09 12:19:21 +08:00
this.deleteBox.show = true;
},
deleteMessage(deleteBox) {
this.$put("alert/message", deleteBox).then(res => {
2020-04-09 12:19:21 +08:00
if (res.code === 200) {
this.$message({duration: 2000, type: 'success', message: this.$t("tip.deleteSuccess")});
this.getAlertList();
} else {
this.$message.error(res.msg);
}
})
},
selectChange(s) {
let ids = [];
this.deleteBox.ids = "";
2020-04-09 12:19:21 +08:00
s.forEach(item => {
ids.push(item.id);
2020-04-09 12:19:21 +08:00
});
this.deleteBox.ids = ids.join(",");
2020-04-09 12:19:21 +08:00
},
2020-04-08 20:27:07 +08:00
showExportDialog() {
this.importBox.show = true;
},
closeDialog() {
this.importBox.show = false;
2020-04-09 12:19:21 +08:00
this.deleteBox.show = false;
2020-04-08 20:27:07 +08:00
},
exportCur:function(){
this.exportExcel(this.searchLabel);
this.closeDialog();
},
exportAll:function(){
2020-04-09 12:19:21 +08:00
let temp = JSON.parse(JSON.stringify(this.searchLabel));
temp.pageSize = -1;
this.exportExcel(temp);
2020-04-08 20:27:07 +08:00
this.closeDialog();
},
getTimeString:function(){
let split='-';
let date=new Date();
let year=date.getFullYear();
let month=this.formatNum(date.getMonth()+1);
let day=this.formatNum(date.getDate());
let hours=this.formatNum(date.getHours());
let minutes=this.formatNum(date.getMinutes());
let seconds=this.formatNum(date.getSeconds());
return year + split + month + split + day + ' ' + hours + split + minutes + split + seconds;
},
formatNum:function(num){
return num>9?num:'0'+num;
},
2020-04-08 20:27:07 +08:00
exportExcel:function(params){
for (let item in params) {
if (params[item]) {
if (item == "alertMessageState") {
this.$set(params, "state", params[item]);
} else{
this.$set(params, item, params[item]);
}
}
}
2020-04-08 20:27:07 +08:00
let temp=this;
if(!params){
params=temp.params;
}
axios.get("alert/message/export", {responseType:'blob', params: params}).then(res=>{
let fileName = 'alert-message-'+temp.getTimeString()+'.xlsx';
if(window.navigator.msSaveOrOpenBlob){
// 兼容ie11
let blobObject = new Blob([res.data]);
window.navigator.msSaveOrOpenBlob(blobObject, fileName);
}else{
let url = URL.createObjectURL(new Blob([res.data]));
let a = document.createElement('a');
document.body.appendChild(a); //此处增加了将创建的添加到body当中
a.href = url;
a.download = fileName;
a.target = '_blank';
a.click();
a.remove(); //将a标签移除
}
})
},
// 全屏
fullScreen() {
this.$bottomBoxWindow.fullScreen(vm);
},
// 退出全屏
exitFullScreen() {
this.$bottomBoxWindow.exitFullScreen(vm);
},
// 鼠标拖动二级列表
listResize(e) {
this.$bottomBoxWindow.listResize(vm, e);
},
showTagDetail(data, key) {
let open = false;
if (key == "asset" || key == "project" || key == "module" || key == "endpoint" || key == "datacenter") {
open = true;
}
if (open) {
let labelList = [];
let detailList = [];
for (let item in data) {
if (item == "asset" || item == "project" || item == "module" || item == "endpoint" || item == "dc") {
labelList.push(item);
detailList.push(data[item]);
}
}
this.showSubList = true;
this.tabList = labelList;
/*this.tabDetailList = detailList;
this.targetTab = key;*/
}
},
labelsClassName(row) {
if (row.column.label == this.$t("alert.list.labels")) {
return "alert-message-list-labels";
} else {
return "";
}
},
jumpTo(data, id) {
bus.$emit("menu-change", data);
this.$store.state.assetData.moduleData = data
this.$store.state.assetData.selectedData = id
this.$router.push({
path: "/" + data,
query: {
t: +new Date()
}
});
},
pageNo(val) {
this.pageObj.pageNo = val;
this.getAlertList();
},
pageSize(val) {
this.pageObj.pageSize = val;
localStorage.setItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId, val);
this.getAlertList();
},
search: function (searchObj) {
let orderBy='';
if(this.searchLabel.orderBy){
orderBy=this.searchLabel.orderBy
}
this.searchLabel = {};
this.pageObj.pageNo = 1;
for (let item in searchObj) {
if (searchObj[item]) {
if (item == "alertMessageState") {
this.$set(this.searchLabel, "state", searchObj[item]);
} else{
this.$set(this.searchLabel, item, searchObj[item]);
}
}
}
if(orderBy){
this.$set(this.searchLabel, 'orderBy', orderBy);
}
this.getAlertList();
},
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:
this.viewProjectData = JSON.parse(JSON.stringify(typeObj));
this.$refs.projectBox.show(true);
break;
case 2:
// this.fillProject(typeObj);
let tempObj = JSON.parse(typeObj.param)
this.$set(typeObj, 'paramObj', []);
for (let k in tempObj) {
typeObj.paramObj.push({key: k, value: tempObj[k]});
}
this.viewModuleData = JSON.parse(JSON.stringify(typeObj));
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;
},
//是否需要排序
sortableShow(prop){
switch(prop){
case 'id':
case 'state':
case 'alertRule':
case 'severity':
case 'startAt':
case 'endAt':
return'custom';
default : return false;
}
},
// prop字段
propTitle(prop){
switch(prop){
case 'id': return'am.id';
case 'state': return'am.state';
case 'alertRule': return'ar.alert_name';
case 'severity': return'am.severity';
case 'startAt': return'am.start_at';
case 'endAt': return'am.end_at';
default : return prop;
}
},
// 数据排序
tableDataSort(item){
let orderBy='';
if(item.order==='ascending'){
orderBy=item.prop;
}
if(item.order==='descending'){
orderBy='-'+item.prop;
}
this.pageObj.orderBy=orderBy;
this.$set(this.searchLabel, "orderBy", orderBy);
this.getAlertList();
},
// label tooltip是否显示
labelToolTipDis(labelType){
switch(labelType){
case 'asset':
case 'module':
case 'project':
return false;
default: return true;
}
},
// alertNmae鼠标划入
alertMessagehover(item,index){
item.loading=true;
this.$set(this.tableData,index,item);
},
// label 鼠标划入
labelHover(item,index,type){
if(this.labelToolTipDis(type)){
return
}
item[type].loading=true;
this.$set(this.tableData,index,item);
}
},
watch: {
showSubList(n) {
this.$bottomBoxWindow.showSubListWatch(vm, n);
},
},
mounted() {
//是否存在分页缓存
let pageSize = localStorage.getItem('nz-pageSize-' + localStorage.getItem('nz-username') + '-' + this.tableId);
if (pageSize != 'undefined' && pageSize != null) {
this.pageObj.pageSize = pageSize
}
this.getAlertList();
this.$nextTick(() => {
//绑定滚动条事件控制top按钮
let el = this.$refs.alertListTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 50) {
this.showTopBtn = true;
} else {
this.showTopBtn = false;
}
});
el.addEventListener("mouseenter", () => {
this.tableHover = true;
});
el.addEventListener("mouseleave", () => {
this.tableHover = false;
});
}
});
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;
}
}
</script>