order_detail.js 3.7 KB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'order.order_num', title: __('Order.order_num')},
                        {field: 'pay_type', title: __('Pay_type'), searchList: {"1":__('Pay_type 1'),"2":__('Pay_type 2')}, formatter: Table.api.formatter.label},
                        {field: 'order_id', title: __('Order_id'),visible:false},
                        {field: 'user_id', title: __('User_id'),visible:false},
                        {field: 'depot_id', title: __('Depot_id'),visible:false, operate:false},
                        {field: 'status', title: __('Status'), searchList: {"-1":__('Status -1'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5')}, formatter: Table.api.formatter.status},
                        {field: 'shipper_code', title: __('Shipper_code')},
                        {field: 'logistic_code', title: __('Logistic_code')},
                        {field: 'createtime', title: __('Createtime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), operate:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'user.nickname', title: __('User.nickname'), formatter: Table.api.formatter.label},
                        {field: 'depot.area_name', title: '仓库', formatter: Table.api.formatter.label},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,
                            buttons: [
                                {
                                    name: 'edit', title: '发货', icon: 'fa fa-truck',
                                    classname: 'btn btn-xs btn-success  btn-dialog',
                                    url: 'order_detail/edit?id={id}'
                                },{
                                    name: 'order_info', title: '订单详情', icon: 'fa fa-list',
                                    classname: 'btn btn-xs btn-warning  btn-dialog',
                                    url: 'order_info/index?order_detail_id={id}',
                                    extend: "data-area='[\"90%\",\"90%\"]'"
                                }
                            ]}
                    ]
                ]
            });

            // 为表格绑定事件
            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;
});