university_course.js 3.6 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: 'university_course/index' + location.search,
  8. add_url: 'university_course/add',
  9. edit_url: 'university_course/edit',
  10. del_url: 'university_course/del',
  11. multi_url: 'university_course/multi',
  12. import_url: 'university_course/import',
  13. table: 'university_course',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. showToggle: false,// 禁用视图切换
  23. search:false,// 禁用默认搜索框
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  30. {field: 'weigh', title: __('Weigh'), operate: false},
  31. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"0":__('Status 0')}, formatter: Table.api.formatter.status},
  32. {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  33. {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  34. {
  35. field: 'operate',
  36. title: __('Operate'),
  37. table: table,
  38. events: Table.api.events.operate,
  39. formatter: Table.api.formatter.operate,
  40. buttons: [
  41. {
  42. name: 'chapter',
  43. text: '章节信息',
  44. title: '章节信息',
  45. originalTitle:'章节信息',
  46. classname: 'btn btn-xs btn-success btn-dialog btn-selectuser',
  47. // icon: 'fa fa-jpy',
  48. url: 'university_course_chapter/index/course_id/{id}?dialog=1',
  49. callback: function (data) {
  50. Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  51. }
  52. }
  53. ]
  54. }
  55. ]
  56. ]
  57. });
  58. // 为表格绑定事件
  59. Table.api.bindevent(table);
  60. },
  61. add: function () {
  62. Controller.api.bindevent();
  63. },
  64. edit: function () {
  65. Controller.api.bindevent();
  66. },
  67. api: {
  68. bindevent: function () {
  69. Form.api.bindevent($("form[role=form]"));
  70. }
  71. }
  72. };
  73. return Controller;
  74. });