| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 | @extends('admin/layout')@section('content')    <style>        .btn-primary, .btn-info {            background: #009688 !important;            border-color: #009688 !important;        }    </style>    <body class="gray-bg">    <div class="wrapper wrapper-content animated fadeInRight">        <div class="row">            <div class="col-sm-12">                <div class="ibox float-e-margins">                    <div class="ibox-content">                        <form class="row" id="searchForm" onsubmit="units.search();return false;">                            <div class="col-md-4">                                <div class="input-group">                                   <span class="input-group-btn">                                       <button type="button" class="btn btn-md btn-info" id="on">批量启用</button>                                       <button type="button" class="btn btn-md btn-danger" id="off"                                               style="margin-left: 10px">批量禁用</button>                                       <button type="button" class="btn btn-md btn-primary" style="margin-left: 10px"                                               onclick="units.save(0)"> <span class="glyphicon glyphicon-plus"></span> 添加</button>                                       <button type="button" class="btn btn-md btn-danger" id="batchDelete"                                               style="margin-left: 10px"><span                                               class="glyphicon glyphicon-remove"></span> 删除</button>                                   </span>                                </div>                            </div>                            <div class="col-md-6 pull-right">                                <div class="input-group">                                    <select name="role_id" id="role_id" class="form-control"                                            style="width: 150px;float: right">                                        <option value="">请选择角色</option>                                        @foreach($roles as $role)                                            <option value="{{$role->id}}">{{$role->name}}</option>                                        @endforeach                                    </select>                                    <input type="text" placeholder="请输入用户名" class="input-md form-control" name="keyword"                                           id="keyWord" style="width: 150px;float: right">                                    <span class="input-group-btn">                                    <button type="button" class="btn btn-md btn-primary"                                            onclick="units.search()"> 搜索</button>                                    <button type="reset" class="btn btn-md btn-primary" style="margin-left: 10px"                                            name="resetBtn"> 重置</button> </span>                                </div>                            </div>                        </form>                        <hr>                        <div class="table-responsive">                            <table id="table" class="table table-condensed" data-mobile-responsive="true"></table>                        </div>                    </div>                </div>            </div>        </div>    </div>    </body>@endsection@section('footer')    <script>        var units = {            search: function () {                tips.selectPage();            },            getIdsBySelections: function () {                var selections = $("#table").bootstrapTable('getSelections');                var ids = [];                $.each(selections, function (inx, val) {                    ids.push(val.id);                });                return ids;            },            save: function (id) {                layer.open({                    type: 2,                    content: ['/admin/system/user/show/' + id],                    area: ['60%', '100%'],                    title: '保存'                });            },            permission: function (userId) {                var params = '?userIds[]=' + userId;                layer.open({                    type: 2,                    content: '/admin/system/user-permissions' + params,                    area: ['50%', '100%'],                    title: '详情'                });            }        };        var config = {};        config.url = '/admin/system/users';        config.columns = [ //字段            {checkbox: true},            {                title: '序号', align: 'center', formatter: function (value, item, index) {                    return index + 1;                }            },            {title: '昵称', field: 'nickname', align: 'center'},            {title: '用户名', field: 'username', align: 'center'},            {                title: '头像', field: 'profile_img', align: 'center', formatter: function (value, item) {                    return'<img src="'+value+'" style="width:64px">';                }            },            {title: '邮箱', field: 'email', align: 'center'},            {title: '角色', field: 'role_name', align: 'center'},            {title: '状态', field: 'status_title', align: 'center'},            {title: '创建时间', field: 'created_at', align: 'center'},            {                title: '操作', field: 'id', align: 'center',                formatter: function (value, rows) {                    var str = '<button onclick="units.save(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button> ';                    if ([5, 23].indexOf(rows.role_id) !== -1) { //客户                        str += '<button onclick="units.permission(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>权限</button>';                    }                    return str;                }            }        ];        tips.bootstrapTable(config);        $(document).on('click', '#on', function () {            var ids = units.getIdsBySelections();            if (ids.length === 0) {                layer.alert('请先选择您所要操作的对象', {icon: 0});                return;            }            tips.ajax({url: '/admin/system/users/on', type: 'put', data: {ids: ids}});            tips.tableRefresh('#table');        });        $(document).on('click', '#off', function () {            var ids = units.getIdsBySelections();            if (ids.length === 0) {                layer.alert('请先选择您所要操作的对象', {icon: 0});                return;            }            tips.ajax({url: '/admin/system/users/off', type: 'put', data: {ids: ids}});            tips.tableRefresh('#table');        });        $(document).on('click', '#batchDelete', function () {            var ids = units.getIdsBySelections();            if (ids.length === 0) {                layer.alert('请先选择您所要操作的对象', {icon: 0});                return;            }            layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function () {                tips.ajax({url: '/admin/system/users', type: 'delete', data: {ids: ids}, tableRefresh: '#table'});            });        });    </script>@endsection
 |