<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<!DOCTYPE HTML>
<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,user-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.login.css"
	rel="stylesheet" type="text/css" />
<link
	href="${pageContext.request.contextPath }/common/admin/css/style.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>
<div class="pd-20">
	<form class="form form-horizontal" id="form-addGoodsType">
		<div class="row cl">
			<label id="integralLabel" class="form-label col-2">类型名称：</label>
			<div id="integralDiv" class="formControls col-2">
				<input id="goodTypename" name="goodTypename" type="text" class="input-text" value="${goodsGoodinfo.goodsInfoBrand }" placeholder="">
			</div>
			<label id="integralLabel" class="form-label col-2">类型简介：</label>
			<div id="integralDiv" class="formControls col-2">
				<input id="goodDesc" name="goodDesc" type="text" class="input-text" value="${goodsGoodinfo.goodsInfoIngredients }" placeholder="">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>类型是否返利：</label>
			<div class="formControls col-2"> <span class="select-box">
				<select id="goodIsRebate" name="goodIsRebate" class="select" onchange="showHidden();">
					<option value="1">不支持返利</option>
					<option value="2">支持返利</option>
				</select>
				</span> 
			</div>
			<label id="rebateType" class="form-label col-2">返利类型：</label>
			<div id="rebateType2" class="formControls col-2">
				<span class="select-box">
					<select id="goodRebateType" name="goodRebateType" class="select" onchange="showHidden();">
						<option value="1">返商品销售价</option>
						<option value="2">返利数量</option>
					</select>
				</span>
			</div>
			<label id="rebateNum" class="form-label col-2">返利数量：</label>
			<div id="rebateNum2" class="formControls col-2">
				<input id="goodRebateNum" name="goodRebateNum" type="text" class="input-text"  placeholder="">
			</div>
		</div>
		<div class="row cl">
			<div class="col-10 col-offset-2">
				<button id="submit" onClick="admin_addGoodsType();" class="btn btn-primary radius" type="button"><i class="Hui-iconfont">&#xe632;</i> 保存</button>
			</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/layer/1.9.3/layer.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/js/H-ui.admin.js"></script>
	<script type="text/javascript"
		src="${pageContext.request.contextPath }/common/admin/js/tips.js"></script> 
<script type="text/javascript">
$(document).ready(function(){
	showHidden();
});
//控制是否返利显示或隐藏
function showHidden(){
	var showhidden = $("#goodIsRebate").val();
	if(showhidden == "1"){
		document.getElementById("rebateType").style.display="none";//显示
		document.getElementById("rebateType2").style.display="none";//显示
		document.getElementById("rebateNum").style.display="none";//显示
		document.getElementById("rebateNum2").style.display="none";//显示
	}else{
		document.getElementById("rebateType").style.display="";//隐藏
		document.getElementById("rebateType2").style.display="";//隐藏
		document.getElementById("rebateNum").style.display="";//隐藏
		document.getElementById("rebateNum2").style.display="";//隐藏
		$("#goodRebateNum").val("");//清空返利数量
	}
}
/*商品类型-添加*/
function admin_addGoodsType(){
			 //类型名称数据验证
			if(!commonLengthJdg('goodTypename',1,30,null,true)){
				layer.msg("类型名称长度为1-15位",{icon: 2,time:3000});
				return;
			}
			 //类型简介数据验证
			if(!commonLengthJdg('goodDesc',1,100,null,true)){
				layer.msg("商品简称长度为1-50位",{icon: 2,time:3000});
				return;
			}
		
		  $.ajax({
              url: '${pageContext.request.contextPath }/admin/goods/addGoodsType',
              type: "POST",
              dataType: "json",
              data: $("#form-addGoodsType").serialize(),
              beforeSubmit: function (data) {
            	  $("#submit").attr("disabled","disabled");
              },
              success:  function(data){
            	  	  layer.msg(data.status,{icon: 1,time:3000},function(){
            	  		window.location.href = '${pageContext.request.contextPath }/admin/goods/listGoodsType';
            	  });
              },
              error:function(data){
            	  layer.msg(data.status,{icon: 5,time:3000});
              }
          });
}
</script>
</body>
</html>