123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数
- Table.api.init({
- extend: {
- index_url: 'commission/reward/index' + location.search,
- add_url: '',
- edit_url: 'commission/reward/edit',
- del_url: 'commission/reward/del',
- multi_url: 'commission/reward/multi',
- import_url: 'commission/reward/import',
- table: 'commission_reward',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('ID'), width: 60},
- {field: 'order.order_sn', title: __('订单号'), operate: 'LIKE'},
- {field: 'buyer.nickname', title: __('下单用户'), operate: 'LIKE'},
- {field: 'buyer.mobile', title: __('手机号'), operate: 'LIKE'},
- {field: 'agent.nickname', title: __('分销用户'), operate: 'LIKE'},
- {field: 'agent.mobile', title: __('分销手机号'), operate: 'LIKE'},
- {field: 'original_commission', title: __('原始佣金'), operate: 'BETWEEN'},
- {field: 'commission', title: __('分销佣金'), operate: 'BETWEEN'},
- {field: 'commission_level', title: __('执行层级'), width: 80},
- {field: 'agent_level', title: __('执行等级'), width: 80},
- {field: 'status', title: __('状态'), searchList: {
- "-2": __('已退回'),
- "-1": __('已取消'),
- "0": __('待入账'),
- "1": __('已入账')
- }, formatter: function(value, row, index) {
- var statusMap = {
- '-2': {text: '已退回', color: 'danger'},
- '-1': {text: '已取消', color: 'warning'},
- '0': {text: '待入账', color: 'info'},
- '1': {text: '已入账', color: 'success'}
- };
- var status = statusMap[value] || {text: value, color: 'default'};
- return '<span class="label label-' + status.color + '">' + status.text + '</span>';
- }},
- {field: 'type', title: __('入账方式'), searchList: {
- "commission": __('佣金钱包'),
- "money": __('余额钱包'),
- "score": __('积分'),
- "cash": __('现金'),
- "change": __('企业付款到零钱'),
- "bank": __('企业付款到银行卡')
- }},
- {field: 'commission_time', title: __('结算时间'), operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
- buttons: [
- {
- name: 'edit',
- text: __('编辑'),
- title: __('编辑佣金'),
- classname: 'btn btn-xs btn-success',
- icon: 'fa fa-edit',
- visible: function (row) {
- return row.status == 0; // 只有待入账的可以编辑
- },
- click: function (data) {
- Layer.prompt({
- title: '修改佣金金额',
- formType: 2,
- value: data.commission
- }, function(value, index, elem) {
- Fast.api.ajax({
- url: 'commission/reward/edit',
- data: {ids: data.id, commission: value}
- }, function(data, ret) {
- table.bootstrapTable('refresh');
- Layer.close(index);
- });
- });
- }
- }
- ],
- formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|