exercise.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. // var index = Layer.load(2, {
  6. // shade: [0.5,'#393D49'],
  7. // content: '正在检查模拟器并下发故障,请稍后...', // 这里是加载的文字
  8. // });
  9. // Layer.close(index);
  10. // if(ret.code==1){
  11. // // Backend.api.addtabs( ret.url,'正在练习');
  12. // }
  13. // });
  14. $(document).on('click', '.btn-startexam', function () {
  15. var sim_type = $(".sim_type").val();
  16. if(!sim_type){
  17. Layer.alert('请先选择模拟器');
  18. return;
  19. }
  20. var index = Layer.load(2, {
  21. shade: [0.5,'#393D49'],
  22. content: '正在检查模拟器并下发故障,请稍后...', // 这里是加载的文字
  23. });
  24. $(this).removeClass('btn-info');
  25. $(this).addClass('btn-primary');
  26. $.ajax({
  27. url: "student/exercise/index",
  28. type: 'post',
  29. data: {
  30. sim_type: $(".sim_type").val(),
  31. },
  32. success: function (ret) {
  33. if(ret.code==1){
  34. window.location.href = ret.url;
  35. }else{
  36. Layer.alert(ret.msg);
  37. Layer.close(index);
  38. return;
  39. }
  40. }
  41. });
  42. });
  43. },
  44. examing: function () {
  45. var dingshi = '';
  46. $(document).ready(function() {
  47. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  48. var display = $('#timer');
  49. var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
  50. var timer = setInterval(function() {
  51. var minutes = parseInt(countdownTime / 60, 10);
  52. var seconds = parseInt(countdownTime % 60, 10);
  53. minutes = minutes < 10 ? "0" + minutes : minutes;
  54. seconds = seconds < 10 ? "0" + seconds : seconds;
  55. display.text(minutes + "分" + seconds+'秒');
  56. if (--countdownTime < 0) {
  57. $.ajax({
  58. url: "student/collection/countdown/ids/"+Config.ids,
  59. type: 'post',
  60. data: {},
  61. success: function (data) {
  62. if(data.code==1){
  63. console.log(data.msg);
  64. $(".djs").html(data.msg);
  65. if(data.msg==0){
  66. $('#update-form').submit();
  67. clearInterval(timer);
  68. }
  69. }
  70. if(data.code==0){
  71. Layer.alert(data.msg);
  72. }
  73. }
  74. });
  75. }
  76. }, 1000);
  77. //五秒刷新,同步更换件列表数据
  78. if(Config.isloading==1 && countdownTime>0){
  79. dingshi = setInterval(function() {
  80. window.location.reload();
  81. }, 30000);
  82. }
  83. });
  84. $(document).on('click', '.btn-replace', function () {
  85. console.log($(".other_replace").val());
  86. if($(".other_replace").val()=='[{"fault_id":"","request_status":"0"}]'){
  87. Layer.alert('请先填写更换件');
  88. return false;
  89. }
  90. $.ajax({
  91. url: "student/collection/replace/ids/"+Config.ids,
  92. type: 'post',
  93. data: {
  94. other_replace: $(".other_replace").val(),
  95. other_report: $(".other_report").val(),
  96. },
  97. success: function (data) {
  98. if(data.code==1){
  99. Layer.alert(data.msg, {
  100. btn: ['确定'], // 或者直接使用默认的确定按钮
  101. yes: function(index, layero){
  102. // 刷新页面
  103. window.location.reload();
  104. }
  105. });
  106. }
  107. if(data.code==0){
  108. Layer.alert(data.msg);
  109. }
  110. }
  111. });
  112. });
  113. //追加记录
  114. $(document).on('click', '.btn-addlog', function () {
  115. clearTimeout(dingshi);
  116. var ids = Config.ids;
  117. var other_report_count = Config.other_report_count;
  118. if(other_report_count==3){
  119. Layer.alert('维修报告最多允许增加三条');
  120. return false;
  121. }
  122. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {
  123. area: ["95%", "85%"],
  124. callback:function(value){
  125. console.log(value+'@@@@');
  126. }
  127. });
  128. });
  129. //编辑记录
  130. $(document).on('click', '.btnedit', function () {
  131. clearTimeout(dingshi);
  132. var ids = Config.ids;
  133. var xh_id = $(this).attr('xh_id');
  134. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {area: ["95%", "85%"],
  135. callback:function(value){
  136. console.log(value+'@@@@');
  137. }
  138. });
  139. });
  140. //移除记录
  141. $(document).on('click', '.btnmove', function () {
  142. var ids = Config.ids;
  143. var xh_id = $(this).attr('xh_id');
  144. Layer.confirm(
  145. __('确定要移除此条记录吗?', ids.length),
  146. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  147. function (index) {
  148. var url = 'student/collection/delreport/ids/'+ids;
  149. options = {url: url, data: {xh_id: xh_id}};
  150. Fast.api.ajax(options, function (data, ret) {
  151. window.location.reload();
  152. }, function (data, ret) {
  153. var error = $(that).data("error") || $.noop;
  154. if (typeof error === 'function') {
  155. if (false === error.call(that, data, ret)) {
  156. return false;
  157. }
  158. }
  159. });
  160. Layer.close(index);
  161. }
  162. );
  163. });
  164. $(document).on('click', '.layui-layer-close1', function () {
  165. window.location.reload();
  166. });
  167. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  168. //绑定动态下拉组件
  169. Form.events.selectpage(obj);
  170. });
  171. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  172. if(ret.code==1){
  173. Backend.api.addtabs( ret.url,'得分分析');
  174. }
  175. });
  176. },
  177. analysis: function () {
  178. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  179. if(ret.code==1){
  180. Backend.api.addtabs( ret.url);
  181. }
  182. });
  183. },
  184. edit: function () {
  185. Controller.api.bindevent();
  186. },
  187. api: {
  188. bindevent: function () {
  189. Form.api.bindevent($("form[role=form]"));
  190. }
  191. }
  192. };
  193. return Controller;
  194. });