define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'study/index' + location.search,
                    add_url: 'study/add',
                    edit_url: 'study/edit',
                    del_url: 'study/del',
                    multi_url: 'study/multi',
                    table: 'study',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate:false},
                        {field: 'type_id', title: __('分类id'),operate:false},
                        {field: 'examname', title: __('Examname'),operate:'like'},
                        {field: 'workname', title: __('学业名称'),operate:'like'},
                        {field: 'class_hour', title: __('Class_hour'),operate:false},
                        {field: 'image', title: __('Image'),operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'yinimage', title: __('印章图片'),operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'pass_mark', title: __('及格分数'),operate:false},
                        {field: 'dan_num', title: __('单选题数量'),operate:false},
                        {field: 'dan_score', title: __('单选题分值'),operate:false},
                        {field: 'duo_num', title: __('多选题数量'),operate:false},
                        {field: 'duo_score', title: __('多选题分值'),operate:false},
                        {field: 'pan_num', title: __('判断题数量'),operate:false},
                        {field: 'pan_score', title: __('判断题分值'),operate:false},
                        {field: 'examdurationtime', title: __('考试时长/分钟'),operate:false},
                        {field: 'expirationtime', title: __('Expirationtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});