dgtdetaildata.js 5.3 KB

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