From deae4b8d0a4035db72e24af0f7d35b5759d7fa16 Mon Sep 17 00:00:00 2001 From: kvkens Date: Thu, 11 Oct 2018 14:12:19 +0800 Subject: [PATCH] publish 1.4.11 --- CHANGELOG.md | 5 +++++ build/Table.css | 4 +++- build/Table.js | 12 ++++++------ build/TableHeader.js | 14 ++++++-------- build/lib/multiSelect.js | 2 +- build/lib/sort.js | 29 +++++++++++++++++++++++++++-- package.json | 2 +- 7 files changed, 49 insertions(+), 19 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9486ae7..20ae2a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ + +## [1.4.11](https://github.com/tinper-bee/bee-table/compare/v1.4.10...v1.4.11) (2018-10-11) + + + ## [1.4.10](https://github.com/tinper-bee/bee-table/compare/v1.4.9...v1.4.10) (2018-10-08) diff --git a/build/Table.css b/build/Table.css index f6b4f0c..bdaf6ea 100644 --- a/build/Table.css +++ b/build/Table.css @@ -184,6 +184,8 @@ transition: all 0.3s ease; } .u-table tr:hover { background: rgb(227,242,253); } + .u-table tr:hover td .uf-eye { + visibility: visible !important; } .u-table tr.tr-row-hover { background: rgb(227,242,253); } .u-table th, @@ -371,7 +373,7 @@ .u-table-thead th:hover .bee-table-column-sorter { display: inline-block; } .u-table-thead .th-drag { - cursor: pointer; } + cursor: move; } .u-table-thead .th-drag-hover { background: #ccc; } .u-table-thead-th { diff --git a/build/Table.js b/build/Table.js index fdd1781..c169015 100644 --- a/build/Table.js +++ b/build/Table.js @@ -642,9 +642,9 @@ var Table = function (_Component) { } cols = cols.concat(leafColumns.map(function (c, i, arr) { var width = c.width; - if (typeof width == 'string' && width.indexOf('%') > -1) { + if (typeof width == 'string' && width.indexOf('%') > -1 && self.contentWidth) { width = parseInt(self.contentWidth * parseInt(width) / 100); - } else { + } else if (width) { width = parseInt(width); } if (lastShowIndex == i) { @@ -732,10 +732,10 @@ var Table = function (_Component) { tableStyle.width = _this3.contentWidth; } } - //自动出现滚动条 - // if(this.contentDomWidth < this.contentWidth){ - // tableStyle.width = this.contentWidth; - // } + // 自动出现滚动条 + if (_this3.contentDomWidth > _this3.contentWidth) { + tableStyle.width = _this3.contentDomWidth; + } var tableBody = hasBody ? getBodyWrapper(_react2["default"].createElement( 'tbody', { className: clsPrefix + '-tbody' }, diff --git a/build/TableHeader.js b/build/TableHeader.js index 77bb907..fb7fdf3 100644 --- a/build/TableHeader.js +++ b/build/TableHeader.js @@ -379,6 +379,9 @@ var TableHeader = function (_Component) { da.width = parseInt(da.width) + contentWidthDiff; canDotDrag = 'th-can-not-drag'; } + if (filterable && index == rows.length - 1) { + da.children = _this2.filterRenderType(da['filtertype'], da.dataindex, i); + } if (draggable) { return _react2["default"].createElement('th', _extends({}, da, { onDragStart: function onDragStart(event) { @@ -433,14 +436,9 @@ var TableHeader = function (_Component) { ); } else { var th = void 0; - if (filterable && index == rows.length - 1) { - da.children = _this2.filterRenderType(da['filtertype'], da.dataindex, i); - th = _react2["default"].createElement('th', _extends({}, da, { key: i, className: da.className + ' ' + fixedStyle })); - } else { - th = da.onClick ? _react2["default"].createElement('th', _extends({}, da, { className: da.className + ' ' + fixedStyle, key: i, onClick: function onClick(event) { - da.onClick(da, event); - } })) : _react2["default"].createElement('th', _extends({}, da, { key: i, className: da.className + ' ' + fixedStyle })); - } + th = da.onClick ? _react2["default"].createElement('th', _extends({}, da, { className: da.className + ' ' + fixedStyle, key: i, onClick: function onClick(event) { + da.onClick(da, event); + } })) : _react2["default"].createElement('th', _extends({}, da, { key: i, className: da.className + ' ' + fixedStyle })); return th; } }) diff --git a/build/lib/multiSelect.js b/build/lib/multiSelect.js index 3a1b2c2..9ab2927 100644 --- a/build/lib/multiSelect.js +++ b/build/lib/multiSelect.js @@ -125,7 +125,7 @@ function multiSelect(Table, Checkbox) { }), key: "checkbox", dataIndex: "checkbox", - width: "100", + width: "55", render: function render(text, record, index) { var rowKey = record["key"] ? record["key"] : _this2.getRowKey(record, i); var bool = checkedObj.hasOwnProperty(rowKey); diff --git a/build/lib/sort.js b/build/lib/sort.js index 8b96715..a3e09f6 100644 --- a/build/lib/sort.js +++ b/build/lib/sort.js @@ -76,6 +76,19 @@ function sort(Table, Icon) { _this.setState({ columns: columns }); }; + _this.getOrderCols = function (columns) { + var orderCols = []; + columns.forEach(function (item) { + if (item.order == 'ascend' || item.order == 'descend') { + orderCols.push({ order: item.order, + field: item.dataIndex, + orderNum: item.orderNum + }); + } + }); + return orderCols; + }; + _this._sortBy = function (pre, after, orderCols, orderColslen, currentIndex) { var preKey = pre[orderCols[currentIndex].key]; var afterKey = after[orderCols[currentIndex].key]; @@ -137,8 +150,12 @@ function sort(Table, Icon) { }); seleObj.order = order; //通过后端请求 - if (sort.backSource) { + if (sort.backSource && typeof sort.sortFun === "function") { //获取排序的字段和方式 + sort.sortFun([{ + order: order, + field: seleObj.dataIndex + }]); } else { if (order === "ascend") { data = data.sort(function (a, b) { @@ -163,7 +180,11 @@ function sort(Table, Icon) { if (!seleObj.orderNum && (order == 'ascend' || order == 'descend')) { seleObj.orderNum = _this.getOrderNum(); } - data = _this.multiSort(columns); + if (sort.backSource && typeof sort.sortFun === "function") { + sort.sortFun(_this.getOrderCols(columns)); + } else { + data = _this.multiSort(columns); + } } _this.setState({ data: data, @@ -255,6 +276,10 @@ function sort(Table, Icon) { * 当有的列不排序时,将该列的orderNum置为‘’,并动态的修改其他列的orderNum。 */ + /** + * 获取排序字段 + */ + /** * pre:前一条数据 diff --git a/package.json b/package.json index a0bf3f7..c623e08 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bee-table", - "version": "1.4.10", + "version": "1.4.11", "description": "Table ui component for react", "keywords": [ "react",