index.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>潜客跟踪</title>
  6. <meta name="renderer" content="webkit">
  7. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  8. <meta name="viewport"
  9. content="width=customer-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  10. <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
  11. <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
  12. <style type="text/css">
  13. .seach_items {
  14. float: right;
  15. margin-left: 10px;
  16. }
  17. </style>
  18. <style type="text/css">
  19. .LAY-btns .layui-nav {
  20. padding-left: 0;
  21. padding-right: 10px;
  22. top: -4px;
  23. margin: 0 10px;
  24. border: 0;
  25. background-color: #009688;
  26. }
  27. .LAY-btns .layui-nav .layui-nav-item {
  28. line-height: 40px;
  29. }
  30. .LAY-btns .layui-nav .layui-nav-child {
  31. top: 34px;
  32. }
  33. .LAY-btns .layui-nav .layui-nav-bar {
  34. display: none;
  35. }
  36. .LAY-btns .layui-nav .layui-nav-child dd.layui-this a {
  37. color: #333;
  38. background-color: #fff;
  39. }
  40. .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {
  41. background-color: #f2f2f2;
  42. color: #000;
  43. }
  44. .tableContent {
  45. width: 100%;
  46. display: flex;
  47. justify-content: space-between;
  48. flex-direction: row;
  49. }
  50. .demo-class .layui-layer-btn0 {
  51. background-color: #009688 !important;
  52. color: #fff;
  53. }
  54. .demo-class .layui-layer-btn1 {
  55. background-color: red;
  56. color: #fff;
  57. }
  58. .treeContent {
  59. height: 30vh;
  60. overflow-y: scroll;
  61. margin-bottom: 10px;
  62. border: 1px solid rgba(0, 0, 0, 0.1);
  63. }
  64. /*隐藏滚动条*/
  65. .treeContent::-webkit-scrollbar {
  66. height: 0 !important;
  67. width: 0px !important;
  68. }
  69. </style>
  70. </head>
  71. <body>
  72. <div class="layui-fluid">
  73. <div class="layui-card">
  74. <div class="layui-card-body" pad15>
  75. <div class="layui-row layui-col-space15">
  76. <div class="layui-col-md12">
  77. <div class="tableContent">
  78. <div style="width: 345px">
  79. <div class="treeContent demo-tree" id="id_tree"></div>
  80. <table id="customer_log" lay-filter="customer-operate-log"></table>
  81. </div>
  82. <div style="width: calc(100% - 360px)">
  83. <div class="LAY-btns" style="margin-bottom: 10px;">
  84. <div style="float: left">
  85. <button class="layui-btn" id="btn_list"><i
  86. class="layui-icon layui-icon-download-circle"></i>导出
  87. </button>
  88. </div>
  89. <form class="layui-form" lay-filter="query-form-element">
  90. <div class="seach_items">
  91. <button class="layui-btn" lay-submit lay-filter="query-form-element"><i
  92. class="layui-icon layui-icon-search"></i>查询
  93. </button>
  94. </div>
  95. <div class="seach_items">
  96. <input type="text" name="tel" autocomplete="off" class="layui-input"
  97. placeholder="电话"/>
  98. </div>
  99. <div class="seach_items">
  100. <input type="text" name="name" autocomplete="off" class="layui-input"
  101. placeholder="姓名"/>
  102. </div>
  103. <div class="seach_items">
  104. <select name="source" id="id_source" style="width: 40px;">
  105. <option value="">请选择来源</option>
  106. </select>
  107. </div>
  108. <div class="seach_items">
  109. <select name="project" id="id_project" style="width: 40px;">
  110. <option value="">请选择项目</option>
  111. </select>
  112. </div>
  113. <div class="seach_items">
  114. <select name="status">
  115. <option value="">请选择状态</option>
  116. <option value="1" selected>正常</option>
  117. <option value="2">放弃</option>
  118. </select>
  119. </div>
  120. </form>
  121. <div style="clear: both;"></div>
  122. </div>
  123. <table id="customer_datagrid" lay-filter="customer-operate"></table>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <script type="text/html" id="customer_datagrid-operate-bar">
  132. <div class="layui-btn-group">
  133. <a class="layui-btn layui-btn-xs" lay-event="customer_search"
  134. >查看</a>
  135. <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="edit"
  136. >修改</a>
  137. <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="add_review"
  138. >跟踪报告</a>
  139. <a class="layui-btn layui-btn-xs" lay-event="add_project"
  140. >添加项目</a>
  141. <a class="layui-btn layui-btn-xs layui-btn-warm" data-permission="customer.inner_review"
  142. lay-event="internal_trace"
  143. >内部跟踪</a>
  144. <a class="layui-btn layui-btn-xs layui-btn-danger" data-permission="customer.again_dispatch"
  145. lay-event="again_dispatch"
  146. >重新分配</a>
  147. </div>
  148. </script>
  149. <script src="../../layuiadmin/layui/layui.js?t=1"></script>
  150. <script>
  151. layui.config({
  152. base: '../../../layuiadmin/' //静态资源所在路径
  153. }).extend({
  154. index: 'lib/index' //主入口模块
  155. }).use(['index', 'table', 'form', 'tree'], function () {
  156. var $ = layui.$;
  157. var table = layui.table
  158. , form = layui.form
  159. , tree = layui.tree
  160. , admin = layui.admin;
  161. var store_id, field;
  162. admin.req({
  163. url: '/customer/dict/',
  164. done: function (res) {
  165. var data = res.data.source;
  166. var source_node = $('#id_source');
  167. for (var i in data) {
  168. var pid = data[i].id;
  169. var name = data[i].name;
  170. source_node.append("<option value='" + pid + "'>" + name + "</option>");
  171. }
  172. var project_data = res.data.project;
  173. var project_node = $('#id_project');
  174. for (var i in project_data) {
  175. var pid1 = project_data[i].id;
  176. var name1 = project_data[i].name;
  177. project_node.append("<option value='" + pid1 + "'>" + name1 + "</option>");
  178. }
  179. form.render('select');
  180. }
  181. });
  182. table.render({
  183. elem: '#customer_log'
  184. , url: '/customer/stage_count/'
  185. , cols: [[
  186. {field: 'stage', title: '阶段', event: 'stage', width: 100}
  187. , {field: 'total_count', title: "总数", event: 'total', width: 80, sort: true}
  188. , {field: 'today_count', title: '今日', event: 'today', width: 80, sort: true}
  189. , {field: 'overdue_count', title: '逾期', event: 'overdue', width: 80, sort: true}
  190. ]]
  191. });
  192. var style = 'font-size:12px;'
  193. table.render({
  194. elem: '#customer_datagrid'
  195. , url: '/customer/new_customer/?status=1'
  196. , title: '潜客跟踪'
  197. , cols: [[
  198. {field: 'name', title: '姓名', width: 90}
  199. , {field: 'gender_text', title: "性别", width: 60}
  200. , {field: 'tel', title: '电话', width: 120}
  201. , {field: 'village', title: '小区', width: 150, style:style}
  202. , {field: 'address', title: '地址', width: 150, style:style}
  203. , {field: 'source_text', title: '来源', width: 100, style:style}
  204. , {field: 'project_text', title: '项目', width: 80, style:style}
  205. , {field: 'stage_progress_text', title: '阶段进度', width: 100, style:style}
  206. , {field: 'status_text', title: '状态', width: 60, style:style}
  207. , {field: 'track_user_text', title: '跟踪人', width: 120, style:style}
  208. , {field: 'store_text', title: '门店', width: 120, style:style}
  209. , {field: 'end_time_f', title: '最后跟踪时间', width: 130, style:style}
  210. , {field: 'last_review', title: '最后跟踪情况', width: 150, style:style}
  211. , {field: 'next_time_f', title: '下次跟踪', width: 100, style:style}
  212. , {field: 'enter_count', title: '进店次数', width: 90, style:style}
  213. , {field: 'last_enter_time', title: '最后进店时间', width: 130, style:style}
  214. , {field: 'create_time_f', title: '建档时间', width: 130, style:style}
  215. , {field: 'create_user_text', title: '建档人', width: 100, style:style}
  216. , {field: 'notes', title: '备注', width: 150, style:style}
  217. , {width: 350, align: 'center', fixed: 'right', toolbar: "#customer_datagrid-operate-bar"}
  218. ]]
  219. , page: true
  220. , height: 'full-108'
  221. , done: function () {
  222. layui.index.removeNoPermButtons();
  223. }
  224. });
  225. var manager_stores = layui.data(layui.setter.tableName)['manager_stores'];
  226. if (parseInt(manager_stores) !== 0) {
  227. admin.req({
  228. url: '/account/employee_tree/'
  229. , done: function (res) {
  230. tree.render({
  231. elem: '#id_tree' //绑定元素
  232. , onlyIconControl: true
  233. , data: res.data
  234. //点击菜单时触发
  235. , click: function (obj) {
  236. //节点高亮
  237. var nodes = document.getElementsByClassName("layui-tree-txt");
  238. for (var i = 0; i < nodes.length; i++) {
  239. if (nodes[i].innerHTML === obj.data.title) {
  240. nodes[i].style.color = "#009688";
  241. nodes[i].style.fontWeight = "bold";
  242. } else {
  243. nodes[i].style.color = "#555";
  244. nodes[i].style.fontWeight = "normal";
  245. }
  246. }
  247. store_id = obj.data.id;
  248. field = obj.data.field;
  249. table.reload('customer_log', {
  250. where: {type: field, id: store_id}
  251. });
  252. }
  253. });
  254. }
  255. });
  256. } else {
  257. $('#id_tree').hide()
  258. }
  259. function createFollowReport(customer_id, stage_progress_sort) {
  260. layer.open({
  261. type: 2,
  262. title: '添加跟踪报告',
  263. area: ['45%', '70%'],
  264. btn: ['保存', '取消'],
  265. yes: function (index, dom) {
  266. layui.onSubmitChild = function (res) {
  267. if (res.code === 0) {
  268. layer.msg('添加成功!', {icon: 1})
  269. }
  270. layer.close(index);
  271. //刷新表格
  272. table.reload('customer_log', {});
  273. table.reload('customer_datagrid', {});
  274. };
  275. layui.submitChild();
  276. },
  277. btn2: function (index, layero) {
  278. layer.close(index);//关闭当前按钮
  279. },
  280. content: 'add_report.html?customer_id=' + customer_id + '&stage_progress_sort=' + stage_progress_sort
  281. });
  282. };
  283. //监听工具条
  284. table.on('tool(customer-operate)', function (obj) {
  285. var data = obj.data;
  286. table.editdata = data;
  287. if (obj.event === 'customer_search') {
  288. layer.open({
  289. skin: 'demo-class',
  290. type: 2,
  291. title: '查看客户详情',
  292. area: ['55%', '90%'],
  293. btn: ['跟踪报告', '更新进度', '取消'],
  294. yes: function (index, dom) {
  295. //添加跟踪报告
  296. createFollowReport(data.id, data.stage_progress_sort)
  297. },
  298. btn2: function (index, layero) {
  299. //更新进度
  300. layer.open({
  301. type: 2,
  302. title: '更新进度',
  303. area: ['45%', '70%'],
  304. btn: ['保存', '取消'],
  305. yes: function (index, dom) {
  306. layui.onSubmitChild = function (res) {
  307. parent.layui.getTipsData();
  308. layer.close(index);
  309. table.reload('customer_datagrid', {});
  310. };
  311. layui.submitChild();
  312. },
  313. btn2: function (index, layero) {
  314. layer.close(index);//关闭当前按钮
  315. },
  316. content: '../order/update_process.html?customer_id=' + data.id
  317. });
  318. },
  319. btn3: function (index, layero) {
  320. //取消
  321. layer.close(index);//关闭当前按钮
  322. },
  323. content: 'detail.html?customer=' + data.id
  324. });
  325. } else if (obj.event === 'edit') {
  326. layer.open({
  327. type: 2,
  328. title: '修改',
  329. shadeClose: false,
  330. area: ['45%', '80%'],
  331. btn: ['保存', '取消'],
  332. yes: function (index, dom) {
  333. layui.onSubmitChild = function (res) {
  334. layer.close(index);
  335. table.reload('customer_datagrid', {});
  336. };
  337. layui.submitChild();
  338. },
  339. btn2: function (index, layero) {
  340. layer.close(index);//关闭当前按钮
  341. },
  342. content: 'edit.html?id=' + data.id
  343. });
  344. }
  345. else if (obj.event === 'add_review') {
  346. //添加跟踪报告
  347. createFollowReport(data.id, data.stage_progress_sort)
  348. }
  349. else if (obj.event === 'add_project') {
  350. layer.open({
  351. type: 2,
  352. title: '添加项目',
  353. area: ['40%', '70%'],
  354. btn: ['保存', '取消'],
  355. yes: function (index, dom) {
  356. layui.onSubmitChild = function (res) {
  357. layer.close(index);
  358. //刷新表格
  359. table.reload('customer_datagrid', {});
  360. };
  361. layui.submitChild();
  362. },
  363. btn2: function (index, layero) {
  364. layer.close(index);//关闭当前按钮
  365. },
  366. content: 'add_project.html?customer_id=' + data.id
  367. });
  368. } else if (obj.event === 'internal_trace') {
  369. layer.open({
  370. type: 2,
  371. title: '内部跟踪',
  372. area: ['40%', '70%'],
  373. btn: ['保存', '取消'],
  374. yes: function (index, dom) {
  375. layui.onSubmitChild = function (res) {
  376. layer.close(index);
  377. //刷新表格
  378. table.reload('customer_log', {});
  379. table.reload('customer_datagrid', {});
  380. };
  381. layui.submitChild();
  382. },
  383. btn2: function (index, layero) {
  384. layer.close(index);//关闭当前按钮
  385. },
  386. content: 'internal_trace.html?customer_id=' + data.id + '&stage_progress_sort=' + data.stage_progress_sort
  387. });
  388. } else if (obj.event === 'again_dispatch') {
  389. layer.open({
  390. type: 2,
  391. title: '重新分配',
  392. area: ['40%', '40%'],
  393. btn: ['保存', '取消'],
  394. yes: function (index, dom) {
  395. layui.onSubmitChild = function (res) {
  396. if (res.code === 0) {
  397. layer.msg('重新分配成功!', {icon: 1})
  398. }
  399. layer.close(index);
  400. table.reload('customer_datagrid', {});
  401. };
  402. layui.submitChild();
  403. },
  404. btn2: function (index, layero) {
  405. layer.close(index);//关闭当前按钮
  406. },
  407. content: 'again_dispatch.html?id=' + data.id
  408. });
  409. }
  410. });
  411. // 点击表格触发
  412. table.on('tool(customer-operate-log)', function (obj) {
  413. var data = obj.data;
  414. let tool_event = obj.event;
  415. let params = {count_param: tool_event};
  416. params['stage_progress'] = data.stage_id;
  417. if (field && store_id) {
  418. params['param'] = field + '_' + store_id;
  419. }
  420. table.reload('customer_datagrid', {
  421. where: params
  422. , page: {curr: 1}
  423. });
  424. });
  425. var _params = {};
  426. form.on('submit(query-form-element)', function (data) {
  427. _params = data.field;
  428. table.reload('customer_datagrid', {
  429. where: data.field
  430. , page: {curr: 1}
  431. });
  432. layer.closeAll();
  433. return false
  434. });
  435. //导出列表
  436. $('#btn_list').on('click', function () {
  437. $.get({
  438. url: '/customer/new_customer/?export=true',
  439. dataType: 'json',
  440. data: _params,
  441. success: function (res) {
  442. if (res.code === 1) {
  443. layer.msg(res.msg);
  444. return;
  445. }
  446. table.exportFile('customer_datagrid', res,)
  447. }
  448. })
  449. });
  450. $('#customer_order').on('click', function () {
  451. layer.open({
  452. type: 2,
  453. title: '预约量房',
  454. area: ['45%', '65%'],
  455. btn: ['保存', '取消'],
  456. yes: function (index, dom) {
  457. layui.onSubmitChild = function (res) {
  458. if (res.code === 0) {
  459. layer.msg('添加成功!', {icon: 1})
  460. }
  461. layer.close(index);
  462. table.reload('customer_datagrid', {});
  463. };
  464. layui.submitChild();
  465. },
  466. btn2: function (index, layero) {
  467. layer.close(index);//关闭当前按钮
  468. },
  469. content: 'order.html'
  470. });
  471. });
  472. });
  473. </script>
  474. </body>
  475. </html>