add.html 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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-add">
  9. <input id="treeId" name="parentId" type="hidden" th:value="${menu.menuId}" />
  10. <div class="form-group">
  11. <label class="col-sm-3 control-label ">上级菜单:</label>
  12. <div class="col-sm-8">
  13. <div class="input-group">
  14. <input class="form-control" type="text" onclick="selectMenuTree()" id="treeName" readonly="true" th:value="${menu.menuName}">
  15. <span class="input-group-addon"><i class="fa fa-search"></i></span>
  16. </div>
  17. </div>
  18. </div>
  19. <div class="form-group">
  20. <label class="col-sm-3 control-label">菜单类型:</label>
  21. <div class="col-sm-8">
  22. <label class="radio-box"> <input type="radio" name="menuType" value="M" /> 目录 </label>
  23. <label class="radio-box"> <input type="radio" name="menuType" value="C" /> 菜单 </label>
  24. <label class="radio-box"> <input type="radio" name="menuType" value="F" /> 按钮 </label>
  25. </div>
  26. </div>
  27. <div class="form-group">
  28. <label class="col-sm-3 control-label">菜单名称:</label>
  29. <div class="col-sm-8">
  30. <input class="form-control" type="text" name="menuName" id="menuName" required>
  31. </div>
  32. </div>
  33. <div class="form-group">
  34. <label class="col-sm-3 control-label">请求地址:</label>
  35. <div class="col-sm-8">
  36. <input id="url" name="url" class="form-control" type="text">
  37. </div>
  38. </div>
  39. <div class="form-group">
  40. <label class="col-sm-3 control-label">打开方式:</label>
  41. <div class="col-sm-8">
  42. <select id="target" name="target" class="form-control m-b">
  43. <option value="menuItem">页签</option>
  44. <option value="menuBlank">新窗口</option>
  45. </select>
  46. </div>
  47. </div>
  48. <div class="form-group">
  49. <label class="col-sm-3 control-label">权限标识:</label>
  50. <div class="col-sm-8">
  51. <input id="perms" name="perms" class="form-control" type="text">
  52. <span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 控制器中定义的权限标识,如:@RequiresPermissions("")</span>
  53. </div>
  54. </div>
  55. <div class="form-group">
  56. <label class="col-sm-3 control-label">显示排序:</label>
  57. <div class="col-sm-8">
  58. <input class="form-control" type="text" name="orderNum" required>
  59. </div>
  60. </div>
  61. <div class="form-group">
  62. <label class="col-sm-3 control-label">图标:</label>
  63. <div class="col-sm-8">
  64. <input id="icon" name="icon" class="form-control" type="text" placeholder="选择图标">
  65. <div class="ms-parent" style="width: 100%;">
  66. <div class="icon-drop animated flipInX" style="display: none;max-height:200px;overflow-y:auto">
  67. <div data-th-include="system/menu/icon"></div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <div class="form-group">
  73. <label class="col-sm-3 control-label">菜单状态:</label>
  74. <div class="col-sm-8">
  75. <div class="radio-box" th:each="dict : ${@dict.getType('sys_show_hide')}">
  76. <input type="radio" th:id="${dict.dictCode}" name="visible" th:value="${dict.dictValue}" th:checked="${dict.isDefault == 'Y' ? true : false}">
  77. <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
  78. </div>
  79. </div>
  80. </div>
  81. </form>
  82. </div>
  83. <th:block th:include="include :: footer" />
  84. <script>
  85. var prefix = ctx + "system/menu";
  86. $("#form-menu-add").validate({
  87. onkeyup: false,
  88. rules:{
  89. menuType:{
  90. required:true,
  91. },
  92. menuName:{
  93. remote: {
  94. url: prefix + "/checkMenuNameUnique",
  95. type: "post",
  96. dataType: "json",
  97. data: {
  98. "parentId": function() {
  99. return $("input[name='parentId']").val();
  100. },
  101. "menuName" : function() {
  102. return $.common.trim($("#menuName").val());
  103. }
  104. },
  105. dataFilter: function(data, type) {
  106. return $.validate.unique(data);
  107. }
  108. }
  109. },
  110. orderNum:{
  111. digits:true
  112. },
  113. },
  114. messages: {
  115. "menuName": {
  116. remote: "菜单已经存在"
  117. }
  118. },
  119. focusCleanup: true
  120. });
  121. function submitHandler() {
  122. if ($.validate.form()) {
  123. $.operate.save(prefix + "/add", $('#form-menu-add').serialize());
  124. }
  125. }
  126. $(function() {
  127. $("input[name='icon']").focus(function() {
  128. $(".icon-drop").show();
  129. });
  130. $("#form-menu-add").click(function(event) {
  131. var obj = event.srcElement || event.target;
  132. if (!$(obj).is("input[name='icon']")) {
  133. $(".icon-drop").hide();
  134. }
  135. });
  136. $(".icon-drop").find(".ico-list i").on("click", function() {
  137. $('#icon').val($(this).attr('class'));
  138. });
  139. $('input').on('ifChecked', function(event){
  140. var menuType = $(event.target).val();
  141. if (menuType == "M") {
  142. $("#url").parents(".form-group").hide();
  143. $("#perms").parents(".form-group").hide();
  144. $("#icon").parents(".form-group").show();
  145. $("#target").parents(".form-group").hide();
  146. } else if (menuType == "C") {
  147. $("#url").parents(".form-group").show();
  148. $("#perms").parents(".form-group").show();
  149. $("#icon").parents(".form-group").hide();
  150. $("#target").parents(".form-group").show();
  151. } else if (menuType == "F") {
  152. $("#url").parents(".form-group").hide();
  153. $("#perms").parents(".form-group").show();
  154. $("#icon").parents(".form-group").hide();
  155. $("#target").parents(".form-group").hide();
  156. }
  157. });
  158. });
  159. /*菜单管理-新增-选择菜单树*/
  160. function selectMenuTree() {
  161. var treeId = $("#treeId").val();
  162. var menuId = treeId > 0 ? treeId : 1;
  163. var url = prefix + "/selectMenuTree/" + menuId;
  164. var options = {
  165. title: '菜单选择',
  166. width: "380",
  167. url: url,
  168. callBack: doSubmit
  169. };
  170. $.modal.openOptions(options);
  171. }
  172. function doSubmit(index, layero){
  173. var body = layer.getChildFrame('body', index);
  174. $("#treeId").val(body.find('#treeId').val());
  175. $("#treeName").val(body.find('#treeName').val());
  176. layer.close(index);
  177. }
  178. </script>
  179. </body>
  180. </html>