statisc.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. tableinfo:{
  22. url : '',
  23. toolbar: '',
  24. pk : 'id',
  25. sortName : 'id',
  26. fixedColumns : true,
  27. fixedNumber : 2,
  28. fixedRightNumber : 1,
  29. columns: [
  30. [
  31. {field: 'state', checkbox: true},
  32. {field: 'month', title: '月份', operate: false},
  33. {field: 'staff', title: '姓名', operate: false},
  34. {field: 'normal', title: __('正常天数'), operate: false},
  35. {field: 'error', title: __('异常天数'), operate: false},
  36. {field: 'late', title:'迟到', operate: false},
  37. {field: 'leave', title: '早退', operate: false},
  38. {field: 'work', title: __('旷工'), operate: false},
  39. {field: 'card', title: __('缺卡'), operate: false},
  40. {field: 'other', title: __('外勤'), operate: false},
  41. {field: 'overtime', title: __('加班时长'), operate: false},
  42. ]
  43. ],
  44. pagination : true,
  45. search : false,
  46. commonSearch : true,
  47. searchFormVisible : true,
  48. searchFormTemplate: 'customformtpl',
  49. //显示导出按钮
  50. showExport: false,
  51. onLoadSuccess:function(){
  52. // 这里就是数据渲染结束后的回调函数
  53. $(".btn-add").data("area",["80%","80%"]);
  54. $(".btn-edit").data("area",["80%","80%"]);
  55. }
  56. },
  57. table: {
  58. first: function () {
  59. // 初始化表格参数配置
  60. Table.api.init({
  61. extend: {
  62. index_url: 'qingdongams/attendance/statisc/index',
  63. table: 'statisc'
  64. }
  65. });
  66. var table = $("#table");
  67. Controller.tableinfo.url=location.href+'&type=0';
  68. Controller.tableinfo.toolbar='#toolbar';
  69. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  70. // 初始化表格
  71. table.bootstrapTable(Controller.tableinfo);
  72. // 为表格绑定事件
  73. Table.api.bindevent(table);
  74. },
  75. second: function () {
  76. // 初始化表格参数配置
  77. Table.api.init({
  78. extend: {
  79. index_url: 'qingdongams/attendance/statisc/index',
  80. table: 'statisc'
  81. }
  82. });
  83. var table = $("#table1");
  84. Controller.tableinfo.url=location.href+'&type=1';
  85. Controller.tableinfo.toolbar='#toolbar1';
  86. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  87. // 初始化表格
  88. table.bootstrapTable(Controller.tableinfo);
  89. // 为表格绑定事件
  90. Table.api.bindevent(table);
  91. },
  92. third: function () {
  93. // 初始化表格参数配置
  94. Table.api.init({
  95. extend: {
  96. index_url: 'qingdongams/attendance/statisc/index',
  97. table: 'statisc'
  98. }
  99. });
  100. var table = $("#table2");
  101. Controller.tableinfo.url=location.href+'&type=2';
  102. Controller.tableinfo.toolbar='#toolbar2 ';
  103. Controller.tableinfo.columns[0][Controller.tableinfo.columns[0].length-1].table=table;
  104. // 初始化表格
  105. table.bootstrapTable(Controller.tableinfo);
  106. // 为表格绑定事件
  107. Table.api.bindevent(table);
  108. },
  109. },
  110. add: function () {
  111. Controller.api.bindevent();
  112. },
  113. api: {
  114. bindevent: function () {
  115. Form.api.bindevent($("form[role=form]"));
  116. },
  117. }
  118. };
  119. return Controller;
  120. });