perf: 尝试修复pl-table在resize时高度不对的问题

This commit is contained in:
陈劲松
2020-04-27 22:38:10 +08:00
parent 79cac9103a
commit df6f7cf04a
2 changed files with 93 additions and 75 deletions

View File

@@ -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();
}
} }
} }
} }

View File

@@ -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,7 +279,6 @@
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;
@@ -340,8 +348,8 @@
this.tableData.push(edpQueryData); this.tableData.push(edpQueryData);
} }
this.tableDataCopy = JSON.stringify(this.tableData); this.tableDataCopy = JSON.stringify(this.tableData);
this.$nextTick(this.$refs.endpointQueryTable.doLayout());
} }
}, 300);
}); });
}, },
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>