define(['table', 'upload','form'], function (Table,Upload,Form) {
    var income_record = {
        //Do setup work hereAction
        index: function () {
            window.statuskOption= Config.statusList;
            
            Table.api.init({
                extend: {
                    index_url: 'income_record/select',
                    add_url: 'income_record/insert',
                    edit_url: 'income_record/update',
                    del_url: 'income_record/delete',
                    multi_url: 'income_record/multi',
                    //dragsort_url: 'income_record/weigh',
                    table: 'income_record',
                }
            });

            var table = $("#table");
            var tableOptions = {
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                commonSearch: false,
                search: false,
                columns: [
                    [
                        {checkbox: true},
                        {
                            field: 'id',
                            title: 'ID',
                            filter: "number",
                            sortable: true    // 是否排序
                        },
                        {
                            title: "名称",
                            field: "title",
                            filter: "string",
                        },
                        {
                            title: "产品单价",
                            field: "price",
                            filter: "string"
                        },
                        {
                            title: "利率",
                            field: "interest_rate",
                            filter: "string",
                            formatter:function(v){
                                return v+'%'
                            }
                        },
                        {
                            title: "持续周期",
                            field: "duration_cycle",
                            filter: "string",
                            formatter:function(v,row){
                                return v+Config.cycleTypeList[row['cycle_type']]
                            }
                        },
                        {
                            title: "结算周期",
                            field: "billing_cycle",
                            filter: "string",
                            formatter:function(v,row){
                                return v+Config.cycleTypeList[row['cycle_type']]
                            }
                        },
                        {
                            title: "状态",
                            field: "status",
                            sortable: true,
                            formatter:Table.api.formatter.status,
                            searchList:window.statuskOption,
                            operate:false,
                            filter: "select",
                            filterOption:"statuskOption"
                        },
                        {
                            title: "memo",
                            field: "memo",
                            visible: false,
                        },
                        {
                            title: "创建时间",
                            field: "created_at",
                            visible: false,
                        },
                        {
                            title: "更新时间",
                            field: "updated_at",
                            visible: false,
                        },
                        {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            };
            // 初始化表格
            table.bootstrapTable(tableOptions);
            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return income_record
});