messagesys.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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: 'messagesys/index' + location.search,
  8. add_url: 'messagesys/add',
  9. edit_url: 'messagesys/edit',
  10. del_url: 'messagesys/del',
  11. multi_url: 'messagesys/multi',
  12. import_url: 'messagesys/import',
  13. table: 'message_sys',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'title', title: __('Title'), operate: 'LIKE'},
  27. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  28. {field: 'operate', title: __('Operate'), table: table,
  29. buttons:[
  30. {
  31. name:'huanxinpush',
  32. text:'推送',
  33. title:'推送',
  34. icon:'fa fa-exclamation-circle',
  35. classname:'btn btn-xs btn-info btn-ajax',
  36. url:'messagesys/huanxinpush/id/{ids}?dialog=1',
  37. target:'_self',
  38. /*hidden:function(row){
  39. return row.status==0 ? false : true;
  40. }*/
  41. }
  42. ],
  43. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  44. ]
  45. ]
  46. });
  47. // 为表格绑定事件
  48. Table.api.bindevent(table);
  49. },
  50. add: function () {
  51. Controller.api.bindevent();
  52. },
  53. edit: function () {
  54. Controller.api.bindevent();
  55. },
  56. huanxinpush: function () {
  57. Controller.api.bindevent();
  58. },
  59. api: {
  60. bindevent: function () {
  61. Form.api.bindevent($("form[role=form]"));
  62. }
  63. }
  64. };
  65. return Controller;
  66. });