exam.js 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. columns: [
  22. [
  23. {checkbox: true},
  24. // {field: 'exam_id', title: __('Exam_id')},
  25. {field: 'exam_collection_name', title: __('考试名称')},
  26. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  27. {field: 'user_username', title: __('学员学号'),operate: false},
  28. {field: 'user_nickname', title: __('学员姓名'),operate: false},
  29. {
  30. field: 'user_depart_id',
  31. title: __('Department'),
  32. visible: false,
  33. addclass: 'selectpage',
  34. extend: 'data-source="department/index/index" data-field="name"',
  35. operate: Config.groupIds !=8 ? 'in':false,
  36. formatter: Table.api.formatter.search
  37. },
  38. {field: 'total_score', title: __('Total_score')},
  39. {field: 'starttime', title: __('Start_time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  40. {field: 'endtime', title: __('End_time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  41. ]
  42. ]
  43. });
  44. // 为表格绑定事件
  45. Table.api.bindevent(table);
  46. $(document).on('click', '.btn-view', function () {
  47. var ids = Table.api.selectedids(table);
  48. var title = '成绩详情';
  49. Fast.api.open(Fast.api.fixurl("student/exam/view/ids/"+ids), title, { area: ["60%", "95%"] });
  50. });
  51. },
  52. add: function () {
  53. Controller.api.bindevent();
  54. },
  55. edit: function () {
  56. Controller.api.bindevent();
  57. },
  58. api: {
  59. bindevent: function () {
  60. Form.api.bindevent($("form[role=form]"));
  61. }
  62. }
  63. };
  64. return Controller;
  65. });