@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">
                            <div class="col-md-6 pull-right">
                                <div class="input-group">
                                    <input type="text" placeholder="请输入查询内容" class="input-md form-control"
                                           name="keyword" style="float: right;width: 150px;"
                                           id="keyWord" >
                                    <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;
            },
            permission: function (roleId) {
                var params = '?roleIds[]=' + roleId;
                layer.open({
                    type: 2,
                    content: ['/admin/system/roles/allot-permissions' + params],
                    area: ['40%', '100%'],
                    title: '分配权限'
                });
            },
            saveView: function (id) {
                layer.open({
                    type: 2,
                    content: ['/admin/system/roles/' + id],
                    area: ['60%', '40%'],
                    title: '保存'
                });
            }
        };

        var config = {};
        config.url = '/admin/logs';
        config.columns = [ //字段
            // {checkbox: true},
            {
                title: '序号', align: 'center', formatter: function (value, item, index) {
                    return index + 1;
                }
            },
            {title: '内容', field: 'content', align: 'center'},
            {title: '附加', field: 'addition', align: 'center'},
            {title: '操作人', field: 'operator_name', align: 'center'},
            {title: '时间', field: 'created_at', align: 'center'},
            // {
            //     title: '操作', field: 'id', align: 'center',
            //     formatter: function (value) {
            //         return (
            //             '<button onclick="units.saveView(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-edit"></span>编辑</button>&nbsp;' +
            //             '<button onclick="units.permission(' + value + ')" class="btn btn-xs"><span class="glyphicon glyphicon-menu-hamburger"></span>权限</button>'
            //         );
            //     }
            // }
        ];
        tips.bootstrapTable(config);


        $(document).on('click', '#batchDelete', function () {
            var ids = units.getIdsBySelections();
            if (ids.length === 0) {
                layer.alert('请先选择您所要操作的对象');
                return;
            }
            layer.confirm('您确定要删除吗?', {icon: 3, title: '删除信息'}, function () {
                tips.ajax({url: '/admin/system/roles', type: 'delete', data: {ids: ids}, tableRefresh: '#table'});
            });
        });


    </script>
@endsection