perf: 尝试修复pl-table在resize时高度不对的问题
This commit is contained in:
@@ -30,7 +30,7 @@
|
|||||||
v-if="targetTab == 'assetDetail' && from == 'endpoint'"
|
v-if="targetTab == 'assetDetail' && from == 'endpoint'"
|
||||||
@changeTab="changeTab"></common-detail-tab>
|
@changeTab="changeTab"></common-detail-tab>
|
||||||
<!--endpoint-query-->
|
<!--endpoint-query-->
|
||||||
<endpoint-query-tab v-show="subResizeShow" v-if="(from == 'endpoint' && targetTab == 'endpointQuery')" :from="from" :obj="obj" @changeTab="changeTab"></endpoint-query-tab>
|
<endpoint-query-tab v-show="subResizeShow" v-if="(from == 'endpoint' && targetTab == 'endpointQuery')" :from="from" :obj="obj" @changeTab="changeTab" ref="endpointQuery"></endpoint-query-tab>
|
||||||
|
|
||||||
<!--alertMessage页的详情-->
|
<!--alertMessage页的详情-->
|
||||||
<template v-if="from == 'alertMessage'">
|
<template v-if="from == 'alertMessage'">
|
||||||
@@ -76,19 +76,26 @@
|
|||||||
methods: {
|
methods: {
|
||||||
exitFullScreen() {
|
exitFullScreen() {
|
||||||
this.$emit("exitFullScreen");
|
this.$emit("exitFullScreen");
|
||||||
|
this.$nextTick(this.afterResize());
|
||||||
},
|
},
|
||||||
fullScreen() {
|
fullScreen() {
|
||||||
this.$emit("fullScreen");
|
this.$emit("fullScreen");
|
||||||
|
this.$nextTick(this.afterResize());
|
||||||
},
|
},
|
||||||
closeSubList() {
|
closeSubList() {
|
||||||
this.$emit("closeSubList");
|
this.$emit("closeSubList");
|
||||||
},
|
},
|
||||||
listResize(e) {
|
listResize(e) {
|
||||||
this.$emit('listResize', e);
|
this.$emit('listResize', e);
|
||||||
|
this.$nextTick(this.afterResize());
|
||||||
},
|
},
|
||||||
changeTab(tab) {
|
changeTab(tab) {
|
||||||
this.$emit('update:targetTab', tab);
|
this.$emit('update:targetTab', tab);
|
||||||
//this.targetTab = tab;
|
},
|
||||||
|
afterResize() {
|
||||||
|
if (this.from == 'endpoint' && this.targetTab == 'endpointQuery') {
|
||||||
|
this.$refs.endpointQuery.tableReload();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@
|
|||||||
<div class="table-header-inner" @click="clearSelectedMetrics"><span><i style="font-size: 12px;margin-left: 2px;" class="nz-icon nz-icon-close " :class="{'control-icon-unchecked':selectedEndpoints.length<1,'control-icon-checked':selectedEndpoints.length>0}"></i></span></div>
|
<div class="table-header-inner" @click="clearSelectedMetrics"><span><i style="font-size: 12px;margin-left: 2px;" class="nz-icon nz-icon-close " :class="{'control-icon-unchecked':selectedEndpoints.length<1,'control-icon-checked':selectedEndpoints.length>0}"></i></span></div>
|
||||||
<pl-table :row-height="28" use-virtual :datas="tableData" border :empty-text="$t('config.mib.noData')" :header-cell-class-name="cellClass" :style="{height: $tableHeight.noPagination}"
|
<pl-table :row-height="28" use-virtual :datas="tableData" border :empty-text="$t('config.mib.noData')" :header-cell-class-name="cellClass" :style="{height: $tableHeight.noPagination}"
|
||||||
class="nz-table endpoint-query-table" style="width: 100%;" v-loading="loading" v-scrollBar:el-table="'large'" :pagination-show="false" ref="endpointQueryTable"
|
class="nz-table endpoint-query-table" style="width: 100%;" v-loading="loading" v-scrollBar:el-table="'large'" :pagination-show="false" ref="endpointQueryTable"
|
||||||
@selection-change="selectChange">
|
@selection-change="selectChange" v-if="tableShow">
|
||||||
<pl-table-column
|
<pl-table-column
|
||||||
:resizable="false"
|
:resizable="false"
|
||||||
type="selection"
|
type="selection"
|
||||||
@@ -193,6 +193,7 @@
|
|||||||
data() {
|
data() {
|
||||||
let temp = this;
|
let temp = this;
|
||||||
return {
|
return {
|
||||||
|
tableShow: true,
|
||||||
tableHover: false,
|
tableHover: false,
|
||||||
dropdownShow: false,
|
dropdownShow: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
@@ -263,6 +264,14 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
tableReload() {
|
||||||
|
this.tableShow = false;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.tableShow = true;
|
||||||
|
//this.queryEndpoint();
|
||||||
|
}, 300);
|
||||||
|
//this.$nextTick(() => {this.tableShow = true});
|
||||||
|
},
|
||||||
queryEndpoint() {
|
queryEndpoint() {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.queryElementTips();
|
this.queryElementTips();
|
||||||
@@ -270,78 +279,77 @@
|
|||||||
this.tableData = [];
|
this.tableData = [];
|
||||||
this.tableDataCopy = '';
|
this.tableDataCopy = '';
|
||||||
this.$get("/prom/api/v1/query?query={endpoint='" + this.currentEndpoint.id + "'}&time=" + this.formatTime).then(response=>{
|
this.$get("/prom/api/v1/query?query={endpoint='" + this.currentEndpoint.id + "'}&time=" + this.formatTime).then(response=>{
|
||||||
setTimeout(() => {
|
this.loading = false;
|
||||||
this.loading = false;
|
if(response.status==="success"){
|
||||||
if(response.status==="success"){
|
let results = response.data.result;
|
||||||
let results = response.data.result;
|
this.queryData=JSON.parse(JSON.stringify(results));
|
||||||
this.queryData=JSON.parse(JSON.stringify(results));
|
for(let result of results) {
|
||||||
for(let result of results) {
|
let metricName = result.metric.__name__;
|
||||||
let metricName = result.metric.__name__;
|
let temp = metricName;
|
||||||
let temp = metricName;
|
let simpleTemp = metricName;//显示简略信息:隐藏same labels后的结果
|
||||||
let simpleTemp = metricName;//显示简略信息:隐藏same labels后的结果
|
let metricColor = "";
|
||||||
let metricColor = "";
|
let bracketsColor = "#eb7b18";//#eb7b18
|
||||||
let bracketsColor = "#eb7b18";//#eb7b18
|
let labelColor = "#65bbd1";//#66d9ef
|
||||||
let labelColor = "#65bbd1";//#66d9ef
|
let valueColor = "#61c261";//#74e680
|
||||||
let valueColor = "#61c261";//#74e680
|
let colorTemp = `<span style="${metricColor}">${metricName}</span>`;
|
||||||
let colorTemp = `<span style="${metricColor}">${metricName}</span>`;
|
let colorSimpleTemp = `<span>${metricName}</span>`;
|
||||||
let colorSimpleTemp = `<span>${metricName}</span>`;
|
let metricTip = {};
|
||||||
let metricTip = {};
|
let queryInfos = (this.elementMetricDatas.filter((item)=> {
|
||||||
let queryInfos = (this.elementMetricDatas.filter((item)=> {
|
return item.metric === temp;
|
||||||
return item.metric === temp;
|
}));
|
||||||
}));
|
if(queryInfos && queryInfos.length > 0) {
|
||||||
if(queryInfos && queryInfos.length > 0) {
|
metricTip = queryInfos[0];
|
||||||
metricTip = queryInfos[0];
|
} else {
|
||||||
} else {
|
metricTip.metric=temp;
|
||||||
metricTip.metric=temp;
|
|
||||||
}
|
|
||||||
delete result.metric.__name__;
|
|
||||||
temp += "{";
|
|
||||||
simpleTemp += "{";
|
|
||||||
colorTemp += `<span style="color: ${bracketsColor}">{</span>`;
|
|
||||||
colorSimpleTemp += `<span style="color: ${bracketsColor}">{</span>`;
|
|
||||||
let keys = Object.keys(result.metric);
|
|
||||||
for (let index in keys){
|
|
||||||
let key = keys[index];
|
|
||||||
temp += key + "='" + result.metric[key] + "',";
|
|
||||||
colorTemp += `<span style="color: ${labelColor}">${key}</span>=<span style="color: ${valueColor}">'${result.metric[key]}'</span>,`;
|
|
||||||
if(!this.sameLabels.some((i)=> {return i == key})) {
|
|
||||||
simpleTemp += key + "='" + result.metric[key] + "',";
|
|
||||||
colorSimpleTemp += `<span style="color: ${labelColor}">${key}</span>=<span style="color: ${valueColor}">'${result.metric[key]}'</span>,`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(temp.indexOf(',') != -1){
|
|
||||||
temp = temp.substr(0,temp.length-1);
|
|
||||||
}
|
|
||||||
if(simpleTemp.indexOf(',') != -1){
|
|
||||||
simpleTemp = simpleTemp.substr(0,simpleTemp.length-1);
|
|
||||||
}
|
|
||||||
if(colorTemp.indexOf(',') != -1){
|
|
||||||
colorTemp = colorTemp.substr(0,colorTemp.length-1);
|
|
||||||
}
|
|
||||||
if(colorSimpleTemp.indexOf(',') != -1){
|
|
||||||
colorSimpleTemp = colorSimpleTemp.substr(0,colorSimpleTemp.length-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
temp += "}";
|
|
||||||
simpleTemp += "}";
|
|
||||||
colorTemp += `<span style="color: ${bracketsColor}">}</span>`;
|
|
||||||
colorSimpleTemp += `<span style="color: ${bracketsColor}">}</span>`;
|
|
||||||
if(!/.+\{.+\}/.test(simpleTemp)) {
|
|
||||||
simpleTemp = simpleTemp.substr(0,simpleTemp.length-2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!/.+\{<\/span><span.+?>.+?\}/.test(colorSimpleTemp)){
|
|
||||||
let metricReg=new RegExp("<span.*?>"+metricName+"<\/span>")
|
|
||||||
colorSimpleTemp=metricReg.exec(colorSimpleTemp)[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
let edpQueryData={element:temp,simpleElement:simpleTemp,colorElement:colorTemp,colorSimpleElement:colorSimpleTemp, value:result.value[1],type:(result.metric.type?result.metric.type:'2'),metricTip:metricTip};
|
|
||||||
this.tableData.push(edpQueryData);
|
|
||||||
}
|
}
|
||||||
this.tableDataCopy = JSON.stringify(this.tableData);
|
delete result.metric.__name__;
|
||||||
|
temp += "{";
|
||||||
|
simpleTemp += "{";
|
||||||
|
colorTemp += `<span style="color: ${bracketsColor}">{</span>`;
|
||||||
|
colorSimpleTemp += `<span style="color: ${bracketsColor}">{</span>`;
|
||||||
|
let keys = Object.keys(result.metric);
|
||||||
|
for (let index in keys){
|
||||||
|
let key = keys[index];
|
||||||
|
temp += key + "='" + result.metric[key] + "',";
|
||||||
|
colorTemp += `<span style="color: ${labelColor}">${key}</span>=<span style="color: ${valueColor}">'${result.metric[key]}'</span>,`;
|
||||||
|
if(!this.sameLabels.some((i)=> {return i == key})) {
|
||||||
|
simpleTemp += key + "='" + result.metric[key] + "',";
|
||||||
|
colorSimpleTemp += `<span style="color: ${labelColor}">${key}</span>=<span style="color: ${valueColor}">'${result.metric[key]}'</span>,`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(temp.indexOf(',') != -1){
|
||||||
|
temp = temp.substr(0,temp.length-1);
|
||||||
|
}
|
||||||
|
if(simpleTemp.indexOf(',') != -1){
|
||||||
|
simpleTemp = simpleTemp.substr(0,simpleTemp.length-1);
|
||||||
|
}
|
||||||
|
if(colorTemp.indexOf(',') != -1){
|
||||||
|
colorTemp = colorTemp.substr(0,colorTemp.length-1);
|
||||||
|
}
|
||||||
|
if(colorSimpleTemp.indexOf(',') != -1){
|
||||||
|
colorSimpleTemp = colorSimpleTemp.substr(0,colorSimpleTemp.length-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
temp += "}";
|
||||||
|
simpleTemp += "}";
|
||||||
|
colorTemp += `<span style="color: ${bracketsColor}">}</span>`;
|
||||||
|
colorSimpleTemp += `<span style="color: ${bracketsColor}">}</span>`;
|
||||||
|
if(!/.+\{.+\}/.test(simpleTemp)) {
|
||||||
|
simpleTemp = simpleTemp.substr(0,simpleTemp.length-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!/.+\{<\/span><span.+?>.+?\}/.test(colorSimpleTemp)){
|
||||||
|
let metricReg=new RegExp("<span.*?>"+metricName+"<\/span>")
|
||||||
|
colorSimpleTemp=metricReg.exec(colorSimpleTemp)[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
let edpQueryData={element:temp,simpleElement:simpleTemp,colorElement:colorTemp,colorSimpleElement:colorSimpleTemp, value:result.value[1],type:(result.metric.type?result.metric.type:'2'),metricTip:metricTip};
|
||||||
|
this.tableData.push(edpQueryData);
|
||||||
}
|
}
|
||||||
}, 300);
|
this.tableDataCopy = JSON.stringify(this.tableData);
|
||||||
|
this.$nextTick(this.$refs.endpointQueryTable.doLayout());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
clearSelectedMetrics() {
|
clearSelectedMetrics() {
|
||||||
@@ -675,7 +683,8 @@
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.getPanelData();
|
this.getPanelData();
|
||||||
this.$nextTick(() => {
|
//this.$nextTick(() => {
|
||||||
|
setTimeout(() => {
|
||||||
//绑定滚动条事件,控制top按钮
|
//绑定滚动条事件,控制top按钮
|
||||||
let el = this.$refs.endpointQueryTable.$el.querySelector(".el-table__body-wrapper");
|
let el = this.$refs.endpointQueryTable.$el.querySelector(".el-table__body-wrapper");
|
||||||
if (el._ps_) {
|
if (el._ps_) {
|
||||||
@@ -693,7 +702,9 @@
|
|||||||
this.tableHover = false;
|
this.tableHover = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
}, 300);
|
||||||
|
|
||||||
|
//});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user