contacts.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  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 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '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. }).on('click', '.show-customer', function (data) {
  33. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  34. var options = {
  35. shadeClose : false,
  36. shade : [0.3, '#393D49'],
  37. area : area,
  38. callback : function (value) {
  39. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  40. console.log(value);
  41. }
  42. };
  43. Fast.api.open($.fn.bootstrapTable.defaults.extend.customer_url + "?ids=" + $(this).data('id'), '客户详情', options);
  44. }).on('click','.btn-send-email',function () {
  45. var tab_id=$('.active.in').attr('id');
  46. var table;
  47. switch (tab_id){
  48. case 'first'://全部
  49. table=$('#table');
  50. break;
  51. case 'second'://我负责的
  52. table=$('#table1');
  53. break;
  54. case 'third'://下属负责的
  55. table=$('#table2');
  56. break;
  57. case 'four'://今日待跟进
  58. table=$('#table3');
  59. break;
  60. case 'five'://今日已跟进
  61. table=$('#table4');
  62. break;
  63. case 'six'://从未跟进的
  64. table=$('#table5');
  65. break;
  66. }
  67. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  68. if(Table.api.selectedids(table).length == 0){
  69. layer.alert('请选择要选中的客户!');
  70. return false;
  71. }
  72. var $this=$(this);
  73. var ids=JSON.stringify(Table.api.selectedids(table));
  74. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  75. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  76. shadeClose: false,
  77. shade: false,
  78. maxmin: false,
  79. moveOut: false,
  80. scrollbars:false,
  81. 'area':[
  82. $(window).width() > 800 ? '600px' : '400px',
  83. $(window).height() > 600 ? '500px' : '400px'
  84. ],
  85. callback:function(value){
  86. Form.events.plupload("#plupload-local");
  87. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  88. },
  89. });
  90. }).on('click','.btn-send-sms',function () {
  91. var tab_id=$('.active.in').attr('id');
  92. var table;
  93. switch (tab_id){
  94. case 'first'://全部
  95. table=$('#table');
  96. break;
  97. case 'second'://我负责的
  98. table=$('#table1');
  99. break;
  100. case 'third'://下属负责的
  101. table=$('#table2');
  102. break;
  103. case 'four'://今日待跟进
  104. table=$('#table3');
  105. break;
  106. case 'five'://今日已跟进
  107. table=$('#table4');
  108. break;
  109. case 'six'://从未跟进的
  110. table=$('#table5');
  111. break;
  112. }
  113. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  114. if(Table.api.selectedids(table).length == 0){
  115. layer.alert('请选择要选中的客户!');
  116. return false;
  117. }
  118. var $this=$(this);
  119. var ids=JSON.stringify(Table.api.selectedids(table));
  120. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  121. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  122. shadeClose: false,
  123. shade: false,
  124. maxmin: false,
  125. moveOut: false,
  126. scrollbars:false,
  127. 'area':[
  128. $(window).width() > 800 ? '600px' : '400px',
  129. $(window).height() > 600 ? '500px' : '400px'
  130. ],
  131. callback:function(value){
  132. Form.events.plupload("#plupload-local");
  133. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  134. },
  135. });
  136. }).on("click", ".btn-export", function () {
  137. var tab_id=$('.active.in').attr('id');
  138. var table,type;
  139. switch (tab_id){
  140. case 'first'://全部
  141. table=$('#table');
  142. type=0;
  143. break;
  144. case 'second'://我负责的
  145. table=$('#table1');
  146. type=1;
  147. break;
  148. case 'third'://下属负责的
  149. table=$('#table2');
  150. type=2;
  151. break;
  152. case 'four'://今日待跟进
  153. table=$('#table3');
  154. type=3;
  155. break;
  156. case 'five'://今日已跟进
  157. table=$('#table4');
  158. type=4;
  159. break;
  160. case 'six'://从未跟进的
  161. table=$('#table5');
  162. type=5;
  163. break;
  164. }
  165. var ids = Table.api.selectedids(table);
  166. var page = table.bootstrapTable('getData');
  167. var options = table.bootstrapTable('getOptions');
  168. var params=options.queryParams({});
  169. var all = options.totalRows;
  170. var sort = options.sortName+' '+options.sortOrder;
  171. var filter = params.filter;
  172. var op = params.op;
  173. Layer.confirm("请选择导出的选项", {
  174. title : '导出数据',
  175. btn : ["选中项(" + ids.length + "条)", "本页(" + page.length + "条)", "全部(" + all + "条)"],
  176. success : function (layero, index) {
  177. $(".layui-layer-btn a", layero).addClass("layui-layer-btn0");
  178. }, yes : function (index, layero) {
  179. if (ids.length == 0) {
  180. Layer.alert('数据为空');
  181. return true;
  182. }
  183. $.post('qingdong/customer/contacts/export', {sort:sort,ids : ids.join(","), isall : 1}, function (res) {
  184. if(res.code == 1){
  185. Layer.alert(res.msg);
  186. window.location.href = res.data.filePath;
  187. Layer.close(index);
  188. table.bootstrapTable('refresh');
  189. }else{
  190. Layer.alert(res.msg);
  191. }
  192. }, 'json');
  193. return false;
  194. },
  195. btn2 : function (index, layero) {
  196. if (page.length == 0) {
  197. Layer.alert('数据为空');
  198. return true;
  199. }
  200. var ids = [];
  201. $.each(page, function (i, j) {
  202. ids.push(j.id);
  203. });
  204. $.post('qingdong/customer/contacts/export', {sort:sort,ids : ids.join(","), isall : 2}, function (res) {
  205. if(res.code == 1){
  206. Layer.alert(res.msg);
  207. window.location.href = res.data.filePath;
  208. Layer.close(index);
  209. table.bootstrapTable('refresh');
  210. }else{
  211. Layer.alert(res.msg);
  212. }
  213. }, 'json');
  214. return false;
  215. },
  216. btn3 : function (index, layero) {
  217. if (page.length == 0) {
  218. Layer.alert('数据为空');
  219. return true;
  220. }
  221. $.post('qingdong/customer/contacts/export?filter='+filter+'&op='+op, {sort:sort,ids : ids.join(","), isall : 3,type:type}, function (res) {
  222. if(res.code == 1){
  223. Layer.alert(res.msg);
  224. window.location.href = res.data.filePath;
  225. Layer.close(index);
  226. table.bootstrapTable('refresh');
  227. }else{
  228. Layer.alert(res.msg);
  229. }
  230. }, 'json');
  231. return false;
  232. }
  233. })
  234. }).on('click','.btn-imports',function () {
  235. Fast.api.open("qingdong/customer/contacts/import", "联系人导入",{
  236. shadeClose: false,
  237. shade: false,
  238. maxmin: false,
  239. moveOut: false,
  240. scrollbars:false,
  241. 'area':[
  242. $(window).width() > 800 ? '600px' : '400px',
  243. $(window).height() > 600 ? '500px' : '400px'
  244. ],
  245. callback:function(value){
  246. Form.events.plupload("#plupload-local");
  247. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  248. },
  249. });
  250. });
  251. },
  252. tableinfo:{
  253. url : '',
  254. toolbar: '#toolbar',
  255. pk : 'id',
  256. sortName : 'id',
  257. fixedColumns : true,
  258. fixedNumber : 2,
  259. fixedRightNumber : 1,
  260. search:false,
  261. searchFormVisible:true,
  262. columns : [
  263. [
  264. {checkbox : true},
  265. {
  266. field : 'name', title : '姓名', fixedColumns : true, formatter : function (value, row, index) {
  267. if(value ==''){
  268. value = '无';
  269. }
  270. return "<a href='javascript:void(0);' data-id='" + row.id + "' class='show-detail'>" + value + "</a>";
  271. }
  272. },
  273. {
  274. field : 'customer', title : '所属客户', fixedColumns : true, formatter : function (value, row, index) {
  275. if(row.customer){
  276. return "<a href='javascript:void(0);' data-id='" + row.customer_id + "' class='show-customer'>" + row.customer.name + "</a>";
  277. }else{
  278. return row.customer_id;
  279. }
  280. },operate:false
  281. },
  282. {field : 'customer_id', title : '客户名称', visible: false, addClass: "selectpage", extend: "data-source='qingdong/customer/customer/index' data-field='name'"},
  283. {field : 'subname', title : '尊称',operate:'like'},
  284. {field : 'mobile', title : '手机',operate:'like'},
  285. {field : 'email', title : '邮箱',operate:'like'},
  286. {field : 'role', title : '角色',operate:false},
  287. {field : 'post', title : '职务',operate:false},
  288. {field : 'address', title : '地址',operate:false},
  289. {field : 'next_time', title : '下次联系时间',operate:false},
  290. {field : 'remarks', title : '备注信息',operate:false},
  291. {field : 'owner_staff.name', title : '归属人',operate:false},
  292. {field : 'createtime', title : '创建时间',formatter: Table.api.formatter.datetime,operate:false},
  293. {field : 'updatetime', title : '更新时间',formatter: Table.api.formatter.datetime,operate:false},
  294. {
  295. field: 'operate2', title: __('Operate'), events: {
  296. 'click .btn-chooseone': function (e, value, row, index) {
  297. Fast.api.close({id: row.id, name: row.name});
  298. },
  299. }, formatter: function () {
  300. return '<a href="javascript:;" class="btn btn-danger btn-chooseone btn-xs"><i class="fa fa-check"></i> ' + __('Choose') + '</a>';
  301. }
  302. },
  303. {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
  304. buttons: [
  305. {
  306. name: 'detail',
  307. text: __('跟进'),
  308. title: __('跟进'),
  309. extend:'data-area=["80%","80%"]',
  310. classname: 'records btn-dialog',
  311. url: 'qingdong/customer/record/add/relation_type/2',
  312. visible: function (row) {
  313. //返回true时按钮显示,返回false隐藏
  314. return true;
  315. }
  316. },
  317. ]
  318. },
  319. ]
  320. ],
  321. onLoadSuccess:function(){
  322. // 这里就是数据渲染结束后的回调函数
  323. $(".btn-add").data("area",["80%","80%"]);
  324. $(".btn-edit").data("area",["80%","80%"]);
  325. }
  326. },
  327. table: {
  328. first: function () {
  329. // 初始化表格参数配置
  330. Table.api.init({
  331. extend : {
  332. add_url : 'qingdong/customer/contacts/add',
  333. detail_url : 'qingdong/customer/contacts/detail',
  334. customer_url : 'qingdong/customer/customer/detail',
  335. table : 'contacts',
  336. }
  337. });
  338. if(Config.fields !='[]'){
  339. if (Config.fields && Object.keys(Config.fields).length > 0) {
  340. var fields = JSON.parse(Config.fields);
  341. var start = Controller.tableinfo.columns[0].length-2;
  342. for (var i = 0; i < fields.length; i++) {
  343. if (fields[i].hasOwnProperty('formatter'))
  344. fields[i].formatter = eval(fields[i].formatter);
  345. if (fields[i].hasOwnProperty('events'))
  346. fields[i].events = eval(fields[i].events);
  347. if (fields[i].hasOwnProperty('searchList'))
  348. fields[i].searchList = JSON.parse(fields[i].searchList);
  349. Controller.tableinfo.columns[0].splice(start + i, 0, fields[i]);
  350. }
  351. }
  352. }
  353. const q = {};
  354. location.search.replace(/([^?&=]+)=([^&]+)/g,function(_,k,v){q[k]=v});
  355. var table = $("#table");
  356. Controller.tableinfo.url=location.href+'&type=0';
  357. Controller.tableinfo.toolbar='#toolbar';
  358. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  359. if (q.isselect == 1) {
  360. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length - 1].visible = false;
  361. } else {
  362. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length - 2].visible = false;
  363. }
  364. // 初始化表格
  365. table.bootstrapTable(Controller.tableinfo);
  366. // 为表格绑定事件
  367. Table.api.bindevent(table);
  368. },
  369. second: function () {
  370. // 初始化表格参数配置
  371. Table.api.init({
  372. extend : {
  373. add_url : 'qingdong/customer/contacts/add',
  374. detail_url : 'qingdong/customer/contacts/detail',
  375. customer_url : 'qingdong/customer/customer/detail',
  376. table : 'contacts',
  377. }
  378. });
  379. var table = $("#table1");
  380. Controller.tableinfo.url=location.href+'&type=1';
  381. Controller.tableinfo.toolbar='#toolbar1';
  382. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  383. // 初始化表格
  384. table.bootstrapTable(Controller.tableinfo);
  385. // 为表格绑定事件
  386. Table.api.bindevent(table);
  387. },
  388. third: function () {
  389. // 初始化表格参数配置
  390. Table.api.init({
  391. extend : {
  392. add_url : 'qingdong/customer/contacts/add',
  393. detail_url : 'qingdong/customer/contacts/detail',
  394. customer_url : 'qingdong/customer/customer/detail',
  395. table : 'contacts',
  396. }
  397. });
  398. var table = $("#table2");
  399. Controller.tableinfo.url=location.href+'&type=2';
  400. Controller.tableinfo.toolbar='#toolbar2';
  401. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  402. // 初始化表格
  403. table.bootstrapTable(Controller.tableinfo);
  404. // 为表格绑定事件
  405. Table.api.bindevent(table);
  406. },
  407. four: function () {
  408. // 初始化表格参数配置
  409. Table.api.init({
  410. extend : {
  411. add_url : 'qingdong/customer/contacts/add',
  412. detail_url : 'qingdong/customer/contacts/detail',
  413. customer_url : 'qingdong/customer/customer/detail',
  414. table : 'contacts',
  415. }
  416. });
  417. var table = $("#table3");
  418. Controller.tableinfo.url=location.href+'&type=3';
  419. Controller.tableinfo.toolbar='#toolbar3';
  420. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  421. // 初始化表格
  422. table.bootstrapTable(Controller.tableinfo);
  423. // 为表格绑定事件
  424. Table.api.bindevent(table);
  425. },
  426. five: function () {
  427. // 初始化表格参数配置
  428. Table.api.init({
  429. extend : {
  430. add_url : 'qingdong/customer/contacts/add',
  431. detail_url : 'qingdong/customer/contacts/detail',
  432. customer_url : 'qingdong/customer/customer/detail',
  433. table : 'contacts',
  434. }
  435. });
  436. var table = $("#table4");
  437. Controller.tableinfo.url=location.href+'&type=4';
  438. Controller.tableinfo.toolbar='#toolbar4';
  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. six: function () {
  446. // 初始化表格参数配置
  447. Table.api.init({
  448. extend : {
  449. add_url : 'qingdong/customer/contacts/add',
  450. detail_url : 'qingdong/customer/contacts/detail',
  451. customer_url : 'qingdong/customer/customer/detail',
  452. table : 'contacts',
  453. }
  454. });
  455. var table = $("#table5");
  456. Controller.tableinfo.url=location.href+'&type=5';
  457. Controller.tableinfo.toolbar='#toolbar5';
  458. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  459. // 初始化表格
  460. table.bootstrapTable(Controller.tableinfo);
  461. // 为表格绑定事件
  462. Table.api.bindevent(table);
  463. },
  464. },
  465. add : function () {
  466. Controller.api.bindevent();
  467. },
  468. edit : function () {
  469. Form.api.bindevent($("form"), function(data, ret){
  470. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  471. Fast.api.close(data);//这里是重点
  472. }, function(data, ret){
  473. });
  474. Controller.api.bindevent();
  475. },
  476. import : function () {
  477. Form.api.bindevent($("form[role=form]"), function (data, ret) {
  478. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  479. Fast.api.close(data);//这里是重点
  480. }, function (data, ret) {
  481. Toastr.error(ret.msg);
  482. return false;
  483. });
  484. },
  485. detail : function () {
  486. // 初始化表格参数配置
  487. Table.api.init({});
  488. //跟进记录
  489. var table1 = $("#records");
  490. // 初始化表格
  491. table1.bootstrapTable({
  492. url : 'qingdong/customer/record/index?contacts_id='+Config.idinfo.id,
  493. pk : 'id',
  494. sortName : 'id',
  495. operate : false,
  496. commonSearch : false,
  497. search : false,
  498. visible : false,
  499. showColumns : false,
  500. showExport : false,
  501. showToggle : false,
  502. columns : [
  503. [
  504. {field: 'follow_type', title: __('跟进类型')},
  505. {field: 'follow_time', title: __('跟进时间')},
  506. {field: 'follow', title: __('跟进状态')},
  507. {field: 'content', title: __('跟进内容'),cellStyle:function (value,row,index,field) {
  508. return {
  509. css: {
  510. "min-width": "150px",
  511. "white-space": "nowrap",
  512. "text-overflow": "ellipsis",
  513. "overflow": "hidden",
  514. "max-width":"300px",
  515. 'cursor':"pointer"
  516. }
  517. };
  518. },formatter:function (value,row,index,field) {
  519. var span=document.createElement('span');
  520. span.setAttribute('title',value);
  521. span.innerHTML = value;
  522. return span.outerHTML;
  523. }
  524. },
  525. {field: 'next_time', title: __('下次跟进时间')},
  526. {
  527. field : 'operate',
  528. title : __('Operate'),
  529. table : table1,
  530. events : Table.api.events.operate,
  531. formatter : Table.api.formatter.operate,
  532. buttons : [
  533. {
  534. name : '详情',
  535. text : __('详情'),
  536. classname : 'records btn-dialog',
  537. url : 'qingdong/customer/record/detail',
  538. callback: function (data) {
  539. $('.btn-success').trigger('click');
  540. },
  541. },
  542. {
  543. name : '评论',
  544. text : __('评论'),
  545. classname : 'records btn-dialog',
  546. url : 'qingdong/customer/comment/add',
  547. callback: function (data) {
  548. $('.btn-success').trigger('click');
  549. },
  550. }
  551. ]
  552. }
  553. ]
  554. ]
  555. });
  556. //操作日志
  557. var table2 = $("#operation_log");
  558. // 初始化表格
  559. table2.bootstrapTable({
  560. url : 'qingdong/customer/log/index?contacts_id='+Config.idinfo.id,
  561. pk : 'id',
  562. sortName : 'id',
  563. operate : false,
  564. commonSearch : false,
  565. search : false,
  566. visible : false,
  567. showColumns : false,
  568. showExport : false,
  569. showToggle : false,
  570. columns : [
  571. [
  572. {field: 'staff.name', title: __('员工')},
  573. {field: 'content', title: __('内容'),cellStyle:function (value,row,index,field) {
  574. return {
  575. css: {
  576. "min-width": "150px",
  577. "white-space": "nowrap",
  578. "text-overflow": "ellipsis",
  579. "overflow": "hidden",
  580. "max-width":"300px",
  581. 'cursor':"pointer"
  582. }
  583. };
  584. },formatter:function (value,row,index,field) {
  585. var span=document.createElement('span');
  586. span.setAttribute('title',value);
  587. span.innerHTML = value;
  588. return span.outerHTML;
  589. }
  590. },
  591. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  592. ]
  593. ]
  594. });
  595. //附件
  596. $('#files').bootstrapTable({
  597. url : 'qingdong/customer/contacts/get_file'+ location.search,
  598. pk : 'id',
  599. sortName : 'id',
  600. operate : false,
  601. commonSearch : false,
  602. search : false,
  603. visible : false,
  604. showColumns : false,
  605. showExport : false,
  606. showToggle : false,
  607. columns : [
  608. [
  609. {field : 'name', title : '附件名称'},
  610. {field : 'size', title : '附件大小'},
  611. {field : 'staff.name', title : '上传人'},
  612. {field : 'createtime', title : '上传时间',formatter: Table.api.formatter.datetime},
  613. {
  614. field : 'operate', title : '操作', formatter : function (value, row, index) {
  615. return "<a href='" + row.file_path + "' data-tips-image='" + row.file_path + "' class='show-detail'>" + '预览' + "</a>";
  616. }
  617. },
  618. ]
  619. ]
  620. });
  621. //编辑
  622. $(document).on('click','.btn-edit',function () {
  623. var id=$('#ids').val();
  624. Fast.api.open("qingdong/customer/contacts/edit?ids="+id, "客户编辑",{
  625. shadeClose: false,
  626. shade: false,
  627. maxmin: false,
  628. moveOut: false,
  629. scrollbars:false,
  630. callback:function () {
  631. location.reload()
  632. }
  633. });
  634. }).on('click',".btn-del",function(){//删除
  635. var id=$('#ids').val();
  636. Layer.confirm('确定删除当前客户吗?', {
  637. btn: ['确定','取消'],
  638. title: '提示',
  639. },function(index, layero){
  640. Fast.api.ajax("qingdong/customer/contacts/del?ids="+id,function(data,ret){
  641. if(ret.code == 1){
  642. Layer.close(index);
  643. parent.location.reload();
  644. }
  645. },function(data,ret){
  646. });
  647. });
  648. }).on('click','.btn-send-email',function () {
  649. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  650. var $this=$(this);
  651. var ids=$('#ids').val();
  652. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  653. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  654. shadeClose: false,
  655. shade: false,
  656. maxmin: false,
  657. moveOut: false,
  658. scrollbars:false,
  659. 'area':[
  660. $(window).width() > 800 ? '600px' : '400px',
  661. $(window).height() > 600 ? '500px' : '400px'
  662. ],
  663. callback:function(value){
  664. Form.events.plupload("#plupload-local");
  665. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  666. },
  667. });
  668. }).on('click','.btn-send-sms',function () {
  669. //在templateView的模式下不能调用table.bootstrapTable('getSelections')来获取选中的ID,只能通过下面的Table.api.selectedids来获取
  670. var $this=$(this);
  671. var ids=$('#ids').val();
  672. var url=$this.data('url'),title=$this.data('title'),types=$this.data('types');
  673. Fast.api.open(url+"?ids="+ids+"&type="+types, title,{
  674. shadeClose: false,
  675. shade: false,
  676. maxmin: false,
  677. moveOut: false,
  678. scrollbars:false,
  679. 'area':[
  680. $(window).width() > 800 ? '600px' : '400px',
  681. $(window).height() > 600 ? '500px' : '400px'
  682. ],
  683. callback:function(value){
  684. Form.events.plupload("#plupload-local");
  685. // 在这里可以接收弹出层中使用`Fast.api.close(data)`进行回传数据
  686. },
  687. });
  688. });
  689. Controller.api.bindevent();
  690. },
  691. api : {
  692. bindevent : function () {
  693. $(document).on("click", ".select-customer", function () {
  694. var $this = $(this);
  695. parent.Backend.api.open($(this).data("url"), __('Select'), {
  696. callback: function (data) {
  697. $this.html(data.name);
  698. $('[name="' + $this.data('name') + '"]').val(data.id);
  699. }
  700. });
  701. });
  702. Form.api.bindevent($("form[role=form]"), function(data, ret){
  703. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  704. Fast.api.close(data);//这里是重点
  705. });
  706. }
  707. }
  708. };
  709. return Controller;
  710. });