page.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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: 'page/index',
  8. add_url: 'page/add',
  9. edit_url: 'page/edit',
  10. del_url: 'page/del',
  11. multi_url: 'page/multi',
  12. table: 'page',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. sortName: 'weigh',
  20. columns: [
  21. [
  22. {field: 'state', checkbox: true},
  23. {field: 'id', title: __('Id'), operate: false},
  24. {field: 'category_id', title: __('Category_id'), operate: '='},
  25. {field: 'title', title: __('Title'), operate: 'LIKE %...%', placeholder: '标题,模糊搜索', style: 'width:200px'},
  26. {field: 'keywords', title: __('Keywords'), operate: 'LIKE %...%', placeholder: '关键字,模糊搜索'},
  27. {field: 'flag', title: __('Flag'), formatter: Table.api.formatter.flag, operate: false},
  28. {field: 'image', title: __('Image'), formatter: Table.api.formatter.image, operate: false},
  29. {field: 'icon', title: __('Icon'), formatter: Table.api.formatter.icon, operate: false},
  30. {field: 'views', title: __('Views'), operate: false},
  31. {field: 'comments', title: __('Comments'), operate: false},
  32. {field: 'weigh', title: __('Weigh'), operate: false},
  33. {field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {'normal': '正常', 'hidden': '隐藏'}, style: 'min-width:100px;'},
  34. {field: 'createtime', title: __('Create Time'), formatter: Table.api.formatter.datetime, operate: 'BETWEEN', type: 'datetime', addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"'},
  35. {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ],
  38. //普通搜索
  39. commonSearch: true,
  40. titleForm: '', //为空则不显示标题,不定义默认显示:普通搜索
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. api: {
  52. bindevent: function () {
  53. Form.api.bindevent($("form[role=form]"));
  54. }
  55. }
  56. };
  57. return Controller;
  58. });