From b9de7de5102301c9e53a157f9caf241eaf4c6854 Mon Sep 17 00:00:00 2001 From: huyueb <1062887235@qq.com> Date: Thu, 28 Dec 2017 10:40:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(multiSelect.js):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=85=A8=E9=80=89=E5=8A=9F=E8=83=BD=E5=9C=A8=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=97=B6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib/multiSelect.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/lib/multiSelect.js b/src/lib/multiSelect.js index 07f951e..6ccdb19 100644 --- a/src/lib/multiSelect.js +++ b/src/lib/multiSelect.js @@ -21,7 +21,7 @@ export default function multiSelect(Table) { this.splice(index, 1); } }; - return class BookLoader extends Component { + return class multiSelect extends Component { constructor(props) { super(props); let { selectDisabled, data } = props, @@ -39,6 +39,25 @@ export default function multiSelect(Table) { data: this.props.data }; } + componentWillReceiveProps(nextProps) { + let props = this.props, + { selectDisabled, data } = props, + checkedObj = {}; + if (nextProps.data !== data) { + for (var i = 0; i < nextProps.data.length; i++) { + let bool = selectDisabled(nextProps.data[i], i); + if (!bool) { + checkedObj[nextProps.data[i]["key"]] = false; + } + } + this.setState({ + checkedAll: false, + checkedObj: checkedObj, + selIds: [], + data: nextProps.data + }); + } + } onAllCheckChange = () => { let self = this; let listData = self.state.data.concat();