<%@ page language="java" import="java.util.*"  contentType="text/html;charset=UTF-8"%> 
<%@ page import="com.chengxusheji.po.Supplier" %>
<%@ taglib prefix="sf" uri="http://www.springframework.org/tags/form" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    Supplier supplier = (Supplier)request.getAttribute("supplier");

%>
<!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"> 
</head>
<body style="margin-top:70px;"> 
<div class="container">
<jsp:include page="../header.jsp"></jsp:include>
	<div class="col-md-9 wow fadeInLeft">
	<ul class="breadcrumb">
  		<li><a href="<%=basePath %>index.jsp">首页</a></li>
  		<li class="active">制造商信息修改</li>
	</ul>
		<div class="row"> 
      	<form class="form-horizontal" name="supplierEditForm" id="supplierEditForm" enctype="multipart/form-data" method="post"  class="mar_t15">
		  <div class="form-group">
			 <label for="supplier_supplierId_edit" class="col-md-3 text-right">记录id:</label>
			 <div class="col-md-9"> 
			 	<input type="text" id="supplier_supplierId_edit" name="supplier.supplierId" class="form-control" placeholder="请输入记录id" readOnly>
			 </div>
		  </div> 
		  <div class="form-group">
		  	 <label for="supplier_supplierName_edit" class="col-md-3 text-right">单位全称:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="supplier_supplierName_edit" name="supplier.supplierName" class="form-control" placeholder="请输入单位全称">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="supplier_fddbr_edit" class="col-md-3 text-right">法定代表人:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="supplier_fddbr_edit" name="supplier.fddbr" class="form-control" placeholder="请输入法定代表人">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="supplier_lxfs_edit" class="col-md-3 text-right">联系方式:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="supplier_lxfs_edit" name="supplier.lxfs" class="form-control" placeholder="请输入联系方式">
			 </div>
		  </div>
		  <div class="form-group">
		  	 <label for="supplier_address_edit" class="col-md-3 text-right">单位地址:</label>
		  	 <div class="col-md-9">
			    <input type="text" id="supplier_address_edit" name="supplier.address" class="form-control" placeholder="请输入单位地址">
			 </div>
		  </div>
			  <div class="form-group">
			  	<span class="col-md-3""></span>
			  	<span onclick="ajaxSupplierModify();" class="btn btn-primary bottom5 top5">修改</span>
			  </div>
		</form> 
	    <style>#supplierEditForm .form-group {margin-bottom:5px;}  </style>
      </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/bootstrap-datetimepicker.min.js"></script>
<script src="<%=basePath %>plugins/locales/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="<%=basePath %>js/jsdate.js"></script>
<script>
var basePath = "<%=basePath%>";
/*弹出修改制造商界面并初始化数据*/
function supplierEdit(supplierId) {
	$.ajax({
		url :  basePath + "Supplier/" + supplierId + "/update",
		type : "get",
		dataType: "json",
		success : function (supplier, response, status) {
			if (supplier) {
				$("#supplier_supplierId_edit").val(supplier.supplierId);
				$("#supplier_supplierName_edit").val(supplier.supplierName);
				$("#supplier_fddbr_edit").val(supplier.fddbr);
				$("#supplier_lxfs_edit").val(supplier.lxfs);
				$("#supplier_address_edit").val(supplier.address);
			} else {
				alert("获取信息失败！");
			}
		}
	});
}

/*ajax方式提交制造商信息表单给服务器端修改*/
function ajaxSupplierModify() {
	$.ajax({
		url :  basePath + "Supplier/" + $("#supplier_supplierId_edit").val() + "/update",
		type : "post",
		dataType: "json",
		data: new FormData($("#supplierEditForm")[0]),
		success : function (obj, response, status) {
            if(obj.success){
                alert("信息修改成功！");
                location.reload(true);
                $("#supplierQueryForm").submit();
            }else{
                alert(obj.message);
            } 
		},
		processData: false,
		contentType: false,
	});
}

$(function(){
        /*小屏幕导航点击关闭菜单*/
        $('.navbar-collapse a').click(function(){
            $('.navbar-collapse').collapse('hide');
        });
        new WOW().init();
    supplierEdit("<%=request.getParameter("supplierId")%>");
 })
 </script> 
</body>
</html>

