<%@ 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 action="${pageContext.request.contextPath }/admin/admin/addUI" method="post" class="form form-horizontal" id="form-admin-add"> --%>
	<form   class="form form-horizontal" id="form-admin-add">	
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>批次号：</label>
			<div class="formControls col-5">
				<input type="text" id="btchNo" name="btchNo" class="input-text" datatype="*2-16" nullmsg="批次号不能为空，并且只能为数值、字母组成">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>描述：</label>
			<div class="formControls col-5">
				<input id="describe" type="text" name="describe"  value="" class="input-text" datatype="*6-20" nullmsg="描述不能为空，可以为：xx月二次生成">
			</div>
			<div class="col-4"> </div>
		</div>
		<div class="row cl">
			<label class="form-label col-3"><span class="c-red">*</span>数量：</label>
			<div class="formControls col-5">
				<input id="number" type="text" name="number"  value="" class="input-text" datatype="*6-20" nullmsg="每次最少生成一张二维码，最大生成1000">
			</div>
			<div class="col-4"> </div>
		</div>

		<div class="row cl">
			<div class="col-9 col-offset-3">
				<input id="sumbit" class="btn btn-primary radius" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;" onclick="admin_add()">
			</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(){
	//数据验证
	$('#btchNo').blur(function(){
		var btchno = $('#btchNo').val();
        var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
        if(reg.test(btchno)){
            layer.msg("批次号不能包含汉字",{icon: 5,time:3000});
            return;
        }
        if(!commonLengthJdg('btchNo',5,20,null,true)){
			layer.msg("批次号不能为空长度为6-20位",{icon: 5,time:3000});
			return;
		}
	});
     $('#describe').blur(function(){
         if(!commonLengthJdg('describe',2,100,null,true)){
             layer.msg("描述不能为空长度为2-100位",{icon: 5,time:3000});
             return;
         }
     });$('#number').blur(function(){
         if(!commonLengthJdg('number',1,5,null,true)){
             layer.msg("数量不能为空长度为1-5位",{icon: 5,time:3000});
             return;
         }
     });

});

$(function(){
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$("#form-admin-add").Validform({
		tiptype:2,
		callback:function(form){
			form[0].submit();
			var index = parent.layer.getFrameIndex(window.name);
			parent.$('.btn-refresh').click();
			parent.layer.close(index);
		}
	});
});

/*管理员-添加*/
function admin_add(){
			var btchno = $('#btchNo').val();
			var reg = new RegExp("[\\u4E00-\\u9FFF]+","g");
			if(reg.test(btchno)){
				layer.msg("批次号不能包含汉字",{icon: 5,time:3000});
				return;
			}
			if(!commonLengthJdg('btchNo',5,20,null,true)){
				layer.msg("批次号不能为空长度为6-20位",{icon: 5,time:3000});
				return;
			}
			if(!commonLengthJdg('describe',2,100,null,true)){
				layer.msg("描述不能为空长度为2-100位",{icon: 5,time:3000});
				return;
			}
			if(!commonLengthJdg('number',1,5,null,true)){
				layer.msg("数量不能为空长度为1-5位",{icon: 5,time:3000});
				return;
			}
		  $.ajax({
              url: '${pageContext.request.contextPath }/admin/qrCode/addQrCode',
              type: "POST",
              dataType: "json",
              data: $("#form-admin-add").serialize(),
              beforeSubmit: function (data) {
            	  $("#submit").attr("disabled","disabled");
              },
              success:  function(data){
                  if(data.status){
                      layer.msg(data.message,{icon: 1,time:3000},function(){
                          window.location.href = '${pageContext.request.contextPath }/admin/qrCode/listQrCodeLogs';
                      });
				  }else{
                      layer.msg(data.message,{icon: 5,time:3000});
				  }
              },
              error:function(data){
            	  layer.msg(data.status,{icon: 5,time:3000});
              }
          });
}
</script>
</body>
</html>