index.blade.php 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. @extends('admin.layouts.app')
  2. @section('content')
  3. <div class="row">
  4. <div class="col-sm-12">
  5. <div class="ibox float-e-margins">
  6. <div class="ibox-title">
  7. <h5>通话列表</h5>
  8. <div class="ibox-tools">
  9. <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
  10. </a>
  11. </div>
  12. </div>
  13. <div class="ibox-content">
  14. <div class="form-group">
  15. <div class="row">
  16. <div class="col-sm-4">
  17. <form method="GET" action="" accept-charset="UTF-8" id="filter_list">
  18. <div class="input-group">
  19. <input type="text" class="form-control" value="{{Request::get('keyword')}}"
  20. placeholder="请输入关键词"
  21. name="keyword">
  22. <span class="input-group-append">
  23. <button type="submit" class="btn btn-primary"
  24. style="height: 100%">搜索</button>
  25. </span>
  26. </div>
  27. </form>
  28. </div>
  29. <div class="col-sm-8 pull-right">
  30. @if(role('Call/List/create'))
  31. <a href="{{ U('Call/List/create')}}" class="btn btn-primary pull-right">添加</a>
  32. @endif
  33. @if(role('Call/List/alldelete'))
  34. <button class="btn btn-danger pull-right" id="alldelete" style="display: none">批量删除</button>
  35. @endif
  36. </div>
  37. </div>
  38. </div>
  39. <div id="call-list">
  40. @include('admin.call.list.data')
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. @endsection
  47. @section('js')
  48. <script type="text/javascript">
  49. var checkedIds = []
  50. /*电话全选功能*/
  51. $('body').on('click', '#checkAll', function () {
  52. items = $('.calllist');
  53. isChecked = $(this).prop('checked')
  54. items.prop('checked', isChecked)
  55. items.each(function () {
  56. saveChecked($(this))
  57. });
  58. if (checkedIds.length) {
  59. $('#alldelete').show()
  60. } else {
  61. $('#alldelete').hide()
  62. }
  63. })
  64. $('body').on('click', '#checkTotal', function () {
  65. items = $('.calllist');
  66. isChecked = $(this).prop('checked')
  67. items.prop('checked', isChecked)
  68. if (isChecked == true) {
  69. $('#alldelete').show()
  70. checkedIds = [{{ $allIds }}][0]
  71. $('#checkAll').prop('checked', true)
  72. } else {
  73. $('#alldelete').hide()
  74. $('#checkAll').prop('checked', false)
  75. checkedIds = []
  76. }
  77. })
  78. $('body').on('click', '.calllist', function () {
  79. items = $('.calllist');
  80. checkedLength = $('.calllist:checked').length
  81. if (checkedLength) {
  82. $('#alldelete').show()
  83. } else {
  84. $('#alldelete').hide()
  85. }
  86. if (items.length == checkedLength) {
  87. $('#checkAll').prop('checked', true)
  88. $('#alldelete').show()
  89. } else {
  90. $('#checkAll').prop('checked', false)
  91. }
  92. saveChecked($(this))
  93. });
  94. /*批量删除*/
  95. $('#alldelete').click(function () {
  96. layer.confirm('你确定要删除选择的待导入电话吗?', {
  97. btn: ['确定', '取消']//按钮
  98. }, function (index) {
  99. layer.close(index);
  100. list_ids = checkedIds;
  101. csrf_token = "{{ csrf_token() }}";
  102. $.ajax({
  103. type: 'post',
  104. url: '{{ U('Call/list/alldelete') }}',
  105. data: {list_ids: list_ids, _token: csrf_token},
  106. success: function (data) {
  107. if (data == 200) {
  108. layer.msg('删除成功', {
  109. icon: 1,
  110. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  111. }, function () {
  112. window.location.href = window.location.href
  113. });
  114. }
  115. }
  116. })
  117. });
  118. });
  119. /*保存选中的项*/
  120. function saveChecked(e) {
  121. if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
  122. checkedIds.push(e.data("id"));
  123. } else {
  124. for (var i = 0; i < checkedIds.length; i++) {
  125. if (e.data("id") == checkedIds[i]) {
  126. checkedIds.splice(i, 1);
  127. break;
  128. }
  129. }
  130. }
  131. }
  132. /*翻页后设置选中项*/
  133. function setChecked() {
  134. var $boxes = $('.calllist');
  135. $boxes.each(function () {
  136. id = $(this).data('id')
  137. if (checkedIds.indexOf(id, 0) != -1) {
  138. $(this).prop('checked', true)
  139. } else {
  140. $(this).prop('checked', false)
  141. }
  142. })
  143. checkedLength = $('.calllist:checked').length
  144. if (checkedLength == $boxes.length) {
  145. $('#checkAll').prop('checked', true)
  146. }
  147. }
  148. /*通话纪录筛选*/
  149. function filter_records() {
  150. data = $('#filter_list').serialize();
  151. $.ajax({
  152. type: 'get',
  153. data: data,
  154. }).done(function (data) {
  155. $('#call-list').html(data.html)
  156. })
  157. }
  158. /*Ajax分页*/
  159. $('body').on('click', '.pagination a', function (e) {
  160. e.preventDefault();
  161. if ($(this).attr('href') != '#') {
  162. data = $('#filter_list').serialize()
  163. $.ajax({
  164. url: $(this).attr('href'),
  165. type: 'get',
  166. data: data,
  167. }).done(function (data) {
  168. $('#call-list').html(data.html)
  169. setChecked()
  170. })
  171. }
  172. });
  173. </script>
  174. @endsection