user_coupon.js 3.7 KB

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