fix(multiSelect.js): 修复全选功能在更新数据时bug

This commit is contained in:
huyueb 2017-12-28 10:40:41 +08:00
parent b63541c144
commit b9de7de510
1 changed files with 20 additions and 1 deletions

View File

@ -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();