perf: 优化table右侧滚动条区域;页面增加top按钮;

1.优化table右侧滚动条区域(暂时只有asset、endpoint页)
2.所有列表页增加top按钮
This commit is contained in:
陈劲松
2020-03-05 21:30:45 +08:00
parent 19bda65ad7
commit 2543b2cb48
10 changed files with 220 additions and 14 deletions

View File

@@ -1174,3 +1174,30 @@ li{
.el-button--primary:hover{ .el-button--primary:hover{
background-color: rgba(255, 99, 71, .85); background-color: rgba(255, 99, 71, .85);
} }
/*滚动条相关减小table内滚动条的空间*/
.ps__rail-y:hover > .ps__thumb-y, .ps__rail-y:focus > .ps__thumb-y, .ps__rail-y.ps--clicking .ps__thumb-y {
width: 6px;
}
.ps__rail-x:hover > .ps__thumb-x, .ps__rail-x:focus > .ps__thumb-x, .ps__rail-x.ps--clicking .ps__thumb-x {
height: 6px;
}
.ps .ps__rail-x:hover, .ps .ps__rail-y:hover, .ps .ps__rail-x:focus, .ps .ps__rail-y:focus, .ps .ps__rail-x.ps--clicking, .ps .ps__rail-y.ps--clicking {
background-color: transparent;
}
.ps__rail-y {
width: 6px;
}
.ps__rail-x {
height: 6px;
}
.el-table__fixed-right {
right: 10px !important;
}
.el-table__fixed-right-patch {
width: 10px !important;
background-color: #fcfcfc;
}
.el-table__fixed-body-wrapper {
height: calc(100% - 42px) !important;
}

View File

@@ -33,6 +33,7 @@
class="nz-table" class="nz-table"
:data="tableData" :data="tableData"
border border
ref="alertRuleTable"
tooltip-effect="light" tooltip-effect="light"
height="calc(100% - 125px)" height="calc(100% - 125px)"
v-scrollBar:el-table v-scrollBar:el-table
@@ -84,6 +85,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn" @click="toTop">TOP</button>
</div> </div>
<alert-config-box :parentAlertRule="alertRule" @reload="getTableData" ref="alertConfigBox"></alert-config-box> <alert-config-box :parentAlertRule="alertRule" @reload="getTableData" ref="alertConfigBox"></alert-config-box>
<project-box :project="viewProjectData" ref="projectBox" @reload="getTableData"></project-box> <project-box :project="viewProjectData" ref="projectBox" @reload="getTableData"></project-box>
@@ -105,6 +107,7 @@
name: "alert-config", name: "alert-config",
data() { data() {
return { return {
showTopBtn: false,
searchMsg: { //给搜索框子组件传递的信息 searchMsg: { //给搜索框子组件传递的信息
zheze_none: true, zheze_none: true,
searchLabelList: [{ searchLabelList: [{
@@ -405,6 +408,19 @@
}, },
mounted() { mounted() {
this.getTableData(); this.getTableData();
this.$nextTick(() => {
//绑定滚动条事件控制top按钮
let el = this.$refs.alertRuleTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 100) {
this.showTopBtn = true;
} else {
this.showTopBtn = false;
}
});
}
});
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) 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)) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
: this.tableTitle; : this.tableTitle;

View File

@@ -25,6 +25,7 @@
class="nz-table" class="nz-table"
:data="tableData" :data="tableData"
border border
ref="alertListTable"
tooltip-effect="light" tooltip-effect="light"
height="calc(100% - 125px)" height="calc(100% - 125px)"
v-scrollBar:el-table v-scrollBar:el-table
@@ -91,6 +92,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn" @click="toTop()">TOP</button>
</div> </div>
<alert-config-box :parentAlertRule="viewRuleData" @reload="getAlertList" ref="alertConfigBox"></alert-config-box> <alert-config-box :parentAlertRule="viewRuleData" @reload="getAlertList" ref="alertConfigBox"></alert-config-box>
<project-box :project="viewProjectData" ref="projectBox" @reload="getAlertList"></project-box> <project-box :project="viewProjectData" ref="projectBox" @reload="getAlertList"></project-box>
@@ -112,6 +114,7 @@
name: "alertList", name: "alertList",
data() { data() {
return { return {
showTopBtn: false,
pageObj: { pageObj: {
pageNo: 1, pageNo: 1,
pageSize: 20, pageSize: 20,
@@ -353,6 +356,19 @@
}, },
mounted() { mounted() {
this.getAlertList(); 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 > 100) {
this.showTopBtn = true;
} else {
this.showTopBtn = false;
}
});
}
});
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) 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)) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
: this.tableTitle; : this.tableTitle;

