define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], function ($, undefined, Backend, Table, Form, Format) { var Controller = { index: function () { // 初始化表格参数配置 Table.api.init({ extend: { index_url: 'fc/withdraw/index' + location.search, add_url: 'fc/withdraw/add', edit_url: 'fc/withdraw/edit', del_url: 'fc/withdraw/del', multi_url: 'fc/withdraw/multi', import_url: 'fc/withdraw/import', table: 'fc_withdraw', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', fixedColumns: true, fixedRightNumber: 1, columns: [ [ {checkbox: true}, {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'withdraw_no', title: __('Withdraw_no'), operate: 'LIKE'}, {field: 'user_id', title: '用户', addClass: 'selectpage', extend: "data-source='user/user/index' data-field='nickname'", formatter: function (value, row) { return row.user_name || '-'; }}, { field: 'amount', title: __('Amount'), operate: 'BETWEEN', formatter: function (value) { return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); } }, { field: 'channel', title: __('Channel'), searchList: {wxpay: __('微信支付')}, formatter: function (value) { var m = {wxpay: __('微信支付')}; return m[value] !== undefined ? m[value] : '-'; } }, { field: 'status', title: __('Status'), searchList: {auditing: __('待审核'), paying: __('转账中'), paid: __('已到账'), failed: __('转账失败'), rejected: __('已驳回')}, formatter: Format.statusFormatter({auditing: __('待审核'), paying: __('转账中'), paid: __('已到账'), failed: __('转账失败'), rejected: __('已驳回')}, {auditing: 'warning', paying: 'info', paid: 'success', failed: 'danger', rejected: 'danger'}) }, { field: 'transfer_status', title: '转账状态', operate: false, formatter: function (value) { var m = { WAIT_USER_CONFIRM: '待用户确认', ACCEPTED: '已受理', PROCESSING: '转账中', SUCCESS: '成功', FAIL: '失败', CANCELLED: '已撤销', AMOUNT_MISMATCH: '金额异常' }; return value && m[value] ? m[value] : (value || '-'); } }, {field: 'fail_reason', title: '失败原因', operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'reason', title: __('Reason'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime, visible: false}, { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons: [ { name: 'pay', text: '打款', title: __('PayWithdraw'), classname: 'btn btn-xs btn-success btn-click', visible: function (row) { return row.status === 'auditing'; }, confirm: __('确认对该提现申请打款?'), click: function (options, row) { Fast.api.ajax({ url: 'fc/withdraw/pay', data: {ids: row.id, op: 'pay'} }, function () { $('#' + options.tableId).bootstrapTable('refresh'); return false; }); } }, { name: 'reject', text: '驳回', title: __('RejectWithdraw'), classname: 'btn btn-xs btn-danger btn-click', visible: function (row) { return row.status === 'auditing'; }, click: function (options, row) { Layer.prompt({title: __('请输入驳回原因'), formType: 2}, function (value, index) { Fast.api.ajax({ url: 'fc/withdraw/pay', data: {ids: row.id, op: 'reject', reason: value} }, function () { $('#' + options.tableId).bootstrapTable('refresh'); return false; }); Layer.close(index); }); } } ] } ] ] }); // 为表格绑定事件 Table.api.bindevent(table); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });