list.vm
4.16 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#set($page_title="菜单列表")
#set($crumbs="首页:/home,菜单列表")
##查询地址
#set($url_list = "/menu/list.do")
#set($url_res_list = "/menu/listResource.do")
##详情
#set($url_show = "/menu/show.do")
##添加
#set($url_save = "/menu/preSave.do")
#set($url_res_save = "/resource/preSave.do")
##删除
#set($url_del = "/menu/del.do")
#set($url_res_del = "/resource/del.do")
##排序
#set($url_sort = "/menu/sort.do")
#set($url_move = "/menu/move.do")
##关联资源
#set($url_bind_resource = "/resource/bind.do")
<div class="row">
<div class="col-xs-12">
<div class="table-header">
菜单列表
</div>
#if(${type} == "res")
#parse("/menu/resList.vm")
#else
#parse("/menu/menuList.vm")
#end
</div>
</div>
<script type="text/javascript">
jQuery(function ($) {
$('table th input:checkbox').on('click', function () {
var that = this;
$(this).closest('table').find('tr > td:first-child input:checkbox')
.each(function () {
this.checked = that.checked;
$(this).closest('tr').toggleClass('selected');
});
});
})
function cleanForm(id) {
var form = $("#" + id);
form.find("input[type=text]").each(function () {
var obj = $(this);
obj.val("");
});
form.find("select").each(function () {
var obj = $(this);
obj.val("20");
});
}
</script>
<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>
<script type="text/javascript" src="/static/module/ztree/js/jquery.ztree.exedit-3.5.js"></script>
#macro(makeTree $tree)
#foreach(${item} in ${tree})
#if($velocityCount> 1),#end{
id:$!{item.id}
, name: "$!{item.label}"
, tt:"$!{item.type}"
#if(${item.type} != 1)
,open:true
,dropRoot:false
,isParent: true
, children: [
#makeTree(${item.children})
]
#else
,dropInner:false
#end
}
#end
#end
<script type="text/javascript">
var znodes = [
#makeTree($tree)
];
var setting = {
callback: {
onClick: function (event, treeId, treeNode) {
if (treeNode.tt != "1") {
window.location.href = "/menu/list.do?param[parentId]=" + treeNode.id
}
if (treeNode.tt == "1"){
window.location.href = "/menu/listResource.do?param[parentId]=" + treeNode.id
}
}
,onDrop:onDrop
}
,edit: {
enable: true
,showRemoveBtn: false
,showRenameBtn: false
,drag:{
inner:dropInner
,prev:false
,next:false
}
}
}
$(function () {
var tree = $.fn.zTree.init($("#menuTree"), setting, znodes);
var node = tree.getNodeByParam("id",${parentId});//treeObj是tree对象
tree.selectNode(node);
})
function redirect(id) {
window.location.href = "/menu/list.do?parentId=" + id
}
/**
* 移入
* @param treeId
* @param nodes
* @param targetNode
* @returns {boolean}
*/
function dropInner(treeId, nodes, targetNode) {
if (targetNode && targetNode.dropInner === false) {
return false;
}
if(targetNode == null){
return false;
}
return true;
}
function onDrop(event, treeId, treeNodes, targetNode, moveType) {
var parent = targetNode.id;
var id = treeNodes[0].id;
window.location.href = "$url_move" + "?id=" + id + "&parentId=" + parent;
// console.log(targetNode.id + "_" + treeNodes[0].id)
}
</script>
<script src="$!{webUtils.getAssetsPath("/ace1.3/assets/js/diligrp.form.js")}"></script>