lessonslot.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: 'bookednum', title: __('Bookednum')},
  34. {field: 'waitnum_max', title: __('Waitnum_max')},
  35. {field: 'coach_ids', title: __('Coach_ids'), operate: 'LIKE'},
  36. {field: 'coach.nickname', title: __('Coach.nickname'), operate: 'LIKE'},
  37. {field: 'lesson_id', title: __('Lesson_id')},
  38. {field: 'lesson.name', title: __('Lesson.name'), operate: 'LIKE'},
  39. {field: 'lesson.name_en', title: __('Lesson.name_en'), operate: 'LIKE'},
  40. {field: 'lesson.type', title: __('Lesson.type'),searchList: {"1":__('Lesson.type 1'),"2":__('Lesson.type 2')}, formatter: Table.api.formatter.normal},
  41. // {field: 'address', title: __('Address'), operate: 'LIKE'},
  42. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"20":__('Status 20'),"30":__('Status 30')}, formatter: Table.api.formatter.status},
  43. // {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  44. // {field: 'notice_status', title: __('Notice_status'), searchList: {"0":__('Notice_status 0'),"1":__('Notice_status 1')}, formatter: Table.api.formatter.status},
  45. {field: 'finishtime', title: __('Finishtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  46. {field: 'cancel_reason', title: __('Cancel_reason'), operate: 'LIKE'},
  47. {field: 'cancel_time', title: __('Cancel_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  48. {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
  49. // {field: 'cancel_notice_status', title: __('Cancel_notice_status'), searchList: {"0":__('Cancel_notice_status 0'),"1":__('Cancel_notice_status 1')}, formatter: Table.api.formatter.status},
  50. {field: 'danceroom_id', title: __('Danceroom_id')},
  51. {field: 'danceroom.name', title: __('Danceroom.name'), operate: 'LIKE'},
  52. {field: 'danceroom.name_en', title: __('Danceroom.name_en'), operate: 'LIKE'},
  53. {field: 'operate', title: __('Operate'), table: table,
  54. buttons:[
  55. {
  56. name:'cancel',
  57. text:'取消',
  58. title:'取消',
  59. icon:'fa fa-exclamation-circle',
  60. classname:'btn btn-xs btn-info btn-dialog',
  61. url:'lessonslot/cancel/id/{ids}?dialog=1',
  62. target:'_self',
  63. hidden:function(row){
  64. return row.status==0 ? false : true;
  65. }
  66. },
  67. {
  68. name:'booking',
  69. text:'预约',
  70. title:'预约',
  71. icon:'fa fa-exclamation-circle',
  72. classname:'btn btn-xs btn-info btn-dialog',
  73. url:'lessonslot/booking/id/{ids}?dialog=1',
  74. target:'_self',
  75. hidden:function(row){
  76. return row.status==0 ? false : true;
  77. }
  78. }
  79. ],
  80. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  81. ]
  82. ]
  83. });
  84. // 为表格绑定事件
  85. Table.api.bindevent(table);
  86. // 复制本周的课程表
  87. /*$(document).on("click", ".btn-copyweek", function () {
  88. Fast.api.ajax('lessonslot/copyweek','复制本周的课程表');
  89. });*/
  90. },
  91. add: function () {
  92. Controller.api.bindevent();
  93. },
  94. booking: function () {
  95. Controller.api.bindevent();
  96. },
  97. edit: function () {
  98. Controller.api.bindevent();
  99. },
  100. cancel: function () {
  101. Controller.api.bindevent();
  102. },
  103. copyweek: function () {
  104. Form.api.bindevent($("form[role=form]"));
  105. },
  106. api: {
  107. bindevent: function () {
  108. Form.api.bindevent($("form[role=form]"));
  109. }
  110. }
  111. };
  112. return Controller;
  113. });
  114. $("#c-packageorder_id").data("params", function (obj) {
  115. return {
  116. user_id: $("#c-user_id").val(), number: $("#c-number").val(), slot_id: $("#c-slot_id").val()
  117. };
  118. });
  119. $(document).on("change","#c-user_id",function(){
  120. $("#c-packageorder_id").selectPageClear();
  121. })
  122. $(document).on("change","#c-number",function(){
  123. $("#c-packageorder_id").selectPageClear();
  124. })