From f967964d980bd34910d23d12be2c23579d59e778 Mon Sep 17 00:00:00 2001 From: wanghaoo Date: Tue, 4 Dec 2018 13:26:33 +0800 Subject: [PATCH] =?UTF-8?q?TableHeader=E4=B8=ADkey=E5=80=BC=E8=AE=BE?= =?UTF-8?q?=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/TableHeader.js | 2 +- build/lib/dragColumn.js | 28 ++-------------------------- build/lib/multiSelect.js | 35 ++++++++++++++++++++++++++++------- src/TableHeader.js | 2 +- 4 files changed, 32 insertions(+), 35 deletions(-) diff --git a/build/TableHeader.js b/build/TableHeader.js index 5cbe9be..2d30148 100644 --- a/build/TableHeader.js +++ b/build/TableHeader.js @@ -592,7 +592,7 @@ var TableHeader = function (_Component) { if (!da.fixed) { return _react2["default"].createElement( "th", - { key: Math.random() + new Date().getTime(), className: thClassName, "data-th-fixed": da.fixed, + { key: da.dataindex, className: thClassName, "data-th-fixed": da.fixed, "data-line-key": da.key, "data-line-index": columIndex, "data-th-width": da.width }, da.children, dragborder ? _react2["default"].createElement( diff --git a/build/lib/dragColumn.js b/build/lib/dragColumn.js index 04b7047..82101b9 100644 --- a/build/lib/dragColumn.js +++ b/build/lib/dragColumn.js @@ -72,35 +72,11 @@ function dragColumn(Table) { columns[index] = dragSourceColum; } } - // let titles = []; - // columns.forEach(da=>{ - // for(let attr of da){ - - // } - // if(typeof da.title != "string"){ - // titles.push(da.title); - // delete da.title; - // } - // }); - // let newColumns = null; - // if(titles.length != 0){ - // newColumns = JSON.parse(JSON.stringify(columns)); - // for (let index = 0; index < newColumns.length; index++) { - // newColumns[index].title = titles[index]; - // } - // console.log("----columns----",newColumns); - // }else{ - // newColumns = JSON.parse(JSON.stringify(columns)); - // } - // this.setState({ - // columns:newColumns - // }); - _this.setState({ columns: cloneDeep(columns) }); - if (_this.props.dragDrop) { - _this.props.dragDrop(event, data, newColumns); + if (_this.props.onDrop) { + _this.props.onDrop(event, data, columns); } }; diff --git a/build/lib/multiSelect.js b/build/lib/multiSelect.js index af369ce..2826d90 100644 --- a/build/lib/multiSelect.js +++ b/build/lib/multiSelect.js @@ -143,21 +143,31 @@ function multiSelect(Table, Checkbox) { if (checkedAll) { check = false; } else { - if (indeterminate) { - check = true; - } else { - check = true; - } + // if(indeterminate){ + // check = true; + // }else{ + // check = true; + // } + check = true; } var selectList = []; + data.forEach(function (item) { - item._checked = check; + if (!item._disabled) { + item._checked = check; + } + if (item._checked) { selectList.push(item); } }); + if (selectList.length > 0) { + indeterminate = true; + } else { + indeterminate = false; + } _this2.setState({ - indeterminate: false, + indeterminate: indeterminate, checkedAll: check }); _this2.props.getSelectedDataFunc(selectList); @@ -190,11 +200,22 @@ function multiSelect(Table, Checkbox) { indeterminate = _state2.indeterminate; var checkAttr = { checked: checkedAll ? true : false }; + var data = _this2.props.data; + var dataLength = data.length; + var disabledCount = 0; indeterminate ? checkAttr.indeterminate = true : ""; + //设置表头Checkbox是否可以点击 + data.forEach(function (item, index, arr) { + if (item._disabled) { + disabledCount++; + } + }); + var _defaultColumns = [{ title: _react2["default"].createElement(Checkbox, _extends({ className: 'table-checkbox' }, checkAttr, { + disabled: disabledCount == dataLength ? true : false, onChange: _this2.onAllCheckChange })), key: "checkbox", diff --git a/src/TableHeader.js b/src/TableHeader.js index b3ec9a5..a3d047b 100644 --- a/src/TableHeader.js +++ b/src/TableHeader.js @@ -536,7 +536,7 @@ class TableHeader extends Component { } thClassName += `${fixedStyle}`; if(!da.fixed){ - return ( {da.children} {