customer.js 46 KB

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