notice.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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: 'exam/notice/index' + location.search,
  8. add_url: 'exam/notice/add',
  9. edit_url: 'exam/notice/edit',
  10. del_url: 'exam/notice/del',
  11. multi_url: 'exam/notice/multi',
  12. import_url: 'exam/notice/import',
  13. table: 'exam_notice',
  14. }
  15. });
  16. var table = $("#table");
  17. //当内容渲染完成给编辑按钮添加`data-area`属性,点击列表编辑按钮时全屏
  18. table.on('post-body.bs.table', function (e, settings, json, xhr) {
  19. $(".btn-add").data("area", ["80%", "80%"]);
  20. $(".btn-editone").data("area", ["80%", "80%"]);
  21. });
  22. // 初始化表格
  23. table.bootstrapTable({
  24. url: $.fn.bootstrapTable.defaults.extend.index_url,
  25. pk: 'id',
  26. sortName: 'weigh',
  27. columns: [
  28. [
  29. {checkbox: true},
  30. {field: 'id', title: __('Id')},
  31. {field: 'name', title: __('Name'), operate: 'LIKE'},
  32. // {field: 'contents', title: __('Contents'), operate: 'LIKE'},
  33. {field: 'weigh', title: __('Weigh'), operate: false},
  34. {
  35. field: 'status',
  36. title: __('Status'),
  37. searchList: {"HIDDEN": __('Hidden'), "NORMAL": __('Normal'),},
  38. formatter: Table.api.formatter.status
  39. },
  40. {
  41. field: 'createtime',
  42. title: __('Createtime'),
  43. operate: 'RANGE',
  44. addclass: 'datetimerange',
  45. autocomplete: false,
  46. formatter: Table.api.formatter.datetime
  47. },
  48. {
  49. field: 'updatetime',
  50. title: __('Updatetime'),
  51. operate: 'RANGE',
  52. addclass: 'datetimerange',
  53. autocomplete: false,
  54. formatter: Table.api.formatter.datetime
  55. },
  56. {
  57. field: 'operate',
  58. title: __('Operate'),
  59. table: table,
  60. events: Table.api.events.operate,
  61. formatter: Table.api.formatter.operate
  62. }
  63. ]
  64. ]
  65. });
  66. // 为表格绑定事件
  67. Table.api.bindevent(table);
  68. },
  69. add: function () {
  70. Controller.api.bindevent();
  71. },
  72. edit: function () {
  73. Controller.api.bindevent();
  74. },
  75. api: {
  76. bindevent: function () {
  77. Form.api.bindevent($("form[role=form]"));
  78. $(document).on('click', '#btnFrontend', function () {
  79. var frontend = $('#frontend').val();
  80. Fast.api.open('exam/config_info/frontend', '前端跳转设置', {
  81. area: ['80%', '80%'],
  82. callback: function (data) {
  83. console.log('callback data', data)
  84. $('#c-front_info').val(JSON.stringify(data))
  85. return false;
  86. }
  87. });
  88. });
  89. }
  90. }
  91. };
  92. return Controller;
  93. });