dgtdaysdata.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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: 'dgtdaysdata/index' + location.search,
  8. add_url: 'dgtdaysdata/add',
  9. edit_url: 'dgtdaysdata/edit',
  10. del_url: 'dgtdaysdata/del',
  11. multi_url: 'dgtdaysdata/multi',
  12. import_url: 'dgtdaysdata/import',
  13. table: 'dgt_days_data',
  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: 'money', title: __('Money'), operate:'BETWEEN'},
  27. {field: 'datatime', title: __('Datatime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  28. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  29. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  30. {field: 'times', title: __('Times')},
  31. {field: 'sendtime', title: '发送时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  32. // {field: 'content', title: __('Content')},
  33. {field: 'operate', title: __('Operate'), table: table,
  34. buttons:[
  35. {
  36. name:'sendout',
  37. text:'发送',
  38. title:'发送',
  39. icon:'fa fa-exclamation-circle',
  40. classname:'btn btn-xs btn-danger btn-ajax',
  41. url:'dgtdaysdata/sendout/id/{ids}',
  42. target:'_self',
  43. refresh:true,
  44. hidden:function($row){
  45. if($row.times == 0){
  46. return false;
  47. }
  48. return true;
  49. }
  50. },
  51. {
  52. name:'edit',
  53. text:'编辑',
  54. title:'编辑',
  55. icon:'fa fa-exclamation-circle',
  56. classname:'btn btn-xs btn-danger btn-dialog',
  57. url:'dgtdaysdata/edit/ids/{ids}',
  58. target:'_self',
  59. refresh:true,
  60. hidden:function($row){
  61. if($row.times == 0){
  62. return false;
  63. }
  64. return true;
  65. }
  66. },
  67. {
  68. name:'del',
  69. text:'删除',
  70. title:'删除',
  71. icon:'fa fa-exclamation-circle',
  72. classname:'btn btn-xs btn-danger btn-ajax',
  73. url:'dgtdaysdata/del/ids/{ids}',
  74. target:'_self',
  75. refresh:true,
  76. hidden:function($row){
  77. if($row.times == 0){
  78. return false;
  79. }
  80. return true;
  81. }
  82. },
  83. ],
  84. events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  85. ]
  86. ]
  87. });
  88. // 为表格绑定事件
  89. Table.api.bindevent(table);
  90. },
  91. add: function () {
  92. Controller.api.bindevent();
  93. },
  94. edit: function () {
  95. Controller.api.bindevent();
  96. },
  97. sendout: function () {
  98. Controller.api.bindevent();
  99. },
  100. api: {
  101. bindevent: function () {
  102. Form.api.bindevent($("form[role=form]"));
  103. }
  104. }
  105. };
  106. return Controller;
  107. });