feat:内置告警规则产生的告警信息不查询当前值

This commit is contained in:
wangwenrui
2020-10-15 10:03:08 +08:00
parent 3ba62acd44
commit bf41d48255
3 changed files with 59 additions and 49 deletions

View File

@@ -133,7 +133,7 @@
{{scope.row['state'] == 2 ? "Expired" : ""}} {{scope.row['state'] == 2 ? "Expired" : ""}}
</span> </span>
<div v-else-if="item.prop == 'current'" class="too-long-split pointer" @click="detail(scope.row)"> <div v-else-if="item.prop == 'current'" class="too-long-split pointer" @click="detail(scope.row)">
<span v-if="!scope.row.current">-</span> <span v-if="!scope.row.current || scope.row.alertRule.buildIn == 1">-</span>
<el-popover v-else placement="right" trigger="hover"> <el-popover v-else placement="right" trigger="hover">
<div slot="reference"> <div slot="reference">
<span class="content-right-option" :id="'alert-list-detail-'+scope.row.id"><i class="nz-icon nz-icon-chart"></i></span> <span class="content-right-option" :id="'alert-list-detail-'+scope.row.id"><i class="nz-icon nz-icon-chart"></i></span>
@@ -614,12 +614,15 @@
this.deleteBox.show = false; this.deleteBox.show = false;
}, },
exportCur:function(){ exportCur:function(){
this.exportExcel(this.searchLabel); let searchLabel=Object.assign({},this.searchLabel)
this.$set(searchLabel,'language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.exportExcel(searchLabel);
this.closeDialog(); this.closeDialog();
}, },
exportAll:function(){ exportAll:function(){
let temp = JSON.parse(JSON.stringify(this.searchLabel)); let temp = JSON.parse(JSON.stringify(this.searchLabel));
temp.pageSize = -1; temp.pageSize = -1;
this.$set(temp,'language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.exportExcel(temp); this.exportExcel(temp);
this.closeDialog(); this.closeDialog();
}, },

View File

@@ -307,7 +307,16 @@
}) })
}, },
exportCur:function(){ exportCur:function(){
this.exportExcel(this.searchLabel); let searchLabel=Object.assign({},this.searchLabel)
this.$set(searchLabel,'language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.exportExcel(searchLabel);
this.importBox.show = false;
},
exportAll:function(){
let temp = JSON.parse(JSON.stringify(this.searchLabel));
temp.pageSize = -1;
this.$set(temp,'language',localStorage.getItem("nz-language") ? localStorage.getItem("nz-language") : 'en')
this.exportExcel(temp);
this.importBox.show = false; this.importBox.show = false;
}, },
getTimeString:function(){ getTimeString:function(){
@@ -324,12 +333,6 @@
formatNum:function(num){ formatNum:function(num){
return num>9?num:'0'+num; return num>9?num:'0'+num;
}, },
exportAll:function(){
let temp = JSON.parse(JSON.stringify(this.searchLabel));
temp.pageSize = -1;
this.exportExcel(temp);
this.importBox.show = false;
},
exportExcel:function(params){ exportExcel:function(params){
let temp=this; let temp=this;
if(!params){ if(!params){
@@ -485,25 +488,27 @@
this.tableData = response.data.list; this.tableData = response.data.list;
this.tableData.forEach((item) => { this.tableData.forEach((item) => {
item.labels = JSON.parse(item.labels); item.labels = JSON.parse(item.labels);
let paramStr = JSON.stringify(this.promQueryParamConvert(item)); if(item.alertRule.buildIn != 1) {
this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => { let paramStr = JSON.stringify(this.promQueryParamConvert(item));
let current = []; this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length - 1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => {
if (response2.data && response2.data.result && response2.data.result.length > 0) { let current = [];
current = response2.data.result[0].value.map((item, i) => { if (response2.data && response2.data.result && response2.data.result.length > 0) {
if (i == 0) { current = response2.data.result[0].value.map((item, i) => {
return bus.computeTimezone(item); if (i == 0) {
} else { return bus.computeTimezone(item);
return parseFloat(item).toFixed(2); } else {
} return parseFloat(item).toFixed(2);
}); }
} });
this.requestIndex+=1; }
item.current=current; this.requestIndex += 1;
if(this.requestIndex===this.tableData.length){ item.current = current;
this.$set(item, "current", current); if (this.requestIndex === this.tableData.length) {
this.requestIndex=0; this.$set(item, "current", current);
} this.requestIndex = 0;
}); }
});
}
}); });
this.pageObj.total = response.data.total; this.pageObj.total = response.data.total;
this.loading = false; this.loading = false;

View File

@@ -348,27 +348,29 @@
this.$nextTick(() => { this.$nextTick(() => {
this.tableData.forEach((item) => { this.tableData.forEach((item) => {
item.labels = JSON.parse(item.labels); item.labels = JSON.parse(item.labels);
let paramStr = JSON.stringify(this.promQueryParamConvert(item)); if(item.alertRule.buildIn != 1){
this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => { let paramStr = JSON.stringify(this.promQueryParamConvert(item));
let current = []; this.$get('/prom/api/v1/query?query=' + paramStr.substring(1, paramStr.length-1).replace(/\+/g, "%2B").replace(/ /g, "%20").replace(/\\/g, "")).then(response2 => {
if (response2.data && response2.data.result && response2.data.result.length > 0) { let current = [];
current = response2.data.result[0].value.map((item, i) => { if (response2.data && response2.data.result && response2.data.result.length > 0) {
if (i == 0) { current = response2.data.result[0].value.map((item, i) => {
return bus.computeTimezone(item); if (i == 0) {
} else { return bus.computeTimezone(item);
return parseFloat(item).toFixed(2); } else {
} return parseFloat(item).toFixed(2);
}); }
}else{ });
current=[null,null] }else{
} current=[null,null]
this.requestIndex+=1; }
item.current=current; this.requestIndex+=1;
if(this.requestIndex===this.tableData.length){ item.current=current;
this.$set(item, "current", current); if(this.requestIndex===this.tableData.length){
this.requestIndex=0; this.$set(item, "current", current);
} this.requestIndex=0;
}); }
});
}
}); });
}); });
this.deleteBox.ids=''; this.deleteBox.ids='';