lessonslot.js 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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: 'lessonslot/index' + location.search,
  8. add_url: 'lessonslot/add',
  9. edit_url: 'lessonslot/edit',
  10. del_url: 'lessonslot/del',
  11. multi_url: 'lessonslot/multi',
  12. import_url: 'lessonslot/import',
  13. table: 'lesson_slot',
  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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  29. {field: 'hours', title: __('Hours')},
  30. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  31. {field: 'num_min', title: __('Num_min')},
  32. {field: 'num_max', title: __('Num_max')},
  33. {field: 'coach_ids', title: __('Coach_ids'), operate: 'LIKE'},
  34. {field: 'lesson_id', title: __('Lesson_id')},
  35. // {field: 'address', title: __('Address'), operate: 'LIKE'},
  36. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"20":__('Status 20'),"30":__('Status 30')}, formatter: Table.api.formatter.status},
  37. // {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  38. // {field: 'notice_status', title: __('Notice_status'), searchList: {"0":__('Notice_status 0'),"1":__('Notice_status 1')}, formatter: Table.api.formatter.status},
  39. {field: 'finishtime', title: __('Finishtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'cancel_reason', title: __('Cancel_reason'), operate: 'LIKE'},
  41. {field: 'cancel_time', title: __('Cancel_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. // {field: 'coach.nickname', title: __('Coach.nickname'), operate: 'LIKE'},
  43. {field: 'lesson_id', title: __('Lesson_id')},
  44. {field: 'lesson.name', title: __('Lesson.name'), operate: 'LIKE'},
  45. {field: 'lesson.name_en', title: __('Lesson.name_en'), operate: 'LIKE'},
  46. {field: 'operate', title: __('Operate'), table: table,
  47. buttons:[
  48. {
  49. name:'cancel',
  50. text:'取消',
  51. title:'取消',
  52. icon:'fa fa-exclamation-circle',
  53. classname:'btn btn-xs btn-info btn-dialog',
  54. url:'lessonslot/cancel/id/{ids}?dialog=1',
  55. target:'_self',
  56. hidden:function(row){
  57. return row.status==0 ? false : true;
  58. }
  59. }
  60. ],
  61. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  62. ]
  63. ]
  64. });
  65. // 为表格绑定事件
  66. Table.api.bindevent(table);
  67. },
  68. add: function () {
  69. Controller.api.bindevent();
  70. },
  71. edit: function () {
  72. Controller.api.bindevent();
  73. },
  74. api: {
  75. bindevent: function () {
  76. Form.api.bindevent($("form[role=form]"));
  77. }
  78. }
  79. };
  80. return Controller;
  81. });