<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>编辑信息</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <!-- 引入 dtree 相关资源 -->
    <link rel="stylesheet" href="/js/lay-module/dtree/dtree.css">
    <link rel="stylesheet" href="/js/lay-module/dtree/font/dtreefont.css">
    <!-- 引入 font-aswsome 相关资源 -->
    <link rel="stylesheet" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">权限名称<span style="color:red"> *</span></label>
                    <div class="layui-input-inline" style="width: 200px">
                        <input type="text" name="roleName" id="roleName" placeholder="请输入权限名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">授权目录</label>
                    <div class="layui-input-inline" style="width: 200px">
                        <input type="text" id="userName" name="userName" placeholder="请选择" onclick="selectDepartment();" readonly="readonly" autocomplete="off" class="layui-input">
                        <input type="hidden" id="ids" name="ids">
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>
<script src="/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script src="/js/jquery-1.10.2.min.js" charset="utf-8"></script>
<script>
    layui.use(['form',"layer"], function () {
        let $ = layui.jquery,
            form = layui.form,
            layer = layui.layer,
            table = layui.table;







        getData();

        function getData(){
            $.ajax({
                type:"get",
                data:{"id":'[[${id}]]'},
                dataType:"json",
                url:"/cloud/role/getData",
                success:function(data){
                    $("#roleName").val(data.data.roleName)
                    getFileRole()
                }
            })
        }
    });

    function selectDepartment(){
        layerOpen = layer.open({
            title: '选择授权目录',
            type: 2,
            shade: 0.2,
            maxmin: true,
            shadeClose: false,
            area: ['700px', '600px'],
            content: '/cloud/space/updateAuthFile/'+'[[${id}]]',
            btn: ['确定', '取消'],
        });
    }
    function getFileRole(){
        let dataSet = {
            "id" : '[[${id}]]'
        }
        $.get('/cloud/space/getRoleFile',dataSet, function (data) {
            if (data.code === 200) {

                $("#userName").val(data.data.name)
                $("#ids").val(data.data.ids)
            }else {
                layer.msg(data.msg, {offset: 't', icon: 2});
            }
        });

    };

    function parentData(name,ids) {
        $("#userName").val(name)
        $("#ids").val(ids)

    }
</script>
</body>
</html>
