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