user.blade.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  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" onsubmit="units.search();return false;">
  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-info" id="on">批量启用</button>
  20. <button type="button" class="btn btn-md btn-danger" id="off"
  21. style="margin-left: 10px">批量禁用</button>
  22. <button type="button" class="btn btn-md btn-primary" style="margin-left: 10px"
  23. onclick="units.save(0)"> <span class="glyphicon glyphicon-plus"></span> 添加</button>
  24. <button type="button" class="btn btn-md btn-danger" id="batchDelete"
  25. style="margin-left: 10px"><span
  26. class="glyphicon glyphicon-remove"></span> 删除</button>
  27. </span>
  28. </div>
  29. </div>
  30. <div class="col-md-6 pull-right">
  31. <div class="input-group">
  32. <select name="role_id" id="role_id" class="form-control"
  33. style="width: 150px;float: right">
  34. <option value="">请选择角色</option>
  35. @foreach($roles as $role)
  36. <option value="{{$role->id}}">{{$role->name}}</option>
  37. @endforeach
  38. </select>
  39. <input type="text" placeholder="请输入用户名" class="input-md form-control" name="keyword"
  40. id="keyWord" style="width: 150px;float: right">
  41. <span class="input-group-btn">
  42. <button type="button" class="btn btn-md btn-primary"
  43. onclick="units.search()"> 搜索</button>
  44. <button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"
  45. name="resetBtn"> 重置</button> </span>
  46. </div>
  47. </div>
  48. </form>
  49. <hr>
  50. <div class="table-responsive">
  51. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </body>
  59. @endsection
  60. @section('footer')
  61. <script>
  62. var units = {
  63. search: function () {
  64. tips.selectPage();
  65. },
  66. getIdsBySelections: function () {
  67. var selections = $("#table").bootstrapTable('getSelections');
  68. var ids = [];
  69. $.each(selections, function (inx, val) {
  70. ids.push(val.id);
  71. });
  72. return ids;
  73. },
  74. save: function (id) {
  75. layer.open({
  76. type: 2,
  77. content: ['/admin/system/user/show/' + id],
  78. area: ['60%', '100%'],
  79. title: '保存'
  80. });
  81. },
  82. permission: function (userId) {
  83. var params = '?userIds[]=' + userId;
  84. layer.open({
  85. type: 2,
  86. content: '/admin/system/user-permissions' + params,
  87. area: ['50%', '100%'],
  88. title: '详情'
  89. });
  90. }
  91. };
  92. var config = {};
  93. config.url = '/admin/system/users';
  94. config.columns = [ //字段
  95. {checkbox: true},
  96. {
  97. title: '序号', align: 'center', formatter: function (value, item, index) {
  98. return index + 1;
  99. }
  100. },
  101. {title: '昵称', field: 'nickname', align: 'center'},
  102. {title: '用户名', field: 'username', align: 'center'},
  103. {
  104. title: '头像', field: 'profile_img', align: 'center', formatter: function (value, item) {
  105. return'<img src="'+value+'" style="width:64px">';
  106. }
  107. },
  108. {title: '邮箱', field: 'email', align: 'center'},
  109. {title: '角色', field: 'role_name', align: 'center'},
  110. {title: '状态', field: 'status_title', align: 'center'},
  111. {title: '创建时间', field: 'created_at', align: 'center'},
  112. {
  113. title: '操作', field: 'id', align: 'center',
  114. formatter: function (value, rows) {
  115. var str = '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;';
  116. if ([5, 23].indexOf(rows.role_id) !== -1) { //客户
  117. str += '<button onclick="units.permission(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>权限</button>';
  118. }
  119. return str;
  120. }
  121. }
  122. ];
  123. tips.bootstrapTable(config);
  124. $(document).on('click', '#on', function () {
  125. var ids = units.getIdsBySelections();
  126. if (ids.length === 0) {
  127. layer.alert('请先选择您所要操作的对象', {icon: 0});
  128. return;
  129. }
  130. tips.ajax({url: '/admin/system/users/on', type: 'put', data: {ids: ids}});
  131. tips.tableRefresh('#table');
  132. });
  133. $(document).on('click', '#off', function () {
  134. var ids = units.getIdsBySelections();
  135. if (ids.length === 0) {
  136. layer.alert('请先选择您所要操作的对象', {icon: 0});
  137. return;
  138. }
  139. tips.ajax({url: '/admin/system/users/off', type: 'put', data: {ids: ids}});
  140. tips.tableRefresh('#table');
  141. });
  142. $(document).on('click', '#batchDelete', function () {
  143. var ids = units.getIdsBySelections();
  144. if (ids.length === 0) {
  145. layer.alert('请先选择您所要操作的对象', {icon: 0});
  146. return;
  147. }
  148. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function () {
  149. tips.ajax({url: '/admin/system/users', type: 'delete', data: {ids: ids}, tableRefresh: '#table'});
  150. });
  151. });
  152. </script>
  153. @endsection