exercise.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. }, 2000);
  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. window.location.reload();
  100. }
  101. if(data.code==0){
  102. Layer.alert(data.msg);
  103. }
  104. }
  105. });
  106. });
  107. //追加记录
  108. $(document).on('click', '.btn-addlog', function () {
  109. clearTimeout(dingshi);
  110. var ids = Config.ids;
  111. var other_report_count = Config.other_report_count;
  112. if(other_report_count==3){
  113. Layer.alert('维修报告最多允许增加三条');
  114. return false;
  115. }
  116. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {
  117. area: ["95%", "85%"],
  118. callback:function(value){
  119. console.log(value+'@@@@');
  120. }
  121. });
  122. });
  123. //编辑记录
  124. $(document).on('click', '.btnedit', function () {
  125. clearTimeout(dingshi);
  126. var ids = Config.ids;
  127. var xh_id = $(this).attr('xh_id');
  128. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {area: ["95%", "85%"],
  129. callback:function(value){
  130. console.log(value+'@@@@');
  131. }
  132. });
  133. });
  134. //移除记录
  135. $(document).on('click', '.btnmove', function () {
  136. var ids = Config.ids;
  137. var xh_id = $(this).attr('xh_id');
  138. Layer.confirm(
  139. __('确定要移除此条记录吗?', ids.length),
  140. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  141. function (index) {
  142. var url = 'student/collection/delreport/ids/'+ids;
  143. options = {url: url, data: {xh_id: xh_id}};
  144. Fast.api.ajax(options, function (data, ret) {
  145. window.location.reload();
  146. }, function (data, ret) {
  147. var error = $(that).data("error") || $.noop;
  148. if (typeof error === 'function') {
  149. if (false === error.call(that, data, ret)) {
  150. return false;
  151. }
  152. }
  153. });
  154. Layer.close(index);
  155. }
  156. );
  157. });
  158. $(document).on('click', '.layui-layer-close1', function () {
  159. window.location.reload();
  160. });
  161. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  162. //绑定动态下拉组件
  163. Form.events.selectpage(obj);
  164. });
  165. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  166. if(ret.code==1){
  167. Backend.api.addtabs( ret.url,'得分分析');
  168. }
  169. });
  170. },
  171. analysis: function () {
  172. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  173. if(ret.code==1){
  174. Backend.api.addtabs( ret.url);
  175. }
  176. });
  177. },
  178. edit: function () {
  179. Controller.api.bindevent();
  180. },
  181. api: {
  182. bindevent: function () {
  183. Form.api.bindevent($("form[role=form]"));
  184. }
  185. }
  186. };
  187. return Controller;
  188. });