edit.html 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <!DOCTYPE html>
  2. <html lang="zh" xmlns:th="http://www.thymeleaf.org" >
  3. <head>
  4. <th:block th:include="include :: header('修改菜单')" />
  5. </head>
  6. <body class="white-bg">
  7. <div class="wrapper wrapper-content animated fadeInRight ibox-content">
  8. <form class="form-horizontal m" id="form-menu-edit" th:object="${menu}">
  9. <input name="menuId" type="hidden" th:field="*{menuId}" />
  10. <input id="treeId" name="parentId" type="hidden" th:field="*{parentId}" />
  11. <div class="form-group">
  12. <label class="col-sm-3 control-label">上级菜单:</label>
  13. <div class="col-sm-8">
  14. <div class="input-group">
  15. <input class="form-control" type="text" onclick="selectMenuTree()" id="treeName" readonly="true" th:value="${menu.parentName == null ? '无' : menu.parentName}">
  16. <span class="input-group-addon"><i class="fa fa-search"></i></span>
  17. </div>
  18. </div>
  19. </div>
  20. <div class="form-group">
  21. <label class="col-sm-3 control-label is-required">菜单类型:</label>
  22. <div class="col-sm-8">
  23. <label class="radio-box"> <input type="radio" th:field="*{menuType}" name="menuType" value="M" /> 目录 </label>
  24. <label class="radio-box"> <input type="radio" th:field="*{menuType}" name="menuType" value="C" /> 菜单 </label>
  25. <label class="radio-box"> <input type="radio" th:field="*{menuType}" name="menuType" value="F" /> 按钮 </label>
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label class="col-sm-3 control-label is-required">菜单名称:</label>
  30. <div class="col-sm-8">
  31. <input class="form-control" type="text" name="menuName" id="menuName" th:field="*{menuName}" required>
  32. </div>
  33. </div>
  34. <div class="form-group">
  35. <label class="col-sm-3 control-label" title="访问的请求地址,如:`/system/user`,如外网地址需内链访问则以`http(s)://`开头">请求地址:<i class="fa fa-question-circle-o"></i></label>
  36. <div class="col-sm-8">
  37. <input id="url" name="url" class="form-control" type="text" th:field="*{url}">
  38. </div>
  39. </div>
  40. <div class="form-group">
  41. <label class="col-sm-3 control-label">打开方式:</label>
  42. <div class="col-sm-8">
  43. <select id="target" name="target" class="form-control m-b">
  44. <option value="menuItem" th:field="*{target}">页签</option>
  45. <option value="menuBlank" th:selected="*{target == 'menuBlank'}">新窗口</option>
  46. </select>
  47. </div>
  48. </div>
  49. <div class="form-group">
  50. <label class="col-sm-3 control-label">权限标识:</label>
  51. <div class="col-sm-8">
  52. <input id="perms" name="perms" class="form-control" type="text" th:field="*{perms}">
  53. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 控制器中定义的权限标识,如:@RequiresPermissions("")</span>
  54. </div>
  55. </div>
  56. <div class="form-group">
  57. <label class="col-sm-3 control-label is-required" title="数字越小越靠前">显示排序:<i class="fa fa-question-circle-o"></i></label>
  58. <div class="col-sm-8">
  59. <input class="form-control" type="text" name="orderNum" th:field="*{orderNum}" required>
  60. </div>
  61. </div>
  62. <div class="form-group">
  63. <label class="col-sm-3 control-label" title="单击选择需要使用的FontAwesome图标">图标:<i class="fa fa-question-circle-o"></i></label>
  64. <div class="col-sm-8">
  65. <input id="icon" name="icon" class="form-control" type="text" placeholder="选择图标" th:field="*{icon}">
  66. <div class="ms-parent" style="width: 100%;">
  67. <div class="icon-drop animated flipInX" style="display: none;max-height:200px;overflow-y:auto">
  68. <div data-th-include="system/menu/icon"></div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="form-group">
  74. <label class="col-sm-3 control-label" title="选择隐藏则菜单将不会出现在侧边栏,也没有权限被访问">菜单状态:<i class="fa fa-question-circle-o"></i></label>
  75. <div class="col-sm-3">
  76. <div class="radio-box" th:each="dict : ${@dict.getType('sys_show_hide')}">
  77. <input type="radio" th:id="${dict.dictCode}" name="visible" th:value="${dict.dictValue}" th:field="*{visible}">
  78. <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
  79. </div>
  80. </div>
  81. <label class="col-sm-2 control-label is-refresh" title="打开菜单选项卡是否刷新页面">是否刷新:<i class="fa fa-question-circle-o"></i></label>
  82. <div class="col-sm-3 is-refresh">
  83. <div class="radio-box">
  84. <input type="radio" id="refresh-no" name="isRefresh" value="1" th:field="*{isRefresh}">
  85. <label for="refresh-no">否</label>
  86. </div>
  87. <div class="radio-box">
  88. <input type="radio" id="refresh-yes" name="isRefresh" value="0" th:field="*{isRefresh}">
  89. <label for="refresh-yes">是</label>
  90. </div>
  91. </div>
  92. </div>
  93. </form>
  94. </div>
  95. <th:block th:include="include :: footer" />
  96. <script>
  97. var prefix = ctx + "system/menu";
  98. $(function() {
  99. var menuType = $('input[name="menuType"]:checked').val();
  100. menuVisible(menuType);
  101. });
  102. $("#form-menu-edit").validate({
  103. onkeyup: false,
  104. rules:{
  105. menuType:{
  106. required:true,
  107. },
  108. menuName:{
  109. remote: {
  110. url: prefix + "/checkMenuNameUnique",
  111. type: "post",
  112. dataType: "json",
  113. data: {
  114. "menuId": function() {
  115. return $("#menuId").val();
  116. },
  117. "parentId": function() {
  118. return $("input[name='parentId']").val();
  119. },
  120. "menuName": function() {
  121. return $.common.trim($("#menuName").val());
  122. }
  123. }
  124. }
  125. },
  126. orderNum:{
  127. digits:true
  128. },
  129. },
  130. messages: {
  131. "menuName": {
  132. remote: "菜单已经存在"
  133. }
  134. },
  135. focusCleanup: true
  136. });
  137. function submitHandler() {
  138. if ($.validate.form()) {
  139. $.operate.save(prefix + "/edit", $('#form-menu-edit').serialize());
  140. }
  141. }
  142. $(function() {
  143. $("input[name='icon']").focus(function() {
  144. $(".icon-drop").show();
  145. });
  146. $("#form-menu-edit").click(function(event) {
  147. var obj = event.srcElement || event.target;
  148. if (!$(obj).is("input[name='icon']")) {
  149. $(".icon-drop").hide();
  150. }
  151. });
  152. $(".icon-drop").find(".ico-list i").on("click",
  153. function() {
  154. $('#icon').val($(this).attr('class'));
  155. });
  156. $('input').on('ifChecked',
  157. function(event) {
  158. var menuType = $(event.target).val();
  159. menuVisible(menuType);
  160. });
  161. });
  162. function menuVisible(menuType) {
  163. if (menuType == "M") {
  164. $("#url").parents(".form-group").hide();
  165. $("#perms").parents(".form-group").hide();
  166. $("#icon").parents(".form-group").show();
  167. $("#target").parents(".form-group").hide();
  168. $(".is-refresh").hide();
  169. } else if (menuType == "C") {
  170. $("#url").parents(".form-group").show();
  171. $("#perms").parents(".form-group").show();
  172. $("#icon").parents(".form-group").show();
  173. $("#target").parents(".form-group").show();
  174. $(".is-refresh").show();
  175. } else if (menuType == "F") {
  176. $("#url").parents(".form-group").hide();
  177. $("#perms").parents(".form-group").show();
  178. $("#icon").parents(".form-group").hide();
  179. $("#target").parents(".form-group").hide();
  180. $(".is-refresh").hide();
  181. }
  182. }
  183. /*菜单管理-修改-选择菜单树*/
  184. function selectMenuTree() {
  185. var menuId = $("#treeId").val();
  186. if(menuId > 0) {
  187. var url = prefix + "/selectMenuTree/" + menuId;
  188. $.modal.open("选择菜单", url, '380', '380');
  189. } else {
  190. $.modal.alertError("主菜单不能选择");
  191. }
  192. }
  193. function selectMenuTree() {
  194. var menuId = $("#treeId").val();
  195. if(menuId > 0) {
  196. var url = prefix + "/selectMenuTree/" + menuId;
  197. var options = {
  198. title: '菜单选择',
  199. width: "380",
  200. url: url,
  201. callBack: doSubmit
  202. };
  203. $.modal.openOptions(options);
  204. } else {
  205. $.modal.alertError("主菜单不能选择");
  206. }
  207. }
  208. function doSubmit(index, layero){
  209. var body = $.modal.getChildFrame(index);
  210. $("#treeId").val(body.find('#treeId').val());
  211. $("#treeName").val(body.find('#treeName').val());
  212. $.modal.close(index);
  213. }
  214. </script>
  215. </body>
  216. </html>