all.blade.php 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. @extends('layouts.admin.app_iframe')
  2. @section('plug-css')
  3. <link href="{{ asset('js/bootstrap-table/dist/bootstrap-table.css') }}" rel="stylesheet">
  4. @endsection
  5. @section('content')
  6. <form id="searchForm" class="form-inline">
  7. <div class="">
  8. <div class="form-group">
  9. <label for="name" class="label-css"> ID:</label>
  10. <input class="form-control" type="text" name="id">
  11. </div>
  12. <div class="form-group">
  13. <label for="name" class="label-css"> 昵称:</label>
  14. <input class="form-control" type="text" name="nickname">
  15. </div>
  16. <div class="form-group">
  17. <label for="name" class="label-css"> 手机号:</label>
  18. <input class="form-control" type="text" name="phone">
  19. </div>
  20. <button type="button" class="btn btn-primary">查询</button>
  21. </div>
  22. </form>
  23. <hr class="hr-css">
  24. <div>
  25. <div id="toolbar">
  26. <div class="columns columns-left btn-group pull-left">
  27. </div>
  28. </div>
  29. <table id="ContentTable"></table>
  30. <div class="pull-right" style="padding-top: 20px">
  31. <button class="btn btn-danger"
  32. title="" data-toggle="tooltip" type="button" id="delIds"
  33. data-original-title="清除">清除
  34. </button>
  35. <button class="btn btn-primary"
  36. title="" data-toggle="tooltip" type="button" id="selectAllIds"
  37. data-original-title="全选">全选
  38. </button>
  39. <button class="btn btn-primary"
  40. title="" data-toggle="tooltip" type="button" id="setIds"
  41. data-original-title="确定">确定
  42. </button>
  43. </div>
  44. </div>
  45. @endsection
  46. @section('plug-js')
  47. <script src="{{ asset('js/bootstrap-table/dist/bootstrap-table.js') }}"></script>
  48. <script src="{{ asset('table_admin/js/common.js') }}"></script>
  49. <script src="{{ asset('js/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js') }}"></script>
  50. <script src="{{ asset('js/jquery-validation1.16/dist/jquery.validate.min.js') }}"></script>
  51. <script src="{{ asset('js/jquery-validation1.16/dist/additional-methods.min.js') }}"></script>
  52. <script src="{{ asset('js/jquery-validation1.16/src/localization/messages_zh.js') }}"></script>
  53. @endsection
  54. @section('scripts')
  55. <script>
  56. function getUrlParam(name) {
  57. let reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
  58. let r = window.location.search.substr(1).match(reg); //匹配目标参数
  59. if (r != null) return unescape(r[2]); return null; //返回参数值
  60. }
  61. $(function () {
  62. //商品选择绑定
  63. $('#setIds').click(function (){
  64. window.top.setUserIds(userIds);
  65. layer.closeAll();
  66. });
  67. //全选绑定
  68. $('#selectAllIds').click(function (){
  69. let data= $('#searchForm').serializeArray();
  70. sendajax("{{ route('admin.member.member-ids') }}",data,function (ret){
  71. let userIds=[];
  72. if(ret.code*1===1){
  73. userIds=ret.data.join(',');
  74. userIds=userIds.split(',');
  75. }
  76. console.log(ret)
  77. window.top.setUserIds(userIds);
  78. layer.closeAll();
  79. })
  80. });
  81. //请求参数获取
  82. let userIds= window.top.getUserIds();
  83. console.log(userIds)
  84. if(!userIds){
  85. userIds=[];
  86. }
  87. $('#delIds').click(function (){
  88. userIds = [];
  89. let data= $('#ContentTable').bootstrapTable('getData');
  90. data.forEach((value, key) => {
  91. value.checkbox = false
  92. $('#ContentTable').bootstrapTable('updateRow', {
  93. index: key,
  94. row: value
  95. });
  96. })
  97. });
  98. BootStrapInit.init('tableGood', 'ContentTable', {
  99. searchForm: 'searchForm', // 表单搜索id 省略默认 'searchForm'
  100. url: "{{ route('admin.member.ajax.index',['no_purchases'=>1]) }}",
  101. method: 'post',
  102. toolbar: '#toolbar',
  103. idField: '', // 指定主键列
  104. uniqueId: "id", // 这里需要指定当前查询表唯一主键字段
  105. onCheckAll: function (rowsAfter) {
  106. console.log(rowsAfter)
  107. rowsAfter.forEach((v,k)=>{
  108. let id_key = userIds.indexOf(v.id + '')
  109. if (id_key <0) {
  110. userIds.push(v.id + '')
  111. }
  112. });
  113. console.log(userIds)
  114. },
  115. onUncheckAll:function (rowsAfter){
  116. console.log(rowsAfter)
  117. rowsAfter.forEach((v,k)=>{
  118. let id_key = userIds.indexOf(v.id + '')
  119. if (id_key >= 0) {
  120. userIds.splice(id_key, 1)
  121. }
  122. });
  123. console.log(userIds)
  124. },
  125. onCheck: function (row) {
  126. userIds.push(row.id+'')
  127. },
  128. onUncheck: function (row) {
  129. let id_key=userIds.indexOf(row.id+'')
  130. if(id_key>=0){
  131. userIds.splice(id_key,1)
  132. }
  133. },
  134. onLoadSuccess:function (data){
  135. console.log(data)
  136. data.rows.forEach((value,key)=>{
  137. if(userIds.indexOf(value.id+'')>=0){
  138. value.checkbox=true
  139. }else {
  140. value.checkbox=false
  141. }
  142. $('#ContentTable').bootstrapTable('updateRow', {
  143. index: key,
  144. row: value
  145. });
  146. })
  147. },
  148. columns: [
  149. {
  150. align: 'center',
  151. field: 'checkbox',
  152. checkbox: true,
  153. formatter: stateFormatter,
  154. },
  155. {
  156. field: 'id',
  157. title: 'ID',
  158. align: 'center',
  159. valign: 'middle',
  160. },
  161. {
  162. field: 'nickname',
  163. title: '会员昵称',
  164. align: 'center',
  165. valign: 'middle',
  166. },
  167. {
  168. field: 'phone',
  169. title: '会员电话',
  170. align: 'center',
  171. valign: 'middle',
  172. },
  173. {
  174. field: 'head_img',
  175. title: '头像',
  176. align: 'center',
  177. valign: 'middle',
  178. formatter:thumbFormatter
  179. },
  180. {
  181. field: 'created_at',
  182. title: '注册时间',
  183. align: 'center',
  184. valign: 'middle',
  185. },
  186. ]
  187. });
  188. });
  189. </script>
  190. @endsection