<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>添加</title>
<%@ include file="/include/header.jsp"%>
<link type="text/css" rel="stylesheet" href="${ctx}/css/baseFrame.css" />
</head>
<body class="">
	<div> <!--class="dialog_main"-->
		<div class="b_box">
			<form id="sysRoleForm" action="post">
				<input type="hidden" name="CSRFToken" value="${csrfToken}" />
				<table class="c_table m_t10">
					<tr>
						<td class="t_tit">角色名称</td>
						<td><input type="text" id="roleName" name="roleName" data-validaterole="sysroleName" data-rule="sysroleName" data-param='{"code" : "mmm","ml":20}' data-message='最大不能超过<!=ml!>' value="" /></td>
					</tr>
					<tr>
						<td class="t_tit">描述</td>
						<td><input type="text" id="remark" name="remark" value="" /></td>
					</tr>
				</table>
			</form>
		</div>
		<div class="action_box m_t10 t_c">
			<input type="button" class="b_btn" id="addBtn" value="保存" />
		</div>
	</div>

	<script type="text/javascript">
	// 验证
	seajs.use(["component/validate", "component/tip"], function(validate, tip) {
		var ntip = function() {
			// 定义一个提示对象
			return new tip({});
		};

		// 定义一个验证对象
		var d = new validate({
			con: "#adminRankForm",
			// 验证容器
			ntip: ntip,
			onSubmit: "#addBtn" // 提交按钮
		});

		// 设置拼装规则: 这里加上各个验证规则
		d.setValidateRule({ sysroleName: ["isBlank", "checkLen"] });
	
		// 注册保存按钮事件
		d.bind("onsubmit", function() {
			if (confirm('确定提交审批？')) {
				// 序列化表单参数
				var serializedForm = $("#sysRoleForm").serialize();
				$.post("${ctx}/sysRole/add.do", serializedForm, function(result) {
					if ("succ" == result) {
						alert("操作成功");
						// 刷新列表页面
						parent.location.replace("${ctx}/sysRole/list.do?ts=" + new Date().getTime()); //如果发表成功则跳到列表界面 
						// 关闭弹窗窗口
						parent.sysRoleDialog.close();
					} else if ("notThroughSecurityCheck" == result["isThroughSecurityCheck"]) { // 如果不通过安全检查
						var mess = result["mess"];
						$.post("${ctx}/common/notThroughSecurityCheck.do?ts=" + new Date().getTime(), mess, function(res) {
							alert(res);
						}, "json");

					} else {
						alert(result.mess);
					}
				},
				"json");
			}
	
		});
	});
	</script>
</body>
</html>