<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-projectPlan-add">
        <input id="planCaseCount" name="planCaseCount" value="0"  type="hidden">
           <div class="form-group">	
				<label class="col-sm-3 control-label">项目名称：</label>
				<div class="col-sm-8">
					<select id="projectId" name="projectId" class="form-control m-b" th:with="type=${projects}" onchange="initializeModuleTree()">
	                    <option th:each="project : ${type}" th:text="${project.projectName}" th:value="${project.projectId}" th:selected="${project.projectId == defaultProjectId}"></option>
	                </select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">计划名称：</label>
				<div class="col-sm-8">
					<input id="planName" name="planName" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">备注：</label>
				<div class="col-sm-8">
					<textarea id="remark" name="remark" class="form-control" rows="8"></textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "testmanagmt/projectPlan";
		
		$.validator.setDefaults({
			ignore:":hidden:not(select)",
			submitHandler : function() {
				save();
			}
		});
		
		$("#form-projectPlan-add").validate({
			rules:{
				projectId:{
					required:true,
				},
				planName:{
					required:true,
        			maxlength: 50,
                    remote: {
                        url: prefix + "/checkProjectPlanNameUnique",
                        type: "post",
                        dataType: "json",
                        data: {
                            name: function () {
                                return $.common.trim($("#planName").val());
                            }
                        },
                        dataFilter: function (data, type) {
                        	return $.validate.unique(data);
                        }
                    }
				},
				remark:{
					maxlength:200
				}
			},
        	messages: {
                "planName": {
                    remote: "测试计划名称已经存在"
                }
            }
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-projectPlan-add').serialize());
	        }
	    }
	</script>
</body>
</html>
