comment.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  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. },
  21. table: {
  22. first: function () {
  23. // 初始化表格参数配置
  24. Table.api.init({
  25. extend: {
  26. index_url: 'qingdongams/leads/comment/index',
  27. table: 'comment'
  28. }
  29. });
  30. var table = $("#table");
  31. // 初始化表格
  32. table.bootstrapTable({
  33. url: 'qingdongams/leads/comment/index?type=0',
  34. toolbar: '#toolbar',
  35. sortName: 'id',
  36. columns: [
  37. [
  38. {field: 'state', checkbox: true},
  39. {
  40. field : 'record.content', title : '跟进内容', fixedColumns : true, formatter : function (value, row, index) {
  41. if(row.record){
  42. return "<a href='javascript:void(0);' data-id='" + row.record.id + "' class='show-record'>" + row.record.content + "</a>";
  43. }else{
  44. return '';
  45. }
  46. },operate:false
  47. },
  48. {field: 'content', title: __('评论内容')},
  49. {field: 'staff.name', title: __('创建人'),operate:false},
  50. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  51. ]
  52. ],
  53. //启用普通表单搜索
  54. commonSearch: true,
  55. searchFormVisible: true,
  56. });
  57. $(document).on('click', '.show-record', function (data) {
  58. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  59. var options = {
  60. shadeClose : false,
  61. shade : [0.3, '#393D49'],
  62. area : area,
  63. callback : function (value) {
  64. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  65. }
  66. };
  67. Fast.api.open("qingdongams/customer/record/detail?ids=" + $(this).data('id'), '跟进详情', options);
  68. });
  69. // 为表格绑定事件
  70. Table.api.bindevent(table);
  71. $('.search').hide();
  72. $('.btn-import').hide();
  73. },
  74. second: function () {
  75. // 初始化表格参数配置
  76. Table.api.init({
  77. extend: {
  78. index_url: 'qingdongams/leads/comment/index',
  79. table: 'comment'
  80. }
  81. });
  82. var table = $("#table1");
  83. // 初始化表格
  84. table.bootstrapTable({
  85. url: 'qingdongams/leads/comment/index?type=1',
  86. toolbar: '#toolbar1',
  87. sortName: 'id',
  88. columns: [
  89. [
  90. {field: 'state', checkbox: true},
  91. {
  92. field : 'record.content', title : '跟进内容', fixedColumns : true, formatter : function (value, row, index) {
  93. if(row.record){
  94. return "<a href='javascript:void(0);' data-id='" + row.record.id + "' class='show-record'>" + row.record.content + "</a>";
  95. }else{
  96. return '';
  97. }
  98. },operate:false
  99. },
  100. {field: 'content', title: __('评论内容')},
  101. {field: 'staff.name', title: __('创建人'),operate:false},
  102. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  103. ]
  104. ],
  105. //启用普通表单搜索
  106. commonSearch: true,
  107. searchFormVisible: true,
  108. });
  109. // 为表格绑定事件
  110. Table.api.bindevent(table);
  111. $('.search').hide();
  112. $('.btn-import').hide();
  113. },
  114. third: function () {
  115. // 初始化表格参数配置
  116. Table.api.init({
  117. extend: {
  118. index_url: 'qingdongams/leads/comment/index',
  119. table: 'comment'
  120. }
  121. });
  122. var table = $("#table2");
  123. // 初始化表格
  124. table.bootstrapTable({
  125. url: 'qingdongams/leads/comment/index?type=2',
  126. toolbar: '#toolbar2',
  127. sortName: 'id',
  128. columns: [
  129. [
  130. {field: 'state', checkbox: true},
  131. {
  132. field : 'record.content', title : '跟进内容', fixedColumns : true, formatter : function (value, row, index) {
  133. if(row.record){
  134. return "<a href='javascript:void(0);' data-id='" + row.record.id + "' class='show-record'>" + row.record.content + "</a>";
  135. }else{
  136. return '';
  137. }
  138. },operate:false
  139. },
  140. {field: 'content', title: __('评论内容')},
  141. {field: 'staff.name', title: __('创建人'),operate:false},
  142. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  143. ]
  144. ],
  145. //启用普通表单搜索
  146. commonSearch: true,
  147. searchFormVisible: true,
  148. });
  149. // 为表格绑定事件
  150. Table.api.bindevent(table);
  151. $('.search').hide();
  152. $('.btn-import').hide();
  153. },
  154. },
  155. add: function () {
  156. Controller.api.bindevent();
  157. },
  158. api: {
  159. bindevent: function () {
  160. Form.api.bindevent($("form[role=form]"));
  161. },
  162. formatter: {
  163. }
  164. }
  165. };
  166. return Controller;
  167. });