<%@ page language="java" contentType="text/html;charset=UTF-8" trimDirectiveWhitespaces="true"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fastboot" prefix="fb"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://shiro.apache.org/tags" prefix="shiro"%>
<fb:ui src="base/main">

	<fb:property name="title">角色设置</fb:property>

	<fb:script type="text/javascript">
		<script>
			layui.use(['tool', 'xect','form'],function() {
						// 操作对象
					    var $ = layui.$,tool = layui.tool,xect = layui.xect,form = layui.form;
						// 初始赋值
					    form.val('inputForm', ${json});
					  	// 监听提交
					    form.on('submit(go)',function(data) {
					        console.log($("#inputForm").serializeArray());
					        tool.submit('${base}/role/submit', $("#inputForm").serializeArray());
					        return false;
					    });
					  	//
					    var tree = xect.render({
					    	el: '#tree', 
					    	name: 'ids',
					    	layVerify: 'required',
					    	layVerType: 'msg',
					    	tips: '请选择操作权限',
					    	autoRow: true,
					    	filterable: true,
					    	toolbar: {
					    		show: true,
					    		list: ['ALL', 'REVERSE', 'CLEAR']
					    	},
					    	filterable: true,
					    	height: 'auto',
					    	tree: {
					    		//是否显示树状结构
					    		show: true,
					    		//是否展示三角图标
					    		showFolderIcon: true,
					    		//是否显示虚线
					    		showLine: true,
					    		//间距
					    		indent: 30,
					    		//默认展开节点的数组, 为 true 时, 展开所有节点
					    		expandedKeys: [ -1 ],
					    		//是否严格遵守父子模式
					    		strict: false,
					    	},
					    	data: ${menus}
					    });
					    tree.setValue(${rolePermissions});
			});
		</script>

	</fb:script>

	<fb:layout>

		<div class="layui-card">
			<form id="inputForm" class="layui-form layui-form-pane xm-select-demo ly-label-center" action="" lay-filter="inputForm">

				<input type="hidden" name="id" />

				<div class="layui-form-item">
					<label class="layui-form-label">名称</label>
					<div class="layui-input-block">
						<input type="text" name="name" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入名称" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">描述</label>
					<div class="layui-input-block">
						<input type="text" name="description" lay-verify="required" lay-verType="tips" autocomplete="off" placeholder="请输入描述" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item layui-form-text">
					<label class="layui-form-label">角色权限</label>
					<div id="tree" class="layui-input-block"></div>
				</div>

				<button id="submit" lay-submit lay-filter="go" hidden="true" />
				<button id="reset" type="reset" hidden="true" />
			</form>
		</div>
	</fb:layout>
</fb:ui>