fix: 修复同页面内有俩top按钮时置顶错误的问题

This commit is contained in:
陈劲松
2020-03-17 19:13:02 +08:00
parent 4e17f0bdb7
commit 54173a8bd1
2 changed files with 18 additions and 5 deletions

View File

@@ -184,7 +184,7 @@
</el-table-column>
</el-table>
<Pagination v-show="mainResizeShow" :tableId="tableId" v-cloak :pageObj="endpointPageObj" @pageNo='endpointPageNo' @pageSize='endpointPageSize' ref="endpointPagination"></Pagination>
<button class="to-top" v-show="showTopBtn1" @click="toTop"><i class="nz-icon nz-icon-top"></i></button>
<button class="to-top" v-show="showTopBtn1" @click="toTop('ps', 0)"><i class="nz-icon nz-icon-top"></i></button>
</div>
<!-- 副列表 endpoint query-->
@@ -285,7 +285,7 @@
width="180">
</el-table-column>
</el-table>
<button class="to-top" v-show="showTopBtn2" @click="toTop"><i class="nz-icon nz-icon-top"></i></button>
<button class="to-top" v-show="showTopBtn2" @click="toTop('ps', 1)"><i class="nz-icon nz-icon-top"></i></button>
</div>
</div>

View File

@@ -80,6 +80,18 @@ Vue.prototype.toTop = (type, wrap) => { //top按钮公共方法
}, 20);
} else {
let els = document.querySelectorAll(".el-table__body-wrapper");
if (wrap || wrap == 0) {
let currentTop = els[wrap].scrollTop;
let interval = currentTop/10;
let intervalFunc = setInterval(function(){ //花200ms分10次回到顶部模拟动画效果
if (currentTop == 0) {
clearInterval(intervalFunc);
} else {
currentTop = (currentTop - interval) < interval*0.5 ? 0 : currentTop - interval;
els[wrap].scrollTop = currentTop;
}
}, 20);
} else {
for (let i = 0; i < els.length; i++) {
let currentTop = els[i].scrollTop;
let interval = currentTop/10;
@@ -93,6 +105,7 @@ Vue.prototype.toTop = (type, wrap) => { //top按钮公共方法
}, 20);
}
}
}
};
Vue.prototype.gutterHandler = (tableClass) => {
setTimeout(() => {