#
mrzhssss
2022-03-17 c6fb95d1be6057a569a3e2ba8c983c1de72c3264
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>仓储管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="icon" type="image/x-icon" href="../static/image/logo1.png" />
    <link rel="stylesheet" href="../static/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../static/css/admin.css?v=318" media="all">
    <link rel="stylesheet" href="../static/css/loader.css" media="all">
    <link rel="stylesheet" href="../static/css/originTable.css" media="all">
    <style>
        .layui-logo cite {
            font-size: 21px;
            font-weight: 500;
            position: relative;
            margin-left: 5px;
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <!-- 头部 -->
    <div class="layui-header">
      <div class="layui-logo">
          <img src="../static/image/logo2.png"/>
          <cite>&nbsp;Wms&nbsp;Admin&nbsp;</cite>
      </div>
      <!-- 左 -->
      <ul class="layui-nav layui-layout-left">
        <li class="layui-nav-item" lay-unselect>
          <a ew-event="flexible" title="侧边伸缩"><i class="layui-icon layui-icon-shrink-right"></i></a>
        </li>
        <li class="layui-nav-item" lay-unselect>
          <a ew-event="refresh" title="刷新"><i class="layui-icon layui-icon-refresh-3"></i></a>
        </li>
      </ul>
      <!-- 右 -->
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item" lay-unselect>
          <a id="hostName"></a>
        </li>
        <li class="layui-nav-item" lay-unselect>
          <a id="toDataV" title="数据中心"><i class="layui-icon layui-icon-chart-screen"></i></a>
        </li>
        <li class="layui-nav-item" lay-unselect>
          <a ew-event="note" title="便签"><i class="layui-icon layui-icon-note"></i></a>
        </li>
        <li class="layui-nav-item layui-hide-xs" lay-unselect>
          <a ew-event="fullScreen" title="全屏"><i class="layui-icon layui-icon-screen-full"></i></a>
        </li>
        <li class="layui-nav-item" lay-unselect>
          <a>
            <cite id="username" style="margin-right: 5px">管理员</cite>
          </a>
          <dl class="layui-nav-child">
            <dd lay-unselect><a ew-href="detail.html?resourceId=8">基本资料</a></dd>
            <hr>
            <dd lay-unselect><a id="logout">退出</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item" lay-unselect>
          <a ew-event="theme" title="主题"><i class="layui-icon layui-icon-more-vertical"></i></a>
        </li>
      </ul>
    </div>
 
    <!-- 侧边栏 -->
    <div class="layui-side">
      <div class="layui-side-scroll">
        <ul id="menu-main" class="layui-nav layui-nav-tree arrow2" lay-filter="admin-side-nav" lay-shrink="_all">
        </ul>
      </div>
    </div>
 
    <!-- 主体部分 -->
    <div class="layui-body"></div>
    <!-- 底部 -->
    <div class="layui-footer layui-text">
        copyright © 2021 浙江中扬立库技术有限公司 all rights reserved.
        <span class="pull-right">Version 1.0.0</span>
    </div>
 
</div>
 
<!--初始化加载层-->
<div class="layuimini-loader">
    <div class="layuimini-loader-inner"></div>
</div>
 
<script type="text/javascript" src="../static/js/jquery/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../static/layui/layui.js"></script>
<script type="text/javascript" src="../static/js/handlebars/handlebars-v4.5.3.js"></script>
<script type="text/javascript" src="../static/js/common.js"></script>
<script>
    console.log('%c WMS %c 1.0.0','background-color:rgb(53,73,94);color: #fff;border-radius:2px 0 0 2px;padding:2px 4px;','background-color:rgb(25,190,107);color: #fff;border-radius:0 2px 2px 0;padding:2px 4px;font: 9pt "Apercu Regular", Georgia, "Times New Roman", Times, serif;');
    $(function () {
        if ("" === localStorage.getItem('token')) {
            top.location.href = baseUrl + "/login";
        }
    });
 
    layui.config({
        base: baseUrl + "/static/layui/lay/modules/"
    }).use(['index','element', 'layer', 'table', 'admin'], function () {
        var $ = layui.jquery;
        var index = layui.index;
        var element = layui.element;
        var layer = layui.layer;
        var admin = layui.admin;
        var table = layui.table;
 
        $.ajax({
            url: baseUrl + "/menu/auth",
            headers: {'token': localStorage.getItem('token')},
            method: 'POST',
            success: function (res) {
                $('.layuimini-loader').fadeOut();
                if (res.code === 200) {
                    var tpl = $('#menuTpl').html();
                    var template = Handlebars.compile(tpl);
                    var html = template(res);
                    $("#menu-main").html(html);
                    element.init();
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/login";
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }
        });
 
        // 检测是否为超级管理员
        $.ajax({
            url: baseUrl + "/show/host.action",
            headers: {'token': localStorage.getItem('token')},
            method: 'GET',
            success: function (res) {
                if (res.code === 200) {
                    if (!isEmpty(res.data.hostName)) {
                        $('#hostName').text(res.data.hostName);
                    }
                    if (res.data.root) {
                        showHost();
                    }
                } else if (res.code === 403) {
                    top.location.href = baseUrl + "/login";
                } else {
                    layer.msg(res.msg, {icon: 2});
                }
            }
        });
 
        // 默认加载主页
        index.loadHome({
            menuPath: baseUrl+'/views/home/console.html',
            menuName: '<i class="layui-icon layui-icon-home"></i>'
        });
 
        $('#username').text(localStorage.getItem('nickname'));
 
        $(document).on('click','#logout', function () {
            window.location.href = "login.html";
            localStorage.removeItem('token');
            localStorage.removeItem('nickname');
            admin.closeAllTabs();
        });
 
        // 替换退出按钮变量
        var logout = document.getElementById('logout');
        var url = logout.getAttribute('href');
        logout.setAttribute('href', baseUrl + "/login");
 
        // 数据中心
        $('#toDataV').click(function () {
            window.open(baseUrl + "/datav");
        })
 
        // 多商户模式
        function showHost() {
            // var dele = layer.msg('正在删除', {icon: 16, time: 10000}, function(){
            //     layer.msg('成功删除', {icon: 1})
            // });
            admin.open({
                type: 1,
                title: '商户选择',
                area: '250px',
                offset: 'r',
                shade: false,
                shadeClose: true,
                content: '<table id="originTable" lay-filter="originTable"></table>',
                success: function (layero) {
                    var insTb = table.render({
                        elem: '#originTable',
                        url: baseUrl + '/host/list/auth',
                        height: 'full-600',
                        headers: {token: localStorage.getItem('token')},
                        request: {
                            pageName: 'curr',
                            pageSize: 'limit'
                        },
                        parseData: function (res) {
                            return {
                                'code': res.code,
                                'msg': res.msg,
                                'count': res.data.total,
                                'data': res.data.records
                            }
                        },
                        response: {
                            statusCode: 200
                        },
                        defaultToolbar: [],
                        cols: [[
                            {field: 'id', title: '编号', width: 70, align: 'center'},
                            {field: 'name', title: '项目名称'}
                        ]],
                        done: function (res, curr, count) {
                            $('.layui-table, .layui-table-view').css("margin", 0);
                            // $('#originTable+.layui-table-view .layui-table-body tbody>tr:first').trigger('click');
                        }
                    });
                    /* 监听行单击事件 */
                    table.on('row(originTable)', function (obj) {
                        obj.tr.addClass('layui-table-click').siblings().removeClass('layui-table-click');
                        // 检测是否为超级管理员
                        $.ajax({
                            url: baseUrl + "/root/change/host/auth?hostId="+obj.data.id,
                            headers: {'token': localStorage.getItem('token')},
                            method: 'GET',
                            success: function (res) {
                                if (res.code === 200) {
                                    window.location.reload();
                                } else if (res.code === 403) {
                                    top.location.href = baseUrl + "/login";
                                } else {
                                    layer.msg(res.msg, {icon: 2});
                                }
                            }
                        });
                    });
                }
            });
        }
 
    });
</script>
<script type="text/html" id="menuTpl">
    {{#each data}}
    <li class="layui-nav-item">
        <a><i class="layui-icon {{this.menuIcon}}"></i>&emsp;<cite>{{this.menu}}</cite></a>
        <dl class="layui-nav-child">
            {{#each this.subMenu}}
            <dd><a lay-href="{{this.code}}?resourceId={{this.id}}">{{this.name}}</a></dd>
            {{/each}}
        </dl>
    </li>
    {{/each}}
</script>
</body>
</html>