lottery.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: 'lottery/lottery/index' + location.search,
  8. add_url: 'lottery/lottery/add',
  9. edit_url: 'lottery/lottery/edit',
  10. del_url: 'lottery/lottery/del',
  11. multi_url: 'lottery/lottery/multi',
  12. import_url: 'lottery/lottery/import',
  13. table: 'lottery',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'code', title: __('Code'), operate: 'LIKE'},
  27. {field: 'title', title: __('Title'), operate: 'LIKE'},
  28. {field: 'memo', title: __('Memo'), operate: 'LIKE'},
  29. {field: 'createtime', title: __('Createtime')},
  30. {
  31. field: 'operate',
  32. title: __('Operate'),
  33. table: table, events:
  34. Table.api.events.operate,
  35. buttons: [
  36. {
  37. name: 'filter',
  38. text: '过滤',
  39. classname: 'btn btn-xs btn-info btn-ajax',
  40. icon: 'fa fa-rotate-left',
  41. url: 'lottery/lottery/filter?ids={id}',
  42. refresh: true
  43. }
  44. ],
  45. formatter: Table.api.formatter.operate
  46. }
  47. ]
  48. ]
  49. });
  50. // 为表格绑定事件
  51. Table.api.bindevent(table);
  52. },
  53. add: function () {
  54. Controller.api.bindevent();
  55. },
  56. edit: function () {
  57. Controller.api.bindevent();
  58. },
  59. api: {
  60. bindevent: function () {
  61. Form.api.bindevent($("form[role=form]"));
  62. }
  63. }
  64. };
  65. return Controller;
  66. });