text: $().ready(function() {
  	validateRule();
  });
  
  $.validator.setDefaults({
  	submitHandler : function() {
  		save();
  	}
  });
  
  function save() {
      var formData = new FormData($("#signupForm")[0]);
      $.ajax({
  		type : "POST",
  		url : "/activiti/process/save",
          data: formData,
          async: false,
          cache: false,
          contentType: false,
          processData: false,
  		error : function(request) {
  			parent.layer.alert("Connection error");
  		},
  		success : function(data) {
  			if (data.code == 0) {
  				parent.layer.msg("操作成功");
  				parent.reLoad();
  				var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
  				parent.layer.close(index);
  
  			} else {
  				parent.layer.alert("操作失败")
  			}
  
  		}
  	});
  
  }
  function validateRule() {
  	var icon = "<i class='fa fa-times-circle'></i> ";
  	$("#signupForm").validate({
  		rules : {
  			name : {
  				required : true
  			},
  			username : {
  				required : true,
  				minlength : 2,
  				remote : {
  					url : "/sys/user/exit", // 后台处理程序
  					type : "post", // 数据发送方式
  					dataType : "json", // 接受数据格式
  					data : { // 要传递的数据
  						username : function() {
  							return $("#username").val();
  						}
  					}
  				}
  			},
  			password : {
  				required : true,
  				minlength : 6
  			},
  			confirm_password : {
  				required : true,
  				minlength : 6,
  				equalTo : "#password"
  			},
  			email : {
  				required : true,
  				email : true
  			},
  			topic : {
  				required : "#newsletter:checked",
  				minlength : 2
  			},
  			agree : "required"
  		},
  		messages : {
  
  			name : {
  				required : icon + "请输入姓名"
  			},
  			username : {
  				required : icon + "请输入您的用户名",
  				minlength : icon + "用户名必须两个字符以上",
  				remote : icon + "用户名已经存在"
  			},
  			password : {
  				required : icon + "请输入您的密码",
  				minlength : icon + "密码必须6个字符以上"
  			},
  			confirm_password : {
  				required : icon + "请再次输入密码",
  				minlength : icon + "密码必须6个字符以上",
  				equalTo : icon + "两次输入的密码不一致"
  			},
  			email : icon + "请输入您的E-mail",
  		}
  	})
  }
  
  var openDept = function(){
  	layer.open({
  		type:2,
  		title:"选择部门",
  		area : [ '300px', '450px' ],
  		content:"/system/sysDept/treeView"
  	})
  };
  function loadDept( deptId,deptName){
  	$("#deptId").val(deptId);
  	$("#deptName").val(deptName);
  }