practice.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'student/practice/index' + location.search,
  8. table: 'teacher_collection',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'exam_collection_id',
  16. sortName: 'exam_collection_id',
  17. fixedColumns: true,
  18. fixedRightNumber: 1,
  19. searchFormVisible:true,
  20. columns: [
  21. [
  22. {checkbox: true},
  23. {field: 'exam_collection_id', title: __('编号')},
  24. {field: 'exam_collection_name', title: __('Exam_collection_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  25. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  26. {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
  27. // {field: 'exam_collection_type', title: __('Exam_collection_type'),operate: false,formatter: function (value, row, index) {
  28. // return '考试';
  29. // }
  30. // },
  31. // {
  32. // field: 'exam_collection_state',searchList:{"2":"打开","3":"关闭"},
  33. // title: __('Exam_collection_state'),
  34. // align: 'center',
  35. // table: table,disable:true,
  36. // formatter: Table.api.formatter.collectonstate
  37. // },
  38. {field: 'limit_duration', title: __('Limit_duration')},
  39. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  40. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  41. // {field: 'create_user_id', title: __('Create_user_id')},
  42. {field: 'create_by', title: __('Create_by'), operate: 'LIKE'},
  43. // {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  44. // {field: 'update_by', title: __('Update_by'), operate: 'LIKE'},
  45. // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  46. // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  47. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  48. {field: 'operate', title: __('Operate'), table: table,
  49. events: Table.api.events.operate,
  50. // formatter: Table.api.formatter.operate,
  51. formatter: Table.api.formatter.buttons,
  52. buttons: [
  53. {
  54. name: 'dispatch',
  55. text: '进入',
  56. icon: 'fa fa-hand-pointer-o',
  57. title: '进入',
  58. // visible: function (row){
  59. // if(row.is_user_examed==0){
  60. // return true;
  61. // }
  62. // return false;
  63. // },
  64. classname: 'btn btn-info btn-xs btn-magic btn-addtabs',
  65. extend: 'data-area=\'["85%","85%"]\'',
  66. url: 'student/practice/into',
  67. }
  68. ],
  69. }
  70. ]
  71. ]
  72. });
  73. // 为表格绑定事件
  74. Table.api.bindevent(table);
  75. },
  76. add: function () {
  77. Controller.api.bindevent();
  78. },
  79. into: function () {
  80. // Controller.api.bindevent();
  81. // Form.api.bindevent($("form[role=form]"), function(data, ret) {
  82. // if(ret.code==1){
  83. // Backend.api.addtabs( ret.url,'正在练习');
  84. // }
  85. // });
  86. $(document).on('click', '.btn-startexam', function () {
  87. var index = Layer.load(2, {
  88. shade: [0.5,'#393D49'],
  89. content: '正在检查模拟器并下发故障,请稍后...', // 这里是加载的文字
  90. });
  91. $(this).removeClass('btn-info');
  92. $(this).addClass('btn-primary');
  93. if(Config.is_fault){
  94. $.ajax({
  95. url: Config.url_type+"/sim/real-exam/student/exercise/start/"+Config.exam_id,
  96. type: 'get',
  97. success: function (data) {
  98. console.log(data);
  99. if(data.code==200){
  100. window.location.href = '/admin/student/practice/examing/ids/'+Config.exam_id;
  101. }else{
  102. Layer.alert(data.msg);
  103. Layer.close(index);
  104. return;
  105. }
  106. }
  107. });
  108. }else{
  109. window.location.href = '/admin/student/practice/examing/ids/'+Config.exam_id;
  110. }
  111. });
  112. },
  113. examing: function () {
  114. $(document).ready(function() {
  115. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  116. var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
  117. var display = $('#timer');
  118. var fenzhong = 0;
  119. var timer = setInterval(function() {
  120. var minutes = parseInt(countdownTime / 60, 10);
  121. var seconds = parseInt(countdownTime % 60, 10);
  122. // minutes = minutes < 10 ? "0" + minutes : minutes;
  123. // seconds = seconds < 10 ? "0" + seconds : seconds;
  124. display.text(minutes + "分" + seconds+'秒');
  125. // console.log(minutes.replace("0-",''));
  126. // console.log(parseInt(minutes.replace("0-",'')));
  127. if (--countdownTime < 0) {
  128. $.ajax({
  129. url: "student/collection/countdown/ids/"+Config.ids,
  130. type: 'post',
  131. data: {},
  132. success: function (data) {
  133. if(data.code==1){
  134. console.log(data.msg);
  135. $(".djs").html(data.msg);
  136. if(data.msg==0){
  137. $('#update-form').submit();
  138. clearInterval(timer);
  139. }
  140. }
  141. if(data.code==0){
  142. Layer.alert(data.msg);
  143. }
  144. }
  145. });
  146. // clearInterval(timer);
  147. // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
  148. // setTimeout(function() {
  149. // var minutes1 = parseInt(countdownTime1 / 60, 10);
  150. // var seconds1 = parseInt(countdownTime1 % 60, 10);
  151. // $(".djs").html('已经超时,'+minutes1 + "分" + seconds1 +'秒后系统自动交卷。');
  152. // if (--countdownTime1>0) {
  153. // var minutes2 = parseInt(countdownTime1 / 60, 10);
  154. // var seconds2 = parseInt(countdownTime1 % 60, 10);
  155. // $(".djs").html('已经超时,'+minutes2 + "分" + seconds2 +'秒后系统自动交卷。');
  156. // console.log(minutes2+'@@@@'+seconds2);
  157. // if(minutes2==0 && seconds2==1){
  158. // $('#update-form').submit();
  159. // clearInterval(timer);
  160. // }
  161. // }
  162. // }, 1000); // 第二个定时器2秒后执行
  163. }
  164. // if(minutes<1){
  165. // fenzhong = parseInt(minutes.replace("0-",''));
  166. // console.log(fenzhong);
  167. // if(fenzhong==7){
  168. // $('#update-form').submit();
  169. // clearInterval(timer);
  170. // }
  171. // }
  172. }, 1000);
  173. //五秒刷新,同步更换件列表数据
  174. if(Config.isloading==1 && countdownTime>0){
  175. setInterval(function() {
  176. window.location.reload();
  177. }, 30000);
  178. }
  179. });
  180. $(document).on('click', '.btn-replace', function () {
  181. console.log($(".other_replace").val());
  182. if($(".other_replace").val()=='[{"fault_id":"","request_status":"0"}]'){
  183. Layer.alert('请先填写更换件');
  184. return false;
  185. }
  186. $.ajax({
  187. url: "student/collection/replace/ids/"+Config.ids,
  188. type: 'post',
  189. data: {
  190. other_replace: $(".other_replace").val(),
  191. other_report: $(".other_report").val(),
  192. },
  193. success: function (data) {
  194. if(data.code==1){
  195. window.location.reload();
  196. }
  197. if(data.code==0){
  198. Layer.alert(data.msg);
  199. }
  200. }
  201. });
  202. });
  203. //追加记录
  204. $(document).on('click', '.btn-addlog', function () {
  205. var ids = Config.ids;
  206. var other_report_count = Config.other_report_count;
  207. if(other_report_count==3){
  208. Layer.alert('维修报告最多允许增加三条');
  209. return false;
  210. }
  211. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {area: ["95%", "85%"], maxmin: true, moveOut: false});
  212. });
  213. //编辑记录
  214. $(document).on('click', '.btnedit', function () {
  215. var ids = Config.ids;
  216. var xh_id = $(this).attr('xh_id');
  217. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {area: ["95%", "85%"], maxmin: true, moveOut: false});
  218. });
  219. //移除记录
  220. $(document).on('click', '.btnmove', function () {
  221. var ids = Config.ids;
  222. var xh_id = $(this).attr('xh_id');
  223. Layer.confirm(
  224. __('确定要移除此条记录吗?', ids.length),
  225. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  226. function (index) {
  227. var url = 'student/collection/delreport/ids/'+ids;
  228. options = {url: url, data: {xh_id: xh_id}};
  229. Fast.api.ajax(options, function (data, ret) {
  230. window.location.reload();
  231. }, function (data, ret) {
  232. var error = $(that).data("error") || $.noop;
  233. if (typeof error === 'function') {
  234. if (false === error.call(that, data, ret)) {
  235. return false;
  236. }
  237. }
  238. });
  239. Layer.close(index);
  240. }
  241. );
  242. });
  243. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  244. //绑定动态下拉组件
  245. Form.events.selectpage(obj);
  246. });
  247. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  248. if(ret.code==1){
  249. Backend.api.addtabs( ret.url,'得分分析');
  250. Backend.api.closetabs('/admin/student/practice/index');
  251. }
  252. });
  253. },
  254. analysis: function () {
  255. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  256. if(ret.code==1){
  257. Backend.api.addtabs( ret.url);
  258. parent.window.reload();
  259. }
  260. });
  261. },
  262. edit: function () {
  263. Controller.api.bindevent();
  264. },
  265. api: {
  266. bindevent: function () {
  267. Form.api.bindevent($("form[role=form]"));
  268. }
  269. }
  270. };
  271. return Controller;
  272. });