lesson.js 4.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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: 'lesson/index' + location.search,
  8. add_url: 'lesson/add',
  9. edit_url: 'lesson/edit',
  10. // del_url: 'lesson/del',
  11. multi_url: 'lesson/multi',
  12. import_url: 'lesson/import',
  13. table: 'lesson',
  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. sortOrder: 'asc',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field: 'id', title: __('Id')},
  29. {field: 'name', title: __('Name'), operate: 'LIKE'},
  30. {field: 'name_en', title: __('Name_en'), operate: 'LIKE'},
  31. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  32. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  33. {field: 'oldprice', title: __('Oldprice'), operate:'BETWEEN'},
  34. {field: 'lessoncate_id', title: __('Lessoncate_id')},
  35. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  36. {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
  37. {field: 'weigh', title: __('Weigh'), operate: false},
  38. // {field: 'title', title: __('Title'), operate: 'LIKE'},
  39. // {field: 'title_en', title: __('Title_en'), operate: 'LIKE'},
  40. // {field: 'info', title: __('Info'), operate: 'LIKE'},
  41. // {field: 'info_en', title: __('Info_en'), operate: 'LIKE'},
  42. // {field: 'shiherenqun', title: __('Shiherenqun'), operate: 'LIKE'},
  43. // {field: 'shiherenqun_en', title: __('Shiherenqun_en'), operate: 'LIKE'},
  44. // {field: 'pingjunrenshu', title: __('Pingjunrenshu'), operate: 'LIKE'},
  45. // {field: 'pingjunrenshu_en', title: __('Pingjunrenshu_en'), operate: 'LIKE'},
  46. // {field: 'sirenkecheng', title: __('Sirenkecheng'), operate: 'LIKE'},
  47. // {field: 'sirenkecheng_en', title: __('Sirenkecheng_en'), operate: 'LIKE'},
  48. // {field: 'daoshi', title: __('Daoshi'), operate: 'LIKE'},
  49. // {field: 'daoshi_en', title: __('Daoshi_en'), operate: 'LIKE'},
  50. {field: 'cate.name', title: __('Cate.name'), operate: 'LIKE'},
  51. {field: 'cate.name_en', title: __('Cate.name_en'), operate: 'LIKE'},
  52. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  53. ]
  54. ]
  55. });
  56. // 为表格绑定事件
  57. Table.api.bindevent(table);
  58. },
  59. add: function () {
  60. Controller.api.bindevent();
  61. },
  62. edit: function () {
  63. Controller.api.bindevent();
  64. },
  65. vue_add: function () {
  66. Form.api.bindevent($("form[role=form]"), function(data, ret){
  67. window.location.href = ret.url;
  68. })
  69. },
  70. vue_edit: function () {
  71. Form.api.bindevent($("form[role=form]"), function(data, ret){
  72. window.location.href = ret.url;
  73. })
  74. },
  75. api: {
  76. bindevent: function () {
  77. Form.api.bindevent($("form[role=form]"));
  78. }
  79. }
  80. };
  81. return Controller;
  82. });