duty_equip.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. $(".btn-add").data("area",["920px","360px"]);
  6. // $(".btn-edit").data("area",["860px","50%"]);
  7. Table.api.init({
  8. extend: {
  9. index_url: 'duty_equip/index' + location.search,
  10. add_url: 'duty_equip/add',
  11. edit_url: 'duty_equip/edit',
  12. del_url: 'duty_equip/del',
  13. multi_url: 'duty_equip/multi',
  14. import_url: 'duty_equip/import',
  15. table: 'duty_equip',
  16. }
  17. });
  18. var table = $("#table");
  19. // 初始化表格
  20. table.bootstrapTable({
  21. url: $.fn.bootstrapTable.defaults.extend.index_url,
  22. pk: 'id',
  23. sortName: 'id',
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'order_number', title: __('序号')},
  28. {field: 'unit_id_text', title: __('Unit_id')},
  29. {field: 'name', title: __('Name')},
  30. {field: 'time', title: __('值班日期')},
  31. {field: 'amount', title: __('Amount')},
  32. {field: 'type', title: __('Type')},
  33. {field: 'state', title: __('State')},
  34. {field: 'site', title: __('Site')},
  35. {field: 'contents', title: __('Contents')},
  36. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. //{field: 'updatetime', title: __('Updatetime'), operate: 'LIKE'},
  38. //{field: 'field', title: __('Field'), operate: 'LIKE'},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. table.on('post-body.bs.table',function(){
  46. $(".btn-editone").data("area",["920px","360px"]);
  47. })
  48. },
  49. add: function () {
  50. Controller.api.bindevent();
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. },
  55. api: {
  56. bindevent: function () {
  57. Form.api.bindevent($("form[role=form]"));
  58. }
  59. }
  60. };
  61. return Controller;
  62. });