From 921021625dbc2c4080be541c52acb6386a28e9ac Mon Sep 17 00:00:00 2001 From: WenG <450292408@qq.com> Date: Mon, 7 Sep 2020 12:11:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=88=86=E6=94=AF=E9=80=89?= =?UTF-8?q?=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../resources/templates/tree/tree-v2.html | 40 ++++++++++++++++--- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html b/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html index eb235ae..b7b0f70 100644 --- a/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html +++ b/cloud-common-plugin/src/main/resources/templates/tree/tree-v2.html @@ -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) {