Commit 26e96050 by 曾经

table-sticky

parent 2c02a409
......@@ -64,7 +64,6 @@ export default {
},
async initFixedHeader() {
if (this.parent) {
// console.log('启动监听,页面:', this.parent)
this.parentDom = document.getElementsByClassName(this.parent)
if (this.parentDom && this.parentDom.length !== 0) {
this.tableWidth = this.parentDom[0].querySelector('.el-table__header-wrapper').getBoundingClientRect().width
......@@ -156,7 +155,7 @@ export default {
let { dom } = this.getFixedDom()
if (dom.classList.contains('fixed')) {
let timer = setTimeout(() => {
this.parentDom[0].getElementsByClassName('el-table__fixed-body-wrapper')[0].style.top = this.headerTop
this.parentDom[0].getElementsByClassName('el-table__fixed-body-wrapper')[0].style.top = this.headerTop+'px'
let container = this.containerDom
if (container && container[0]) {
container[0].scrollTop = container[0].scrollTop + 3;
......@@ -190,7 +189,7 @@ export default {
let { height, top, left } = this.tablexy
let scrollTop = e.target.scrollTop
let { fixedRightHeaderDom, fixedRightBox, fixedLeftHeaderDom, fixedLeftBox, dom } = this.getFixedDom()
if (scrollTop >= height / 2 + top) {
if (scrollTop >= (height / 2 + (top-this.topMenuHeight)) ) {
// 存在右侧固定表头
if (fixedRightHeaderDom) {
this.setFixedStyle({
......@@ -215,7 +214,7 @@ export default {
this.updateWidth()
dom.style.position = 'fixed'
dom.style.zIndex = '2000'
dom.style.top =this.headerTop
dom.style.top =this.headerTop+'px'
dom.style.overflow = 'hidden'
} else {
this.clearFixedStyle()
......@@ -226,7 +225,7 @@ export default {
let { dom, scrollLeft, width, left } = data
dom.style.zIndex = '2000'
dom.style.position = 'fixed'
dom.style.top = this.headerTop
dom.style.top = this.headerTop+'px'
dom.scrollLeft = scrollLeft
dom.style.width = width
dom.style.overflow = 'hidden'
......@@ -246,13 +245,13 @@ export default {
if (fixedLeftHeaderDom) {
fixedLeftHeaderDom.style.zIndex = '0'
fixedLeftHeaderDom.style.position = 'static'
fixedLeftHeaderDom.style.top = this.headerTop
fixedLeftHeaderDom.style.top = this.headerTop+'px'
fixedLeftHeaderDom.style.left = left + 'px'
fixedLeftBox.style.top = getComputedStyle(dom).height
}
dom.classList.remove('fixed')
dom.style.position = 'static'
dom.style.top = this.headerTop
dom.style.top = this.headerTop+'px'
dom.style.zIndex = '0'
}
},
......@@ -279,7 +278,9 @@ export default {
tableWidth: 0,
timerList: [],
tableDom: null,
containerDom: null
containerDom: null,
headerWidth:0,
topMenuHeight:62
}
},
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment