collection.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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: '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. classname: 'btn btn-info btn-xs btn-magic btn-addtabs',
  59. extend: 'data-area=\'["85%","85%"]\'',
  60. url: 'student/collection/into',
  61. }
  62. ],
  63. }
  64. ]
  65. ]
  66. });
  67. // 为表格绑定事件
  68. Table.api.bindevent(table);
  69. },
  70. add: function () {
  71. Controller.api.bindevent();
  72. },
  73. into: function () {
  74. // Controller.api.bindevent();
  75. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  76. if(ret.code==1){
  77. Backend.api.addtabs( ret.url,'正在考试');
  78. }
  79. });
  80. },
  81. examing: function () {
  82. $(document).ready(function() {
  83. var countdownTime = Config.timer; // 倒计时时间,单位为秒
  84. var display = $('#timer');
  85. var timer = setInterval(function() {
  86. var minutes = parseInt(countdownTime / 60, 10);
  87. var seconds = parseInt(countdownTime % 60, 10);
  88. minutes = minutes < 10 ? "0" + minutes : minutes;
  89. seconds = seconds < 10 ? "0" + seconds : seconds;
  90. display.text(minutes + "分" + seconds+'秒');
  91. if (--countdownTime < 0) {
  92. clearInterval(timer);
  93. display.text("时间到!");
  94. }
  95. }, 1000);
  96. });
  97. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  98. if(ret.code==1){
  99. Backend.api.addtabs( ret.url,'得分分析');
  100. }
  101. });
  102. },
  103. analysis: function () {
  104. Form.api.bindevent($("form[role=form]"), function(data, ret) {
  105. if(ret.code==1){
  106. Backend.api.addtabs( ret.url);
  107. }
  108. });
  109. },
  110. edit: function () {
  111. Controller.api.bindevent();
  112. },
  113. api: {
  114. bindevent: function () {
  115. Form.api.bindevent($("form[role=form]"));
  116. }
  117. }
  118. };
  119. return Controller;
  120. });