add.html 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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 is-required">菜单类型:</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 is-required">菜单名称:</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 is-required">显示排序:</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-3">
  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.default}">
  77. <label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
  78. </div>
  79. </div>
  80. <label class="col-sm-2 control-label is-refresh" title="打开菜单选项卡是否刷新页面">是否刷新:<i class="fa fa-question-circle-o"></i></label>
  81. <div class="col-sm-3 is-refresh">
  82. <div class="radio-box">
  83. <input type="radio" id="refresh-no" name="isRefresh" value="1" checked>
  84. <label for="refresh-no">否</label>
  85. </div>
  86. <div class="radio-box">
  87. <input type="radio" id="refresh-yes" name="isRefresh" value="0">
  88. <label for="refresh-yes">是</label>
  89. </div>
  90. </div>
  91. </div>
  92. </form>
  93. </div>
  94. <th:block th:include="include :: footer" />
  95. <script>
  96. var prefix = ctx + "system/menu";
  97. $("#form-menu-add").validate({
  98. onkeyup: false,
  99. rules:{
  100. menuType:{
  101. required:true,
  102. },
  103. menuName:{
  104. remote: {
  105. url: prefix + "/checkMenuNameUnique",
  106. type: "post",
  107. dataType: "json",
  108. data: {
  109. "parentId": function() {
  110. return $("input[name='parentId']").val();
  111. },
  112. "menuName" : function() {
  113. return $.common.trim($("#menuName").val());
  114. }
  115. },
  116. dataFilter: function(data, type) {
  117. return $.validate.unique(data);
  118. }
  119. }
  120. },
  121. orderNum:{
  122. digits:true
  123. },
  124. },
  125. messages: {
  126. "menuName": {
  127. remote: "菜单已经存在"
  128. }
  129. },
  130. focusCleanup: true
  131. });
  132. function submitHandler() {
  133. if ($.validate.form()) {
  134. $.operate.save(prefix + "/add", $('#form-menu-add').serialize());
  135. }
  136. }
  137. $(function() {
  138. $("input[name='icon']").focus(function() {
  139. $(".icon-drop").show();
  140. });
  141. $("#form-menu-add").click(function(event) {
  142. var obj = event.srcElement || event.target;
  143. if (!$(obj).is("input[name='icon']")) {
  144. $(".icon-drop").hide();
  145. }
  146. });
  147. $(".icon-drop").find(".ico-list i").on("click", function() {
  148. $('#icon').val($(this).attr('class'));
  149. });
  150. $('input').on('ifChecked', function(event){
  151. var menuType = $(event.target).val();
  152. if (menuType == "M") {
  153. $("#url").parents(".form-group").hide();
  154. $("#perms").parents(".form-group").hide();
  155. $("#icon").parents(".form-group").show();
  156. $("#target").parents(".form-group").hide();
  157. $("input[name='visible']").parents(".form-group").show();
  158. $(".is-refresh").hide();
  159. } else if (menuType == "C") {
  160. $("#url").parents(".form-group").show();
  161. $("#perms").parents(".form-group").show();
  162. $("#icon").parents(".form-group").show();
  163. $("#target").parents(".form-group").show();
  164. $("input[name='visible']").parents(".form-group").show();
  165. $(".is-refresh").show();
  166. } else if (menuType == "F") {
  167. $("#url").parents(".form-group").hide();
  168. $("#perms").parents(".form-group").show();
  169. $("#icon").parents(".form-group").hide();
  170. $("#target").parents(".form-group").hide();
  171. $("input[name='visible']").parents(".form-group").hide();
  172. $(".is-refresh").hide();
  173. }
  174. });
  175. });
  176. /*菜单管理-新增-选择菜单树*/
  177. function selectMenuTree() {
  178. var treeId = $("#treeId").val();
  179. var menuId = treeId > 0 ? treeId : 1;
  180. var url = prefix + "/selectMenuTree/" + menuId;
  181. var options = {
  182. title: '菜单选择',
  183. width: "380",
  184. url: url,
  185. callBack: doSubmit
  186. };
  187. $.modal.openOptions(options);
  188. }
  189. function doSubmit(index, layero){
  190. var body = layer.getChildFrame('body', index);
  191. $("#treeId").val(body.find('#treeId').val());
  192. $("#treeName").val(body.find('#treeName').val());
  193. layer.close(index);
  194. }
  195. </script>
  196. </body>
  197. </html>