customer.js 45 KB

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