define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数 Table.api.init({ extend: { index_url: 'commission/agent/index' + location.search, add_url: '', edit_url: 'commission/agent/edit', del_url: 'commission/agent/del', multi_url: 'commission/agent/multi', import_url: 'commission/agent/import', table: 'commission_agent', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'user_id', sortName: 'user_id', columns: [ [ {checkbox: true}, {field: 'user_id', title: __('ID'), width: 60}, {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'}, {field: 'user.mobile', title: __('手机号'), operate: 'LIKE'}, {field: 'status', title: __('状态'), searchList: { "normal": __('正常'), "pending": __('审核中'), "freeze": __('冻结'), "forbidden": __('禁用'), "reject": __('拒绝') }, formatter: function(value, row, index) { var colorMap = { 'normal': 'success', 'pending': 'warning', 'freeze': 'info', 'forbidden': 'danger', 'reject': 'danger' }; var textMap = { 'normal': '正常', 'pending': '审核中', 'freeze': '冻结', 'forbidden': '禁用', 'reject': '拒绝' }; var color = colorMap[value] || 'default'; var text = textMap[value] || value; return '' + text + ''; }}, {field: 'total_income', title: __('总收益'), operate: 'BETWEEN'}, {field: 'child_agent_count_1', title: __('直推分销商'), width: 80}, {field: 'child_agent_count_all', title: __('团队分销商'), width: 80}, {field: 'pending_reward', title: __('待结算佣金'), width: 80}, {field: 'become_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: 'detail', text: __('详情'), title: __('详情'), classname: 'btn btn-xs btn-primary btn-dialog', icon: 'fa fa-list', url: 'commission/agent/detail', callback: function (data) { table.bootstrapTable('refresh'); } }, { name: 'edit_status', text: __('编辑状态'), title: __('编辑状态'), classname: 'btn btn-xs btn-success btn-click', icon: 'fa fa-edit', click: function (data) { Layer.prompt({ title: '修改状态', formType: 2, value: data.status, select: ['normal', 'pending', 'freeze', 'forbidden', 'reject'], selectTips: ['正常', '审核中', '冻结', '禁用', '拒绝'] }, function(value, index, elem) { Fast.api.ajax({ url: 'commission/agent/edit', data: {ids: data.user_id, status: value} }, function(data, ret) { table.bootstrapTable('refresh'); Layer.close(index); }); }); } } ], formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, detail: function () { Controller.api.bindevent(); }, select: function () { // 初始化表格参数 Table.api.init({ extend: { index_url: 'commission/agent/select' + location.search, } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'user_id', sortName: 'user_id', columns: [ [ {checkbox: true}, {field: 'user_id', title: __('ID'), width: 60}, {field: 'user.nickname', title: __('用户昵称'), operate: 'LIKE'}, {field: 'user.mobile', title: __('手机号'), operate: 'LIKE'}, {field: 'level_info.name', title: __('分销等级')}, {field: 'status', title: __('状态'), searchList: { "normal": __('正常'), "pending": __('审核中'), "freeze": __('冻结'), "forbidden": __('禁用'), "reject": __('拒绝') }, formatter: Table.api.formatter.status}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, buttons: [ { name: 'choose', text: __('选择'), title: __('选择'), classname: 'btn btn-xs btn-primary btn-choose', icon: 'fa fa-check', click: function (data) { var multiple = Backend.api.query('multiple'); multiple = multiple == 'true' ? true : false; Fast.api.close(data); } } ], formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, team: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });