exercise.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 timer = setInterval(function() {
  15. var minutes = parseInt(countdownTime / 60, 10);
  16. var seconds = parseInt(countdownTime % 60, 10);
  17. minutes = minutes < 10 ? "0" + minutes : minutes;
  18. seconds = seconds < 10 ? "0" + seconds : seconds;
  19. display.text(minutes + "分" + seconds+'秒');
  20. if (--countdownTime < 0) {
  21. clearInterval(timer);
  22. display.text("时间到!");
  23. }
  24. }, 1000);
  25. });
  26. $(document).on('click', '.btn-replace', function () {
  27. console.log($(".other_replace").val());
  28. if($(".other_replace").val()=='[{"fault_id":"","request_status":"0"}]'){
  29. Layer.alert('请先填写更换件');
  30. return false;
  31. }
  32. $.ajax({
  33. url: "student/collection/replace/ids/"+Config.ids,
  34. type: 'post',
  35. data: {
  36. other_replace: $(".other_replace").val(),
  37. other_report: $(".other_report").val(),
  38. },
  39. success: function (data) {
  40. if(data.code==1){
  41. window.location.reload();
  42. }
  43. if(data.code==0){
  44. Layer.alert(data.msg);
  45. }
  46. }
  47. });
  48. });
  49. //追加记录
  50. $(document).on('click', '.btn-addlog', function () {
  51. var ids = Config.ids;
  52. var other_report_count = Config.other_report_count;
  53. if(other_report_count==3){
  54. Layer.alert('维修报告最多允许增加三条');
  55. return false;
  56. }
  57. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {area: ["95%", "85%"], maxmin: true, moveOut: false});
  58. });
  59. //编辑记录
  60. $(document).on('click', '.btnedit', function () {
  61. var ids = Config.ids;
  62. var xh_id = $(this).attr('xh_id');
  63. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {area: ["95%", "85%"], maxmin: true, moveOut: false});
  64. });
  65. //移除记录
  66. $(document).on('click', '.btnmove', function () {
  67. var ids = Config.ids;
  68. var xh_id = $(this).attr('xh_id');
  69. Layer.confirm(
  70. __('确定要移除此条记录吗?', ids.length),
  71. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  72. function (index) {
  73. var url = 'student/collection/delreport/ids/'+ids;
  74. options = {url: url, data: {xh_id: xh_id}};
  75. Fast.api.ajax(options, function (data, ret) {
  76. window.location.reload();
  77. }, function (data, ret) {
  78. var error = $(that).data("error") || $.noop;
  79. if (typeof error === 'function') {
  80. if (false === error.call(that, data, ret)) {
  81. return false;
  82. }
  83. }
  84. });
  85. Layer.close(index);
  86. }
  87. );
  88. });
  89. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  90. //绑定动态下拉组件
  91. Form.events.selectpage(obj);
  92. });
  93. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  94. if(ret.code==1){
  95. Backend.api.addtabs( ret.url,'得分分析');
  96. }
  97. });
  98. },
  99. analysis: function () {
  100. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  101. if(ret.code==1){
  102. Backend.api.addtabs( ret.url);
  103. }
  104. });
  105. },
  106. edit: function () {
  107. Controller.api.bindevent();
  108. },
  109. api: {
  110. bindevent: function () {
  111. Form.api.bindevent($("form[role=form]"));
  112. }
  113. }
  114. };
  115. return Controller;
  116. });