<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:mo="https://gitee.com/aun/Timo">
    <head th:replace="/common/template :: header(~{::title},~{::link},~{::style})">
        <link rel="stylesheet" th:href="@{/lib/zTree_v3/css/zTreeStyle/zTreeStyle.css}" type="text/css">
    </head>
    <body class="timo-layout-page">
        <div class="layui-card timo-tree" th:attr="data-url=@{'/api/rbac/menu/' + ${enabled}}">
            <div class="layui-card-header timo-card-header">
                <span>
                    <i class="fa fa-bars"></i>
                    资源管理
                </span>
                <i class="layui-icon layui-icon-refresh refresh-btn"></i>
            </div>
            <div class="layui-card-body layui-row">
                <div class="layui-col-lg2 layui-col-sm3">
                    <div class="layui-card timo-nav-tree">
                        <div class="layui-card-header">资源目录树</div>
                        <div class="layui-card-body">
                            <ul class="ztree"></ul>
                        </div>
                    </div>
                </div>
                <div class="layui-col-lg10 layui-col-sm9">
                    <div class="layui-row timo-card-screen">
                        <div class="pull-left layui-form-pane timo-search-box">
                            <div class="layui-inline">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-block timo-search-status">
                                    <select id="getByStatus" class="timo-search-select" name="enabled" onchange="getListByStatus()"
                                            mo:dict="MENU_STATUS" mo-selected="${enabled}"></select>
                                </div>
                            </div>
                        </div>
                        <div class="pull-right screen-btn-group">
                            <button class="layui-btn open-popup popup-add" data-title="添加资源"
                                    th:attr="data-url=@{/rbac/menu/add}">
                                <i class="fa fa-plus"></i>
                                添加
                            </button>
                            <div class="btn-group">
                                <button class="layui-btn">操作
                                    <span class="caret"></span>
                                </button>
                                <dl class="layui-nav-child layui-anim layui-anim-upbit">
                                    <dd>
                                        <a class="ajax-status" th:href="@{/api/rbac/menu/status/1}">启用</a>
                                    </dd>
                                    <dd>
                                        <a class="ajax-status" th:href="@{/api/rbac/menu/status/0}">停用</a>
                                    </dd>
                                </dl>
                            </div>
                        </div>
                    </div>
                    <div class="timo-table-wrap">
                        <table class="layui-table timo-table timo-tree-table">
                            <thead>
                                <tr>
                                    <th class="timo-table-checkbox">
                                        <label class="timo-checkbox">
                                            <input type="checkbox">
                                            <i class="layui-icon layui-icon-ok"></i>
                                        </label>
                                    </th>
                                    <th>名称</th>
                                    <th>URL 地址</th>
                                    <th>菜单类型</th>
                                    <th>可访问的角色</th>
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody class="tree-hide">
                                <tr class="{{$hide}}" tree-pid="{{pid}}" tree-id="{{id}}">
                                    <td>
                                        <label class="timo-checkbox">
                                            <input type="checkbox" value="{{id}}">
                                            <i class="layui-icon layui-icon-ok"></i>
                                        </label>
                                    </td>
                                    <td>{{name}}</td>
                                    <td>{{url}}</td>
                                    <td>{{type}}</td>
                                    <td>
                                        <a class="open-popup" data-title="已授予的角色"
                                           th:attr="data-url=@{'/rbac/menu/roleList/{{id}}'}" data-size="800,600"
                                           href="#">查看</a>
                                    </td>
                                    <td>
                                        <a class="open-popup popup-edit" data-title="编辑资源"
                                           th:attr="data-url=@{'/rbac/menu/edit/{{id}}'}" href="#">编辑
                                        </a>
                                        <a class="open-popup" data-title="详细信息"
                                           th:attr="data-url=@{'/rbac/menu/detail/{{id}}'}"
                                           data-size="800,600" href="#">详细
                                        </a>
                                        <a class="ajax-delete popup-delete" th:attr="data-msg='确定要删除 {{name}}?'"
                                           th:href="@{'/api/rbac/menu/{{id}}'}">删除
                                        </a>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <script th:replace="/common/template :: script"></script>
        <script type="text/javascript" th:src="@{/js/plugins/jquery-2.2.4.min.js}"></script>
        <script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.core.min.js}"></script>
        <script type="text/javascript" th:src="@{/lib/zTree_v3/js/jquery.ztree.exedit.min.js}"></script>
        <script type="text/javascript" th:src="@{/js/timoTree.js}"></script>
        <script type="text/javascript">
            $.fn.timoTree();
            function getListByStatus() {
                var selectedOption = $("#getByStatus option:selected")
                var param = selectedOption.text()
                url = '?enabled=' + param
                window.location.href = window.location.pathname + url;
            }
        </script>
    </body>
</html>