View File

@@ -56,6 +56,7 @@
v-scrollBar:el-table v-scrollBar:el-table
border border
tooltip-effect="light" tooltip-effect="light"
ref="assetTable"
> >
<el-table-column <el-table-column
:resizable="false" :resizable="false"
@@ -179,7 +180,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<!--<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light">TOP</button>--> <button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn" @click="toTop">TOP</button>
</div> </div>
<!--<asset-add-unit :add-unit-show='addUnitShow' @refreshData="flushData" ref="assetAddUnit" <!--<asset-add-unit :add-unit-show='addUnitShow' @refreshData="flushData" ref="assetAddUnit"
@@ -249,6 +250,7 @@
disabled: false disabled: false
}], }],
}, },
showTopBtn: false,
searchLabel: {}, //搜索参数 searchLabel: {}, //搜索参数
checkList: [], checkList: [],
tablelable: [], tablelable: [],
@@ -503,6 +505,10 @@
}); });
window.open(routeData.href); window.open(routeData.href);
}, },
/*toTop() {
let el = document.querySelector(".el-table__body-wrapper");
el.scrollTop = 0;
},*/
cli(id,host,accounts){ cli(id,host,accounts){
let port = ''; let port = '';
let accountId = ''; let accountId = '';
@@ -764,6 +770,17 @@
this.checkList = []; this.checkList = [];
this.checkList = this.$store.state.assetData.selectedData; this.checkList = this.$store.state.assetData.selectedData;
} }
//绑定滚动条事件控制top按钮
let el = this.$refs.assetTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 100) {
this.showTopBtn = true;
} else {
this.showTopBtn = false;
}
});
}
}); });
let localStorageTitle=localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path); let localStorageTitle=localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path);
this.tablelable = localStorageTitle ? JSON.parse(localStorageTitle) : this.tableTitle; this.tablelable = localStorageTitle ? JSON.parse(localStorageTitle) : this.tableTitle;

View File

@@ -34,6 +34,7 @@
class="nz-table" class="nz-table"
:data="tableData" :data="tableData"
border border
ref="accountTable"
height="calc(100% - 125px)" height="calc(100% - 125px)"
v-scrollBar:el-table v-scrollBar:el-table
style="width: 100%;"> style="width: 100%;">
@@ -83,6 +84,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn" @click="toTop">TOP</button>
</div> </div>
<transition name="right-box"> <transition name="right-box">
@@ -172,6 +174,7 @@
name: "account", name: "account",
data() { data() {
return { return {
showTopBtn: false,
rightBox: { //弹出框相关 rightBox: { //弹出框相关
show: false, show: false,
isEdit: false, //false查看true编辑 isEdit: false, //false查看true编辑
@@ -509,6 +512,19 @@
mounted() { mounted() {
this.getTableData(); this.getTableData();
this.initReceiverData(); this.initReceiverData();
this.$nextTick(() => {
//绑定滚动条事件控制top按钮
let el = this.$refs.accountTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 100) {
this.showTopBtn = true;
} else {
this.showTopBtn = false;
}
});
}
});
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) 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)) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
: this.tableTitle; : this.tableTitle;

View File

