index.blade.php 9.6 KB

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