index.blade.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  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" style="display: none">添加到待导列表</span>
  23. <span class="btn btn-success pull-right fa fa-table"
  24. style="display: none" data-toggle="modal"
  25. data-target="#myModal1">导出到Excel</span>
  26. </div>
  27. @endif
  28. </div>
  29. </div>
  30. {{--添加过滤条件--}}
  31. <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
  32. <tr>
  33. <th> 过滤条件</th>
  34. <form method="GET" action="" accept-charset="UTF-8" id="filter_threads">
  35. <th>
  36. <select name="process" class="form-control" onchange="filter_threads()">
  37. <option value="">有无跟进</option>
  38. <option value="1">有</option>
  39. <option value="2">无</option>
  40. </select>
  41. </th>
  42. <th>
  43. <div class="input-group">
  44. <input type="text" class="form-control" value="{{Request::get('keyword')}}"
  45. placeholder="请输入企业名称或电话"
  46. name="keyword">
  47. <span class="input-group-append">
  48. <button type="button" class="btn btn-sm btn-default"
  49. onclick="filter_threads()">搜索</button>
  50. </span>
  51. </div>
  52. </th>
  53. </form>
  54. </tr>
  55. </table>
  56. <div id="threads-list">
  57. @include('admin.user.threads.data')
  58. </div>
  59. </div>
  60. </div>
  61. <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
  62. <div class="modal-dialog">
  63. <div class="modal-content animated flipInY">
  64. <div class="modal-header">
  65. <h4 class="modal-title">选择拨打的IP</h4></div>
  66. <small class="font-bold">
  67. <div class="modal-body">
  68. <div class="ibox float-e-margins">
  69. <div class="ibox-content">
  70. <select name="ip" class="form-control" id="ip">
  71. <option value="172.31.20.181">172.31.20.181</option>
  72. <option value="172.31.20.182">172.31.20.182</option>
  73. <option value="172.31.20.183">172.31.20.183</option>
  74. <option value="172.31.20.184">172.31.20.184</option>
  75. <option value="172.31.20.185">172.31.20.185</option>
  76. <option value="172.31.20.186">172.31.20.186</option>
  77. <option value="172.31.20.187">172.31.20.187</option>
  78. <option value="172.31.20.188">172.31.20.188</option>
  79. </select>
  80. <div class="form-group">
  81. <label class="control-label col-sm-3">&nbsp;</label>
  82. <div class="col-sm-9">
  83. <input type="submit" class="btn btn-success" style="margin-right:20px;"
  84. id="addCallList">
  85. <input type="reset" class="btn btn-default">
  86. </div>
  87. </div>
  88. </div>
  89. </div>
  90. </div>
  91. <div class="modal-footer">
  92. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  93. </div>
  94. </small>
  95. </div>
  96. <small class="font-bold">
  97. </small>
  98. </div>
  99. <small class="font-bold">
  100. </small>
  101. </div>
  102. <div class="modal inmodal" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
  103. <div class="modal-dialog">
  104. <div class="modal-content animated flipInY">
  105. <div class="modal-header">
  106. <h4 class="modal-title">选择要导出的字段</h4></div>
  107. <small class="font-bold">
  108. <div class="modal-body">
  109. <div class="ibox float-e-margins">
  110. <div class="ibox-content">
  111. <div class="form-group">
  112. <form action="" id="check-fields">
  113. <div class="row">
  114. <div class="col-sm-6">
  115. <h4 style="color: #ccc">联系方式:</h4>
  116. </div>
  117. </div>
  118. <div class="row">
  119. <div class="col-sm-3">
  120. <div class="checkbox checkbox-success">
  121. <input class="check-fields" type="checkbox" checked="checked"
  122. name="phone" disabled>
  123. <label>
  124. 电话
  125. </label>
  126. </div>
  127. </div>
  128. <div class="col-sm-3">
  129. <div class="checkbox checkbox-success">
  130. <input class="check-fields" type="checkbox" checked="checked"
  131. name="email">
  132. <label>
  133. Email
  134. </label>
  135. </div>
  136. </div>
  137. <div class="col-sm-3">
  138. <div class="checkbox checkbox-success">
  139. <input class="check-fields" type="checkbox" checked="checked"
  140. name="qq">
  141. <label>
  142. qq
  143. </label>
  144. </div>
  145. </div>
  146. </div>
  147. <div class="row">
  148. <div class="col-sm-6">
  149. <h4 style="color: #ccc">其他字段:</h4>
  150. </div>
  151. </div>
  152. <div class="row">
  153. <div class="col-sm-3">
  154. <div class="checkbox checkbox-success">
  155. <input class="check-fields" type="checkbox" checked="checked"
  156. name="company_name" disabled>
  157. <label>
  158. 企业名称
  159. </label>
  160. </div>
  161. </div>
  162. <div class="col-sm-3">
  163. <div class="checkbox checkbox-success">
  164. <input class="check-fields" type="checkbox" checked="checked"
  165. name="ower_name">
  166. <label>
  167. 线索拥有者
  168. </label>
  169. </div>
  170. </div>
  171. <div class="col-sm-3">
  172. <div class="checkbox checkbox-success">
  173. <input class="check-fields" type="checkbox" checked="checked"
  174. name="website">
  175. <label>
  176. 企业网址
  177. </label>
  178. </div>
  179. </div>
  180. <div class="col-sm-3">
  181. <div class="checkbox checkbox-success">
  182. <input class="check-fields" type="checkbox" checked="checked"
  183. name="legal_person">
  184. <label>
  185. 法人
  186. </label>
  187. </div>
  188. </div>
  189. <div class="col-sm-3">
  190. <div class="checkbox checkbox-success">
  191. <input class="check-fields" type="checkbox" checked="checked"
  192. name="reg_capital">
  193. <label>
  194. 注册资本
  195. </label>
  196. </div>
  197. </div>
  198. <div class="col-sm-3">
  199. <div class="checkbox checkbox-success">
  200. <input class="check-fields" type="checkbox" checked="checked"
  201. name="reg_addr">
  202. <label>
  203. 注册地址
  204. </label>
  205. </div>
  206. </div>
  207. <div class="col-sm-3">
  208. <div class="checkbox checkbox-success">
  209. <input class="check-fields" type="checkbox" checked="checked"
  210. name="lastest">
  211. <label>
  212. 最新跟进
  213. </label>
  214. </div>
  215. </div>
  216. <div class="col-sm-3">
  217. <div class="checkbox checkbox-success">
  218. <input class="check-fields" type="checkbox" checked="checked"
  219. name="created_at">
  220. <label>
  221. 领取时间
  222. </label>
  223. </div>
  224. </div>
  225. </div>
  226. </form>
  227. </div>
  228. <div class="form-group">
  229. <label class="control-label col-sm-3">&nbsp;</label>
  230. <div class="col-sm-9">
  231. <input type="submit" class="btn btn-success" style="margin-right:20px;"
  232. id="export_threads">
  233. </div>
  234. </div>
  235. </div>
  236. </div>
  237. </div>
  238. <div class="modal-footer">
  239. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  240. </div>
  241. </small>
  242. </div>
  243. <small class="font-bold">
  244. </small>
  245. </div>
  246. <small class="font-bold">
  247. </small>
  248. </div>
  249. </div>
  250. @endsection
  251. @section('js')
  252. <script type="text/javascript">
  253. var checkedIds = []
  254. /*电话全选功能*/
  255. $('body').on('click', '#checkAll', function () {
  256. items = $('.contacts');
  257. isChecked = $(this).prop('checked');
  258. items.prop('checked', isChecked);
  259. items.each(function () {
  260. saveChecked($(this))
  261. });
  262. if (checkedIds.length) {
  263. $('.fa-phone').show()
  264. $('.fa-table').show()
  265. } else {
  266. $('.fa-phone').hide()
  267. $('.fa-table').hide()
  268. }
  269. });
  270. $('body').on('click', '#checkTotal', function () {
  271. items = $('.contacts');
  272. isChecked = $(this).prop('checked')
  273. items.prop('checked', isChecked)
  274. if (isChecked == true) {
  275. $('.fa-phone').show()
  276. checkedIds = [{{ $allIds }}][0]
  277. $('.fa-table').show()
  278. $('#checkAll').prop('checked', true)
  279. } else {
  280. $('.fa-phone').hide()
  281. $('#checkAll').prop('checked', false)
  282. checkedIds = []
  283. }
  284. })
  285. $('body').on('click', '.contacts', function () {
  286. items = $('.contacts');
  287. checkedLength = $('.contacts:checked').length
  288. if (checkedLength) {
  289. $('#addCallList').show()
  290. $('.fa-table').show()
  291. } else {
  292. $('#addCallList').hide()
  293. $('.fa-table').hide()
  294. }
  295. if (items.length == checkedLength) {
  296. $('#checkAll').prop('checked', true)
  297. $('#addCallList').show()
  298. $('.fa-table').show()
  299. } else {
  300. $('#checkAll').prop('checked', false)
  301. }
  302. saveChecked($(this))
  303. console.log(checkedIds)
  304. });
  305. /*保存选中的项*/
  306. function saveChecked(e) {
  307. if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
  308. checkedIds.push(e.data("id"));
  309. } else {
  310. for (var i = 0; i < checkedIds.length; i++) {
  311. if (e.data("id") == checkedIds[i]) {
  312. checkedIds.splice(i, 1);
  313. break;
  314. }
  315. }
  316. }
  317. }
  318. /*翻页后设置选中项*/
  319. function setChecked() {
  320. var $boxes = $('.contacts');
  321. $boxes.each(function () {
  322. id = $(this).data('id')
  323. if (checkedIds.indexOf(id, 0) != -1) {
  324. $(this).prop('checked', true)
  325. } else {
  326. $(this).prop('checked', false)
  327. }
  328. })
  329. checkedLength = $('.contacts:checked').length
  330. if (checkedLength == $boxes.length) {
  331. $('#checkAll').prop('checked', true)
  332. }
  333. }
  334. /*添加选择的电话到拨打列表*/
  335. $('#addCallList').click(function () {
  336. contact_ids = checkedIds
  337. csrf_token = "{{ csrf_token() }}"
  338. ip = $('#ip').val()
  339. $.ajax({
  340. type: 'post',
  341. url: '{{ U('User/Threads/addCallList') }}',
  342. data: {_token: csrf_token, ip: ip,contact_ids: contact_ids},
  343. success: function (data) {
  344. if (data == 200) {
  345. layer.msg('导入成功', {
  346. icon: 1,
  347. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  348. }, function () {
  349. window.location.href = window.location.href
  350. });
  351. }
  352. }
  353. })
  354. });
  355. /*导出线索到excel*/
  356. $('#export_threads').click(function () {
  357. threads_ids = checkedIds
  358. csrf_token = "{{ csrf_token() }}";
  359. check_fields = $('#check-fields').serialize()
  360. $.ajax({
  361. type: 'post',
  362. url: '{{ U('User/Threads/export_threads') }}',
  363. data: {threads_ids: threads_ids, type: 1, _token: csrf_token, check_fields: check_fields},
  364. success: function (data) {
  365. $.fileDownload("{{ U('User/Threads/export_threads') }}", {
  366. data: {threads_ids: threads_ids, _token: csrf_token, check_fields: check_fields},
  367. prepareCallback: function (url) {
  368. console.log("开始下载");
  369. },
  370. successCallback: function (url) {
  371. console.log("正在下载,请稍后...");
  372. console.log("SUCCESS", "导出完成!");
  373. },
  374. failCallback: function (html, url) {
  375. console.log("正在下载,请稍后...");
  376. console.log("ERROR", "导出失败,未知的异常!");
  377. }
  378. });
  379. }
  380. })
  381. });
  382. /*线索筛选*/
  383. function filter_threads() {
  384. data = $('#filter_threads').serialize()
  385. $.ajax({
  386. type: 'get',
  387. data: data,
  388. }).done(function (data) {
  389. $('#threads-list').html(data.html)
  390. })
  391. }
  392. /*Ajax 分页*/
  393. $('body').on('click', '.pagination a', function (e) {
  394. e.preventDefault();
  395. if ($(this).attr('href') != '#') {
  396. data = $('#filter_threads').serialize()
  397. $.ajax({
  398. url: $(this).attr('href'),
  399. type: 'get',
  400. data: data,
  401. }).done(function (data) {
  402. $('#threads-list').html(data.html)
  403. setChecked()
  404. })
  405. }
  406. });
  407. </script>
  408. @endsection