trylesson.js 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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,
  46. buttons:[
  47. {
  48. name:'trylessonorder_add',
  49. text:__('用户下单'),
  50. title:__('用户下单'),
  51. icon:'fa fa-exclamation-circle',
  52. classname:'btn btn-xs btn-info btn-dialog',
  53. url:'trylessonorder/add/trylesson_id/{ids}?dialog=1',
  54. target:'_self',
  55. },
  56. ],
  57. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  58. ]
  59. ]
  60. });
  61. // 为表格绑定事件
  62. Table.api.bindevent(table);
  63. },
  64. add: function () {
  65. Controller.api.bindevent();
  66. },
  67. edit: function () {
  68. Controller.api.bindevent();
  69. },
  70. api: {
  71. bindevent: function () {
  72. Form.api.bindevent($("form[role=form]"));
  73. }
  74. }
  75. };
  76. return Controller;
  77. });