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

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'user.id', title: __('用户id')},
                        {field: 'user.nickname', title: __('用户昵称')},
                        {field: 'username', title: __('Username')},
                        {field: 'avatar', title: __('Avatar'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'logintime', title: __('Logintime'), operate:false, 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:false, addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'money', title: __('Money'), operate:false},
                        {field: 'merchant_title', title: __('商家名称')},
                        {field: 'merchant_name', title: __('商家联系人姓名')},
                        {field: 'merchant_mobile', title: __('商家联系人电话')},
                        {field: 'area', title: __('地址'), operate:false},
                        // {field: 'brief', title: __('简介'), operate:false},
                        {field: 'business_images', title: __('营业执照'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'other_images', title: __('其他图片'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.images},
                        {field: 'status', title: __('Status'),searchList: {"normal":__('正常'),"hidden":__('隐藏')}, formatter: Table.api.formatter.status},
                        {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;
});