<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>部门管理</title>
    <link rel="stylesheet" href="/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <link rel="stylesheet" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <style>
        .site-dropdown-demo .layui-menu li:hover{background-color: #333;}
    </style>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <!-- 上方搜索栏 -->

        <!-- 表格 -->
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;"> <legend>企业架构</legend>
        </fieldset>
        <div id="test9" class="demo-tree demo-tree-box"></div>
        <table class="layui-hide" id="table-data" lay-filter="table-data"></table>
    </div>
</div>


<!--引入JS文件-->
<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(['table','dropdown', 'util', 'layer','form','tree'], function () {
        let dropdown = layui.dropdown,
            util = layui.util,
            layer = layui.layer,
            $ = layui.jquery,
            form = layui.form,
            tree = layui.tree,
            table = layui.table;




        $(document).ready(function () {
            loadTree()
            function loadTree(){
                $.get('/cloud/account/department/query', function (data) {
                    if (data.code === 200) {
                        let dataMap = data.data
                        tree.render({
                            elem: '#test9'
                            ,data: dataMap
                            ,showLine: false  //是否开启连接线
                            ,onlyIconControl: true
                            ,click: function(obj){
                                if(obj.data.companyId!=null){
                                    layer.confirm('确认要转入该 <b>' + obj.data.departmentName + ' </b>吗？', {
                                        title: false,
                                        btn: ['确定', '取消'],
                                        closeBtn: 0,        // 不显示右上角的关闭按钮
                                        // 按钮【确定】的回调
                                        btn1: function (index) {
                                            window.parent.parentOpen('[[${user.id}]]',obj.data.id);
                                            layer.close(index)
                                        },
                                    });

                                }

                            },
                        });
                    }else {
                        layer.msg(data.msg, {offset: 't', icon: 2});
                    }
                });
            }


            /*$.get('/cloud/account/company/query', function (data) {
                if (data.code === 200) {
                    let dataMap = data.data
                    dataMap.forEach(function (d) {
                        $("#companyId").append(
                            ' <option value="${d.id}" title="${d.companyName}">${d.companyName}</option>`
                        )
                    })
                    form.render('select');
                }else {
                    layer.msg(data.msg, {offset: 't', icon: 2});
                }
            });*/
        })




    });

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