<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<link th:href="@{/ajax/libs/datapicker/bootstrap-datetimepicker.min.css}" rel="stylesheet"/>
<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-qaVersion-add">
			<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}">
	                    <option th:each="projects : ${type}" th:text="${projects.projectName}" th:value="${projects.projectId}" th:selected="${projects.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="versionNumber" name="versionNumber" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">版本状态：</label>
				<div class="col-sm-8">
					<select class="form-control m-b" id="versionStatus" name="versionStatus" th:with="type=${@dict.getType('qa_version_status')}">
						<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
					</select>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">负责人：</label>
				<div class="col-sm-8">
					<input id="leader" name="leader" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">开发人员：</label>
				<div class="col-sm-8">
					<input id="developer" name="developer" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">测试人员：</label>
				<div class="col-sm-8">
					<input id="tester" name="tester" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">计划完成日期：</label>
				<div class="col-sm-8">
					<input id="planFinishDate" name="planFinishDate" class="form-control" type="text" readonly>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">实际完成日期：</label>
				<div class="col-sm-8">
					<input id="actuallyFinishDate" name="actuallyFinishDate" class="form-control" type="text" readonly>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">上线日期：</label>
				<div class="col-sm-8">
					<input id="launchDate" name="launchDate" class="form-control" type="text" readonly>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">版本工期（天）：</label>
				<div class="col-sm-8">
					<input id="timeLimitVersion" name="timeLimitVersion" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">计划完成需求数：</label>
				<div class="col-sm-8">
					<input id="demandPlanFinish" name="demandPlanFinish" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">实际完成需求数：</label>
				<div class="col-sm-8">
					<input id="demandActuallyFinish" name="demandActuallyFinish" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">测试用例数：</label>
				<div class="col-sm-8">
					<input id="testcaseCount" name="testcaseCount" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">转测试打回次数：</label>
				<div class="col-sm-8">
					<input id="testingReturn" name="testingReturn" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">开发投入人力（人/天）：</label>
				<div class="col-sm-8">
					<input id="devHumanResources" name="devHumanResources" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">测试投入人力（人/天）：</label>
				<div class="col-sm-8">
					<input id="testHumanResources" name="testHumanResources" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">代码变动行数：</label>
				<div class="col-sm-8">
					<input id="changeLineCode" name="changeLineCode" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Bug数量 级别:致命：</label>
				<div class="col-sm-8">
					<input id="bugZm" name="bugZm" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Bug数量 级别:严重：</label>
				<div class="col-sm-8">
					<input id="bugYz" name="bugYz" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Bug数量 级别:一般：</label>
				<div class="col-sm-8">
					<input id="bugYb" name="bugYb" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">Bug数量 级别:提示：</label>
				<div class="col-sm-8">
					<input id="bugTs" name="bugTs" 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="qualityReview" name="qualityReview" class="form-control"></textarea>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">版本说明：</label>
				<div class="col-sm-8">
					<textarea id="imprint" name="imprint" class="form-control"></textarea>
				</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"></textarea>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script th:src="@{/ajax/libs/datapicker/bootstrap-datetimepicker.min.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "qualitymanagmt/qaVersion";
		
		$('#planFinishDate').datetimepicker({
			format: 'yyyy-mm-dd',
		    minView: "month",//设置只显示到月份
		    autoclose:true,//选中关闭
		    forceParse:true
		});
		
		$('#actuallyFinishDate').datetimepicker({
			format: 'yyyy-mm-dd',
		    minView: "month",//设置只显示到月份
		    autoclose:true,//选中关闭
		    endDate:new Date(),
		    forceParse:true
		});
		
		$('#launchDate').datetimepicker({
			format: 'yyyy-mm-dd',
		    minView: "month",//设置只显示到月份
		    autoclose:true,//选中关闭
		    endDate:new Date(),
		    forceParse:true
		});
		
		$("#form-qaVersion-add").validate({
			rules:{
				projectId:{
					required:true,
				},
				versionNumber:{
					required:true,
					maxlength: 40,
				},
				versionStatus:{
					required:true,
				},
				leader:{
					required:true,
        			maxlength: 20,
				},
				developer:{
					required:true,
        			maxlength: 40,
				},
				tester:{
					required:true,
        			maxlength: 40,
				},
				planFinishDate:{
					required:true,
				},
				actuallyFinishDate:{
					required: function(element) {
				        return $("#versionStatus").val() == '待上线' || $("#versionStatus").val() == '已完成';
					},
				},
				launchDate:{
					required: function(element) {
				        return $("#versionStatus").val() == '已完成';
					},
				},
				timeLimitVersion:{
					required: function(element) {
				        return $("#versionStatus").val() == '待上线' || $("#versionStatus").val() == '已完成';
					},
					isNumber:true,
					isFloatGtZero:true,
					max:10000
				},
				demandPlanFinish:{
					required: function(element) {
				        return $("#versionStatus").val() == '待上线' || $("#versionStatus").val() == '已完成';
					},
					isInteger:true,
					isIntGtZero:true,
					max:1000
				},
				demandActuallyFinish:{
					required: function(element) {
				        return $("#versionStatus").val() == '待上线' || $("#versionStatus").val() == '已完成';
					},
					isInteger:true,
					isIntGtZero:true,
					max:1000
				},
				testcaseCount:{
					isInteger:true,
					isIntGtZero:true,
					max:100000
				},
				testingReturn:{
					isInteger:true,
					isIntGtZero:true,
					max:100
				},
				devHumanResources:{
					isNumber:true,
					isIntGtZero:true,
					max:10000
				},
				testHumanResources:{
					isNumber:true,
					isIntGtZero:true,
					max:10000
				},
				changeLineCode:{
					isInteger:true,
					isIntGtZero:true,
					max:1000000
				},
				bugZm:{
					isInteger:true,
					isIntGtZero:true,
					max:10000
				},
				bugYz:{
					isInteger:true,
					isIntGtZero:true,
					max:10000
				},
				bugYb:{
					isInteger:true,
					isIntGtZero:true,
					max:10000
				},
				bugTs:{
					isInteger:true,
					isIntGtZero:true,
					max:10000
				},
				qualityReview:{
					maxlength: 1000,
				},
				imprint:{
					maxlength: 1000,
				},
				remark:{
					maxlength: 500,
				},
			},
			messages: {
				'actuallyFinishDate': {
					required: "版本待上线或完成，此项必填",
				},
				'launchDate': {
					required: "版本完成上线，此项必填",
				},
				'timeLimitVersion': {
					required: "版本待上线或完成，此项必填",
				},
				'demandPlanFinish': {
					required: "版本待上线或完成，此项必填",
				},
				'demandActuallyFinish': {
					required: "版本待上线或完成，此项必填",
				}
			},
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-qaVersion-add').serialize());
	        }
	    }
	</script>
</body>
</html>
