add.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <!DOCTYPE html>
  2. <html xmlns:th="http://www.thymeleaf.org"
  3. xmlns:sec="http://www.pollix.at/thymeleaf/shiro">
  4. <head th:replace="admin/common/html/tableHead :: tableHead(~{::title},~{::link},~{::style})">
  5. <title th:text=${title}></title>
  6. <!-- 这儿引用单独的css link -->
  7. <!-- Ladda for Bootstrap 3按钮加载进度插件 -->
  8. <link rel="stylesheet" th:href="@{/static/admin/assets/js/button/ladda/ladda.min.css}">
  9. <!-- bootstrap-table表单样式 -->
  10. <link th:href="@{/static/admin/assets/js/bootstrap/css/bootstrap-table/bootstrap-table.min.css}" rel="stylesheet"/>
  11. <!-- treeview -->
  12. <link th:href="@{/static/admin/assets/js/bootstrap/bootstrap-treeview/css/bootstrap-treeview.css}" rel="stylesheet"/>
  13. <style type="text/css">
  14. .content-wrap {
  15. padding: 0px;
  16. }
  17. body {
  18. color: #9ea7b3;
  19. font-family: "Open Sans", Arial, sans-serif!important;
  20. font-size: 13px!important;
  21. line-height: 20px;
  22. overflow-x: hidden!important;
  23. min-height: 100%;
  24. z-index: -2;
  25. margin: 0px !important;
  26. background: url() no-repeat top center fixed;
  27. -moz-background-size: cover;
  28. -webkit-background-size: cover;
  29. -o-background-size: cover;
  30. background-size: cover;
  31. }
  32. label.error {
  33. position: absolute;
  34. right: 18px;
  35. top: 5px;
  36. color: #ef392b;
  37. font-size: 12px;
  38. }
  39. .ico-list .fa{
  40. margin: 5px;
  41. padding: 5px;
  42. cursor:pointer;
  43. font-size: 18px;
  44. width: 28px;
  45. border-radius: 3px;
  46. }
  47. .ico-list .fa:hover {
  48. background-color: #1d9d74;
  49. color: #ffffff;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <div id="fcapp" class="content-wrap">
  55. <div class="row">
  56. <div class="col-sm-12">
  57. <div class="nest" id="elementClose">
  58. <div class="">
  59. </div>
  60. <div class="body-nest" id="element">
  61. <div class="panel-body">
  62. <form class="form-horizontal m" id="form-add">
  63. <div class="form-group">
  64. <label class="col-sm-3 control-label">类型:</label>
  65. <div class="col-sm-8">
  66. <label class="radio-inline"><input type="radio" name="type" value="0" v-model="menu.type"> 目录</label>
  67. <label class="radio-inline"><input type="radio" name="type" value="1" v-model="menu.type"> 菜单</label>
  68. <label class="radio-inline"><input type="radio" name="type" value="2" v-model="menu.type"> 按钮</label>
  69. </div>
  70. </div>
  71. <div class="form-group">
  72. <label class="col-sm-3 control-label ">权限名称:</label>
  73. <div class="col-sm-8">
  74. <input class="form-control" type="text" id="name" name="name"/>
  75. </div>
  76. </div>
  77. <div v-if="menu.type == 1 || menu.type == 2" class="form-group">
  78. <label class="col-sm-3 control-label ">上级菜单:</label>
  79. <div class="col-sm-8">
  80. <input class="form-control" type="hidden" id="pid" name="pid"/>
  81. <input class="form-control" readonly="true" type="text" id="pidName" onclick="selectMenuTree()" />
  82. </div>
  83. </div>
  84. <div v-if="menu.type == 1 || menu.type == 2" class="form-group">
  85. <label class="col-sm-3 control-label ">权限URL:</label>
  86. <div class="col-sm-8">
  87. <input class="form-control" type="text" id="url" name="url"/>
  88. </div>
  89. </div>
  90. <div v-if="menu.type == 1" class="form-group">
  91. <label class="col-sm-3 control-label ">打开方式:</label>
  92. <div class="col-sm-8">
  93. <select class="form-control" id="isBlank" name="isBlank" >
  94. <option value="0">签页</option>
  95. <option value="1">新窗口</option>
  96. </select>
  97. </div>
  98. </div>
  99. <div v-if="menu.type == 1 || menu.type == 2" class="form-group">
  100. <label class="col-sm-3 control-label ">权限关键字:</label>
  101. <div class="col-sm-8">
  102. <input class="form-control" type="text" id="perms" name="perms" placeholder="多个用逗号分隔,如:user:list,user:create"/>
  103. </div>
  104. </div>
  105. <div v-if="menu.type != 2" class="form-group">
  106. <label class="col-sm-3 control-label ">排序:</label>
  107. <div class="col-sm-8">
  108. <input class="form-control" type="number" id="orderNum" name="orderNum"/>
  109. </div>
  110. </div>
  111. <div v-if="menu.type != 2" class="form-group">
  112. <label class="col-sm-3 control-label ">图标:</label>
  113. <div class="col-sm-8">
  114. <input class="form-control" onfocus="showdrop();" type="text" id="icon" name="icon"/>
  115. <!--
  116. <code style="margin-top: 4px; display: block;">获取图标:https://fontawesome.com/v4.7.0/icons/</code>
  117. -->
  118. <div class="ms-parent" style="width: 100%;">
  119. <div class="icon-drop animated flipInX" style="display: none;max-height:200px;overflow-y:auto">
  120. <div data-th-include="admin/permission/icon"></div>
  121. </div>
  122. </div>
  123. </div>
  124. </div>
  125. <div class="form-group">
  126. <label class="col-sm-3 control-label ">权限描述:</label>
  127. <div class="col-sm-8">
  128. <input class="form-control" type="text" id="descripion" name="descripion"/>
  129. </div>
  130. </div>
  131. <div class="form-group">
  132. <label class="col-sm-3 control-label ">菜单状态:</label>
  133. <div class="col-sm-8">
  134. <select class="form-control" id="visible" name="visible" >
  135. <option value="0">显示</option>
  136. <option value="1">隐藏</option>
  137. </select>
  138. </div>
  139. </div>
  140. <div class="form-group">
  141. <div class="form-control-static col-sm-offset-9">
  142. <button type="submit" class="btn btn-primary">提交</button>
  143. <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button>
  144. </div>
  145. </div>
  146. </form>
  147. </div>
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. </div>
  153. <!-- 通用js -->
  154. <div th:include="admin/common/html/js :: onload_js">
  155. </div>
  156. <!-- bootstarp 表格 -->
  157. <script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/bootstrap-table.min.js}" type="text/javascript"></script>
  158. <script th:src="@{/static/admin/assets/js/bootstrap/js/bootstrap-table/locale/bootstrap-table-zh-CN.min.js}" type="text/javascript"></script>
  159. <script th:src="@{/static/admin/assets/js/bootstrap/js/base_list.js}" type="text/javascript"></script>
  160. <!-- 弹窗 -->
  161. <script th:src="@{/static/admin/assets/js/layer/layer.js}" type="text/javascript"></script>
  162. <!-- 遮罩层 -->
  163. <script th:src="@{/static/admin/assets/js/blockUI/jquery.blockUI.js}" type="text/javascript"></script>
  164. <!--bootstarp threeView -->
  165. <script th:src="@{/static/admin/assets/js/bootstrap/bootstrap-treeview/js/bootstrap-treeview.js}" type="text/javascript"></script>
  166. <script type="text/javascript">
  167. $(function(){
  168. //初始化vue
  169. var vm = new Vue({
  170. el:"#fcapp",
  171. data: {
  172. "menu":{
  173. type:0
  174. }
  175. }
  176. });
  177. //验证方法
  178. $("#form-add").validate({
  179. rules:{
  180. name:{
  181. required:true,
  182. minlength: 2,
  183. maxlength: 20,
  184. remote: {
  185. url: rootPath + "/PermissionVueController/checkNameUnique",
  186. type: "post",
  187. dataType: "json",
  188. dataFilter: function(data, type) {
  189. if (data == "0")
  190. return true;
  191. else
  192. return false;
  193. }
  194. }
  195. },
  196. url:{
  197. required:true,
  198. minlength: 1,
  199. maxlength: 100,
  200. remote: {
  201. url: rootPath + "/PermissionVueController/checkURLUnique",
  202. type: "post",
  203. dataType: "json",
  204. dataFilter: function(data, type) {
  205. var u=$("#url").val();
  206. if (data == "0" || u== "#")
  207. return true;
  208. else
  209. return false;
  210. }
  211. }
  212. },perms:{
  213. required:true,
  214. minlength: 1,
  215. maxlength: 100,
  216. remote: {
  217. url: rootPath + "/PermissionVueController/checkPermsUnique",
  218. type: "post",
  219. dataType: "json",
  220. dataFilter: function(data, type) {
  221. var u=$("#perms").val();
  222. if (data == "0" || u== "#")
  223. return true;
  224. else
  225. return false;
  226. }
  227. }
  228. }
  229. },
  230. messages: {
  231. "name": {
  232. remote: "权限名字已经存在"
  233. },
  234. "url": {
  235. remote: "权限地址已经存在"
  236. },
  237. "perms": {
  238. remote: "权限关键字已经存在"
  239. }
  240. },
  241. submitHandler:function(form){
  242. add();
  243. }
  244. });
  245. })
  246. //添加方法
  247. function add() {
  248. var dataFormJson=$("#form-add").serialize();
  249. $.ajax({
  250. cache : true,
  251. type : "POST",
  252. url : rootPath + "/PermissionVueController/add",
  253. data :dataFormJson,
  254. async : false,
  255. error : function(request) {
  256. $.modal.alertError("系统错误");
  257. },
  258. success : function(data) {
  259. $.operate.saveSuccess(data);
  260. }
  261. });
  262. }
  263. /*菜单管理-修改-选择菜单树*/
  264. function selectMenuTree() {
  265. var url = rootPath+ "/PermissionVueController/tree";
  266. $.modal.open("选择菜单", url, '380', '380');
  267. }
  268. //显示图标
  269. function showdrop(){
  270. $(".icon-drop").show();
  271. }
  272. $(function() {
  273. $("#form-add").click(function(event) {
  274. var obj = event.srcElement || event.target;
  275. if (!$(obj).is("input[name='icon']")) {
  276. $(".icon-drop").hide();
  277. }
  278. });
  279. $(".icon-drop").find(".ico-list i").on("click", function() {
  280. $('#icon').val($(this).attr('class'));
  281. });
  282. });
  283. </script>
  284. </body>
  285. </html>