work.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. report: function () {
  4. Table.api.init({});
  5. var table = $("#table");
  6. // 初始化表格
  7. table.bootstrapTable({
  8. sortName: 'id',
  9. //启用普通表单搜索
  10. search:false,
  11. escape:false,
  12. pagination:false,
  13. commonSearch: true,
  14. searchFormVisible: true,
  15. });
  16. // 为表格绑定事件
  17. Table.api.bindevent(table);
  18. Form.events.selectpage($("form"));
  19. Form.events.daterangepicker($("form"));
  20. },record: function () {
  21. Table.api.init({});
  22. var table = $("#table");
  23. // 初始化表格
  24. table.bootstrapTable({
  25. sortName: 'id',
  26. //启用普通表单搜索
  27. search:false,
  28. escape:false,
  29. pagination:false,
  30. commonSearch: true,
  31. searchFormVisible: true,
  32. });
  33. // 为表格绑定事件
  34. Table.api.bindevent(table);
  35. Form.events.selectpage($("form"));
  36. Form.events.daterangepicker($("form"));
  37. },record_list: function () {
  38. // 初始化表格参数配置
  39. Table.api.init({
  40. extend: {
  41. index_url: location.href,
  42. table: 'record'
  43. }
  44. });
  45. var table = $("#table");
  46. // 初始化表格
  47. table.bootstrapTable({
  48. url: $.fn.bootstrapTable.defaults.extend.index_url,
  49. toolbar: '#toolbar',
  50. sortName: 'id',
  51. columns: [
  52. [
  53. {field: 'state', checkbox: true},
  54. {
  55. field : 'customer.name', title : '所属客户', fixedColumns : true, formatter : function (value, row, index) {
  56. if(row.customer){
  57. return "<a href='javascript:void(0);' data-id='" + row.customer.id + "' class='show-customer'>" + row.customer.name + "</a>";
  58. }else{
  59. return '';
  60. }
  61. },operate:false
  62. },
  63. {field: 'follow_type', title: __('跟进类型'),operate:false},
  64. {field: 'follow_time', title: __('跟进时间'),operate:false},
  65. {field: 'follow', title: __('跟进状态'),operate:false},
  66. {field: 'content', title: __('跟进内容'),operate:false},
  67. {field: 'next_time', title: __('下次跟进时间'),operate:false},
  68. {field: 'staff.name', title: __('创建人'),operate:false},
  69. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  70. {
  71. field : 'operate',
  72. title : __('Operate'),
  73. table : table,
  74. events : Table.api.events.operate,
  75. formatter : Table.api.formatter.operate,
  76. buttons : [
  77. {
  78. name : '详情',
  79. text : __('详情'),
  80. classname : 'records btn-dialog',
  81. url : 'qingdong/customer/record/detail',
  82. callback: function (data) {
  83. $('.btn-success').trigger('click');
  84. },
  85. },
  86. {
  87. name : '评论',
  88. text : __('评论'),
  89. classname : 'records btn-dialog',
  90. url : 'qingdong/customer/comment/add',
  91. callback: function (data) {
  92. $('.btn-success').trigger('click');
  93. },
  94. }
  95. ]
  96. }
  97. ]
  98. ],
  99. search:false,
  100. //启用普通表单搜索
  101. commonSearch: true,
  102. searchFormVisible: true,
  103. onLoadSuccess:function(){
  104. // 这里就是数据渲染结束后的回调函数
  105. $(".btn-add").data("area",["80%","80%"]);
  106. $(".btn-edit").data("area",["80%","80%"]);
  107. }
  108. });
  109. $(document).on('click', '.show-customer', function (data) {
  110. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  111. var options = {
  112. shadeClose : false,
  113. shade : [0.3, '#393D49'],
  114. area : area,
  115. callback : function (value) {
  116. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  117. }
  118. };
  119. Fast.api.open($.fn.bootstrapTable.defaults.extend.customer_url + "?ids=" + $(this).data('id'), '客户详情', options);
  120. });
  121. // 为表格绑定事件
  122. Table.api.bindevent(table);
  123. },
  124. };
  125. return Controller;
  126. });