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