user.blade.php 6.5 KB

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