notice.js 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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: 'notice/index',
  8. add_url: 'notice/add',
  9. edit_url: 'notice/edit',
  10. // del_url: 'notice/del',
  11. multi_url: 'notice/multi',
  12. table: 'notice',
  13. },
  14. showToggle:false,
  15. showColumns:false,
  16. showExport:false,
  17. searchFormVisible: true,
  18. search:false,
  19. });
  20. var table = $("#table");
  21. // 初始化表格
  22. table.bootstrapTable({
  23. url: $.fn.bootstrapTable.defaults.extend.index_url,
  24. pk: 'id',
  25. sortName: 'id',
  26. columns: [
  27. [
  28. {checkbox: true, visible:(Config.group<=2 || Config.group==6)},
  29. // {field: 'id', title: __('Id'),operate:false},
  30. {field: 'title', title: __('Title'),formatter: Controller.api.formatter.link,operate: 'LIKE %...%'},
  31. {field: 'show_level', title: __('Show_level'), visible:false, searchList: {"show_level 1":'超管可见',"show_level 2":'超管、普管可见',"show_level 3":'超管、普管、渠道商可见',"show_level 4":'超管、普管、渠道商、代理商可见'},operate:false},
  32. {field: 'show_level_text', title: __('Show_level'), visible:(Config.group<=2 || Config.group==6), operate:false},
  33. {field: 'dialog_type', title: __('Dialog_type'), visible:false, searchList: {"dialog_type 1":__('Dialog_type 1'),"dialog_type 2":__('Dialog_type 2'),"dialog_type 3":__('Dialog_type 3')},operate:false},
  34. {field: 'dialog_type_text', title: __('Dialog_type'), visible:(Config.group<=2 || Config.group==6), operate:false},
  35. {field: 'status', title: __('Status'), visible:(Config.group<=2 || Config.group==6), searchList: {"normal":__('status normal'),"hidden":__('status hidden')}, formatter: Controller.api.formatter.toggle,operate:false},
  36. // {field: 'status_text', title: __('Status'), operate:false},
  37. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime,operate:false},
  38. {field: 'operate', title: __('Operate'), visible:(Config.group<=2 || Config.group==6), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  39. ]
  40. ]
  41. });
  42. // 为表格绑定事件
  43. Table.api.bindevent(table);
  44. $(document).on('click','.layer-open',function () {
  45. Fast.api.open($(this).attr('href'), '公告', {});
  46. return false;
  47. })
  48. },
  49. add: function () {
  50. Controller.api.bindevent();
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. },
  55. show: function () {
  56. $(document).on('click', '.btn-close', function () {
  57. Fast.api.close();
  58. });
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. },
  64. formatter: {
  65. link: function (value, row, index) {
  66. return '<a href="notice/show/ids/' + row.id + '" class="layer-open">' + value + '</a>';
  67. },
  68. toggle: function (value, row, index) {
  69. return '<i class="fa ' + (value == 'normal' ? 'fa-toggle-on' : 'fa-toggle-off') + ' text-success fa-2x btn-change" data-params="status=' + (value == 'normal' ? 'hidden' : 'normal') + '" data-id="' + row.id + '"></i>';
  70. }
  71. }
  72. }
  73. };
  74. return Controller;
  75. });