<style>
	table, tr, thead, tbody {
		width: 100%;
	}
	
	tr {
		border-bottom: solid 1px #999999;
	}
	td {
		padding: 5px;
	}
</style>

<div ng-controller="SaleOrderCtrl">
	<div class="top padding5 bold">
		<a href="#" class="f16 topText">&nbsp;<i class="fa fa-angle-left"></i>&nbsp;订单详情</a>
		<div class="right"><i class="fa fa-reorder"></i>&nbsp;&nbsp;</div>
	</div>
	<div class="orderInfo padding5">
		<div>-销售订单-
		</div>
		<div>订单号：<span ng-bind="purcOrder.code"></span>&nbsp;&nbsp;&nbsp;
			<span class="">[{{purcOrder.status | status}}]</span>
		</div>
		<div class="">客&nbsp;&nbsp;&nbsp;户：<a ng-bind="purcOrder.enterprise.enName"></a></div>
		<div class="">收货地址：<a ng-bind="purcOrder.enterprise.enAddress"></a></div>
		<div class="">
			单据时间：<span ng-bind="purcOrder.date | date:'yyyy-MM-dd'"></span>&nbsp;&nbsp;&nbsp;&nbsp;
			总额：<span ng-bind="getOrderTotal(purcOrder.orderItems) | currency:symbol(purcOrder.currency)"></span>
		</div>
		<div ng-show="purcOrder.remark" ng-bind="purcOrder.remark"></div>	
	</div>
	<div class="f12 padding5" style="min-height: 400px; position: relative;">
		<div class="loading"  ng-class="{'in': loading}">
			<i></i>
		</div>
		<table>
			<thead class="text-center bold">
				<td width="15%">序号</td>
				<td width="50%" colspan=2>商品</td>
				<td width="35%">回复状态</td>
			</thead>
			<tbody>
				<tr>
					<td colspan=2 class="text-center"><input ng-model="check_all" ng-click="checkAll(check_all)" type="checkbox">&nbsp;全选</td>
					<td colspan=2 class="">
						<button ng-click="replyByBatch()" class="btn btn-default btn-sm f14 bold">&nbsp;批量回复&nbsp;</button>
					</td>
				</tr>
			</tbody>
			<tbody ng-repeat="orderItem in purcOrder.orderItems" ng-class="{expand: orderItem.expand}">
				<tr class="br-b">
					<td width="15%" rowspan=2 ><input ng-click="checkOne(orderItem.checked)" ng-model="orderItem.checked" type="checkbox">&nbsp;{{orderItem.number}}</td>
					<td width="50%" colspan=2 class="br-l">
						<span class="ellipsis bold">{{orderItem.product.code}}</span><br>
						<a>{{orderItem.product.title}}</a><br>
						<div class="ellipsis">{{orderItem.product.spec}}</div>
					</td>
					<td ng-click="expandReply(orderItem)" data="{{orderItem.number}}" class="text-center" width="35%" class="br-l">
						已回复 <span class="bold text-success" ng-bind="orderItem.replyQty?orderItem.replyQty:0"></span><br>
						<span class="text-danger bold">(点击进行回复)</span>
					</td>
				</tr>
				<tr>
					<td class="text-center" width="20%" class="br-l text-danger">{{orderItem.price | currency:symbol(purcOrder.currency)}}</td>
					<td class="text-center" width="30%" class="br-l text-success">× {{orderItem.qty}}({{orderItem.product.unit}})</td>
					<td class="text-center" width="35%" class="br-l">{{orderItem.delivery | date:'yyyy-MM-dd'}}</td>
				</tr>
				<tr ng-show="orderItem.expand" class="expanding replyList br-b bg-info">
					<td colspan="3">
						<div ng-show="orderItem.replysError">加载回复记录失败</div>
						<div ng-show="orderItem.replys.length == 0">没有回复记录</div>
						<div ng-repeat="reply in orderItem.replys"><b>{{reply.date | date:'yyyy-MM-dd'}}</b> 回复数量<b class="text-success">{{reply.qty}}</b>;</div>
					</td>
					<td>
						<input ng-model="orderItem.reply.remark" class="form-control input-sm" placeholder="回复内容" type="text">
					</td>
				</tr>
				<tr ng-show="orderItem.expand" class="expanding reply text-center">
					<td><button ng-click="reply(orderItem)" type="button" class="btn btn-default btn-sm">回复</button></td>
					<td  colspan="2">
						<div class="input-group input-group-sm">
						<input ng-model="orderItem.reply.delivery" class="form-control input-sm" placeholder="交货日期"
						  	datepicker-popup="yyyy-MM-dd" is-open="orderItem.opened" min-date="purcOrder.date" 
						  	ng-required="true"  current-text="今天" clear-text="清除" close-text="关闭"
							datepicker-options="{formatDayTitle: 'yyyy年M月', formatMonth: 'M月', showWeeks: false}"
							ng-focus="open($event, orderItem)">
						<span class="input-group-btn">
                			<button type="button" class="btn btn-default" ng-click="open($event, orderItem)"><i class="glyphicon glyphicon-calendar"></i></button>
              			</span>
					  	</div>
					</td>
					<td><input ng-model="orderItem.reply.qty" value="{{orderItem.qty-orderItem.replyQty}}" class="form-control input-sm" placeholder="数量" type="number"></td>
				</tr>
			</tbody>
		</table>
		<div ng-show="purcOrder.orderItems.length == 0" class="text-warning text-center f16 bold">
			<br><i class="fa fa-bookmark"></i> 没有未回复的单据明细
		</div>
	</div>
</div>