<%@ 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 uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!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,member-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/html5.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/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.admin.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>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 奶粉管理 <span class="c-gray en">&gt;</span> 奶粉信息管理<a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="pd-20">
	<form action="${pageContext.request.contextPath }/admin/milk_powder/list" method="get" id="searchForm">
	<div class="text-c"> 
	   	 奶粉状态: <span class="select-box inline">
		    <select class="select" id="" name="status">
		    	<option value="">所有</option>
		      	<option value="approved" <c:if test="${mPowderDto.status == 'approved' }">selected="selected"</c:if>>已认证</option>
				<option value="not_approved" <c:if test="${mPowderDto.status == 'not_approved' }">selected="selected"</c:if>>未认证</option>
				<option value="user_uploading" <c:if test="${mPowderDto.status == 'user_uploading'}">selected="selected"</c:if>>用户上传</option>
		    </select>
	    </span>
		奶粉品牌:  
		<input type="text" class="input-text" style="width:150px" placeholder="输入奶粉品牌" value="${mPowderDto.brand }" id="" name="brand">
		奶粉编号:  
		<input type="text" class="input-text" style="width:150px" placeholder="输入奶粉编号" value="${mPowderDto.powderNumber }" id="" name="powderNumber">
		奶粉条形码:  
		<input type="text" class="input-text" style="width:150px" placeholder="输入奶粉条形码" value="${mPowderDto.barCode }" id="" name="barCode">
		
		<button type="button" class="btn btn-success radius" id="searchButton" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</div>
	</form>
	<div class="cl pd-5 bg-1 bk-gray mt-20">
		<span class="l"><a href="javascript:;" onclick="toAdd('${pageContext.request.contextPath }/admin/milk_powder/to_add')"
			class="btn btn-danger radius">添加奶粉</a>&nbsp;
	    </span>
	</div>
	<div>
	<table class="table table-border table-bordered table-hover table-bg">
		<thead>
			<tr class="text-c">
				<th width="80">奶粉品牌</th>
				<th width="150">奶粉系列</th>
				<th width="50">奶粉编号</th>
				<th width="50">条形码</th>
				<th width="50">段数</th>
				
				<th width="50">版本</th>
				<th width="50">年龄阶段</th>
				<th width="40">重量/勺</th>
				<th width="40">毫升/勺</th>
				<th width="50">比例</th>
				
				<th width="50">密度</th>
				<th width="40">使用次数</th>
				<th width="100">创建时间</th>
				<th width="200">操作</th>
			</tr>
		</thead>
		<tbody>
			<c:if test="${!empty mPowderList }">
				<c:forEach items="${mPowderList }" var="mPowder">
				<tr class="text-c">
					<td>${mPowder.brand }</td>
					<td>${mPowder.series }</td>
					<td class='text-l'>${mPowder.powderNumber }</td>
					<td>${mPowder.barCode }</td>
					<td>${mPowder.level }</td>
					
					<td>${mPowder.version }</td>
					<td>${mPowder.ageRange }</td>
					<td>${mPowder.weightPerSpoon }</td>
					<td>${mPowder.milkVolumePerSpoon }</td>
					<td>${mPowder.powderRatio }</td>
					
					<td>${mPowder.density }</td>
					<td>—</td>
					<td><fmt:formatDate value="${mPowder.createdOn }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td class="td-manage">
						<input id="through" class="btn btn-primary radius upload-btn" onclick="updateMPowder('修改','${pageContext.request.contextPath }/admin/milk_powder/to_update/${mPowder.id }','','700');" type="button" value="修改" />&nbsp;
						<input id="through" class="btn btn-primary radius upload-btn" onclick="deleteMPowder(this,${mPowder.id });" type="button" value="删除" />
					</td>
				</tr>
				</c:forEach>
			</c:if>
			<c:if test="${empty mPowderList }">
				<tr class="text-c">
					<td colspan="9">没有查询到数据</td>
				</tr>
			</c:if>
		</tbody>
	</table>
	</div>
</div>
<div align="right">
	<%@include file="/common/other/paper/pager.jsp"%>
</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/lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/My97DatePicker/WdatePicker.js"></script> 
<script type="text/javascript" src="${pageContext.request.contextPath }/common/admin/lib/datatables/1.10.0/jquery.dataTables.min.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">
$(document).ready(function() {
	$("#searchButton").click(function() {
		var action = $("#searchForm").attr("action");
		$("#searchForm").attr("action", action).submit();
	});
})

/*添加奶粉信息*/
function toAdd(url){
	window.location.href = url;
}
/*奶粉信息-编辑*/
function updateMPowder(title,url,id,w,h){
	layer_show(title,url,w,h);
}
/*奶粉信息-删除*/
function deleteMPowder(obj,id){
	layer.confirm('确认要删除吗？',function(){
		$.ajax({
			url: '${pageContext.request.contextPath }/admin/milk_powder/delete/'+id,
			dataType:'json',//服务器返回json格式数据
			type:'post',	//HTTP请求类型
			error:function(data){
	      	  	layer.msg("删除失败!",{icon: 5,time:2000});
	        },
	        success:  function(data){
	      	  	if(data.status){
					$(obj).parents("tr").remove();
					layer.msg('已删除!',{icon:1,time:3000});
	      	  	}else{
	      	  		layer.msg(data.message,{icon:1,time:3000});
	      	  	}
	        }
		});
	});
}
</script> 
</body>
</html>