lessonslot.js 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. table.on('load-success.bs.table', function (e, data) {
  18. console.log(data);
  19. $("#last_week").attr('href','/FioeDKdjym.php/lessonslot/index?addtab=1&week_current=' + data.extend.last_week);
  20. $("#this_week").attr('href','/FioeDKdjym.php/lessonslot/index?addtab=1&week_current=' + data.extend.this_week);
  21. $("#next_week").attr('href','/FioeDKdjym.php/lessonslot/index?addtab=1&week_current=' + data.extend.next_week);
  22. });
  23. // 初始化表格
  24. table.bootstrapTable({
  25. url: $.fn.bootstrapTable.defaults.extend.index_url,
  26. pk: 'id',
  27. sortName: 'id',
  28. fixedColumns: true,
  29. fixedRightNumber: 1,
  30. columns: [
  31. [
  32. {checkbox: true},
  33. {field: 'id', title: __('Id')},
  34. {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  35. {field: 'week', title: __('Week'), operate:false},
  36. {field: 'hours', title: __('Hours')},
  37. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'num_min', title: __('Num_min')},
  39. {field: 'num_max', title: __('Num_max')},
  40. {field: 'bookednum', title: __('Bookednum')},
  41. {field: 'waitnum_max', title: __('Waitnum_max')},
  42. {field: 'coach_ids', title: __('Coach_ids'), operate: 'LIKE'},
  43. {field: 'coach.nickname', title: __('Coach.nickname'), operate: 'LIKE'},
  44. {field: 'lesson_id', title: __('Lesson_id')},
  45. {field: 'lesson.name', title: __('Lesson.name'), operate: 'LIKE'},
  46. {field: 'lesson.name_en', title: __('Lesson.name_en'), operate: 'LIKE'},
  47. {field: 'lesson.type', title: __('Lesson.type'),searchList: {"1":__('Lesson.type 1'),"2":__('Lesson.type 2')}, formatter: Table.api.formatter.normal},
  48. // {field: 'address', title: __('Address'), operate: 'LIKE'},
  49. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"20":__('Status 20'),"30":__('Status 30')}, formatter: Table.api.formatter.status},
  50. // {field: 'remark', title: __('Remark'), operate: 'LIKE'},
  51. // {field: 'notice_status', title: __('Notice_status'), searchList: {"0":__('Notice_status 0'),"1":__('Notice_status 1')}, formatter: Table.api.formatter.status},
  52. {field: 'finishtime', title: __('Finishtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  53. {field: 'cancel_reason', title: __('Cancel_reason'), operate: 'LIKE'},
  54. {field: 'cancel_time', title: __('Cancel_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  55. {field: 'is_show', title: __('Is_show'), searchList: {"1":__('Is_show 1'),"0":__('Is_show 0')}, formatter: Table.api.formatter.normal},
  56. {field: 'copy_status', title: __('Copy_status'), searchList: {"1":__('Copy_status 1'),"0":__('Copy_status 0')}, formatter: Table.api.formatter.normal},
  57. // {field: 'cancel_notice_status', title: __('Cancel_notice_status'), searchList: {"0":__('Cancel_notice_status 0'),"1":__('Cancel_notice_status 1')}, formatter: Table.api.formatter.status},
  58. {field: 'danceroom_id', title: __('Danceroom_id')},
  59. {field: 'danceroom.name', title: __('Danceroom.name'), operate: 'LIKE'},
  60. {field: 'danceroom.name_en', title: __('Danceroom.name_en'), operate: 'LIKE'},
  61. {field: 'operate', title: __('Operate'), table: table,
  62. buttons:[
  63. {
  64. name:'cancel',
  65. text:'取消',
  66. title:'取消',
  67. icon:'fa fa-exclamation-circle',
  68. classname:'btn btn-xs btn-info btn-dialog',
  69. url:'lessonslot/cancel/id/{ids}?dialog=1',
  70. target:'_self',
  71. hidden:function(row){
  72. return row.status==0 ? false : true;
  73. }
  74. },
  75. {
  76. name:'booking',
  77. text:'预约',
  78. title:'预约',
  79. icon:'fa fa-exclamation-circle',
  80. classname:'btn btn-xs btn-info btn-dialog',
  81. url:'lessonslot/booking/id/{ids}?dialog=1',
  82. target:'_self',
  83. hidden:function(row){
  84. return row.status==0 ? false : true;
  85. }
  86. }
  87. ],
  88. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  89. ]
  90. ]
  91. });
  92. // 为表格绑定事件
  93. Table.api.bindevent(table);
  94. // 复制本周的课程表
  95. /*$(document).on("click", ".btn-copyweek", function () {
  96. Fast.api.ajax('lessonslot/copyweek','复制本周的课程表');
  97. });*/
  98. },
  99. add: function () {
  100. Controller.api.bindevent();
  101. },
  102. booking: function () {
  103. Controller.api.bindevent();
  104. },
  105. edit: function () {
  106. Controller.api.bindevent();
  107. },
  108. cancel: function () {
  109. Controller.api.bindevent();
  110. },
  111. copyweek: function () {
  112. Form.api.bindevent($("form[role=form]"));
  113. },
  114. api: {
  115. bindevent: function () {
  116. Form.api.bindevent($("form[role=form]"));
  117. }
  118. }
  119. };
  120. return Controller;
  121. });
  122. $("#c-packageorder_id").data("params", function (obj) {
  123. return {
  124. user_id: $("#c-user_id").val(), number: $("#c-number").val(), slot_id: $("#c-slot_id").val()
  125. };
  126. });
  127. $("#c-trylessonorder_id").data("params", function (obj) {
  128. return {
  129. user_id: $("#c-user_id").val(), number: $("#c-number").val(), slot_id: $("#c-slot_id").val()
  130. };
  131. });
  132. $(document).on("change","#c-user_id",function(){
  133. $("#c-packageorder_id").selectPageClear();
  134. $("#c-trylessonorder_id").selectPageClear();
  135. })
  136. $(document).on("change","#c-number",function(){
  137. $("#c-packageorder_id").selectPageClear();
  138. $("#c-trylessonorder_id").selectPageClear();
  139. })