From 2fc1fc05fd4198d840747b02e74f2384e2fb1a28 Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Sat, 15 Sep 2018 13:47:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(bee-table=E4=B8=AD=E5=BC=95=E7=94=A8checkbo?= =?UTF-8?q?x=E5=9C=A8safair=E4=B8=8B=E6=97=A0=E6=B3=95=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98):?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/Table.css | 2 +- build/Table.js | 5 +++-- build/TableHeader.js | 12 +++++++++--- package.json | 2 +- 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/Table.css b/build/Table.css index 2c93390..1c152c2 100644 --- a/build/Table.css +++ b/build/Table.css @@ -70,7 +70,7 @@ right: 0; bottom: 0; left: 0; - z-index: 1600; + z-index: 1900; opacity: .7; filter: blur(0.5px); background-color: #fff; } diff --git a/build/Table.js b/build/Table.js index 3ba7001..06f6a4c 100644 --- a/build/Table.js +++ b/build/Table.js @@ -656,7 +656,8 @@ var Table = function (_Component) { var headStyle = {}; var tableClassName = ''; - if (scroll.x || fixed) { + //表格元素的宽度大于容器的宽度也显示滚动条 + if (scroll.x || fixed || this.contentDomWidth < this.contentWidth) { tableClassName = clsPrefix + '-fixed'; if (!footerScroll) { bodyStyle.overflowX = bodyStyle.overflowX || 'auto'; @@ -703,7 +704,7 @@ var Table = function (_Component) { var _drag_class = _this3.props.dragborder ? "table-drag-bordered" : ""; return _react2["default"].createElement( 'table', - { className: ' ' + tableClassName + ' table table-bordered ' + _drag_class + ' ', style: tableStyle }, + { className: ' ' + tableClassName + ' table-bordered ' + _drag_class + ' ', style: tableStyle }, _this3.props.dragborder ? null : _this3.getColGroup(columns, fixed), hasHead ? _this3.getHeader(columns, fixed) : null, tableBody diff --git a/build/TableHeader.js b/build/TableHeader.js index f76fa18..40978a8 100644 --- a/build/TableHeader.js +++ b/build/TableHeader.js @@ -105,8 +105,9 @@ var TableHeader = function (_Component) { 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; - _this.contentTableWidth = contentTable.width; + _this.contentTableWidth = contentTableDom.style.width ? parseInt(contentTableDom.style.width) : parseInt(contentTableDom.scrollWidth); }; _this.onMouseUp = function (event, data) { @@ -127,10 +128,14 @@ var TableHeader = function (_Component) { contentTable = _this$props2.contentTable; var x = event.pageX - _this.drag.initPageLeftX + _this.drag.initLeft - 0; + var contentTableDom = document.getElementById("u-table-drag-thead-" + _this.theadKey).parentNode; + if (!_this.contentTableWidth) { - _this.contentTableWidth = contentTable.clientWidth; + _this.contentTableWidth = contentTableDom.style.width ? parseInt(contentTableDom.style.width) : parseInt(contentTableDom.scrollWidth); } + // console.log(this.contentTableWidth,x); var newTableWidth = _this.contentTableWidth + x; + // console.log(newTableWidth); var newWidth = _this.drag.width + x; if (newWidth < _this.props.minColumnWidth) { //清楚样式 @@ -164,8 +169,9 @@ var TableHeader = function (_Component) { var currentDom = document.getElementById("u-table-drag-thead-" + _this.theadKey).getElementsByTagName("th")[_this.drag.currIndex]; currentDom.style.width = newWidth + "px"; // this.contentTableWidth = newTableWidth; - var contentTableDom = document.getElementById("u-table-drag-thead-" + _this.theadKey).parentNode; + contentTableDom.style.width = newTableWidth + 'px'; + _this.drag.x = x; }; diff --git a/package.json b/package.json index 4b740c0..76caf24 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bee-table", - "version": "1.4.0", + "version": "1.4.1", "description": "Table ui component for react", "keywords": [ "react",