define(['table', 'upload','form'], function (Table,Upload,Form) {
    var Archives = {
        index: function () {
            window.filterData['type'] = {value1:"page",symbol:'=','value2':''};
            Table.api.init({
                extend: {
                    index_url: 'singlepage/select',
                    add_url: 'singlepage/insert',
                    edit_url: 'singlepage/update',
                    del_url: 'singlepage/delete',
                    multi_url: 'singlepage/multi',
                    dragsort_url: 'singlepage/weigh',
                    table: 'archives',
                }
            });

            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: "name",
                            filter: "string",
                        },
                        {
                            title: "创建时间",
                            field: "created_at"
                        },
                        {
                            title: "更新时间",
                            field: "updated_at"
                        },
                        {
                            title: "状态",
                            field: "status",
                            formatter: Table.api.formatter.switch
                        },
                        {field: 'operate', title: '操作', table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            };
            // 初始化表格
            table.bootstrapTable(tableOptions);
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        update:function(){
            this.bindevent();
        },
        insert:function(){
            this.bindevent();
        },
        bindevent:function(){
            Config['upload_url'] = 'files/upload';
            var form = $('form');
            Form.api.bindevent(form)
        }
    };
    return Archives
});