user_coupons.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_coupons/index' + location.search,
  8. add_url: 'user_coupons/add',
  9. edit_url: 'user_coupons/edit',
  10. del_url: 'user_coupons/del',
  11. multi_url: 'user_coupons/multi',
  12. import_url: 'user_coupons/import',
  13. table: 'user_coupons',
  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: false,
  23. fixedRightNumber: 1,
  24. columns: [
  25. [
  26. {checkbox: true},
  27. {field: 'id', title: __('Id')},
  28. {field: 'user_id', title: __('User_id')},
  29. {field: 'user.nickname', title: __('Nickname'), operate: 'LIKE'},
  30. {field: 'company_id', title: __('Company_id')},
  31. {field: 'company.name', title: __('Company_name'), operate: 'LIKE'},
  32. {field: 'coupons_id', title: __('Coupons_id')},
  33. {field: 'coupon_name', title: __('Coupon_name'), operate: 'LIKE'},
  34. {field: 'coupon_info', title: __('Coupon_info'), operate: 'LIKE'},
  35. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  36. {field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'number', title: __('Number')},
  38. {field: 'remain', title: __('Remain')},
  39. {field: 'payorder_id', title: __('Payorder_id'), operate: false, visible:false},
  40. {field: 'getfrom', title: __('Getfrom'), operate: 'LIKE'},
  41. //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  42. ]
  43. ]
  44. });
  45. // 为表格绑定事件
  46. Table.api.bindevent(table);
  47. },
  48. add: function () {
  49. Controller.api.bindevent();
  50. },
  51. edit: function () {
  52. Controller.api.bindevent();
  53. },
  54. api: {
  55. bindevent: function () {
  56. $("#c-coupons_id").on('change', function () {
  57. var couponId = $('#c-coupons_id').val();
  58. $("#c-coupons_id").data("params",function(){
  59. return {custom:{company_id:companyId}};
  60. });
  61. $.ajax({
  62. url:'coupons/index?filter={"id":"'+couponId+'"}&op={"id":"="}',
  63. method:'get',
  64. success:function(res){
  65. var rows = res.rows[0];
  66. var couponName = rows["name"];
  67. $("#c-coupon_name").val(couponName);
  68. }
  69. });
  70. });
  71. Form.api.bindevent($("form[role=form]"));
  72. }
  73. }
  74. };
  75. return Controller;
  76. });