index.blade.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. var checkedIds = []
  88. /*电话全选功能*/
  89. $('body').on('click', '#checkAll', function () {
  90. items = $('.contacts');
  91. isChecked = $(this).prop('checked');
  92. items.prop('checked', isChecked);
  93. items.each(function () {
  94. saveChecked($(this))
  95. });
  96. if (isChecked == true) {
  97. $('#addCallList').show();
  98. $('#export_threads').show()
  99. } else {
  100. $('#addCallList').hide();
  101. $('#export_threads').hide()
  102. }
  103. console.log(checkedIds)
  104. });
  105. $('body').on('click', '.contacts', function () {
  106. items = $('.contacts');
  107. checkedLength = $('.contacts:checked').length
  108. if (checkedLength) {
  109. $('#addCallList').show()
  110. $('#export_threads').show()
  111. } else {
  112. $('#addCallList').hide()
  113. $('#export_threads').hide()
  114. }
  115. if (items.length == checkedLength) {
  116. $('#addCallList').show()
  117. $('#export_threads').show()
  118. } else {
  119. $('#checkAll').prop('checked', false)
  120. }
  121. saveChecked($(this))
  122. console.log(checkedIds)
  123. });
  124. /*保存选中的项*/
  125. function saveChecked(e) {
  126. if (e.is(":checked")) {
  127. checkedIds.push(e.data("id"));
  128. } else {
  129. for (var i = 0; i < checkedIds.length; i++) {
  130. if (e.data("id") == checkedIds[i]) {
  131. checkedIds.splice(i, 1);
  132. break;
  133. }
  134. }
  135. }
  136. }
  137. /*翻页后设置选中项*/
  138. function setChecked() {
  139. var $boxes = $('.contacts');
  140. $boxes.each(function () {
  141. id = $(this).data('id')
  142. if (checkedIds.indexOf(id, 0) != -1) {
  143. $(this).prop('checked', true)
  144. } else {
  145. $(this).prop('checked', false)
  146. }
  147. })
  148. }
  149. /*添加选择的电话到拨打列表*/
  150. $('#addCallList').click(function () {
  151. contact_ids = checkedIds
  152. csrf_token = "{{ csrf_token() }}"
  153. $.ajax({
  154. type: 'post',
  155. url: '{{ U('User/Threads/addCallList') }}',
  156. data: {contact_ids: contact_ids, _token: csrf_token},
  157. success: function (data) {
  158. if (data == 200) {
  159. layer.msg('导入成功', {
  160. icon: 1,
  161. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  162. }, function () {
  163. window.location.href = window.location.href
  164. });
  165. }
  166. }
  167. })
  168. });
  169. /*导出线索到excel*/
  170. $('#export_threads').click(function () {
  171. threads_ids = checkedIds
  172. csrf_token = "{{ csrf_token() }}";
  173. $.ajax({
  174. type: 'post',
  175. url: '{{ U('User/Threads/export_threads') }}',
  176. data: {threads_ids: threads_ids, type: 1, _token: csrf_token},
  177. success: function (data) {
  178. $.fileDownload("{{ U('User/Threads/export_threads') }}", {
  179. data: {threads_ids: threads_ids, _token: csrf_token},
  180. prepareCallback: function (url) {
  181. console.log("开始下载");
  182. },
  183. successCallback: function (url) {
  184. console.log("正在下载,请稍后...");
  185. console.log("SUCCESS", "导出完成!");
  186. },
  187. failCallback: function (html, url) {
  188. console.log("正在下载,请稍后...");
  189. console.log("ERROR", "导出失败,未知的异常!");
  190. }
  191. });
  192. }
  193. })
  194. });
  195. /*线索筛选*/
  196. function filter_threads() {
  197. data = $('#filter_threads').serialize()
  198. $.ajax({
  199. type: 'get',
  200. data: data,
  201. }).done(function (data) {
  202. $('#threads-list').html(data.html)
  203. })
  204. }
  205. /*Ajax 分页*/
  206. $('body').on('click', '.pagination a', function (e) {
  207. e.preventDefault();
  208. if ($(this).attr('href') != '#') {
  209. data = $('#filter_threads').serialize()
  210. $.ajax({
  211. url: $(this).attr('href'),
  212. type: 'get',
  213. data: data,
  214. }).done(function (data) {
  215. $('#threads-list').html(data.html)
  216. setChecked()
  217. })
  218. }
  219. });
  220. </script>
  221. @endsection