index.blade.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. @extends('admin/layout')
  2. @section('content')
  3. <style>
  4. .btn-primary, .btn-info {
  5. background: #009688 !important;
  6. border-color: #009688 !important;
  7. }
  8. </style>
  9. <body class="gray-bg">
  10. <div class="wrapper wrapper-content animated fadeInRight">
  11. <div class="row">
  12. <div class="col-sm-12">
  13. <div class="ibox float-e-margins">
  14. <div class="ibox-content">
  15. <form class="row" id="searchForm">
  16. <div class="col-md-4">
  17. <div class="input-group">
  18. <span class="input-group-btn">
  19. <button type="button" class="btn btn-md btn-primary" onclick="units.saveView(0)"
  20. style="margin-left: 10px"> <span class="glyphicon glyphicon-plus"></span> 添加</button>
  21. <button type="button" class="btn btn-md btn-danger" id="batchDelete"
  22. style="margin-left: 10px"><span
  23. class="glyphicon glyphicon-remove"></span> 删除</button>
  24. </span>
  25. </div>
  26. </div>
  27. </form>
  28. <hr>
  29. <div class="table-responsive">
  30. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </body>
  38. @endsection
  39. @section('footer')
  40. <script>
  41. var units = {
  42. search: function () {
  43. tips.selectPage();
  44. },
  45. getIdsBySelections: function () {
  46. var selections = $("#table").bootstrapTable('getSelections');
  47. var ids = [];
  48. $.each(selections, function (inx, val) {
  49. ids.push(val.id);
  50. });
  51. return ids;
  52. },
  53. permission: function (roleId) {
  54. var params = '?roleIds[]=' + roleId;
  55. layer.open({
  56. type: 2,
  57. content: ['/admin/system/roles/allot-permissions' + params],
  58. area: ['40%', '100%'],
  59. title: '分配权限'
  60. });
  61. },
  62. saveView: function (id) {
  63. layer.open({
  64. type: 2,
  65. content: ['/admin/system/roles/'+id],
  66. area: ['60%', '40%'],
  67. title: '保存'
  68. });
  69. }
  70. };
  71. var config = {};
  72. config.url = '/admin/system/roles';
  73. config.columns = [ //字段
  74. /*{checkbox: true},*/
  75. {
  76. title: '序号', align: 'center', formatter: function (value, item, index) {
  77. return index + 1;
  78. }
  79. },
  80. {title: '角色', field: 'name', align: 'center'},
  81. // {title: '状态', field: 'status_title', align: 'center'},
  82. {title: '创建时间', field: 'created_at', align: 'center'},
  83. {
  84. title: '操作', field: 'id', align: 'center',
  85. formatter: function (value) {
  86. return (
  87. '<button onclick="units.saveView(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;' +
  88. '<button onclick="units.permission(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>权限</button>'
  89. );
  90. }
  91. }
  92. ];
  93. tips.bootstrapTable(config);
  94. $(document).on('click', '#batchDelete', function () {
  95. var ids = units.getIdsBySelections();
  96. if (ids.length === 0) {
  97. layer.alert('请先选择您所要操作的对象');
  98. return;
  99. }
  100. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function () {
  101. tips.ajax({url: '/admin/system/roles', type: 'delete', data: {ids: ids},tableRefresh:'#table'});
  102. });
  103. });
  104. </script>
  105. @endsection