notice.js 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'qingdongams/notice/notice/index',
  8. add_url: 'qingdongams/notice/notice/add',
  9. edit_url: 'qingdongams/notice/notice/edit',
  10. del_url: 'qingdongams/notice/notice/del',
  11. table: 'notice'
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. sortName: 'id',
  19. columns: [
  20. [
  21. {field: 'state', checkbox: true},
  22. {field: 'title', title: __('标题'), operate:'like'},
  23. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  24. {
  25. field: 'operate',
  26. title: __('Operate'),
  27. table: table,
  28. events: Table.api.events.operate,
  29. formatter: Table.api.formatter.operate
  30. }
  31. ]
  32. ],
  33. //启用普通表单搜索
  34. search:false,
  35. commonSearch: true,
  36. searchFormVisible: true,
  37. onLoadSuccess:function(){
  38. // 这里就是数据渲染结束后的回调函数
  39. $('.btn-editone').html('编辑');
  40. $('.fa-pencil').remove();
  41. $('.btn-delone').html('删除');
  42. $('.fa-trash').remove();
  43. $('.btn-editone').removeClass('btn-success')
  44. $('.btn-editone').removeClass('btn')
  45. $('.btn-delone').removeClass('btn')
  46. $('.btn-delone').removeClass('btn-danger')
  47. }
  48. });
  49. // 为表格绑定事件
  50. Table.api.bindevent(table);
  51. $('.search').hide();
  52. $('.btn-import').hide();
  53. },
  54. add: function () {
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. Controller.api.bindevent();
  59. },
  60. detail: function () {
  61. Controller.api.bindevent();
  62. },
  63. api: {
  64. bindevent: function () {
  65. Form.api.bindevent($("form[role=form]"));
  66. },
  67. formatter: {
  68. thumb: function (value, row, index) {
  69. var style = row.storage == 'upyun' ? '!/fwfh/120x90' : '';
  70. return '<img src="' + row.image + '" data-tips-image alt="" title="封面图" style="max-height:90px;max-width:120px">';
  71. },
  72. }
  73. }
  74. };
  75. return Controller;
  76. });