<%@ page language="java" import="java.util.*"  contentType="text/html;charset=UTF-8"%> 
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1 , user-scalable=no">
<title>制造商添加</title>
<link href="<%=basePath %>plugins/bootstrap.css" rel="stylesheet">
<link href="<%=basePath %>plugins/bootstrap-dashen.css" rel="stylesheet">
<link href="<%=basePath %>plugins/font-awesome.css" rel="stylesheet">
<link href="<%=basePath %>plugins/animate.css" rel="stylesheet">
<link href="<%=basePath %>plugins/bootstrap-datetimepicker.min.css" rel="stylesheet" media="screen">
</head>
<body style="margin-top:70px;">
<jsp:include page="../header.jsp"></jsp:include>
<div class="container">
	<div class="row">
		<div class="col-md-12 wow fadeInUp" data-wow-duration="0.5s">
			<div>
				<!-- Nav tabs -->
				<ul class="nav nav-tabs" role="tablist">
			    	<li role="presentation" ><a href="<%=basePath %>Supplier/frontlist">制造商列表</a></li>
			    	<li role="presentation" class="active"><a href="#supplierAdd" aria-controls="supplierAdd" role="tab" data-toggle="tab">添加制造商</a></li>
				</ul>
				<!-- Tab panes -->
				<div class="tab-content">
				    <div role="tabpanel" class="tab-pane" id="supplierList">
				    </div>
				    <div role="tabpanel" class="tab-pane active" id="supplierAdd"> 
				      	<form class="form-horizontal" name="supplierAddForm" id="supplierAddForm" enctype="multipart/form-data" method="post"  class="mar_t15">
						  <div class="form-group">
						  	 <label for="supplier_supplierName" class="col-md-2 text-right">单位全称:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="supplier_supplierName" name="supplier.supplierName" class="form-control" placeholder="请输入单位全称">
							 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="supplier_fddbr" class="col-md-2 text-right">法定代表人:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="supplier_fddbr" name="supplier.fddbr" class="form-control" placeholder="请输入法定代表人">
							 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="supplier_lxfs" class="col-md-2 text-right">联系方式:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="supplier_lxfs" name="supplier.lxfs" class="form-control" placeholder="请输入联系方式">
							 </div>
						  </div>
						  <div class="form-group">
						  	 <label for="supplier_address" class="col-md-2 text-right">单位地址:</label>
						  	 <div class="col-md-8">
							    <input type="text" id="supplier_address" name="supplier.address" class="form-control" placeholder="请输入单位地址">
							 </div>
						  </div>
				          <div class="form-group">
				             <span class="col-md-2""></span>
				             <span onclick="ajaxSupplierAdd();" class="btn btn-primary bottom5 top5">添加</span>
				          </div>
						</form> 
				        <style>#supplierAddForm .form-group {margin:10px;}  </style>
					</div>
				</div>
			</div>
		</div>
	</div> 
</div>

<jsp:include page="../footer.jsp"></jsp:include> 
<script src="<%=basePath %>plugins/jquery.min.js"></script>
<script src="<%=basePath %>plugins/bootstrap.js"></script>
<script src="<%=basePath %>plugins/wow.min.js"></script>
<script src="<%=basePath %>plugins/bootstrapvalidator/js/bootstrapValidator.min.js"></script>
<script type="text/javascript" src="<%=basePath %>plugins/bootstrap-datetimepicker.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="<%=basePath %>plugins/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script>
var basePath = "<%=basePath%>";
	//提交添加制造商信息
	function ajaxSupplierAdd() { 
		//提交之前先验证表单
		$("#supplierAddForm").data('bootstrapValidator').validate();
		if(!$("#supplierAddForm").data('bootstrapValidator').isValid()){
			return;
		}
		jQuery.ajax({
			type : "post",
			url : basePath + "Supplier/add",
			dataType : "json" , 
			data: new FormData($("#supplierAddForm")[0]),
			success : function(obj) {
				if(obj.success){ 
					alert("保存成功！");
					$("#supplierAddForm").find("input").val("");
					$("#supplierAddForm").find("textarea").val("");
				} else {
					alert(obj.message);
				}
			},
			processData: false, 
			contentType: false, 
		});
	} 
$(function(){
	/*小屏幕导航点击关闭菜单*/
    $('.navbar-collapse a').click(function(){
        $('.navbar-collapse').collapse('hide');
    });
    new WOW().init();
	//验证制造商添加表单字段
	$('#supplierAddForm').bootstrapValidator({
		feedbackIcons: {
			valid: 'glyphicon glyphicon-ok',
			invalid: 'glyphicon glyphicon-remove',
			validating: 'glyphicon glyphicon-refresh'
		},
		fields: {
			"supplier.supplierName": {
				validators: {
					notEmpty: {
						message: "单位全称不能为空",
					}
				}
			},
			"supplier.fddbr": {
				validators: {
					notEmpty: {
						message: "法定代表人不能为空",
					}
				}
			},
			"supplier.lxfs": {
				validators: {
					notEmpty: {
						message: "联系方式不能为空",
					}
				}
			},
			"supplier.address": {
				validators: {
					notEmpty: {
						message: "单位地址不能为空",
					}
				}
			},
		}
	}); 
})
</script>
</body>
</html>
