duty_statistics.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area",["860px","46%"]);
  6. $(".btn-edit").data("area",["860px","46%"]);
  7. Table.api.init({
  8. extend: {
  9. index_url: 'duty_statistics/index' + location.search,
  10. add_url: 'duty_statistics/add',
  11. edit_url: 'duty_statistics/edit',
  12. del_url: 'duty_statistics/del',
  13. multi_url: 'duty_statistics/multi',
  14. import_url: 'duty_statistics/import',
  15. table: 'duty_statistics',
  16. }
  17. });
  18. var table = $("#table");
  19. table.on('post-common-search.bs.table', function (event, table) {
  20. var form = $("form", table.$commonsearch);
  21. $("input[name='factory.name']", form).addClass("selectpage").data("source", "factories/index").data("primaryKey", "name").data("field", "name");
  22. $("input[name='admin.username']", form).addClass("selectpage").data("source", "auth/admin/index").data("primaryKey", "username").data("field", "username");//路径为控制器方法
  23. $("input[name='engineer.name']", form).addClass("selectpage").data("source", "engineers/index").data("primaryKey", "name").data("field", "name");
  24. Form.events.cxselect(form); Form.events.selectpage(form);
  25. });
  26. // 初始化表格
  27. table.bootstrapTable({
  28. url: $.fn.bootstrapTable.defaults.extend.index_url,
  29. pk: 'id',
  30. sortName: 'id',
  31. search:false,
  32. commonSearch: true,
  33. showToggle: false,
  34. showColumns: false,
  35. pagination:false,
  36. columns: [
  37. [
  38. // {checkbox: true},
  39. {field: 'order_number', title: __('Id')},
  40. {field: 'unit_name', title: __('Unit_id'),operate:false},
  41. {field: 'unit_id', title: __('Unit_id'),visible:false, operate: 'IN'},
  42. {field: 'duty_today', title: __('Today'), operate: 'LIKE',formatter: Controller.api.formatter.status},
  43. {field: 'duty_tomorrow', title: __('Tomorrow'), operate: 'LIKE',formatter: Controller.api.formatter.status},
  44. {field: 'duty_bus', title: __('Vehicle'), operate: 'LIKE',formatter: Controller.api.formatter.status},
  45. {field: 'duty_equip', title: __('Equip'), operate: 'LIKE',formatter: Controller.api.formatter.status}
  46. ]
  47. ]
  48. });
  49. $('#s-search').click(function(){
  50. window.location.href="?unit_id="+$('#s-unit_id').val();
  51. });
  52. // 为表格绑定事件
  53. Table.api.bindevent(table);
  54. },
  55. add: function () {
  56. Controller.api.bindevent();
  57. },
  58. edit: function () {
  59. Controller.api.bindevent();
  60. },
  61. api: {
  62. bindevent: function () {
  63. Form.api.bindevent($("form[role=form]"));
  64. },
  65. formatter: {//渲染的方法
  66. status: function (value, row, index) {
  67. if(value=='1')return '<span class="text-success"><i class="fa fa-check-circle"></i></span>';
  68. return '<span class="text-danger"><i class="fa fa-times-circle"></i></span>';
  69. }
  70. },
  71. }
  72. };
  73. return Controller;
  74. });