@@ -66,7 +66,8 @@
:data="tableData" :data="tableData"
border border
v-scrollBar:el-table v-scrollBar:el-table
height="calc(100% - 160px)" height="calc(100% - 125px)"
ref="dcTable"
style="width: 100%;"> style="width: 100%;">
<el-table-column <el-table-column
:resizable="false" :resizable="false"
@@ -125,6 +126,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn1" @click="toTop">TOP</button>
<!--dc table end--> <!--dc table end-->
<element-set <element-set
v-clickoutside="elementsetHide" v-clickoutside="elementsetHide"
@@ -160,6 +162,7 @@
class="nz-table" class="nz-table"
:data="cabinetDatas" :data="cabinetDatas"
border border
ref="cabTable"
v-scrollBar:el-table v-scrollBar:el-table
height="calc(100% - 125px)" height="calc(100% - 125px)"
style="width: 100%;"> style="width: 100%;">
@@ -214,6 +217,7 @@
</div> </div>
<!--cabinet table end--> <!--cabinet table end-->
<cabinet-box :cur-cabinet="curCabinet" :cur-idc="currentShowDc" ref="cabinetEditBox" @after="getCabinetDatas"></cabinet-box> <cabinet-box :cur-cabinet="curCabinet" :cur-idc="currentShowDc" ref="cabinetEditBox" @after="getCabinetDatas"></cabinet-box>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn2" @click="toTop">TOP</button>
</div> </div>
</template> </template>
<script> <script>
@@ -225,6 +229,8 @@
}, },
data() { data() {
return { return {
showTopBtn1: false,
showTopBtn2: false,
currentDc: { currentDc: {
id: '', id: '',
name: '', name: '',
@@ -556,7 +562,28 @@
mounted() { mounted() {
this.getTableData(); this.getTableData();
this.$nextTick(function(){ this.$nextTick(function(){
this.getUserData(); this.getUserData();//绑定滚动条事件控制top按钮
let el = this.$refs.dcTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 100) {
this.showTopBtn1 = true;
} else {
this.showTopBtn1 = false;
}
});
}
let el2 = this.$refs.cabTable.$el.querySelector(".el-table__body-wrapper");
if (el2._ps_) {
el2.addEventListener("ps-scroll-y", () => {
if (el2._ps_.scrollbarYTop > 100) {
this.showTopBtn2 = true;
} else {
this.showTopBtn2 = false;
}
});
}
}); });
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) 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)) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))

View File

@@ -30,7 +30,7 @@
</div> </div>
</div> </div>
</div> </div>
<el-table :data="tableData" border height="calc(100% - 125px)" style="width: 100%;" class="nz-table" v-scrollBar:el-table> <el-table :data="tableData" border height="calc(100% - 125px)" style="width: 100%;" ref="promTable" class="nz-table" v-scrollBar:el-table>
<el-table-column :resizable="false" v-for="(item, index) in tablelable" v-if="item.show" :width="item.width" <el-table-column :resizable="false" v-for="(item, index) in tablelable" v-if="item.show" :width="item.width"
:key="`col-${index}`" :label="item.label"> :key="`col-${index}`" :label="item.label">
<template slot-scope="scope" :column="item"> <template slot-scope="scope" :column="item">
@@ -75,6 +75,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination> <Pagination :pageObj="pageObj" @pageNo='pageNo' @pageSize='pageSize' ref="Pagination"></Pagination>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn" @click="toTop">TOP</button>
</div> </div>
<transition name="right-box"> <transition name="right-box">
@@ -194,6 +195,7 @@
name: "prom", name: "prom",
data() { data() {
return { return {
showTopBtn: false,
rightBox: { //弹出框相关 rightBox: { //弹出框相关
show: false, show: false,
isEdit: false, //false查看true编辑 isEdit: false, //false查看true编辑
@@ -640,6 +642,19 @@
mounted: function () { mounted: function () {
this.getIdcData(); this.getIdcData();
this.getUserData(); this.getUserData();
this.$nextTick(() => {
//绑定滚动条事件控制top按钮
let el = this.$refs.promTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 100) {
this.showTopBtn = true;
} else {
this.showTopBtn = false;
}
});
}
});
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) 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)) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
: this.tableTitle; : this.tableTitle;

View File

