index.blade.php 21 KB

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