index.blade.php 10 KB

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