huawei
4 天以前 5b1ced24cc4a7a3f873ff685f3a5e5c9f2d5441a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>看板目录</title>
    <script src="js/layui/layui.js"></script>
    <link rel="stylesheet" type="text/css" href="js/layui/css/layui.css" />
    <style>
        /* 全局布局设置 */
        html, body {
            height: 100%;
            margin: 0;
            padding: 0;
        }
 
        body {
            /* 背景灰色饱和度稍微调高一点,偏冷灰,更具现代感 */
            background-color: #e3e5e8; 
            font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
            display: flex;
            flex-direction: column; /* 垂直排列 */
        }
 
        /* 头部样式 */
        .header {
            background: #fff;
            padding: 15px 0;
            text-align: center;
            box-shadow: 0 2px 5px rgba(0,0,0,0.05);
            flex-shrink: 0; /* 防止被压缩 */
        }
        .header h1 {
            margin: 0;
            font-size: 22px;
            color: #333;
            font-weight: 600;
            letter-spacing: 1px;
        }
 
        /* 中间容器(卡片)样式 */
        .container-wrapper {
            flex: 1; /* 占据剩余空间,确保页脚沉底 */
            display: flex;
            justify-content: center; /* 水平居中 */
            align-items: flex-start; /* 顶部对齐 */
            padding: 20px;
        }
 
        .container {
            background: #fff;
            width: 100%;
            /* 卡片稍微小一点,限制最大宽度 */
            max-width: 700px; 
            min-height: 400px;
            border-radius: 8px; /* 圆角 */
            /* 柔和的阴影 */
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); 
            padding: 25px 20px;
            box-sizing: border-box;
        }
 
        /* 优化 Layui Tree 的显示 */
        .layui-tree-entry {
            height: 36px; /* 增加行高,方便点击 */
        }
        .layui-tree-txt {
            font-size: 15px; /*字体稍微大一点 */
            color: #555;
        }
 
        /* 底部样式 */
        .footer {
            text-align: center;
            padding: 15px 0 25px 0;
            color: #999;
            font-size: 12px;
            flex-shrink: 0; /* 防止被压缩 */
        }
        .footer h4 {
            font-weight: normal;
            margin: 0;
        }
    </style>
</head>
<body>
    <!-- 头部 -->
    <div class="header">
        <h1>看板目录</h1>
    </div>
 
    <!-- 中间部分 -->
    <div class="container-wrapper">
        <div class="container">
            <!-- 树形菜单容器 -->
            <div id="menuTree"></div>
        </div>
    </div>
 
    <!-- 底边 -->
    <div class="footer">
        <h4>&copy; 宁波广深科技有限公司</h4>
    </div>
 
    <script type="text/javascript">
        layui.use(["tree", "jquery", "layer"], function () {
            var tree = layui.tree,
                layer = layui.layer,
                $ = layui.jquery;
 
            // 加载 Loading 动画
            var loadIndex = layer.load(2, {shade: [0.1, '#fff']});
 
            $.ajax({
                url: "http://localhost:5204/simple/getTree",
                type: "POST",
                dataType: "json",
                success: function (res) {
                    layer.close(loadIndex); // 关闭 Loading
                    
 
                    if (res.code === 0) {
                        tree.render({
                            elem: "#menuTree",
                            data: res.data,
                            id: 'treeId',
                            
                            // 禁止自动跳转,完全由 click 事件接管
                            isJump: false, 
                            // 仅点击图标展开,点击文字触发 click 事件
                            onlyIconControl: true, 
                            
                            click: function(obj){
                                var data = obj.data;
                                console.log("点击节点类型判断:", data.nodeType);
                            console.log("nodeType:", data.nodeType, "url:", data.url);
 
                                // 1. 为 0 不能点击(目录/分组)
                                if (data.nodeType === 0) {
                                    // 只是提示,不做跳转
                                    layer.msg("请选择具体的看板项目", {icon: 0, time: 1500});
                                    return; 
                                } 
                                if (data.nodeType === 2|data.nodeType === 1) {
                                    // 逻辑交由 bi_view.html 处理(它会判断自己URL或子项URL)
                                    // 只要是类型1或2,就允许进入 bi_view.html
                                    window.location.href = "bi_view.html?menuId=" + data.id + "&lbsj=10";
                                }
                            }
                        });
                    } else {
                        layer.msg("数据加载失败: " + res.msg, {icon: 2});
                    }
                },
                error: function(){
                    layer.close(loadIndex);
                    layer.msg("接口请求失败,请检查后端服务是否启动", {icon: 2});
                }
            });
        });
    </script>
</body>
</html>