@@ -85,6 +85,7 @@
</div> </div>
</el-scrollbar> </el-scrollbar>
</div> </div>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn" @click="toTop('el', $refs.dashboardScrollbar.wrap)">TOP</button>
</div> </div>
<panel-box :panel="panel" @reload="panelReload" @reloadForDel="panelReloadForDel" ref="panelBox"></panel-box> <panel-box :panel="panel" @reload="panelReload" @reloadForDel="panelReloadForDel" ref="panelBox"></panel-box>
@@ -101,6 +102,7 @@
name: "panel", name: "panel",
data() { data() {
return { return {
showTopBtn: false, //top按钮
visible: false, visible: false,
rightBox: { //面板弹出框相关 rightBox: { //面板弹出框相关
show: false, show: false,
@@ -550,6 +552,11 @@
let _self = this; let _self = this;
let scrollbarWrap = this.$refs.dashboardScrollbar.wrap; let scrollbarWrap = this.$refs.dashboardScrollbar.wrap;
scrollbarWrap.onscroll = function() { scrollbarWrap.onscroll = function() {
if (scrollbarWrap.scrollTop > 100) {
_self.showTopBtn = true;
} else {
_self.showTopBtn = false;
}
if (scrollbarWrap.scrollHeight - scrollbarWrap.scrollTop - scrollbarWrap.offsetHeight < 20) { if (scrollbarWrap.scrollHeight - scrollbarWrap.scrollTop - scrollbarWrap.offsetHeight < 20) {
_self.$refs.chartList.pageDataList(true, _self.showPanel.id); _self.$refs.chartList.pageDataList(true, _self.showPanel.id);
} }

View File

@@ -118,9 +118,10 @@
<el-table <el-table
:data="endpointTableData" :data="endpointTableData"
border border
class="nz-table" class="nz-table endpoint-table"
height="calc(100% - 125px)" height="calc(100% - 125px)"
v-scrollBar:el-table v-scrollBar:el-table
ref="endpointTable"
style="width: 100%;"> style="width: 100%;">
<el-table-column <el-table-column
:resizable="false" :resizable="false"
@@ -164,6 +165,7 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
<Pagination v-cloak :pageObj="endpointPageObj" @pageNo='endpointPageNo' @pageSize='endpointPageSize' ref="endpointPagination"></Pagination> <Pagination v-cloak :pageObj="endpointPageObj" @pageNo='endpointPageNo' @pageSize='endpointPageSize' ref="endpointPagination"></Pagination>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn1" @click="toTop">TOP</button>
</div> </div>
<!--endpoint query--> <!--endpoint query-->
@@ -213,7 +215,7 @@
:data="showTableData" :data="showTableData"
border border
v-scrollBar:el-table v-scrollBar:el-table
class="nz-table" class="nz-table endpoint-query-table"
:header-cell-class-name="cellClass" :header-cell-class-name="cellClass"
height="calc(100% - 92px)" height="calc(100% - 92px)"
@selection-change="selectChange" @selection-change="selectChange"
@@ -251,6 +253,7 @@
width="180"> width="180">
</el-table-column> </el-table-column>
</el-table> </el-table>
<button class="to-top nz-btn nz-btn-size-normal nz-btn-style-light" v-show="showTopBtn2" @click="toTop">TOP</button>
</div> </div>
<element-set <element-set
@@ -324,6 +327,8 @@
let temp=this; let temp=this;
return { return {
tableShow: 1, // 1.endpoint; 2.metrics tableShow: 1, // 1.endpoint; 2.metrics
showTopBtn1: false,
showTopBtn2: false,
editEndpoint: {id: '', host: '', port: '', param: '', path: '', asset: {}, project: {}, module: {}, moduleId: '', assetId: '', paramObj: []}, editEndpoint: {id: '', host: '', port: '', param: '', path: '', asset: {}, project: {}, module: {}, moduleId: '', assetId: '', paramObj: []},
endpointTableTitle: [ endpointTableTitle: [
{ {
@@ -794,7 +799,7 @@
response.data.list[i].paramObj.push({key: k, value: tempObj[k]}) response.data.list[i].paramObj.push({key: k, value: tempObj[k]})
} }
} catch (err) { } catch (err) {
console.error(response.data.list[i], err); //console.error(response.data.list[i], err);
} }
} }
this.endpointTableData = response.data.list; this.endpointTableData = response.data.list;
@@ -845,7 +850,7 @@
this.moduleList[i].paramObj.push({key: k, value: tempObj[k]}); this.moduleList[i].paramObj.push({key: k, value: tempObj[k]});
} }
} catch (err) { } catch (err) {
console.info(response.data.list[i], err); //console.error(response.data.list[i], err);
} }
} }
if (this.moduleList.length > 0) { if (this.moduleList.length > 0) {
@@ -1049,12 +1054,28 @@
this.showTableDataCopy=JSON.stringify(this.showTableData); this.showTableDataCopy=JSON.stringify(this.showTableData);
this.tableShow=3; this.tableShow=3;
this.queryEdpLoading=false; this.queryEdpLoading=false;
this.gutterHandler(".endpoint-query-table"); //控制table右边距
this.showTopBtn2 = false;
this.$nextTick(() => {
//绑定滚动条事件控制top按钮
let el = this.$refs.metricInfoTab.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 20) {
this.showTopBtn2 = true;
} else {
this.showTopBtn2 = false;
}
});
}
});
} }
}) })
}, },
backToEdpTab:function(){ backToEdpTab:function(){
this.tableShow=1; this.tableShow=1;
this.selectedEndpoints=[]; this.selectedEndpoints=[];
this.showTopBtn1 = false;
}, },
changeTime:function(size,unit){ changeTime:function(size,unit){
let time=this.getTime(size,unit); let time=this.getTime(size,unit);
@@ -1353,10 +1374,18 @@
if(response.data.msg==='success'){ if(response.data.msg==='success'){
this.elementMetricDatas=response.data.data.list; this.elementMetricDatas=response.data.data.list;
} }
} }
},
/*gutterHandler() {
setTimeout(() => {
let gutterCol = document.querySelector(".endpoint-table col[name='gutter']");
if (gutterCol.attributes['width'].value != '0') {
gutterCol.attributes['width'].value = '10';
let bb = document.querySelector('.el-table__body');
document.querySelector('.endpoint-table .el-table__body').attributes['style'].value = "width: calc(100% - 10px)";
} }
}, 10)
}*/
}, },
created() { created() {
this.currentProject = this.$store.state.currentProject; this.currentProject = this.$store.state.currentProject;
@@ -1368,6 +1397,21 @@
setTimeout(()=>{ setTimeout(()=>{
this.getEndpointTableData(); this.getEndpointTableData();
}, 200); }, 200);
this.$nextTick(() => {
this.gutterHandler(".endpoint-table");
//绑定滚动条事件控制top按钮
let el = this.$refs.endpointTable.$el.querySelector(".el-table__body-wrapper");
if (el._ps_) {
el.addEventListener("ps-scroll-y", () => {
if (el._ps_.scrollbarYTop > 100) {
this.showTopBtn1 = true;
} else {
this.showTopBtn1 = false;
}
});
}
});
this.tablelable = localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path) 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)) ? JSON.parse(localStorage.getItem("nz-tableTitle-" + localStorage.getItem("nz-username") + "-" + this.$route.path))
: this.endpointTableTitle; : this.endpointTableTitle;

