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

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                fixedColumns: true,
                fixedRightNumber: 1,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'order_id', title: __('Order_id')},
                        {field: 'order.order_no', title: __('Order.order_no'), operate: 'LIKE'},
                        {field: 'product_id', title: __('Product_id')},

                        {field: 'order.product_name', title: __('Order.product_name'), operate: 'LIKE'},
                        {field: 'user_id', title: __('User_id')},
//                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
//                        {field: 'road_id', title: __('Road_id')},
                        {field: 'roadname', title: __('Roadname'), operate: 'LIKE'},
                        {field: 'roadtype', title: __('Roadtype'), searchList: {"1":__('Roadtype 1'),"2":__('Roadtype 2'),"3":__('Roadtype 3')}, formatter: Table.api.formatter.normal},
//                        {field: 'ticket_id', title: __('Ticket_id')},
                        {field: 'ticket_name', title: __('Ticket_name'), operate: 'LIKE'},
                        {field: 'ticket_price', title: __('Ticket_price'), operate:'BETWEEN'},
                        {field: 'ticket_number', title: __('Ticket_number')},
                        {field: 'pay_fee', title: __('Pay_fee'), operate:'BETWEEN'},

//                        {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;
});
