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

            var table = $("#table");
            var tableOptions = {
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                commonSearch: false,
                //fixedColumns: true,
                //fixedRightNumber: 1,
                exportTypes: ['csv'],
                search: false,
                columns: [
                    [
                        
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'code', title: __('邀请码')},
                        {field: 'expire', title: __('有效期'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible:false},

                        {
                            title: "创建时间",
                            field: "created_at"
                        },
                        {
                            title: "更新时间",
                            field: "updated_at",
                            formatter:Table.api.formatter.datetime,
                            visible: false,
                        },
                        {
                            title: "状态",
                            field: "status",
                            formatter: function (v){
                                if(v==1){
                                    return '已使用';
                                }
                                return '未使用';
                            }
                        }
                    ]
                ]
            };
            // 初始化表格
            table.bootstrapTable(tableOptions);
            // 为表格绑定事件
            Table.api.bindevent(table);
        }
    };
    return Controller;
});