define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'user/user/index', add_url: 'user/user/add', edit_url: 'user/user/edit', del_url: 'user/user/del', multi_url: 'user/user/multi', balance_url: 'user/user/balance', cardslip_url: 'user/user/cardslip', collection_url: 'user/user/collection', table: 'user', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('Id'), operate: false}, {field: 'agent.mobile', title: __('Group_id'), operate: false}, {field: 'mobile', title: __('Mobile'), operate: 'LIKE'}, {field: 'parent.mobile', title: __('Parent_id'), operate: false}, {field: 'balance', title: __('Balance'), operate: false}, {field: 'freeze', title: __('Freeze'), operate: false}, {field: 'task_num', title: __('Task'), operate: false}, {field: 'open_task', title: __('抢单开关'), formatter: Table.api.formatter.toggle, searchList: {0: __('关'), 1: __('开')} }, {field: 'recharge', title: __('Recharge'), operate: false}, {field: 'withdraw', title: __('Withdrawal'), operate: false}, {field: 'bonus_sum', title: __('累计收益'), operate: false}, {field: 'id', title: __('Income'), operate: false, formatter: function(value, row, index) { return row.recharge - row.withdraw; }}, {field: 'invitation_code', title: __('Invitation_code'), operate: false}, {field: 'is_agent', title: __('Is_agent'), searchList: {1: __('Yes'), 0: __('No')}, formatter: Table.api.formatter.toggle}, {field: 'user_type', title: __('User_type'), formatter: Table.api.formatter.toggle, searchList: {0: __('Dummy'), 1: __('Real person')} }, {field: 'is_lock', title: __('锁定'), formatter: Table.api.formatter.toggle, searchList: {0: __('Normal'), 1: __('Locking')} }, {field: 'operate', title: __('Operate'), table: table, buttons: [ { name: "account", text: __('Account change'), classname: 'btn btn-xs btn-info btn-magic btn-dialog', url: 'trade/money_log/index', refresh: true },{ name: "clear", text: __('Clear'), classname: 'btn btn-xs btn-danger btn-magic btn-ajax', url: 'user/user/clear', visible: function (row) { if(row.task_num > 0) return true; return false; }, refresh: true },{ name: "team", text: __('Team'), classname: 'btn btn-xs btn-success btn-magic btn-dialog', url: 'user/team/index', extend: 'data-area=\'["80%","80%"]\'', refresh: true },{ name: "edit", text: __('Edit'), classname: 'btn btn-xs btn-warning btn-magic btn-dialog', url: 'user/user/edit/ids/{id}', refresh: true },{ name: "del", text: __('Del'), classname: 'btn btn-xs btn-danger btn-magic btn-ajax', confirm: __('Confirm review'), url: 'user/user/del/ids/{id}', refresh: true }], events: Table.api.events.operate, formatter: Table.api.formatter.operate } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); //余额 $(document).on('click','.btn-balance',function () { var ids = Table.api.selectedids(table); Fast.api.open($.fn.bootstrapTable.defaults.extend.balance_url + "?ids=" + ids, __('Balance')) }); //卡单 $(document).on('click','.btn-cardslip',function () { var ids = Table.api.selectedids(table); Fast.api.open($.fn.bootstrapTable.defaults.extend.cardslip_url + "?ids=" + ids, __('Card slip')) }); //收款 $(document).on('click','.btn-collection',function () { var ids = Table.api.selectedids(table); Fast.api.open($.fn.bootstrapTable.defaults.extend.collection_url + "?ids=" + ids, __('Collection')) }); }, balance: function () { //余额 Controller.api.bindevent(); }, cardslip: function () { //卡单 Controller.api.bindevent(); //一键清空 $(document).on('click','.btn-clear',function () { $('.form-horizontal .form-control').attr('value', '') }); }, collection: function () { //收款 Controller.api.bindevent(); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });