index.blade.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. @extends('admin.layouts.app')
  2. @section('header')
  3. <script src="/base/js/plugins/fileDownload/jquery.fileDownload.js"></script>
  4. @endsection
  5. @section('content')
  6. <div class="row">
  7. <div class="col-sm-12">
  8. <div class="ibox float-e-margins">
  9. <div class="ibox-title">
  10. <h5>我的线索</h5>
  11. <div class="ibox-tools">
  12. <a class="collapse-link"> <i class="fa fa-chevron-up"></i>
  13. </a>
  14. </div>
  15. </div>
  16. <div class="ibox-content">
  17. <div class="form-group">
  18. @if(role('User/Threads/addCallList'))
  19. <div class="col-sm-8 pull-right">
  20. <span class="btn btn-primary pull-right fa fa-phone"
  21. data-toggle="modal"
  22. data-target="#myModal2">添加到电话列表</span>
  23. <span id="export_threads" class="btn btn-success pull-right fa fa-table"
  24. style="display: none">导出到Excel</span>
  25. </div>
  26. @endif
  27. </div>
  28. </div>
  29. {{--添加过滤条件--}}
  30. <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
  31. <tr>
  32. <th> 过滤条件</th>
  33. <form method="GET" action="" accept-charset="UTF-8" id="filter_threads">
  34. <th>
  35. <select name="process" class="form-control" onchange="filter_threads()">
  36. <option value="">有无跟进</option>
  37. <option value="1">有</option>
  38. <option value="2">无</option>
  39. </select>
  40. </th>
  41. <th>
  42. <div class="input-group">
  43. <input type="text" class="form-control" value="{{Request::get('keyword')}}"
  44. placeholder="请输入企业名称或电话"
  45. name="keyword">
  46. <span class="input-group-append">
  47. <span class="btn btn-sm btn-default"
  48. style="height: 100%" onclick="filter_threads()">搜索</span>
  49. </span>
  50. </div>
  51. </th>
  52. </form>
  53. </tr>
  54. </table>
  55. <div id="threads-list">
  56. @include('admin.user.threads.data')
  57. </div>
  58. </div>
  59. </div>
  60. <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
  61. <div class="modal-dialog">
  62. <div class="modal-content animated flipInY">
  63. <div class="modal-header">
  64. <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span
  65. class="sr-only">Close</span></button>
  66. <h4 class="modal-title">选择拨打的IP</h4></div>
  67. <small class="font-bold">
  68. <div class="modal-body">
  69. <div class="ibox float-e-margins">
  70. <div class="ibox-content">
  71. <select name="ip" class="form-control" id="ip">
  72. <option value="172.31.20.133">172.31.20.133</option>
  73. <option value="172.31.20.134">172.31.20.134</option>
  74. <option value="172.31.20.135">172.31.20.135</option>
  75. <option value="172.31.20.136">172.31.20.136</option>
  76. <option value="172.31.20.137">172.31.20.137</option>
  77. </select>
  78. <div class="form-group">
  79. <label class="control-label col-sm-3">&nbsp;</label>
  80. <div class="col-sm-9">
  81. <input type="submit" class="btn btn-success" style="margin-right:20px;"
  82. id="addCallList">
  83. <input type="reset" class="btn btn-default">
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. <div class="modal-footer">
  90. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  91. </div>
  92. </small>
  93. </div>
  94. <small class="font-bold">
  95. </small>
  96. </div>
  97. <small class="font-bold">
  98. </small>
  99. </div>
  100. </div>
  101. @endsection
  102. @section('js')
  103. <script type="text/javascript">
  104. var checkedIds = []
  105. /*电话全选功能*/
  106. $('body').on('click', '#checkAll', function () {
  107. items = $('.contacts');
  108. isChecked = $(this).prop('checked');
  109. items.prop('checked', isChecked);
  110. items.each(function () {
  111. saveChecked($(this))
  112. });
  113. if (checkedIds.length) {
  114. $('#addCallList').show();
  115. $('#export_threads').show()
  116. } else {
  117. $('#addCallList').hide();
  118. $('#export_threads').hide()
  119. }
  120. });
  121. $('body').on('click', '#checkTotal', function () {
  122. items = $('.contacts');
  123. isChecked = $(this).prop('checked')
  124. items.prop('checked', isChecked)
  125. if (isChecked == true) {
  126. $('.fa-phone').show()
  127. checkedIds = [{{ $allIds }}][0]
  128. $('#export_threads').show()
  129. $('#checkAll').prop('checked', true)
  130. } else {
  131. $('.fa-phone').hide()
  132. $('#checkAll').prop('checked', false)
  133. checkedIds = []
  134. }
  135. })
  136. $('body').on('click', '.contacts', function () {
  137. items = $('.contacts');
  138. checkedLength = $('.contacts:checked').length
  139. if (checkedLength) {
  140. $('#addCallList').show()
  141. $('#export_threads').show()
  142. } else {
  143. $('#addCallList').hide()
  144. $('#export_threads').hide()
  145. }
  146. if (items.length == checkedLength) {
  147. $('#checkAll').prop('checked', true)
  148. $('#addCallList').show()
  149. $('#export_threads').show()
  150. } else {
  151. $('#checkAll').prop('checked', false)
  152. }
  153. saveChecked($(this))
  154. console.log(checkedIds)
  155. });
  156. /*保存选中的项*/
  157. function saveChecked(e) {
  158. if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
  159. checkedIds.push(e.data("id"));
  160. } else {
  161. for (var i = 0; i < checkedIds.length; i++) {
  162. if (e.data("id") == checkedIds[i]) {
  163. checkedIds.splice(i, 1);
  164. break;
  165. }
  166. }
  167. }
  168. }
  169. /*翻页后设置选中项*/
  170. function setChecked() {
  171. var $boxes = $('.contacts');
  172. $boxes.each(function () {
  173. id = $(this).data('id')
  174. if (checkedIds.indexOf(id, 0) != -1) {
  175. $(this).prop('checked', true)
  176. } else {
  177. $(this).prop('checked', false)
  178. }
  179. })
  180. checkedLength = $('.contacts:checked').length
  181. if(checkedLength == $boxes.length){
  182. $('#checkAll').prop('checked', true)
  183. }
  184. }
  185. /*添加选择的电话到拨打列表*/
  186. $('#addCallList').click(function () {
  187. contact_ids = checkedIds
  188. csrf_token = "{{ csrf_token() }}"
  189. ip = $('#ip').val()
  190. $.ajax({
  191. type: 'post',
  192. url: '{{ U('User/Threads/addCallList') }}',
  193. data: {contact_ids: contact_ids, _token: csrf_token, ip: ip},
  194. success: function (data) {
  195. if (data == 200) {
  196. layer.msg('导入成功', {
  197. icon: 1,
  198. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  199. }, function () {
  200. window.location.href = window.location.href
  201. });
  202. }
  203. }
  204. })
  205. });
  206. /*导出线索到excel*/
  207. $('#export_threads').click(function () {
  208. threads_ids = checkedIds
  209. csrf_token = "{{ csrf_token() }}";
  210. $.ajax({
  211. type: 'post',
  212. url: '{{ U('User/Threads/export_threads') }}',
  213. data: {threads_ids: threads_ids, type: 1, _token: csrf_token},
  214. success: function (data) {
  215. $.fileDownload("{{ U('User/Threads/export_threads') }}", {
  216. data: {threads_ids: threads_ids, _token: csrf_token},
  217. prepareCallback: function (url) {
  218. console.log("开始下载");
  219. },
  220. successCallback: function (url) {
  221. console.log("正在下载,请稍后...");
  222. console.log("SUCCESS", "导出完成!");
  223. },
  224. failCallback: function (html, url) {
  225. console.log("正在下载,请稍后...");
  226. console.log("ERROR", "导出失败,未知的异常!");
  227. }
  228. });
  229. }
  230. })
  231. });
  232. /*线索筛选*/
  233. function filter_threads() {
  234. data = $('#filter_threads').serialize()
  235. $.ajax({
  236. type: 'get',
  237. data: data,
  238. }).done(function (data) {
  239. $('#threads-list').html(data.html)
  240. })
  241. }
  242. /*Ajax 分页*/
  243. $('body').on('click', '.pagination a', function (e) {
  244. e.preventDefault();
  245. if ($(this).attr('href') != '#') {
  246. data = $('#filter_threads').serialize()
  247. $.ajax({
  248. url: $(this).attr('href'),
  249. type: 'get',
  250. data: data,
  251. }).done(function (data) {
  252. $('#threads-list').html(data.html)
  253. setChecked()
  254. })
  255. }
  256. });
  257. </script>
  258. @endsection