comment.js 7.8 KB

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