collection.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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/collection/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: 'limit_duration', title: __('Limit_duration')},
  28. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,},
  29. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  30. // {field: 'create_user_id', title: __('Create_user_id')},
  31. {field: 'create_by', title: __('Create_by'), operate: 'LIKE'},
  32. // {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  33. // {field: 'update_by', title: __('Update_by'), operate: 'LIKE'},
  34. // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  35. // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  37. {field: 'operate', title: __('Operate'), table: table,
  38. events: Table.api.events.operate,
  39. // formatter: Table.api.formatter.operate,
  40. formatter: Table.api.formatter.buttons,
  41. buttons: [
  42. {
  43. name: 'dispatch',
  44. text: '进入',
  45. icon: 'fa fa-hand-pointer-o',
  46. title: '进入',
  47. visible: function (row){
  48. if(row.is_user_examed==0){
  49. return true;
  50. }
  51. return false;
  52. },
  53. classname: 'btn btn-info btn-xs btn-magic btn-addtabs',
  54. extend: 'data-area=\'["85%","85%"]\'',
  55. url: 'student/collection/into',
  56. }
  57. ],
  58. }
  59. ]
  60. ]
  61. });
  62. // 为表格绑定事件
  63. Table.api.bindevent(table);
  64. },
  65. add: function () {
  66. Controller.api.bindevent();
  67. },
  68. into: function () {
  69. $(document).on('click', '.btn-startexam', function () {
  70. // var index = Layer.load(0, {shade: false}); //0代表加载的风格,支持0-2
  71. var index = Layer.load(2, {
  72. shade: [0.5,'#393D49'],
  73. content: '正在检查模拟器并下发故障,请稍后...', // 这里是加载的文字
  74. });
  75. $(this).removeClass('btn-info');
  76. $(this).addClass('btn-primary');
  77. if(Config.is_fault){
  78. $.ajax({
  79. ///sim/real-exam/student/exam/start/15?ip=192.168.1.110
  80. url: Config.url_type+"/sim/real-exam/student/exam/start/"+Config.exam_id+"?ip="+Config.server_ip,
  81. type: 'get',
  82. success: function (data) {
  83. console.log(data);
  84. if(data.code==200){
  85. window.location.href = '/admin/student/collection/examing/ids/'+Config.exam_id;
  86. }else{
  87. Layer.alert(data.msg);
  88. Layer.close(index);
  89. return;
  90. }
  91. }
  92. });
  93. }else{
  94. window.location.href = '/admin/student/collection/examing/ids/'+Config.exam_id;
  95. }
  96. });
  97. //刷新模拟器
  98. $(document).on('click', '.btn-refreshs', function () {
  99. var index = Layer.load(2, {
  100. shade: [0.5,'#393D49'],
  101. content: '正在刷新检查模拟器,请稍后...', // 这里是加载的文字
  102. });
  103. $(this).removeClass('btn-info');
  104. $(this).addClass('btn-primary');
  105. if(Config.is_fault){
  106. $.ajax({
  107. url: Config.url_type+"/sim/real-exam/student/refresh-sim-state?userId="+Config.user_id+"&ip="+Config.server_ip,
  108. type: 'get',
  109. success: function (data) {
  110. console.log(data);
  111. if(data.code==200 && data.data.simState==2){
  112. $(".kaiguan").css('display','block');
  113. }else{
  114. $(".kaiguan").css('display','none');
  115. }
  116. Layer.close(index);
  117. $(".mnq_zt").val(data.msg);
  118. }
  119. });
  120. }else{
  121. window.location.href='';
  122. }
  123. });
  124. if(Config.is_fault){
  125. var index = Layer.load(2, {
  126. shade: [0.5,'#393D49'],
  127. content: '正在刷新检查模拟器,请稍后...', // 这里是加载的文字
  128. });
  129. $.ajax({
  130. url: Config.url_type+"/sim/real-exam/student/refresh-sim-state?userId="+Config.user_id+"&ip="+Config.server_ip,
  131. type: 'get',
  132. success: function (data) {
  133. console.log(data);
  134. if(data.code==200 && data.data.simState==2){
  135. $(".kaiguan").css('display','block');
  136. }else{
  137. $(".kaiguan").css('display','none');
  138. }
  139. Layer.close(index);
  140. $(".mnq_zt").val(data.msg)
  141. }
  142. });
  143. }
  144. },
  145. examing: function () {
  146. var dingshi = '';
  147. $(document).ready(function() {
  148. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  149. var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
  150. var display = $('#timer');
  151. var fenzhong = 0;
  152. var timer = setInterval(function() {
  153. var minutes = parseInt(countdownTime / 60, 10);
  154. var seconds = parseInt(countdownTime % 60, 10);
  155. // minutes = minutes < 10 ? "0" + minutes : minutes;
  156. // seconds = seconds < 10 ? "0" + seconds : seconds;
  157. display.text(minutes + "分" + seconds+'秒');
  158. // console.log(minutes.replace("0-",''));
  159. // console.log(parseInt(minutes.replace("0-",'')));
  160. if (--countdownTime < 0) {
  161. // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
  162. $.ajax({
  163. url: "student/collection/countdown/ids/"+Config.ids,
  164. type: 'post',
  165. data: {},
  166. success: function (data) {
  167. if(data.code==1){
  168. console.log(data.msg);
  169. $(".djs").html(data.msg);
  170. if(data.msg==0){
  171. $('#update-form').submit();
  172. clearInterval(timer);
  173. }
  174. }
  175. if(data.code==0){
  176. Layer.alert(data.msg);
  177. }
  178. }
  179. });
  180. }
  181. }, 1000);
  182. //五秒刷新,同步更换件列表数据
  183. if(Config.isloading==1 && countdownTime>0){
  184. dingshi = setInterval(function() {
  185. window.location.reload();
  186. }, 30000);//30000
  187. }
  188. });
  189. $(document).on('click', '.btn-replace', function () {
  190. console.log($(".other_replace").val());
  191. if($(".other_replace").val()=='[{"fault_id":"","request_status":"0"}]'){
  192. Layer.alert('请先填写更换件');
  193. return false;
  194. }
  195. $.ajax({
  196. url: "student/collection/replace/ids/"+Config.ids,
  197. type: 'post',
  198. data: {
  199. other_replace: $(".other_replace").val(),
  200. other_report: $(".other_report").val(),
  201. },
  202. success: function (data) {
  203. if(data.code==1){
  204. Layer.alert(data.msg, {
  205. btn: ['确定'], // 或者直接使用默认的确定按钮
  206. yes: function(index, layero){
  207. // 刷新页面
  208. window.location.reload();
  209. }
  210. });
  211. }
  212. if(data.code==0){
  213. Layer.alert(data.msg);
  214. }
  215. }
  216. });
  217. });
  218. //追加记录
  219. $(document).on('click', '.btn-addlog', function () {
  220. clearTimeout(dingshi);
  221. var ids = Config.ids;
  222. var other_report_count = Config.other_report_count;
  223. if(other_report_count==3){
  224. Layer.alert('维修报告最多允许增加三条');
  225. return false;
  226. }
  227. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {
  228. area: ["95%", "85%"],
  229. callback:function(value){
  230. console.log(value+'@@@@');
  231. }
  232. });
  233. });
  234. //编辑记录
  235. $(document).on('click', '.btnedit', function () {
  236. clearTimeout(dingshi);
  237. var ids = Config.ids;
  238. var xh_id = $(this).attr('xh_id');
  239. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {
  240. area: ["95%", "85%"],
  241. callback:function(value){
  242. console.log(value+'@@@@');
  243. }
  244. });
  245. });
  246. //移除记录
  247. $(document).on('click', '.btnmove', function () {
  248. var ids = Config.ids;
  249. var xh_id = $(this).attr('xh_id');
  250. Layer.confirm(
  251. __('确定要移除此条记录吗?', ids.length),
  252. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  253. function (index) {
  254. var url = 'student/collection/delreport/ids/'+ids;
  255. options = {url: url, data: {xh_id: xh_id}};
  256. Fast.api.ajax(options, function (data, ret) {
  257. window.location.reload();
  258. }, function (data, ret) {
  259. var error = $(that).data("error") || $.noop;
  260. if (typeof error === 'function') {
  261. if (false === error.call(that, data, ret)) {
  262. return false;
  263. }
  264. }
  265. });
  266. Layer.close(index);
  267. }
  268. );
  269. });
  270. $(document).on('click', '.layui-layer-close1', function () {
  271. window.location.reload();
  272. });
  273. $(document).on('click', '.btn-jiaojuan', function () {
  274. // Layer.confirm(__('确定交卷?<br/>交卷后无法再修改维修报告和进行维修。'), {
  275. // icon: 3,
  276. // title: '提示'
  277. // }, function (index) {
  278. // Layer.close(index);
  279. // $("#update-form").submit();
  280. // });
  281. Layer.confirm(__('确定交卷?<br/>交卷后无法再修改维修报告和进行维修。'), {
  282. icon: 3,
  283. title: '提示'
  284. }, function (index) {
  285. if(Config.is_fault){
  286. Fast.api.ajax({
  287. url: Config.url_type+"/sim/real-exam/student/exam/submit/"+Config.exam_id+"?ip="+Config.server_ip,
  288. type: 'get',
  289. }, function (data) {
  290. console.log(data);
  291. if(data.code==200){
  292. $("#update-form").submit();
  293. }else{
  294. Layer.closeAll();
  295. Layer.alert(data.msg);
  296. }
  297. });
  298. }else{
  299. $("#update-form").submit();
  300. }
  301. });
  302. });
  303. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  304. //绑定动态下拉组件
  305. Form.events.selectpage(obj);
  306. });
  307. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  308. if(ret.code==1){
  309. Backend.api.addtabs( ret.url,'成绩管理');
  310. Backend.api.closetabs('/admin/student/collection/index');
  311. }
  312. });
  313. },
  314. addreport: function () {
  315. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  316. if(ret.code==1){
  317. parent.location.reload();
  318. }
  319. });
  320. },
  321. editreport: function () {
  322. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  323. if(ret.code==1){
  324. parent.location.reload();
  325. }
  326. });
  327. },
  328. delreport: function () {
  329. Controller.api.bindevent();
  330. },
  331. analysis: function () {
  332. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  333. if(ret.code==1){
  334. Backend.api.addtabs( ret.url);
  335. }
  336. });
  337. },
  338. edit: function () {
  339. Controller.api.bindevent();
  340. },
  341. api: {
  342. bindevent: function () {
  343. Form.api.bindevent($("form[role=form]"));
  344. }
  345. }
  346. };
  347. return Controller;
  348. });