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/financeflow/index' + location.search, add_url: 'fc/financeflow/add', edit_url: 'fc/financeflow/edit', del_url: 'fc/financeflow/del', multi_url: 'fc/financeflow/multi', import_url: 'fc/financeflow/import', table: 'fc_finance_flow', } }); var table = $("#table"); // 初始化表格 table.bootstrapTable({ url: $.fn.bootstrapTable.defaults.extend.index_url, pk: 'id', sortName: 'id', columns: [ [ {checkbox: true}, {field: 'id', title: __('SerialNo'), operate: false, sortable: false, align: 'center', width: '70px', class: 'fc-serial', table: table, formatter: Format.serial}, {field: 'flow_no', title: __('Flow_no'), operate: 'LIKE'}, { field: 'type', title: __('Type'), searchList: {income: __('收入'), expense: __('支出')}, formatter: function (value) { var m = {income: __('收入'), expense: __('支出')}; return m[value] !== undefined ? m[value] : '-'; } }, {field: 'scene', title: __('Scene'), operate: 'LIKE'}, { field: 'amount', title: __('Amount'), operate: 'BETWEEN', formatter: function (value) { return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); } }, { field: 'balance', title: __('Balance'), operate: 'BETWEEN', formatter: function (value) { return value === '' || value === null ? '-' : '¥' + parseFloat(value).toFixed(2); } }, {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime}, {field: 'related_text', title: '关联单号', operate: false, sortable: false, formatter: function (value) { return value ? value : '-'; }}, {field: 'remark', title: __('Remark'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content}, {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate} ] ] }); // 为表格绑定事件 Table.api.bindevent(table); // 导出资金流水(沿用当前 URL 上的 type 过滤) $(document).on('click', '.btn-export-flow', function () { var type = Fast.api.query('type') || ''; window.open(Fast.api.fixurl('fc/financeflow/export?type=' + encodeURIComponent(type))); }); // 导出营收报表(按日/月/年) $(document).on('click', '.btn-export-report', function () { var period = $('#report-period').val() || 'month'; window.open(Fast.api.fixurl('fc/financeflow/exportReport?period=' + encodeURIComponent(period))); }); }, add: function () { Controller.api.bindevent(); }, edit: function () { Controller.api.bindevent(); }, api: { bindevent: function () { Form.api.bindevent($("form[role=form]")); } } }; return Controller; });