用户文件上传删除权限隐藏

This commit is contained in:
Arno 2019-06-05 10:43:39 +08:00
parent e54d8d7729
commit 2e2588040c

View File

@ -90,26 +90,28 @@
<div class="layui-form-item" id="projectsDiv"> <div class="layui-form-item" id="projectsDiv">
<label class="layui-form-label" title="能删除项目,启动停止项目">管理项目</label> <label class="layui-form-label" title="能删除项目,启动停止项目">管理项目</label>
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-inline"> <div id="projectOpt_$!item.id" style="display: none;">
<label class="layui-form-label">上传文件</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">上传文件</label>
#set($nowName=$item.id+"_uploadFile") <div class="layui-input-block">
<input type="checkbox" value="true" #set($nowName=$item.id+"_uploadFile")
#if($userItem.nodeRole[$item.id].uploadFile) <input type="checkbox" value="true"
checked #if($userItem.nodeRole[$item.id].uploadFile)
#end checked
name="$nowName" lay-skin="switch" lay-text="是|否"> #end
name="$nowName" lay-skin="switch" lay-text="是|否">
</div>
</div> </div>
</div> <div class="layui-inline">
<div class="layui-inline"> <label class="layui-form-label">删除文件</label>
<label class="layui-form-label">删除文件</label> <div class="layui-input-block">
<div class="layui-input-block"> #set($nowName=$item.id+"_deleteFile")
#set($nowName=$item.id+"_deleteFile") <input type="checkbox" value="true"
<input type="checkbox" value="true" #if($userItem.nodeRole[$item.id].deleteFile)
#if($userItem.nodeRole[$item.id].deleteFile) checked
checked #end
#end name="$nowName" lay-skin="switch" lay-text="是|否">
name="$nowName" lay-skin="switch" lay-text="是|否"> </div>
</div> </div>
</div> </div>
<div> <div>
@ -124,37 +126,40 @@
<div class="layui-form-item"> <div class="layui-form-item">
<label class="layui-form-label">管理Tomcat</label> <label class="layui-form-label">管理Tomcat</label>
<div class="layui-inline"> <div class="layui-inline">
<div class="layui-inline"> <div id="tomcatOpt_$item.id">
<label class="layui-form-label">上传文件</label> <div class="layui-inline">
<div class="layui-input-block"> <label class="layui-form-label">上传文件</label>
#set($nowName=$item.id+"_uploadTomcatFile") <div class="layui-input-block">
<input type="checkbox" value="true" #set($nowName=$item.id+"_uploadTomcatFile")
#if($userItem.nodeTomcatRole[$item.id].uploadFile) <input type="checkbox" value="true"
checked #if($userItem.nodeTomcatRole[$item.id].uploadFile)
#end checked
name="$nowName" lay-skin="switch" lay-text="是|否"> #end
name="$nowName" lay-skin="switch" lay-text="是|否">
</div>
</div> </div>
</div> <div class="layui-inline">
<div class="layui-inline"> <label class="layui-form-label">删除文件</label>
<label class="layui-form-label">删除文件</label> <div class="layui-input-block">
<div class="layui-input-block"> #set($nowName=$item.id+"_deleteTomcatFile")
#set($nowName=$item.id+"_deleteTomcatFile") <input type="checkbox" value="true"
<input type="checkbox" value="true" #if($userItem.nodeTomcatRole[$item.id].deleteFile)
#if($userItem.nodeTomcatRole[$item.id].deleteFile) checked
checked #end
#end name="$nowName" lay-skin="switch" lay-text="是|否">
name="$nowName" lay-skin="switch" lay-text="是|否"> </div>
</div> </div>
</div> </div>
<div> <div>
#foreach($pItem in $nowTomcat) #foreach($pItem in $nowTomcat)
#set($nowName="p_"+$item.id+"_"+$pItem.id) #set($nowName="p_"+$item.id+"_"+$pItem.id)
<input type="checkbox" <input type="checkbox" lay-filter="manageTomcat"
p="p_$item.id" p="p_$item.id"
name="$nowName" name="$nowName"
#if($userItem.isTomcat($item.id,$pItem.id))checked#end #if($userItem.isTomcat($item.id,$pItem.id))checked#end
project="$pItem.id" project="$pItem.id"
value="$pItem.id" value="$pItem.id"
node_id="$item.id"
title="$pItem.name"> title="$pItem.name">
#end #end
</div> </div>
@ -226,18 +231,16 @@
var projects = {}; var projects = {};
for (var i = 0; i < treeNodes.length; i++) { for (var i = 0; i < treeNodes.length; i++) {
var treeNode = treeNodes[i]; var treeNode = treeNodes[i];
var setting = treeNode.setting;
var nodeId = setting.nodeId;
var nodes = treeNode.getCheckedNodes(true); var nodes = treeNode.getCheckedNodes(true);
if (!nodes || nodes.length <= 0) { if (!nodes || nodes.length <= 0) {
continue; continue;
} }
var group = treeNode.group; var group = treeNode.group;
var nodeProjects = []; var nodeProjects = [];
var nodeId = "localhost";
for (var j = 0; j < nodes.length; j++) { for (var j = 0; j < nodes.length; j++) {
var node = nodes[j]; var node = nodes[j];
if (node.nodeId) {
nodeId = node.nodeId;
}
var id = node.id; var id = node.id;
if (id) { if (id) {
nodeProjects.push(id); nodeProjects.push(id);
@ -255,31 +258,33 @@
if (typeof nodeModels == "string") { if (typeof nodeModels == "string") {
nodeModels = evil(nodeModels); 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) { 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++) { for (var j = 0; j < nodeModels.length; j++) {
var nodeModel = nodeModels[j]; var nodeModel = nodeModels[j];
var groupProjects = nodeModel.groupProjects; var groupProjects = nodeModel.groupProjects;
@ -291,16 +296,41 @@
} }
} }
var id = "#tree_" + nodeModel.id; var id = "#tree_" + nodeModel.id;
setting.nodeId = nodeModel.id;
var zTreeObj = $.fn.zTree.init($(id), setting, groupProjects); var zTreeObj = $.fn.zTree.init($(id), setting, groupProjects);
treeNodes.push(zTreeObj); treeNodes.push(zTreeObj);
//展开节点 //展开节点
zTreeObj.expandAll(true); zTreeObj.expandAll(true);
tomcatManage(nodeModel.id, false);
} }
} }
loadProjects(); 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() { function loadProjects() {
var userItem = '$!userItem'; var userItem = '$!userItem';
@ -318,6 +348,9 @@
continue; continue;
} }
var treeObj = $.fn.zTree.getZTreeObj("tree_" + key); var treeObj = $.fn.zTree.getZTreeObj("tree_" + key);
if (!treeObj) {
continue;
}
for (var i = 0; i < projects.length; i++) { for (var i = 0; i < projects.length; i++) {
var id = projects[i]; var id = projects[i];
var obj = treeObj.getNodeByParam("id", id, null); var obj = treeObj.getNodeByParam("id", id, null);
@ -326,16 +359,34 @@
} }
} }
// //监听tomcat选择
form.on('switch(manage)', function (data) { form.on('checkbox(manageTomcat)', function (data) {
var nodeId = $(data.elem).attr("nodeId"); var check = data.elem.checked;
if (data.elem.checked) { var dom = data.elem;
$('input[p="p_' + nodeId + '"]').prop('disabled', false).removeClass('layui-disabled'); var nodeId = dom.getAttribute("node_id");
} else { tomcatManage(nodeId, check);
$('input[p="p_' + nodeId + '"]').prop('disabled', true).addClass('layui-disabled');
}
form.render();
}); });
//更新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();
}
}
}
} }
</script> </script>
</html> </html>