index.blade.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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">添加到待导列表</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. <div class="form-group">
  69. <label>&nbsp;标签</label>
  70. <div class="col-sm-9">
  71. <input type="text" name="label" id="calllist_label" class="form-control">
  72. </div>
  73. </div>
  74. <div class="form-group">
  75. <label>&nbsp;拨打IP:</label>
  76. <select name="ip" class="form-control" id="ip">
  77. <option value="172.31.20.181">172.31.20.181</option>
  78. <option value="172.31.20.182">172.31.20.182</option>
  79. <option value="172.31.20.183">172.31.20.183</option>
  80. <option value="172.31.20.184">172.31.20.184</option>
  81. <option value="172.31.20.185">172.31.20.185</option>
  82. <option value="172.31.20.186">172.31.20.186</option>
  83. <option value="172.31.20.187">172.31.20.187</option>
  84. <option value="172.31.20.188">172.31.20.188</option>
  85. </select>
  86. </div>
  87. <div class="form-group">
  88. <label class="control-label col-sm-3">&nbsp;</label>
  89. <div class="col-sm-9">
  90. <input type="submit" class="btn btn-success" style="margin-right:20px;"
  91. id="addCallList">
  92. <input type="reset" class="btn btn-default">
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="modal-footer">
  99. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  100. </div>
  101. </small>
  102. </div>
  103. <small class="font-bold">
  104. </small>
  105. </div>
  106. <small class="font-bold">
  107. </small>
  108. </div>
  109. <div class="modal inmodal" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
  110. <div class="modal-dialog">
  111. <div class="modal-content animated flipInY">
  112. <div class="modal-header">
  113. <h4 class="modal-title">选择要导出的字段</h4></div>
  114. <small class="font-bold">
  115. <div class="modal-body">
  116. <div class="ibox float-e-margins">
  117. <div class="ibox-content">
  118. <div class="form-group">
  119. <form action="" id="check-fields">
  120. <div class="row">
  121. <div class="col-sm-6">
  122. <h4 style="color: #ccc">联系方式:</h4>
  123. </div>
  124. </div>
  125. <div class="row">
  126. <div class="col-sm-3">
  127. <div class="checkbox checkbox-success">
  128. <input class="check-fields" type="checkbox" checked="checked"
  129. name="phone" disabled>
  130. <label>
  131. 电话
  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="email">
  139. <label>
  140. Email
  141. </label>
  142. </div>
  143. </div>
  144. <div class="col-sm-3">
  145. <div class="checkbox checkbox-success">
  146. <input class="check-fields" type="checkbox" checked="checked"
  147. name="qq">
  148. <label>
  149. qq
  150. </label>
  151. </div>
  152. </div>
  153. </div>
  154. <div class="row">
  155. <div class="col-sm-6">
  156. <h4 style="color: #ccc">其他字段:</h4>
  157. </div>
  158. </div>
  159. <div class="row">
  160. <div class="col-sm-3">
  161. <div class="checkbox checkbox-success">
  162. <input class="check-fields" type="checkbox" checked="checked"
  163. name="company_name" disabled>
  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="ower_name">
  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="website">
  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="legal_person">
  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_capital">
  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="reg_addr">
  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="lastest">
  218. <label>
  219. 最新跟进
  220. </label>
  221. </div>
  222. </div>
  223. <div class="col-sm-3">
  224. <div class="checkbox checkbox-success">
  225. <input class="check-fields" type="checkbox" checked="checked"
  226. name="created_at">
  227. <label>
  228. 领取时间
  229. </label>
  230. </div>
  231. </div>
  232. </div>
  233. </form>
  234. </div>
  235. <div class="form-group">
  236. <label class="control-label col-sm-3">&nbsp;</label>
  237. <div class="col-sm-9">
  238. <input type="submit" class="btn btn-success" style="margin-right:20px;"
  239. id="export_threads">
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. </div>
  245. <div class="modal-footer">
  246. <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
  247. </div>
  248. </small>
  249. </div>
  250. <small class="font-bold">
  251. </small>
  252. </div>
  253. <small class="font-bold">
  254. </small>
  255. </div>
  256. </div>
  257. @endsection
  258. @section('js')
  259. <script type="text/javascript">
  260. var checkedIds = []
  261. /*电话全选功能*/
  262. $('body').on('click', '#checkAll', function () {
  263. items = $('.contacts');
  264. isChecked = $(this).prop('checked');
  265. items.prop('checked', isChecked);
  266. items.each(function () {
  267. saveChecked($(this))
  268. });
  269. if (checkedIds.length) {
  270. $('.fa-phone').show()
  271. $('.fa-table').show()
  272. } else {
  273. $('.fa-phone').hide()
  274. $('.fa-table').hide()
  275. }
  276. });
  277. $('body').on('click', '#checkTotal', function () {
  278. items = $('.contacts');
  279. isChecked = $(this).prop('checked')
  280. items.prop('checked', isChecked)
  281. if (isChecked == true) {
  282. $('.fa-phone').show()
  283. checkedIds = [{{ $allIds }}][0]
  284. $('.fa-table').show()
  285. $('#checkAll').prop('checked', true)
  286. } else {
  287. $('.fa-phone').hide()
  288. $('#checkAll').prop('checked', false)
  289. checkedIds = []
  290. }
  291. })
  292. $('body').on('click', '.contacts', function () {
  293. items = $('.contacts');
  294. checkedLength = $('.contacts:checked').length
  295. if (checkedLength) {
  296. $('.fa-phone').show()
  297. $('.fa-table').show()
  298. } else {
  299. $('.fa-phone').hide()
  300. $('.fa-table').hide()
  301. }
  302. if (items.length == checkedLength) {
  303. $('#checkAll').prop('checked', true)
  304. $('.fa-phone').show()
  305. $('.fa-table').show()
  306. } else {
  307. $('#checkAll').prop('checked', false)
  308. }
  309. saveChecked($(this))
  310. console.log(checkedIds)
  311. });
  312. /*保存选中的项*/
  313. function saveChecked(e) {
  314. if (e.is(":checked") && checkedIds.indexOf(e.data("id"), 0) == -1) {
  315. checkedIds.push(e.data("id"));
  316. } else {
  317. for (var i = 0; i < checkedIds.length; i++) {
  318. if (e.data("id") == checkedIds[i]) {
  319. checkedIds.splice(i, 1);
  320. break;
  321. }
  322. }
  323. }
  324. }
  325. /*翻页后设置选中项*/
  326. function setChecked() {
  327. var $boxes = $('.contacts');
  328. $boxes.each(function () {
  329. id = $(this).data('id')
  330. if (checkedIds.indexOf(id, 0) != -1) {
  331. $(this).prop('checked', true)
  332. } else {
  333. $(this).prop('checked', false)
  334. }
  335. })
  336. checkedLength = $('.contacts:checked').length
  337. if (checkedLength == $boxes.length) {
  338. $('#checkAll').prop('checked', true)
  339. }
  340. }
  341. /*添加选择的电话到拨打列表*/
  342. $('#addCallList').click(function () {
  343. thread_ids = checkedIds
  344. csrf_token = "{{ csrf_token() }}"
  345. ip = $('#ip').val()
  346. label = $('#calllist_label').val()
  347. $.ajax({
  348. type: 'post',
  349. url: '{{ U('Call/List/syncAdd') }}',
  350. data: {_token: csrf_token, ip: ip, thread_ids: thread_ids, label: label},
  351. success: function (data) {
  352. if (data == 200) {
  353. layer.msg('导入成功', {
  354. icon: 1,
  355. time: 2000 //2秒关闭(如果不配置,默认是3秒)
  356. }, function () {
  357. window.location.href = window.location.href
  358. });
  359. }
  360. }
  361. })
  362. });
  363. /*导出线索到excel*/
  364. $('#export_threads').click(function () {
  365. threads_ids = checkedIds
  366. csrf_token = "{{ csrf_token() }}";
  367. check_fields = $('#check-fields').serialize()
  368. $.ajax({
  369. type: 'post',
  370. url: '{{ U('User/Threads/export_threads') }}',
  371. data: {threads_ids: threads_ids, type: 1, _token: csrf_token, check_fields: check_fields},
  372. success: function (data) {
  373. $.fileDownload("{{ U('User/Threads/export_threads') }}", {
  374. data: {threads_ids: threads_ids, _token: csrf_token, check_fields: check_fields},
  375. prepareCallback: function (url) {
  376. console.log("开始下载");
  377. },
  378. successCallback: function (url) {
  379. console.log("正在下载,请稍后...");
  380. console.log("SUCCESS", "导出完成!");
  381. },
  382. failCallback: function (html, url) {
  383. console.log("正在下载,请稍后...");
  384. console.log("ERROR", "导出失败,未知的异常!");
  385. }
  386. });
  387. }
  388. })
  389. });
  390. /*线索筛选*/
  391. function filter_threads() {
  392. data = $('#filter_threads').serialize()
  393. $.ajax({
  394. type: 'get',
  395. data: data,
  396. }).done(function (data) {
  397. $('#threads-list').html(data.html)
  398. })
  399. }
  400. /*Ajax 分页*/
  401. $('body').on('click', '.pagination a', function (e) {
  402. e.preventDefault();
  403. if ($(this).attr('href') != '#') {
  404. data = $('#filter_threads').serialize()
  405. $.ajax({
  406. url: $(this).attr('href'),
  407. type: 'get',
  408. data: data,
  409. }).done(function (data) {
  410. $('#threads-list').html(data.html)
  411. setChecked()
  412. })
  413. }
  414. });
  415. </script>
  416. @endsection