新增分支选择

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();
}
},
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) {
if(!isNodeSelect(treeNode[selectTree.primaryKey])) {
if(treeNode[selectTree.primaryKey] == '0') {
zTree.checkNode(treeNode, false, true);
return;
} else {
selectedNodes.push(treeNode);
var nodes = zTree.getCheckedNodes(true);
for(var i = 0, item; item = nodes[i++];) {
if(item[selectTree.primaryKey] == '0') {
zTree.checkNode(item, false, true);
return;
} else {
selectedNodes.push(item);
}
}
// if(treeNode[selectTree.primaryKey] == '0') {
// zTree.checkNode(treeNode, false, true);
// return;
// } else {
// selectedNodes.push(treeNode);
// }
showSelectNodes();
} 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) {