promotion.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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: 'operation/promotion/index',
  8. // edit_url: 'user/user/edit',
  9. // multi_url: 'user/user/multi',
  10. table: 'operation_promotion',
  11. }
  12. });
  13. var table = $("#table");
  14. // 初始化表格
  15. table.bootstrapTable({
  16. url: $.fn.bootstrapTable.defaults.extend.index_url,
  17. pk: 'id',
  18. sortName: 'user.id',
  19. searchFormTemplate: 'customformtpl',
  20. columns: [
  21. [
  22. // {checkbox: true},
  23. {field: 'id', title: __('Id'), sortable: true},
  24. {field: 'u_id', title: __('前端用户ID')},
  25. {field: 'nickname', title: __('昵称'), operate: 'LIKE'},
  26. {field: 'mobile', title: __('手机号'), operate: 'LIKE'},
  27. {field: 'preuser.nickname', title: __('上级用户'), formatter: Controller.api.formatter.perusersearch},
  28. {field: 'promotionNum', title: __('下级用户'), formatter: Controller.api.formatter.nextusersearch},
  29. {field: 'promotionAllMoney', title: __('下级总充值'), operate: false},
  30. {field: 'totalRechargeNum', title: __('下级总充值人数'), operate: false},
  31. {field: 'conditionRechargeMoney', title: __('下级充值'), operate: false},
  32. {field: 'conditionPromotionNum', title: __('下级新增'), operate: false},
  33. {field: 'conditionFirstRecharge', title: __('下级新客首充'), operate: false},
  34. {field: 'arrpu', title: __('arrpu'), operate: false},
  35. {field: 'arpu', title: __('arpu'), operate: false},
  36. ]
  37. ],
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. },
  42. add: function () {
  43. Controller.api.bindevent();
  44. },
  45. edit: function () {
  46. Controller.api.bindevent();
  47. },
  48. api: {
  49. bindevent: function () {
  50. Form.api.bindevent($("form[role=form]"));
  51. },
  52. formatter: {
  53. perusersearch: function (value, row, index) {
  54. if(value){
  55. //这里手动构造URL
  56. url = "operation/promotion?pre_uid=" + row.preuser.u_id;
  57. //方式一,直接返回class带有addtabsit的链接,这可以方便自定义显示内容
  58. //return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __('Search %s', value) + '</a>';
  59. //方式二,直接调用Table.api.formatter.addtabs
  60. this.url = url;
  61. this.atitle = '用户推广列表';
  62. return Table.api.formatter.dialog.call(this, value, row, index);
  63. }else{
  64. return '-';
  65. }
  66. },
  67. nextusersearch: function (value, row, index) {
  68. //这里手动构造URL
  69. url = "user/usererji?parent_id=" + row.id;
  70. //方式一,直接返回class带有addtabsit的链接,这可以方便自定义显示内容
  71. //return '<a href="' + url + '" class="label label-success addtabsit" title="' + __("Search %s", value) + '">' + __('Search %s', value) + '</a>';
  72. //方式二,直接调用Table.api.formatter.addtabs
  73. this.url = url;
  74. this.atitle = '用户推广列表';
  75. return Table.api.formatter.dialog.call(this, value, row, index);
  76. }
  77. }
  78. }
  79. };
  80. return Controller;
  81. });