- #set($nowName=$item.id+"_uploadTomcatFile")
-
-
-
#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();
+ }
+ }
+ }
}