collection.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. url: Config.url_type+"/sim/real-exam/student/exam/start/"+Config.exam_id,
  80. type: 'get',
  81. success: function (data) {
  82. console.log(data);
  83. if(data.code==200){
  84. window.location.href = '/admin/student/collection/examing/ids/'+Config.exam_id;
  85. }else{
  86. Layer.alert(data.msg);
  87. Layer.close(index);
  88. return;
  89. }
  90. }
  91. });
  92. }else{
  93. window.location.href = '/admin/student/collection/examing/ids/'+Config.exam_id;
  94. }
  95. });
  96. },
  97. examing: function () {
  98. var dingshi = '';
  99. $(document).ready(function() {
  100. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  101. var countdownTime1 = 600; // 10分钟倒计时时间,单位为秒
  102. var display = $('#timer');
  103. var fenzhong = 0;
  104. var timer = setInterval(function() {
  105. var minutes = parseInt(countdownTime / 60, 10);
  106. var seconds = parseInt(countdownTime % 60, 10);
  107. // minutes = minutes < 10 ? "0" + minutes : minutes;
  108. // seconds = seconds < 10 ? "0" + seconds : seconds;
  109. display.text(minutes + "分" + seconds+'秒');
  110. // console.log(minutes.replace("0-",''));
  111. // console.log(parseInt(minutes.replace("0-",'')));
  112. if (--countdownTime < 0) {
  113. // $(".djs").html('已经超时,10分钟00秒后系统自动交卷。');
  114. $.ajax({
  115. url: "student/collection/countdown/ids/"+Config.ids,
  116. type: 'post',
  117. data: {},
  118. success: function (data) {
  119. if(data.code==1){
  120. console.log(data.msg);
  121. $(".djs").html(data.msg);
  122. if(data.msg==0){
  123. $('#update-form').submit();
  124. clearInterval(timer);
  125. }
  126. }
  127. if(data.code==0){
  128. Layer.alert(data.msg);
  129. }
  130. }
  131. });
  132. }
  133. }, 1000);
  134. //五秒刷新,同步更换件列表数据
  135. if(Config.isloading==1 && countdownTime>0){
  136. dingshi = setInterval(function() {
  137. window.location.reload();
  138. }, 30000);//30000
  139. }
  140. });
  141. $(document).on('click', '.btn-replace', function () {
  142. console.log($(".other_replace").val());
  143. if($(".other_replace").val()=='[{"fault_id":"","request_status":"0"}]'){
  144. Layer.alert('请先填写更换件');
  145. return false;
  146. }
  147. $.ajax({
  148. url: "student/collection/replace/ids/"+Config.ids,
  149. type: 'post',
  150. data: {
  151. other_replace: $(".other_replace").val(),
  152. other_report: $(".other_report").val(),
  153. },
  154. success: function (data) {
  155. if(data.code==1){
  156. Layer.alert(data.msg, {
  157. btn: ['确定'], // 或者直接使用默认的确定按钮
  158. yes: function(index, layero){
  159. // 刷新页面
  160. window.location.reload();
  161. }
  162. });
  163. }
  164. if(data.code==0){
  165. Layer.alert(data.msg);
  166. }
  167. }
  168. });
  169. });
  170. //追加记录
  171. $(document).on('click', '.btn-addlog', function () {
  172. clearTimeout(dingshi);
  173. var ids = Config.ids;
  174. var other_report_count = Config.other_report_count;
  175. if(other_report_count==3){
  176. Layer.alert('维修报告最多允许增加三条');
  177. return false;
  178. }
  179. Fast.api.open('student/collection/addreport/ids/'+ids, __("维修报告"), {
  180. area: ["95%", "85%"],
  181. callback:function(value){
  182. console.log(value+'@@@@');
  183. }
  184. });
  185. });
  186. //编辑记录
  187. $(document).on('click', '.btnedit', function () {
  188. clearTimeout(dingshi);
  189. var ids = Config.ids;
  190. var xh_id = $(this).attr('xh_id');
  191. Fast.api.open('student/collection/editreport/ids/'+ids+'/xh_id/'+xh_id, __("维修报告"), {
  192. area: ["95%", "85%"],
  193. callback:function(value){
  194. console.log(value+'@@@@');
  195. }
  196. });
  197. });
  198. //移除记录
  199. $(document).on('click', '.btnmove', function () {
  200. var ids = Config.ids;
  201. var xh_id = $(this).attr('xh_id');
  202. Layer.confirm(
  203. __('确定要移除此条记录吗?', ids.length),
  204. {icon:3, title: __('Warning'), shadeClose: true, btn: [__('OK'), __('Cancel')]},
  205. function (index) {
  206. var url = 'student/collection/delreport/ids/'+ids;
  207. options = {url: url, data: {xh_id: xh_id}};
  208. Fast.api.ajax(options, function (data, ret) {
  209. window.location.reload();
  210. }, function (data, ret) {
  211. var error = $(that).data("error") || $.noop;
  212. if (typeof error === 'function') {
  213. if (false === error.call(that, data, ret)) {
  214. return false;
  215. }
  216. }
  217. });
  218. Layer.close(index);
  219. }
  220. );
  221. });
  222. $(document).on('click', '.layui-layer-close1', function () {
  223. window.location.reload();
  224. });
  225. $(document).on("fa.event.appendfieldlist", "#second-fieldlist .btn-append", function (e, obj) {
  226. //绑定动态下拉组件
  227. Form.events.selectpage(obj);
  228. });
  229. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  230. if(ret.code==1){
  231. Backend.api.addtabs( ret.url,'成绩管理');
  232. Backend.api.closetabs('/admin/student/collection/index');
  233. }
  234. });
  235. },
  236. addreport: function () {
  237. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  238. if(ret.code==1){
  239. parent.location.reload();
  240. }
  241. });
  242. },
  243. editreport: function () {
  244. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  245. if(ret.code==1){
  246. parent.location.reload();
  247. }
  248. });
  249. },
  250. delreport: function () {
  251. Controller.api.bindevent();
  252. },
  253. analysis: function () {
  254. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  255. if(ret.code==1){
  256. Backend.api.addtabs( ret.url);
  257. }
  258. });
  259. },
  260. edit: function () {
  261. Controller.api.bindevent();
  262. },
  263. api: {
  264. bindevent: function () {
  265. Form.api.bindevent($("form[role=form]"));
  266. }
  267. }
  268. };
  269. return Controller;
  270. });