index.blade.php 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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', '#checkTotal', function () {
  128. items = $('.contacts');
  129. isChecked = $(this).prop('checked')
  130. items.prop('checked', isChecked)
  131. if (isChecked == true) {
  132. $('.fa-phone').show()
  133. checkedIds = [{{ $allIds }}][0]
  134. $('#checkAll').prop('checked',true)
  135. } else {
  136. $('.fa-phone').hide()
  137. $('#checkAll').prop('checked', false)
  138. checkedIds = []
  139. }
  140. })
  141. $('body').on('click', '.contacts', function () {
  142. items = $('.contacts');
  143. checkedLength = $('.contacts:checked').length
  144. if (checkedLength) {
  145. $('.fa-phone').show()
  146. } else {
  147. $('.fa-phone').hide()
  148. }
  149. if (items.length == checkedLength) {
  150. $('#checkAll').prop('checked', true)
  151. $('.fa-phone').show()
  152. } else {
  153. $('#checkAll').prop('checked', false)
  154. }
  155. saveChecked($(this))
  156. });
  157. /*添加选择的电话到拨打列表*/
  158. $('#addCallList').click(function () {
  159. contact_phones = checkedIds;
  160. csrf_token = "{{ csrf_token() }}";
  161. ip = $('#ip').val()
  162. $.ajax({
  163. type: 'post',
  164. url: '{{ U('Call/Records/addCallList') }}',
  165. data: {contact_phones: contact_phones, _token: csrf_token, ip:ip},
  166. success: function (data) {
  167. if (data == 200) {
  168. layer.msg('导入成功', {
  169. icon: 1,
  170. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  171. }, function () {
  172. window.location.href = window.location.href
  173. });
  174. }
  175. }
  176. })
  177. });
  178. /*保存选中的项*/
  179. function saveChecked(e) {
  180. if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
  181. checkedIds.push(e.data("id"));
  182. } else {
  183. for (var i = 0; i < checkedIds.length; i++) {
  184. if (e.data("id") == checkedIds[i]) {
  185. checkedIds.splice(i, 1);
  186. break;
  187. }
  188. }
  189. }
  190. }
  191. /*翻页后设置选中项*/
  192. function setChecked() {
  193. var $boxes = $('.contacts');
  194. $boxes.each(function () {
  195. id = $(this).data('id')
  196. if (checkedIds.indexOf(id, 0) != -1) {
  197. $(this).prop('checked', true)
  198. } else {
  199. $(this).prop('checked', false)
  200. }
  201. })
  202. checkedLength = $('.contacts:checked').length
  203. if(checkedLength == $boxes.length){
  204. $('#checkAll').prop('checked', true)
  205. }
  206. }
  207. /*通话纪录筛选*/
  208. function filter_records() {
  209. data = $('#filter_records').serialize();
  210. $.ajax({
  211. type: 'get',
  212. data: data,
  213. }).done(function (data) {
  214. $('#records-list').html(data.html)
  215. })
  216. }
  217. /*Ajax分页*/
  218. $('body').on('click', '.pagination a', function (e) {
  219. e.preventDefault();
  220. if ($(this).attr('href') != '#') {
  221. data = $('#filter_records').serialize()
  222. $.ajax({
  223. url: $(this).attr('href'),
  224. type: 'get',
  225. data: data,
  226. }).done(function (data) {
  227. $('#records-list').html(data.html)
  228. setChecked()
  229. })
  230. }
  231. });
  232. </script>
  233. @endsection