<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
	<th:block th:include="include :: header('修改（报价单）')" />
	<th:block th:include="include :: datetimepicker-css" />
	<th:block th:include="include :: bootstrap-editable-css" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<div class="panel-group" id="accordion">
			<form class="form-horizontal" id="form-order-edit" th:object="${crmOrderPrice}">
				<div class="panel panel-default">
					<div  class="panel-heading">
						<h4 class="form-header h4 panel-title">
							<a data-toggle="collapse" data-parent="#accordion"
							   href="#collapseOne">
								基本信息
							</a>
						</h4>
					</div>
					<div id="collapseOne" class="panel-collapse collapse in">
						<div class="panel-body">
							<input name="orderId" th:field="*{orderId}" type="hidden">
							<input name="customerId" type="hidden" id="customerId" />
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">报价客户：</label>
										<div class="col-sm-8">
											<div class="input-group">
												<input name="customerName" onclick="selectCustomer()" th:field="*{customer.customerName}" class="form-control" type="text" placeholder="请选择报价客户 " id="customerName" required readonly>
												<span class="input-group-addon"><i class="fa fa-search"></i></span>
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">主题：</label>
										<div class="col-sm-8">
											<input name="orderName" th:field="*{orderName}" class="form-control" type="text" required>
										</div>
									</div>
								</div>
							</div>

							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">报价总额：</label>
										<div class="col-sm-6">
											<input name="totalPrice" th:field="*{totalPrice}" class="form-control" type="text" required>
											<input name="costPrice" th:field="*{costPrice}" class="form-control" type="hidden">
										</div>
										<div class="col-sm-2">
											<i class="fa fa fa-cny"><a href="javascript:autoCaculate();">自动计算</a></i>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label">币种：</label>
										<div class="col-sm-8">
											<select name="currency" class="form-control m-b" >
												<option value="RMB" >人名币</option>
												<option value="USD" >美金</option>
											</select>
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">单价：</label>
										<div class="col-sm-8">
											<input name="price" class="form-control" type="text" th:field="*{price}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">重量：</label>
										<div class="col-sm-8">
											<input name="weight" th:field="*{weight}" class="form-control" type="text" required>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">总数量：</label>
										<div class="col-sm-8">
											<input name="totalQuantity" class="form-control" type="text" th:field="*{totalQuantity}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">税率：</label>
										<div class="col-sm-8">
											<input name="exchRate" th:field="*{exchRate}" class="form-control" type="text" required>
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">运费：</label>
										<div class="col-sm-8">
											<input name="freight" class="form-control" type="text" th:field="*{freight}" required>
											<i class="fa fa fa-cny" style="width: 84px"><a href="javascript:autoCaculatea();">自动计算</a></i>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">总重量：</label>
										<div class="col-sm-8">
											<input name="totalWeight" th:field="*{totalWeight}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">装柜标准：</label>
										<div class="col-sm-8">
											<input name="contStand" class="form-control" type="text" th:field="*{contStand}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">装柜重量：</label>
										<div class="col-sm-8">
											<input name="contWeight" th:field="*{contWeight}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">货款总计：</label>
										<div class="col-sm-8">
											<input name="totalPaymentGoods" class="form-control" type="text" th:field="*{totalPaymentGoods}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">货款增值税：</label>
										<div class="col-sm-8">
											<input name="addedTax" th:field="*{addedTax}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">运输增值税：</label>
										<div class="col-sm-8">
											<input name="transportAddedTax" class="form-control" type="text" th:field="*{transportAddedTax}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">毛利增值税：</label>
										<div class="col-sm-8">
											<input name="profitAddedTax" th:field="*{profitAddedTax}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">退税：</label>
										<div class="col-sm-8">
											<input name="taxRebates" class="form-control" type="text" th:field="*{taxRebates}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">开票金额：</label>
										<div class="col-sm-8">
											<input name="invoiceAmount" th:field="*{invoiceAmount}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">末税总值：</label>
										<div class="col-sm-8">
											<input name="totalEndTax" class="form-control" type="text" th:field="*{totalEndTax}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">FOB $/kg：</label>
										<div class="col-sm-8">
											<input name="fob" th:field="*{fob}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">美金价值：</label>
										<div class="col-sm-8">
											<input name="dollarVal" class="form-control" type="text" th:field="*{dollarVal}" required>
										</div>
									</div>
									<div  class="form-group">
										<label class="col-sm-4 control-label is-required">管理费：</label>
										<div class="col-sm-8">
											<input name="managFee" class="form-control" type="text" th:field="*{managFee}" required>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">毛利：</label>
										<div class="col-sm-8">
											<input name="profit" class="form-control" type="text" th:field="*{profit}" required>
										</div>
									</div>
									<div class="form-group">
										<label class="col-sm-4 control-label ">净利：</label>
										<div class="col-sm-8">
											<input name="netProfit" th:field="*{netProfit}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label">出口港：</label>
										<div class="col-sm-8">
											<div class="input-group date">
												<input name="portOfLoading" th:value="${crmOrderPrice.portOfLoading}" class="form-control"  type="text">
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label">目的港：</label>
										<div class="col-sm-8">
											<div class="input-group date">
												<input name="portOfDestination" th:value="${crmOrderPrice.portOfDestination}" class="form-control"  type="text" required>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label">运输方式：</label>
										<div class="col-sm-8">
											<div class="input-group date">
												<input name="shippedVia" th:value="${crmOrderPrice.shippedVia}" class="form-control"  type="text">
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label">报价人：</label>
										<div class="col-sm-8">
											<input name="prcieBy" th:field="*{prcieBy}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label">报价时间：</label>
										<div class="col-sm-8">
											<div class="input-group date">
												<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
												<input name="prcieEndDate" th:value="${#dates.format(crmOrderPrice.prcieEndDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text">
											</div>
										</div>
									</div>
								</div>
								<div class="col-sm-6">
									<div class="form-group">
										<label class="col-sm-4 control-label is-required">报价有效截止时间：</label>
										<div class="col-sm-8">
											<div class="input-group date">
												<span class="input-group-addon"><i class="fa fa-calendar"></i></span>
												<input name="prcieEndDate" th:value="${#dates.format(crmOrderPrice.prcieEndDate, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" required>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="col-sm-12">
									<div class="form-group">
										<label class="col-xs-2 control-label">备注：</label>
										<div class="col-xs-10">
											<textarea name="remark" maxlength="500" class="form-control" rows="3">[[*{remark}]]</textarea>
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
				<!--start-->
				<div class="panel panel-default">
					<div  class="panel-heading">
						<h4 class="form-header h4 panel-title">
							<a data-toggle="collapse" data-parent="#accordion"
							   href="#collapseTwo">
								成本信息
							</a>
						</h4>
					</div>
					<div id="collapseTwo" class="panel-collapse collapse">
						<div class="panel-body">
							<div class="row">
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">FOB$/kg(5%)：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobFive" th:field="*{fobFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">10%：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobTen" th:field="*{fobTen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">15%：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobFifteen" th:field="*{fobFifteen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">20%：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobTwenty" th:field="*{fobTwenty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">25%：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobTwentyFive" th:field="*{fobTwentyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">30%：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobThirty" th:field="*{fobThirty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">35%：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="fobThirtyFive" th:field="*{fobThirtyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">美金价值(5%)：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValFive" th:field="*{dollarValFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">10%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValTen" th:field="*{dollarValTen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">15%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValFifteen" th:field="*{dollarValFifteen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">20%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValTwenty" th:field="*{dollarValTwenty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">25%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValTwentyFive" th:field="*{dollarValTwentyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">30%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValThirty" th:field="*{dollarValThirty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">35%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="dollarValThirtyFive" th:field="*{dollarValThirtyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">毛利(5%)：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitFive" th:field="*{profitFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">10%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitTen" th:field="*{profitTen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">15%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitFifteen" th:field="*{profitFifteen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">20%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitTwenty" th:field="*{profitTwenty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">25%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitTwentyFive" th:field="*{profitTwentyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">30%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitThirty" th:field="*{profitThirty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">35%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="profitThirtyFive" th:field="*{profitThirtyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">管理费(5%)：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeFive" th:field="*{managFeeFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">

									<label class="col-sm-4 control-label">10%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeTen" th:field="*{managFeeTen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">15%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeFifteen" th:field="*{managFeeFifteen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">20%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeTwenty" th:field="*{managFeeTwenty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">25%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeTwentyFive" th:field="*{managFeeTwentyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">30%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeThirty" th:field="*{managFeeThirty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">35%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="managFeeThirtyFive" th:field="*{managFeeThirtyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
							<div class="row">
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">净利(5%)：</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitFive" th:field="*{netProfitFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">10%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitTen" th:field="*{netProfitTen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">15%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitFifteen" th:field="*{netProfitFifteen}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">20%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitTwenty" th:field="*{netProfitTwenty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">25%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitTwentyFive" th:field="*{netProfitTwentyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">30%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitThirty" th:field="*{netProfitThirty}" class="form-control" type="text">
										</div>
									</div>
								</div>
								<div class="form-group col-sm-3">
									<label class="col-sm-4 control-label">35%:</label>
									<div class="col-sm-8">
										<div class="input-group date">
											<input name="netProfitThirtyFive" th:field="*{netProfitThirtyFive}" class="form-control" type="text">
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</form>

			<div class="panel panel-default">
				<div  class="panel-heading">
					<h4 class="form-header h4 panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
						   href="#collapseThree">
							产品信息
						</a>
					</h4>
				</div>
				<div id="collapseThree" class="panel-collapse collapse">
					<div class="container-div panel-body">
						<div class="row">
							<div class="btn-group-sm" id="toolbarProduct" role="group">
								<a class="btn btn-success" onclick="addProduct();"> <i
										class="fa fa-plus"></i> 添加
								</a>
							</div>
							<div class="col-sm-12 select-table table-striped">
								<table id="bootstrap-table"></table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>

	</div>
	<div class="row">
        <div class="col-sm-offset-5 col-sm-10">
        	<button type="button" class="btn btn-sm btn-primary" onclick="submit()" shiro:hasPermission="crm:orderPrice:submit"><i class="fa fa-location-arrow"></i>提 交</button>&nbsp;
            <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: datetimepicker-js" />
	<th:block th:include="include :: bootstrap-table-editable-js" />
	<script th:inline="javascript">
		var productCategoryDatas = [[${@dict.getType('product_category')}]];
		var orderProductStatusDatas = [[${@dict.getType('order_product_status')}]];
		var prefix = ctx + "crm/orderPrice";
		var prefixProduct = ctx + "crm/product";
		var prefixOrderPriceProduct =  ctx + "crm/orderPriceProduct";
		var orderId=[[${orderId}]];
		
		$("#form-order-edit").validate({
			focusCleanup : true
		});
		
		$(function() {
            var options = {
                url: prefixOrderPriceProduct + "/listAll",
                removeUrl: prefixOrderPriceProduct + "/remove",
                showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
		        showPageGo: true,
		        onEditableSave: onEditableSave,
                modalName: "关联产品信息",
                queryParams : {
                    orderId:orderId
				},
                columns: [                
                {
                    field : 'orderProductId', 
                    title : '订单产品ID',
                    visible: false
                },
		        {
                    title: "序号",
                    formatter: function (value, row, index) {
                 	    return $.table.serialNumber(index);
                    }
                },
                {
                    field : 'orderId', 
                    title : '订单id',
                    visible: false
                },
                {
                    field : 'productId', 
                    title : '产品id',
                    visible: false
                },
				{
					field : 'supplier.supplierName',
					title : '供应商',
					sortable: true
				},
                {
                    field : 'product.productName', 
                    title : '产品名称'
                },
				{
					field : 'product.productSpec',
					title : '产品规格',
					sortable: true
				},
                {
                    field : 'sellPrice', 
                    title : '销售单价',
					editable : {
						type : 'text',
						title : '销售单价',
						emptytext : "【销售单价】为空",
						validate : function(value) {
							if (value.length == 0) {
								return '销售单价不能为空';
							}
							if (!isNumber(value)) {
						        return '销售单价必须为数字';
						    }	
						}
					}
                },
                {
                    field : 'productCount', 
                    title : '报价数量',
					editable : {
						type : 'text',
						title : '订购数量',
						emptytext : "【订购数量】为空",
						validate : function(value) {
							if (value.length == 0) {
								return '订购数量不能为空';
							}
							if (!(isNumber(value) && value % 1 === 0)) {
						        return '订购数量必须为数字';
						    }	
						}
					}
                },
                {
                    field : 'product.salePrice', 
                    title : '原价'
                },
                {
                    field : 'discount', 
                    title : '利润',
					editable : {
						type : 'text',
						title : '利润（1-100之间）',
						emptytext : "【利润】为空",
						validate : function(value) {
							if (value.length == 0) {
								return '利润不能为空';
							}
							if (!isNumber(value)) {
						        return '利润必须为【1-100】之间的数字';
						    }	
							if (parseInt(value)>100||parseInt(value)<0) {
						        return '利润必须为【1-100】之间的数字';
						    }
						}
					}
                },
                {
                    field : 'realPrice', 
                    title : '实际价格'
                },
				{
				    title: '图片',
				    formatter: function(value, row, index) {
				    	return $.table.imageView(row.product.productImage);
				    }
				},
                {
                    field : 'product.productCategory', 
                    title : '产品类别',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(productCategoryDatas, value);
                    },
		            sortable: true
                },
                {
                    field : 'orderProductStatus', 
                    title : '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(orderProductStatusDatas, value);
                    },
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        //actions.push('<a class="btn btn-success btn-xs '  + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.orderProductId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs '  + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderProductId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
		
		/* function queryParams(params) {
			debugger;
            //var search = $.table.queryParams(params);
            search.orderType = '10';
            return search;
        } */
		
		function onEditableSave (field, row, oldValue, $el) {
        	//alert("字段名：" + field + "，当前值：" + row[field]  + "，旧值：" + oldValue);
        	if(field=="productCount"){//订购数量
        		var data = { "orderPriceProductId": row.orderProductId, "productCount": row[field]};
    			$.operate.post(prefixOrderPriceProduct + "/updateOrderPriceProductCount", data);
        	}
        	else if(field=="sellPrice"){//销售价格
        		var data = { "orderPriceProductId": row.orderProductId, "sellPrice": row[field]};
    			$.operate.post(prefixOrderPriceProduct + "/updateOrderPriceSellPrice", data);
        	}
			else if(field=="discount"){//折扣
				var data = { "orderPriceProductId": row.orderProductId, "discount": row[field]};
    			$.operate.post(prefixOrderPriceProduct + "/updateOrderPriceDiscount", data);
        	}
        }
        
        function submit() {
			if ($.validate.form()) {
				$.modal.confirm("确认提交吗？", function() {
					$.operate.saveTab(prefix + "/submit", $('#form-order-edit').serialize());
	        	});
			}
		}

		function submitHandler() {
			if ($.validate.form()) {
				$.operate.saveTab(prefix + "/edit", $('#form-order-edit')
						.serialize());
			}
		}

		$("input[name='prcieDate']").datetimepicker({
			format : "yyyy-mm-dd",
			minView : "month",
			autoclose : true
		});
		
		$("input[name='prcieEndDate']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });
		
		/* 自动计算 */
		function autoCaculate(){
			var data = $("#" + table.options.id).bootstrapTable('getData');
			if (data.length == 0) {
       			$.modal.alertWarning("请添加产品后计算！");
       			return;
       		}
			var orderId= [[${orderId}]];
			$.ajax({
	            url: prefixOrderPriceProduct + "/selectOrderPrice",
	            data: {
					"orderPriceId" : orderId
				},
	            type: "post",
	            success: function(result) {
	            	if (result.code == 0) {
	            		$("#totalPrice").val(result.data.totalPrice);
	            		$("#costPrice").val(result.data.costPrice);
	            		$.modal.msgSuccess(result.msg);
	            	} else {
	            		$.modal.msgError(result.msg);
	            	}
	            },
				error : function(e) {
					$.modal.msgError("系统异常");
				}
	        })
		}


		/* 自动计算 */
		function autoCaculatea(){
			$.ajax({
				url: prefix + "/calculate",
				data: $('#form-order-edit').serialize(),
				type: "post",
				success: function(result) {
					if (result.code == 0) {
						$("input[name='totalWeight']").val(result.data.totalWeight);
						$("input[name='contWeight']").val(result.data.contWeight);
						$("input[name='totalPaymentGoods']").val(result.data.totalPaymentGoods);
						$("input[name='addedTax']").val(result.data.addedTax);
						$("input[name='transportAddedTax']").val(result.data.transportAddedTax);
						$("input[name='profitAddedTax']").val(result.data.profitAddedTax);
						$("input[name='taxRebates']").val(result.data.taxRebates);
						$("input[name='invoiceAmount']").val(result.data.invoiceAmount);
						$("input[name='totalEndTax']").val(result.data.totalEndTax);
						$("input[name='exchRate']").val(result.data.exchRate);
						$("input[name='fob']").val(result.data.fob);
						$("input[name='dollarVal']").val(result.data.dollarVal);
						$("input[name='profit']").val(result.data.profit);
						$("input[name='managFee']").val(result.data.managFee);
						$("input[name='netProfit']").val(result.data.netProfit);
						$("input[name='fobFive']").val(result.data.fobFive);
						$("input[name='dollarValFive']").val(result.data.dollarValFive);
						$("input[name='profitFive']").val(result.data.profitFive);
						$("input[name='managFeeFive']").val(result.data.managFeeFive);
						$("input[name='netProfitFive']").val(result.data.netProfitFive);
						$("input[name='fobTen']").val(result.data.fobTen);
						$("input[name='dollarValTen']").val(result.data.dollarValTen);
						$("input[name='profitTen']").val(result.data.profitTen);
						$("input[name='managFeeTen']").val(result.data.managFeeTen);
						$("input[name='netProfitTen']").val(result.data.netProfitTen);
						$("input[name='fobFifteen']").val(result.data.fobFifteen);
						$("input[name='dollarValFifteen']").val(result.data.dollarValFifteen);
						$("input[name='profitFifteen']").val(result.data.profitFifteen);
						$("input[name='managFeeFifteen']").val(result.data.managFeeFifteen);
						$("input[name='netProfitFifteen']").val(result.data.netProfitFifteen);
						$("input[name='fobTwenty']").val(result.data.fobTwenty);
						$("input[name='dollarValTwenty']").val(result.data.dollarValTwenty);
						$("input[name='profitTwenty']").val(result.data.profitTwenty);
						$("input[name='managFeeTwenty']").val(result.data.managFeeTwenty);
						$("input[name='netProfitTwenty']").val(result.data.netProfitTwenty);
						$("input[name='fobTwentyFive']").val(result.data.fobTwentyFive);
						$("input[name='dollarValTwentyFive']").val(result.data.dollarValTwentyFive);
						$("input[name='profitTwentyFive']").val(result.data.profitTwentyFive);
						$("input[name='managFeeTwentyFive']").val(result.data.managFeeTwentyFive);
						$("input[name='netProfitTwentyFive']").val(result.data.netProfitTwentyFive);
						$("input[name='fobThirty']").val(result.data.fobThirty);
						$("input[name='dollarValThirty']").val(result.data.dollarValThirty);
						$("input[name='profitThirty']").val(result.data.profitThirty);
						$("input[name='managFeeThirty']").val(result.data.managFeeThirty);
						$("input[name='netProfitThirty']").val(result.data.netProfitThirty);
						$("input[name='fobThirtyFive']").val(result.data.fobThirtyFive);
						$("input[name='dollarValThirtyFive']").val(result.data.dollarValThirtyFive);
						$("input[name='profitThirtyFive']").val(result.data.profitThirtyFive);
						$("input[name='managFeeThirtyFive']").val(result.data.managFeeThirtyFive);
						$("input[name='netProfitThirtyFive']").val(result.data.netProfitThirtyFive);
					} else {
						$.modal.msgError(result.msg);
					}
				},
				error : function(e) {
					$.modal.msgError("系统异常");
				}
			})
		}
		
		/* 报价单管理-修改-选择产品  */
		function addProduct()
		{
			var orderId= [[${orderId}]];
			$.modal.open('选择报价单产品', prefixProduct + '/selectOrderPriceProduct/'+orderId);
		}
		
		/* 订单管理-修改-选择客户  */
	    function selectCustomer() {
	    	var url = ctx + "crm/customer/selectCustomer";
	   		$.modal.open("选择客户", url);
		}
			
	    function isNumber(val){
	        var regPos = /^\d+(\.\d+)?$/; //非负浮点数
	        if(regPos.test(val)){
	            return true;
	        }else{
	            return false;
	        }
	    }
	</script>
</body>
</html>