index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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: 'content/article/index/index' + location.search,
  8. add_url: 'content/article/index/add',
  9. edit_url: 'content/article/index/edit',
  10. del_url: 'content/article/index/del',
  11. multi_url: 'content/article/index/multi',
  12. import_url: 'content/article/index/import',
  13. table: 'article',
  14. }
  15. });
  16. var table = $("#table");
  17. var statusSearchList = JSON.parse(Config.statusSearchList);
  18. // 初始化表格
  19. table.bootstrapTable({
  20. url: $.fn.bootstrapTable.defaults.extend.index_url,
  21. pk: 'id',
  22. sortName: 'sort',
  23. fixedColumns: true,
  24. fixedRightNumber: 1,
  25. columns: [
  26. [
  27. {checkbox: true},
  28. {field: 'id', title: __('Id')},
  29. {field: 'category_id', title: __('Category_id')},
  30. {field: 'title', title: __('Title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  31. {field: 'author', title: __('Author'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  32. {field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  33. {field: 'synopsis', title: __('Synopsis'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  34. // {field: 'share_title', title: __('Share_title'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  35. // {field: 'share_synopsis', title: __('Share_synopsis'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  36. // {field: 'views', title: __('Views'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
  37. // {field: 'likes', title: __('Likes')},
  38. {field: 'sort', title: __('Sort')},
  39. {field: 'status', title: __('Status'),searchList:statusSearchList, formatter: Table.api.formatter.status},
  40. // {field: 'operator_id', title: __('Operator_id')},
  41. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  42. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  43. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  44. ]
  45. ]
  46. });
  47. // 为表格绑定事件
  48. Table.api.bindevent(table);
  49. },
  50. recyclebin: function () {
  51. // 初始化表格参数配置
  52. Table.api.init({
  53. extend: {
  54. 'dragsort_url': ''
  55. }
  56. });
  57. var table = $("#table");
  58. // 初始化表格
  59. table.bootstrapTable({
  60. url: 'content/article/index/recyclebin' + location.search,
  61. pk: 'id',
  62. sortName: 'id',
  63. columns: [
  64. [
  65. {checkbox: true},
  66. {field: 'id', title: __('Id')},
  67. {field: 'title', title: __('Title'), align: 'left'},
  68. {
  69. field: 'deletetime',
  70. title: __('Deletetime'),
  71. operate: 'RANGE',
  72. addclass: 'datetimerange',
  73. formatter: Table.api.formatter.datetime
  74. },
  75. {
  76. field: 'operate',
  77. width: '140px',
  78. title: __('Operate'),
  79. table: table,
  80. events: Table.api.events.operate,
  81. buttons: [
  82. {
  83. name: 'Restore',
  84. text: __('Restore'),
  85. classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
  86. icon: 'fa fa-rotate-left',
  87. url: 'content/article/index/restore',
  88. refresh: true
  89. },
  90. {
  91. name: 'Destroy',
  92. text: __('Destroy'),
  93. classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
  94. icon: 'fa fa-times',
  95. url: 'content/article/index/destroy',
  96. refresh: true
  97. }
  98. ],
  99. formatter: Table.api.formatter.operate
  100. }
  101. ]
  102. ]
  103. });
  104. // 为表格绑定事件
  105. Table.api.bindevent(table);
  106. },
  107. add: function () {
  108. Controller.api.bindevent();
  109. },
  110. edit: function () {
  111. Controller.api.bindevent();
  112. },
  113. api: {
  114. bindevent: function () {
  115. Form.api.bindevent($("form[role=form]"));
  116. }
  117. }
  118. };
  119. return Controller;
  120. });