food.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. $(".btn-add").data("area",["1000px","690px"]);
  5. // 初始化表格参数配置
  6. Table.api.init({
  7. extend: {
  8. index_url: 'food/index' + location.search,
  9. add_url: 'food/add',
  10. edit_url: 'food/edit',
  11. del_url: 'food/del',
  12. multi_url: 'food/multi',
  13. import_url: 'food/import',
  14. table: 'food',
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'id',
  23. columns: [
  24. [
  25. {checkbox: true},
  26. {field: 'order_number', title: __('Id')},
  27. {field: 'unit_id_text', title: __('单位')},
  28. {field: 'people_id_text', title: __('People_id')},
  29. {field: 'record_date', title: __('Record_date'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  30. {field: 'chairman_id_text', title: __('经委会主任')},
  31. {field: 'people_id1_text', title: __('People_id1')},
  32. //{field: 'people_ids', title: __('People_ids'), operate: 'LIKE'},
  33. {field: 'createtime', title: __('Createtime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. //{field: 'updatetime', title: __('Updatetime'), operate: 'LIKE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,buttons: [
  36. {
  37. name: '查看',
  38. text: '查看',
  39. title: '查看',
  40. classname: 'btn btn-xs btn-info btn-view btn-dialog ',
  41. icon: 'fa fa-search',
  42. url: 'food/details',
  43. extend: 'data-area=\'["960px","80%"]\'',
  44. refresh: true
  45. }
  46. ], formatter: Table.api.formatter.operate}
  47. ]
  48. ]
  49. });
  50. // 为表格绑定事件
  51. Table.api.bindevent(table);
  52. table.on('post-body.bs.table',function(){
  53. $(".btn-editone").data("area",["1000px","690px"]);
  54. })
  55. },
  56. add: function () {
  57. Controller.api.bindevent();
  58. $("#c-people_id,#c-chairman_id,#c-people_id1,#c-people_ids").data("params", function (obj) {
  59. // console.log($(this).attr('id'))
  60. var unit_id = $('#J_unitselect').val();
  61. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  62. });
  63. $(document).on('click','.btn-append',function(){
  64. $(".people_id1,.people_id2").data("params", function (obj) {
  65. var unit_id = $('#J_unitselect').val();
  66. return {
  67. "custom[unit_id][0]": "in",
  68. "custom[unit_id][1]": unit_id
  69. };
  70. });
  71. });
  72. $(document).on("fa.event.appendfieldlist", "#add-form .btn-append", function (e, obj) {
  73. Form.events.selectpage(obj);
  74. Form.events.selectpicker(obj);
  75. // Form.events.datetimepicker(obj);
  76. });
  77. },
  78. edit: function () {
  79. Controller.api.bindevent();
  80. $("#c-people_id,#c-chairman_id,#c-people_id1,#c-people_ids").data("params", function (obj) {
  81. // console.log($(this).attr('id'))
  82. var unit_id = $('#J_unitselect').val();
  83. return {"custom[unit_id][0]":"in","custom[unit_id][1]":unit_id};
  84. });
  85. $(document).on('click','.btn-append',function(){
  86. $(".people_id1,.people_id2").data("params", function (obj) {
  87. var unit_id = $('#J_unitselect').val();
  88. return {
  89. "custom[unit_id][0]": "in",
  90. "custom[unit_id][1]": unit_id
  91. };
  92. });
  93. });
  94. $(document).on("fa.event.appendfieldlist", "#edit-form .btn-append", function (e, obj) {
  95. Form.events.selectpage(obj);
  96. Form.events.selectpicker(obj);
  97. // Form.events.datetimepicker(obj);
  98. });
  99. },
  100. api: {
  101. bindevent: function () {
  102. Form.api.bindevent($("form[role=form]"));
  103. }
  104. }
  105. };
  106. return Controller;
  107. });