Skip to content

Commit

Permalink
fix(multiSelect.js): 修复全选功能在更新数据时bug
Browse files Browse the repository at this point in the history
  • Loading branch information
HuYuee committed Dec 28, 2017
1 parent b63541c commit b9de7de
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/lib/multiSelect.js
Expand Up @@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit b9de7de

Please sign in to comment.