cnki.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index : function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend : {
  7. index_url : 'qingdong/customer/cnki/index',
  8. detail_url : 'qingdong/customer/customer/detail',
  9. table : 'qingdong_customer',
  10. }
  11. });
  12. var table = $("#table");
  13. // 初始化表格
  14. table.bootstrapTable({
  15. url : $.fn.bootstrapTable.defaults.extend.index_url,
  16. pk : 'id',
  17. sortName : 'id',
  18. fixedColumns : true,
  19. fixedNumber : 2,
  20. fixedRightNumber : 1,
  21. search:false,
  22. searchFormVisible:true,
  23. columns : [
  24. [
  25. {checkbox : true},
  26. {
  27. field : 'name', title : '客户名称', fixedColumns : true, formatter : function (value, row, index) {
  28. return "<a href='javascript:void(0);' data-id='" + row.id + "' class='show-detail'>" + value + "</a>";
  29. },operate:'like'
  30. },
  31. {field : 'subname', title : '助记名称',operate:'like'},
  32. {field : 'contract_status', title : '成交状态',operate:'=',searchList:{0:'未成交',1:'已成交'},formatter:Table.api.formatter.status},
  33. {field : 'industry', title : '客户所属',operate:'like'},
  34. {field : 'follow', title : '客户状态',operate:'like'},
  35. {field : 'source', title : '客户来源',operate:'like'},
  36. {field : 'level', title : '客户星级',operate:'=',searchList:{0:'无',1:'1星',2:'2星',3:'3星',4:'4星',5:'5星'},formatter:Table.api.formatter.status},
  37. {field : 'next_time', title : '下次联系时间',operate:false},
  38. {field : 'last_time', title : '最后跟进时间',operate:false},
  39. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.buttons,
  41. buttons: [
  42. {
  43. name: 'detail',
  44. text: __('合并客户'),
  45. title: __('合并客户'),
  46. classname: 'records btn-dialog',
  47. extend:'data-area=["90%","90%"]',
  48. url: 'qingdong/customer/cnki/edit',
  49. visible: function (row) {
  50. //返回true时按钮显示,返回false隐藏
  51. return true;
  52. }
  53. },
  54. ]
  55. }
  56. ]
  57. ]
  58. });
  59. $(document).on('click', '.show-detail', function (data) {
  60. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  61. var options = {
  62. shadeClose : false,
  63. shade : [0.3, '#393D49'],
  64. area : area,
  65. callback : function (value) {
  66. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  67. console.log(value);
  68. }
  69. };
  70. Fast.api.open($.fn.bootstrapTable.defaults.extend.detail_url + "?ids=" + $(this).data('id'), '客户详情', options);
  71. });
  72. // 为表格绑定事件
  73. Table.api.bindevent(table);
  74. },
  75. add : function () {
  76. Controller.api.bindevent();
  77. },
  78. edit : function () {
  79. $('.tongbu').change(function(){
  80. var number = $(this).val();
  81. var name = $(this).data('name');
  82. var zucontent = $('.zu_'+name).html();
  83. var fucontent = $('.fu_'+name).html();
  84. var content = zucontent+fucontent;
  85. if(number == 1){
  86. $('#c-'+name).val($.trim(zucontent));
  87. $('#c-'+name).selectpicker('val', zucontent.replace(/\s+/g,''));
  88. }else if(number == 2){
  89. $('#c-'+name).val(fucontent.replace(/\s+/g,''));
  90. $('#c-'+name).selectpicker('val', fucontent.replace(/\s+/g,''));
  91. }
  92. else{
  93. $('#c-'+name).val(content.replace(/\s+/g,''));
  94. }
  95. });
  96. Controller.api.bindevent();
  97. },
  98. api : {
  99. bindevent : function () {
  100. Form.api.bindevent($("form[role=form]"), function(data, ret){
  101. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  102. Fast.api.close(data);//这里是重点
  103. });
  104. }
  105. }
  106. };
  107. return Controller;
  108. });