index.blade.php 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216
  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 id="addCallList" class="btn btn-primary pull-right fa fa-phone"
  21. style="display: none">添加到电话列表</span>
  22. <span id="export_threads" class="btn btn-success pull-right fa fa-table"
  23. style="display: none">导出到Excel</span>
  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_threads">
  33. <th>
  34. <select name="process" class="form-control" onchange="filter_threads()">
  35. <option value="">有无跟进</option>
  36. <option value="1">有</option>
  37. <option value="2">无</option>
  38. </select>
  39. </th>
  40. {{--<th style="width: 40%">--}}
  41. {{--<div class="row">--}}
  42. {{--<div class="col-sm-5" id="data_1">--}}
  43. {{--<div class="input-group date">--}}
  44. {{--<span class="input-group-addon">--}}
  45. {{--<i class="fa fa-calendar"></i></span>--}}
  46. {{--<input type="text" id="start" class="form-control" placeholder="领取日期"--}}
  47. {{--name="start"--}}
  48. {{--value="{{Request::get('start') ? : ''}}">--}}
  49. {{--</div>--}}
  50. {{--</div>--}}
  51. {{--_--}}
  52. {{--<div class="col-sm-5" id="data_2">--}}
  53. {{--<div class="input-group date">--}}
  54. {{--<span class="input-group-addon">--}}
  55. {{--<i class="fa fa-calendar"></i></span>--}}
  56. {{--<input type="text" id="end" class="form-control" placeholder="领取日期"--}}
  57. {{--name="end"--}}
  58. {{--value="{{Request::get('end') ? : ''}}">--}}
  59. {{--</div>--}}
  60. {{--</div>--}}
  61. {{--</div>--}}
  62. {{--</th>--}}
  63. <th>
  64. <div class="input-group">
  65. <input type="text" class="form-control" value="{{Request::get('keyword')}}"
  66. placeholder="请输入企业名称"
  67. name="keyword">
  68. <span class="input-group-append">
  69. <span class="btn btn-sm btn-default"
  70. style="height: 100%" onclick="filter_threads()">搜索</span>
  71. </span>
  72. </div>
  73. </th>
  74. </form>
  75. </tr>
  76. </table>
  77. <div id="threads-list">
  78. @include('admin.user.threads.data')
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. @endsection
  85. @section('js')
  86. <script type="text/javascript">
  87. /*电话全选功能*/
  88. $('body').on('click','#checkAll',function () {
  89. items = $('.contacts');
  90. isChecked = $(this).prop('checked');
  91. items.prop('checked', isChecked);
  92. if (isChecked == true) {
  93. $('#addCallList').show();
  94. $('#export_threads').show()
  95. } else {
  96. $('#addCallList').hide();
  97. $('#export_threads').hide()
  98. }
  99. });
  100. $('body').on('click','.contacts',function () {
  101. items = $('.contacts');
  102. checkedLength = $('.contacts:checked').length
  103. if (checkedLength) {
  104. $('#addCallList').show()
  105. $('#export_threads').show()
  106. } else {
  107. $('#addCallList').hide()
  108. $('#export_threads').hide()
  109. }
  110. if (items.length == checkedLength) {
  111. $('#addCallList').show()
  112. $('#export_threads').show()
  113. } else {
  114. $('#checkAll').prop('checked', false)
  115. }
  116. });
  117. /*添加选择的电话到拨打列表*/
  118. $('#addCallList').click(function () {
  119. contact_ids = []
  120. csrf_token = "{{ csrf_token() }}"
  121. $('.contacts:checked').each(function () {
  122. contact_ids.push($(this).val())
  123. })
  124. $.ajax({
  125. type: 'post',
  126. url: '{{ U('User/Threads/addCallList') }}',
  127. data: {contact_ids: contact_ids, _token: csrf_token},
  128. success: function (data) {
  129. if (data == 200) {
  130. layer.msg('导入成功', {
  131. icon: 1,
  132. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  133. }, function () {
  134. window.location.href = window.location.href
  135. });
  136. }
  137. }
  138. })
  139. });
  140. /*导出线索到excel*/
  141. $('#export_threads').click(function () {
  142. threads_ids = [];
  143. csrf_token = "{{ csrf_token() }}";
  144. $('.contacts:checked').each(function () {
  145. threads_ids.push($(this).val())
  146. });
  147. $.ajax({
  148. type: 'post',
  149. url: '{{ U('User/Threads/export_threads') }}',
  150. data: {threads_ids: threads_ids,type:1, _token: csrf_token},
  151. success: function (data) {
  152. $.fileDownload("{{ U('User/Threads/export_threads') }}", {
  153. data: {threads_ids: threads_ids, _token: csrf_token},
  154. prepareCallback: function (url) {
  155. console.log("开始下载");
  156. },
  157. successCallback: function (url) {
  158. console.log("正在下载,请稍后...");
  159. console.log("SUCCESS", "导出完成!");
  160. },
  161. failCallback: function (html, url) {
  162. console.log("正在下载,请稍后...");
  163. console.log("ERROR", "导出失败,未知的异常!");
  164. }
  165. });
  166. }
  167. })
  168. });
  169. /*线索筛选*/
  170. function filter_threads() {
  171. data = $('#filter_threads').serialize()
  172. $.ajax({
  173. type: 'get',
  174. data: data,
  175. }).done(function (data) {
  176. $('#threads-list').html(data.html)
  177. })
  178. }
  179. /*Ajax 分页*/
  180. $('body').on('click', '.pagination a', function (e) {
  181. e.preventDefault();
  182. if ($(this).attr('href') != '#') {
  183. data = $('#filter_threads').serialize()
  184. $.ajax({
  185. url: $(this).attr('href'),
  186. type: 'get',
  187. data: data,
  188. }).done(function (data) {
  189. $('#threads-list').html(data.html)
  190. })
  191. }
  192. });
  193. </script>
  194. @endsection