exam.js 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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/exam/index' + location.search,
  8. table: 'teacher_exams',
  9. }
  10. });
  11. var table = $("#table");
  12. // 初始化表格
  13. table.bootstrapTable({
  14. url: $.fn.bootstrapTable.defaults.extend.index_url,
  15. pk: 'exam_id',
  16. sortName: 'exam_id',
  17. fixedColumns: true,
  18. fixedRightNumber: 1,
  19. searchFormVisible:true,
  20. singleSelect : true,
  21. search:false,
  22. showExport:false,
  23. showToggle:false,
  24. showColumns: false,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. // {field: 'exam_id', title: __('Exam_id')},
  29. {field: 'exam_collection_name', title: __('考试名称'),operate: 'like'},
  30. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  31. {field: 'user_username', title: __('学员账号'),operate: false},
  32. {field: 'user_nickname', title: __('学员姓名'),operate: false},
  33. {
  34. field: 'user_depart_id',
  35. title: __('Department'),
  36. visible: false,
  37. addclass: 'selectpage',
  38. extend: 'data-source="department/index/index" data-field="name"',
  39. operate: Config.groupIds !=8 ? 'in':false,
  40. formatter: Table.api.formatter.search
  41. },
  42. {field: 'total_score', title: __('Total_score'),
  43. formatter: function(value, row,index) {
  44. if(value<60){
  45. return '<span class="text-danger">'+value+'</span>';
  46. }else{
  47. return '<span class="text-success">'+value+'</span>';
  48. }
  49. }
  50. },
  51. {field: 'starttime', title: __('Start_time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  52. {field: 'endtime', title: __('End_time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  53. ]
  54. ]
  55. });
  56. // 为表格绑定事件
  57. Table.api.bindevent(table);
  58. $(document).on('click', '.btn-view', function () {
  59. var ids = Table.api.selectedids(table);
  60. var title = '成绩详情';
  61. Fast.api.open(Fast.api.fixurl("student/exam/view/ids/"+ids), title, { area: ["75%", "95%"] });
  62. });
  63. },
  64. add: function () {
  65. Controller.api.bindevent();
  66. },
  67. edit: function () {
  68. Controller.api.bindevent();
  69. },
  70. api: {
  71. bindevent: function () {
  72. Form.api.bindevent($("form[role=form]"));
  73. }
  74. }
  75. };
  76. return Controller;
  77. });