edit.html 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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">菜单类型:</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">菜单名称:</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">请求地址:</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">显示排序:</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">图标:</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">菜单状态:</label>
  75. <div class="col-sm-8">
  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. </div>
  82. </form>
  83. </div>
  84. <th:block th:include="include :: footer" />
  85. <script>
  86. var prefix = ctx + "system/menu";
  87. $(function() {
  88. var menuType = $('input[name="menuType"]:checked').val();
  89. menuVisible(menuType);
  90. });
  91. $("#form-menu-edit").validate({
  92. onkeyup: false,
  93. rules:{
  94. menuType:{
  95. required:true,
  96. },
  97. menuName:{
  98. remote: {
  99. url: prefix + "/checkMenuNameUnique",
  100. type: "post",
  101. dataType: "json",
  102. data: {
  103. "menuId": function() {
  104. return $("#menuId").val();
  105. },
  106. "parentId": function() {
  107. return $("input[name='parentId']").val();
  108. },
  109. "menuName": function() {
  110. return $.common.trim($("#menuName").val());
  111. }
  112. },
  113. dataFilter: function(data, type) {
  114. return $.validate.unique(data);
  115. }
  116. }
  117. },
  118. orderNum:{
  119. digits:true
  120. },
  121. },
  122. messages: {
  123. "menuName": {
  124. remote: "菜单已经存在"
  125. }
  126. },
  127. focusCleanup: true
  128. });
  129. function submitHandler() {
  130. if ($.validate.form()) {
  131. $.operate.save(prefix + "/edit", $('#form-menu-edit').serialize());
  132. }
  133. }
  134. $(function() {
  135. $("input[name='icon']").focus(function() {
  136. $(".icon-drop").show();
  137. });
  138. $("#form-menu-edit").click(function(event) {
  139. var obj = event.srcElement || event.target;
  140. if (!$(obj).is("input[name='icon']")) {
  141. $(".icon-drop").hide();
  142. }
  143. });
  144. $(".icon-drop").find(".ico-list i").on("click",
  145. function() {
  146. $('#icon').val($(this).attr('class'));
  147. });
  148. $('input').on('ifChecked',
  149. function(event) {
  150. var menuType = $(event.target).val();
  151. menuVisible(menuType);
  152. });
  153. });
  154. function menuVisible(menuType) {
  155. if (menuType == "M") {
  156. $("#url").parents(".form-group").hide();
  157. $("#perms").parents(".form-group").hide();
  158. $("#icon").parents(".form-group").show();
  159. $("#target").parents(".form-group").hide();
  160. } else if (menuType == "C") {
  161. $("#url").parents(".form-group").show();
  162. $("#perms").parents(".form-group").show();
  163. $("#icon").parents(".form-group").hide();
  164. $("#target").parents(".form-group").show();
  165. } else if (menuType == "F") {
  166. $("#url").parents(".form-group").hide();
  167. $("#perms").parents(".form-group").show();
  168. $("#icon").parents(".form-group").hide();
  169. $("#target").parents(".form-group").hide();
  170. }
  171. }
  172. /*菜单管理-修改-选择菜单树*/
  173. function selectMenuTree() {
  174. var menuId = $("#treeId").val();
  175. if(menuId > 0) {
  176. var url = prefix + "/selectMenuTree/" + menuId;
  177. $.modal.open("选择菜单", url, '380', '380');
  178. } else {
  179. $.modal.alertError("主菜单不能选择");
  180. }
  181. }
  182. function selectMenuTree() {
  183. var menuId = $("#treeId").val();
  184. if(menuId > 0) {
  185. var url = prefix + "/selectMenuTree/" + menuId;
  186. var options = {
  187. title: '菜单选择',
  188. width: "380",
  189. url: url,
  190. callBack: doSubmit
  191. };
  192. $.modal.openOptions(options);
  193. } else {
  194. $.modal.alertError("主菜单不能选择");
  195. }
  196. }
  197. function doSubmit(index, layero){
  198. var body = layer.getChildFrame('body', index);
  199. $("#treeId").val(body.find('#treeId').val());
  200. $("#treeName").val(body.find('#treeName').val());
  201. layer.close(index);
  202. }
  203. </script>
  204. </body>
  205. </html>