<!DOCTYPE html>
<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8" />
<title>工作流</title>
</head>
<body>
	<div>
		<span>填写请假单</span>
		<input id="title" placeholder="题目" /><br />
		<input id="days" placeholder="请假天数" /><br />
		<textarea id="content" placeholder="内容" rows="10"></textarea>
		<button onclick="submit()">提交</button>
	</div>
</body>
</html>

<style>
* {
	font-family: "微软雅黑";
	font-size: 15px;
	margin: 0 auto;
}
div{
	width: 400px;
	margin-top:100px;
	text-align:center;
	padding-top:10px;
}
input,textarea,button{
	padding: 3px;
	margin-top:10px;
}
input, textarea {
	width: 400px;
	border: 1px solid #ccc;
	border-radius: 4px;
}

button {
	width: 408px;
}
</style>

<script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script>
	function submit() {
		var operator = getUser();
		if(operator == ""){
			location.href = "/";
		}
		$.ajax({
			url : "/writeForm",
			data : {
				"title" : $("#title").val(),
				"content" : $("#content").val(),
                "days" : $("#days").val(),
				"operator" : operator
			},
			success : function(data) {
				if(data.code == 200){
					location.href="/home";
				}
			}
		});
	}
	
	function getUser(){
		var name="userInfo=";
		var user = "";
		var ca = document.cookie.split(';');
		$.each(ca, function(i, item){
			if(item.indexOf(name) != -1){
				user = item.substring(name.length,item.length);
			}    
		});
		return user;
	}
</script>