banner.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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: 'banner/index' + location.search,
  8. add_url: 'banner/add',
  9. edit_url: 'banner/edit',
  10. del_url: 'banner/del',
  11. multi_url: 'banner/multi',
  12. import_url: 'banner/import',
  13. table: 'banner',
  14. dragsort_url:false
  15. }
  16. });
  17. var table = $("#table");
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'weigh',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. search: false,
  26. columns: [
  27. [
  28. {checkbox: true},
  29. {field: 'id', title: __('Id')},
  30. {field: 'company_id', title: __('Company_id')},
  31. {field: 'company.name', title: __('Company.name'), operate: 'LIKE'},
  32. // {field: 'title', title: __('Title'), operate: 'LIKE'},
  33. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. // {field: 'url', title: __('Url'), operate: 'LIKE', formatter: Table.api.formatter.url},
  35. // {field: 'position', title: __('Position'), searchList: {"0":__('Position 0'),"1":__('Position 1')}, formatter: Table.api.formatter.normal},
  36. // {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  37. // {field: 'weigh', title: __('Weigh'), operate: false},
  38. // {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  41. ]
  42. ]
  43. });
  44. // 为表格绑定事件
  45. Table.api.bindevent(table);
  46. },
  47. add: function () {
  48. Controller.api.bindevent();
  49. },
  50. edit: function () {
  51. Controller.api.bindevent();
  52. },
  53. api: {
  54. bindevent: function () {
  55. Form.api.bindevent($("form[role=form]"));
  56. }
  57. }
  58. };
  59. return Controller;
  60. });