customer.js 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index : function () {
  4. // 初始化表格参数配置
  5. Table.api.init();
  6. //绑定事件
  7. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  8. var panel = $($(this).attr("href"));
  9. if (panel.length > 0) {
  10. Controller.table[panel.attr("id")].call(this);
  11. $(this).on('click', function (e) {
  12. $($(this).attr("href")).find(".btn-refresh").trigger("click");
  13. });
  14. }
  15. //移除绑定的事件
  16. $(this).unbind('shown.bs.tab');
  17. });
  18. //必须默认触发shown.bs.tab事件
  19. $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
  20. $(document).on('click', '.show-detail', function (data) {
  21. var area = [$(window).width() > 1200 ? '90%' : '95%', $(window).height() > 800 ? '90%' : '95%'];
  22. var options = {
  23. shadeClose : false,
  24. shade : [0.3, '#393D49'],
  25. area : area,
  26. callback : function (value) {
  27. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  28. console.log(value);
  29. }
  30. };
  31. console.log($.fn.bootstrapTable.defaults.extend.detail_url);
  32. Fast.api.open($.fn.bootstrapTable.defaults.extend.detail_url + "?ids=" + $(this).data('id'), '客户详情', options);
  33. });
  34. //导入
  35. $(document).on('click','.btn-imports',function () {
  36. Fast.api.open("qingdong/customer/customer/import", "客户导入",{
  37. shadeClose: false,
  38. shade: false,
  39. maxmin: false,
  40. moveOut: false,
  41. scrollbars:false,
  42. 'area':[
  43. $(window).width() > 800 ? '600px' : '400px',
  44. $(window).height() > 600 ? '500px' : '400px'
  45. ],
  46. callback:function(value){
  47. Form.events.plupload("#plupload-local");
  48. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  49. },
  50. });
  51. }).on('click','.btn-transfer',function () {
  52. var tab_id=$('.active.in').attr('id');
  53. var table;
  54. switch (tab_id){
  55. case 'first'://全部
  56. table=$('#table');
  57. break;
  58. case 'second'://我负责的
  59. table=$('#table1');
  60. break;
  61. case 'third'://下属负责的
  62. table=$('#table2');
  63. break;
  64. case 'four'://今日待跟进
  65. table=$('#table3');
  66. break;
  67. case 'five'://今日已跟进
  68. table=$('#table4');
  69. break;
  70. case 'six'://从未跟进的
  71. table=$('#table5');
  72. break;
  73. }
  74. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  75. if(Table.api.selectedids(table).length == 0){
  76. layer.alert('请选择要筛选的客户!');
  77. return false;
  78. }
  79. var ids=JSON.stringify(Table.api.selectedids(table));
  80. Fast.api.open("qingdong/customer/customer/batch_change?ids="+ids, "批量转移客户",{
  81. shadeClose: false,
  82. shade: false,
  83. maxmin: false,
  84. moveOut: false,
  85. scrollbars:false,
  86. 'area':[
  87. $(window).width() > 800 ? '600px' : '400px',
  88. $(window).height() > 600 ? '500px' : '400px'
  89. ],
  90. callback:function(value){
  91. Form.events.plupload("#plupload-local");
  92. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  93. },
  94. });
  95. }).on('click','.btn-send-email',function () {
  96. var tab_id=$('.active.in').attr('id');
  97. var table;
  98. switch (tab_id){
  99. case 'first'://全部
  100. table=$('#table');
  101. break;
  102. case 'second'://我负责的
  103. table=$('#table1');
  104. break;
  105. case 'third'://下属负责的
  106. table=$('#table2');
  107. break;
  108. case 'four'://今日待跟进
  109. table=$('#table3');
  110. break;
  111. case 'five'://今日已跟进
  112. table=$('#table4');
  113. break;
  114. case 'six'://从未跟进的
  115. table=$('#table5');
  116. break;
  117. }
  118. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  119. if(Table.api.selectedids(table).length == 0){
  120. layer.alert('请选择要选中的客户!');
  121. return false;
  122. }
  123. var $this=$(this);
  124. var ids=JSON.stringify(Table.api.selectedids(table));
  125. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  126. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  127. shadeClose: false,
  128. shade: false,
  129. maxmin: false,
  130. moveOut: false,
  131. scrollbars:false,
  132. 'area':[
  133. $(window).width() > 800 ? '600px' : '400px',
  134. $(window).height() > 600 ? '500px' : '400px'
  135. ],
  136. callback:function(value){
  137. Form.events.plupload("#plupload-local");
  138. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  139. },
  140. });
  141. }).on('click','.btn-send-sms',function () {
  142. var tab_id=$('.active.in').attr('id');
  143. var table;
  144. switch (tab_id){
  145. case 'first'://全部
  146. table=$('#table');
  147. break;
  148. case 'second'://我负责的
  149. table=$('#table1');
  150. break;
  151. case 'third'://下属负责的
  152. table=$('#table2');
  153. break;
  154. case 'four'://今日待跟进
  155. table=$('#table3');
  156. break;
  157. case 'five'://今日已跟进
  158. table=$('#table4');
  159. break;
  160. case 'six'://从未跟进的
  161. table=$('#table5');
  162. break;
  163. }
  164. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  165. if(Table.api.selectedids(table).length == 0){
  166. layer.alert('请选择要选中的客户!');
  167. return false;
  168. }
  169. var $this=$(this);
  170. var ids=JSON.stringify(Table.api.selectedids(table));
  171. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  172. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  173. shadeClose: false,
  174. shade: false,
  175. maxmin: false,
  176. moveOut: false,
  177. scrollbars:false,
  178. 'area':[
  179. $(window).width() > 800 ? '600px' : '400px',
  180. $(window).height() > 600 ? '500px' : '400px'
  181. ],
  182. callback:function(value){
  183. Form.events.plupload("#plupload-local");
  184. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  185. },
  186. });
  187. }).on("click", ".btn-export", function () {
  188. var tab_id=$('.active.in').attr('id');
  189. var table,type;
  190. switch (tab_id){
  191. case 'first'://全部
  192. table=$('#table');
  193. type=0;
  194. break;
  195. case 'second'://我负责的
  196. table=$('#table1');
  197. type=1;
  198. break;
  199. case 'third'://下属负责的
  200. table=$('#table2');
  201. type=2;
  202. break;
  203. case 'four'://今日待跟进
  204. table=$('#table3');
  205. type=3;
  206. break;
  207. case 'five'://今日已跟进
  208. table=$('#table4');
  209. type=4;
  210. break;
  211. case 'six'://从未跟进的
  212. table=$('#table5');
  213. type=5;
  214. break;
  215. }
  216. var ids = Table.api.selectedids(table);
  217. var page = table.bootstrapTable('getData');
  218. var options = table.bootstrapTable('getOptions');
  219. var all = options.totalRows;
  220. var params=options.queryParams({});
  221. var sort = options.sortName+' '+options.sortOrder;
  222. var filter = params.filter;
  223. var op = params.op;
  224. Layer.confirm("请选择导出的选项", {
  225. title : '导出数据',
  226. btn : ["选中项(" + ids.length + "条)", "本页(" + page.length + "条)", "全部(" + all + "条)"],
  227. success : function (layero, index) {
  228. $(".layui-layer-btn a", layero).addClass("layui-layer-btn0");
  229. },
  230. yes : function (index, layero) {
  231. if (ids.length == 0) {
  232. Layer.alert('数据为空');
  233. return true;
  234. }
  235. $.post('qingdong/customer/customer/export', {sort:sort,ids : ids.join(","), isall : 1}, function (res) {
  236. Layer.alert(res.msg);
  237. if(res.code == 1){
  238. window.location.href = res.data.filePath;
  239. Layer.close(index);
  240. }
  241. table.bootstrapTable('refresh');
  242. }, 'json');
  243. return false;
  244. },
  245. btn2 : function (index, layero) {
  246. if (page.length == 0) {
  247. Layer.alert('数据为空');
  248. return true;
  249. }
  250. var ids = [];
  251. $.each(page, function (i, j) {
  252. ids.push(j.id);
  253. });
  254. $.post('qingdong/customer/customer/export', {sort:sort,ids : ids.join(","), isall : 2}, function (res) {
  255. Layer.alert(res.msg);
  256. if(res.code == 1){
  257. window.location.href = res.data.filePath;
  258. Layer.close(index);
  259. }
  260. table.bootstrapTable('refresh');
  261. }, 'json');
  262. return false;
  263. },
  264. btn3 : function (index, layero) {
  265. if (page.length == 0) {
  266. Layer.alert('数据为空');
  267. return true;
  268. }
  269. $.post('qingdong/customer/customer/export?filter='+filter+'&op='+op, {sort:sort,ids : ids.join(","), isall : 3,type:type}, function (res) {
  270. Layer.alert(res.msg);
  271. if(res.code == 1){
  272. window.location.href = res.data.filePath;
  273. Layer.close(index);
  274. }
  275. table.bootstrapTable('refresh');
  276. }, 'json');
  277. return false;
  278. }
  279. })
  280. });
  281. },
  282. tableinfo:{
  283. url : '',
  284. toolbar: '#toolbar',
  285. pk : 'id',
  286. sortName : 'id',
  287. fixedColumns : true,
  288. fixedNumber : 2,
  289. fixedRightNumber : 1,
  290. search:false,
  291. searchFormVisible:true,
  292. columns : [
  293. [
  294. {checkbox : true},
  295. {
  296. field : 'name', title : '客户名称', fixedColumns : true, formatter : function (value, row) {
  297. if(!value){
  298. value = '无'
  299. }
  300. return "<a href='javascript:void(0);' data-id='" + row.id + "' class='show-detail'>" + value + "</a>";
  301. },operate:'like',searchable:true
  302. },
  303. // {field : 'subname', title : '助记名称',operate:'like'},
  304. {field : 'owner_staff.name', title : '归属员工',operate:false},
  305. // {field : 'owner_staff_id', title : '归属员工',visible:false,operate:'=',searchList:$.getJSON("qingdong/customer/customer/stafflist")},
  306. // {field : 'contract_status', title : '成交状态',operate:'=',searchList:{0:'未成交',1:'已成交'},formatter:Table.api.formatter.status},
  307. // {field : 'industry', title : '客户所属',operate:'like'},
  308. // {field : 'follow', title : '客户状态',operate:'like'},
  309. // {field : 'source', title : '客户来源',operate:'like'},
  310. // {field : 'level', title : '客户星级',operate:'=',searchList:{0:'无',1:'1星',2:'2星',3:'3星',4:'4星',5:'5星'},formatter:Table.api.formatter.status},
  311. //
  312. // {field : 'next_time', title : '下次联系时间',operate:false},
  313. // {field : 'last_time', title : '最后跟进时间',operate:false},
  314. // {field : 'receivetime', title : '领取时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  315. {field: 'createtime', title: __('Createtime'),autocomplete:false, operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  316. {
  317. field: 'operate2', title: __('Operate'), events: {
  318. 'click .btn-chooseone': function (e, value, row, index) {
  319. Fast.api.close({id: row.id, name: row.name});
  320. },
  321. }, formatter: function () {
  322. return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
  323. }
  324. },
  325. {field: 'operate', title: __('Operate'),
  326. events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
  327. buttons: [
  328. {
  329. name: 'edit',
  330. text: __('编辑'),
  331. title: __('编辑'),
  332. extend:'data-area=["80%","80%"]',
  333. classname: 'records btn-dialog',
  334. url: 'qingdong/customer/customer/edit',
  335. visible: function (row) {
  336. if(row.operation =='read'){
  337. return false;
  338. }
  339. //返回true时按钮显示,返回false隐藏
  340. return true;
  341. }
  342. },
  343. {
  344. name: 'detail',
  345. text: __('跟进'),
  346. title: __('跟进'),
  347. extend:'data-area=["80%","80%"]',
  348. classname: ' records btn-dialog',
  349. url: 'qingdong/customer/record/add/relation_type/1',
  350. visible: function (row) {
  351. return true;
  352. }
  353. },
  354. {
  355. name: 'contract',
  356. text: __('合同列表'),
  357. title: __('合同列表'),
  358. extend:'data-area=["80%","80%"]',
  359. classname: ' records btn-dialog',
  360. url: 'qingdong/customer/cuscontract?ref=addtabs',
  361. visible: function (row) {
  362. return true;
  363. }
  364. },
  365. {
  366. name: 'contract',
  367. text: __('跟进记录'),
  368. title: __('跟进记录'),
  369. extend:'data-area=["80%","80%"]',
  370. classname: ' records btn-dialog',
  371. url: 'qingdong/customer/cusrecord?ref=addtabs',
  372. visible: function (row) {
  373. return true;
  374. }
  375. },
  376. // {
  377. // name: 'seas',
  378. // text: __('公海'),
  379. // title: __('公海'),
  380. // classname: 'seas btn-ajax',
  381. // url: 'qingdong/customer/customer/seas',
  382. // visible: function (row) {
  383. // //返回true时按钮显示,返回false隐藏
  384. // if(row.operation_team=='update' || row.operation =='read'){
  385. // return false;
  386. // }
  387. // return true;
  388. // },
  389. // confirm: '确定将当前客户放入公海吗?',
  390. // refresh:true,
  391. // error: function (data, ret) {
  392. // console.log(data, ret);
  393. // Layer.alert(ret.msg);
  394. // return false;
  395. // },
  396. //
  397. // },
  398. ]
  399. },
  400. ]
  401. ],
  402. onLoadSuccess:function(){
  403. // 这里就是数据渲染结束后的回调函数
  404. $(".btn-add").data("area",["80%","80%"]);
  405. $(".btn-edit").data("area",["80%","80%"]);
  406. }
  407. },
  408. table: {
  409. first : function() {
  410. // 初始化表格参数配置
  411. Table.api.init({
  412. extend : {
  413. add_url : 'qingdong/customer/customer/add',
  414. detail_url : 'qingdong/customer/customer/detail',
  415. table : 'customer',
  416. }
  417. });
  418. if(Config.fields !='[]'){
  419. if (Config.fields && Object.keys(Config.fields).length > 0) {
  420. var fields = JSON.parse(Config.fields);
  421. var start = Controller.tableinfo.columns[0].length-2;
  422. for (var i = 0; i < fields.length; i++) {
  423. if (fields[i].hasOwnProperty('formatter'))
  424. fields[i].formatter = eval(fields[i].formatter);
  425. if (fields[i].hasOwnProperty('events'))
  426. fields[i].events = eval(fields[i].events);
  427. if (fields[i].hasOwnProperty('searchList'))
  428. fields[i].searchList = JSON.parse(fields[i].searchList);
  429. Controller.tableinfo.columns[0].splice(start + i, 0, fields[i]);
  430. }
  431. }
  432. }
  433. let q = {}
  434. location.search.replace(/([^?&=]+)=([^&]+)/g,function(_,k,v){q[k]=v});
  435. var table = $("#table");
  436. Controller.tableinfo.url=location.href+'&type=0';
  437. Controller.tableinfo.toolbar='#toolbar';
  438. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  439. if (q.isselect == 1) {
  440. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length - 1].visible = false;
  441. } else {
  442. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length - 2].visible = false;
  443. }
  444. // 初始化表格
  445. table.bootstrapTable(Controller.tableinfo);
  446. // 为表格绑定事件
  447. Table.api.bindevent(table);
  448. },
  449. second : function() {
  450. // 初始化表格参数配置
  451. Table.api.init({
  452. extend : {
  453. add_url : 'qingdong/customer/customer/add',
  454. table : 'customer',
  455. }
  456. });
  457. var table = $("#table1");
  458. Controller.tableinfo.url=location.href+'&type=1';
  459. Controller.tableinfo.toolbar='#toolbar1';
  460. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  461. // 初始化表格
  462. table.bootstrapTable(Controller.tableinfo);
  463. // 为表格绑定事件
  464. Table.api.bindevent(table);
  465. },
  466. third : function() {
  467. // 初始化表格参数配置
  468. Table.api.init({
  469. extend : {
  470. add_url : 'qingdong/customer/customer/add',
  471. table : 'customer',
  472. }
  473. });
  474. var table = $("#table2");
  475. Controller.tableinfo.url=location.href+'&type=2';
  476. Controller.tableinfo.toolbar='#toolbar2';
  477. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  478. // 初始化表格
  479. table.bootstrapTable(Controller.tableinfo);
  480. // 为表格绑定事件
  481. Table.api.bindevent(table);
  482. },
  483. four : function() {
  484. // 初始化表格参数配置
  485. Table.api.init({
  486. extend : {
  487. add_url : 'qingdong/customer/customer/add',
  488. table : 'customer',
  489. }
  490. });
  491. var table = $("#table3");
  492. Controller.tableinfo.url=location.href+'&type=3';
  493. Controller.tableinfo.toolbar='#toolbar3';
  494. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  495. // 初始化表格
  496. table.bootstrapTable(Controller.tableinfo);
  497. // 为表格绑定事件
  498. Table.api.bindevent(table);
  499. },
  500. five : function() {
  501. // 初始化表格参数配置
  502. Table.api.init({
  503. extend : {
  504. add_url : 'qingdong/customer/customer/add',
  505. table : 'customer',
  506. }
  507. });
  508. var table = $("#table4");
  509. Controller.tableinfo.url=location.href+'&type=4';
  510. Controller.tableinfo.toolbar='#toolbar4';
  511. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  512. // 初始化表格
  513. table.bootstrapTable(Controller.tableinfo);
  514. // 为表格绑定事件
  515. Table.api.bindevent(table);
  516. },
  517. six : function() {
  518. // 初始化表格参数配置
  519. Table.api.init({
  520. extend : {
  521. add_url : 'qingdong/customer/customer/add',
  522. table : 'customer',
  523. }
  524. });
  525. var table = $("#table5");
  526. Controller.tableinfo.url=location.href+'&type=5';
  527. Controller.tableinfo.toolbar='#toolbar5';
  528. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  529. // 初始化表格
  530. table.bootstrapTable(Controller.tableinfo);
  531. // 为表格绑定事件
  532. Table.api.bindevent(table);
  533. },
  534. },
  535. add : function () {
  536. Controller.api.bindevent();
  537. },
  538. editteam : function () {
  539. Controller.api.bindevent();
  540. },
  541. delteam : function () {
  542. Controller.api.bindevent();
  543. },
  544. map : function () {
  545. window.addEventListener('message', function (event) {
  546. var loc = event.data;
  547. $('#lng').val(loc.latlng.lng)
  548. $('#lat').val(loc.latlng.lat)
  549. $('#address').val(loc.poiaddress)
  550. $('#address_detail').val(loc.poiname)
  551. console.log(loc)
  552. }, false);
  553. Form.api.bindevent($("form[role=form]"), function(data, ret){
  554. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  555. Fast.api.close(data);//这里是重点
  556. }, function(data, ret){
  557. },function (){
  558. var lng=$('#lng').val();
  559. var lat=$('#lat').val();
  560. var address=$('#address').val();
  561. var address_detail=$('#address_detail').val();
  562. if(!address){
  563. Layer.alert('请选择地理位置!');
  564. return false;
  565. }
  566. Fast.api.close({lng:lng,lat:lat,address:address,address_detail:address_detail});
  567. return false;
  568. });
  569. },
  570. change : function () {
  571. Controller.api.bindevent();
  572. },
  573. batch_change : function () {
  574. Controller.api.bindevent();
  575. },
  576. add_consume : function () {
  577. Controller.api.bindevent();
  578. },
  579. edit : function () {
  580. Controller.api.bindevent();
  581. },
  582. get_sign_detail : function () {
  583. Controller.api.bindevent();
  584. },
  585. addteam : function () {
  586. Controller.api.bindevent();
  587. },
  588. import : function () {
  589. $('[name="staff_id"]').on('change',function (){
  590. var staff_id=$(this).val();
  591. if(staff_id == 0){
  592. $('#seas_type').show();
  593. }else{
  594. $('#seas_type').hide();
  595. }
  596. })
  597. Form.api.bindevent($("form[role=form]"), function (data, ret) {
  598. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  599. Fast.api.close(data);//这里是重点
  600. }, function (data, ret) {
  601. Toastr.error(ret.msg);
  602. return false;
  603. });
  604. },
  605. words : function () {
  606. $('.copy').on('click',function (){
  607. var copyhtml=$(this).prev().html();
  608. let copyInput = document.createElement('input');//创建input元素
  609. document.body.appendChild(copyInput);//向页面底部追加输入框
  610. copyInput.setAttribute('value', copyhtml);//添加属性,将url赋值给input元素的value属性
  611. copyInput.select();//选择input元素
  612. document.execCommand("Copy");//执行复制命令
  613. Layer.msg('复制成功!');
  614. copyInput.remove();//删除动态创建的节点
  615. })
  616. $("[name='is_template']").on('click',function (){
  617. var ischecked=$(this).is(':checked');
  618. if(ischecked == true){
  619. $('#template_name').show();
  620. }else{
  621. $('#template_name').hide();
  622. }
  623. })
  624. $("[name='template_id']").on('change',function (){
  625. var url=$(this).find(':selected').data('url');
  626. $('#file').val(url)
  627. })
  628. Form.api.bindevent($("form[role=form]"), function (data, ret) {
  629. Fast.api.close(data);//这里是重点
  630. }, function (data, ret) {
  631. Toastr.error(ret.msg);
  632. return false;
  633. });
  634. },
  635. tabledetail:{
  636. record: function () {
  637. //跟进记录
  638. var table6 = $("#records");
  639. // 初始化表格
  640. table6.bootstrapTable({
  641. url : 'qingdong/customer/record/index?customer_id='+Config.idinfo.id,
  642. pk : 'id',
  643. sortName : 'id',
  644. toolbar:"#toolbar_records",
  645. operate : false,
  646. commonSearch : false,
  647. search : false,
  648. visible : false,
  649. showColumns : false,
  650. showExport : false,
  651. showToggle : false,
  652. columns : [
  653. [
  654. // {field: 'follow_type', title: __('跟进类型')},
  655. {field: 'follow_time', title: __('跟进时间')},
  656. // {field: 'follow', title: __('跟进状态')},
  657. {field: 'content', title: __('跟进内容'),cellStyle:function (value,row,index,field) {
  658. return {
  659. css: {
  660. "min-width": "150px",
  661. "white-space": "nowrap",
  662. "text-overflow": "ellipsis",
  663. "overflow": "hidden",
  664. "max-width":"300px",
  665. 'cursor':"pointer"
  666. }
  667. };
  668. },formatter:function (value,row,index,field) {
  669. var span=document.createElement('span');
  670. span.setAttribute('title',value);
  671. span.innerHTML = value;
  672. return span.outerHTML;
  673. }
  674. },
  675. {field: 'next_time', title: __('下次跟进时间')},
  676. {
  677. field : 'operate',
  678. title : __('Operate'),
  679. table : table6,
  680. events : Table.api.events.operate,
  681. formatter : Table.api.formatter.operate,
  682. buttons : [
  683. {
  684. name : '详情',
  685. text : __('详情'),
  686. classname : 'records btn-dialog',
  687. url : 'qingdong/customer/record/detail',
  688. callback: function (data) {
  689. $('.btn-success').trigger('click');
  690. },
  691. },
  692. {
  693. name : '评论',
  694. text : __('评论'),
  695. classname : 'records btn-dialog',
  696. url : 'qingdong/customer/comment/add',
  697. callback: function (data) {
  698. $('.btn-success').trigger('click');
  699. },
  700. visible: function (row) {
  701. if(Config.idinfo.operation_team =='update'){
  702. return false;
  703. }
  704. //返回true时按钮显示,返回false隐藏
  705. return true;
  706. },
  707. }
  708. ]
  709. }
  710. ]
  711. ]
  712. });
  713. // 为表格1绑定事件
  714. Table.api.bindevent(table6);
  715. },
  716. basic: function () {
  717. },
  718. //联系人
  719. contacts: function () {
  720. var table = $("#table-contacts");
  721. // 初始化表格
  722. table.bootstrapTable({
  723. url : 'qingdong/customer/customer/get_contacts' + location.search,
  724. pk : 'id',
  725. sortName : 'id',
  726. toolbar:"#toolbar_contacts",
  727. operate : false,
  728. commonSearch : false,
  729. search : false,
  730. visible : false,
  731. showColumns : false,
  732. showExport : false,
  733. showToggle : false,
  734. columns : [
  735. [
  736. {
  737. field : 'name', title : '姓名', fixedColumns : true, formatter : function (value, row, index) {
  738. if(value ==''){
  739. value = '无';
  740. }
  741. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  742. return value;
  743. }
  744. return "<a href='javascript:void(0);' class='btn-dialog' " +
  745. "data-url='qingdong/customer/contacts/detail/ids/"+row.id+"' data-title='联系人详情' >" + value + "</a>";
  746. },operate:'like'
  747. },
  748. {field : 'post', title : '职务'},
  749. {field : 'role', title : '角色'},
  750. {field : 'email', title : '邮箱'},
  751. {field : 'mobile', title : '手机号'},
  752. {field : 'remarks', title : '备注信息'},
  753. ]
  754. ]
  755. });
  756. Table.api.bindevent(table);
  757. },
  758. //费用
  759. settings5: function () {
  760. var table5 = $("#consume");
  761. // 初始化表格
  762. table5.bootstrapTable({
  763. url : 'qingdong/customer/customer/get_consume' + location.search,
  764. pk : 'id',
  765. sortName : 'id',
  766. toolbar:"#toolbar_consume",
  767. operate : false,
  768. commonSearch : false,
  769. search : false,
  770. visible : false,
  771. showColumns : false,
  772. showExport : false,
  773. showToggle : false,
  774. columns : [
  775. [
  776. {
  777. field : 'consume_time', title : '消费日期', fixedColumns : true, formatter : function (value, row, index) {
  778. if(value ==''){
  779. value = '无';
  780. }
  781. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  782. return value;
  783. }
  784. return "<a href='javascript:void(0);' class='btn-dialog' " +
  785. "data-url='qingdong/customer/consume/detail/ids/"+row.id+"' data-title='费用详情' >" + value + "</a>";
  786. },operate:'like'
  787. },
  788. {field : 'consume_type', title : '消费方式'},
  789. {field : 'money', title : '消费金额'},
  790. {field : 'money', title : '消费人'},
  791. {field : 'follow_staff.name', title : '审核人'},
  792. {field : 'check_status', title : '状态', formatter : Table.api.formatter.status,
  793. searchList : {0 : '待审核', 1 : '审核中', 2 : '审核通过', 3 : '审核未通过', 4 : '撤销', 5 : '草稿(未提交)'}},
  794. {field: 'operate', title: __('Operate'), table: table5, events: Table.api.events.operate}
  795. ]
  796. ]
  797. });
  798. Table.api.bindevent(table5);
  799. },
  800. //合同
  801. settings1: function () {
  802. var table1 = $("#contract");
  803. // 初始化表格
  804. table1.bootstrapTable({
  805. url : 'qingdong/customer/customer/get_contract' + location.search,
  806. pk : 'id',
  807. sortName : 'id',
  808. toolbar:"#toolbar_contract",
  809. operate : false,
  810. commonSearch : false,
  811. search : false,
  812. visible : false,
  813. showColumns : false,
  814. showExport : false,
  815. showToggle : false,
  816. columns : [
  817. [
  818. {
  819. field : 'num', title : '合同编号', fixedColumns : true, formatter : function (value, row, index) {
  820. if(value ==''){
  821. value = '无';
  822. }
  823. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  824. return value;
  825. }
  826. return "<a href='javascript:void(0);' class='btn-dialog' " +
  827. "data-url='qingdong/customer/contract/detail/ids/"+row.id+"' data-title='合同详情' >" + value + "</a>";
  828. },operate:'like'
  829. },
  830. {field : 'name', title : '合同名称'},
  831. {field : 'customer.name', title : '客户名称'},
  832. {field : 'money', title : '合同金额'},
  833. {field : 'start_time', title : '开始日期'},
  834. {field : 'end_time', title : '结束日期'},
  835. {field : 'check_status', title : '状态', formatter : Table.api.formatter.status,
  836. searchList : {0 : '待审核', 1 : '审核中', 2 : '审核通过', 3 : '审核未通过', 4 : '撤销', 5 : '草稿(未提交)'}},
  837. ]
  838. ]
  839. });
  840. Table.api.bindevent(table1);
  841. },
  842. //回款计划
  843. settings2: function () {
  844. //回款计划
  845. var table_plan = $("#plan");
  846. table_plan.bootstrapTable({
  847. url : 'qingdong/customer/customer/get_receivables_plan' + location.search,
  848. pk : 'id',
  849. sortName : 'id',
  850. toolbar:"#toolbar_receivablesplan",
  851. operate : false,
  852. commonSearch : false,
  853. search : false,
  854. visible : false,
  855. showColumns : false,
  856. showExport : false,
  857. showToggle : false,
  858. columns : [
  859. [
  860. {field : 'num', title : '期数'},
  861. {field : 'customer.name', title : '客户名称'},
  862. {
  863. field : 'contract.num', title : '合同编号', fixedColumns : true, formatter : function (value, row, index) {
  864. if(value ==''){
  865. value = '无';
  866. }
  867. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  868. return value;
  869. }
  870. return "<a href='javascript:void(0);' class='btn-dialog' " +
  871. "data-url='qingdong/customer/contract/detail/ids/"+row.contract.id+"' data-title='合同详情' >" + value + "</a>";
  872. },operate:'like'
  873. },
  874. {field : 'money', title : '计划回款金额'},
  875. {field : 'return_date', title : '计划回款日期'},
  876. {field : 'return_type', title : '计划回款方式'},
  877. {field : 'remind', title : '提前几日提醒'},
  878. {field : 'remarks', title : '备注'},
  879. ]
  880. ]
  881. });
  882. Table.api.bindevent(table_plan);
  883. //回款记录
  884. var table_receivables = $("#receivables");
  885. table_receivables.bootstrapTable({
  886. url : 'qingdong/customer/customer/get_receivables' + location.search,
  887. pk : 'id',
  888. sortName : 'id',
  889. toolbar:"#toolbar_receivables",
  890. operate : false,
  891. commonSearch : false,
  892. search : false,
  893. visible : false,
  894. showColumns : false,
  895. showExport : false,
  896. showToggle : false,
  897. columns : [
  898. [
  899. {
  900. field : 'number', title : '回款编号', fixedColumns : true, formatter : function (value, row, index) {
  901. if(value ==''){
  902. value = '无';
  903. }
  904. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  905. return value;
  906. }
  907. return "<a href='javascript:void(0);' class='btn-dialog' " +
  908. "data-url='qingdong/customer/receivables/detail/ids/"+row.id+"' data-title='回款详情' >" + value + "</a>";
  909. },operate:'like'
  910. },
  911. {
  912. field : 'contract.name', title : '合同名称', fixedColumns : true, formatter : function (value, row, index) {
  913. if(value ==''){
  914. value = '无';
  915. }
  916. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  917. return value;
  918. }
  919. return "<a href='javascript:void(0);' class='btn-dialog' " +
  920. "data-url='qingdong/customer/contract/detail/ids/"+row.contract.id+"' data-title='合同详情' >" + value + "</a>";
  921. },operate:'like'
  922. },
  923. {field : 'money', title : '合同金额'},
  924. {field : 'money', title : '回款金额'},
  925. {field : 'plan.num', title : '期数'},
  926. {field : 'owner_staff.name', title : '负责人'},
  927. {
  928. field : 'check_status', title : '状态', formatter : Table.api.formatter.status,
  929. searchList : {0 : '待审核', 1 : '审核中', 2 : '审核通过', 3 : '审核未通过', 4 : '撤销', 5 : '草稿(未提交)'}
  930. },
  931. {field : 'return_time', title : '回款日期'},
  932. ]
  933. ]
  934. });
  935. Table.api.bindevent(table_receivables);
  936. },
  937. //相关团队
  938. team: function () {
  939. var tableteam = $("#table_team");
  940. tableteam.bootstrapTable({
  941. url : 'qingdong/customer/customer/getteam' + location.search,
  942. pk : 'id',
  943. sortName : 'id',
  944. toolbar:"#toolbar_team",
  945. operate : false,
  946. commonSearch : false,
  947. search : false,
  948. visible : false,
  949. showColumns : false,
  950. showExport : false,
  951. showToggle : false,
  952. columns : [
  953. [
  954. {field : 'img', title : '头像', formatter: Table.api.formatter.image},
  955. {field : 'name', title : '员工姓名'},
  956. {field : 'post', title : '员工角色'},
  957. {field : 'roles', title : '团队角色'},
  958. {field : 'is_edit', title : '权限'},
  959. {field: 'operate', title: __('Operate'), table: tableteam, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
  960. buttons: [
  961. {
  962. text: __('修改'),
  963. title: __('修改'),
  964. extend:'data-area=["400px","300px"]',
  965. classname: 'btn-dialog',
  966. url: 'qingdong/customer/customer/editteam/customer_id/{customer_id}',
  967. visible: function (row) {
  968. if(row.roles == '负责人'){
  969. return false;
  970. }
  971. if(Config.idinfo.operation_team =='update' || Config.idinfo.operation =='read'){
  972. return false;
  973. }
  974. //返回true时按钮显示,返回false隐藏
  975. return true;
  976. }
  977. },
  978. {
  979. text: __('删除'),
  980. title: __('删除'),
  981. classname: 'btn-ajax',
  982. refresh:true,
  983. confirm: '确认发送',
  984. extend:'data-area=["80%","80%"]',
  985. url: 'qingdong/customer/customer/delteam/customer_id/{customer_id}/staff_id/{id}',
  986. visible: function (row) {
  987. if(row.roles == '负责人'){
  988. return false;
  989. }
  990. if(Config.idinfo.operation_team =='update'){
  991. return false;
  992. }
  993. //返回true时按钮显示,返回false隐藏
  994. return true;
  995. },
  996. },
  997. ]
  998. }
  999. ]
  1000. ]
  1001. });
  1002. // 为表格绑定事件
  1003. Table.api.bindevent(tableteam);
  1004. },
  1005. //附件
  1006. settings3: function () {
  1007. var tablefiles = $("#files");
  1008. tablefiles.bootstrapTable({
  1009. url : 'qingdong/customer/customer/get_file' + location.search,
  1010. pk : 'id',
  1011. sortName : 'id',
  1012. toolbar:"#toolbar_files",
  1013. operate : false,
  1014. commonSearch : false,
  1015. search : false,
  1016. visible : false,
  1017. showColumns : false,
  1018. showExport : false,
  1019. showToggle : false,
  1020. columns : [
  1021. [
  1022. {field : 'name', title : '附件名称'},
  1023. {field : 'size', title : '附件大小'},
  1024. {
  1025. field : 'file_path', title : '文件预览', events : Table.api.events.image, formatter : Table.api.formatter.image, operate : false
  1026. },
  1027. {
  1028. field : 'file_path', title : '下载',formatter : function (value, row, index) {
  1029. if(value ==''){
  1030. value = '无';
  1031. }
  1032. return "<a href='"+value+"' download='' >点击下载</a>";
  1033. }
  1034. },
  1035. ]
  1036. ]
  1037. });
  1038. // 为表格绑定事件
  1039. Table.api.bindevent(tablefiles);
  1040. },
  1041. //操作日志
  1042. settings4: function () {
  1043. var table7 = $("#operation_log");
  1044. // 初始化表格
  1045. table7.bootstrapTable({
  1046. url : 'qingdong/customer/log/index?customer_id='+Config.idinfo.id,
  1047. pk : 'id',
  1048. sortName : 'id',
  1049. toolbar:"#toolbar_log",
  1050. operate : false,
  1051. commonSearch : false,
  1052. search : false,
  1053. visible : false,
  1054. showColumns : false,
  1055. showExport : false,
  1056. showToggle : false,
  1057. columns : [
  1058. [
  1059. {field: 'staff.name', title: __('员工')},
  1060. {field: 'content', title: __('内容'),cellStyle:function (value,row,index,field) {
  1061. return {
  1062. css: {
  1063. "min-width": "150px",
  1064. "white-space": "nowrap",
  1065. "text-overflow": "ellipsis",
  1066. "overflow": "hidden",
  1067. "max-width":"300px",
  1068. 'cursor':"pointer"
  1069. }
  1070. };
  1071. },formatter:function (value,row,index,field) {
  1072. var span=document.createElement('span');
  1073. span.setAttribute('title',value);
  1074. span.innerHTML = value;
  1075. return span.outerHTML;
  1076. }
  1077. },
  1078. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  1079. ]
  1080. ]
  1081. });
  1082. Table.api.bindevent(table7);
  1083. },
  1084. //签到记录
  1085. settings6: function () {
  1086. var table8 = $("#sign");
  1087. table8.bootstrapTable({
  1088. url: 'qingdong/customer/customer/get_sign?customer_id=' + Config.idinfo.id,
  1089. pk: 'id',
  1090. sortName: 'id',
  1091. toolbar: "#toolbar_sign",
  1092. operate: false,
  1093. commonSearch: false,
  1094. search: false,
  1095. visible: false,
  1096. showColumns: false,
  1097. showExport: false,
  1098. showToggle: false,
  1099. columns: [
  1100. [
  1101. {field: 'location', title: '地理位置', formatter: Controller.api.formatter.map, operate: false},
  1102. {
  1103. field: 'createtime',
  1104. title: __('创建时间'),
  1105. operate: 'RANGE',
  1106. addclass: 'datetimerange',
  1107. formatter: Table.api.formatter.datetime
  1108. },
  1109. {
  1110. field: 'operate',
  1111. title: __('Operate'),
  1112. table: table8,
  1113. events: Table.api.events.operate,
  1114. formatter: Table.api.formatter.operate,
  1115. buttons: [
  1116. {
  1117. name: 'detail',
  1118. text: __('签到详情'),
  1119. title: __('签到详情'),
  1120. classname: 'records btn-dialog',
  1121. extend: 'data-area=["90%","90%"]',
  1122. url: 'qingdong/customer/customer/get_sign_detail',
  1123. callback: function (data) {
  1124. $('.btn-success').trigger('click');
  1125. },
  1126. }
  1127. ]
  1128. }
  1129. ]
  1130. ]
  1131. });
  1132. Table.api.bindevent(table8);
  1133. },
  1134. //商机
  1135. settings7: function () {
  1136. var table = $("#business");
  1137. // 初始化表格
  1138. table.bootstrapTable({
  1139. url : 'qingdong/customer/customer/get_business?customer_id=' + Config.idinfo.id,
  1140. pk : 'id',
  1141. sortName : 'id',
  1142. toolbar:"#toolbar_business",
  1143. operate : false,
  1144. commonSearch : false,
  1145. search : false,
  1146. visible : false,
  1147. showColumns : false,
  1148. showExport : false,
  1149. showToggle : false,
  1150. columns : [
  1151. [
  1152. {
  1153. field : 'name', title : '商机名称', fixedColumns : true, formatter : function (value, row, index) {
  1154. if(value ==''){
  1155. value = '无';
  1156. }
  1157. if(Config.idinfo.operation =='read'){
  1158. return value;
  1159. }
  1160. return "<a href='javascript:void(0);' data-id='" + row.id + "' class='show-business-detail'>" + value + "</a>";
  1161. }
  1162. },
  1163. {field : 'money', title : '商机金额'},
  1164. {field : 'expect_time', title : '预计成交时间',operate: 'RANGE', addclass: 'datetimerange'},
  1165. {field : 'next_time', title : '下次联系时间',operate: 'RANGE', addclass: 'datetimerange'},
  1166. {field : 'type', title : '商机阶段', formatter : Table.api.formatter.status,
  1167. searchList : {0 : '初期沟通', 1 : '立项跟踪', 2 : '方案/报价', 3 : '谈判审核', 4 : '赢单', 5 : '输单', 6 : '无效'}},
  1168. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  1169. ]
  1170. ]
  1171. });
  1172. Table.api.bindevent(table);
  1173. },
  1174. },
  1175. detail : function (){
  1176. // 初始化表格参数配置
  1177. Table.api.init({});
  1178. //绑定事件
  1179. $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  1180. var panel = $($(this).attr("href"));
  1181. if (panel.length > 0) {
  1182. Controller.tabledetail[panel.attr("id")].call(this);
  1183. $(this).on('click', function (e) {
  1184. $($(this).attr("href")).find(".btn-refresh").trigger("click");
  1185. });
  1186. }
  1187. //移除绑定的事件
  1188. $(this).unbind('shown.bs.tab');
  1189. });
  1190. //必须默认触发shown.bs.tab事件
  1191. $('ul.nav-tabs li.active a[data-toggle="tab"]').trigger("shown.bs.tab");
  1192. $(document).on('click', '.show-business-detail', function (data) {
  1193. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  1194. var options = {
  1195. shadeClose : false,
  1196. shade : [0.3, '#393D49'],
  1197. area : area,
  1198. callback : function (value) {
  1199. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  1200. console.log(value);
  1201. }
  1202. };
  1203. Fast.api.open("qingdong/customer/business/detail?ids=" + $(this).data('id'), '商机', options);
  1204. }).on('click','.btn-edit',function () {
  1205. var id=$('#ids').val();
  1206. Fast.api.open("qingdong/customer/customer/edit?ids="+id, "客户编辑",{
  1207. shadeClose: false,
  1208. shade: false,
  1209. maxmin: false,
  1210. moveOut: false,
  1211. scrollbars:false,
  1212. callback:function () {
  1213. location.reload()
  1214. }
  1215. });
  1216. }).on('click',".btn-del",function(){//删除
  1217. var id=$('#ids').val();
  1218. Layer.confirm('确定删除当前客户吗?', {
  1219. btn: ['确定','取消'],
  1220. title: '提示',
  1221. },function(index, layero){
  1222. Fast.api.ajax("qingdong/customer/customer/del?ids="+id,function(data,ret){
  1223. if(ret.code == 1){
  1224. Layer.close(index);
  1225. parent.location.reload();
  1226. }
  1227. },function(data,ret){
  1228. });
  1229. });
  1230. }).on('click',".btn-seas",function(){//放入公海
  1231. var id=$('#ids').val();
  1232. Layer.confirm('确定将当前客户放入公海吗?', {
  1233. btn: ['确定','取消'],
  1234. title: '提示',
  1235. },function(index, layero){
  1236. Fast.api.ajax("qingdong/customer/customer/seas?ids="+id,function(data,ret){
  1237. if(ret.code == 1){
  1238. Layer.close(index);
  1239. parent.location.reload();
  1240. }
  1241. },function(data,ret){
  1242. });
  1243. });
  1244. }).on('click',".btn-change",function(){//转移客户
  1245. var id=$('#ids').val();
  1246. Fast.api.open("qingdong/customer/customer/change?ids="+id, "转移客户",{
  1247. shadeClose: false,
  1248. shade: false,
  1249. maxmin: false,
  1250. moveOut: false,
  1251. scrollbars:false,
  1252. area:["400px","350px"],
  1253. callback:function () {
  1254. location.reload()
  1255. }
  1256. });
  1257. }).on('click','.btn-send-email',function () {
  1258. var $this=$(this);
  1259. var ids=$('#ids').val();
  1260. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  1261. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  1262. shadeClose: false,
  1263. shade: false,
  1264. maxmin: false,
  1265. moveOut: false,
  1266. scrollbars:false,
  1267. 'area':[
  1268. $(window).width() > 800 ? '600px' : '400px',
  1269. $(window).height() > 600 ? '500px' : '400px'
  1270. ],
  1271. callback:function(value){
  1272. Form.events.plupload("#plupload-local");
  1273. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  1274. },
  1275. });
  1276. }).on('click','.btn-send-sms',function () {
  1277. var $this=$(this);
  1278. var ids=$('#ids').val();
  1279. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  1280. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  1281. shadeClose: false,
  1282. shade: false,
  1283. maxmin: false,
  1284. moveOut: false,
  1285. scrollbars:false,
  1286. 'area':[
  1287. $(window).width() > 800 ? '600px' : '400px',
  1288. $(window).height() > 600 ? '500px' : '400px'
  1289. ],
  1290. callback:function(value){
  1291. Form.events.plupload("#plupload-local");
  1292. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  1293. },
  1294. });
  1295. }).on('click', '.btn-word', function (data) {
  1296. //导出word
  1297. var area = [$(window).width() > 1200 ? '1200px' : '70%', $(window).height() > 800 ? '800px' : '80%'];
  1298. var options = {
  1299. shadeClose : false,
  1300. shade : [0.3, '#393D49'],
  1301. area : area,
  1302. callback : function (value) {
  1303. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  1304. window.location.href = value.file;
  1305. }
  1306. };
  1307. Fast.api.open("qingdong/customer/customer/words?ids=" + $(this).data('id'), '导出word', options);
  1308. });
  1309. Controller.api.bindevent();
  1310. },
  1311. api : {
  1312. bindevent : function () {
  1313. $("#fachoose-map").on('click', function () {
  1314. parent.Fast.api.open("qingdong/customer/customer/map",'地理位置选择', {
  1315. area: ['500px', '600px'],
  1316. callback: function (data) {
  1317. console.log(data);
  1318. $('#lng').val(data.lng)
  1319. $('#lat').val(data.lat)
  1320. $('#address').val(data.address)
  1321. $('#address_text').val(data.address)
  1322. $('#address_detail').val(data.address_detail)
  1323. }
  1324. });
  1325. return false;
  1326. });
  1327. Form.api.bindevent($("form[role=form]"), function(data, ret){
  1328. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  1329. Fast.api.close(data);//这里是重点
  1330. });
  1331. },
  1332. formatter : {
  1333. thumb : function (value, row, index) {
  1334. var length = row.file_ids.length;
  1335. var html='';
  1336. for(var i=0;i<length;i++){
  1337. html += '<a href="' + row.file_ids[i] + '" target="_blank"><img src="' + row.file_ids[i] + '" data-tips-image alt="" title="签到图" style="max-height:90px;max-width:120px;margin-right:10px;"></a>';
  1338. }
  1339. return html;
  1340. },
  1341. map:function(value,row,index){
  1342. return '<a href="https://apis.map.qq.com/uri/v1/marker?marker=coord:'+row.lat+','+row.lng+';title:'+row.location+';addr:'+row.location+'&referer=crm" target="_blank" >'+row.location+'</a>';
  1343. }
  1344. }
  1345. }
  1346. };
  1347. return Controller;
  1348. });