From 2e2588040c1ddee51acd83ff8fc97f49df949970 Mon Sep 17 00:00:00 2001 From: Arno Date: Wed, 5 Jun 2019 10:43:39 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=96=87=E4=BB=B6=E4=B8=8A?= =?UTF-8?q?=E4=BC=A0=E5=88=A0=E9=99=A4=E6=9D=83=E9=99=90=E9=9A=90=E8=97=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/src/main/resources/vm/user/edit.vm | 203 +++++++++++------- 1 file changed, 127 insertions(+), 76 deletions(-) diff --git a/modules/server/src/main/resources/vm/user/edit.vm b/modules/server/src/main/resources/vm/user/edit.vm index a709c910d..bfe469f40 100644 --- a/modules/server/src/main/resources/vm/user/edit.vm +++ b/modules/server/src/main/resources/vm/user/edit.vm @@ -90,26 +90,28 @@
-
- -
- #set($nowName=$item.id+"_uploadFile") - + -
- -
- #set($nowName=$item.id+"_deleteFile") - +
+ +
+ #set($nowName=$item.id+"_deleteFile") + +
@@ -124,37 +126,40 @@
-
- -
- #set($nowName=$item.id+"_uploadTomcatFile") - +
+
+ +
+ #set($nowName=$item.id+"_uploadTomcatFile") + +
-
-
- -
- #set($nowName=$item.id+"_deleteTomcatFile") - +
+ +
+ #set($nowName=$item.id+"_deleteTomcatFile") + +
#foreach($pItem in $nowTomcat) #set($nowName="p_"+$item.id+"_"+$pItem.id) - #end
@@ -226,18 +231,16 @@ var projects = {}; for (var i = 0; i < treeNodes.length; i++) { var treeNode = treeNodes[i]; + var setting = treeNode.setting; + var nodeId = setting.nodeId; var nodes = treeNode.getCheckedNodes(true); if (!nodes || nodes.length <= 0) { continue; } var group = treeNode.group; var nodeProjects = []; - var nodeId = "localhost"; for (var j = 0; j < nodes.length; j++) { var node = nodes[j]; - if (node.nodeId) { - nodeId = node.nodeId; - } var id = node.id; if (id) { nodeProjects.push(id); @@ -255,31 +258,33 @@ if (typeof nodeModels == "string") { nodeModels = evil(nodeModels); } - var setting = { - check: { - enable: true, - chkStyle: "checkbox", - chkboxType: { - "Y": "ps", - "N": "ps" - }, - autoCheckTrigger: true - }, - data: { - simpleData: { - enable: true - }, - key: { - name: "name", - children: "projects" - }, - view: { - selectedMulti: false - } - } - }; - if (nodeModels && nodeModels.length > 0) { + var setting = { + check: { + enable: true, + chkStyle: "checkbox", + chkboxType: { + "Y": "ps", + "N": "ps" + }, + autoCheckTrigger: true + }, + data: { + simpleData: { + enable: true + }, + key: { + name: "name", + children: "projects" + }, + view: { + selectedMulti: false + } + }, + callback: { + onCheck: zTreeOnCheck + } + }; for (var j = 0; j < nodeModels.length; j++) { var nodeModel = nodeModels[j]; var groupProjects = nodeModel.groupProjects; @@ -291,16 +296,41 @@ } } var id = "#tree_" + nodeModel.id; + setting.nodeId = nodeModel.id; var zTreeObj = $.fn.zTree.init($(id), setting, groupProjects); treeNodes.push(zTreeObj); //展开节点 zTreeObj.expandAll(true); + tomcatManage(nodeModel.id, false); } } loadProjects(); }); }); + //勾选回调 + function zTreeOnCheck(event, treeId, treeNode) { + var check = treeNode.checked; + var treeObj = $.fn.zTree.getZTreeObj(treeId); + var setting = treeObj.setting; + var nodeId = setting.nodeId; + var id = "#projectOpt_" + nodeId; + if (check) { + $(id).css("display", "block"); + } else { + var nodes = treeObj.getCheckedNodes(true); + //全部取消勾选 隐藏开关并重置为未选中 + if (!nodes || nodes.length <= 0) { + $(id).css("display", "none"); + var uploadId = $('input[name=' + nodeId + '_uploadFile]'); + var deleteId = $('input[name=' + nodeId + '_deleteFile]'); + uploadId.prop('checked', false); + deleteId.prop('checked', false); + form.render(); + } + } + } + //渲染选中节点 function loadProjects() { var userItem = '$!userItem'; @@ -318,6 +348,9 @@ continue; } var treeObj = $.fn.zTree.getZTreeObj("tree_" + key); + if (!treeObj) { + continue; + } for (var i = 0; i < projects.length; i++) { var id = projects[i]; var obj = treeObj.getNodeByParam("id", id, null); @@ -326,16 +359,34 @@ } } - // - form.on('switch(manage)', function (data) { - var nodeId = $(data.elem).attr("nodeId"); - if (data.elem.checked) { - $('input[p="p_' + nodeId + '"]').prop('disabled', false).removeClass('layui-disabled'); - } else { - $('input[p="p_' + nodeId + '"]').prop('disabled', true).addClass('layui-disabled'); - } - form.render(); + //监听tomcat选择 + form.on('checkbox(manageTomcat)', function (data) { + var check = data.elem.checked; + var dom = data.elem; + var nodeId = dom.getAttribute("node_id"); + tomcatManage(nodeId, check); }); + + //更新tomcat管理 + function tomcatManage(nodeId, check) { + if (!nodeId) { + return; + } + var id = "#tomcatOpt_" + nodeId; + if (check) { + $(id).css("display", "block"); + } else { + var list = $("input[node_id=" + nodeId + "]:checked"); + if (!list || list.length <= 0) { + $(id).css("display", "none"); + var uploadId = $('input[name=' + nodeId + '_uploadTomcatFile]'); + var deleteId = $('input[name=' + nodeId + '_deleteTomcatFile]'); + uploadId.prop('checked', false); + deleteId.prop('checked', false); + form.render(); + } + } + } } \ No newline at end of file