<title>设为管理员</title>

<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a lay-href="">主页</a>
        <a><cite>用户管理</cite></a>
        <a><cite>设为管理员</cite></a>
    </div>
</div>

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-header">设为管理员</div>
                <div class="layui-card-body" pad15>
                    <form class="layui-form" wid100 lay-filter="LAY-info-form">
                        <div class="layui-fields">
                        </div>
                        <div class="layui-submit">
                            <div class="layui-form-item">
                                <div class="layui-input-block">
                                    <button class="layui-btn" lay-submit lay-filter="submit">确认</button>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    var config;
    layui.admin.req({
        url: '/manage/data/response.json',
        method: 'POST',
        data: {admin_role: 'select'},
        success: function (res) {
            config = {
                api: {
                    submit: '/manage/user/admin/set.json'
                },
                submitSuccess: function (res) {
                    layui.layer.msg(res.msg, function () {
                        location.hash = config.url.index;
                    })
                },
                fields: [
                    {name: 'user_id', key: 'user_id', type: 'hide', value: layui.router().search.id},
                    {name: '用户名', key: 'name', type: 'label', value: layui.router().search.name},
                    {name: '角色', key: 'role_id', type: 'select', extra: res.data.admin_role.select},
                    {name: '认证码', key: 'auth_code', type: 'password',},
                    {name: '重复认证码', key: 'auth_code_repeat', type: 'password',},
                ],
            };
            layui.use('curd/addOrEdit', layui.factory('curd/addOrEdit'));
        }
    });
</script>