agent.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  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. multi_url: 'commission/agent/multi',
  10. import_url: 'commission/agent/import',
  11. table: 'commission_agent',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. pk: 'user_id',
  19. sortName: 'user_id',
  20. fixedColumns: true, // 启用固定列功能
  21. fixedRightNumber: 1, // 固定右侧最后1列(操作列)
  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: 'level_info.name', title: __('分销等级'), formatter: function(value, row, index) {
  29. if (row.level_info) {
  30. return row.level_info.name + '(等级' + row.level_info.level + ')';
  31. }
  32. return row.level || '-';
  33. }},
  34. {field: 'status', title: __('状态'), searchList: {
  35. "normal": __('正常'),
  36. "pending": __('审核中'),
  37. "freeze": __('冻结'),
  38. "forbidden": __('禁用'),
  39. "reject": __('拒绝')
  40. }, formatter: function(value, row, index) {
  41. var colorMap = {
  42. 'normal': 'success',
  43. 'pending': 'warning',
  44. 'freeze': 'info',
  45. 'forbidden': 'danger',
  46. 'reject': 'danger'
  47. };
  48. var textMap = {
  49. 'normal': '正常',
  50. 'pending': '审核中',
  51. 'freeze': '冻结',
  52. 'forbidden': '禁用',
  53. 'reject': '拒绝'
  54. };
  55. var color = colorMap[value] || 'default';
  56. var text = textMap[value] || value;
  57. return '<span class="label label-' + color + '">' + text + '</span>';
  58. }},
  59. {field: 'total_income', title: __('总收益'), operate: 'BETWEEN'},
  60. {field: 'child_agent_count_1', title: __('直推分销商'), width: 80},
  61. {field: 'child_agent_count_all', title: __('团队分销商'), width: 80},
  62. {field: 'child_user_count_all', title: __('团队人数'), width: 80},
  63. {field: 'pending_reward', title: __('待结算佣金'), width: 80},
  64. {field: 'become_time', title: __('成为分销商时间'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
  65. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
  66. buttons: [
  67. {
  68. name: 'detail',
  69. text: __('详情'),
  70. title: __('详情'),
  71. classname: 'btn btn-xs btn-primary btn-dialog',
  72. icon: 'fa fa-list',
  73. url: 'commission/agent/detail',
  74. callback: function (data) {
  75. table.bootstrapTable('refresh');
  76. }
  77. },
  78. {
  79. name: 'team',
  80. text: __('团队'),
  81. title: __('团队'),
  82. classname: 'btn btn-xs btn-info btn-dialog',
  83. icon: 'fa fa-users',
  84. url: 'commission/agent/team',
  85. callback: function (data) {
  86. table.bootstrapTable('refresh');
  87. }
  88. },
  89. ],
  90. formatter: Table.api.formatter.operate}
  91. ]
  92. ]
  93. });
  94. // 为表格绑定事件
  95. Table.api.bindevent(table);
  96. },
  97. detail: function () {
  98. var agentId = Fast.api.query('id');
  99. var agentData = {};
  100. // 获取分销商详情
  101. function getDetail() {
  102. Fast.api.ajax({
  103. url: 'commission/agent/detail',
  104. data: {id: agentId}
  105. }, function(data) {
  106. agentData = data;
  107. updateDetailView(data);
  108. });
  109. }
  110. // 更新详情视图
  111. function updateDetailView(data) {
  112. if (data.user) {
  113. $('#user-avatar').attr('src', data.user.avatar || '/assets/img/avatar.png');
  114. $('#user-nickname').text(data.user.nickname || data.user_id);
  115. }
  116. // 状态
  117. var statusMap = {
  118. 'normal': {text: '正常', class: 'label-success'},
  119. 'pending': {text: '审核中', class: 'label-warning'},
  120. 'freeze': {text: '冻结', class: 'label-info'},
  121. 'forbidden': {text: '禁用', class: 'label-danger'},
  122. 'reject': {text: '拒绝', class: 'label-danger'}
  123. };
  124. var status = statusMap[data.status] || {text: data.status, class: 'label-default'};
  125. $('#agent-status').text(status.text).attr('class', 'label ' + status.class);
  126. // 等级
  127. if (data.level_info) {
  128. $('#agent-level').text(data.level_info.name + '(等级' + data.level_info.level + ')');
  129. if (data.level_info.commission_rules) {
  130. $('#commission-1').text(data.level_info.commission_rules.commission_1 || '0.00');
  131. $('#commission-2').text(data.level_info.commission_rules.commission_2 || '0.00');
  132. $('#commission-3').text(data.level_info.commission_rules.commission_3 || '0.00');
  133. }
  134. } else {
  135. $('#agent-level').text(data.level);
  136. }
  137. // 待升级等级
  138. if (data.level_status > 0 && data.level_status_info) {
  139. $('#upgrade-level-group').show();
  140. $('#upgrade-level').text(data.level_status_info.name + '(等级' + data.level_status + ')');
  141. } else {
  142. $('#upgrade-level-group').hide();
  143. }
  144. // 上级分销商
  145. if (data.user && data.user.parent_user) {
  146. $('#parent-agent').text(data.user.parent_user.nickname || '用户' + data.user.parent_user_id);
  147. } else {
  148. $('#parent-agent').text('无');
  149. }
  150. // 允许升级
  151. $('#upgrade-lock').prop('checked', data.upgrade_lock == 0);
  152. // 统计数据
  153. $('#child-user-count-all').text(data.child_user_count_all || 0);
  154. $('#child-user-count-1').text(data.child_user_count_1 || 0);
  155. $('#child-agent-count-all').text(data.child_agent_count_all || 0);
  156. $('#child-agent-count-1').text(data.child_agent_count_1 || 0);
  157. $('#child-order-money-all').text((data.child_order_money_all || 0) + '元');
  158. $('#child-order-count-all').text(data.child_order_count_all || 0);
  159. $('#child-order-money-1').text((data.child_order_money_1 || 0) + '元');
  160. $('#child-order-count-1').text(data.child_order_count_1 || 0);
  161. $('#total-income').text((data.total_income || 0) + '元');
  162. $('#pending-reward').text((data.pending_reward || 0) + '元');
  163. $('#total-consume').text(((data.user && data.user.total_consume) || 0) + '元');
  164. // 申请信息
  165. if (data.apply_info && data.apply_info.length > 0) {
  166. var applyHtml = '<form class="form-horizontal">';
  167. data.apply_info.forEach(function(item) {
  168. applyHtml += '<div class="form-group">';
  169. applyHtml += '<label class="col-sm-3 control-label">' + item.name + ':</label>';
  170. applyHtml += '<div class="col-sm-9">';
  171. if (item.type === 'image') {
  172. applyHtml += '<img src="' + item.value + '" style="max-width: 200px; max-height: 120px;">';
  173. } else {
  174. applyHtml += '<p class="form-control-static">' + item.value + '</p>';
  175. }
  176. applyHtml += '</div></div>';
  177. });
  178. applyHtml += '</form>';
  179. $('#apply-info').html(applyHtml);
  180. } else {
  181. $('#apply-info').html('<p class="text-muted">暂无申请信息</p>');
  182. }
  183. }
  184. // 详情页面特有的全局函数
  185. // 修改状态事件委托
  186. $(document).on('click', '.btn-edit-status', function () {
  187. var userId = $(this).data('user-id');
  188. var currentStatus = $(this).data('current-status') || 'normal';
  189. var html = Template('statusedittml', {
  190. currentStatus: currentStatus,
  191. userId: userId
  192. });
  193. layer.open({
  194. type: 1,
  195. skin: 'layui-layer-demo',
  196. title: '修改分销商状态',
  197. anim: 2,
  198. area: ['400px', '280px'],
  199. shadeClose: 1,
  200. content: html,
  201. btn: ['确定', '取消'],
  202. zIndex: 999999,
  203. yes: function (index) {
  204. var newStatus = $('input[name="status"]:checked').val();
  205. if (!newStatus) {
  206. Toastr.error('请选择状态');
  207. return false;
  208. }
  209. // 发送AJAX请求
  210. Fast.api.ajax({
  211. url: 'commission/agent/edit',
  212. data: {
  213. ids: $('#status_user_id').val(),
  214. status: newStatus
  215. }
  216. }, function(data, ret) {
  217. window.location.reload();
  218. Toastr.success('修改成功');
  219. layer.close(index);
  220. });
  221. },
  222. success: function (layero, index) {
  223. // 使用FastAdmin标准方式绑定表单事件
  224. Form.api.bindevent(layero.find("form"));
  225. }
  226. });
  227. });
  228. // 修改到期时间 - 使用事件委托
  229. $(document).on('click', '.btn-edit-expire-time', function () {
  230. var userId = $(this).data('user-id');
  231. var expireTime = $(this).data('expire-time');
  232. // 将时间戳转换为日期字符串
  233. var currentTime = '';
  234. if (expireTime && expireTime != '') {
  235. var date = new Date(expireTime * 1000);
  236. currentTime = date.getFullYear() + '-' +
  237. String(date.getMonth() + 1).padStart(2, '0') + '-' +
  238. String(date.getDate()).padStart(2, '0') + ' ' +
  239. String(date.getHours()).padStart(2, '0') + ':' +
  240. String(date.getMinutes()).padStart(2, '0') + ':' +
  241. String(date.getSeconds()).padStart(2, '0');
  242. }
  243. // 使用Template渲染HTML
  244. var html = Template('expiretimetpl', {
  245. currentTime: currentTime,
  246. userId: userId
  247. });
  248. layer.open({
  249. type: 1,
  250. skin: 'layui-layer-demo',
  251. title: '修改分销商到期时间',
  252. anim: 2,
  253. area: ['500px', '500px'],
  254. shadeClose: 1,
  255. content: html,
  256. btn: ['确定', '取消'],
  257. zIndex: 999999,
  258. yes: function (index) {
  259. var newTime = ($('#expire_time').val()).trim();
  260. // 验证时间格式
  261. if (newTime && !/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(newTime)) {
  262. Toastr.error('时间格式不正确,请使用格式: 2024-01-01 00:00:00');
  263. return;
  264. }
  265. var userId = $('#user_id').val();
  266. Fast.api.ajax({
  267. url: 'commission/agent/updateExpireTime',
  268. data: {
  269. user_id: userId,
  270. expire_time: newTime
  271. }
  272. }, function(data, ret) {
  273. window.location.reload();
  274. Toastr.success('修改成功');
  275. layer.close(index);
  276. });
  277. },
  278. success: function (layero, index) {
  279. // 使用FastAdmin标准方式绑定表单事件
  280. Form.api.bindevent(layero.find("form"));
  281. }
  282. });
  283. });
  284. window.changeLevel = function(userId) {
  285. Toastr.info('等级修改功能待完善');
  286. };
  287. window.changeParentUser = function(userId) {
  288. Fast.api.open('commission/agent/select?id=' + userId, '更换上级分销商', {
  289. callback: function() {
  290. location.reload();
  291. }
  292. });
  293. };
  294. window.approveLevel = function(userId, levelStatus) {
  295. Fast.api.ajax({
  296. url: 'commission/agent/edit',
  297. data: {ids: userId, level_status: levelStatus}
  298. }, function() {
  299. location.reload();
  300. });
  301. };
  302. window.rejectLevel = function(userId) {
  303. Fast.api.ajax({
  304. url: 'commission/agent/edit',
  305. data: {ids: userId, level_status: 0}
  306. }, function() {
  307. location.reload();
  308. });
  309. };
  310. window.toggleUpgradeLock = function(userId, currentLock) {
  311. var newLock = currentLock == 0 ? 1 : 0;
  312. Fast.api.ajax({
  313. url: 'commission/agent/edit',
  314. data: {ids: userId, upgrade_lock: newLock}
  315. }, function() {
  316. location.reload();
  317. });
  318. };
  319. window.viewTeam = function(userId) {
  320. Fast.api.open('commission/agent/team?id=' + userId, '查看团队');
  321. };
  322. // 事件绑定
  323. $(document).ready(function() {
  324. $('.btn-refresh').click(function() {
  325. location.reload();
  326. });
  327. $('#refresh-detail').click(function() {
  328. getDetail();
  329. });
  330. $('#edit-status').click(function() {
  331. Layer.prompt({
  332. title: '修改状态',
  333. formType: 2,
  334. value: agentData.status,
  335. select: ['normal', 'pending', 'freeze', 'forbidden', 'reject'],
  336. selectTips: ['正常', '审核中', '冻结', '禁用', '拒绝']
  337. }, function(value, index) {
  338. Fast.api.ajax({
  339. url: 'commission/agent/edit',
  340. data: {ids: agentId, status: value}
  341. }, function() {
  342. Layer.close(index);
  343. getDetail();
  344. });
  345. });
  346. });
  347. $('#change-parent').click(function() {
  348. Fast.api.open('commission/agent/select?id=' + agentId, '更换上级分销商', {
  349. callback: function() {
  350. getDetail();
  351. }
  352. });
  353. });
  354. $('#upgrade-lock').change(function() {
  355. var value = $(this).is(':checked') ? 0 : 1;
  356. Fast.api.ajax({
  357. url: 'commission/agent/edit',
  358. data: {ids: agentId, upgrade_lock: value}
  359. }, function() {
  360. getDetail();
  361. });
  362. });
  363. $('#approve-level').click(function() {
  364. Fast.api.ajax({
  365. url: 'commission/agent/edit',
  366. data: {ids: agentId, level_status: agentData.level_status}
  367. }, function() {
  368. getDetail();
  369. });
  370. });
  371. $('#reject-level').click(function() {
  372. Fast.api.ajax({
  373. url: 'commission/agent/edit',
  374. data: {ids: agentId, level_status: 0}
  375. }, function() {
  376. getDetail();
  377. });
  378. });
  379. // 初始化
  380. if (agentId) {
  381. getDetail();
  382. }
  383. });
  384. Controller.api.bindevent();
  385. },
  386. select: function () {
  387. var userId = Fast.api.query('id');
  388. var selectedParentId = null;
  389. var currentPage = 1;
  390. var pageSize = 10;
  391. // 获取当前用户信息
  392. function getCurrentUserInfo() {
  393. Fast.api.ajax({
  394. url: 'commission/agent/detail',
  395. data: {id: userId}
  396. }, function(data) {
  397. var html = '<label>当前推荐人:</label>';
  398. if (data.user && data.user.parent_user) {
  399. html += '<img src="' + (data.user.parent_user.avatar || '/assets/img/avatar.png') + '" ';
  400. html += 'style="width: 20px; height: 20px; border-radius: 50%; margin-right: 5px;">';
  401. html += (data.user.parent_user.nickname || '用户' + data.user.parent_user_id);
  402. selectedParentId = data.user.parent_user_id;
  403. } else {
  404. html += '无';
  405. selectedParentId = 0;
  406. }
  407. $('#current-parent').html(html);
  408. });
  409. }
  410. // 获取分销商列表
  411. function getAgentList() {
  412. var searchType = $('#search-type').val();
  413. var searchValue = $('#search-value').val();
  414. var searchData = {
  415. page: currentPage,
  416. limit: pageSize
  417. };
  418. if (searchValue) {
  419. searchData[searchType] = searchValue;
  420. }
  421. Fast.api.ajax({
  422. url: 'commission/agent/select',
  423. data: searchData
  424. }, function(ret) {
  425. var html = '';
  426. if (ret.data.rows && ret.data.rows.length > 0) {
  427. ret.data.rows.forEach(function(item) {
  428. var statusClass = '';
  429. var statusText = '';
  430. switch(item.status) {
  431. case 'normal':
  432. statusClass = 'label-success';
  433. statusText = '正常';
  434. break;
  435. case 'pending':
  436. statusClass = 'label-warning';
  437. statusText = '审核中';
  438. break;
  439. case 'freeze':
  440. statusClass = 'label-info';
  441. statusText = '冻结';
  442. break;
  443. case 'forbidden':
  444. statusClass = 'label-danger';
  445. statusText = '禁用';
  446. break;
  447. case 'reject':
  448. statusClass = 'label-danger';
  449. statusText = '拒绝';
  450. break;
  451. default:
  452. statusClass = 'label-default';
  453. statusText = item.status;
  454. }
  455. html += '<tr' + (selectedParentId == item.user_id ? ' class="warning"' : '') + '>';
  456. html += '<td><input type="radio" name="parent_agent" value="' + item.user_id + '"' + (selectedParentId == item.user_id ? ' checked' : '') + '></td>';
  457. html += '<td>' + item.user_id + '</td>';
  458. html += '<td>';
  459. html += '<img src="' + (item.user.avatar || '/assets/img/avatar.png') + '" style="width: 32px; height: 32px; border-radius: 50%; margin-right: 5px;">';
  460. html += (item.user.nickname || '用户' + item.user_id);
  461. html += '</td>';
  462. html += '<td>';
  463. if (item.level_info) {
  464. html += item.level_info.name + '<br><small>等级' + item.level_info.level + '</small>';
  465. } else {
  466. html += '等级' + item.level;
  467. }
  468. html += '</td>';
  469. html += '<td>' + (item.user.mobile || '-') + '</td>';
  470. html += '<td><span class="label ' + statusClass + '">' + statusText + '</span></td>';
  471. html += '<td>';
  472. if (selectedParentId == item.user_id) {
  473. html += '<span class="text-success">已选择</span>';
  474. } else {
  475. html += '<button type="button" class="btn btn-xs btn-primary" onclick="selectAgent(' + item.user_id + ')">选择</button>';
  476. }
  477. html += '</td>';
  478. html += '</tr>';
  479. });
  480. } else {
  481. html = '<tr><td colspan="7" class="text-center">暂无数据</td></tr>';
  482. }
  483. $('#agent-list').html(html);
  484. // 更新分页
  485. updatePagination(ret.data.total);
  486. });
  487. }
  488. // 更新分页
  489. function updatePagination(total) {
  490. var totalPages = Math.ceil(total / pageSize);
  491. var html = '<ul class="pagination">';
  492. // 上一页
  493. if (currentPage > 1) {
  494. html += '<li><a href="javascript:;" onclick="changePage(' + (currentPage - 1) + ')">上一页</a></li>';
  495. }
  496. // 页码
  497. for (var i = 1; i <= totalPages; i++) {
  498. if (i == currentPage) {
  499. html += '<li class="active"><a href="javascript:;">' + i + '</a></li>';
  500. } else {
  501. html += '<li><a href="javascript:;" onclick="changePage(' + i + ')">' + i + '</a></li>';
  502. }
  503. }
  504. // 下一页
  505. if (currentPage < totalPages) {
  506. html += '<li><a href="javascript:;" onclick="changePage(' + (currentPage + 1) + ')">下一页</a></li>';
  507. }
  508. html += '</ul>';
  509. $('#pagination').html(html);
  510. }
  511. // 选择页面特有的全局函数
  512. window.searchAgent = function() {
  513. currentPage = 1;
  514. getAgentList();
  515. };
  516. window.selectAgent = function(agentId) {
  517. selectedParentId = agentId;
  518. $('input[name="parent_agent"]').prop('checked', false);
  519. $('input[value="' + agentId + '"]').prop('checked', true);
  520. $('#agent-table tbody tr').removeClass('warning');
  521. $('input[value="' + agentId + '"]').closest('tr').addClass('warning');
  522. $('#set-platform').prop('checked', false);
  523. };
  524. window.changePage = function(page) {
  525. currentPage = page;
  526. getAgentList();
  527. };
  528. window.confirmChange = function() {
  529. if (selectedParentId === null) {
  530. Toastr.error('请选择上级分销商');
  531. return;
  532. }
  533. Fast.api.ajax({
  534. url: 'commission/agent/changeParentUser',
  535. data: {
  536. id: userId,
  537. parent_user_id: selectedParentId
  538. }
  539. }, function() {
  540. Toastr.success('更换成功');
  541. Fast.api.close();
  542. });
  543. };
  544. // 事件绑定
  545. $(document).ready(function() {
  546. // 设为平台直推
  547. $('#set-platform').change(function() {
  548. if ($(this).is(':checked')) {
  549. selectedParentId = 0;
  550. $('input[name="parent_agent"]').prop('checked', false);
  551. $('#agent-table tbody tr').removeClass('warning');
  552. }
  553. });
  554. // 搜索框回车事件
  555. $('#search-value').keypress(function(e) {
  556. if (e.which == 13) {
  557. searchAgent();
  558. }
  559. });
  560. // 初始化
  561. getCurrentUserInfo();
  562. getAgentList();
  563. });
  564. },
  565. team: function () {
  566. // 优先从Config中获取ID,否则从URL参数获取
  567. var agentId = Config.current_agent_id || Fast.api.query('id');
  568. console.log('agentId:', agentId);
  569. // 初始化表格参数
  570. Table.api.init({
  571. extend: {
  572. index_url: 'commission/agent/team?id=' + agentId,
  573. add_url: '',
  574. edit_url: '',
  575. del_url: '',
  576. multi_url: '',
  577. import_url: '',
  578. table: 'commission_agent',
  579. }
  580. });
  581. var table = $("#table");
  582. // 初始化表格
  583. table.bootstrapTable({
  584. url: $.fn.bootstrapTable.defaults.extend.index_url,
  585. pk: 'user_id',
  586. sortName: 'user_id',
  587. columns: [
  588. [
  589. {checkbox: true},
  590. {field: 'user_id', title: __('ID'), width: 60},
  591. {field: 'user.nickname', title: __('团队成员'), operate: 'LIKE', formatter: function(value, row, index) {
  592. if (row.user) {
  593. var avatarUrl = row.user.avatar || '/assets/img/avatar.png';
  594. var html = '<div style="display:flex;align-items:center;">';
  595. html += '<img src="' + avatarUrl + '" style="width:40px;height:40px;border-radius:50%;margin-right:10px;" />';
  596. html += '<div>';
  597. html += '<div style="color:#337ab7;font-weight:bold;">' + (row.user.nickname || row.user_id) + '</div>';
  598. html += '<div style="color:#6c757d;font-size:12px;">' + (row.user.mobile || '') + '</div>';
  599. html += '</div></div>';
  600. return html;
  601. }
  602. return row.user_id;
  603. }},
  604. {field: 'level_info.name', title: __('分销等级'), formatter: function(value, row, index) {
  605. if (row.level_info) {
  606. return row.level_info.name + '<br><small>等级' + row.level_info.level + '</small>';
  607. }
  608. return '等级' + (row.level || '-');
  609. }},
  610. {field: 'status', title: __('状态'), searchList: {
  611. "normal": __('正常'),
  612. "pending": __('审核中'),
  613. "freeze": __('冻结'),
  614. "forbidden": __('禁用'),
  615. "reject": __('拒绝')
  616. }, formatter: function(value, row, index) {
  617. var colorMap = {
  618. 'normal': 'success',
  619. 'pending': 'warning',
  620. 'freeze': 'info',
  621. 'forbidden': 'danger',
  622. 'reject': 'danger'
  623. };
  624. var textMap = {
  625. 'normal': '正常',
  626. 'pending': '审核中',
  627. 'freeze': '冻结',
  628. 'forbidden': '禁用',
  629. 'reject': '拒绝'
  630. };
  631. var color = colorMap[value] || 'default';
  632. var text = textMap[value] || value;
  633. return '<span class="label label-' + color + '">' + text + '</span>';
  634. }},
  635. {field: 'child_user_count_all', title: __('团队人数'), width: 80},
  636. {field: 'child_agent_count_1', title: __('直推分销商'), width: 80},
  637. {field: 'child_agent_count_all', title: __('团队分销商'), width: 80},
  638. {field: 'total_income', title: __('累计佣金'), operate: 'BETWEEN'},
  639. {field: 'pending_reward', title: __('待结算佣金'), width: 80},
  640. {field: 'become_time', title: __('成为分销商时间'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime}
  641. ]
  642. ]
  643. });
  644. // 为表格绑定事件
  645. Table.api.bindevent(table);
  646. // // 团队页面特有的全局函数
  647. // window.viewTeam = function(userId) {
  648. // Fast.api.open('commission/agent/team?id=' + userId, '查看团队');
  649. // };
  650. // window.viewDetail = function(userId) {
  651. // Fast.api.open('commission/agent/detail?id=' + userId, '分销商详情');
  652. // };
  653. Controller.api.bindevent();
  654. },
  655. api: {
  656. bindevent: function () {
  657. Form.api.bindevent($("form[role=form]"));
  658. }
  659. }
  660. };
  661. return Controller;
  662. });