<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../common/common.jsp" %>
<title>运营管理系统</title>
<script type="text/javascript" src="${staticPath}static/js/rolepermission.js"></script>
</head>
<body>
<%@ include file="../common/head.jsp" %>
<div class="wrapMain">
	<div class="laymid">
		<div class="wrap">
			<%@ include file="../common/left.jsp" %>
			<div class="mainWrap">
				<div class="content-inner">
					<div id="formError"></div>
					<form id="modfiyRolePermissionForm" onsubmit="return checkRolePermissionModfiy();">
					<ul class="ulFrm">
						<li>
							<span class="label labelW120 labelRight">角色：</span>
							<div class="select selectW120 {width:'120',onchange:changeSelect}">
								<select name="roleId" id="roleId">
									<option value="0">请选择</option>
								    <c:forEach items="${roleList }" var="item">
									   <option value="${item.roleId }">${item.name }</option>
									</c:forEach> 
								</select>
							</div>
						</li>
						
						<li>
							<span class="label labelW120 labelRight alignTop">菜单权限：</span>
							<ul class="auth inline">
								<c:forEach var="first" items="${permissionList}">
									<li>
										<input type="checkbox" name="permissionId" value="${first.permissionId }" class="parent checkbox {click:subAll}" /><label>${first.name }</label>
										<ul class="sub_auth">
											<c:forEach var="second" items="${first.subPerms}">
												<li><input type="checkbox" name="permissionId" value="${second.permissionId }" class="checkbox {click:subchildren} "><label>${second.name }</label></li>
											</c:forEach>
										</ul>
									</li>	
								</c:forEach>
							</ul>
						</li>
						<li class="p125"><input type="submit" name="submit" id="submit" class="btn" value="更新" /></li>
					</ul>
					</form>
				</div>
			</div>
		</div>
	</div>
</div>
<%@ include file="../common/footer.jsp" %>
<script type="text/javascript">
$(function(){
	resetText();
	$(".select").uiSelect();
	$(".checkbox").checkbox();
});
function subAll(obj){
	var input = $(obj).nextAll("ul").find("input[type=checkbox]");
	if($(obj).is(":checked"))
		input.check();
	else
		input.uncheck();
	$(".checkbox").checkbox();
}
function subchildren(obj){
	var input = $(obj).parents("ul");
	input.prev().prev().attr("checked",false);
	input.find("input[type=checkbox]").each(function(){
		if($(this).is(":checked")) input.prev().prev().attr("checked",true);
	});
	$(".checkbox").checkbox();
}
</script>
</body>
</html>