exercise.js 6.6 KB

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