This commit is contained in:
jonyshi 2019-06-26 17:50:04 +08:00
parent 39610f5853
commit 8aea29060a
2 changed files with 10 additions and 4 deletions

View File

@ -169,14 +169,16 @@ var TableHeader = function (_Component) {
// const newTableWidth = this.drag.tableWidth + diff;// +'px'; // const newTableWidth = this.drag.tableWidth + diff;// +'px';
// this.table.table.style.width = newTableWidth+'px';;//改变table的width // this.table.table.style.width = newTableWidth+'px';;//改变table的width
// if(this.table.innerTableBody){//TODO 后续需要处理此处 // if(this.table.innerTableBody){//TODO 后续需要处理此处
// this.table.innerTableBody.style.width = newTableWidth+'px'; ; // this.table.innerTableBody.style.width = newTableWidth+'px';
// } // }
var newDiff = parseInt(currentCols.style.minWidth) - parseInt(currentCols.style.width); var newDiff = parseInt(currentCols.style.minWidth) - parseInt(currentCols.style.width);
if (newDiff > 0) { if (newDiff > 0) {
//缩小 //缩小
var lastWidth = _this.lastColumWidth + newDiff; var lastWidth = _this.lastColumWidth + newDiff;
_this.table.cols[lastShowIndex].style.width = lastWidth + "px"; _this.table.cols[lastShowIndex].style.width = lastWidth + "px"; //同步表头
_this.table.tableBodyCols[lastShowIndex].style.width = lastWidth + "px"; //同步表体
} }
var showScroll = contentDomWidth - (_this.drag.tableWidth + diff) - scrollbarWidth; var showScroll = contentDomWidth - (_this.drag.tableWidth + diff) - scrollbarWidth;
@ -512,6 +514,7 @@ var TableHeader = function (_Component) {
table.cols = tableDome.getElementsByTagName("col"); table.cols = tableDome.getElementsByTagName("col");
table.ths = tableDome.getElementsByTagName("th"); table.ths = tableDome.getElementsByTagName("th");
table.tr = tableDome.getElementsByTagName("tr"); table.tr = tableDome.getElementsByTagName("tr");
table.tableBodyCols = contentTable.querySelector('.u-table-scroll .u-table-body').getElementsByTagName("col");
} }
table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header'); table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header');

View File

@ -76,6 +76,7 @@ class TableHeader extends Component {
table.cols = tableDome.getElementsByTagName("col"); table.cols = tableDome.getElementsByTagName("col");
table.ths = tableDome.getElementsByTagName("th"); table.ths = tableDome.getElementsByTagName("th");
table.tr = tableDome.getElementsByTagName("tr"); table.tr = tableDome.getElementsByTagName("tr");
table.tableBodyCols = contentTable.querySelector('.u-table-scroll .u-table-body').getElementsByTagName("col");
} }
table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header') ; table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header') ;
@ -274,13 +275,15 @@ class TableHeader extends Component {
// const newTableWidth = this.drag.tableWidth + diff;// +'px'; // const newTableWidth = this.drag.tableWidth + diff;// +'px';
// this.table.table.style.width = newTableWidth+'px';;//改变table的width // this.table.table.style.width = newTableWidth+'px';;//改变table的width
// if(this.table.innerTableBody){//TODO 后续需要处理此处 // if(this.table.innerTableBody){//TODO 后续需要处理此处
// this.table.innerTableBody.style.width = newTableWidth+'px'; ; // this.table.innerTableBody.style.width = newTableWidth+'px';
// } // }
let newDiff = (parseInt(currentCols.style.minWidth) - parseInt(currentCols.style.width)); let newDiff = (parseInt(currentCols.style.minWidth) - parseInt(currentCols.style.width));
if(newDiff > 0){//缩小 if(newDiff > 0){//缩小
let lastWidth = this.lastColumWidth + newDiff; let lastWidth = this.lastColumWidth + newDiff;
this.table.cols[lastShowIndex].style.width = lastWidth +"px"; this.table.cols[lastShowIndex].style.width = lastWidth +"px";//同步表头
this.table.tableBodyCols[lastShowIndex].style.width = lastWidth + "px";//同步表体
} }
let showScroll = contentDomWidth - (this.drag.tableWidth + diff) - scrollbarWidth ; let showScroll = contentDomWidth - (this.drag.tableWidth + diff) - scrollbarWidth ;