var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
	$("#cancleAdd").click(function(){
		parent.layer.close(index);
	});
	$("#addRole").click(function(){
		var roleName=$("#roleName").val();
		roleName=roleName.replace(/(^\s*)|(\s*$)/g, '');
		var re = /^[\u4e00-\u9fa5a-z0-9]+$/;//只能输入汉字和英文字母
		if (!re.test(roleName)) {
			layer.tips('角色名非法', '#roleName', {
				  tips: [1, 'red'] //还可配置颜色
				});
			$("#roleName").val("");
			$("#roleName").prop("placeholder","角色名由汉字、数字、字母组成");
		  } else {
			  var roleD=$("#roleDescription").val();
			  roleD=roleD.replace(/(^\s*)|(\s*$)/g, '');
			  $.ajax({
				  url:'/pqs9200/role/addRole',
				  type:'POST',
				  dataType:"text",
				  data:{
						roleName:roleName,
			  			roleD:roleD
					},
				 success:function(data){
					//没有权限的请求
						if(data==300){
							location.href='/pqs9200/auth/unauthorized';
						//没有登陆的请求
						}else if(data==301){
							location.href='/pqs9200';
						}else{
							var info = $.parseJSON(data);
							if(info.code!=200){
								layer.msg(info.message, {icon: 5});
							}else{
								layer.msg(info.message, {
									  icon:6,
									  time: 1000 
									}, function(){
										parent.layer.close(index);
									}); 
							}
						}	
				 }  
			  });
		  }
	});