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

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

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate:false},
                        {field: 'user.nickname', title: __('User.nickname'), operate:false},
                        {field: 'name', title: __('Name'), operate:false},
                        {field: 'sex', title: __('Sex'),formatter: Table.api.formatter.label,searchList:{'1': '男','2':'女'}},
                        {field: 'birth', title: __('Birth'), operate:false},
                        {field: 'idcard', title: __('Idcard'), operate:false},
                        {field: 'before', title: __('Before'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'behind', title: __('Behind'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'phone', title: __('Phone'), operate:false},
                        {field: 'thumbnail', title: __('Thumbnail'), operate:false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'address', title: __('Address'), operate:false},
                        {field: 'honor', title: __('Honor'), operate:false},
                        {field: 'online', title: __('Online'), operate:false},
                        {field: 'status', title: __('Status'),formatter: Table.api.formatter.status,searchList:{'0':'待审核','1': '审核通过','2':'审核未通过'}},
                        {field: 'is_recommend', title: __('Is_recommend'),formatter: Table.api.formatter.toggle,yes:'1',no:'0',searchList:{'0': '不推荐','1':'推荐'}},
                        {field: 'is_forbid', title: __('是否封禁'),formatter: Table.api.formatter.toggle,yes:'1',no:'0',searchList:{'0': '正常','1':'封禁'}},
                        {field: 'is_stick', title: __('是否置顶'),formatter: Table.api.formatter.status,searchList:{'0':'不置顶','1': '置顶'}},
                        // {field: 'territory_id', title: __('Territory_id'), operate:false},
                        {field: 'territory_id', title: __('按钮组'), table: table, events: Table.api.events.operate, buttons:
                            [
                                {
                                    text: '擅长领域',
                                    title: '擅长领域',
                                    icon: 'fa fa-list',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    url: 'hobby/index1',
                                    extend: 'data-area=\'["80%","80%"]\''
                                },
                                {
                                    text: '收益记录',
                                    title: '收益记录',
                                    icon: 'fa fa-list',
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    url: 'jilu/index1',
                                    extend: 'data-area=\'["80%","80%"]\''
                                },
                            ], operate:false, formatter: Table.api.formatter.buttons
                        },
                        {field: 'proportion', title: __('佣金比例'), operate:false},
                        {field: 'income', title: __('总收入'), operate:false},
                        {field: 'withdraw', title: __('提现金额'), operate:false},
                        {field: 'balance', title: __('账号余额'), operate:false},
                        {field: 'count', title: __('总订单数'), operate:false},
                        // {field: 'level', title: __('Level'), operate:false},
                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        {field: 'updatetime', title: __('Updatetime'), 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;
});