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

            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: "platform",
                            field: "platform",
                            filter: "select",
                            filterOption:"osList",
                            visible: false,
                        },
                        {
                            title: "类型",
                            field: "type",
                            filter: "select",
                            filterOption:"typeList"
                        },
                        {
                            title: "类型",
                            field: "version",
                            filter: "string"
                        },
                        {
                            title: "WGT类型",
                            field: "version_wgt",
                            filter: "int"
                        },
                        {
                            title: "强制更新",
                            field: "force",
                            filter: "select",
                            filterOption:"typeList"
                        },
                        {
                            title: "创建时间",
                            field: "created_at"
                        },
                        {
                            title: "更新时间",
                            field: "updated_at",
                            formatter:Table.api.formatter.datetime,
                            visible: false,
                        },
                        {
                            title: "状态",
                            field: "status",
                            formatter: Table.api.formatter.switch,
                            filter:'select',
                            filterOption:'statusOption'
                        },
                        {
                            field: 'operate', title: '操作', 
                            table: table, events: Table.api.events.operate, 
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            };
            // 初始化表格
            table.bootstrapTable(tableOptions);
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        update:function(){
            var form = $('form');
            Form.api.bindevent(form);
        },
        insert:function(){
            var form = $('form');
            Form.api.bindevent(form);
        }
    };
    return Version
});