trylesson.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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: 'trylesson/index' + location.search,
  8. add_url: 'trylesson/add',
  9. edit_url: 'trylesson/edit',
  10. // del_url: 'trylesson/del',
  11. multi_url: 'trylesson/multi',
  12. import_url: 'trylesson/import',
  13. table: 'trylesson',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'name_en', title: __('Name_en'), operate: 'LIKE'},
  30. {field: 'info', title: __('Info'), operate: 'LIKE'},
  31. {field: 'info_en', title: __('Info_en'), operate: 'LIKE'},
  32. {field: 'lesson_ids', title: __('Lesson_ids'), operate: 'LIKE'},
  33. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  34. {field: 'price', title: __('Price'), operate:'BETWEEN'},
  35. {field: 'oldprice', title: __('Oldprice'), operate:'BETWEEN'},
  36. // {field: 'content', title: __('Content')},
  37. // {field: 'content_en', title: __('Content_en')},
  38. {field: 'lessoncate_id', title: __('Lessoncate_id')},
  39. {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
  40. {field: 'weigh', title: __('Weigh'), operate: false},
  41. // {field: 'lesson.name', title: __('Lesson.name'), operate: 'LIKE'},
  42. // {field: 'lesson.name_en', title: __('Lesson.name_en'), operate: 'LIKE'},
  43. {field: 'cate.name', title: __('Cate.name'), operate: 'LIKE'},
  44. {field: 'cate.name_en', title: __('Cate.name_en'), operate: 'LIKE'},
  45. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  46. ]
  47. ]
  48. });
  49. // 为表格绑定事件
  50. Table.api.bindevent(table);
  51. },
  52. add: function () {
  53. Controller.api.bindevent();
  54. },
  55. edit: function () {
  56. Controller.api.bindevent();
  57. },
  58. api: {
  59. bindevent: function () {
  60. Form.api.bindevent($("form[role=form]"));
  61. }
  62. }
  63. };
  64. return Controller;
  65. });