usercoupon.js 3.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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: 'usercoupon/index' + location.search,
  8. // add_url: 'usercoupon/add',
  9. // edit_url: 'usercoupon/edit',
  10. del_url: 'usercoupon/del',
  11. multi_url: 'usercoupon/multi',
  12. // import_url: 'usercoupon/import',
  13. table: 'user_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. fixedColumns: true,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'user_id', title: __('User_id')},
  29. {field: 'coupon_id', title: __('Coupon_id')},
  30. {field: 'title', title: __('Title'), operate: 'LIKE'},
  31. {field: 'desc', title: __('Desc'), operate: 'LIKE'},
  32. {field: 'type', title: __('Type'), searchList: {"1":__('Type 1'),"2":__('Type 2')}, formatter: Table.api.formatter.normal},
  33. {field: 'money', title: __('Money')},
  34. {field: 'minmoney', title: __('Minmoney')},
  35. {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},
  36. {field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'active_id', title: __('Active_id')},
  39. {field: 'order_id', title: __('Order_id')},
  40. {field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1')}, formatter: Table.api.formatter.status,
  41. custom: {0: 'success', 1: 'danger'}
  42. },
  43. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  44. {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  45. // {field: 'coupon.title', title: __('Coupon.title'), operate: 'LIKE'},
  46. // {field: 'coupon.desc', title: __('Coupon.desc'), operate: 'LIKE'},
  47. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  48. ]
  49. ]
  50. });
  51. // 为表格绑定事件
  52. Table.api.bindevent(table);
  53. },
  54. add: function () {
  55. Controller.api.bindevent();
  56. },
  57. edit: function () {
  58. Controller.api.bindevent();
  59. },
  60. api: {
  61. bindevent: function () {
  62. Form.api.bindevent($("form[role=form]"));
  63. }
  64. }
  65. };
  66. return Controller;
  67. });