collection.js 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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: 'student/collection/index' + location.search,
  8. table: 'teacher_collection',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'exam_collection_id',
  16. sortName: 'exam_collection_id',
  17. fixedColumns: true,
  18. fixedRightNumber: 1,
  19. searchFormVisible:true,
  20. columns: [
  21. [
  22. {checkbox: true},
  23. {field: 'exam_collection_id', title: __('编号')},
  24. {field: 'exam_collection_name', title: __('Exam_collection_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  25. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  26. {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
  27. {field: 'limit_duration', title: __('Limit_duration')},
  28. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,},
  29. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  30. // {field: 'create_user_id', title: __('Create_user_id')},
  31. {field: 'create_by', title: __('Create_by'), operate: 'LIKE'},
  32. // {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  33. // {field: 'update_by', title: __('Update_by'), operate: 'LIKE'},
  34. // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. {field: 'operate', title: __('Operate'), table: table,
  38. events: Table.api.events.operate,
  39. // formatter: Table.api.formatter.operate,
  40. formatter: Table.api.formatter.buttons,
  41. buttons: [
  42. {
  43. name: 'dispatch',
  44. text: '进入',
  45. icon: 'fa fa-hand-pointer-o',
  46. title: '进入',
  47. visible: function (row){
  48. if(row.is_user_examed==0){
  49. return true;
  50. }
  51. return false;
  52. },
  53. classname: 'btn btn-info btn-xs btn-magic btn-addtabs',
  54. extend: 'data-area=\'["85%","85%"]\'',
  55. url: 'student/collection/into',
  56. }
  57. ],
  58. }
  59. ]
  60. ]
  61. });
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. },
  68. into: function () {
  69. $(document).on('click', '.btn-startexam', function () {
  70. $.ajax({
  71. url: Config.url_type+"/sim/real-exam/student/exam/start/"+Config.exam_id,
  72. type: 'get',
  73. success: function (data) {
  74. console.log(data);
  75. if(data.code==200){
  76. window.location.href = '/ZQOtIMLKud.php/student/collection/examing/ids/'+Config.exam_id;
  77. }else{
  78. Layer.alert(data.msg);
  79. return;
  80. }
  81. }
  82. });
  83. });
  84. // Controller.api.bindevent();
  85. // Form.api.bindevent($("form[role=form]"), function(data, ret) {
  86. // if(ret.code==1){
  87. // Backend.api.addtabs( ret.url,'正在考试');
  88. // }
  89. // });
  90. },
  91. examing: function () {
  92. $(document).ready(function() {
  93. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  94. var display = $('#timer');
  95. var fenzhong = 0;
  96. var timer = setInterval(function() {
  97. var minutes = parseInt(countdownTime / 60, 10);
  98. var seconds = parseInt(countdownTime % 60, 10);
  99. minutes = minutes < 10 ? "0" + minutes : minutes;
  100. seconds = seconds < 10 ? "0" + seconds : seconds;
  101. display.text(minutes + "分" + seconds+'秒');
  102. // console.log(minutes.replace("0-",''));
  103. // console.log(parseInt(minutes.replace("0-",'')));
  104. if (--countdownTime < 0) {
  105. // clearInterval(timer);
  106. $(".djs").html('已到考试结束时间,10分钟内系统自动交卷。')
  107. // display.text("时间到!");
  108. }
  109. if(minutes<1){
  110. fenzhong = parseInt(minutes.replace("0-",''));
  111. console.log(fenzhong);
  112. if(fenzhong==7){
  113. $('#update-form').submit();
  114. clearInterval(timer);
  115. }
  116. }
  117. }, 1000);
  118. //五秒刷新,同步更换件列表数据
  119. if(Config.isloading==1 && countdownTime>0){
  120. setInterval(function() {
  121. window.location.reload();
  122. }, 30000);
  123. }
  124. });
  125. $(document).on('click', '.btn-replace', function () {
  126. console.log($(".other_replace").val());
  127. $.ajax({
  128. url: "student/collection/replace/ids/"+Config.ids,
  129. type: 'post',
  130. data: {
  131. other_replace: $(".other_replace").val(),
  132. other_report: $(".other_report").val(),
  133. },
  134. success: function (data) {
  135. if(data.code==1){
  136. window.location.reload();
  137. }
  138. if(data.code==0){
  139. Layer.alert(data.msg);
  140. }
  141. }
  142. });
  143. });
  144. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  145. //绑定动态下拉组件
  146. Form.events.selectpage(obj);
  147. });
  148. // Form.api.bindevent($("form[role=form]"), function (data, ret) {
  149. // Layer.alert(data.data);
  150. // });
  151. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  152. if(ret.code==1){
  153. // Backend.api.addtabs( ret.url,'得分分析');
  154. Backend.api.addtabs( ret.url);
  155. }
  156. });
  157. },
  158. analysis: function () {
  159. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  160. if(ret.code==1){
  161. Backend.api.addtabs( ret.url);
  162. }
  163. });
  164. },
  165. edit: function () {
  166. Controller.api.bindevent();
  167. },
  168. api: {
  169. bindevent: function () {
  170. Form.api.bindevent($("form[role=form]"));
  171. }
  172. }
  173. };
  174. return Controller;
  175. });