<%@ 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,user-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 }/lib/respond.min.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/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/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="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="form-admin-add">
		<div class="layui-layer-title" id="sendOrderDivTitle" style="cursor: move;" move="ok">确认发货</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">
				<input type="text" class="input-text" value="" placeholder="请输入物流编号" name="postNum" 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="postFirm" size="1">
					<option value="">请选择物流公司</option>
					<option value="0">申通快递</option>
					<option value="1">圆通快递</option>
					<option value="2">顺丰快递</option>
				</select>
				</span> </div>
		</div>
		<br>
		<div class="col-9 col-offset-3">
	        <input class="btn btn-primary radius" type="submit" 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>
	
	<!-- 后台备注 -->
	<div class="layui-layer layui-anim layui-layer-iframe" id="layui-remark" 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="form-admin-remark">
		<div class="layui-layer-title" id="sendOrderDivTitle" style="cursor: move;" move="ok">订单备注</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">
				<input type="text" class="input-text" value="" placeholder="请输入备注信息" id="remarkInfoInput" name="postNum" datatype="*2-16" nullmsg="用户名不能为空">(不超过100字)
			</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" id="adminRemarkColor" size="1">
					<option value="1" class="optionclass" id="optionclass1">红色</option>
					<option value="2" class="optionclass" id="optionclass2">黄色</option>
					<option value="3" class="optionclass" id="optionclass3">绿色</option>
				</select>
				</span> </div>
		</div>
		<br>
		<div class="col-9 col-offset-3">
	        <input class="btn btn-primary radius" type="button" onclick="remrakSumbit()" 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>
	
	<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">
		<div class="text-c">
		<form action="${pageContext.request.contextPath }/admin/etcOrder/listUI" method="post" id="myForm">
			<input type="hidden" name="orderStatus" value="${orderStatusStr }" />
			<input type="text" name="text" id="textInputUser" value="${selectInput }" placeholder="订单编号/物流公司/物流编号/收货人/手机号" style="width: 300px" class="input-text">
			日期范围： 
			<input type="text" readonly="readonly" onfocus="WdatePicker({maxDate:'#F{$dp.$D(\'endDate\')||\'2020-10-01\'}'})" id="beginDate" value="${beginDate }" name="beginDate" class="input-text Wdate" style="width: 120px;">
			- <input type="text" readonly="readonly" onfocus="WdatePicker({minDate:'#F{$dp.$D(\'beginDate\')}',maxDate:'2020-10-01'})" id="endDate" value="${endDate }" name="endDate" class="input-text Wdate" style="width: 120px;">
			<button name="" id="submitBtn" class="btn btn-success" type="submit">
				<i class="Hui-iconfont">&#xe665;</i> 搜索
			</button>
		</form>
		</div>
		<div class="cl pd-5 bg-1 bk-gray mt-20">
			<div id="tab_demo" class="HuiTab">
			  <div class="tabBar cl">
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=allEtcOrder'" class="allEtcOrder">全部订单</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcOrderCancel'" class="etcOrderCancel">取消订单</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcToSubmitOrder'" class="etcToSubmitOrder">待提交信息</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcToPayOrder'" class="etcToPayOrder">待支付</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcToSendOrder'" class="etcToSendOrder">待发货状态</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcReturnPayOrder'" class="etcReturnPayOrder">申请退款中</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcReturnPayOrderSuccess'" class="etcReturnPayOrderSuccess">退款完成，订单关闭</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcSendOrderSuccess'" class="etcSendOrderSuccess">已发货</span>
			  	<span onclick="location.href='${pageContext.request.contextPath }${statusUrl }&orderStatus=etcOrderSend'" class="etcOrderSend">已付余款</span>
			  </div>
			</div>
		</div>
		<div class="mt-20">
			<table class="table table-border table-bordered table-bg table-hover table-sort">
				<thead>
					<tr class="text-c">
						<th width="10">订单编号</th>
						<th width="140">已支付</th>
						<th width="150">昵称</th>
						<th width="100">余款</th>
						<th width="80">订单类型</th>
						<th width="150">订单结束奖励积分</th>
						<th width="150">试用人姓名</th>
						<th width="70">试用人电话</th>
						<th width="150">身份证照片</th>
						<th width="150">订单状态</th>
						<th width="150">时间</th>
						<th width="150">我们的备注</th>
						<th width="50">备注图标</th>
						<th width="150">用户备注</th>
						<th width="150">操作</th>
					</tr>
				</thead>
				<tbody>
				<c:if test="${!(empty orders)}">
					<c:forEach items="${orders }" var="order">
						<tr class="text-c">
							<td><a style="color: blue;" href="${pageContext.request.contextPath }/admin/goods/selectOrderByOidDesc?orderId=${order.etcOrderId}">${order.etcOrderId }</td>
							<td>${order.etcOrderRmbTotal }</td>
							<td>${order.userNickName }</td>
							<td>${order.etcOrderEtcTotal }</td>
							<td>${order.etcOrderType == 1 ? "全免试用" : "需要押金" }</td>
							<td>${order.etcOrderRewardNum }</td>
							<td>${order.etcOrderEtcName }</td>
							<td>${order.etcOrderEtcTel }</td>
							<td>
								<img alt="" src="${pageContext.request.contextPath }${order.etcOrderPhtotUrl }" style="width: 50px;height: 50px">
							</td>
							<!-- 判断订单状态是否需要循环 -->
							<c:choose>
								<c:when test="${orderListIsStatus == true }">
									<%-- 订单来自状态查询 --%><td>${orderLinkStatus}</td>
								</c:when>
								<c:otherwise>
									<td>${order.orderLinkStatus}</td>
								</c:otherwise>
							</c:choose>
							
							<td><fmt:formatDate value="${order.etcOrderCreateDate }" pattern="MM-dd HH:mm" /></td>
							
							<!-- start 后台备注 -->
							<c:if test="${fn:length(order.etcOrderAdminRemark)>'3'}">  
                   			<td title="${order.etcOrderAdminRemark }" id="${order.etcOrderId }AdminRemark">${fn:substring(order.etcOrderAdminRemark,0,3)}...</td>  
			            	</c:if>  
			          		<c:if test="${fn:length(order.etcOrderAdminRemark)<='3'}">  
			             		<td title="${order.etcOrderAdminRemark }" id="${order.etcOrderId }AdminRemark">${order.etcOrderAdminRemark}</td>  
			          		</c:if>
							<td class="td-status">
								<c:if test="${order.etcOrderColorFlag==1 }">
									<div style="width:100%;height:20px;background-color: red;" id="${order.etcOrderId }AdminRemarkColor" lang="1"></div>
								</c:if>
								<c:if test="${order.etcOrderColorFlag==2 }">
									<div style="width:100%;height:20px;background-color: yellow;" id="${order.etcOrderId }AdminRemarkColor" lang="2"></div>
								</c:if>
								<c:if test="${order.etcOrderColorFlag==3 }">
									<div style="width:100%;height:20px;background-color: green;" id="${order.etcOrderId }AdminRemarkColor" lang="3"></div>
								</c:if>
							</td>
							<!-- end 后台备注 -->
							
							<!-- start 用户备注 -->
							<c:if test="${fn:length(order.etcOrderUserRemark)>'3'}">  
                   			<td title="${order.etcOrderUserRemark }">${fn:substring(order.etcOrderUserRemark,0,3)}...</td>  
			            	</c:if>  
			          		<c:if test="${fn:length(order.etcOrderUserRemark)<='3'}">  
			             		<td title="${order.etcOrderUserRemark }">${order.etcOrderUserRemark}</td>  
			          		</c:if>
							<!-- end 用户备注 -->
							
							<!-- 遍历操作 -->
							<td class="td-manage">
								<div class="dropDown dropDown_hover">
								  <a class="dropDown_A" href="#">操作</a>
								  <div class="dropDown-menu box-shadow" style="left:-22px;">
								    <ul>
								      <c:if test="${!(empty order.operations) }">
								      	<c:forEach items="${order.operations }" var="oper">
								      		<li><a href="${pageContext.request.contextPath }${oper.url}" lang="${order.etcOrderId }" title="${oper.name}" alt="${oper.name}" onclick="return orderAction(this)"><i class="Hui-iconfont">${oper.img}</i><font>${oper.name}</font></a></li>
								      	</c:forEach>
								      </c:if>
								    </ul>
								  </div>
								</div>
								
							</td>
						</tr>
					</c:forEach>
				</c:if>
				<c:if test="${empty orders}">
					<tr align="center"><td colspan="16" style="text-align: center;">未查询到该类数据!</td></tr>
				</c:if>
				</tbody>
			</table>
			<br/>
		<div align="right">
			<%@include file="/common/other/paper/pager.jsp"%>
		</div>
		</div>
	</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/My97DatePicker/WdatePicker.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">
		// 选中对应的订单头信息
		$(".${orderStatusStr}").attr("class", "current");
		// orderid
		var orderid = "";
		// 订单操作
		function orderAction(_this) {
			var $a = $(_this);
			var orderStatusStr = $a.children("font").text();
			if (orderStatusStr == "发货") {
				$("#layui-layer4").show();
				$("#sendOrderDivTitle").html("为'" + $a.attr("lang") + "'发货:");
				$("#form-admin-add").attr("action", $a.attr("href"));
				return false;
			} else if (orderStatusStr == "备注") {
				orderid = $a.attr("lang");
				$("#layui-remark").show();
				$("#form-admin-remark").attr("action", $a.attr("href"));
				// 回显现有的备注
				$("#remarkInfoInput").val($("#" + $a.attr("lang") + "AdminRemark").attr("title"));
				$(".optionclass").attr("selected", "");
				$("#optionclass" + $("#" + $a.attr("lang") + "AdminRemarkColor").attr("lang")).attr("selected", true);
				return false;
			}
			return true;
		}
		
		// 提交备注
		function remrakSumbit() {
			var remarkInfoInput = $("#remarkInfoInput").val();
			if (remarkInfoInput.length >= 0 && remarkInfoInput.length <= 100) {
				var adminRemarkColor = $("#adminRemarkColor").val();
				var url = $("#form-admin-remark").attr("action");
				var args = {"datetime" : new Date().getTime(), "remark" : remarkInfoInput, "remarkColor" : adminRemarkColor};
				$.ajax({
					   type: "POST",
					   url: url,
					   data: args,
					   dataType: "json",
					   success: function(data){
							if (data.status) {
								$("#layui-remark").hide();
								layer.msg(data.info,{icon:1,time:2000});
								$("#" + orderid + "AdminRemark").attr("title", remarkInfoInput);
								if (remarkInfoInput.length >= 3) {
									remarkInfoInput = remarkInfoInput.substr(0, 3) + "...";
								}
								$("#" + orderid + "AdminRemark").text(remarkInfoInput);
								var color = "";
								if (adminRemarkColor == "1") {
									color = "red";
								} else if (adminRemarkColor == "2") {
									color = "yellow";
								} else if (adminRemarkColor == "3") {
									color = "green";
								}
								
								$("#" + orderid + "AdminRemarkColor").css("background-color", color);
							} else {
								layer.msg(data.info,{icon:5,time:2000});
							}
					   }
				});
			}
			
		}
		
		// 关闭窗口
		function exitWindowsDiv(_this) {
			$(_this).parent().parent().hide();
		}
		
		// 搜索事件
		$(function() {
			$("#submitBtn").click(function() {
				var textInputUser = $("#textInputUser").val();
				if (textInputUser != null && textInputUser != "") {
					return true;
				}
				layer.msg("输入信息不能为空哦!",{icon:5,time:2000});
				return false;
			});
		});
	</script>
</body>
</html>