enumgear.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'enumgear/index' + location.search,
  8. add_url: 'enumgear/add',
  9. edit_url: 'enumgear/edit',
  10. del_url: 'enumgear/del',
  11. multi_url: 'enumgear/multi',
  12. import_url: 'enumgear/import',
  13. table: 'car_enum_gear',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'name', title: __('Name'), operate: 'LIKE'},
  27. {field: 'weigh', title: __('Weigh'), operate: false},
  28. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  29. ]
  30. ]
  31. });
  32. // 为表格绑定事件
  33. Table.api.bindevent(table);
  34. },
  35. add: function () {
  36. Controller.api.bindevent();
  37. },
  38. edit: function () {
  39. Controller.api.bindevent();
  40. },
  41. api: {
  42. bindevent: function () {
  43. Form.api.bindevent($("form[role=form]"));
  44. }
  45. }
  46. };
  47. return Controller;
  48. });