exercise.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  5. if(ret.code==1){
  6. Backend.api.addtabs( ret.url,'正在练习');
  7. }
  8. });
  9. },
  10. examing: function () {
  11. $(document).ready(function() {
  12. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  13. var display = $('#timer');
  14. var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
  15. var timer = setInterval(function() {
  16. var minutes = parseInt(countdownTime / 60, 10);
  17. var seconds = parseInt(countdownTime % 60, 10);
  18. minutes = minutes < 10 ? "0" + minutes : minutes;
  19. seconds = seconds < 10 ? "0" + seconds : seconds;
  20. display.text(minutes + "分" + seconds+'秒');
  21. if (--countdownTime < 0) {
  22. $.ajax({
  23. url: "student/collection/countdown/ids/"+Config.ids,
  24. type: 'post',
  25. data: {},
  26. success: function (data) {
  27. if(data.code==1){
  28. console.log(data.msg);
  29. $(".djs").html(data.msg);
  30. if(data.msg==0){
  31. $('#update-form').submit();
  32. clearInterval(timer);
  33. }
  34. }
  35. if(data.code==0){
  36. Layer.alert(data.msg);
  37. }
  38. }
  39. });
  40. // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
  41. // setTimeout(function() {
  42. // var minutes1 = parseInt(countdownTime1 / 60, 10);
  43. // var seconds1 = parseInt(countdownTime1 % 60, 10);
  44. // $(".djs").html('已经超时,'+minutes1 + "分" + seconds1 +'秒后系统自动交卷。');
  45. // if (--countdownTime1>0) {
  46. // var minutes2 = parseInt(countdownTime1 / 60, 10);
  47. // var seconds2 = parseInt(countdownTime1 % 60, 10);
  48. // $(".djs").html('已经超时,'+minutes2 + "分" + seconds2 +'秒后系统自动交卷。');
  49. // console.log(minutes2+'@@@@'+seconds2);
  50. // if(minutes2==0 && seconds2==1){
  51. // $('#update-form').submit();
  52. // clearInterval(timer);
  53. // }
  54. // }
  55. // }, 1000); // 第二个定时器2秒后执行
  56. }
  57. }, 1000);
  58. //五秒刷新,同步更换件列表数据
  59. if(Config.isloading==1 && countdownTime>0){
  60. setInterval(function() {
  61. window.location.reload();
  62. }, 30000);
  63. }
  64. });
  65. $(document).on('click', '.btn-replace', function () {
  66. console.log($(".other_replace").val());
  67. if($(".other_replace").val()=='[{"fault_id":"","request_status":"0"}]'){
  68. Layer.alert('请先填写更换件');
  69. return false;
  70. }
  71. $.ajax({
  72. url: "student/collection/replace/ids/"+Config.ids,
  73. type: 'post',
  74. data: {
  75. other_replace: $(".other_replace").val(),
  76. other_report: $(".other_report").val(),
  77. },
  78. success: function (data) {
  79. if(data.code==1){
  80. window.location.reload();
  81. }
  82. if(data.code==0){
  83. Layer.alert(data.msg);
  84. }
  85. }
  86. });
  87. });
  88. //追加记录
  89. $(document).on('click', '.btn-addlog', function () {
  90. var ids = Config.ids;
  91. var other_report_count = Config.other_report_count;
  92. if(other_report_count==3){
  93. Layer.alert('维修报告最多允许增加三条');
  94. return false;
  95. }
  96. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {area: ["95%", "85%"], maxmin: true, moveOut: false});
  97. });
  98. //编辑记录
  99. $(document).on('click', '.btnedit', function () {
  100. var ids = Config.ids;
  101. var xh_id = $(this).attr('xh_id');
  102. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {area: ["95%", "85%"], maxmin: true, moveOut: false});
  103. });
  104. //移除记录
  105. $(document).on('click', '.btnmove', function () {
  106. var ids = Config.ids;
  107. var xh_id = $(this).attr('xh_id');
  108. Layer.confirm(
  109. __('确定要移除此条记录吗?', ids.length),
  110. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  111. function (index) {
  112. var url = 'student/collection/delreport/ids/'+ids;
  113. options = {url: url, data: {xh_id: xh_id}};
  114. Fast.api.ajax(options, function (data, ret) {
  115. window.location.reload();
  116. }, function (data, ret) {
  117. var error = $(that).data("error") || $.noop;
  118. if (typeof error === 'function') {
  119. if (false === error.call(that, data, ret)) {
  120. return false;
  121. }
  122. }
  123. });
  124. Layer.close(index);
  125. }
  126. );
  127. });
  128. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  129. //绑定动态下拉组件
  130. Form.events.selectpage(obj);
  131. });
  132. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  133. if(ret.code==1){
  134. Backend.api.addtabs( ret.url,'得分分析');
  135. }
  136. });
  137. },
  138. analysis: function () {
  139. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  140. if(ret.code==1){
  141. Backend.api.addtabs( ret.url);
  142. }
  143. });
  144. },
  145. edit: function () {
  146. Controller.api.bindevent();
  147. },
  148. api: {
  149. bindevent: function () {
  150. Form.api.bindevent($("form[role=form]"));
  151. }
  152. }
  153. };
  154. return Controller;
  155. });