<%@ 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" %>
<!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 rel="Bookmark" href="/favicon.ico">
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<!--[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.admin.css" rel="stylesheet" type="text/css" />
<link href="${pageContext.request.contextPath }/common/admin/skin/default/skin.css" rel="stylesheet" type="text/css" id="skin" />
<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/admin/css/style.css" rel="stylesheet" type="text/css" />

<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>商品列表</title>
</head>
<body>
<!-- 弹出对话框 start -->
<div class="layui-layer layui-anim layui-layer-iframe" id="layui-layer4" times="4" showtime="0" contype="string" style="display:none; z-index: 19891018; width: 400px; height: 260px; position: absolute; top: 100px; left: 379px;">
	<form action="" method="post" class="form form-horizontal" id="updateAgentMachine">
	<input type="hidden" name="userMachineId" id="send-machineId"/>
	<div class="layui-layer-title" id="sendOrderDivTitle" style="cursor: move;" move="ok">确认发货</div>
	<br>
	<input type="hidden" id="agentMachineId" name="agentMachineId" value = "">
	<input type="hidden" id="agentMachineStatus" name="agentMachineStatus" value = "">	
	<div class="row cl">
		<label class="form-label col-3"><span class="c-red"></span>&nbsp;&nbsp;快递编号：</label>
		<div class="formControls col-5">
			<input type="text" id="agentMachinePostNum" class="input-text" value="" placeholder="请输入物流编号" name="agentMachinePostNum" datatype="*2-16" nullmsg="单号不能为空">
		</div>
		<div class="col-4"> </div>
	</div>
	<br>
	<div class="row cl">
		<label class="form-label col-3"><span class="c-red"></span>&nbsp;&nbsp;快递名称：</label>
		<div class="formControls col-5"> <span class="select-box" style="width:150px;">
			<select class="select" name="agentMachinePostName" size="1">
				<option value="sto">申通快递</option>
				<option value="yto">圆通快递</option>
				<option value="sf">顺丰快递</option>
				<option value="ems">邮政EMS</option>
				<option value="zto">中通快递</option>
				<option value="zjs">宅急送</option>
				<option value="yunda">韵达快递</option>
				<option value="cces">cces快递</option>
				<option value="pick">上门提货</option>
				<option value="htky">汇通快递</option>
				<option value="ttkdex">天天快递</option>
				<option value="stars">星晨急便</option>
				<option value="jd">京东快递</option>
				<option value="01">其他</option>
				<option value="02">上门送货</option>
			</select>
			</span> </div>
	</div>
	<br>
	<div class="col-9 col-offset-3">
        <input class="btn btn-primary radius" onclick="updateAgentMachineStatus()" type="button" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
      </div>
    </form>
	<span class="layui-layer-setwin">
		<a class="layui-layer-ico layui-layer-close layui-layer-close1" onclick="exitWindowsDiv(this)" href="javascript:;"></a>
	</span>
</div>
<!-- 弹出对话框 end -->

	<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/card/agentMachineList" method="post">
			时间范围： <input  id="beginDate" value="${beginDate }" name="beginDate" class="input-text Wdate" style="width: 120px;" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',maxDate:'#F{$dp.$D(\'endDate\')||\'%y-%M-%d\'}'})" readonly>
				 - <input  id="endDate" value="${endDate }" name="endDate" class="input-text Wdate" style="width: 120px;" type="text" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd',minDate:'#F{$dp.$D(\'beginDate\')||\'%y-%M-%d\'}'})" readonly>
			<span class="select-box" style="width:180px;">
				<select class="select" name="agentMachineStatus" size="1">
					<option value="" >选择状态</option>
					<option value="0"  ${agentMachineStatus==0?'selected':''}>未支付</option>
					<option value="1"  ${agentMachineStatus==1?'selected':''}>待确定</option>
					<option value="2" ${agentMachineStatus==2?'selected':''}>已确定</option>
					<option value="3" ${agentMachineStatus==3?'selected':''}>已发货</option>
				</select>
			</span>
			<button name="" id="submitBtn"  class="btn btn-success" type="submit">
				<i class="Hui-iconfont"></i> 搜索
			</button>
		</form>
	<form id="agentMachineform" >
		<table class="table table-border table-bordered table-bg">
			<thead>
				<tr>
					<th scope="col" colspan="14">赠送记录列表</th>
				</tr>
				<tr class="text-c">
					<th width="150">代理商名称</th>
					<th width="150">代理商类型</th>
					<th width="90">赠送状态</th>
					<th width="150">产品名称</th>
					<th width="130">产品颜色名称</th>
					<th width="100">机器69码</th>
					<th width="100">收件人地址</th>
					<th width="100">收件人姓名</th>
					<th width="100">收件人电话</th>
					<th width="100">快递名称</th>
					<th width="100">快递单号</th>
					<th width="100">创建时间</th>
					<th width="100">备注</th>
					<th width="100">操作</th>
				</tr>
			</thead>
			<tbody>
				<c:if test="${! (empty agentMachineList) }">
					<c:forEach items="${agentMachineList }" var="infolist">
						<tr class="text-c">
							<td class="nick-name-td">${infolist.agentNameInfo}</td>
							<td>${infolist.agentMachineType==1?'付费代理商':''}
								${infolist.agentMachineType==2?'推荐人':''}
								${infolist.agentMachineType==3?'销售奖励':''}</td>
							<td>
								<input id="hiddenGoodstatus" type="hidden" value="${infolist.agentMachineStatus }">
									${infolist.agentMachineStatus==0?'未支付':''}
									${infolist.agentMachineStatus==1?'待确定':''}
									${infolist.agentMachineStatus==2?'已确定':''}
									${infolist.agentMachineStatus==3?'已发货':''}
							</td>
							<td>${infolist.agentMachineProductName}</td>
							<td>${infolist.agentMachineColorName }</td>
							<td>${infolist.agentMachine69code}</td>
							<td>${infolist.agentMachineAddressInfo}</td>
							<td>${infolist.agentMachineAddressName}</td>
							<td>${infolist.agentMachineAddressTel}</td>
							<td>${infolist.agentMachinePostName}</td>
							<td>${infolist.agentMachinePostNum}</td>
							<td><fmt:formatDate value="${infolist.agentMachineCreateDate}" pattern="YYYY-MM-dd HH:mm" /></td>
							<td>${infolist.agentMachineRemark}</td>
							<td class="td-manage">
								<input id="hiddenGoodstatus" type="hidden" value="${infolist.agentMachineStatus }">
								<c:if test="${infolist.agentMachineStatus eq 2}">
									<a  onClick="show(3,'${infolist.agentMachineId}');" href="javascript:;" title="发货">发货</a>&nbsp;
									<a  onClick="syncStatus(${infolist.agentMachineType},'${infolist.agentMachineId}');" href="javascript:;" title="同步状态">同步状态</a>
								</c:if>
							</td>
					</c:forEach>
				</c:if>
			</tbody>
		</table>
		<div align="right" class="mt-10 mb-10 mr-10">
			<%@include file="/common/other/paper/pager.jsp"%>
  		</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/My97DatePicker/WdatePicker.js"></script> 
	<script type="text/javascript">
	/* $(document).ready(function(){
		$('#beginDate').datepicker();//时间控件
        $('#endDate').datepicker();
	}); */
	$(function() {
		var $td = $(".nick-name-td");
		if ($td.length > 0) {
			for (var i = 0; i < $td.length; i++) {
				var t = decodeURI($($td[i]).text());
				$($td[i]).text(t);
			}
		}
	});
	function show(agentMachineStatus,agentMachineId) {
		$("#agentMachineId").val(agentMachineId);
		$("#agentMachineStatus").val(agentMachineStatus);
		$("#layui-layer4").show();
	}

	//同步订单状态
	function syncStatus(agentMachineType,agentMachineId) {
	    var type = 0;
		switch (agentMachineType) {
			case 1: type = 2;break;
			case 2: type = 2;break;
			case 3: type = 4;break;
		}
        $.ajax({
            type:'POST',
            url: '${pageContext.request.contextPath }/admin/rent/efast/select_efast_order/'+ agentMachineId + '/' + type,
            dataType: 'json',
            success:function(data) {
                location.reload();
            }
        });
	}
	// 关闭窗口
	function exitWindowsDiv(_this) {
		$("#layui-layer4").hide();
	}
	
	  function updateAgentMachineStatus(){
		// 校验物流信息
			var postNum = $("#agentMachinePostNum").val();
			if (postNum == null || postNum.length < 1) {
				alert("请输入完整的快递单号!");
				return;
			}
		  
			$.ajax({
		        url: '${pageContext.request.contextPath }/admin/card/updateAgentMachineStatus',
		        type: "POST",
		        dataType: "json",
		        data: $('#updateAgentMachine').serialize(),
		        error:function(){
		      	  layer.msg(data.status,{icon: 5,time:3000});
		        },
			        success:  function(data){
			      	  layer.msg(data.status,{icon: 1,time:1000},function(){
				      	   window.location.href = '${pageContext.request.contextPath }/admin/card/agentMachineList'; 
			      	  });
			      	  
			     }
		    });
		} 

</script>
</body>
</html>