新增分支选择

This commit is contained in:
WenG 2020-09-07 12:11:07 +08:00
parent 39fdcc33db
commit 921021625d

View File

@ -190,17 +190,45 @@
showSelectNodes(); showSelectNodes();
} }
}, },
beforeCheck: function(treeId, treeNode) {
if(!selectTree.check.chkboxType.SB) {
return true;
}
if(isNodeSelect(treeNode[selectTree.primaryKey])) {
return true;
}
// 清空原有选项
var nodes = zTree.getCheckedNodes(true);
for(var i = 0, item; item = nodes[i++];) {
zTree.checkNode(item, false, true);
removeSelectNodes(item[selectTree.primaryKey]);
}
return true;
},
onCheck: function(event, treeId, treeNode) { onCheck: function(event, treeId, treeNode) {
if(!isNodeSelect(treeNode[selectTree.primaryKey])) { if(!isNodeSelect(treeNode[selectTree.primaryKey])) {
if(treeNode[selectTree.primaryKey] == '0') { var nodes = zTree.getCheckedNodes(true);
zTree.checkNode(treeNode, false, true); for(var i = 0, item; item = nodes[i++];) {
return; if(item[selectTree.primaryKey] == '0') {
} else { zTree.checkNode(item, false, true);
selectedNodes.push(treeNode); return;
} else {
selectedNodes.push(item);
}
} }
// if(treeNode[selectTree.primaryKey] == '0') {
// zTree.checkNode(treeNode, false, true);
// return;
// } else {
// selectedNodes.push(treeNode);
// }
showSelectNodes(); showSelectNodes();
} else { } else {
removeSelectNodes(treeNode[selectTree.primaryKey]); var nodes = zTree.getCheckedNodes(false);
for(var i = 0, item; item = nodes[i++];) {
removeSelectNodes(item[selectTree.primaryKey]);
}
// removeSelectNodes(treeNode[selectTree.primaryKey]);
} }
}, },
onAsyncSuccess: function(event, treeId, treeNode, msg) { onAsyncSuccess: function(event, treeId, treeNode, msg) {