<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/icheck/icheck.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />
<!--[if IE 6]>
<script type="text/javascript" src="http://lib.h-ui.net/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>添加奶粉信息</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 奶粉管理 <span class="c-gray en">&gt;</span> 添加奶粉信息 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="pd-20">
		<form action="${pageContext.request.contextPath}/admin/milk_powder/add" method="post" class="form form-horizontal" id="form-coupon-add">
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>奶粉品牌：</label>
			<div class="formControls col-2">
				<input id="brand" type="text" name="brand" placeholder="" value="" class="input-text" style="width:90%"></div>
			<label class="form-label col-2"><span class="c-red">*</span>奶粉系列：</label>
			<div class="formControls col-2">
				<input id="series" type="text" name="series" placeholder="" value="" class="input-text" style="width:90%"></div>
		</div>
			
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>奶粉编号：</label>
			<div class="formControls col-2">
				<input id="powderNumber" type="text" name="powderNumber" placeholder="" value="" class="input-text" style="width:90%"></div>
			<label class="form-label col-2"><span class="c-red">*</span>条形码：</label>
			<div class="formControls col-2">
				<input id="barCode" type="text" name="barCode" placeholder="" value="" class="input-text" style="width:90%"></div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>段数：</label>
			<div class="formControls col-2">
				<input id="level" type="text" name="level" placeholder="" value="" class="input-text" style="width:90%"></div>
			<label id="integralLabel" class="form-label col-2"><span class="c-red">*</span>版本：</label>
			<div id="integralDiv" class="formControls col-2">
				<input id="version" name="version" type="text" class="input-text" value="" placeholder="">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>年龄阶段：</label>
			<div class="formControls col-2">
				<input id="ageRange" type="text" name="ageRange" placeholder="" value="" class="input-text" style="width:90%"></div>
			<label class="form-label col-2"><span class="c-red">*</span>重量/勺：</label>
			<div class="formControls col-2">
				<input id="weightPerSpoon" type="text" name="weightPerSpoon" placeholder="" value="" class="input-text" style="width:90%">
			</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>毫升/勺：</label>
			<div class="formControls col-2">
				<input id="milkVolumePerSpoon" type="text" name="milkVolumePerSpoon" placeholder="" value="" class="input-text" style="width:90%"></div>
			<label class="form-label col-2"><span class="c-red">*</span>比例：</label>
			<div class="formControls col-2">
				<input id="powderRatio" type="text" name="powderRatio" placeholder="" value="" class="input-text" style="width:90%"></div>
		</div>
		
		<div class="row cl">
			<label id="integralLabel" class="form-label col-2"><span class="c-red">*</span>奶粉状态：</label>
			<div id="integralDiv" class="formControls col-2">
				<span class="select-box">
				<select id="status" name="status" class="select">
						<option value="approved">已认证</option>
						<option value="not_approved">未认证</option>
						<option value="user_uploading">用户上传</option>
				</select>
				</span>
			</div>
			
			<label class="form-label col-2"><span class="c-red">*</span>上传用户电话：</label>
			<div class="formControls col-2">
				<input id="userTel" type="text" name="userTel" placeholder="" value="" class="input-text" style="width:90%">
			</div>
		</div>
		
		<!-- <div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>密度：</label>
			<div class="formControls col-2">
				<input id="density" type="text" name="density" placeholder="" value="" class="input-text" style="width:90%">
			</div>
		</div> -->
		<input id="density" type="hidden" name="density" >
		<input id="type" type="hidden" name="type" >
    	<div class="row cl">
      	<div class="col-9 col-offset-3">
        	<input class="btn btn-primary radius" onclick="return checkForm()" type="submit" id="submitBtn" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
      	</div>
    	</div>
  	</form>
</div>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/icheck/jquery.icheck.min.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/layer/1.9.3/layer.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/tips.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script>  
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/H-ui.admin.js"></script>
<script type="text/javascript">
function checkForm(){
	//品牌验证
	if(!commonTypeJdg('brand',null,null,true)){
		layer.msg("奶粉品牌不能为空",{icon: 2,time:2000});
		return false;
	}
	//系列验证
	if(!commonTypeJdg('series',null,null,true)){
		layer.msg("奶粉系列不能为空",{icon: 2,time:2000});
		return false;
	}
	//奶粉编号验证
	if(!commonTypeJdg('powderNumber',null,null,true)){
		layer.msg("奶粉编号不能为空",{icon: 2,time:2000});
		return false;
	}
	//条形码验证
	if(!commonTypeJdg('barCode',null,null,true)){
		layer.msg("条形码不能为空",{icon: 2,time:2000});
		return false;
	}
	//段数验证
	if(!commonTypeJdg('level',null,null,true)){
		layer.msg("奶粉段数不能为空",{icon: 2,time:2000});
		return false;
	}
	//版本验证
	if(!commonTypeJdg('version',null,null,true)){
		layer.msg("版本不能为空",{icon: 2,time:2000});
		return false;
	}
	//年龄阶段验证
	if(!commonTypeJdg('ageRange',null,null,true)){
		layer.msg("年龄阶段不能为空",{icon: 2,time:2000});
		return false;
	}
	//每勺重量验证
	if(!commonTypeJdg('weightPerSpoon','digital',null,true)){
		layer.msg("每勺重量不能为空!且只能是数字",{icon: 2,time:2000});
		return false;
	}
	//毫升/勺验证
	if(!commonTypeJdg('milkVolumePerSpoon','digital',null,true)){
		layer.msg("毫升/勺不能为空!且只能是数字",{icon: 2,time:2000});
		return false;
	}
	//比例验证
	if(!commonTypeJdg('powderRatio','digital',null,true)){
		layer.msg("比例不能为空!且只能是数字",{icon: 2,time:2000});
		return false;
	}
	var status = $("#status").val();
	//用户上传的时候电话不能为空
	if(status == 'user_uploading'){
		if(!commonTypeJdg('userTel',null,null,true)){
			layer.msg("用户上传时电话不能为空",{icon: 2,time:2000});
			return false;
		}
	}
	//密度验证
	/* if(!commonTypeJdg('density','digital',null,true)){
		layer.msg("密度不能为空长!且只能是数字",{icon: 2,time:2000});
		return false;
	} */
	//计算密度
	var weightPerSpoon = $("#weightPerSpoon").val();
	var milkVolumePerSpoon = $("#milkVolumePerSpoon").val();
	var density = (weightPerSpoon/milkVolumePerSpoon*100).toFixed(2);
	if(density<13.2){
		density = 6;
	}else if(density>13.21 && density<15.3){
		density = 7;
	}else if(density>15.31 && density<17.4){
		density = 8;
	}else if(density>17.41 && density<19.5 ){
		density = 9;
	}else if(density>19.51 && density<22.0){
		density = 10;
	}else if(density>22.1 ){
		density = 10;
	}
	$("#density").val(density);
	$("#type").val(density);
	return true;
}

</script>
</body>
</html>