authority.vm
4.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#set($page_title="编辑")
#set($crumbs="首页:/home,角色列表:/role/list.do")
#set($url_roleMenu = "/role/roleMenu.do")
#set($url_authority = "/role/authority.do")
<div class="page-content">
<div class="page-header">
<h1>
<small>
<i class="icon-double-angle-right"></i>
分配权限
</small>
</h1>
</div>
<!-- /.page-header -->
<div class="row">
<div class="col-xs-12">
<!-- PAGE CONTENT BEGINS -->
<form class="form-horizontal" role="form" method="post" action="$url_authority">
<input type="hidden" value="$roleId" name="id">
## <div class="form-group">
##
## <label class="col-sm-3 control-label no-padding-right"
## for="form-field-1"> 菜单: </label>
## </div>
<div>
<div id="ztree" class="ztree"></div>
</div>
<div id="formHidden"></div>
<div class="clearfix form-actions">
<div class="col-md-offset-3 col-md-9">
<button class="btn btn-info" type="submit" id="submitbtn">
<i class="icon-ok bigger-110"></i>
提交
</button>
<a class="btn btn-info" href="javascript:history.back()">
<i class="icon-undo bigger-110"></i>
返回
</a>
</div>
</div>
</form>
</div>
</div>
</div>
<link rel="stylesheet" href="/static/module/ztree/css/zTreeStyle/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="/static/module/ztree/js/jquery.ztree.core-3.5.js"></script>
<script type="text/javascript" src="/static/module/ztree/js/jquery.ztree.excheck-3.5.js"></script>
#macro(makeResTree $tree)
#foreach(${item} in ${tree})
#if($velocityCount> 1),#end{
id:"menu:$!{item.id}"
, name: "$!{item.label}"
,ttype:"menu"
## ,open:true
,isParent: true
, children: [
#makeResTree(${item.children})
]
#if(${menuRoles.contains(${item.id})})
, checked: true
#end
#if(${item.type} == 1)
## #else
,isParent: true
,open:true
,children:[
#foreach($res in $menuResrouceMap.get($item))
#if($velocityCount> 1),#end
{
id:"res:${res.id}"
,name:"$res.resourceName"
,ttype:"res"
#if(${assignedMap.containsKey(${res.id})})
, checked: true
#end
}
#end
]
#end
}
#end
#end
<script type="text/javascript">
var znodes = [
#makeResTree($menus)
];
var setting = {
check: {
enable: true
}
,callback: {
onNodeCreated: function(event, treeId, treeNode){
console.log(treeNode.ttype)
if(treeNode.ttype == "res"){
$("#" + treeNode.tId).addClass("menuRes")
} else {
$("#" + treeNode.tId).addClass("clearfix")
// $("#" + treeId).addClass("menuCl")
}
}
}
}
$(function(){
var tree = $.fn.zTree.init($("#ztree"), setting, znodes);
$("#submitbtn").click(function(){
var div = $("#formHidden");
div.html("");
var items = tree.getCheckedNodes();
for(var i in items) {
var item = items[i];
var hi = "<input type='hidden' name='authority' value='"+item.id+"'>"
div.append(hi);
}
});
})
</script>
<style type="text/css">
.menuRes{
display: inline-block;
float:left;
}
.menuRes span.button.switch{
background-image:none;
background-color:#fff;
}
</style>