如上图,直接上代码:

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

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

            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: 'operate', title: __('Operate'), table: table, width:'100px',events: Table.api.events.operate, formatter: Table.api.formatter.operate, buttons:[ //width是规定这列的宽度
                                {
                                    name: 'click',
                                    text: '审性别',
                                    title:'审核性别',
                                    classname: 'btn btn-xs btn-info btn-click',
                                    icon: 'fa fa-eye',
                                    // dropdown: '更多',//如果包含dropdown,将会以下拉列表的形式展示
                                    visible: function (row) {
                                        let data = row;
                                    	// 判断当前行数据中的 status 字段的值是否等于 1
                                        if (row.statussex == 3) {
                                        	// return true 代表显示
                                            return true;
                                        }
                                    },

                                    click: function (data,row) {
                                        console.log(row);
                                        layer.confirm('审核性别', {
                                          btn: ['男', '女', '拒绝'] //可以无限个按钮
                                          ,btn3: function(index, layero){
                                            $.post('user/verify/statusSex?id='+row.id+'&status=4',{},function(ret){
                                                layer.msg(ret.msg);
                                                if(ret.code == 1){
                                                   layer.close();
                                                   $("#table").bootstrapTable('refresh',{});
                                                }
                                            },'json');
                                          }
                                        }, function(index, layero){
                                           $.post('user/verify/statusSex?id='+row.id+'&status=1',{},function(ret){
                                                layer.msg(ret.msg);
                                                if(ret.code == 1){
                                                   layer.close();
                                                   $("#table").bootstrapTable('refresh',{});
                                                }
                                            },'json');
                                        }, function(index){
                                            $.post('user/verify/statusSex?id='+row.id+'&status=2',{},function(ret){
                                                layer.msg(ret.msg);
                                                if(ret.code == 1){
                                                    layer.close();
                                                    $("#table").bootstrapTable('refresh',{});
                                                }
                                            },'json');
                                        });;
                                    }
                                },

                                ]
                        },
                        {field: 'user_id', title: __('User_id')},
                        {field: 'user.nickname', title: __('User.nickname'), operate: 'LIKE'},
                        {field: 'user.avatar', title: __('User.avatar'), operate: 'LIKE', events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'sexfile', title: __('Sexfile'), operate: false, formatter: Table.api.formatter.file},
                        {field: 'statussex', title: __('Statussex'), searchList: {"0":__('Statussex 0'),"1":__('Statussex 1'),"2":__('Statussex 2'),"3":__('Statussex 3'),"4":__('Statussex 4')}, formatter: Table.api.formatter.normal},
                        {field: 'idname', title: __('Idname'), operate: 'LIKE'},
                        {field: 'idcard', title: __('Idcard'), operate: 'LIKE'},
                        {field: 'idzimage', title: __('Idzimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'idfimage', title: __('Idfimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'idsimage', title: __('Idsimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'statusid', title: __('Statusid'), searchList: {"0":__('Statusid 0'),"1":__('Statusid 1'),"2":__('Statusid 2')}, formatter: Table.api.formatter.normal},
                        
                        
                        {field: 'videofile', title: __('Videofile'), operate: false, formatter: Table.api.formatter.file},
                        {field: 'statusvideo', title: __('Statusvideo'), searchList: {"0":__('Statusvideo 0'),"1":__('Statusvideo 1'),"2":__('Statusvideo 2')}, formatter: Table.api.formatter.normal},
                        
                        
                        {field: 'carimage', title: __('Carimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'statuscar', title: __('Statuscar'), searchList: {"0":__('Statuscar 0'),"1":__('Statuscar 1'),"2":__('Statuscar 2')}, formatter: Table.api.formatter.normal},
                        
                        
                        {field: 'houseimage', title: __('Houseimage'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
                        {field: 'statushouse', title: __('Statushouse'), searchList: {"0":__('Statushouse 0'),"1":__('Statushouse 1'),"2":__('Statushouse 2')}, formatter: Table.api.formatter.normal},

                        {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, 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);
        },
        recyclebin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'user/verify/recyclebin' + location.search,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {
                            field: 'deletetime',
                            title: __('Deletetime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'operate',
                            width: '130px',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'Restore',
                                    text: __('Restore'),
                                    classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
                                    icon: 'fa fa-rotate-left',
                                    url: 'user/verify/restore',
                                    refresh: true
                                },
                                {
                                    name: 'Destroy',
                                    text: __('Destroy'),
                                    classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
                                    icon: 'fa fa-times',
                                    url: 'user/verify/destroy',
                                    refresh: true
                                }
                            ],
                            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;
});
点赞(0) 打赏

评论列表 共有 0 条评论

暂无评论

微信小程序

微信扫一扫体验

立即
投稿

微信公众账号

微信扫一扫加关注

发表
评论
返回
顶部