index.blade.php 21 KB

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