agent.js 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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: 'commission/agent/index' + location.search,
  8. add_url: '',
  9. edit_url: 'commission/agent/edit',
  10. del_url: 'commission/agent/del',
  11. multi_url: 'commission/agent/multi',
  12. import_url: 'commission/agent/import',
  13. table: 'commission_agent',
  14. }
  15. });
  16. var table = $("#table");
  17. // 初始化表格
  18. table.bootstrapTable({
  19. url: $.fn.bootstrapTable.defaults.extend.index_url,
  20. pk: 'user_id',
  21. sortName: 'user_id',
  22. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'user_id', title: __('ID'), width: 60},
  26. {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'},
  27. {field: 'user.mobile', title: __('手机号'), operate: 'LIKE'},
  28. {field: 'status', title: __('状态'), searchList: {
  29. "normal": __('正常'),
  30. "pending": __('审核中'),
  31. "freeze": __('冻结'),
  32. "forbidden": __('禁用'),
  33. "reject": __('拒绝')
  34. }, formatter: function(value, row, index) {
  35. var colorMap = {
  36. 'normal': 'success',
  37. 'pending': 'warning',
  38. 'freeze': 'info',
  39. 'forbidden': 'danger',
  40. 'reject': 'danger'
  41. };
  42. var textMap = {
  43. 'normal': '正常',
  44. 'pending': '审核中',
  45. 'freeze': '冻结',
  46. 'forbidden': '禁用',
  47. 'reject': '拒绝'
  48. };
  49. var color = colorMap[value] || 'default';
  50. var text = textMap[value] || value;
  51. return '<span class="label label-' + color + '">' + text + '</span>';
  52. }},
  53. {field: 'total_income', title: __('总收益'), operate: 'BETWEEN'},
  54. {field: 'child_agent_count_1', title: __('直推分销商'), width: 80},
  55. {field: 'child_agent_count_all', title: __('团队分销商'), width: 80},
  56. {field: 'pending_reward', title: __('待结算佣金'), width: 80},
  57. {field: 'become_time', title: __('成为分销商时间'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
  58. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
  59. buttons: [
  60. {
  61. name: 'detail',
  62. text: __('详情'),
  63. title: __('详情'),
  64. classname: 'btn btn-xs btn-primary btn-dialog',
  65. icon: 'fa fa-list',
  66. url: 'commission/agent/detail',
  67. callback: function (data) {
  68. table.bootstrapTable('refresh');
  69. }
  70. },
  71. {
  72. name: 'edit_status',
  73. text: __('编辑状态'),
  74. title: __('编辑状态'),
  75. classname: 'btn btn-xs btn-success btn-click',
  76. icon: 'fa fa-edit',
  77. click: function (data) {
  78. Layer.prompt({
  79. title: '修改状态',
  80. formType: 2,
  81. value: data.status,
  82. select: ['normal', 'pending', 'freeze', 'forbidden', 'reject'],
  83. selectTips: ['正常', '审核中', '冻结', '禁用', '拒绝']
  84. }, function(value, index, elem) {
  85. Fast.api.ajax({
  86. url: 'commission/agent/edit',
  87. data: {ids: data.user_id, status: value}
  88. }, function(data, ret) {
  89. table.bootstrapTable('refresh');
  90. Layer.close(index);
  91. });
  92. });
  93. }
  94. }
  95. ],
  96. formatter: Table.api.formatter.operate}
  97. ]
  98. ]
  99. });
  100. // 为表格绑定事件
  101. Table.api.bindevent(table);
  102. },
  103. detail: function () {
  104. Controller.api.bindevent();
  105. },
  106. select: function () {
  107. // 初始化表格参数
  108. Table.api.init({
  109. extend: {
  110. index_url: 'commission/agent/select' + location.search,
  111. }
  112. });
  113. var table = $("#table");
  114. // 初始化表格
  115. table.bootstrapTable({
  116. url: $.fn.bootstrapTable.defaults.extend.index_url,
  117. pk: 'user_id',
  118. sortName: 'user_id',
  119. columns: [
  120. [
  121. {checkbox: true},
  122. {field: 'user_id', title: __('ID'), width: 60},
  123. {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'},
  124. {field: 'user.mobile', title: __('手机号'), operate: 'LIKE'},
  125. {field: 'level_info.name', title: __('分销等级')},
  126. {field: 'status', title: __('状态'), searchList: {
  127. "normal": __('正常'),
  128. "pending": __('审核中'),
  129. "freeze": __('冻结'),
  130. "forbidden": __('禁用'),
  131. "reject": __('拒绝')
  132. }, formatter: Table.api.formatter.status},
  133. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
  134. buttons: [
  135. {
  136. name: 'choose',
  137. text: __('选择'),
  138. title: __('选择'),
  139. classname: 'btn btn-xs btn-primary btn-choose',
  140. icon: 'fa fa-check',
  141. click: function (data) {
  142. var multiple = Backend.api.query('multiple');
  143. multiple = multiple == 'true' ? true : false;
  144. Fast.api.close(data);
  145. }
  146. }
  147. ],
  148. formatter: Table.api.formatter.operate}
  149. ]
  150. ]
  151. });
  152. // 为表格绑定事件
  153. Table.api.bindevent(table);
  154. },
  155. team: function () {
  156. Controller.api.bindevent();
  157. },
  158. api: {
  159. bindevent: function () {
  160. Form.api.bindevent($("form[role=form]"));
  161. }
  162. }
  163. };
  164. return Controller;
  165. });