View File

@@ -63,6 +63,27 @@ Vue.prototype.$post = post;
Vue.prototype.$get = get; Vue.prototype.$get = get;
Vue.prototype.$put = put; Vue.prototype.$put = put;
Vue.prototype.$delete = del; Vue.prototype.$delete = del;
Vue.prototype.toTop = (type, wrap) => { //top按钮公共方法
if (type == 'el') {
wrap.scrollTop = 0;
} else {
let els = document.querySelectorAll(".el-table__body-wrapper");
for (let i = 0; i < els.length; i++) {
els[i].scrollTop = 0;
}
}
};
Vue.prototype.gutterHandler = (tableClass) => {
setTimeout(() => {
let gutterCol = document.querySelector(tableClass + " col[name='gutter']");
//console.info(gutterCol.attributes['width'].value)
if (gutterCol.attributes['width'].value != '0') {
//console.info(gutterCol)
gutterCol.attributes['width'].value = '10';
document.querySelector(tableClass + ' .el-table__body').attributes['style'].value = "width: calc(100% - 10px)";
}
}, 1000)
}
Vue.config.productionTip = false; Vue.config.productionTip = false;
Vue.use(ElementUI); Vue.use(ElementUI);
@@ -86,7 +107,7 @@ Vue.directive("scrollBar", {
!el && console.warn("未发现className为el-table__body-wrapper的dom"); !el && console.warn("未发现className为el-table__body-wrapper的dom");
// 启用x轴后不让原生滚动条出来作乱 // 启用x轴后不让原生滚动条出来作乱
/*vnode.context.$nextTick(() => { vnode.context.$nextTick(() => {
el.classList.add("ps"); el.classList.add("ps");
el.addEventListener("ps-scroll-y", () => el.addEventListener("ps-scroll-y", () =>
el.classList.add("ps") el.classList.add("ps")
@@ -94,7 +115,7 @@ Vue.directive("scrollBar", {
el.addEventListener("ps-scroll-x", () => el.addEventListener("ps-scroll-x", () =>
el.classList.add("ps") el.classList.add("ps")
); );
});*/ });
} }
const rules = ["fixed", "absolute", "relative"]; const rules = ["fixed", "absolute", "relative"];
if (!rules.includes(window.getComputedStyle(el, null).position)) { if (!rules.includes(window.getComputedStyle(el, null).position)) {
@@ -188,7 +209,7 @@ window.vm = new Vue({
template: '<App/>' template: '<App/>'
}) })
export default vm export default vm;
/*router.beforeEach((to, from, next) => { /*router.beforeEach((to, from, next) => {
if (to.path === '/login') { if (to.path === '/login') {
next() next()