TLAdmin一个纯粹至简的后台权限开发系统

你是否会遇到开发一个小系统却要去选择各种功能强大而复杂的后台开发框架?
是否纠结自己写一个?
上网找了一圈却发现后台界面不甚是让人满意!


现在TLAdmin来了

TLAdmin,采用thinkphp5.1.x + layui
后台开发CURD简单到爆
例如、写个列表页是这样的
后端

public function index()
    {
        if ($this->request->isAjax()) {
            $limit = input('param.limit', 20, 'intval');
            $admin = new Admin();
            $where = [];
            $param = input('param.');
            if (!empty($param['q'])) {
                switch ($param['type']) {
                    case 1:
                        $where[] = ['username','like', '%' . $param['q'] . '%'];
                        break;
                    case 2:
                        $where[] = ['id', '=', intval($param['q'])];
                        break;
                }
            }
            $role_id = input('param.role_id', 0, 'intval');
            if ($role_id > 0) {
                $where[] = ['role_id', '=', $role_id];
            }
            $lists = $admin->with('Role')->where($where)->paginate($limit, false, ['query' => input('param.')]);
            return json([
                'code' => 0,
                'msg' => '',
                'count' => $lists->total(),
                'data' => $lists->items(),
            ]);
        } else {
            return $this->fetch();
        }
    }

前端页

{extend name="layout" /}
{block name="page"}
<div class="layui-card">
    <div class="tools">
        <div class="btns">
            <button class="layui-btn layui-btn-normal open" url="{:url('user/add')}">添加用户</button>
        </div>
        <div class="search">
            <form class="layui-form" method="get">
                <div class="layui-inline" style="width: 100px;">
                    <select name="type" lay-verify="type">
                        <option value="1" {eq name=":input('param.type')" value="1"}selected{/eq}>用户名</option>
                        <option value="2" {eq name=":input('param.type')" value="2"}selected{/eq}>id</option>
                    </select>
                </div>
                <div class="layui-inline">
                    <input type="text" name="q" placeholder="请输查询要素" autocomplete="off" class="layui-input" value="{:input('param.q')}">
                </div>
                <div class="layui-inline">
                    <button class="layui-btn">
                        <i class="layui-icon">&#xe615;</i>
                    </button>
                </div>
            </form>
        </div>
    </div>
    <div class="layui-card-body">
        <table id="dataTable" lay-filter="dataTable"></table>
    </div>
</div>
{/block}
{block name="js"}
<script type="text/html" id="lockTpl">
    {{#  if(d.lock == 0){ }}
    <span>正常</span>
    {{# }else{ }}
    <span class="danger">锁定</span>
    {{# } }}
</script>
<script type="text/html" id="toolBar">
    <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">编辑</a>
    {{# if(d.id>1){ }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    {{# } }}
</script>
<script>
    layui.config({
        base: '__STATIC__/js/'
    }).use(['app'], function () {
        var app=layui.app;
        var table=layui.table;
        table.render({
            elem: '#dataTable'
            ,url: window.location.href //数据接口
            ,page: app.page_config //开启分页
            ,cols: [[ //表头
                {field: 'id', title: 'ID', width:80}
                ,{field: 'username', title: '用户名', width:80}
                ,{field: 'role_name', title: '角色', width:135}
                ,{field: 'name', title: '姓名', width:135}
                ,{field: 'mobile', title: '手机', width: 180}
                ,{field: 'addtime', title: '添加时间', width: 150}
                ,{field: 'edit_password_time', title: '上次改密', width: 150}
                ,{title: '状态', width: 100,templet: '#lockTpl'}
                ,{field: 'lock_msg', title: '状态备注', width: 200}
                ,{title: '操作',width:220,toolbar:"#toolBar"}
            ]]
        });
        //监听工具条
        table.on('tool(dataTable)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'detail') {
                app.open('{:url("user/login_log")}?id=' + data.id, '查看登录日志:' + data.username);
            } else if (layEvent === 'del') {
                layer.confirm('真的要删除吗?', function (index) {
                    layer.close(index);
                    app.post({
                        id: data.id
                    }, 0, '{:url("user/del")}');
                });
            } else if (layEvent === 'edit') {
                app.open('{:url("user/edit")}?id=' + data.id, '编辑');
            }
        });
    });
</script>
{/block}

是不是清晰明了很简单!
我已经用他开发过很多小系统和网站后台...无往不利!
TLAdmin开源下载地址:https://gitee.com/boume/TLAdmin