couponuser.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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: 'couponuser/index/coupon_id/' + Config.coupon_id + location.search,
  8. // add_url: 'couponuser/add',
  9. // edit_url: 'couponuser/edit',
  10. // del_url: 'couponuser/del',
  11. // multi_url: 'couponuser/multi',
  12. // import_url: 'couponuser/import',
  13. table: 'user',
  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. showToggle: false,
  25. showColumns: false,
  26. showExport: false,
  27. columns: [
  28. [
  29. {field: 'state', checkbox: true},
  30. {field: 'id', title: __('Id')},
  31. {field: 'username', title: __('Username'), operate: 'LIKE'},
  32. {field: 'nickname', title: __('Nickname'), operate: 'LIKE'},
  33. {field: 'mobile', title: __('Mobile'), operate: 'LIKE'},
  34. {field: 'avatar', title: __('Avatar'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
  35. {field: 'money', title: __('Money'), operate: 'LIKE'},
  36. {field: 'status', title: __('Status'), searchList: {"1":__('Status 1'),"2":__('Status 2')}, formatter: Table.api.formatter.status,
  37. custom: {1:'success',2:'danger'}},
  38. {field: 'realname', title: __('Realname'), operate: 'LIKE'},
  39. {field: 'gender', title: __('Gender'), searchList: {"1":__('Gender 1'),"2":__('Gender 2')}, formatter: Table.api.formatter.normal},
  40. {field: 'birthday', title: __('Birthday'),formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  41. {field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
  42. {field: 'passport', title: __('Passport'), operate: 'LIKE'},
  43. {field: 'emergencycontact', title: __('Emergencycontact'), operate: 'LIKE'},
  44. {field: 'contactmobile', title: __('Contactmobile'), operate: 'LIKE'},
  45. {field: 'outdoorduration', title: __('Outdoorduration'), operate: 'LIKE'},
  46. {field: 'invite_no', title: __('Invite_no'), operate: 'LIKE'},
  47. {field: 'growthvalue', title: __('Growthvalue')},
  48. {field: 'growthlevel', title: __('Growthlevel')},
  49. {field: 'experiencelevel', title: __('Experiencelevel')},
  50. {field: 'experiencetime', title: __('Experiencetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  51. {field: 'maxlevel', title: __('Maxlevel')},
  52. {field: 'freenumber', title: __('Freenumber')},
  53. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
  54. buttons: [
  55. {
  56. name: 'giveout',
  57. text: '发放',
  58. title: __('发放'),
  59. extend: 'data-area=\'["85%", "85%"]\'',
  60. classname: 'btn btn-xs btn-success btn-ajax',
  61. icon: 'fa fa-pencil',
  62. confirm: '确认发放?',
  63. url: 'couponuser/giveout/coupon_id/' + Config.coupon_id,
  64. // refresh: true,
  65. // success: function (data, ret) {
  66. // // Layer.alert(ret.msg + ",返回数据:" + JSON.stringify(data));
  67. // Layer.alert(ret.msg);
  68. // //如果需要阻止成功提示,则必须使用return false;
  69. // return false;
  70. // },
  71. // error: function (data, ret) {
  72. // // console.log(data, ret);
  73. // Layer.alert(ret.msg);
  74. // return false;
  75. // },
  76. // callback: function (data) {
  77. // Layer.alert("接收到回传数据:" + JSON.stringify(data), {title: "回传数据"});
  78. // },
  79. // visible: function (row) {
  80. // if (row.status == 0) {
  81. // return true;
  82. // } else {
  83. // return false;
  84. // }
  85. // }
  86. }
  87. ]
  88. }
  89. ]
  90. ]
  91. });
  92. // 为表格绑定事件
  93. Table.api.bindevent(table);
  94. // 获取选中项
  95. $(document).on("click", ".btn-selected", function () {
  96. var that = this;
  97. var ids = Table.api.selectedids(table);
  98. Layer.confirm('确认发放?', function (index) {
  99. // Layer.alert(JSON.stringify(Table.api.selectedids(table)));
  100. Table.api.multi('couponuser/giveout/coupon_id/' + Config.coupon_id, ids.join(","), table, that);
  101. Layer.close(index);
  102. });
  103. });
  104. },
  105. add: function () {
  106. Controller.api.bindevent();
  107. },
  108. edit: function () {
  109. Controller.api.bindevent();
  110. },
  111. selected: function () {
  112. Controller.api.bindevent();
  113. },
  114. api: {
  115. bindevent: function () {
  116. Form.api.bindevent($("form[role=form]"));
  117. }
  118. }
  119. };
  120. return Controller;
  121. });