index.jsp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <%@ page contentType="text/html; charset=utf-8"%>
  2. <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
  4. <%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
  5. <%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
  6. <%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
  7. <%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
  8. <c:set var="basePath" value="${pageContext.request.contextPath}"/>
  9. <!DOCTYPE HTML>
  10. <html lang="zh-cn">
  11. <head>
  12. <meta charset="utf-8">
  13. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  14. <meta name="viewport" content="width=device-width, initial-scale=1">
  15. <title>角色管理</title>
  16. <link href="${basePath}/resources/zheng-admin/plugins/bootstrap-3.3.0/css/bootstrap.min.css" rel="stylesheet"/>
  17. <link href="${basePath}/resources/zheng-admin/plugins/material-design-iconic-font-2.2.0/css/material-design-iconic-font.min.css" rel="stylesheet"/>
  18. <link href="${basePath}/resources/zheng-admin/plugins/bootstrap-table-1.11.0/bootstrap-table.min.css" rel="stylesheet"/>
  19. <link href="${basePath}/resources/zheng-admin/plugins/waves-0.7.5/waves.min.css" rel="stylesheet"/>
  20. <link href="${basePath}/resources/zheng-admin/css/common.css" rel="stylesheet"/>
  21. </head>
  22. <body>
  23. <div id="main">
  24. <div id="toolbar">
  25. <shiro:hasPermission name="upms:role:create"><a class="waves-effect waves-button" href="javascript:;"><i class="zmdi zmdi-plus"></i> 新增角色</a></shiro:hasPermission>
  26. <shiro:hasPermission name="upms:role:update"><a class="waves-effect waves-button" href="javascript:;"><i class="zmdi zmdi-edit"></i> 编辑角色</a></shiro:hasPermission>
  27. <shiro:hasPermission name="upms:role:delete"><a class="waves-effect waves-button" href="javascript:;"><i class="zmdi zmdi-close"></i> 删除角色</a></shiro:hasPermission>
  28. </div>
  29. <table id="table"></table>
  30. </div>
  31. <script src="${basePath}/resources/zheng-admin/plugins/jquery.1.12.4.min.js"></script>
  32. <script src="${basePath}/resources/zheng-admin/plugins/bootstrap-3.3.0/js/bootstrap.min.js"></script>
  33. <script src="${basePath}/resources/zheng-admin/plugins/bootstrap-table-1.11.0/bootstrap-table.min.js"></script>
  34. <script src="${basePath}/resources/zheng-admin/plugins/bootstrap-table-1.11.0/locale/bootstrap-table-zh-CN.min.js"></script>
  35. <script src="${basePath}/resources/zheng-admin/plugins/waves-0.7.5/waves.min.js"></script>
  36. <script src="${basePath}/resources/zheng-admin/js/common.js"></script>
  37. <style>
  38. body{font-size: 12px;}
  39. .table i{font-size: 12px; color: #000;}
  40. .bootstrap-table .table>thead>tr>th{border-bottom: none;}
  41. </style>
  42. <script>
  43. $(function() {
  44. // bootstrap table初始化
  45. $('#table').bootstrapTable({
  46. url: '${basePath}/manage/role/list',
  47. height: getHeight(),
  48. striped: true,
  49. search: true,
  50. showRefresh: true,
  51. showColumns: true,
  52. minimumCountColumns: 2,
  53. clickToSelect: true,
  54. detailView: true,
  55. detailFormatter: 'detailFormatter',
  56. pagination: true,
  57. toolbar: '#toolbar',
  58. columns: [
  59. {field: 'state', checkbox: true},
  60. {field: 'roleId', title: '编号', sortable: true, align: 'center'},
  61. {field: 'name', title: '角色名称'},
  62. {field: 'description', title: '角色描述'},
  63. {field: 'action', title: '操作', align: 'center', formatter: 'actionFormatter', events: 'actionEvents'}
  64. ]
  65. }).on('all.bs.table', function (e, name, args) {
  66. $('[data-toggle="tooltip"]').tooltip();
  67. $('[data-toggle="popover"]').popover();
  68. });
  69. $(window).resize(function () {
  70. $('#table').bootstrapTable('resetView', {
  71. height: getHeight()
  72. });
  73. });
  74. });
  75. // 格式化操作按钮
  76. function actionFormatter(value, row, index) {
  77. return [
  78. '<a class="update" href="javascript:void(0)" data-toggle="tooltip" title="Edit"><i class="glyphicon glyphicon-edit"></i></a> ',
  79. '<a class="delete" href="javascript:void(0)" data-toggle="tooltip" title="Remove"><i class="glyphicon glyphicon-remove"></i></a>'
  80. ].join('');
  81. }
  82. // 操作按钮事件
  83. window.actionEvents = {
  84. 'click .update': function (e, value, row, index) {
  85. alert('You click update icon, row: ' + JSON.stringify(row));
  86. console.log(value, row, index);
  87. },
  88. 'click .delete': function (e, value, row, index) {
  89. alert('You click delete icon, row: ' + JSON.stringify(row));
  90. console.log(value, row, index);
  91. }
  92. };
  93. // 展开内容
  94. function detailFormatter(index, row) {
  95. var html = [];
  96. $.each(row, function (key, value) {
  97. html.push('<p><b>' + key + ':</b> ' + value + '</p>');
  98. });
  99. return html.join('');
  100. }
  101. // 动态高度
  102. function getHeight() {
  103. return $(window).height() - 20;
  104. }
  105. </script>
  106. </body>
  107. </html>