coupon.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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: 'coupon/index' + location.search,
  8. add_url: 'coupon/add',
  9. // edit_url: 'coupon/edit',
  10. // del_url: 'coupon/del',
  11. multi_url: 'coupon/multi',
  12. import_url: 'coupon/import',
  13. table: 'coupon',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'id',
  21. sortName: 'weigh',
  22. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'title', title: __('Title'), operate: 'LIKE'},
  29. {field: 'desc', title: __('Desc'), operate: 'LIKE'},
  30. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  31. {field: 'money', title: __('Money')},
  32. {field: 'minmoney', title: __('Minmoney')},
  33. {field: 'purpose', title: __('Purpose'), searchList: {"0":__('Purpose 0'),"1":__('Purpose 1'),"2":__('Purpose 2'),"3":__('Purpose 3'),"4":__('Purpose 4'),"5":__('Purpose 5')}, formatter: Table.api.formatter.normal},
  34. {field: 'effectiveday', title: __('Effectiveday')},
  35. {field: 'weigh', title: __('Weigh'), operate: false},
  36. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status},
  37. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  40. buttons: [
  41. {
  42. name: 'chanagestatus',
  43. text: '发布',
  44. title: __('发布'),
  45. extend: 'data-area=\'["85%", "85%"]\'',
  46. classname: 'btn btn-xs btn-success btn-ajax',
  47. icon: 'fa fa-pencil',
  48. confirm: '确认发布?',
  49. url: 'coupon/chanagestatus/status/1',
  50. refresh: true,
  51. // success: function (data, ret) {
  52. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  53. // Layer.alert(ret.msg);
  54. // //如果需要阻止成功提示,则必须使用return false;
  55. // return false;
  56. // },
  57. // error: function (data, ret) {
  58. // // console.log(data, ret);
  59. // Layer.alert(ret.msg);
  60. // return false;
  61. // },
  62. // callback: function (data) {
  63. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  64. // },
  65. visible: function (row) {
  66. if (row.status == 0) {
  67. return true;
  68. } else {
  69. return false;
  70. }
  71. }
  72. },
  73. {
  74. name: 'chanagestatus',
  75. text: '下架',
  76. title: __('下架'),
  77. extend: 'data-area=\'["85%", "85%"]\'',
  78. classname: 'btn btn-xs btn-danger btn-ajax',
  79. icon: 'fa fa-pencil',
  80. confirm: '确认下架?',
  81. url: 'coupon/chanagestatus/status/2',
  82. refresh: true,
  83. // success: function (data, ret) {
  84. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  85. // Layer.alert(ret.msg);
  86. // //如果需要阻止成功提示,则必须使用return false;
  87. // return false;
  88. // },
  89. // error: function (data, ret) {
  90. // // console.log(data, ret);
  91. // Layer.alert(ret.msg);
  92. // return false;
  93. // },
  94. // callback: function (data) {
  95. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  96. // }
  97. visible : function (row) {
  98. if (row.status == 1) {
  99. return true;
  100. } else {
  101. return false;
  102. }
  103. }
  104. },
  105. {
  106. name: 'delcoupon',
  107. text: '删除',
  108. title: __('删除'),
  109. extend: 'data-area=\'["85%", "85%"]\'',
  110. classname: 'btn btn-xs btn-danger btn-ajax',
  111. icon: 'fa fa-trash',
  112. confirm: '确认删除?',
  113. url: 'coupon/delcoupon',
  114. refresh: true,
  115. // success: function (data, ret) {
  116. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  117. // Layer.alert(ret.msg);
  118. // //如果需要阻止成功提示,则必须使用return false;
  119. // return false;
  120. // },
  121. // error: function (data, ret) {
  122. // // console.log(data, ret);
  123. // Layer.alert(ret.msg);
  124. // return false;
  125. // },
  126. // callback: function (data) {
  127. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  128. // }
  129. visible : function (row) {
  130. if (row.status == 2) {
  131. return true;
  132. } else {
  133. return false;
  134. }
  135. }
  136. }
  137. ]
  138. }
  139. ]
  140. ]
  141. });
  142. // 为表格绑定事件
  143. Table.api.bindevent(table);
  144. },
  145. add: function () {
  146. Controller.api.bindevent();
  147. },
  148. edit: function () {
  149. Controller.api.bindevent();
  150. },
  151. api: {
  152. bindevent: function () {
  153. Form.api.bindevent($("form[role=form]"));
  154. }
  155. }
  156. };
  157. return Controller;
  158. });