collection.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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: 'teacher/collection/index' + location.search,
  8. add_url: 'teacher/collection/add',
  9. edit_url: 'teacher/collection/edit',
  10. del_url: 'teacher/collection/del',
  11. multi_url: 'teacher/collection/multi',
  12. import_url: 'teacher/collection/import',
  13. table: 'teacher_collection',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'exam_collection_id',
  21. sortName: 'exam_collection_id',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. searchFormVisible:true,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field: 'exam_collection_id', title: __('编号')},
  29. {field: 'exam_collection_name', title: __('Exam_collection_name'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  30. {field: 'sim_type', title: __('Sim_type'),searchList:{"0001":"FZD04B型侦毒器","0002":"FZB006型毒剂报警器","0003":"防化兵用毒剂报警器"},formatter: Table.api.formatter.simtype},
  31. {field: 'question_setting_method', title: __('Question_setting_method'),searchList:{"1":"系统随机","2":"教师自选","3":"任务自选"},formatter: Table.api.formatter.simmethod},
  32. {field: 'exam_collection_type', title: __('Exam_collection_type'),operate: false,formatter: function (value, row, index) {
  33. return '考试';
  34. }
  35. },
  36. {
  37. field: 'exam_collection_state',searchList:{"2":"打开","3":"关闭"},
  38. title: __('Exam_collection_state'),
  39. align: 'center',
  40. table: table,
  41. formatter: Table.api.formatter.collectonstate
  42. },
  43. // {field: 'task_id', title: __('Task_id')},
  44. {field: 'limit_duration', title: __('Limit_duration')},
  45. {field: 'start_time', title: __('Start_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  46. {field: 'end_time', title: __('End_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  47. // {field: 'create_user_id', title: __('Create_user_id')},
  48. {field: 'create_by', title: __('Create_by'), operate: 'LIKE'},
  49. {field: 'createtime', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  50. // {field: 'update_by', title: __('Update_by'), operate: 'LIKE'},
  51. // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
  52. // {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  53. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  54. ]
  55. ]
  56. });
  57. // 为表格绑定事件
  58. Table.api.bindevent(table);
  59. },
  60. add: function () {
  61. Controller.api.bindevent();
  62. },
  63. edit: function () {
  64. Controller.api.bindevent();
  65. },
  66. api: {
  67. bindevent: function () {
  68. Form.api.bindevent($("form[role=form]"));
  69. }
  70. }
  71. };
  72. return Controller;
  73. });