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

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

            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')}, formatter: Table.api.formatter.normal},
                        {field: 'chufabanci_id', title: __('Chufabanci_id')},
                        {field: 'chufatime', title: __('Chufatime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'ticket_number', title: __('Ticket_number')},
//                        {field: 'chufadi_id', title: __('Chufadi_id')},
                        {field: 'chufaname', title: __('Chufaname'), operate: 'LIKE'},
//                        {field: 'longitude', title: __('Longitude'), operate: 'LIKE'},
//                        {field: 'latitude', title: __('Latitude'), operate: 'LIKE'},
                        {field: 'hexiao_no', title: __('Hexiao_no'), operate: 'LIKE'},
                        {field: 'hexiao_status', title: __('Hexiao_status'), searchList: {"0":__('Hexiao_status 0'),"1":__('Hexiao_status 1')}, formatter: Table.api.formatter.status},
                        {field: 'hexiao_uid', title: __('Hexiao_uid')},
                        {field: 'user.mobile', title: __('User.mobile'), operate: 'LIKE'},

                        {field: 'hexiao_coachid', title: __('Hexiao_coachid')},
                        {field: 'hexiao_time', title: __('Hexiao_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        {field: 'coach.nickname', title: __('Coach.nickname'), operate: 'LIKE'},
                        {field: 'coach.mobile', title: __('Coach.mobile'), operate: 'LIKE'},
//                        {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;
});
