From 2aea757a7f7c3e1744baf1f2190d68f78b815332 Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Mon, 8 Oct 2018 15:41:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=90=88=E5=B9=B6=E5=88=97=E4=B8=AD?= =?UTF-8?q?=E8=AE=A1=E7=AE=97lastShowIndex):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/ColumnManager.js | 2 +- build/Table.js | 15 +++++++++++++-- build/TableHeader.js | 2 +- package.json | 2 +- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/build/ColumnManager.js b/build/ColumnManager.js index f21145f..ec72884 100644 --- a/build/ColumnManager.js +++ b/build/ColumnManager.js @@ -214,7 +214,7 @@ var ColumnManager = function () { }; ColumnManager.prototype.getColumnWidth = function getColumnWidth(contentWidth) { - var columns = this.groupedColumns(); + var columns = this.leafColumns(); var res = { computeWidth: 0, lastShowIndex: 0 }; columns.forEach(function (col, index) { //如果列显示 diff --git a/build/Table.js b/build/Table.js index ace04ae..fdd1781 100644 --- a/build/Table.js +++ b/build/Table.js @@ -617,6 +617,7 @@ var Table = function (_Component) { Table.prototype.getColGroup = function getColGroup(columns, fixed) { var cols = []; + var self = this; var _state = this.state, _state$contentWidthDi = _state.contentWidthDiff, contentWidthDiff = _state$contentWidthDi === undefined ? 0 : _state$contentWidthDi, @@ -641,9 +642,15 @@ var Table = function (_Component) { } cols = cols.concat(leafColumns.map(function (c, i, arr) { var width = c.width; - if (lastShowIndex == i) { - width = parseInt(width) + contentWidthDiff; + if (typeof width == 'string' && width.indexOf('%') > -1) { + width = parseInt(self.contentWidth * parseInt(width) / 100); + } else { + width = parseInt(width); } + if (lastShowIndex == i) { + width = width + contentWidthDiff; + } + return _react2["default"].createElement('col', { key: c.key, style: { width: width, minWidth: c.width } }); })); return _react2["default"].createElement( @@ -725,6 +732,10 @@ var Table = function (_Component) { tableStyle.width = _this3.contentWidth; } } + //自动出现滚动条 + // if(this.contentDomWidth < this.contentWidth){ + // tableStyle.width = this.contentWidth; + // } var tableBody = hasBody ? getBodyWrapper(_react2["default"].createElement( 'tbody', { className: clsPrefix + '-tbody' }, diff --git a/build/TableHeader.js b/build/TableHeader.js index ceee73b..77bb907 100644 --- a/build/TableHeader.js +++ b/build/TableHeader.js @@ -119,7 +119,7 @@ var TableHeader = function (_Component) { _this.contentTableWidth = parseInt(contentTableDom.scrollWidth); } var dragColWidth = _this.drag.data[_this.drag.currIndex].width; - if (typeof dragColWidth == 'string' && dragColWidth.indexOf('%')) { + if (typeof dragColWidth == 'string' && dragColWidth.indexOf('%') > -1) { _this.drag.width = _this.contentTableWidth * parseInt(dragColWidth) / 100; } else { _this.drag.width = parseInt(_this.drag.data[_this.drag.currIndex].width); diff --git a/package.json b/package.json index 38b93d0..1fda6a5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bee-table", - "version": "1.4.9", + "version": "1.4.10", "description": "Table ui component for react", "keywords": [ "react",