<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<meta name="description" content="Xenon Boostrap Admin Panel" />
	<meta name="author" content="" />
	<title>系统角色管理</title>
</head>
<body class="page-body">
	<div class="page-container">
		<%@ include file="../../common/menu.jsp"%>
		<div class="main-content">
			<%@ include file="../../common/header.jsp"%>
			<div class="page-title">
				<div class="title-env">
					<h1 class="title">新增系统角色</h1>
				</div>
				<div class="breadcrumb-env">
					<ol class="breadcrumb bc-1">
						<li>
							<a href="javascript:;"><i class="fa-home"></i>系统管理</a>
						</li>
						<li class="active">
							<strong>新增系统角色</strong>
						</li>
					</ol>
				</div>
			</div>
			<!-- Removing search and results count filter -->
			<div class="row">
				<div class="col-sm-12">
					<div class="panel panel-default">
						<div class="panel-body">
							<form role="form" id="addUserForm" class="form-horizontal">
								<div class="form-group">
									<label class="col-sm-2 control-label" for="name">角色名</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="name" name="name" value="">
									</div>
								</div>
								<div class="form-group">
									<label class="col-sm-2 control-label" for="description">描述</label>
									<div class="col-sm-4">
										<input type="text" class="form-control" id="description" name="description" value=""  />
									</div>
								</div>
								<div class="form-group" style="display: none;">
									<label class="col-sm-2 control-label" for="description">数据权限</label>
									<div class="col-sm-4">
										<label class="radio-inline">
											<input type="radio" value="personal" name="data_level" style="margin-top: 2px;">
											仅查看自己相关
										</label>
										<label class="radio-inline">
											<input type="radio" value="all" checked="checked" name="data_level" style="margin-top: 2px;">
											查看所有
										</label>
									</div>
								</div>
								<div class="form-group-separator"></div>
								<div class="form-group">
									<div class="col-sm-6" style="text-align: center;">
										<button type="button" id="btn_save" class="btn btn-info" >保存</button>
										<button type="button" id="btn_cancel" class="btn btn-white" >返回</button>
										<input id="token" type="hidden" name="token" value="${SESSION_TOKEN }"/>
									</div>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
			<%@ include file="../../common/footer.jsp"%>
		</div>
	</div>
	
	<script type="text/javascript">
		$(function() {
			$("#btn_save").click(function(){
				var name = $("#name").val();
				if(!checkStr(name)){
					toastr.error("角色名不能为空", null, opts);
					return false;
				}
				
				$("#btn_save").attr("disabled","disabled");
				
				 $("#addUserForm").ajaxSubmit({  
		                type:'post',
		                dataType: "json",
		                url : "${ROOT_PATH}/sysRole/save.do",
		                success:function(data){  
		                	window.setTimeout("enableBtn('#btn_save');",Constants.reloadTime);
		                	if (data.result == '01') {
		                		toastr.success("新增成功", null, opts);
		                		window.location.href = '${ROOT_PATH}/sysRole';
		                	}else{
		                		toastr.error(data.msg, null, opts);
		                	}
		                },  
		                error:function(XmlHttpRequest,textStatus,errorThrown){
		                	window.setTimeout("enableBtn('#btn_save');",Constants.reloadTime);
		                	toastr.error(Constants.netError, null, opts);
		                }  
		            }); 
				
			});
			
			$("#btn_cancel").click(function(){
				history.back(-1);
			});
		});
	</script>
</body>
</html>