add.html
6.73 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
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link href="ajax/libs/iCheck/custom.css" th:href="@{/ajax/libs/iCheck/custom.css}" rel="stylesheet"/>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-menu-add">
<input id="treeId" name="parentId" type="hidden" th:value="${menu.id}" />
<div class="form-group">
<label class="col-sm-3 control-label ">上级菜单:</label>
<div class="col-sm-8">
<input class="form-control" type="text" onclick="selectMenuTree()" id="treeName" readonly="true" th:value="${menu.menuName}"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单类型:</label>
<div class="col-sm-8">
<label class="checkbox-inline i-checks"> <input type="radio" name="menuType" value="M" /> 目录 </label>
<label class="checkbox-inline i-checks"> <input type="radio" name="menuType" value="C" /> 菜单 </label>
<label class="checkbox-inline i-checks"> <input type="radio" name="menuType" value="F" /> 按钮 </label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单名称:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="menuName" id="menuName">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">请求地址:</label>
<div class="col-sm-8">
<input id="url" name="url" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">权限标识:</label>
<div class="col-sm-8">
<input id="perms" name="perms" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">显示排序:</label>
<div class="col-sm-8">
<input class="form-control" type="text" name="orderNum">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">图标:</label>
<div class="col-sm-8">
<input id="icon" name="icon" class="form-control" type="text" placeholder="选择图标">
<div class="ms-parent" style="width: 100%;">
<div class="icon-drop animated flipInX" style="display: none;max-height:200px;overflow-y:auto">
<div data-th-include="system/menu/icon"></div>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单状态:</label>
<div class="col-sm-8" th:with="type=${@dict.getType('sys_show_hide')}">
<div th:each="dict : ${type}" th:class="${dict['cssClass']}">
<input type="radio" th:id="${dict['id']}" name="visible" th:value="${dict['dictValue']}" th:checked="${dict['isDefault'] == 'Y' ? true : false}">
<label th:for="${dict['id']}" th:text="${dict['dictLabel']}"></label>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">菜单终端:</label>
<div class="col-sm-8" th:with="type=${@dict.getType('sys_menu_mobile')}">
<div th:each="dict : ${type}" th:class="${dict['cssClass']}">
<input type="radio" th:id="${dict['id']}" name="menuMobile" th:value="${dict['dictValue']}" th:checked="${dict['isDefault'] == 'Y' ? true : false}">
<label th:for="${dict['id']}" th:text="${dict['dictLabel']}"></label>
</div>
</div>
</div>
<div class="form-group">
<div class="form-control-static col-sm-offset-9">
<button type="submit" class="btn btn-primary">提交</button>
<button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
</div>
</div>
</form>
</div>
<div th:include="include::footer"></div>
<script th:src="@{/ajax/libs/iCheck/icheck.min.js}"></script>
<script>
var prefix = ctx + "system/menu"
$("#form-menu-add").validate({
rules:{
menuName:{
required:true,
remote: {
url: prefix + "/checkMenuNameUnique",
type: "post",
dataType: "json",
data: {
"menuName" : function() {
return $.trim($("#menuName").val());
}
},
dataFilter: function(data, type) {
if (data == "0") return true;
else return false;
}
}
},
orderNum:{
required:true,
digits:true
},
},
messages: {
"menuName": {
remote: "菜单已经存在"
}
},
submitHandler:function(form){
$.operate.save(prefix + "/add", $('#form-menu-add').serialize());
}
});
$(function() {
$("input[name='icon']").focus(function() {
$(".icon-drop").show();
});
$("#form-menu-add").click(function(event) {
var obj = event.srcElement || event.target;
if (!$(obj).is("input[name='icon']")) {
$(".icon-drop").hide();
}
});
$(".icon-drop").find(".ico-list i").on("click", function() {
$('#icon').val($(this).attr('class'));
});
$('input').on('ifChecked', function(event){
var menuType = $(event.target).val();
if (menuType == "M") {
$("#url").parents(".form-group").hide();
$("#perms").parents(".form-group").hide();
$("#icon").parents(".form-group").show();
} else if (menuType == "C") {
$("#url").parents(".form-group").show();
$("#perms").parents(".form-group").show();
$("#icon").parents(".form-group").hide();
} else if (menuType == "F") {
$("#url").parents(".form-group").hide();
$("#perms").parents(".form-group").show();
$("#icon").parents(".form-group").hide();
}
});
});
/*菜单管理-新增-选择菜单树*/
function selectMenuTree() {
var id = $("#treeId").val();
if(id > 0) {
var url = prefix + "/selectMenuTree/" + id;
$.modal.open("选择菜单", url, '380', '380');
}
else {
var url = prefix + "/selectMenuTree/1";
$.modal.open("选择菜单", url, '380', '380');
}
}
</script>
</body>
</html>