This commit is contained in:
ahua52 2017-09-07 18:13:10 +08:00
parent 0691a17b7a
commit 3ac3d886c7
3 changed files with 45 additions and 53 deletions

View File

@ -249,16 +249,14 @@ var Tree = function (_React$Component) {
this.props.onCheck((0, _util.getStrictlyValue)(checkedKeys, this.props.checkedKeys.halfChecked), newSt); this.props.onCheck((0, _util.getStrictlyValue)(checkedKeys, this.props.checkedKeys.halfChecked), newSt);
} else { } else {
if (checked && index === -1) { if (checked && index === -1) {
(function () { this.treeNodesStates[treeNode.props.pos].checked = true;
_this3.treeNodesStates[treeNode.props.pos].checked = true;
var checkedPositions = []; var checkedPositions = [];
Object.keys(_this3.treeNodesStates).forEach(function (i) { Object.keys(this.treeNodesStates).forEach(function (i) {
if (_this3.treeNodesStates[i].checked) { if (_this3.treeNodesStates[i].checked) {
checkedPositions.push(i); checkedPositions.push(i);
} }
}); });
(0, _util.handleCheckState)(_this3.treeNodesStates, (0, _util.filterParentPosition)(checkedPositions), true); (0, _util.handleCheckState)(this.treeNodesStates, (0, _util.filterParentPosition)(checkedPositions), true);
})();
} }
if (!checked) { if (!checked) {
this.treeNodesStates[treeNode.props.pos].checked = false; this.treeNodesStates[treeNode.props.pos].checked = false;
@ -567,16 +565,14 @@ var Tree = function (_React$Component) {
this.halfCheckedKeys = props._treeNodesStates.halfCheckedKeys; this.halfCheckedKeys = props._treeNodesStates.halfCheckedKeys;
this.checkedKeys = props._treeNodesStates.checkedKeys; this.checkedKeys = props._treeNodesStates.checkedKeys;
} else { } else {
(function () { var checkedKeys = this.state.checkedKeys;
var checkedKeys = _this4.state.checkedKeys;
var checkKeys = void 0; var checkKeys = void 0;
if (!props.loadData && _this4.checkKeys && _this4._checkedKeys && (0, _util.arraysEqual)(_this4._checkedKeys, checkedKeys)) { if (!props.loadData && this.checkKeys && this._checkedKeys && (0, _util.arraysEqual)(this._checkedKeys, checkedKeys)) {
// if checkedKeys the same as _checkedKeys from onCheck, use _checkedKeys. // if checkedKeys the same as _checkedKeys from onCheck, use _checkedKeys.
checkKeys = _this4.checkKeys; checkKeys = this.checkKeys;
} else { } else {
(function () {
var checkedPositions = []; var checkedPositions = [];
_this4.treeNodesStates = {}; this.treeNodesStates = {};
(0, _util.loopAllChildren)(props.children, function (item, index, pos, keyOrPos, siblingPosition) { (0, _util.loopAllChildren)(props.children, function (item, index, pos, keyOrPos, siblingPosition) {
_this4.treeNodesStates[pos] = { _this4.treeNodesStates[pos] = {
node: item, node: item,
@ -591,13 +587,11 @@ var Tree = function (_React$Component) {
} }
}); });
// if the parent node's key exists, it all children node will be checked // if the parent node's key exists, it all children node will be checked
(0, _util.handleCheckState)(_this4.treeNodesStates, (0, _util.filterParentPosition)(checkedPositions), true); (0, _util.handleCheckState)(this.treeNodesStates, (0, _util.filterParentPosition)(checkedPositions), true);
checkKeys = (0, _util.getCheck)(_this4.treeNodesStates); checkKeys = (0, _util.getCheck)(this.treeNodesStates);
})();
} }
_this4.halfCheckedKeys = checkKeys.halfCheckedKeys; this.halfCheckedKeys = checkKeys.halfCheckedKeys;
_this4.checkedKeys = checkKeys.checkedKeys; this.checkedKeys = checkKeys.checkedKeys;
})();
} }
} }

View File

@ -157,7 +157,6 @@ var TreeNode = function (_React$Component) {
var callbackPromise = this.props.root.onExpand(this); var callbackPromise = this.props.root.onExpand(this);
if (callbackPromise && (typeof callbackPromise === 'undefined' ? 'undefined' : _typeof(callbackPromise)) === 'object') { if (callbackPromise && (typeof callbackPromise === 'undefined' ? 'undefined' : _typeof(callbackPromise)) === 'object') {
(function () {
var setLoading = function setLoading(dataLoading) { var setLoading = function setLoading(dataLoading) {
_this2.setState({ dataLoading: dataLoading }); _this2.setState({ dataLoading: dataLoading });
}; };
@ -167,7 +166,6 @@ var TreeNode = function (_React$Component) {
}, function () { }, function () {
setLoading(false); setLoading(false);
}); });
})();
} }
}; };

File diff suppressed because one or more lines are too long