index.blade.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. @if(role('Call/Records/addCallList'))
  16. <div class="col-sm-8 pull-right">
  17. <span id="addCallList" class="btn btn-primary pull-right fa fa-phone"
  18. style="display: none">添加到电话列表</span>
  19. </div>
  20. @endif
  21. {{--@if(role('Call/Records/create'))--}}
  22. {{--<div class="col-sm-8 pull-right">--}}
  23. {{--<a href="{{ U('Call/Records/create')}}" class="btn btn-primary pull-right">添加</a>--}}
  24. {{--</div>--}}
  25. {{--@endif--}}
  26. </div>
  27. </div>
  28. {{-- 过滤条件 --}}
  29. <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
  30. <tr>
  31. <th> 过滤条件</th>
  32. <form method="GET" action="" accept-charset="UTF-8" id="filter_records">
  33. <th>
  34. <select name="ip" class="form-control" onchange="filter_records()">
  35. <option value="">拨打IP</option>
  36. <option value="172.31.20.133">172.31.20.133</option>
  37. <option value="172.31.20.134">172.31.20.134</option>
  38. <option value="172.31.20.135">172.31.20.135</option>
  39. <option value="172.31.20.136">172.31.20.136</option>
  40. <option value="172.31.20.137">172.31.20.137</option>
  41. </select>
  42. </th>
  43. <th>
  44. <select name="term_status" class="form-control" onchange="filter_records()">
  45. <option value="">接听状态</option>
  46. <option value="200">已接通</option>
  47. <option value="408">未接通</option>
  48. </select>
  49. </th>
  50. <th>
  51. <div class="input-group">
  52. <input type="text" class="form-control" value="{{Request::get('phone')}}"
  53. placeholder="请输入电话号码"
  54. name="phone">
  55. <span class="input-group-append">
  56. <span class="btn btn-sm btn-default"
  57. style="height: 100%" onclick="filter_records()">搜索</span>
  58. </span>
  59. </div>
  60. </th>
  61. </form>
  62. </tr>
  63. </table>
  64. <div id="records-list">
  65. @include('admin.call.records.data')
  66. </div>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. @endsection
  72. @section('js')
  73. <script type="text/javascript">
  74. var checkedIds = []
  75. /*电话全选功能*/
  76. $('body').on('click', '#checkAll', function () {
  77. items = $('.contacts');
  78. isChecked = $(this).prop('checked')
  79. items.prop('checked', isChecked)
  80. items.each(function () {
  81. saveChecked($(this))
  82. });
  83. if (isChecked == true) {
  84. $('#addCallList').show()
  85. } else {
  86. $('#addCallList').hide()
  87. }
  88. console.log(checkedIds)
  89. })
  90. $('body').on('click', '.contacts', function () {
  91. items = $('.contacts');
  92. checkedLength = $('.contacts:checked').length
  93. if (checkedLength) {
  94. $('#addCallList').show()
  95. } else {
  96. $('#addCallList').hide()
  97. }
  98. if (items.length == checkedLength) {
  99. $('#addCallList').show()
  100. } else {
  101. $('#checkAll').prop('checked', false)
  102. }
  103. saveChecked($(this))
  104. });
  105. /*添加选择的电话到拨打列表*/
  106. $('#addCallList').click(function () {
  107. contact_phones = checkedIds ;
  108. csrf_token = "{{ csrf_token() }}";
  109. $.ajax({
  110. type: 'post',
  111. url: '{{ U('Call/Records/addCallList') }}',
  112. data: {contact_phones: contact_phones, _token: csrf_token},
  113. success: function (data) {
  114. if (data == 200) {
  115. layer.msg('导入成功', {
  116. icon: 1,
  117. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  118. }, function () {
  119. window.location.href = window.location.href
  120. });
  121. }
  122. }
  123. })
  124. });
  125. /*保存选中的项*/
  126. function saveChecked(e) {
  127. if (e.is(":checked")) {
  128. checkedIds.push(e.data("id"));
  129. } else {
  130. for (var i = 0; i < checkedIds.length; i++) {
  131. if (e.data("id") == checkedIds[i]) {
  132. checkedIds.splice(i, 1);
  133. break;
  134. }
  135. }
  136. }
  137. }
  138. /*翻页后设置选中项*/
  139. function setChecked() {
  140. var $boxes = $('.contacts');
  141. $boxes.each(function () {
  142. id = $(this).data('id')
  143. if (checkedIds.indexOf(id, 0) != -1) {
  144. $(this).prop('checked', true)
  145. } else {
  146. $(this).prop('checked', false)
  147. }
  148. })
  149. }
  150. /*通话纪录筛选*/
  151. function filter_records() {
  152. data = $('#filter_records').serialize();
  153. $.ajax({
  154. type: 'get',
  155. data: data,
  156. }).done(function (data) {
  157. $('#records-list').html(data.html)
  158. })
  159. }
  160. /*Ajax分页*/
  161. $('body').on('click', '.pagination a', function (e) {
  162. e.preventDefault();
  163. if ($(this).attr('href') != '#') {
  164. data = $('#filter_records').serialize()
  165. $.ajax({
  166. url: $(this).attr('href'),
  167. type: 'get',
  168. data: data,
  169. }).done(function (data) {
  170. $('#records-list').html(data.html)
  171. setChecked()
  172. })
  173. }
  174. });
  175. </script>
  176. @endsection