new_coupon.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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: 'new_coupon/index' + location.search,
  8. add_url: 'new_coupon/add',
  9. edit_url: 'new_coupon/edit',
  10. del_url: 'new_coupon/del',
  11. multi_url: 'new_coupon/multi',
  12. import_url: 'new_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: 'id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('Id')},
  26. {field: 'coupon_type', title: __('Coupon_type'), searchList: {"1":__('Coupon_type 1'),"2":__('Coupon_type 2')}, formatter: Table.api.formatter.normal},
  27. {field: 'coupon_name', title: __('Coupon_name'), searchList: {"1":__('Coupon_name 1'),"2":__('Coupon_name 2')}, formatter: Table.api.formatter.normal},
  28. {field: 'coupon_price', title: __('Coupon_price'), operate:'BETWEEN'},
  29. {field: 'limit_price', title: __('Limit_price'), operate:'BETWEEN'},
  30. {
  31. field: 'expiration',
  32. title: __('Expiration'),
  33. operate: false,
  34. formatter: function(value, data) {
  35. return data.expiration + '天';
  36. }
  37. },
  38. {field: 'coupon_status', title: __('Coupon_status'), searchList: {"0":__('Coupon_status 0'),"1":__('Coupon_status 1')}, formatter: Table.api.formatter.status},
  39. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: function (value, row, index) {
  41. var that = $.extend({}, this);
  42. var table = $(that.table).clone(true);
  43. $(table).data("operate-del", null);
  44. that.table = table;
  45. return Table.api.formatter.operate.call(that, value, row, index);
  46. }}
  47. ]
  48. ]
  49. });
  50. // 为表格绑定事件
  51. Table.api.bindevent(table);
  52. },
  53. add: function () {
  54. Controller.api.bindevent();
  55. },
  56. edit: function () {
  57. Controller.api.bindevent();
  58. },
  59. issue_user: function () {
  60. Controller.api.bindevent();
  61. },
  62. api: {
  63. bindevent: function () {
  64. Form.api.bindevent($("form[role=form]"));
  65. }
  66. }
  67. };
  68. return Controller;
  69. });