posters.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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: 'posters/index' + location.search,
  8. add_url: 'posters/create',
  9. edit_url: 'posters/update',
  10. del_url: 'posters/del',
  11. table: 'posters',
  12. }
  13. });
  14. var table = $("#table");
  15. $(".btn-add").data("area", ["100%", "100%"]);
  16. table.on('post-body.bs.table', function (e, settings, json, xhr) {
  17. $(".btn-editone").data("area", ["100%", "100%"]);
  18. });
  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: 'id', title: __('Id')},
  28. {field: 'title', title: __('Title'), operate: 'LIKE'},
  29. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  30. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  31. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  32. ]
  33. ]
  34. });
  35. // 为表格绑定事件
  36. Table.api.bindevent(table);
  37. },
  38. add: function () {
  39. Controller.api.bindevent();
  40. },
  41. edit: function () {
  42. Controller.api.bindevent();
  43. },
  44. api: {
  45. bindevent: function () {
  46. Form.api.bindevent($("form[role=form]"));
  47. }
  48. }
  49. };
  50. return Controller;
  51. });