<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> 
<!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" />
<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" />
<link href="${pageContext.request.contextPath }/common/other/kingedit/themes/default/default.css" rel="stylesheet" type="text/css" />
<title>修改产品颜色</title>
</head>
<body>
<div class="pd-20">
	<form action="${pageContext.request.contextPath }/admin/product_color/update" class="form form-horizontal" id="form-addGoods" method="POST">
	<input name="colorId" type="hidden" value="${productColor.colorId }">
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>颜色名称：</label>
			<div class="formControls col-4">
				<input id="colorName" name="colorName" type="text" class="input-text" value="${productColor.colorName }" placeholder="" >
			</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">
				<select id="colorProductName" name="colorProductId">
					<option value="">请选择所属产品</option>
					<c:forEach items="${pList}" var="product" varStatus="status">
	                	<option value="${product.productId}" <c:if test="${product.productId == productColor.colorProductId }">selected</c:if>>${product.productName }</option>
	                </c:forEach>
	            </select>
            </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="colorPrice" type="text" name="colorPrice" id="" placeholder="" 
					value="<fmt:formatNumber type='number' value='${productColor.colorPrice / 100} ' pattern='0' maxFractionDigits='2'/>" 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="colorDiscount" type="text" name="colorDiscount" id="" placeholder="" 
					value="<fmt:formatNumber type='number' value='${productColor.colorDiscount / 100} ' pattern='0' maxFractionDigits='2'/>" class="input-text" style="width:90%">元</div>
		</div>
		
		<div class="row cl">
			<label class="form-label col-2"><span class="c-red">*</span>产品69码：</label>
			<div class="formControls col-2">
				<input id="color69Code" name="color69Code" type="text" class="input-text" value="${productColor.color69Code }" placeholder="">
			</div>
			
		</div>
		
		<div class="row cl">
			<div class="col-10 col-offset-2">
				<!-- <button onClick="return admin_addGoods();" class="btn btn-primary radius" type="submit"><i class="Hui-iconfont">&#xe632;</i> 保存</button> -->
				<button onClick="return checkColor();" class="btn btn-primary radius" type="submit">
					<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" src="${pageContext.request.contextPath }/common/admin/js/ueditor.all.min.js"></script> 
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/js/ueditor.config.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/utils/tools.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/js/utils/jquery-1.9.1.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/other/kingedit/kindeditor.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath }/common/other/kingedit/lang/zh_CN.js"></script>
<script type="text/javascript">

/*商品-数据验证*/
function checkColor(){
	//颜色名称数据验证
	if(!commonLengthJdg('colorName',1,60,null,true)){
		layer.msg("颜色名称不能为空!且长度为1-30位",{icon: 2,time:2000});
		return false;
	}
	//所属产品数据验证
	if(!commonLengthJdg('colorProductName',1,20,null,true)){
		layer.msg("请选择所属产品!",{icon: 2,time:2000});
		return false;
	}
	 
	//商品原价数据验证
	if(!commonTypeJdg('colorPrice','money',null,true)){
		layer.msg("商品原价不能为空!且须为金钱格式",{icon: 2,time:2000});
		return false;
	}
	if(!commonLengthJdg('colorPrice',1,9,null,true)){
		layer.msg("商品原价长度为1-9位",{icon: 2,time:2000});
		return false;
	}
	
	//商品折扣价数据验证
	if(!commonTypeJdg('colorDiscount','money',null,true)){
		layer.msg("商品折扣价不能为空!且须为金钱格式",{icon: 2,time:2000});
		return false;
	}
	if(!commonLengthJdg('colorDiscount',1,9,null,true)){
		layer.msg("商品折扣价长度为1-9位",{icon: 2,time:2000});
		return false;
	}
	//产品69码验证
	if(!commonTypeJdg('color69Code',null,null,true)){
		layer.msg("产品69码不能为空",{icon: 2,time:2000});
		return false;
	}
	
	//原价乘100 取整
	var colorPrice = $("#colorPrice").val();
	$("#colorPrice").val(Math.round(colorPrice * 100));
	//折扣价乘100 取整
	var colorDiscount = $("#colorDiscount").val();
	$("#colorDiscount").val(Math.round(colorDiscount * 100));
	
}
</script>
</body>
</html>