reward.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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/reward/index' + location.search,
  8. add_url: '',
  9. edit_url: 'commission/reward/edit',
  10. del_url: 'commission/reward/del',
  11. multi_url: 'commission/reward/multi',
  12. import_url: 'commission/reward/import',
  13. table: 'commission_reward',
  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. columns: [
  23. [
  24. {checkbox: true},
  25. {field: 'id', title: __('ID'), width: 60},
  26. {field: 'order.order_sn', title: __('订单号'), operate: 'LIKE'},
  27. {field: 'buyer.nickname', title: __('下单用户'), operate: 'LIKE'},
  28. {field: 'buyer.mobile', title: __('手机号'), operate: 'LIKE'},
  29. {field: 'agent.nickname', title: __('分销用户'), operate: 'LIKE'},
  30. {field: 'agent.mobile', title: __('分销手机号'), operate: 'LIKE'},
  31. {field: 'original_commission', title: __('原始佣金'), operate: 'BETWEEN'},
  32. {field: 'commission', title: __('分销佣金'), operate: 'BETWEEN'},
  33. {field: 'commission_level', title: __('执行层级'), width: 80},
  34. {field: 'agent_level', title: __('执行等级'), width: 80},
  35. {field: 'status', title: __('状态'), searchList: {
  36. "-2": __('已退回'),
  37. "-1": __('已取消'),
  38. "0": __('待入账'),
  39. "1": __('已入账')
  40. }, formatter: function(value, row, index) {
  41. var statusMap = {
  42. '-2': {text: '已退回', color: 'danger'},
  43. '-1': {text: '已取消', color: 'warning'},
  44. '0': {text: '待入账', color: 'info'},
  45. '1': {text: '已入账', color: 'success'}
  46. };
  47. var status = statusMap[value] || {text: value, color: 'default'};
  48. return '<span class="label label-' + status.color + '">' + status.text + '</span>';
  49. }},
  50. {field: 'type', title: __('入账方式'), searchList: {
  51. "commission": __('佣金钱包'),
  52. "money": __('余额钱包'),
  53. "score": __('积分'),
  54. "cash": __('现金'),
  55. "change": __('企业付款到零钱'),
  56. "bank": __('企业付款到银行卡')
  57. }},
  58. {field: 'commission_time', title: __('结算时间'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
  59. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
  60. buttons: [
  61. {
  62. name: 'edit',
  63. text: __('编辑'),
  64. title: __('编辑佣金'),
  65. classname: 'btn btn-xs btn-success',
  66. icon: 'fa fa-edit',
  67. visible: function (row) {
  68. return row.status == 0; // 只有待入账的可以编辑
  69. },
  70. click: function (data) {
  71. Layer.prompt({
  72. title: '修改佣金金额',
  73. formType: 2,
  74. value: data.commission
  75. }, function(value, index, elem) {
  76. Fast.api.ajax({
  77. url: 'commission/reward/edit',
  78. data: {ids: data.id, commission: value}
  79. }, function(data, ret) {
  80. table.bootstrapTable('refresh');
  81. Layer.close(index);
  82. });
  83. });
  84. }
  85. }
  86. ],
  87. formatter: Table.api.formatter.operate}
  88. ]
  89. ]
  90. });
  91. // 为表格绑定事件
  92. Table.api.bindevent(table);
  93. },
  94. api: {
  95. bindevent: function () {
  96. Form.api.bindevent($("form[role=form]"));
  97. }
  98. }
  99. };
  100. return Controller;
  101. });