user.blade.php 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. @extends('admin/layout')
  2. @section('content')
  3. <body class="gray-bg">
  4. <div class="wrapper wrapper-content animated fadeInRight">
  5. <div class="row">
  6. <div class="col-sm-12">
  7. <div class="ibox float-e-margins">
  8. <div class="ibox-title"></div>
  9. <div class="ibox-content">
  10. <form class="row" id="searchForm" onsubmit="units.search();return false;">
  11. <div class="col-md-4">
  12. <div class="input-group">
  13. <span class="input-group-btn">
  14. {{--<button type="button" class="btn btn-md btn-info" id="on"><span--}}
  15. {{--class="glyphicon glyphicon-hand-up"></span> 启用</button>--}}
  16. {{--<button type="button" class="btn btn-md btn-warning" id="off"--}}
  17. {{--style="margin-left: 10px"><span--}}
  18. {{--class="glyphicon glyphicon-hand-down"></span> 禁用</button>--}}
  19. <button type="button" class="btn btn-md btn-primary" style="margin-left: 10px"
  20. onclick="units.save(0)"> <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. <div class="col-md-6 pull-right">
  28. <div class="input-group">
  29. <input type="text" placeholder="请输入用户名" class="input-md form-control" name="keyword"
  30. id="keyWord">
  31. <span class="input-group-btn">
  32. <button type="button" class="btn btn-md btn-primary"
  33. onclick="units.search()"> 搜索</button>
  34. <button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"
  35. name="resetBtn"> 重置</button> </span>
  36. </div>
  37. </div>
  38. </form>
  39. <hr>
  40. <div class="table-responsive">
  41. <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </body>
  49. @endsection
  50. @section('footer')
  51. <script>
  52. var units = {
  53. search: function () {
  54. tips.selectPage();
  55. },
  56. getIdsBySelections: function () {
  57. var selections = $("#table").bootstrapTable('getSelections');
  58. var ids = [];
  59. $.each(selections, function (inx, val) {
  60. ids.push(val.id);
  61. });
  62. return ids;
  63. },
  64. save: function (id) {
  65. layer.open({
  66. type: 2,
  67. content: ['/admin/agents/users/' + id],
  68. area: ['60%', '100%'],
  69. title: '保存'
  70. });
  71. },
  72. permission: function (userId) {
  73. var params = '?userIds[]=' + userId;
  74. layer.open({
  75. type: 2,
  76. content: '/admin/system/user-permissions' + params,
  77. area: ['50%', '100%'],
  78. title: '详情'
  79. });
  80. }
  81. };
  82. var config = {};
  83. config.url = '/admin/agents/users';
  84. config.columns = [ //字段
  85. {checkbox: true},
  86. {
  87. title: '序号', align: 'center', formatter: function (value, item, index) {
  88. return index + 1;
  89. }
  90. },
  91. {title: '昵称', field: 'nickname', align: 'center'},
  92. {title: '用户名', field: 'username', align: 'center'},
  93. {title: '邮箱', field: 'email', align: 'center'},
  94. {title: '角色', field: 'role_name', align: 'center'},
  95. {title: '创建时间', field: 'created_at', align: 'center'},
  96. {
  97. title: '操作', field: 'id', align: 'center',
  98. formatter: function (value, rows) {
  99. var str = '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;';
  100. if (rows.role_id == 5) { //客户
  101. str += '<button onclick="units.permission(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>权限</button>';
  102. }
  103. return str;
  104. }
  105. }
  106. ];
  107. tips.bootstrapTable(config);
  108. $(document).on('click', '#on', function () {
  109. var ids = units.getIdsBySelections();
  110. if (ids.length === 0) {
  111. layer.alert('请先选择您所要操作的对象', {icon: 0});
  112. return;
  113. }
  114. tips.ajax({url: '/admin/system/users/on', type: 'put', data: {ids: ids}});
  115. tips.tableRefresh('#table');
  116. });
  117. $(document).on('click', '#off', function () {
  118. var ids = units.getIdsBySelections();
  119. if (ids.length === 0) {
  120. layer.alert('请先选择您所要操作的对象', {icon: 0});
  121. return;
  122. }
  123. tips.ajax({url: '/admin/system/users/off', type: 'put', data: {ids: ids}});
  124. tips.tableRefresh('#table');
  125. });
  126. $(document).on('click', '#batchDelete', function () {
  127. var ids = units.getIdsBySelections();
  128. if (ids.length === 0) {
  129. layer.alert('请先选择您所要操作的对象', {icon: 0});
  130. return;
  131. }
  132. layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function () {
  133. tips.ajax({url: '/admin/system/users', type: 'delete', data: {ids: ids}, tableRefresh: '#table'});
  134. });
  135. });
  136. </script>
  137. @endsection