From 7263f78c133b545454d75b7ea7940e1773625cc0 Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Sun, 30 Sep 2018 11:08:05 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8B=96=E6=8B=BD=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E7=B1=BB=E5=9E=8B=E3=80=81=E6=BB=9A=E5=8A=A8?= =?UTF-8?q?=E6=9D=A1=E9=94=99=E4=BD=8D=E9=97=AE=E9=A2=98):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Table.css | 5 ++++- build/TableHeader.js | 12 ++++++++++-- package.json | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/build/Table.css b/build/Table.css index 41cf509..f6b4f0c 100644 --- a/build/Table.css +++ b/build/Table.css @@ -218,7 +218,7 @@ padding-right: 0px; } .u-table-fixed-header .u-table-body-inner { height: 100%; - overflow: auto; } + overflow: scroll; } .u-table-fixed-header .u-table-scroll .u-table-header { overflow-x: scroll; padding-bottom: 20px; @@ -390,6 +390,9 @@ .u-table-thead-th .th-drag-gap-hover { background: #ccc; cursor: col-resize; } + .u-table-thead-th.th-can-not-drag .th-drag-gap-hover { + cursor: none; + width: 0px; } .u-table-thead-th:last-child-drag-gap { border: none; } .u-table-filter-column-pop-cont { diff --git a/build/TableHeader.js b/build/TableHeader.js index 17edef2..ceee73b 100644 --- a/build/TableHeader.js +++ b/build/TableHeader.js @@ -110,7 +110,7 @@ var TableHeader = function (_Component) { _this.drag.currIndex = _this.props.rows[0].findIndex(function (da) { return da.key == data.key; }); - _this.drag.width = _this.drag.data[_this.drag.currIndex].width; + var contentTableDom = document.getElementById("u-table-drag-thead-" + _this.theadKey).parentNode; var styleWidth = contentTableDom.style.width; if (styleWidth && (typeof styleWidth == 'number' || styleWidth.includes('px'))) { @@ -118,6 +118,12 @@ var TableHeader = function (_Component) { } else { _this.contentTableWidth = parseInt(contentTableDom.scrollWidth); } + var dragColWidth = _this.drag.data[_this.drag.currIndex].width; + if (typeof dragColWidth == 'string' && dragColWidth.indexOf('%')) { + _this.drag.width = _this.contentTableWidth * parseInt(dragColWidth) / 100; + } else { + _this.drag.width = parseInt(_this.drag.data[_this.drag.currIndex].width); + } }; _this.onMouseUp = function (event, data) { @@ -365,11 +371,13 @@ var TableHeader = function (_Component) { var thHover = da.drgHover ? ' ' + clsPrefix + '-thead th-drag-hover' : ""; delete da.drgHover; var fixedStyle = ''; + var canDotDrag = ''; if (!fixed && da.fixed) { fixedStyle = clsPrefix + '-row-fixed-columns-in-body'; } if (lastShowIndex == i) { da.width = parseInt(da.width) + contentWidthDiff; + canDotDrag = 'th-can-not-drag'; } if (draggable) { return _react2["default"].createElement('th', _extends({}, da, { @@ -400,7 +408,7 @@ var TableHeader = function (_Component) { onMouseUp: function onMouseUp(event) { _this2.onThMouseUp(event, da); }, - className: da.className + ' ' + clsPrefix + '-thead-th ' + fixedStyle, + className: da.className + ' ' + clsPrefix + '-thead-th ' + canDotDrag + ' ' + fixedStyle, key: i }, da.children, _react2["default"].createElement('div', { ref: function ref(el) { diff --git a/package.json b/package.json index 1670ab9..099756d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bee-table", - "version": "1.4.7", + "version": "1.4.8", "description": "Table ui component for react", "keywords": [ "react",