<%@ page language="java" import="java.util.*" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Open Park</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="<%=path%>/static/css/font.css">
    <link rel="stylesheet" href="<%=path%>/static/css/xadmin.css">
    <script type="text/javascript" src="<%=path%>/static/js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="<%=path%>/static/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="<%=path%>/static/js/xadmin.js"></script>
    <script>
        var index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
        $(function(){
            var flag = "${flag }";
            if(flag == 1){
                parent.location.reload();
                parent.layer.close(index); //执行关闭
            }
        });
    </script>
</head>

<body>
<div class="x-body">
    <form class="layui-form layui-form-pane" id="editForm" action="<%=path %>/user/update" method="post">
        <input type="hidden" value="${role.id}" name="id">
        <div class="layui-form-item">
            <label for="name" class="layui-form-label">
                <span class="x-red">*</span>角色名
            </label>
            <div class="layui-input-inline">
                <input type="text" id="role" name="role" value="${role.role}" required="" lay-verify="required"
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">
                拥有权限
            </label>
            <table class="layui-table layui-input-block">
                <tbody>
                <c:forEach items="${menuList}" var="menu">
                <tr>
                    <c:if test="${menu.checked == 1}">
                        <td>
                                ${menu.name}
                            <input name="permission" type="checkbox" value="${menu.id}" checked>

                        </td>
                    </c:if>
                    <c:if test="${menu.checked == 0}">
                        <td>
                                ${menu.name}
                            <input name="permission" type="checkbox" value="${menu.id}">

                        </td>
                    </c:if>
                    <td>
                        <div class="layui-input-block">
                            <c:forEach items="${permissionList}" var="p">
                                <c:if test="${p.parentid == menu.id && p.checked == 1}">
                                    <input name="permission" type="checkbox" value="${p.id}"
                                           checked> ${p.name}
                                </c:if>
                                <c:if test="${p.parentid == menu.id && p.checked == 0}">
                                    <input name="permission" type="checkbox" value="${p.id}"> ${p.name}
                                </c:if>
                            </c:forEach>
                        </div>
                    </td>
                </tr>
                </c:forEach>
                </tbody>
            </table>
        </div>
        <div class="layui-form-item layui-form-text">
            <label for="desc" class="layui-form-label">
                描述
            </label>
            <div class="layui-input-block">
                <textarea placeholder="请输入内容" id="description" name="description"
                          class="layui-textarea">${role.description}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <button class="layui-btn" lay-submit="" lay-filter="edit">修改</button>
        </div>
    </form>
</div>
<script>
    //监听提交
    form.on('submit(edit)', function (data) {
        $("#editForm").submit();
    });


    })
    ;
</script>
</body>

</html>