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

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

            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_sn', title: __('order_sn')},
                        {field: 'user.username', title: __('username')},
                        {field: 'user.mobile', title: __('mobile')},
                        {field: 'address', title: __('address')},
                        {field: 'gift.title', title: __('title')},
                        {field: 'thumb', title: __('thumb'),formatter:Table.api.formatter.image},
                        {field: 'unit_score', title: __('score')},
                        {field: 'num', title: __('num')},
                        {field: 'total_score', title: __('total_score')},
                        {field: 'createtime', title: __('createtime'), 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;
});