messagets.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: 'messagets/index' + location.search,
  8. add_url: 'messagets/add',
  9. edit_url: 'messagets/edit',
  10. del_url: 'messagets/del',
  11. multi_url: 'messagets/multi',
  12. import_url: 'messagets/import',
  13. table: 'message_ts',
  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: 'info', title: __('Info'), operate: 'LIKE'},
  28. {field: 'times', title: __('Times')},
  29. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  30. {field: 'operate', title: __('Operate'), table: table,
  31. buttons:[
  32. {
  33. name:'huanxinpush',
  34. text:'推送',
  35. title:'推送',
  36. icon:'fa fa-exclamation-circle',
  37. classname:'btn btn-xs btn-info btn-ajax',
  38. url:'messagets/huanxinpush/id/{ids}?dialog=1',
  39. target:'_self',
  40. refresh:true
  41. }
  42. ],events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  43. ]
  44. ]
  45. });
  46. // 为表格绑定事件
  47. Table.api.bindevent(table);
  48. },
  49. add: function () {
  50. Controller.api.bindevent();
  51. },
  52. edit: function () {
  53. Controller.api.bindevent();
  54. },
  55. huanxinpush: function () {
  56. Controller.api.bindevent();
  57. },
  58. api: {
  59. bindevent: function () {
  60. Form.api.bindevent($("form[role=form]"));
  61. }
  62. }
  63. };
  64. return Controller;
  65. });