customer.js 45 KB

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