<%@ 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="shiro" uri="http://shiro.apache.org/tags"%>
<%@page import="com.fadu.app.util.SystemCache"%>
<c:set var="contextPath" value="${pageContext.request.contextPath}"></c:set>
<!-- 诉保订单信息 -->
<link rel="stylesheet"
	  href="${contextPath}/static/assets/css/jquery-ui.css" />
<link rel="stylesheet"
	  href="${contextPath}/static/assets/css/datepicker.css" />
<link rel="stylesheet"
	  href="${contextPath}/static/assets/css/ui.jqgrid.css" />
<link rel="stylesheet"
	  href="${contextPath}/static/js/datatimepicker/bootstrap-datetimepicker.min.css" />
<style>
	.hr-line-dashed {
		background-color: #ffffff;
		border-top: 1px dashed #e7eaec;
		color: #ffffff;
		height: 1px;
		margin: 20px 0;
	}
	#sousuo{
		position: relative;
		top: -20px;
	}
</style>
<script>
	function setCity(obj){
		var val = obj.value;
		var sec = document.getElementById('cityId');
		sec.innerHTML = "<option value=''>全部</option>";
		if(val != ''){
			//ajax
			$.getJSON("${contextPath}/util/getCitysByProvince?provinceId="+val,function(result){
				$.each(result, function(i, v){
					sec.innerHTML+="<option value='"+v.name+"'>"+v.name+"</option>";
				});
			});
		}
	}
</script>

<div class="well well-sm">
	省：<select id="provinceId" onchange="setCity(this)">
	<option selected value="" >全部</option>
	<% for(String s:SystemCache.provinceMap.keySet()){ %>
	<option value="<%=s%>" ><%=SystemCache.getProvinceName(s) %></option>
	<%} %>
</select>
	市：<select id="cityId"></select>

	<input type="text" class="input-sm" placeholder="搜索关键字" id="keyword" />
	<select class="select" id="orderState">
		<option value="" selected="selected">状态</option>
		<option value="0">审核中</option>
		<option value="10">已取消</option>
		<option value="20">审核失败</option>
		<option value="21">审核反馈</option>
		<option value="22">待付款</option>
		<option value="30">待确认</option>
		<option value="31">付款反馈</option>
		<option value="32">待出函</option>
		<option value="40">已出函</option>
		<option value="41">已配送</option>
		<option value="50">退保处理中</option>
		<option value="51">退保成功</option>
		<option value="52">退保失败</option>

	</select>
	<%--<select class="select" id="orderPayType">
		<option value="-1" selected="selected">支付方式</option>
		<option value="3">在线支付</option>
		<option value="0">线下转账</option>
		<option value="1">微信</option>
		<option value="2">支付宝</option>
	</select>--%>

	<%--<select class="select" id="surrenderType">
		<option value="" selected="selected">是否退保</option>
		<option value="1">已退保</option>
	</select>--%>

	是否有效
	<select class="select" id="validState">
		<option value="2">全部订单</option>
		<option value="0" selected="selected" >有效</option>
		<option value="1"  >无效</option>
	</select>
	渠道
	<select class="select" id="isOnline">
		<option value="" selected="selected">所有订单</option>
		<option value="0" >非渠道订单</option>
		<option value="1">渠道订单</option>
	</select>
	<%--	是否老律师
        <select class="select" id="isOldLawyer">
          <option value="" selected="selected">所有订单</option>
          <option value="0" >非老律师订单</option>
          <option value="1">老律师订单</option>
       </select>--%>
	<%--是否重复订单
	<select class="select" id="isRepeat">
		<option value="2" >所有订单</option>
		<option value="0" selected="selected" >非重复订单</option>
		<option value="1" >重复订单</option>
	</select>
	客户经理
	<select class="select" id="isManager">
		<option value="" selected="selected">所有订单</option>
		<option value="0" >客户经理订单</option>
		<option value="1">非客户经理订单</option>
	</select>--%>
	<input type="text" class="input-sm" placeholder="订单开始时间" id="sendStart" />
	<input type="text" class="input-sm"	placeholder="订单结束时间" id="sendEnd" />

	<input type="text" class="input-sm" placeholder="订单付款开始时间" id="payStart" />
	<input type="text" class="input-sm"	placeholder="订单付款结束时间" id="payEnd" />
	<button type="button" class="btn btn-primary btn-sm" id="searchd">
		筛选
	</button>
	<button type="button" class="btn btn-success btn-sm" onclick='showothers()' id="showothers">
		显示字段
	</button>
	<button type="button" class="btn btn-primary btn-sm" onclick='calc()' id="calc">
		计算筛选后的保费
	</button>
	<%--<button type="button" class="btn btn-success btn-sm" onclick='exportOrder()'>
		导出excel表
	</button>--%>
	<button type="button" class="btn btn-danger btn-sm" data-toggle='modal' onclick='add()'>
		补单
	</button>
</div>

<div class="row">
	<div class="col-xs-12">
		<div id ="calc-result" class="bg-info" style="display:none">test</div>
		<table id="grid-table"></table>
		<div id="grid-pager"></div>
		<script type="text/javascript">
			var $path_base = "${contextPath}/static";//in Ace demo this will be used for editurl parameter
		</script>
		<!-- PAGE CONTENT ENDS -->
	</div>
	<!-- /.col -->
</div>
<!-- /.row -->

<div id="modal-table" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 650px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					订单详情
				</div>
			</div>
			<div class="modal-body" id="modal-table-body1"
				 style="max-height: 500px;overflow-y: scroll;">
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 关闭
					</button>
				</div>
			</div>
		</div>
	</div>
</div>


<!-- 模态框:跟单记录（Modal） -->
<div id="modal-gendan-records" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog" style="min-width: 380px;width:680px;">
		<div class="modal-content">
			<div class="modal-header bg-primary">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
				<h4 class="modal-title text-center" id="myModalLabel">跟单记录</h4>
			</div>
			<div class="modal-body" id="modal-audit-order-body">
				<input type="hidden" name="orderId" id="mod-gendan-orderId"/>
				<table id="gendanTable"></table>
			</div>
			<div class="form-group"  >
				<label class="col-sm-3 control-label">跟单信息图片:</label>
				<div>
					<input type="hidden" name="orderId" id="mod-gendan-orderId1" value=""/>
					<div id="div77-edit" class="checkbox-inline"></div>
					<input type="button" onclick="uploadGendanPic(77,'div77-edit')" value="上传跟单记录图片"/>
				</div>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 关闭
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="mod-add" class="modal fade" tabindex="-1" data-backdrop="static">
	<div class="modal-dialog" >
		<form id="AddForm">
			<div class="modal-content">
				<div class="modal-header no-padding">
					<div class="table-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							<span class="white">&times;</span>
						</button>
						后台补单
					</div>
				</div>
				<div class="modal-body" style="overflow-y: scroll;">
					<div id="mod-add-tip" class="red clearfix"></div>

					<div class="form-group">
						<label for="mod-add-loginName">公司登录名</label>
						<input type="text"  id="mod-add-loginName" class="searchIpt form-control" />
					</div>
					<div class="form-group">
						<label for="mod-add-courtName">法院</label>
						<input type="text" id="mod-add-courtName" class="form-control"  />
					</div>
					<div class="form-group">
						<label for="mod-add-lawyerTel">律师手机号</label>
						<input type="text"  id="mod-add-lawyerTel" class="form-control" />
					</div>
					<div class="form-group">
						<label for="mod-add-bdSum">保全金额</label>
						<input id="mod-add-bdSum" class="form-control" />
					</div>
					<div class="form-group">
						<label for="mod-add-bdCode">标的类型</label>
						<select class="select form-control" id="mod-add-bdCode">
							<option value="S101">房产</option>
							<option value="S102" selected="selected">银行账户类</option>
							<option value="S103">土地使用权</option>
							<option value="S104">非上市公司股权</option>
							<option value="S105">应收债权</option>
							<option value="S106">采矿权</option>
							<option value="S201">车辆</option>
							<option value="S202">船舶</option>
							<option value="S203">不易腐朽损坏货物</option>
							<option value="S204">机器设备</option>
							<option value="S205">商标专利</option>
							<option value="S301">上市公司股票</option>
							<option value="S302">非固定收益基金账户</option>
							<option value="S303">易腐朽损坏货物</option>
						</select>
					</div>
					<%--<div class="form-group">
						<label for="mod-add-bdCode1">混合标的（非必选）</label>
						<select class="select form-control" id="mod-add-bdCode1">
							<option value="" selected="selected">请选择</option>
							<option value="S101">房产</option>
							<option value="S102">银行账户类</option>
							<option value="S103">土地使用权</option>
							<option value="S104">非上市公司股权</option>
							<option value="S105">应收债权</option>
							<option value="S106">采矿权</option>
							<option value="S201">车辆</option>
							<option value="S202">船舶</option>
							<option value="S203">不易腐朽损坏货物</option>
							<option value="S204">机器设备</option>
							<option value="S205">商标专利</option>
							<option value="S301">上市公司股票</option>
							<option value="S302">非固定收益基金账户</option>
							<option value="S303">易腐朽损坏货物</option>
						</select>
					</div>--%>
					<%--<div class="form-group">
						<label for="mod-add-bdCode2">混合标的（非必选）</label>
						<select class="select form-control" id="mod-add-bdCode2">
							<option value="" selected="selected">请选择</option>
							<option value="S101">房产</option>
							<option value="S102">银行账户类</option>
							<option value="S103">土地使用权</option>
							<option value="S104">非上市公司股权</option>
							<option value="S105">应收债权</option>
							<option value="S106">采矿权</option>
							<option value="S201">车辆</option>
							<option value="S202">船舶</option>
							<option value="S203">不易腐朽损坏货物</option>
							<option value="S204">机器设备</option>
							<option value="S205">商标专利</option>
							<option value="S301">上市公司股票</option>
							<option value="S302">非固定收益基金账户</option>
							<option value="S303">易腐朽损坏货物</option>
						</select>
					</div>--%>
					<div class="form-group">
						<label for="mod-add-jfCommision">费率</label>
						<div class="input-group">
							<input type="text" id="mod-add-bfCommision" class="form-control" />
							<span class="input-group-addon">%</span>
						</div>
					</div>

					<div class="form-group">
						<label for="mod-add-bf">保费金额</label>
						<input id="mod-add-bf" class="form-control" />
					</div>
					<div class="form-group">
						<label for="mod-add-jfCommision">积分比例</label>
						<div class="input-group">
							<input type="text" id="mod-add-jfCommision" class="form-control" />
							<span class="input-group-addon">%</span>
						</div>
					</div>
					<div class="form-group">
						<label for="mod-add-points">积分</label>
						<input id="mod-add-points" class="form-control" />
					</div>
					<div class="form-group">
						<label for="mod-add-manager">客户经理</label>
						<input id="mod-add-manager" class="form-control" />
					</div>
					<div class="form-group" style="display: none">
						<label for="mod-add-payedDate">付款时间</label>
						<input id="mod-add-payedDate" class="form-control" placeholder="付款时间" />
					</div>
					<%--<div class="form-group">
                       <label for="mod-add-orderShippingType">配送方式</label>
                       <select class="select form-control" id="mod-add-orderShippingType">
                          <option value="4" selected="selected">顺丰/EMS配送</option>
                          <option value="5">同城闪送</option>
                          <option value="6">专人送函上门</option>
                       </select>
                    </div>--%>
					<%--<div class="form-group">
                     <label for="mod-add-deliveryAddress">收件地址</label>
                     <input id="mod-add-deliveryAddress" disabled  placeholder="待补充" class="form-control"/>
                 </div>
                 <div class="form-group">
                     <label for="mod-add-contactMan">联系人</label>
                     <input id="mod-add-contactMan" disabled  placeholder="待补充" class="form-control"/>
                 </div>
                 <div class="form-group">
                     <label for="mod-add-contactPhone">联系电话</label>
                     <input id="mod-add-contactPhone" disabled  placeholder="待补充" class="form-control"/>
                 </div>--%>
				</div>
				<div class="modal-footer no-margin-top">
					<div class="text-center">
						<button id="mod-add-submit" type="button" class="btn btn-sm btn-primary">
							<i class="ace-icon fa fa-floppy-o bigger-160"></i>
							保存
						</button>
						<button class="btn btn-sm" data-dismiss="modal">
							<i class="ace-icon fa fa-share bigger-160"></i>
							取消
						</button>
					</div>
				</div>
			</div><!-- /.modal-content -->
		</form>
	</div><!-- /.modal-dialog -->
</div>

<div id="modal-orderAttachs" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 650px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					订单文件
				</div>
			</div>
			<div class="modal-body" id="modal-orderAttachs-body"></div>
		</div>
	</div>
</div>
<!-- 增加跟单记录 -->
<div id="modal-gendan-edit" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 600px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header center">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					跟单记录
				</div>
			</div>
			<div class="modal-body" id="modal-gendan-body">
				<form id="editOrderForm" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-gendan-editId" />
					<div class="form-group" id="mod-gendan-div">
						<label class="col-sm-3 control-label left">选择跟单记录:</label>
						<div class="col-sm-12">
							<label class="checkbox-inline col-sm-6">
								<input type="radio" name="optionsRadiosinline" id="option1" value="保险公司审核中" checked/>保险公司审核中
							</label>
							<label class="checkbox-inline col-sm-5">
								<input type="radio" name="optionsRadiosinline" id="option2" value="待律师补充资料" />待律师补充资料
							</label>
							<label class="checkbox-inline col-sm-6">
								<input type="radio" name="optionsRadiosinline" id="option3" value="已通知律师付款" />已通知律师付款
							</label>
							<label class="checkbox-inline col-sm-5">
								<input type="radio" name="optionsRadiosinline" id="option4" value="待保险公司出函" />待保险公司出函
							</label>
							<label class="checkbox-inline col-sm-12">
								<input type="radio" name="optionsRadiosinline" id="option5" value="未联系到律师" />未联系到律师
							</label>
							<label class="checkbox-inline col-sm-3 text-left">
								<input type="radio" name="optionsRadiosinline" id="option6" class="col-sm-2" value="其他" >其他
							</label>
							<input type="text" id="mod-gendan-other" class="col-sm-6">
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-4 control-label">选择 下次跟单时间:</label>
						<div class="col-sm-4 text-left">
							<input type="text" class="form-control" id="nextDate" class="form-control " placeholder="选择下次跟单时间" />
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-gendan-submit" type="button"
							class="btn btn-sm btn-primary">
						<i class="ace-icon fa fa-floppy-o bigger-160"></i> 保存
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="modal-edit-order" class="modal fade" tabindex="-1"
	 data-backdrop="static" style="z-index: 99998">
	<div class="modal-dialog" style="min-width: 400px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					修改订单
				</div>
			</div>
			<div class="modal-body" id="modal-edit-order-body">
				<form id="editOrderForm2" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-edit-orderId" />
					<input type="hidden" name="jjgsId" id="mod-edit-jjgsId" />

					<div class="form-group"  >
						<label class="col-sm-3 control-label" style="text-align: left">状态修改</label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">状态:</label>
						<div class="col-sm-9 text-left">
							<select class="select" id="mod-edit-state">
								<option value="0">待审核</option>
								<option value="10">已取消</option>
								<option value="20">审核失败</option>
								<option value="21">审核反馈</option>
								<option value="22">待付款</option>
								<option value="30">待确认</option>
								<option value="31">付款反馈</option>
								<option value="32">待出函</option>
								<option value="40">已出函</option>
								<option value="41">已配送</option>
								<option value="50">退保处理中</option>
								<option value="51">退保成功</option>
								<option value="52">退保失败</option>
							</select>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">是否有效订单:</label>
						<div class="col-sm-9 text-left">
							<select class="select" id="mod-edit-valid">
								<option value="0" selected="selected">是</option>
								<option value="1">否</option>
							</select>
						</div>
					</div>
					<%--<div class="form-group">
						<label class="col-sm-3 control-label">是否是老律师:</label>
						<div class="col-sm-9 text-left">
							<select class="select" id="mod-edit-isOldLawyer">
								<option value="1" selected="selected">是</option>
								<option value="0">否</option>
							</select>
						</div>
					</div>--%>
					<div class="form-group">
						<label class="col-sm-3 control-label">是否是重复订单:</label>
						<div class="col-sm-9 text-left">
							<select class="select" id="mod-edit-isRepeat">
								<option value="1" selected="selected">是</option>
								<option value="0">否</option>
							</select>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label" style="text-align: left">字段修改</label>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">公司登录名:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-companyLoginName" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">保全金额:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-sqbd" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">法院:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-court" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">原告:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-plaintiff" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">保费:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-bf" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">返点比例:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-backProportion" class="form-control"/>
							<span class="input-group-addon">%</span>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">确认付款时间:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-payedate" class="form-control"/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group"  >
						<label class="col-sm-4 control-label" style="text-align: left">服务费修改</label>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">服务费比例:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-serviceCostPro" class="form-control"/>
							<span class="input-group-addon">%</span>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">修改理由:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-changeReason" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">修改依据:</label>
						<div id="div76-edit" class="checkbox-inline"></div>
						<input type="button" onclick="uploadEditPic(76,'div76-edit')" value="上传"/>
						<label>(上传和律师、保险公司的聊天记录)</label>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group"  >
						<label class="col-sm-8 control-label" style="text-align: left">审核通过，保险公司上传资料修改</label>
					</div>
					<%--<div class="form-group"  >
						<label class="col-sm-3 control-label">付款凭证:</label>
						<div id="div41-edit" class="checkbox-inline"></div>
						<input type="button" onclick="uploadEditPic(41,'div41-edit')" value="上传"/>
					</div>--%>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">投保单原件:</label>
						<div>
							<div id="div72-edit" class="checkbox-inline"></div>
							<input type="button" onclick="uploadEditPic(72,'div72-edit')" value="上传图片"/>
						</div>
						<br>
						<div>
							<label class="col-sm-3 control-label"> </label>
							<div class="checkbox-inline" id="div73-edit"></div>
							<input type="button" onclick="uploadEditFil(72,'div73-edit')" value="上传文件"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">保函电子版:</label>
						<div>
							<div id="div71-edit" class="checkbox-inline"></div>
							<input type="button" onclick="uploadEditPic(71,'div71-edit')" value="上传图片"/>
						</div>
						<br>
						<div>
							<label class="col-sm-3 control-label"> </label>
							<div class="checkbox-inline" id="div74-edit"></div>
							<input type="button" onclick="uploadEditFil(71,'div74-edit')" value="上传文件"/>
						</div>

					</div>
					<div class="form-group"  >
						<label class="col-sm-8 control-label" style="text-align: left">
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;保险公司收款账号信息：</label>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">账户名:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-accountName" class="form-control"/>
						</div>
						<div class="col-sm-8 input-group"></div>
						<div class="col-sm-8 input-group"></div>
						<div class="col-sm-8 input-group"></div>
						<label class="col-sm-3 control-label">账号:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-accountNum" class="form-control"/>
						</div>
						<div class="col-sm-8 input-group"></div>
						<div class="col-sm-8 input-group"></div>
						<div class="col-sm-8 input-group"></div>
						<label class="col-sm-3 control-label">开户行:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-accountBank" class="form-control"/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group"  >
						<label class="col-sm-8 control-label" style="text-align: left">律师上传资料修改</label>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">付款凭证:</label>
						<div>
							<div id="div41-edit" class="checkbox-inline"></div>
							<input type="button" onclick="uploadEditPic(41,'div41-edit')" value="上传图片"/>
						</div>
						<br>
						<div>
							<label class="col-sm-3 control-label"> </label>
							<div class="checkbox-inline" id="div66-edit"></div>
							<input type="button" onclick="uploadEditFil(41,'div66-edit')" value="上传文件"/>

						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">投保单照片:</label>
						<div>
							<div id="div52-edit" class="checkbox-inline"></div>
							<input type="button" onclick="uploadEditPic(52,'div52-edit')" value="上传图片"/>

						</div>
						<br>
						<div>
							<label class="col-sm-3 control-label"></label>
							<div class="checkbox-inline" id="div88-edit"></div>
							<input type="button" onclick="uploadEditFil(52,'div88-edit')" value="上传文件"/>

						</div>

					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group"  >
						<label class="col-sm-4 control-label" style="text-align: left">开票信息</label>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">单位名称：</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-orderFpName" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">纳税人识别号:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-taxNum" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">地址:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-addr" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">电话:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-tel" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">开户行名:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-bankName" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">开户账号:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-bankAccount" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">开票信息图片:</label>
						<div>
							<div id="div733-edit" class="checkbox-inline"></div>
							<input type="button" onclick="uploadEditPic(73,'div733-edit')" value="上传图片"/>
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group"  >
						<label class="col-sm-8 control-label" style="text-align: left">其它信息修改</label>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">配送方式:</label>
						<div class="col-sm-9 text-left">
							<select class="select" id="delivery">
								<option value="4">顺丰/EMS配送</option>
								<option value="5">同城闪送</option>
								<option value="6">专人送函上门</option>
							</select>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label">跟单人员:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="mod-edit-documentaryUser" class="form-control"/>
						</div>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">客户经理修改:</label>
						<div class="col-sm-8 input-group">
							<input type="text" id="managerName" class="form-control"/>
						</div>
					</div>
					<div class="form-group"  >
						<label class="col-sm-3 control-label"  >修改记录:</label>
						<label id="changeHis"></label>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-edit-order-submit" type="button"
							class="btn btn-sm btn-primary">
						<i class="ace-icon fa fa-floppy-o bigger-160"></i> 保存
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="modal-surrender" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 650px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					是否退保
				</div>
			</div>
			<div class="modal-body" id="modal-surrender-body">
				<form id="editCompany" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-surrender-orderId" />
					<div class="form-group" id="mod-surrender-div">
						<label class="col-sm-2 control-label">是否退保:</label>
						<div class="col-sm-10 text-left">
							<select class="select" id="mod-surrender" name="mod-surrender">
								<option value="0">否</option>
								<option value="1">是</option>
							</select>
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-surrender-submit" type="button"
							class="btn btn-sm btn-primary" onclick="saveWlAddressInfo()">
						<i class="ace-icon fa fa-floppy-o bigger-160"></i> 保存
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="modal-distribution2" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 450px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					安排配送
				</div>
			</div>
			<div class="modal-body" id="modal-distribution-body2">
				<form id="editDistribution2" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-distribution-orderId2" />
					<input type="hidden" name="orderShippingType" id="mod-distribution-orderShippingType" />
					<input type="hidden" name="orderId" id="mod-distribution-ssdborderwlId2" />
					<div class="form-group">
						<label class="col-sm-2 control-label">寄件信息</label>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div2">
						<label class="col-sm-3 control-label" id="mod-distribution-sendcompany_name">快递公司:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-sendcompany"  placeholder="默认顺丰，其他快递请输入" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div3">
						<label class="col-sm-3 control-label" id="mod-distribution-sendOrderNum_name">快递单号:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-sendOrderNum" class="form-control" />
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-distribution-submit2" type="button"
							class="btn btn-sm btn-primary" onclick="saveWlInfo();">
						确定
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="modal-feedBack" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 450px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					审核反馈
				</div>
			</div>
			<div class="modal-body" id="modal-feedback-body2">
				<form id="form_feedback" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-orderId2" />
					<div class="form-group" style="margin-left: 18%">
						<input name="feedBackRadio" type="radio" value="22"  />
						<label class=" control-label " style="text-align: left;width:66%">审核通过</label>
					</div>
					<div class="form-group" style="margin-left: 18%">
						<input name="feedBackRadio" type="radio" value="21" />
						<label class="  control-label" style="text-align: left">审核反馈</label>
						<input   type="text" value=""   style="text-align: left;width:66%" id="feedbackText"/>
					</div>
					<div class="form-group" style="margin-left: 18%">
						<input name="feedBackRadio" type="radio" value="20"/>
						<label class=" control-label" style="text-align: left">审核失败</label>
						<input  type="text" value="" style="text-align: left;width:66%" id="failFeedBackText"/>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-feedback-submit2" type="button"
							class="btn btn-sm btn-primary" >
						确定
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="modal-distribution3" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 450px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					修改保函收件地址
				</div>
			</div>
			<div class="modal-body" id="modal-distribution-body3">
				<form id="editDistribution3" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-distribution-orderId3" />
					<input type="hidden" name="orderShippingType" id="mod-distribution-orderShippingType1" />
					<input type="hidden" name="orderId" id="mod-distribution-ssdborderwlId3" />
					<div class="form-group">
						<label class="col-sm-5 control-label">保函收件地址</label>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div4">
						<label class="col-sm-3 control-label" id="mod-distribution-receiver_name">收件人:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-receiver" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div5">
						<label class="col-sm-3 control-label" id="mod-distribution-contacts_name">联系人:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-contacts" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div6">
						<label class="col-sm-3 control-label" id="mod-distribution-adress_name">地址:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-adress" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div7">
						<label class="col-sm-3 control-label" id="mod-distribution-remark_name">备注:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-remark" class="form-control" />
						</div>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-distribution-submit3" type="button"
							class="btn btn-sm btn-primary" onclick="saveWlAddressInfo()">
						确定
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>

<div id="modal-distribution" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 450px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					安排闪送配送
				</div>
			</div>
			<div class="modal-body" id="modal-distribution-body">
				<form id="editDistribution" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-distribution-orderId" />
					<input type="hidden" name="orderId" id="mod-distribution-ssdborderwlId" />
					<div class="form-group">
						<label class="col-sm-2 control-label">寄件信息</label>
					</div>
					<div class="form-group" id="mod-distribution-sendname-div">
						<label class="col-sm-2 control-label">寄件人:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-sendname" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendphone-div">
						<label class="col-sm-2 control-label">联系电话:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-sendphone" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendaddress-div">
						<label class="col-sm-2 control-label">寄件地址:</label>
						<div class="col-sm-2 text-left">
							<input type="text" id="mod-distribution-sendaddresscity" class="form-control" placeholder="如:北京市" onchange="changeSendAddress()"/>
						</div>
						<div class="col-sm-5 text-left">
							<input type="text" id="mod-distribution-sendaddress" class="form-control" placeholder="如:海淀区软件园" onchange="changeSendAddress()"/>
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendaddressdital-div">
						<label class="col-sm-2 control-label"></label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-sendaddressdital" class="form-control" placeholder="街道详细（精确到门牌号）" onchange="changeSendAddress()"/>
						</div>
					</div>
					<div class="form-group" id="mod-distribution-sendcoordinate-div">
						<label class="col-sm-2 control-label">经纬度:</label>
						<div class="col-sm-3 text-left">
							<input type="text" id="mod-distribution-sendlatitude" class="form-control" />
						</div>
						<div class="col-sm-3 text-left">
							<input type="text" id="mod-distribution-sendlongitude" class="form-control" />
						</div>
					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">收件信息</label>
					</div>
					<div class="form-group" id="mod-distribution-recname-div">
						<label class="col-sm-2 control-label">收件人:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-recname" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-recphone-div">
						<label class="col-sm-2 control-label">联系电话:</label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-recphone" class="form-control" />
						</div>
					</div>
					<div class="form-group" id="mod-distribution-recaddress-div">
						<label class="col-sm-2 control-label">收件地址:</label>
						<div class="col-sm-2 text-left">
							<input type="text" id="mod-distribution-recaddresscity" class="form-control" placeholder="如:广州市" onchange="changeRecAddress()"/>
						</div>
						<div class="col-sm-5 text-left">
							<input type="text" id="mod-distribution-recaddress" class="form-control" placeholder="如:天河城百货" onchange="changeRecAddress()"/>
						</div>
					</div>
					<div class="form-group" id="mod-distribution-recaddressdital-div">
						<label class="col-sm-2 control-label"></label>
						<div class="col-sm-7 text-left">
							<input type="text" id="mod-distribution-recaddressdital" class="form-control" placeholder="街道详细（精确到门牌号）" onchange="changeRecAddress()"/>
						</div>
					</div>
					<div class="form-group" id="mod-distribution-reccoordinate-div">
						<label class="col-sm-2 control-label">经纬度:</label>
						<div class="col-sm-3 text-left">
							<input type="text" id="mod-distribution-reclatitude" class="form-control" />
						</div>
						<div class="col-sm-3 text-left">
							<input type="text" id="mod-distribution-reclongitude" class="form-control" />
						</div>
					</div>

				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button id="modal-distribution-submit" type="button"
							class="btn btn-sm btn-primary">
						闪送下单
					</button>
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 取消
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<div id="modal-distributiondetail" class="modal fade" tabindex="-1"
	 data-backdrop="static">
	<div class="modal-dialog" style="min-width: 450px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal"
							aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					闪送配送详情
				</div>
			</div>
			<div class="modal-body" id="modal-distributiondetail-body">
				<form id="showDistribution" class="form-horizontal">
					<input type="hidden" name="orderId" id="mod-distributiondetail-orderId" />
					<input type="hidden" name="orderId" id="mod-distributiondetail-ssdborderwlId" />
					<div class="form-group">
						<label class="col-sm-3 control-label">订单号：</label>
						<label class="col-sm-3 control-label" id="distributiondetail_orderId"></label>
					</div>
					<div class="form-group">
						<label class="col-sm-3 control-label">配送状态：</label>
						<label class="col-sm-3 control-label" id="distributiondetail_type"></label>
					</div>
					<div class="form-group" id="modal-distributiondetail_group">
						<label class="col-sm-3 control-label">配送员：</label>
						<label class="col-sm-2 control-label" id="distributiondetail_courierName"></label>
						<label class="col-sm-2 control-label">电话：</label>
						<label class="col-sm-2 control-label" id="distributiondetail_courierphone"></label>
					</div>
					<div class="form-group " id="modal-distributiondetail_mapgroup">
						<input type="text" id="mod-distributiondetail-mapdata" class="form-control" style="display: none;"/>
						<label class="col-sm-2 control-label"></label>
						<div class="col-sm-10">
							<button type="button" class="btn btn-default col-sm-10 col-sm-offset-2" style="border-radius:4px;" onclick="showMap()"> >>>点击查看实时轨迹<<< </button>
						</div>

					</div>
					<div class="hr-line-dashed"></div>
					<div class="form-group">
						<label class="col-sm-2 control-label">寄件信息</label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">寄件人:</label>
						<label class="col-sm-3 control-label" id="distributiondetail_sendname"></label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">寄件人电话:</label>
						<label class="col-sm-3 control-label" id="distributiondetail_send_phone"></label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">寄件地址:</label>
						<label class="col-sm-8 control-label" id="distributiondetail_send_address" style="text-align:left"></label>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label">收件信息</label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">收件人:</label>
						<label class="col-sm-3 control-label" id="distributiondetail_recname"></label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">收件人电话:</label>
						<label class="col-sm-3 control-label" id="distributiondetail_recphone"></label>
					</div>
					<div class="form-group" >
						<label class="col-sm-3 control-label">收件地址:</label>
						<label class="col-sm-8 control-label" id="distributiondetail_recaddress" style="text-align:left"></label>
					</div>
				</form>
			</div>
			<div class="modal-footer no-margin-top">
				<div class="text-center">
					<button class="btn btn-sm" data-dismiss="modal">
						<i class="ace-icon fa fa-share bigger-160"></i> 关闭
					</button>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- 图片上传 -->
<div id="mod-pic" class="modal fade" tabindex="-1" style="z-index: 99999">
	<div class="modal-dialog" style="max-width: 500px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					图片上传
				</div>
			</div>
			<div class="modal-body">
				<div class="row">
					<div class="col-xs-12">

						<!-- PAGE CONTENT BEGINS  -->
						<form id="picform" >
							<input id="picFileId" type="file" name="picfile" multiple="multiple" />
							<input type="hidden" name="attachType" id="mod-pic-attachType"/>
							<input type="hidden" name="divId" id="mod-pic-divId"/>
							<input type="hidden" name="orderId" id="mod-pic-orderId1" value=""/>
							<div class="hr hr-12 dotted"></div>
							<div class="text-center">
								<button type="button" class="btn btn-sm btn-primary" onclick="updatePic()">上传</button>
								<button type="reset" class="btn btn-sm">清除</button>
							</div>
						</form>
					</div><!-- /.col -->
				</div><!-- /.row -->

			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>

<!-- 图片上传 -->
<div id="mod-gendan" class="modal fade" tabindex="-1" style="z-index: 99999">
	<div class="modal-dialog" style="max-width: 500px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					跟单图片上传
				</div>
			</div>
			<div class="modal-body">
				<div class="row">
					<div class="col-xs-12">

						<!-- PAGE CONTENT BEGINS  -->
						<form id="gendanform" class="form-horizontal">
							<input id="gendanId" type="file" name="gendanfile" multiple />
							<input type="hidden" name="attachType" id="mod-gendan-attachType"/>
							<input type="hidden" name="divId" id="mod-gendan-divId"/>
							<input type="hidden" name="orderId" id="mod-gen-orderId1" value=""/>
							<div class="hr hr-12 dotted"></div>
							<div class="text-center">
								<button type="button" class="btn btn-sm btn-primary" onclick="updateGendanPic()">上传</button>
								<button type="reset" class="btn btn-sm">清除</button>
							</div>
						</form>
					</div><!-- /.col -->
				</div><!-- /.row -->

			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>

<%--文件上传--%>
<div id="mod-file" class="modal fade" tabindex="-1" style="z-index: 99999">
	<div class="modal-dialog" style="max-width: 500px;">
		<div class="modal-content">
			<div class="modal-header no-padding">
				<div class="table-header">
					<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
						<span class="white">&times;</span>
					</button>
					文件上传
				</div>
			</div>
			<div class="modal-body">
				<!-- PAGE CONTENT BEGINS -->
				<form id="fileform" class="form-horizontal">
					<input id="FileId" type="file" name="file" multiple />
					<input type="hidden" name="attachType" id="mod-file-attachType"/>
					<input type="hidden" name="divId" id="mod-file-divId"/>
					<input type="hidden" name="orderId" id="mod-file-orderId1" value=""/>
					<div class="hr hr-12 dotted"></div>
					<div class="text-center">
						<button type="button" class="btn btn-sm btn-primary" onclick="updateFile()">上传</button>
						<button type="reset" class="btn btn-sm">清除</button>
					</div>
				</form>
			</div>
		</div><!-- /.modal-content -->
	</div><!-- /.modal-dialog -->
</div>
<%@include file="/WEB-INF/page/back/auth.jsp"%>
<script type="text/javascript" src="${contextPath}/static/js/copyplugins/clipboard.min.js"></script>
<!-- page specific plugin scripts -->
<script type="text/javascript">
	var hiddenModalBody = null;
	var myGrid = null;
	var gendanTable = null;
	var scripts = [ null,
		"http://gosspublic.alicdn.com/aliyun-oss-sdk-4.3.0.min.js?v="+Math.random(),
		"${contextPath}/static/js/contract/picupload.js?v="+Math.random(),
		"${contextPath}/static/js/contract/fileupload.js?v="+Math.random(),
		"${contextPath}/static/js/contract/gendanFileupload.js?v="+Math.random(),
		"${contextPath}/static/assets/js/date-time/bootstrap-datepicker.js",
		"${contextPath}/static/assets/js/bootstrap-typeahead.js",
		"${contextPath}/static/js/contract/uuid.js",
		"${contextPath}/static/assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js",
		"${contextPath}/static/assets/js/jqGrid/jquery.jqGrid.js",
		"${contextPath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js",
		"${contextPath}/static/assets/js/lazyload/jquery.lazyload.js",
		"${contextPath}/static/js/datatimepicker/bootstrap-datetimepicker.zh-CN.js",
		"${contextPath}/static/js/datatimepicker/bootstrap-datetimepicker.min.js",
		"${contextPath}/static/js/datatimepicker/bootstrap-datetimepicker.min.css",
		null ]

	$("#mod-add-bf").on('input',function(e){
		var jfCommision = $("#mod-add-jfCommision").val();
		var bf = $("#mod-add-bf").val();
		if(jfCommision != null && bf != null){
			$("#mod-add-points").val(Math.round(jfCommision/10*bf,2));
		}
	});
	$("#mod-add-bdSum").on('input',function(e){
		var bfCommision = $("#mod-add-bfCommision").val();
		var bq = $("#mod-add-bdSum").val();
		if(bfCommision != null && bq != null){
			$("#mod-add-bf").val(Math.ceil(bfCommision/100*bq,2));
		}
		var jfCommision = $("#mod-add-jfCommision").val();
		var bf = $("#mod-add-bf").val();
		if(jfCommision != null && bf != null){
			$("#mod-add-points").val(Math.round(jfCommision/10*bf,2));
		}
	});

	$("#mod-add-jfCommision").on('input',function(e){
		var jfCommision = $("#mod-add-jfCommision").val();
		var bf = $("#mod-add-bf").val();
		$("#mod-add-points").val(Math.round(jfCommision/10*bf,2));
	});
	$("#mod-add-bfCommision").on('input',function(e){
		var bfCommision = $("#mod-add-bfCommision").val();
		var bq = $("#mod-add-bdSum").val();
		if(bfCommision != null && bq != null){
			$("#mod-add-bf").val(Math.ceil(bfCommision/100*bq,2));
		}
		var jfCommision = $("#mod-add-jfCommision").val();
		var bf = $("#mod-add-bf").val();
		if(jfCommision != null && bf != null){
			$("#mod-add-points").val(Math.round(jfCommision/10*bf,2));
		}
	});

	$("#mod-add-points").on('input',function(e){
		var points = $("#mod-add-points").val();
		var bf = $("#mod-add-bf").val();
		$("#mod-add-jfCommision").val(Math.round(points*10/bf,2));
	});
	$("#mod-add-bf").on('input',function(e){
		var bf = $("#mod-add-bf").val();
		var bq = $("#mod-add-bdSum").val();
		$("#mod-add-bfCommision").val(Math.round(bf/bq*100));
	});

	$('.page-content-area').ace_ajax('loadScripts', scripts, function() {
		// inline scripts related to this page
		jQuery(function($) {
			var grid_selector = "#grid-table";
			var pager_selector = "#grid-pager";
			var gendan_selector = "#gendanTable";
			// resize to fit page size
			$(window).on('resize.jqGrid', function() {
				$(grid_selector).jqGrid('setGridWidth', $(".page-content").width());
			});
			// resize on sidebar collapse/expand
			var parent_column = $(grid_selector).closest('[class*="col-"]');

			initGendanTalbe();

			$(document).on('settings.ace.jqGrid', function(ev, event_name, collapsed) {
				if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
					// setTimeout is for webkit only to give time for DOM changes and then redraw!!!
					setTimeout(function() {
						$(grid_selector).jqGrid('setGridWidth', parent_column.width());
					}, 0);
				}
			});

			$('#mod-gendan-other').bind('input propertychange', function() {
				$("input[id='option6']").get(0).checked=true;
			});

			function initGendanTalbe(orderId){
				gendanTable = jQuery(gendan_selector).jqGrid({
					subGrid : false,
					url : "${contextPath}/order/getGendan?orderId=?"+orderId,
					datatype : "local",
					height : "auto",
					autowidth:true,
					colNames : ["修改时间", "订单状态", "跟单记录", "下次跟进时间", "跟单客服"],
					colModel : [{
						name : "updateDate",
						index : "updateDate",
						label : "修改时间",
						width : 140,
						align : "center",
						search : false,
						formatter : formatCreateDate,
					},{
						name : "orderState",
						index : "orderState",
						label : "订单状态",
						align : "center",
						width : 70,
						search : false,
					},{
						name : "gendanRecord",
						index : "gendanRecord",
						label : "跟单记录",
						align : "center",
						width : 180,
						sortable: false,
						search : false
					},{
						name : "nextDate",
						index : "nextDate",
						label : "下次跟进时间",
						width : 140,
						align : "center",
						search : false,
						formatter : formatCreateDate,
					},{
						name : "gendanUser",
						index : "gendanUser",
						label : "跟单客服",
						align : "right",
						width : 90,
						sortable: false,
						search : false
					}],
					sortname : "updateDate",
					sortorder : "asc",
					viewrecords : false,
					rowNum : 36,
					rowList : [ 10, 20, 30 ],
					altRows : true,
					//toppager : true,
					multiselect : false,
					//multikey : "ctrlKey",
					multiboxonly : true,
					rownumbers:false,
					rownumWidth:30,
					//gridComplete: completeMethod,
					footerrow:true,
				}).trigger("reloadGrid"); //重新载入
			}

			$("#searchd").click(function(){
				$("#calc-result").hide();
				var keyword =$("#keyword").val();
				var orderState = $("#orderState").val();
				/*var payType = $("#orderPayType").val();
				var surrender = $("#surrenderType").val();*/
				var isOnline = $("#isOnline").val();
				// var isOldLawyer = $("#isOldLawyer").val();
				var isRepeat = $("#isRepeat").val();
				var isManager = $("#isManager").val();
				var sendStart = $("#sendStart").val();
				var sendEnd = $("#sendEnd").val();
				var payStart = $("#payStart").val();
				var payEnd = $("#payEnd").val();
				var validState = $("#validState").val();
				var obj =  document.getElementById('provinceId');
				var provinceId = obj.options[obj.selectedIndex].text; //文本
				var cityId = $("#cityId").val();
				if(provinceId == "全部"){
					provinceId = null;
				}
				if(sendStart.length < 1 && sendEnd.length > 1){
					alert('出函开始时间不能为空');
					return;
				}
				if(sendStart.length > 1 && sendEnd.length < 1){
					alert('出函结束时间不能为空');
					return;
				}
				if(sendStart.length > 1 && sendEnd.length > 1){
					if(checkNotDate(sendStart)){
						alert('出函开始时间错误');
						return;
					}
					if(checkNotDate(sendEnd)){
						alert('出函结束时间错误');
						return;
					}
					var startTime = new Date(Date.parse(sendStart.replace(/-/g, "/")));
					var endTime = new Date(Date.parse(sendEnd.replace(/-/g, "/")));
					if(endTime.getTime() < startTime.getTime()){
						alert('出函开始时间不能小于出函结束时间');
						return;
					}
				}
				myGrid.setGridParam({postData:{'keyword':keyword,'orderState':orderState/*,'payType':payType*/,'provinceId':provinceId,
						'cityId':cityId,'sendStart':sendStart,'sendEnd':sendEnd,/* 'surrender':surrender, */
						'isOnline':isOnline,'isManager':isManager,'validState':validState,'payStart':payStart,
						'payEnd':payEnd,'isRepeat':isRepeat,'type':"manager"},
					url : '${contextPath}/sys/ssdbOrder/getOrder'}).trigger('reloadGrid');
			});
			myGrid = jQuery(grid_selector).jqGrid({
				subGrid : false,
				url : "${contextPath}/sys/ssdbOrder/getOrder?type=manager",
				datatype : "json",
				height : "auto",
				mtype: 'POST',

				colModel : [{
					name : 'orderId',
					index : 'orderId',
					label : '订单号',
					width : 140,
					editable : false
				},{
					name : 'createDate',//1449829970000
					index : 'createDate',
					label : '提交时间',
					width : 120,
					search : false,
					editable : false,
					formatter : formatCreateDate
				},{
					name : 'uploadPayDate',//1449829970000
					index : 'uploadPayDate',
					label : '付款时间',
					width : 120,
					search : false,
					sortable : true,
				},{
					name : 'payedDate',
					label : '确认付款时间',
					width : 120,
					hidden : true,
				},{
					name : 'sendDate',//1449829970000
					index : 'sendDate',
					label : '出函时间',
					width : 120,
					search : false,
					editable : false,
					formatter : formatCreateDate
				},{
					name : 'loginName',
					label : '登录名',
					width : 120,
				},{
					name : 'companyName',
					label : '公司全称',
					width : 120,
					hidden : true,
				},{
					name : 'province',
					label : '省',
					width : 120,
					hidden : true,
				},{
					name : 'cityName',
					label : '市',
					width : 120,
					hidden : true,
				},{
					name : 'courtName',
					index :'courtName',
					label : '法院',
					width :180,
				},{
					name : 'plaintiff',
					index :'plaintiff',
					label : '原告',
					width :80,
					hidden : false,
				},{
					name : 'realName',
					index :'realName',
					label : '律师',
					width :80,
					export:false
				},{
					name : 'mobile',
					index :'mobile',
					label : '律师手机号',
					width :120,
					export:false
				},{
					name : 'sqbd',
					label : '保全金额',
					width :100,
					search : false,
					hidden : true,
				},{
					name : 'bdCode',
					label : '标的类型',
					width :100,
					search : false,
					hidden : true,
				},{
					name : 'bf',
					label : '保费',
					width :100,
					search : false,
				},{
					name : 'points',
					label : '积分',
					width :100,
					search : false,
				},{
					name : 'commisionLawyer',
					label : '返点比例',
					width :100,
					search : false,
				},{
					name : 'shTime',
					label : '审核时长',
					width : 80,
					hidden : true,
				},{
					name : 'chTime',
					label : '出函时长',
					width : 80,
					hidden : true,
				},{
					name : 'orderStateName',
					label : '订单状态',
					width : 160,
					formatter : optionOverFormatter
				},{
					name : 'gendanRecord',
					label : '最新跟单记录  ',
					width : 110,
				},{
					name : 'nextDate',
					label : '下次跟单时间',
					width : 100,
					sortable : true,
					formatter : formatCreateDate
				},{
					name : 'newUser',
					label : '是否新用户',
					width : 80,
				},{
					name : 'managerName',
					label : '客户经理',
					width : 80,
				},{
					name : 'documentaryUser',
					label : '跟单人员',
					width : 80,
				},{
					name : 'id',
					index : '',
					label : '操作',
					width : 160,
					editable : false,
					search : false,
					sortable : false,
					fixed:true,
					formatter : optionFormatter
				},{
					name : 'id',
					index : '',
					label : '跟单记录操作',
					width : 150,
					editable : false,
					search : false,
					sortable : false,
					fixed:true,
					formatter : gendanOptionFormatter
				}],
				//scroll : 1, // set the scroll property to 1 to enable paging with scrollbar - virtual loading of records
				sortname : "createDate",
				sortorder : "desc",
				viewrecords : true,
				rowNum : 30,
				rowList : [ 30, 100, 500 ,2000],
				pager : pager_selector,
				altRows : true,
				//toppager : true,
				//multiselect : true,
				//multikey : "ctrlKey",
				//multiboxonly : true,
				loadComplete : function() {
					var table = this;
					setTimeout(function(){
						styleCheckbox(table);
						updateActionIcons(table);
						updatePagerIcons(table);
						enableTooltips(table);
					}, 0);
				},
				//caption : "用户管理列表",
				//autowidth : true,
				/**
				 grouping : true,
				 groupingView : {
        				 groupField : ['name'],
        				 groupDataSorted : true,
        				 plusicon : 'fa fa-chevron-down bigger-110',
        				 minusicon : 'fa fa-chevron-up bigger-110'
        			},
				 */
			});

			function formatCommentFlag(cellvalue, options, rowObject){
				if(cellvalue==1)
					return "已评论";
				if(cellvalue==1)
					return "未评论";
				return "";
			}


			function optionOverFormatter(cellvalue, options, rowObject){
				var template = cellvalue ;
				if (rowObject.overTime == 1) {
					template += "  <button type=\"button\" style='background-color: #d30404;'><span style='color:white'>已超时</span></button>";
				}
				return template;
			}

			function formatCreateDate(cellvalue, options, rowObject){
				var result = "";
				if(cellvalue != null){
					var d = new Date(cellvalue);
					result = d.getFullYear() + '-' + formatDate(d.getMonth() + 1) + "-" + formatDate(d.getDate()) + ' ' + formatDate(d.getHours()) + ":" + formatDate(d.getMinutes()) + ":" + formatDate(d.getSeconds());
				}
				console.log(result);
				return result;
			}

			function formatDate(d){
				var result = "";
				if(d > 9){
					result = d.toString();
				}else{
					result = '0' + d.toString();
				}
				return result;
			}

			function formatPayType(cellvalue, options, rowObject){
				var result = "";
				if(cellvalue == 0){
					result = "线下转账";
				}else if(cellvalue == 1){
					result = "微信";
				}else if(cellvalue == 2){
					result = "支付宝";
				}
				return result;
			}

			function optionFormatter(cellvalue, options, cell) {
				var template = "<button data-toggle='modal' onclick='showdetail1(\""+cell.orderId+"\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>详细</button>&nbsp;|&nbsp;";
				template += "<button data-toggle='modal' onclick='getSysuser(\""+cell.orderId+"\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>修改</button>" + "<br>";
				// template += "<button data-toggle='modal' onclick='showSurrender(\""+cell.orderId+"\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>退保</button>";
				if(cell.orderShippingType.indexOf("闪送") != -1 && cell.ssOrderType != '00'&& cell.ssOrderType != '64' && cell.ssOrderType != '-1'){
					template += "&nbsp;|&nbsp<button data-toggle='modal' onclick='showWaitToDist(\"" + cell.orderId + "\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>闪送详情</button>";
				}else if((cell.orderServiceType == '普通订单' && cell.orderState >= 32 && cell.orderState < 41 &&　cell.orderShippingType.indexOf("闪送") != -1 && (cell.ssOrderType == '00' || cell.ssOrderType == '-1'))|| (cell.orderServiceType == '先出函后付费' && cell.orderState >= 22 && cell.orderState < 41 && cell.orderShippingType.indexOf("闪送") != -1 && (cell.ssOrderType == '00' || cell.ssOrderType == '-1'))) {
					template += "&nbsp;|&nbsp<button data-toggle='modal' onclick='showDistribution(\"" + cell.orderId + "\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>配送</button>";
				} else if (cell.orderState == 40) {
					template += "&nbsp;|&nbsp<button data-toggle='modal' onclick='showWLInfo(\"" + cell.orderId + "\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>配送</button>";
				}
				if (cell.orderState == 0 || cell.orderState == 21) {
					template += "&nbsp;|&nbsp<button data-toggle='modal' onclick='showFeedBack(\"" + cell.orderId + "\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>反馈</button>";
				}
				template += "<button data-toggle='modal' onclick='updateCompany(\""+cell.orderId+"\")' class='btn btn-minier btn-info'>更换保险公司</button>" + "<br>";
				return template;
			}

			function gendanOptionFormatter(cellvalue, options, cell) {
				var gendan = "<button data-toggle='modal' onclick='showGendan(\""+cell.orderId+"\")' class='btn btn-minier btn-blue'><i class='ace-icon fa fa-hdd-o '></i>查看</button>&nbsp;|&nbsp;";
				gendan += "<button data-toggle='modal' onclick='showGendanEdit(\""+cell.orderId+"\")' class='btn btn-minier btn-yellow'><i class='ace-icon fa fa-hdd-o '></i>添加</button>";
				return gendan;
			}

			$(window).triggerHandler('resize.jqGrid');// trigger window resize to make the grid get the correct size
			// enable search/filter toolbar
			// jQuery(grid_selector).jqGrid('filterToolbar',{defaultSearch:true,stringResult:true})
			// jQuery(grid_selector).filterToolbar({});
			// switch element when editing inline
			function aceSwitch(cellvalue, options, cell) {
				setTimeout(function() {
					$(cell).find('input[type=checkbox]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
				}, 0);
			}
			// navButtons
			jQuery(grid_selector).jqGrid('navGrid', pager_selector, { // navbar options
				edit : false,
				editicon : 'ace-icon fa fa-pencil blue',
				add : false,
				addicon : 'ace-icon fa fa-plus-circle purple',
				del : false,
				delicon : 'ace-icon fa fa-trash-o red',
				search : false,
				searchicon : 'ace-icon fa fa-search orange',
				refresh : false,
				refreshicon : 'ace-icon fa fa-refresh blue',
				view : false,
				viewicon : 'ace-icon fa fa-search-plus grey'
			}, {
				// edit record form
				// closeAfterEdit: true,
				// width: 700,
				recreateForm : true,
				beforeShowForm : function(e) {
					var form = $(e[0]);
					form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
					style_edit_form(form);
				},
				errorTextFormat: function (response) {
					var result = eval('('+response.responseText+')');
					return result.message;
				}
			}, {
				// new record form
				// width: 700,
				closeAfterAdd : true,
				recreateForm : true,
				viewPagerButtons : false,
				beforeShowForm : function(e) {
					var form = $(e[0]);
					form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
					style_edit_form(form);
				},
				errorTextFormat: function (response) {
					var result = eval('('+response.responseText+')');
					return result.message;
				}
			}, {
				// delete record form
				recreateForm : true,
				beforeShowForm : function(e) {
					var form = $(e[0]);
					if (form.data('styled'))
						return false;
					form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
					style_delete_form(form);
					form.data('styled', true);
				},
				onClick : function(e) {
					// alert(1);
				}
			}, {
				// search form
				recreateForm : true,
				afterShowSearch : function(e) {
					var form = $(e[0]);
					form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
					style_search_form(form);
				},
				afterRedraw : function() {
					style_search_filters($(this));
				},
				multipleSearch : true
				/**
				 * multipleGroup:true, showQuery: true
				 */
			}, {
				// view record form
				recreateForm : true,
				beforeShowForm : function(e) {
					var form = $(e[0]);
					form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
				}
			})


			function style_edit_form(form) {
				// form.find('input[name=statusCn]').addClass('ace ace-switch ace-switch-5').after('<span class="lbl"></span>');
				// don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
				// .addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');

				// update buttons classes
				var buttons = form.next().find('.EditButton .fm-button');
				buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();// ui-icon, s-icon
				buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
				buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

				buttons = form.next().find('.navButton a');
				buttons.find('.ui-icon').hide();
				buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
				buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
			}

			function style_delete_form(form) {
				var buttons = form.next().find('.EditButton .fm-button');
				buttons.addClass('btn btn-sm btn-white btn-round').find('[class*="-icon"]').hide();// ui-icon, s-icon
				buttons.eq(0).addClass('btn-danger').prepend('<i class="ace-icon fa fa-trash-o"></i>');
				buttons.eq(1).addClass('btn-default').prepend('<i class="ace-icon fa fa-times"></i>')
			}

			function style_search_filters(form) {
				form.find('.delete-rule').val('X');
				form.find('.add-rule').addClass('btn btn-xs btn-primary');
				form.find('.add-group').addClass('btn btn-xs btn-success');
				form.find('.delete-group').addClass('btn btn-xs btn-danger');
			}
			function style_search_form(form) {
				var dialog = form.closest('.ui-jqdialog');
				var buttons = dialog.find('.EditTable')
				buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'ace-icon fa fa-retweet');
				buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'ace-icon fa fa-comment-o');
				buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'ace-icon fa fa-search');
			}

			function beforeDeleteCallback(e) {
				var form = $(e[0]);
				if (form.data('styled'))
					return false;
				form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
				style_delete_form(form);
				form.data('styled', true);
			}

			function beforeEditCallback(e) {
				var form = $(e[0]);
				form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
				style_edit_form(form);
			}

			// it causes some flicker when reloading or navigating grid
			// it may be possible to have some custom formatter to do this as the grid is being created to prevent this
			// or go back to default browser checkbox styles for the grid
			function styleCheckbox(table) {
				/**
				 * $(table).find('input:checkbox').addClass('ace') .wrap('<label />') .after('<span class="lbl align-top" />') $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
				 * .find('input.cbox[type=checkbox]').addClass('ace') .wrap('<label />').after('<span class="lbl align-top" />');
				 */
			}

			// unlike navButtons icons, action icons in rows seem to be hard-coded
			// you can change them like this in here if you want
			function updateActionIcons(table) {
				/**
				 * var replacement = { 'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue', 'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red', 'ui-icon-disk' : 'ace-icon fa fa-check green', 'ui-icon-cancel' :
				 * 'ace-icon fa fa-times red' }; $(table).find('.ui-pg-div span.ui-icon').each(function(){ var icon = $(this); var $class = $.trim(icon.attr('class').replace('ui-icon', '')); if($class in replacement)
				 * icon.attr('class', 'ui-icon '+replacement[$class]); })
				 */
			}

			// replace icons with FontAwesome icons like above
			function updatePagerIcons(table) {
				var replacement = {
					'ui-icon-seek-first' : 'ace-icon fa fa-angle-double-left bigger-140',
					'ui-icon-seek-prev' : 'ace-icon fa fa-angle-left bigger-140',
					'ui-icon-seek-next' : 'ace-icon fa fa-angle-right bigger-140',
					'ui-icon-seek-end' : 'ace-icon fa fa-angle-double-right bigger-140'
				};
				$('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function() {
					var icon = $(this);
					var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

					if ($class in replacement)
						icon.attr('class', 'ui-icon ' + replacement[$class]);
				})
			}

			function enableTooltips(table) {
				$('.navtable .ui-pg-button').tooltip({
					container : 'body'
				});
				$(table).find('.ui-pg-div').tooltip({
					container : 'body'
				});
			}

			// var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

			$(document).one('ajaxloadstart.page', function(e) {
				$(grid_selector).jqGrid('GridUnload');
				$('.ui-jqdialog').remove();
			});

			$('#sendStart').datepicker({
				language: 'zh-CN',
				pickTime: false,
				todayBtn: true,
				autoclose: true,
				minView: '2',
				forceParse: false,
				format:"yyyy-mm-dd"
			});
			$('#sendEnd').datepicker({
				language: 'zh-CN',
				pickTime: false,
				todayBtn: true,
				autoclose: true,
				minView: '2',
				forceParse: false,
				format:"yyyy-mm-dd"
			});
			$('#payStart').datepicker({
				language: 'zh-CN',
				pickTime: false,
				todayBtn: true,
				autoclose: true,
				minView: '2',
				forceParse: false,
				format:"yyyy-mm-dd"
			});
			$('#payEnd').datepicker({
				language: 'zh-CN',
				pickTime: false,
				todayBtn: true,
				autoclose: true,
				minView: '2',
				forceParse: false,
				format:"yyyy-mm-dd"
			});
			$('#mod-add-payedDate').datepicker({
				language: 'zh-CN',
				pickTime: false,
				todayBtn: true,
				autoclose: true,
				minView: '2',
				forceParse: false,
				format:"yyyy-mm-dd"
			});
			$('#mod-edit-payedate').datepicker({
				language: 'zh-CN',
				pickTime: false,
				todayBtn: true,
				autoclose: true,
				minView: '2',
				forceParse: false,
				format:"yyyy-mm-dd 00:00:00"
			});
		});
	});

	$(function(){
		hiddenModalBody = '<div class="row">'
				+ '<label class="col-sm-3 control-label">承诺审核时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-CheckCloseDate"></label>'
				+ '<label class="col-sm-3 control-label">审核时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-CheckDate"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">收款承诺时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-PayCloseDate"></label>'
				+ '<label class="col-sm-3 control-label">确认收款时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-PayedDate"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">出函承诺时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-SendCloseDate"></label>'
				+ '<label class="col-sm-3 control-label">出函时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-SendDate"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">配送时间:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-SendeDate"></label>'
				+ '<label class="col-sm-3 control-label">申请人电话:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-ContactMobile"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">标的额:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-sqbd"></label>'
				+ '<label class="col-sm-3 control-label">提交邮箱:</label>'
				+ '<label class="col-sm-3 control-label text-right" id="mt-email"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-2 control-label">标的类型:</label>'
				+ '<label class="control-label text-left" id="mt-bdCode"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-2 control-label">诉讼阶段:</label>'
				+ '<label class="control-label text-left" id="mt-Stage"></label>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-2 control-label">失败原因:</label>'
				+ '<label class="col-sm-10 control-label text-right" id="mt-FailReason"></label>'
				+ '</div>'
				+ '<div class="hr-line-dashed"></div>';
		hiddenModalBody += '<div class="row">'
				+ '<label class="col-sm-3 control-label">律师申请资料:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="lawyer-Check"></div>'
				+ '<label class="col-sm-3 control-label">律师申请其他资料:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="lawyer-Other"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">律师上传保单/合同:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="lawyer-Example2"></div>'
				+ '<label class="col-sm-3 control-label">律师上传转账证明:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="lawyer-Pay"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">公司上传保函:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="company-Example1"></div>'
				+ '<label class="col-sm-3 control-label">公司上传保单:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="company-Example2"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">公司上传发票:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="company-Invoice"></div>'
				+ '<label class="col-sm-3 control-label">已签名保单:</label>'
				+ '<div class="col-sm-3 text-right no-padding-right" id="company-nosign-Example2"></div>'
				+ '</div>'
				+ '<div class="hr-line-dashed"></div>';

		hiddenModalBody += '<div class="row">'
				+ '<div class="col-sm-9 text-left"><h5>保函</h5></div>'
				+ '<div class="col-sm-3 text-right" id="wl-sendType0"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">收件人:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-receiver0"></div>'
				+ '<label class="col-sm-3 control-label">电话:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-mobile0"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-2 control-label">地址:</label>'
				+ '<label class="col-sm-10 control-label text-right" id="wl-address0"></label>'
				+ '</div>'
				+ '<div class="row" style="display:none" id="wl-reachTimeDiv0">'
				+ '<label class="col-sm-3 control-label">送达时间:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-reachTime0"></div>'
				+ '<div class="col-sm-6"></div>'
				+ '</div>'
				+ '<div class="row" style="display:none" id="wl-companyInfoDiv0">'
				+ '<label class="col-sm-3 control-label">快递公司:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-company0"></div>'
				+ '<label class="col-sm-3 control-label">运单号:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-orderId0"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<div class="col-sm-9 text-left"><h5>发票(保单)</h5></div>'
				+ '<div class="col-sm-3 text-right" id="wl-sendType1"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">收件人:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-receiver1"></div>'
				+ '<label class="col-sm-3 control-label">电话:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-mobile1"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-2 control-label">地址:</label>'
				+ '<label class="col-sm-10 control-label text-right" id="wl-address1"></label>'
				+ '</div>'
				+ '<div class="row" style="display:none" id="wl-reachTimeDiv1">'
				+ '<label class="col-sm-3 control-label">送达时间:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-reachTime1"></div>'
				+ '<div class="col-sm-6"></div>'
				+ '</div>'
				+ '<div class="row" style="display:none" id="wl-companyInfoDiv1">'
				+ '<label class="col-sm-3 control-label">快递公司:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-company1"></div>'
				+ '<label class="col-sm-3 control-label">运单号:</label>'
				+ '<div class="col-sm-3 text-right" id="wl-orderId1"></div>'
				+ '</div>'
				+ '<div class="hr-line-dashed"></div>';

		hiddenModalBody += '<div class="row">'
				+ '<label class="col-sm-3 control-label">服务质量:</label>'
				+ '<div class="col-sm-3 text-right" id="comment-value1"></div>'
				+ '<label class="col-sm-3 control-label">出函速度:</label>'
				+ '<div class="col-sm-3 text-right" id="comment-value2"></div>'
				+ '</div>'
				+ '<div class="row">'
				+ '<label class="col-sm-3 control-label">匿名:</label>'
				+ '<div class="col-sm-3 text-right" id="comment-showFlag"></div>'
				+ '<label class="col-sm-3 control-label">评论时间:</label>'
				+ '<div class="col-sm-3 text-right" id="comment-createDate"></div>'
				+ '</div>'
				+ '<div class="row" id="modalBodyLastDiv">'
				+ '<label class="col-sm-2 control-label">评论内容:</label>'
				+ '<label class="col-sm-10 control-label text-right" id="comment-content"></label>'
				+ '</div>';



		$('#modal-gendan-submit').click(function(event) {
			addGendan();
		});

		$('#modal-surrender-submit').click(function(event) {
			setSurrender();//退保
		});
	});

	function setSurrender(){
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/setSurrender",
			type : "post",
			data : {
				'orderId' : $('#mod-surrender-orderId').val(),
				'surrender' : $('#mod-surrender').val()
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					$("#modal-surrender").modal("toggle");
					alert('保存成功');
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});
	}

	function addGendan(){
		var gendanRecord = $('input:radio[name="optionsRadiosinline"]:checked').val();
		if (gendanRecord=="其他"){
			gendanRecord = $('#mod-gendan-other').val();
		}
		var nextDate = $('#nextDate').val();
		//if (nextDate==null) {
		//	alert('下次跟单日期不能为空！');
		//	return;
		//}
		var orderId = $('#mod-gendan-editId').val();
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/addGendan",
			type : "post",
			data : {
				'nextDate': nextDate,
				'gendanRecord' : gendanRecord,
				'orderId' : orderId
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					$("#modal-gendan-edit").modal("toggle");
					alert('保存成功');
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});
	}

	function editOrder(){
		var bf = $('#mod-edit-bf').val();
		if(isNotDouble(bf)){
			alert('保费只能为浮点数');
			return;
		}
		var commisionLawyer = $('#mod-edit-commisionLawyer').val();
		if(isNotDouble(commisionLawyer)){
			alert('返现比例只能为浮点数');
			return;
		}else{
			commisionLawyer = commisionLawyer/100;
		}
		var points = $('#mod-edit-points').val();
		if(isNotNaturalNumber(points)){
			alert('积分只能为自然数');
			return;
		}
		var fsRemark = $('#mod-edit-remark').val();

		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/editOrder",
			type : "post",
			data : {
				'payedDate': $('#mod-edit-payedDate').val(),
				'bf' : bf,
				'orderId' : $('#mod-edit-orderId').val(),
				'points' : points,
				'fsRemark' : fsRemark,
				'state' : $('#mod-edit-state').val(),
				'plaintiff' : $('#mod-edit-plaintiff').val(),
				'jjgsId' : $('#mod-edit-jjgs').val(),
				'validState' : $('#mod-edit-valid').val(),
				'commisionLawyer' : commisionLawyer,
				'orderShippingType' : $('#mod-edit-orderShippingType').val(),
				'deliveryAddress':$('#mod-edit-deliveryAddress').val(),
				'contactMan':$('#mod-edit-contactMan').val(),
				'contactPhone':$('#mod-edit-contactPhone').val()
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					$("#modal-edit-order").modal("toggle");
					alert('保存成功');
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});
	}

	function checkNotDate(dateStr){
		var result = false;
		var re = /^(\d{4})-(\d{2})-(\d{2})$///正则表达式
		if(!re.test(dateStr)){
			result = true;
		}
		return result;
	}

	function formatStr(str){
		var result = '';
		if(str != undefined && str != null){
			result = str;
		}
		return result;
	}

	function initModalTableBody(){
		$('#modal-table-body').html(hiddenModalBody);
	}

	function isNotBlank(obj){
		var result = true;
		if(obj == undefined || obj == null || obj == 'null' || obj.length < 1){
			result = false;
		}
		return result;
	}

	function isNotDouble(obj){
		var reg = /\d+(\.\d+)?/;
		return !reg.test(obj);
	}

	function isNotNumber(obj){
		var reg = /^[0-9]*[1-9][0-9]*$/;
		return !reg.test(obj);
	}

	function isNotNaturalNumber(obj){
		var reg = /^[0-9]+$/;
		return !reg.test(obj);
	}

	function getJjgsList(jjgsId){
		$.getJSON("${contextPath}/sys/ssdbOrder/getJjgsList", function(result){
			$("select[name=mod-edit-jjgs]").each(function(i, obj){
				var html = "<option value=''>无</option>";
				$.each(result.jbList, function(i, obj){
					html+="<option value='"+obj.jjgsId+"'>"+obj.jjgsName+"（"+obj.jjgsBl * 100+"%）"+"</option>";
				});
				$(this).html(html);
				$('#mod-edit-jjgs').val(jjgsId);//选中的value
				//$("#mod-edit-jjgs").append(html);
			})
		});
	};

	//显示配送详情
	function showWaitToDist(id) {  //id,type
		$("#modal-distributiondetail_group").show();
		$("#modal-distributiondetail_mapgroup").show();
		$("#modal-distributiondetail").modal("toggle");
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssfw/getSsByOrder",
			type : "post",
			data : {
				'orderId' : id,
			},
			success : function(ret) {
				if(ret != null){
					if(ret.checkSuccess == true) {
						$("#distributiondetail_orderId").html(ret.ssdbssDec.ssOrderId);
						$("#distributiondetail_type").html(ret.orderTypeText);
						var orderType = Number(ret.orderType);
						if (orderType > 30 && orderType < 60) { //派送中 ,显示轨迹
							$("#distributiondetail_courierName").html(ret.resultDetail.data.courier);
							$("#distributiondetail_courierphone").html(ret.courierName);
							var mapList = new Array();
							var tempAddress = new Object();
							var trialMessage = ret.resultDetail.data.trialMessage;
							tempAddress.Long = Number(ret.ssdbssDec.sendLongitude);
							tempAddress.Lat = Number(ret.ssdbssDec.sendLatitude);
							mapList.push(tempAddress);
							for (var i = 0; i < trialMessage.length; i++) {
								tempAddress = new Object();
								tempAddress.Long = trialMessage[i].lng;
								tempAddress.Lat = trialMessage[i].lat;
								mapList.push(tempAddress);
							}
							tempAddress = new Object();
							tempAddress.Long = Number(ret.ssdbssDec.recLongitude);
							tempAddress.Lat = Number(ret.ssdbssDec.recLatitude);
							mapList.push(tempAddress);
							$("#mod-distributiondetail-mapdata").val(JSON.stringify(mapList));
						} else { //隐藏
							$("#modal-distributiondetail_group").hide();
							$("#modal-distributiondetail_mapgroup").hide();
						}
						$("#distributiondetail_sendname").html(ret.ssdbssDec.sendName);
						$("#distributiondetail_send_phone").html(ret.ssdbssDec.sendPhone);
						var sendAddress = ret.ssdbssDec.sendAddressCity + ret.ssdbssDec.sendAddress + ret.ssdbssDec.sendAddressDitail;
						$("#distributiondetail_send_address").html(sendAddress);
						$("#distributiondetail_recname").html(ret.ssdbssDec.recName);
						$("#distributiondetail_recphone").html(ret.ssdbssDec.recPhone);
						var recAddress = ret.ssdbssDec.recAddressCity + ret.ssdbssDec.recAddress + ret.ssdbssDec.recAddressDetail;
						$("#distributiondetail_recaddress").html(recAddress);
					}else{
						alert("查询闪送订单状态失败");
					}
				}
			}
		});
	}

	//跳转到新地图页面
	function showMap() {
		var mapData = $("#mod-distributiondetail-mapdata").val();
		window.open("${contextPath}/sys/ssdbOrder/showMap?mapData=" + mapData);
	}

	//显示反馈
	function showFeedBack(id) {
		$("#mod-orderId2").val(id);
		$("#modal-feedBack").modal("toggle");
		$("#feedbackText").val("");
		$("#failFeedBackText").val("");
	}

	//显示配送
	function showWLInfo(id) {
		$("#mod-distribution-orderId2").val(id);
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getOrderAndWLById",
			type : "post",
			data : {
				'orderId' : id,
			},
			success : function(ret) {
				if(ret.success){
					if (ret.data.orderShippingType == 4) {
						$("#mod-distribution-orderShippingType").val(4);
						$("#mod-distribution-sendcompany_name").html("快递公司：");
						$("#mod-distribution-sendOrderNum_name").html("快递单号：");
						if (ret.wl != null) {
							$("#mod-distribution-sendcompany").val(ret.wl.wl_company);
							$("#mod-distribution-sendOrderNum").val(ret.wl.wl_order);
						}
					} else if (ret.data.orderShippingType == 6) {
						$("#mod-distribution-orderShippingType").val(6);
						$("#mod-distribution-sendcompany_name").html("保险公司人员：");
						$("#mod-distribution-sendOrderNum_name").html("联系电话：");
						if (ret.wl != null) {
							$("#mod-distribution-sendcompany").val(ret.wl.courierName);
							$("#mod-distribution-sendOrderNum").val(ret.wl.courierPhone);
						}
					}
				} else {
					alert("获取配送方式失败！")
				}
			}
		});
		$("#modal-distribution2").modal("toggle");
	}

	//审核反馈
	$("#modal-feedback-submit2").click(function () {
		var orderId  = $("#mod-orderId2").val();
		var feedBackKey= $('input:radio[name="feedBackRadio"]:checked').val();
		var feedbackText = $("#feedbackText").val();
		var failFeedBackText = $("#failFeedBackText").val();
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/orderFeedBack",
			type : "post",
			data : {
				'orderId' : orderId,
				'feedBackKey' : feedBackKey,
				'feedbackText' : feedbackText,
				'failFeedBackText' : failFeedBackText
			},
			success : function(ret) {
				if(ret.success){
					alert("操作成功");
					$("#modal-feedBack").modal("toggle");
					myGrid.trigger("reloadGrid");
				} else {
					alert(ret.message);
				}
			}
		});
	});

	function saveWlAddressInfo() {
		var receiver = $("#mod-distribution-receiver").val();
		var contacts = $("#mod-distribution-contacts").val();
		var address = $("#mod-distribution-adress").val();
		var remark = $("#mod-distribution-remark").val();
		var orderId = $("#mod-distribution-orderId3").val();
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/updateWlInfo",
			type : "post",
			data : {
				'receiver' : receiver,
				'mobile' : contacts,
				'address' : address,
				'remark' : remark,
				'orderId':orderId
			},
			success : function(ret) {
				if(ret.success){
					alert("修改成功");
					$("#modal-distribution3").modal("toggle");
					$("#bh_contacts").html(contacts);
					$("#bh_receiver").html(receiver);
					$("#bh_address").html(address);
					$("#bh_remark").html(remark);
				}
			}
		});
	}

	function saveWlInfo() {
		var orderId = $("#mod-distribution-orderId2").val();
		var companyName = $("#mod-distribution-sendcompany").val();
		var companyPhone = $("#mod-distribution-sendOrderNum").val();
		var orderShippingType = $("#mod-distribution-orderShippingType").val();      //判空
		if ( companyPhone == "") {
			alert("快递单号不能为空！！！！！")
		}
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/saveWlInfo",
			type : "post",
			data : {
				'orderId' : orderId,
				'companyName' : companyName,
				'companyPhone' : companyPhone,
				'orderShippingType' : orderShippingType
			},
			success : function(ret) {
				if(ret.success){
					$("#modal-distribution2").modal("toggle");
					myGrid.trigger("reloadGrid");
				}
			}
		});
	}

	//显示闪送下单对话框
	function showDistribution(id) {
		$(":input","#editDistribution")
				.not(":button",":reset","hidden","submit")
				.val("");
		$("#modal-distribution").modal("toggle");
		$("#mod-distribution-orderId").val(id);
		//根据物流回显数据
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getSsdbWLByOrder",
			type : "post",
			data : {
				'orderId' : id,
			},
			success : function(ret) {
				if(ret != null){
					$("#mod-distribution-ssdborderwlId").val(ret.ssdbOrderWlId);

					$("#mod-distribution-sendname").val(ret.ssdbssDec.sendName);
					$("#mod-distribution-sendphone").val(ret.ssdbssDec.sendPhone);
					$("#mod-distribution-sendaddresscity").val(ret.ssdbssDec.sendAddressCity);
					$("#mod-distribution-sendaddress").val(ret.ssdbssDec.sendAddress);
					$("#mod-distribution-sendaddressdital").val(ret.ssdbssDec.sendAddressDitail);
					$("#mod-distribution-sendlongitude").val(ret.ssdbssDec.sendLatitude);
					$("#mod-distribution-sendlatitude").val(ret.ssdbssDec.sendLongitude);

					$("#mod-distribution-recname").val(ret.ssdbssDec.recName);
					$("#mod-distribution-recphone").val(ret.ssdbssDec.recPhone);
					$("#mod-distribution-recaddresscity").val(ret.ssdbssDec.recAddressCity);
					$("#mod-distribution-recaddress").val(ret.ssdbssDec.recAddress);
					$("#mod-distribution-recaddressdital").val(ret.ssdbssDec.recAddressDetail);
					$("#mod-distribution-reclongitude").val(ret.ssdbssDec.recLatitude);
					$("#mod-distribution-reclatitude").val(ret.ssdbssDec.recLongitude);
				}
			}
		});
	}

	function showSurrender(id){
		$('#mod-surrender-orderId').val(id);
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getOrderDetail",
			type : "post",
			data : {
				'orderId' : id,
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					$('#mod-surrender').val(ret.surrender);
					$("#modal-surrender").modal("toggle");
				}else{
					alert(ret.message);
				}
			}
		});
	}
	function showGendan(orderId){
		gendanTable.setGridParam({postData:{'orderId':orderId},url:'${contextPath}/sys/ssdbOrder/getGendan',datatype:'json',page:1}).trigger('reloadGrid');
		$("#div77-edit").html("");
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getEditOrderDetail",
			type : "post",
			data : {
				'orderId' : orderId
			},
			complete : function(ret) {
				console.log(ret);
				var ret = eval("(" + ret.responseText + ")");
				console.log(ret);
				if (ret.success) {
					var pic77 = ret.gendanPics ; //t保险公司投保单照片
					for(var i = 0 ;i < pic77.length; i ++) {
						loadGendanPic(orderId, pic77[i].path,"","",pic77[i].id,'div77-edit');
					}
				}
			}
		});
		$("#mod-gendan-orderId1").val(orderId);
		$("#modal-gendan-records").modal("toggle");
	}

	function showdetail1(id) {
		$("#modal-table").modal("toggle");
		$("#modal-table-body1").html('');
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getOrderDetail1",
			type : "post",
			data : {
				'orderId' : id
			},
			complete : function(ret) {
				var html = '';
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success) {
					//字段信息

					html += '<div class="row">\n' +
							'<label class="col-sm-3">保全金额:</label>\n' +
							'<label class="col-sm-3">'+ret.sqbd+'</label>\n' +
							'<label class="col-sm-3">费率:</label>\n' +
							'<label class="col-sm-3">'+ret.ratLawyer+'</label>\n' +
							'</div>\n' +
							'<div class="row">\n' +
							'<label class="col-sm-3">保全标的类型:</label>\n' +
							'<label class="col-sm-3">'+ret.bdCode+'</label>\n' +
							'</div>\n' +
							'<div class="row">\n' +
							'<label class="col-sm-3">订单取消原因::</label>\n' +
							'<label class="col-sm-3">'+ret.cancelReason+'</label>\n' +
							'</div>\n' +
							'<div class="row">' +
							'<label class="col-sm-3">订单审核失败原因:</label>' +
							'<label class="col-sm-3">'+ret.failReason+'</label>' +
							'</div>\n' +
							'<div class="row">' +
							'<label class="col-sm-3">提交方式:</label>' +
							'<label class="col-sm-3">'+ret.submitType+'</label>' +
							'</div>\n' +
							'<div class="hr-line-dashed"></div>';

					//审核资料
					html += '<div class="row">\n' +
							' <label class="col-sm-3">审核资料</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-4">提供审核的资料:</label>\n' +
							' <label class="col-sm-3">共' + ret.lawyerCheck +'张</label>\n' +
							'<label class="col-sm-1"></label>\n';

					if (ret.lawyerCheck > 0 ) {
						html +=	'<label class="col-sm-2"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',31,0)">查看</a></label> ' +
								'<label class="col-sm-2"><a class="btn btn-minier btn-primary " href="${contextPath}/sys/ssdbOrder/downloadOrderAttachsByType?id=' + ret.id + '&key=31" target="_blank">下载</a></label>\n' +
								'</div>';
					}else {
						html +=	'<label class="col-sm-2"></label><label class="col-sm-2"></label></div> ' ;
					}

					//审核反馈补充资料
					html += '<div class="row">\n' +
							' <label class="col-sm-4">审核反馈补充的资料:</label>\n' +
							' <label class="col-sm-3">共' + ret.lawyerCheckNew +'张</label>\n' +
							' <label class="col-sm-1"></label>\n'
					/*' <label class="col-sm-2"></label>\n' +
                    ' <label class="col-sm-2"></label>\n'*/
					/* ' </div>\n';*/

					if (ret.lawyerCheckNew > 0 ) {
						html +=	'<label class="col-sm-2"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',31,1)">查看</a></label> ' +
								'<label class="col-sm-2"><a class="btn btn-minier btn-primary " href="${contextPath}/sys/ssdbOrder/downloadOrderAttachsByType?id=' + ret.id + '&key=31&isNew=1" target="_blank">下载</a></label>\n' +
								'<label class="col-sm-2"></label>'+
								'</div>';
					}else {
						html +=	'<label class="col-sm-2"></label><label class="col-sm-2"></label></div> ' ;
					}

					var div = '';
					var logs = null;
					var logsArray = [ret.logReplys,ret.logPays,ret.logLawyers,ret.logCompanys];
					var logType = ['审核资料问题反馈','支付问题反馈','律师反馈','诉保公司回复信息'];
					for(var j=0;j<logsArray.length;j++){
						logs = logsArray[j];
						if(isNotBlank(logs)){
							div += '<div class="hr-line-dashed"></div>';
							div += '<div class="row"><div class="col-sm-12 text-left"><h5>' + logType[j] + '</h5></div></div>';
							var log = null;
							for(var i in logs){
								log = logs[i];
								div += '<div class="row">'
										+ '<label class="col-sm-3 control-label">' + log.createDate + '：' + '</label>'
										+ '<label class="col-sm-9 control-label text-left">' + log.content + '</label>'
										+ '</div>';
							}
						}
					}
					html += div;

					// 跟单资料
					html += '<div class="row">\n' +
							' <label class="col-sm-3">跟单资料</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">投保单原件:</label>\n';

					if (ret.companyExample2 > 0 ) {
						html +=    ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="${contextPath}/sys/ssdbOrder/downloadOrderAttachsByType?id=' + ret.id + '&key=72" target="_blank">下载</a></label>\n';
					}else {
						html +=    ' <label class="col-sm-3"></label>\n';
					}
					html +=    ' <label class="col-sm-3">保函模板照片:</label>\n' ;

					if (ret.companyExample3 > 0) {
						html +=' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',70,0)">查看</a></label>\n';
					}else {
						html +=' <label class="col-sm-3"></label>\n';
					}

					html += ' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">投保单签字照片:</label>\n';
					if (ret.lawyerExample2 > 0) {
						html += ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',52,0)">查看</a></label>\n';
					}else {
						html += ' <label class="col-sm-3"></label>\n';
					}

					html +=  ' <label class="col-sm-3">付款凭证:</label>\n';

					if (ret.lawyerPay > 0) {
						html += ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',41,0)">查看</a></label>\n';
					}else {
						html += ' <label class="col-sm-3"></label>\n';
					}

					html +=	' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">保函图片:</label>\n';

					if (ret.companyExample1 > 0) {
						html += ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',71,0)">查看</a></label>\n';
					}else {
						html += ' <label class="col-sm-3"></label>\n';
					}
					html +=  ' <label class="col-sm-3">发票图片:</label>\n' ;

					if (ret.companyInvoice > 0) {
						html += ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',73,0)">查看</a></label>\n';
					}else {
						html += ' <label class="col-sm-3"></label>\n';
					}
					html += ' </div>';
					html +=  ' <div class="row"> <label class="col-sm-3">公司上传需客户签名的保单:</label>\n';
					if (ret.companyNosignExample2 > 0) {
						html += ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',74,0)">查看</a></label>\n';
					}else {
						html += ' <label class="col-sm-3"></label>\n';
					}
					html += "</div>";
					//保险公司收款账号信息
					html += '<div class="hr-line-dashed"></div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-5">保险公司收款账号信息</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">账号名：</label>\n' +
							' <label class="col-sm-9">'+ (ret.accountName == null ? "": ret.accountName) +'</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">账号：</label>\n' +
							' <label class="col-sm-9">' + (ret.accountNum == null ? "" : ret.accountNum) + '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">开户行：</label>\n' +
							' <label class="col-sm-9">' + (ret.accountBank == null ? "" : ret.accountBank)+ '</label>\n' +
							' </div>';

					var wls = ret.wls ;
					var receiver = '';
					var contacts = '';
					var address = '';
					var remark = '';
					if (wls.length > 0) {
						receiver = wls[0].receiver ;
						contacts = wls[0].mobile ;
						address = wls[0].address;
						remark = wls[0].remark;
					}

					//保函收件地址
					html += '<div class="hr-line-dashed"></div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">保函收件地址：</label>\n' +
							' <label class="col-sm-3"><input type="button" value="修改" onclick="changeBHAdress(\''+id+'\',\''+receiver+'\',\''+contacts+'\',\''+address+'\',\''+remark+'\')"/></label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3" >收件人:</label>\n' +
							' <label class="col-sm-3" id="bh_receiver">'+ receiver +'</label>\n' +
							' <label class="col-sm-3">联系人:</label>\n' +
							' <label class="col-sm-3" id="bh_contacts">'+ contacts +'</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">地址:</label>\n' +
							' <label class="col-sm-9" id="bh_address">' +address+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">备注:</label>\n' +
							' <label class="col-sm-9" id="bh_remark">' +remark+ '</label>\n' +
							' </div>';

					var fp = ret.fp ;
					var invoType = '';
					var name = '';
					var taxNum = '';
					var addr = '';
					var tel = '';
					var bankAccount = '';
					var bankName = '';
					if (fp != null) {
						invoType = fp.invoType  ;
						name = fp.name ;
						taxNum = fp.taxNum;
						addr = fp.addr  ;
						tel = fp.tel ;
						bankAccount = fp.bankAccount ;
						bankName = fp.bankName ;
					}

					//开票信息
					html += '<div class="hr-line-dashed"></div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">开票信息：</label>\n' +
							' <label class="col-sm-4"><input type="button" value="复制开票信息" class="copybtn" data-clipboard-action="copy" data-clipboard-target="#foo"/><textarea style="resize:none;overflow:hidden; width: 0.01px;height: 0.01px;border:none;opacity: 0" id="foo">.</textarea></label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">发票类型:</label>\n' +
							' <label class="col-sm-9" id="fp-invoType">' + getInvoType(invoType)+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">发票抬头:</label>\n' +
							' <label class="col-sm-9">' +name+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">纳税人识别号:</label>\n' +
							' <label class="col-sm-9"> ' +taxNum+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">公司地址:</label>\n' +
							' <label class="col-sm-9">' +addr+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">电话:</label>\n' +
							' <label class="col-sm-9">' +tel+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">开户名:</label>\n' +
							' <label class="col-sm-9">' +name+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">开户账号:</label>\n' +
							' <label class="col-sm-9">'+bankAccount+'</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">开户行:</label>\n' +
							' <label class="col-sm-9">'+bankName+'</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">开户行号:</label>\n' +
							' <label class="col-sm-9"> </label>\n' +
							' </div>\n' +
							' <div class="hr-line-dashed"></div>';

					//复制开票信息
					var copyStr = '';
					if (fp != null) {
						copyStr = $("#fp-invoType").html() + "\r\n"+name +"\r\n"+ taxNum +"\r\n"+ addr + "\r\n"+tel + "\r\n"+bankAccount + "\r\n"+bankName ;
						$("#foo").val(copyStr);
					}

					//退保截图
					html += '<div class="row">\n' +
							' <label class="col-sm-3">退保信息:</label>\n' +
							' <label class="col-sm-9"> </label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">退保截图：</label>\n';

					if (ret.lawyerRefund > 0) {
						html += ' <label class="col-sm-3"><a class="btn btn-minier btn-primary " href="#" onClick="showOrderFilesByType(\'' + ret.id + '\',75,0)">查看</a></label>\n';
					}
					html += ' </div>\n' +
							' <div class="hr-line-dashed"></div>';

					//客户经理
					html += '<div class="row">\n' +
							' <label class="col-sm-3">客户经理</label>\n' +
							' <label class="col-sm-3">' +(ret.managerName == null ? "":ret.managerName)+ '</label>\n' +
							' <label class="col-sm-3">联系方式</label>\n' +
							' <label class="col-sm-3">' +(ret.managerPhone == null ? "":ret.managerPhone)+ '</label>\n' +
							' </div>';

					html += ' </div>\n' +
							' <div class="hr-line-dashed"></div>';

					//服务评价
					html += '<div class="row">\n' +
							' <label class="col-sm-3">服务评价</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">服务质量:</label>\n' +
							' <label class="col-sm-3">' +(ret.commentValue1 == null ? "":ret.commentValue1)+ '</label>\n' +
							' <label class="col-sm-3">出函速度:</label>\n' +
							' <label class="col-sm-3">' +(ret.commentValue2 == null ? "":ret.commentValue2)+ '</label>\n' +
							' </div>\n' +
							' <div class="row">\n' +
							' <label class="col-sm-3">评价内容:</label>\n' +
							' <label class="col-sm-3">' +(ret.commentContent == null ? "":ret.commentContent)+ '</label>\n' +
							' </div>';

					$('#modal-table-body1').html(html);

				}else {
					alert(ret.message);
				}
			}
		});

	}

	function changeBHAdress(id,receiver,contacts,address,remark) {
		$("#mod-distribution-orderId3").val(id);
		$("#modal-distribution3").modal("toggle");
		$("#mod-distribution-receiver").val(receiver);
		$("#mod-distribution-contacts").val(contacts);
		$("#mod-distribution-adress").val(address);
		$("#mod-distribution-remark").val(remark);
	}

	function showdetail(id){
		$('#modal-table-body').html('');
		var bdCode = {"S101":"房产","S102":"银行账户类","S103":"土地使用权","S104":"非上市公司股权","S105":"应收债权","S201":"车辆","S202":"船舶","S203":"不易腐朽损坏货物","S204":"机器设备","S205":"商标专利","S301":"上市公司股票","S302":"非固定收益基金账户","S303":"易腐朽损坏货物"};
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getOrderDetail",
			type : "post",
			data : {
				'orderId' : id
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					initModalTableBody();
					$('#mod-edit-jjgsId').val(ret.jjgsId);//经济公司id
					var keyObj = {"checkCloseDate":"mt-CheckCloseDate","checkDate":"mt-CheckDate","payCloseDate":"mt-PayCloseDate","payedDate":"mt-PayedDate","sendCloseDate":"mt-SendCloseDate","sendDate":"mt-SendDate","sendeDate":"mt-SendeDate","contactMobile":"mt-ContactMobile","stage":"mt-Stage","failReason":"mt-FailReason","commentValue1":"comment-value1","commentValue2":"comment-value2","commentShowFlag":"comment-showFlag","commentCreateDate":"comment-createDate","commentContent":"comment-content","sqbd":"mt-sqbd","lawyerEmail":"mt-email"};
					for(var key in keyObj){
						$('#' + keyObj[key]).html(ret[key]);
					}

					keyObj = {"lawyerCheck":[31,"lawyer-Check"],"lawyerOther":[61,"lawyer-Other"],"lawyerExample2":[52,"lawyer-Example2"],"lawyerPay":[41,"lawyer-Pay"],"companyExample1":[71,"company-Example1"],"companyExample2":[72,"company-Example2"],"companyInvoice":[73,"company-Invoice"],"companyNosignExample2":[74,"company-nosign-Example2"]};
					var value,sum,html = null;
					for(var key in keyObj){
						value = keyObj[key];
						sum = parseInt(ret[key]);
						if(sum > 0){
							//			html = '<span>共' + sum + '个</span>&emsp;<a class="btn btn-minier btn-primary" href="#" onClick="showOrderFilesByType(\'' + id + '\',\'' + value[0] + '\')">查看</a>';
							html = '<span>共' + sum + '个</span>&emsp;';
							html += '<a class="btn btn-minier btn-primary" href="#" onClick="showOrderFilesByType(\'' + id + '\',\'' + value[0] + '\',0)">查看</a>&nbsp;';
							html += '<a class="btn btn-minier btn-primary" href="${contextPath}/sys/ssdbOrder/downloadOrderAttachsByType?id=' + id + '&key=' + value[0] + '" target="_blank">下载</a>';
						}else{
							html = '<span>共0个</span>';
						}
						$('#' + value[1]).html(html);
					}

					var wlKey = {"wl-receiver":"receiver","wl-mobile":"mobile","wl-address":"address"};
					var wls = ret.wls;
					if(isNotBlank(wls)){
						var wl,ci,isWL = null;
						for(var i in wls){
							wl = wls[i];
							if(wl.fileType == '0'){
								ci = 0;
							}else{
								ci = 1;
							}
							for(var j in wlKey){
								$('#' + j + ci).html(wl[wlKey[j]]);
							}
							if(wl.sendType == '1'){
								$('#wl-sendType' + ci).html('上门配送');
								isWL = false;
							}else{
								$('#wl-sendType' + ci).html('快递配送');
								isWL = true;
							}
							if(isWL){
								$('#wl-companyInfoDiv' + ci).show();
								$('#wl-reachTimeDiv' + ci).hide();
								$('#wl-company' + ci).html(wl.wl_company);
								$('#wl-orderId' + ci).html(wl.wl_order);
							}else{
								$('#wl-companyInfoDiv' + ci).hide();
								$('#wl-reachTimeDiv' + ci).show();
								$('#wl-reachTime' + ci).html(wl.reachTime);
							}
						}
					}

					var div = '';
					var logs = null;
					var logsArray = [ret.logReplys,ret.logPays,ret.logLawyers,ret.logCompanys];
					var logType = ['审核资料问题反馈','支付问题反馈','律师反馈','诉保公司回复信息'];
					for(var j=0;j<logsArray.length;j++){
						logs = logsArray[j];
						if(isNotBlank(logs)){
							div += '<div class="hr-line-dashed"></div>';
							div += '<div class="row"><div class="col-sm-12 text-left"><h5>' + logType[j] + '</h5></div></div>';
							var log = null;
							for(var i in logs){
								log = logs[i];
								div += '<div class="row">'
										+ '<label class="col-sm-3 control-label">' + log.createDate + '：' + '</label>'
										+ '<label class="col-sm-9 control-label text-left">' + log.content + '</label>'
										+ '</div>';
							}
						}
					}
					if(div.length > 0){
						$('#modalBodyLastDiv').after(div);
					}

					var a0 = ret.bdCode.split(',');
					var a1 = [];
					var obj = null;
					for(var i=0;i<a0.length;i++){
						obj = bdCode[a0[i]];
						if(obj != undefined){
							a1.push(obj);
						}
					}
					$('#mt-bdCode').html(a1.join());

					$("#modal-table").modal("toggle");
				}else{
					alert(ret.message);
				}
			}
		});
	}

	function getInvoType(invoType) {
		if (invoType == '0') {
			return '普通发票';
		} else if (invoType == '1') {
			return '增值税发票';
		} else {
			return invoType ;
		}
	}

	//跟单编辑框
	function showGendanEdit(orderId){
		$('#mod-gendan-editId').val(orderId);
		initDatetimepicker('nextDate');
		$("#modal-gendan-edit").modal("toggle");
	}

	function initDatetimepicker(id){
		$('#' + id).datetimepicker({
			language: 'zh-CN',
			weekStart: 1,
			todayBtn:  1,
			autoclose: 1,
			todayHighlight: 1,
			startView: 2,
			forceParse: 0,
			showMeridian: 1
		});
	}


	$('#mod-pic').on('hidden.bs.modal', function (){
		if($('.modal.in').length > 0){
			$("body").addClass("modal-open");
		}

	});
	$('#mod-gendan').on('hidden.bs.modal', function (){
		if($('.modal.in').length > 0){
			$("body").addClass("modal-open");
		}

	});
	$('#mod-file').on('hidden.bs.modal', function (){
		if($('.modal.in').length > 0){
			$("body").addClass("modal-open");
		}

	});

	function getSysuser(orderId) {
		console.log(111);
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getSysuserRole",
			type : "post",
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				console.log(ret);
				if (ret.succ === "true"){
					$("#mod-edit-state").attr('disabled',true);
					$("#mod-edit-valid").attr('disabled',true);
					$("#mod-edit-companyLoginName").attr('disabled',true);
					$("#mod-edit-sqbd").attr('disabled',true);
					$("#mod-edit-court").attr('disabled',true);
					/*$("#mod-edit-plaintiff").attr('disabled',true);*/
					$("#mod-edit-bf").attr('disabled',true);
					$("#mod-edit-backProportion").attr('disabled',true);
					$("#mod-edit-serviceCostPro").attr('disabled',true);
					$("#mod-edit-documentaryUser").attr('disabled',true);
					$("#mod-edit-accountName").attr('disabled',true);
					$("#mod-edit-accountNum").attr('disabled',true);
					$("#mod-edit-accountBank").attr('disabled',true);
					$("#managerName").attr('disabled',true);
					$("#mod-edit-orderFpName").attr('disabled',true);
					$("#mod-edit-taxNum").attr('disabled',true);
					$("#mod-edit-addr").attr('disabled',true);
					$("#mod-edit-tel").attr('disabled',true);
					$("#mod-edit-bankName").attr('disabled',true);
					$("#mod-edit-bankAccount").attr('disabled',true);
					$("#mod-edit-payedate").attr('disabled',true);
					$("#mod-edit-changeReason").attr('disabled',true);
					$("#delivery").attr('disabled',true);
					$("#changeHis").attr('disabled',true);
					showEditOrder(orderId);
				}else{
					console.log(333);
					showEditOrder(orderId);
				}
			}
		});
	}

	function showEditOrder(orderId){
		//清空图片
		$("#div76-edit").html("");
		$("#div41-edit").html("");
		$("#div52-edit").html("");
		$("#div72-edit").html("");
		$("#div71-edit").html("");
		$("#div88-edit").html("");
		$("#div66-edit").html("");
		$("#div73-edit").html("");
		$("#div74-edit").html("");
		$("#modal-edit-order").modal("toggle");
		$("#editOrderForm2")[0].reset();
		$("#mod-edit-orderId").val(orderId);

		//清空状态
		$("#mod-edit-state").val();
		$("#mod-edit-valid").val();
		// $("#mod-edit-isOldLawyer").val(0);
		$("#mod-edit-isRepeat").val(0);
		$("#mod-edit-companyLoginName").val();
		$("#mod-edit-sqbd").val();
		$("#mod-edit-court").val();
		$("#mod-edit-plaintiff").val();
		$("#mod-edit-bf").val();
		$("#mod-edit-backProportion").val();
		$("#mod-edit-serviceCostPro").val();
		$("#mod-edit-documentaryUser").val();
		$("#mod-edit-accountName").val();
		$("#mod-edit-accountNum").val();
		$("#mod-edit-accountBank").val();
		$("#managerName").val();
		$("#mod-edit-orderFpName").val();
		$("#mod-edit-taxNum").val();
		$("#mod-edit-addr").val();
		$("#mod-edit-tel").val();
		$("#mod-edit-bankName").val();
		$("#mod-edit-bankAccount").val();
		$("#mod-edit-payedate").val();
		$("#mod-edit-changeReason").val();
		$("#delivery").val();
		$("#changeHis").html("");

		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getEditOrderDetail",
			type : "post",
			data : {
				'orderId' : orderId
			},
			complete : function(ret) {
				console.log(ret);
				var ret = eval("(" + ret.responseText + ")");
				console.log(ret);
				if (ret.success) {
					$("#mod-edit-state").val(ret.orderState);
					$("#mod-edit-valid").val(ret.validState);
					// $("#mod-edit-isOldLawyer").val(ret.isOldLawyer);
					// $("#mod-edit-isRepeat").val(ret.isRepeat);
					$("#mod-edit-companyLoginName").val(ret.loginName);
					$("#mod-edit-sqbd").val(ret.sqbd);
					$("#mod-edit-court").val(ret.courtName);
					$("#mod-edit-plaintiff").val(ret.plaintiff);
					$("#mod-edit-bf").val(ret.bf);
					$("#mod-edit-backProportion").val(ret.commisionLawyer);
					$("#mod-edit-serviceCostPro").val(ret.serviceCostProportion);
					$("#mod-edit-documentaryUser").val(ret.documentaryUser);
					$("#mod-edit-accountName").val(ret.accountName);
					$("#mod-edit-accountNum").val(ret.accountNum);
					$("#mod-edit-accountBank").val(ret.accountBank);
					$("#managerName").val(ret.managerName);
					$("#mod-edit-orderFpName").val(ret.name);
					$("#mod-edit-taxNum").val(ret.taxNum);
					$("#mod-edit-addr").val(ret.addr);
					$("#mod-edit-tel").val(ret.tel);
					$("#mod-edit-bankName").val(ret.bankName);
					$("#mod-edit-bankAccount").val(ret.bankAccount);
					$("#mod-edit-payedate").val(ret.payeDate);
					$("#mod-edit-changeReason").val(ret.serviceCostReason);
					$("#delivery").val(ret.orderShippingType);
					$("#changeHis").html(ret.changeHis);

					//图片
					var changeServiceCostReasons = ret.changeServiceCostReasons ; //服务费修改凭证
					for(var i = 0 ;i < changeServiceCostReasons.length; i ++) {
						loadPic(orderId, changeServiceCostReasons[i].path,"","",changeServiceCostReasons[i].id,'div76-edit');
					}
					var payMoneyUrls = ret.payMoneyUrls ; //付款凭证
					for(var i = 0 ;i < payMoneyUrls.length; i ++) {
						loadPic(orderId, payMoneyUrls[i].path,"","",payMoneyUrls[i].id,'div41-edit');
					}
					var payMoneyFileUrls = ret.payMoneyFileUrls ; //付款凭证pdf
					for(var i = 0 ;i < payMoneyFileUrls.length; i ++) {
						loadFile(orderId, payMoneyFileUrls[i].path,payMoneyFileUrls[i].name,"",payMoneyFileUrls[i].id,'div66-edit');
					}

					var tbdFileUrls = ret.tbdFileUrls ; //保险公司投保单pdf
					for(var i = 0 ;i < tbdFileUrls.length; i ++) {
						loadFile(orderId, tbdFileUrls[i].path,tbdFileUrls[i].name,"",tbdFileUrls[i].id,'div73-edit');
					}

					var tbdPicUrls = ret.tbdPicUrls ; //t保险公司投保单照片
					for(var i = 0 ;i < tbdPicUrls.length; i ++) {
						loadPic(orderId, tbdPicUrls[i].path,"","",tbdPicUrls[i].id,'div72-edit');
					}
					var lawTbdPicUrls = ret.lawTbdPicUrls ; //律师投保单照片
					for(var i = 0 ;i < lawTbdPicUrls.length; i ++) {
						loadPic(orderId, lawTbdPicUrls[i].path,"","",lawTbdPicUrls[i].id,'div52-edit');
					}
					var lawTbdFileUrls = ret.lawTbdFileUrls ; //律师投保单pdf文件
					for(var i = 0 ;i < lawTbdFileUrls.length; i ++) {
						loadFile(orderId, lawTbdFileUrls[i].path,lawTbdFileUrls[i].name,"",lawTbdFileUrls[i].id,'div88-edit');
					}
					var bhPicUrls = ret.bhPicUrls ; //保函照片
					for(var i = 0 ;i < bhPicUrls.length; i ++) {
						loadPic(orderId, bhPicUrls[i].path,"","",bhPicUrls[i].id,'div71-edit');
					}
					var bhFileUrls = ret.bhFileUrls ; //保函照片pdf
					for(var i = 0 ;i < bhFileUrls.length; i ++) {
						loadFile(orderId, bhFileUrls[i].path,bhFileUrls[i].name,"",bhFileUrls[i].id,'div74-edit');
					}
				}
			}
		});
	}

	$("#mod-edit-commisionLawyer").on('input',function(e){
		var commisionLawyer = $("#mod-edit-commisionLawyer").val();
		var bf = $("#mod-edit-bf").val();
		$("#mod-edit-points").val(Math.round(commisionLawyer/10*bf,2));
	});

	$("#mod-edit-points").on('input',function(e){
		var points = $("#mod-edit-points").val();
		var bf = $("#mod-edit-bf").val();
		$("#mod-edit-commisionLawyer").val(Math.round(points*10/bf,2));
	});

	$("#mod-edit-bf").on('input',function(e){
		var commisionLawyer = $("#mod-edit-commisionLawyer").val();
		var bf = $("#mod-edit-bf").val();
		if(commisionLawyer != null && bf != null){
			$("#mod-edit-points").val(Math.round(commisionLawyer/10*bf,2));
		}
	});

	function showOrderFilesByType(id,type,isNew){
		$('#modal-orderAttachs-body').html('');
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/getOrderAttachsByAttachType",
			type : "post",
			data : {
				'orderId' : id,
				'attachType' : type,
				'isNew':isNew

			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					var attachs = ret.attachs;
					var aBean,name,oa = null;
					var html = '';
					var i = 1;
					var url = '${oss_bucket_ssdb_url}';
					var thum = '${oss_bucket_ssdb_url_img}';
					var size = '${oss_bucket_ssdb_url_img_size}';
					for(var j=0;j<attachs.length;j++){
						aBean = attachs[j];
						name = formatStr(aBean.name);

						if(name.length > 0){
							html += '<div class="row">'
									+ '<div class="col-md-2">' + i + '、' + name + '</div>'
									+ '<div class="col-md-10">';
							for(var m in aBean.attachs){
								oa = aBean.attachs[m];

								if (oa.suffix == 'pdf') {
									html +='<a href="' + url + oa.path + '" target="_blank">';
									html += oa.name;
									html +='</a>&nbsp;';
								}else{
									html +='<a href="' + url + oa.path + '" target="_blank">';
									html += '<img class="lazy" src="${contextPath}/static/img/loading.gif" data-original="' + thum + oa.path + size + '" height="100" width="100">';
									html +='</a>&nbsp;';
								}

							}
							html +=   '</div>'
									+ '</div>'
									+ '<div class="hr-line-dashed"></div>';
							i++;
						}else{
							html += '<div class="row">'
									+ '<div class="col-md-12">';
							for(var m in aBean.attachs){
								oa = aBean.attachs[m];

								if('74' == type){
									html +='<a href="' + url + oa.path + '" target="_blank">';
									html +=oa.name;
									html +='</a>&nbsp;';
								}else{
									if (oa.suffix == 'pdf') {
										html += '<br>';
										html +='<a href="' + url + oa.path + '" target="_blank">';
										html += oa.name;
										html +='</a>&nbsp;';
									}else{
										html +='<a href="' + url + oa.path + '" target="_blank">';
										html += '<img class="lazy" src="${contextPath}/static/img/loading.gif" data-original="' + thum + oa.path + size + '" height="100" width="100">';
										html +='</a>&nbsp;';
									}

								}
							}
							html +=   '</div>'
									+ '</div>';
						}
					}
					$('#modal-orderAttachs-body').html(html);
					$("#modal-orderAttachs").modal("toggle");
					setTimeout(function () {
						$("img.lazy").lazyload({
							threshold : 200
						});
					}, 200);
				}else{
					alert(ret.message);
				}
			}
		});
	}



	function add(){
		$("#AddForm")[0].reset();
		$("#mod-add-tip").html('');
		$("#mod-add").modal("toggle");
	}

	function calc(){
		//订单数：100 | 总保费：100000元 | 客单价：100元 | 退保保费：1000元 |  总积分：10000 | 总标的：100000000
		var dds = $("#grid-table").getCol('orderId',false,'count');
		var zbf = $("#grid-table").getCol('bf',false,'sum');
		var zjf = $("#grid-table").getCol('points',false,'sum');
		var zbd = $("#grid-table").getCol('sqbd',false,'sum');

		$("#calc-result").html("订单数："+dds+" | 总保费："+(zbf).toFixed(2) +"元 | 客单价："+(zbf/dds).toFixed(2)
				+"元 |  总积分："+zjf +" | 总标的："+ (zbd).toFixed(2) );

		if( $("#calc-result").css("display")==='none' ){
			$("#calc-result").show();
		}else{
			$("#calc-result").hide();
		}
	}

	function exportOrder(){
		var keys = [], ii = 0, rows = "";
		var grid_selector = "#grid-table";
		var ids = $(grid_selector).getDataIDs(); // Get All IDs
		console.log("哈哈");
		console.log(ids);
		var row = $(grid_selector).getRowData(ids[0]); // Get First row to get the labels
		console.log("呵呵");
		console.log(row);
		for (var k in row) {
			keys[ii++] = k; // capture col names
			rows = rows + k + "\t"; // output each Column as tab delimited
		}
		rows="订单号\t提交时间\t付款时间\t确认付款时间\t出函时间\t登录名\t公司全称\t省\t市\t法院\t原告\t律师\t标的\t标的类型\t保费\t积分\t返点比例\t审核时长\t出函时长\t" +
				"订单状态\t最新跟单记录\t下次跟单时间\t是否新用户\t跟单人员\t操作\t跟单记录操作";
		console.log(typeof(rows));
		rows = rows + "\n"; // Output header with end of line
		for (i = 0; i < ids.length; i++) {
			row = $(grid_selector).getRowData(ids[i]); // get each row
			//var rowData = $('#gridTable').jqGrid('getRowData',rowId);
			for (j = 0; j < keys.length-1; j++){
				if (j !== 12) {
					rows = rows + row[keys[j]].replace(/^\s*|\s*$/g,"") + "\t"; // output each Row as tab delimited
				}
			}
			rows = rows + "\n"; // output each row with end of line
		}
		rows = rows + "\n"; // end of line at the end
		var form = "<form name='csvexportform' action='${contextPath}/sys/ssdbOrder/operateOrder?oper=excel' method='post'>";
		form = form + "<input type='hidden' name='csvBuffer' value='" + encodeURIComponent(rows) + "'>";
		form = form + "</form><script>document.csvexportform.submit();</sc" + "ript>";
		OpenWindow = window.open('', '');
		OpenWindow.document.write(form);
		OpenWindow.document.close();
	}

	function showothers(){
		if($("#showothers").text()=="隐藏字段"){
			$("#showothers").text("显示字段");
			myGrid.setGridParam().hideCol("province").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("cityName").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("payedDate").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("plaintiff").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("sqbd").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("bdCode").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("orderServiceType").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("orderShippingType").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("surrender").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("shTime").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("chTime").trigger("reloadGrid");
			myGrid.setGridParam().hideCol("companyName").trigger("reloadGrid");
		}else{
			$("#showothers").text("隐藏字段");
			myGrid.setGridParam().showCol("province").trigger("reloadGrid");
			myGrid.setGridParam().showCol("cityName").trigger("reloadGrid");
			myGrid.setGridParam().showCol("payedDate").trigger("reloadGrid");
			myGrid.setGridParam().showCol("plaintiff").trigger("reloadGrid");
			myGrid.setGridParam().showCol("sqbd").trigger("reloadGrid");
			myGrid.setGridParam().showCol("bdCode").trigger("reloadGrid");
			myGrid.setGridParam().showCol("orderServiceType").trigger("reloadGrid");
			myGrid.setGridParam().showCol("orderShippingType").trigger("reloadGrid");
			myGrid.setGridParam().showCol("surrender").trigger("reloadGrid");
			myGrid.setGridParam().showCol("shTime").trigger("reloadGrid");
			myGrid.setGridParam().showCol("chTime").trigger("reloadGrid");
			myGrid.setGridParam().showCol("companyName").trigger("reloadGrid");
		}
	}

	function checkTel(no) {
		var isMob = /^1[0-9]{10}/;
		if (isMob.test(no)) {
			return true;
		} else {
			return false;
		}
	}

	$("#mod-add-lawyerTel").on("input propertychange", function (e) {
		var lawyerTel = $(this).val();
		if (checkTel(lawyerTel)) {
			$.ajax({
				dataType: "json",
				url: "${contextPath}/sys/ssfw/extractRecentSsdbOrderWL",
				type: "post",
				data: {
					'lawyerPhone': lawyerTel,
				},
				success: function (data) {
					$("#mod-add-deliveryAddress").val(ret_value(data.address));
					$("#mod-add-orderShippingType").val(ret_value(data.orderShippingType), 4);
					$("#mod-add-orderShippingType").val(5);
					$("#mod-add-contactPhone").val(ret_value(data.mobile));
					$("#mod-add-contactMan").val(ret_value(data.receiver));
				}
			});
		}
	});

	function ret_value(v, defualt) {
		if (v == "null") {
			return "";
		}
		defualt_ret = "";
		if (defualt) {
			defualt_ret = defualt;
		}
		return v || defualt_ret;
	};
	$("#mod-add-submit").on("click", function(e) {
		var loginName = $("#mod-add-loginName").val();
		var courtName = $("#mod-add-courtName").val();
		var lawyerTel = $("#mod-add-lawyerTel").val();
		var bdSum = $("#mod-add-bdSum").val();
		var bdCode = $("#mod-add-bdCode").val();
		var bdCode1 = $("#mod-add-bdCode1").val();
		var bdCode2 = $("#mod-add-bdCode2").val();
		var bf = $("#mod-add-bf").val();
		var points = $("#mod-add-points").val();
		var payedDate = $("#mod-add-payedDate").val();
		/*var orderShippingType = $("#mod-add-orderShippingType").val();*/
		var deliveryAddress = $("#mod-add-deliveryAddress").val();
		var contactMan = $("#mod-add-contactMan").val();
		var contactPhone = $("#mod-add-contactPhone").val();

		var commisionLawyer = $("#mod-add-jfCommision").val();
		var ratLawyer = $("#mod-add-bfCommision").val();
		var managerId = $("#mod-add-manager").val();
		if(!isNotBlank(loginName)){
			alert("请输入公司登录名");
			return;
		}
		if(!isNotBlank(courtName)){
			alert("请输入法院");
			return;
		}
		if(!isNotBlank(lawyerTel) || isNotNumber(lawyerTel)){
			alert("请输入正确的手机号");
			return;
		}
		if(!isNotBlank(bdSum) || isNotDouble(bdSum)){
			alert('请输入正确的诉讼标的');
			return;
		}

		if(!isNotBlank(bdCode)){
			alert('请输入标的类型');
			return;
		}

		if(!isNotBlank(bf) || isNotDouble(bf)){
			alert('请输入正确的保费金额');
			return;
		}

		if(!isNotBlank(points) || isNotDouble(points)){
			alert('请输入正确的积分');
			return;
		}

		/*if(!isNotBlank(deliveryAddress)){
            alert('请输入收件地址');
            return;
        }

        if(!isNotBlank(contactMan)){
            alert('请输入联系人');
            return;
        }

        if(!isNotBlank(contactPhone)){
            alert('请输入联系电话');
            return;
        }*/
		$(this).attr("disabled","true");
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/addOrder",
			type : "post",
			data : {
				'loginName' : loginName,
				'courtName' : courtName,
				'deliveryAddress' : "待补充",
				'contactMan' : "待补充",
				'contactPhone' : "待补充",
				'contactMobile' : lawyerTel,
				'sqbd' : bdSum,
				'bdCode' : bdCode,
				'bdCode1' : bdCode1,
				'bdCode2' : bdCode2,
				'commisionLawyer' : commisionLawyer / 100,
				'ratLawyer' : ratLawyer / 100,
				'bf' : bf,
				'points' : points,
				'orderShippingType' : 4,
				'payedDate' : payedDate,
				'managerId' : managerId
			},
			complete : function(ret) {
				$('#mod-add-submit').removeAttr('disabled')
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					alert("补单成功");
					$("#mod-add").modal("toggle");
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});

	});

	$("#modal-distribution-submit").on("click", function(e) {


		var ssdborderId =  $("#mod-distribution-orderId").val();
		var ssdborderwlId =  $("#mod-distribution-ssdborderwlId").val();

		var sendname = $("#mod-distribution-sendname").val();
		var sendphone = $("#mod-distribution-sendphone").val();
		var sendaddresscity = $("#mod-distribution-sendaddresscity").val();
		var sendaddress = $("#mod-distribution-sendaddress").val();
		var sendaddressditail = $("#mod-distribution-sendaddressdital").val();
		var  sendlatitude= $("#mod-distribution-sendlongitude").val();
		var  sendlongitude= $("#mod-distribution-sendlatitude").val();

		var recname = $("#mod-distribution-recname").val();
		var recphone = $("#mod-distribution-recphone").val();
		var recaddresscity = $("#mod-distribution-recaddresscity").val();
		var recaddress = $("#mod-distribution-recaddress").val();
		var recaddressdetail = $("#mod-distribution-recaddressdital").val();
		var  reclatitude= $("#mod-distribution-reclongitude").val();
		var  reclongitude= $("#mod-distribution-reclatitude").val();

		if(!isNotBlank(sendname)){
			alert("请输入寄件人姓名");
			return;
		}
		if(!isNotBlank(sendphone)){
			alert("请输入寄件人电话");
			return;
		}
		if(!isNotBlank(sendaddress) || !isNotBlank(sendaddresscity)){
			alert("请输入寄件人地址");
			return;
		}
		if(!isNotBlank(sendaddressditail)){
			alert("请输入详细地址");
			return;
		}
		if(!isNotBlank(recname)){
			alert("请输入收件人姓名");
			return;
		}
		if(!isNotBlank(recphone)){
			alert("请输入收件人电话");
			return;
		}
		if(!isNotBlank(recaddress) || !isNotBlank(recaddresscity)){
			alert("请输入收件人地址");
			return;
		}
		if(!isNotBlank(recaddressdetail)){
			alert("请输入收件人详细地址");
			return;
		}
		$("#modal-distribution-submit").attr("disabled","true");
		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssfw/placeOrder",
			type : "post",
			data : {
				'ssdborderwlId':ssdborderwlId,
				'ssdborderId' : ssdborderId,
				'sendName' : sendname,
				'sendPhone' : sendphone,
				'sendAddressCity':sendaddresscity,
				'sendAddress' : sendaddress,
				'sendAddressDitail':sendaddressditail,
				'sendLongitude' : sendlongitude,
				'sendLatitude' : sendlatitude,
				'recName' : recname,
				'recPhone' : recphone,
				'recAddressCity' : recaddresscity,
				'recAddress' : recaddress,
				'recAddressDetail' : recaddressdetail,
				'recLongitude' : reclongitude,
				'recLatitude' : reclatitude
			},
			success : function(data) {
				alert(data.resultmsg);
				$("#modal-distribution").modal("toggle");
				if(data.resultType == true){
					myGrid.trigger("reloadGrid");
				}else{
					$("#modal-distribution-submit").removeAttr("disabled");
				}
			}
		});
	});

	//自动补全律师手机号;
	$(document).ready(function($) {
		$.fn.typeahead.Constructor.prototype.blur = function() {
			var that = this;
			/*console.log(that);*/
			setTimeout(function () { that.hide() }, 250);
			/*alert("hahah")*/

		};
		$("#mod-add-lawyerTel").typeahead({
			source: function (query, process) {
				return $.ajax({
					url: '${contextPath}/sys/ssdbOrder/getlawyerTel',
					type: 'post',
					data: {keyword: query},
					success: function (result) {
						var ret = eval("(" + result + ")");
						var arr1 = new Array();
						for (var i = 0;i<ret.length;i++){
							var obj = new Object();
							obj.name =  ret[i].realName;
							obj.phone = ret[i].mobile;
							arr1.push("{\"name\" :\""+obj.name+"\",\"phone\":\""+obj.phone+"\"}");
						}
						//var jsonObj =  JSON.parse(arr);
						//console.log(arr1);
						process(arr1);
					}
				});
			},
			highlighter: function (obj) {
				var item = JSON.parse(obj);
				console.log(item);
				var query = this.query.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
				return (item.name+""+item.phone).replace(new RegExp('(' + query + ')', 'ig'), function ($1, match) {
					return '<strong>' + match + '</strong>'
				});
			},
			updater: function (obj) {
				var item = JSON.parse(obj);
				return item.phone;
			}

		});
	});


	//自动补全公司登录名;
	$(document).ready(function($) {
		$.fn.typeahead.Constructor.prototype.blur = function() {
			var that = this;
			setTimeout(function () { that.hide() }, 250);
		};

		$('#mod-add-loginName').typeahead({
			source: function(query, process) {
				var parameter = {keyword: query};
				$.post('${contextPath}/sys/ssdbOrder/getCompanyName', parameter, function (data) {
					var ret = eval("(" + data + ")");
					process(ret);
				});
			}
		});
	});
	//自动补全法院;
	$(document).ready(function($) {
		$.fn.typeahead.Constructor.prototype.blur = function() {
			var that = this;
			setTimeout(function () { that.hide() }, 250);
		};

		$('#mod-add-courtName').typeahead({
			source: function(query, process) {
				var parameter = {keyword : query};
				$.post('${contextPath}/sys/ssdbOrder/getCourtName', parameter, function (data) {
					var ret = eval("(" + data + ")");
					console.log(ret);
					/*alert(ret);*/
					process(ret);

				});
			}
		});
	});


	function changeSendAddress(){
		var distributionSendaddress = $("#mod-distribution-sendaddresscity").val().trim() + $("#mod-distribution-sendaddress").val().trim() + $("#mod-distribution-sendaddressdital").val().trim();
		AddressToCoordinates(distributionSendaddress,0);
	}

	function changeRecAddress(){
		var distributionRecaddress = $("#mod-distribution-recaddresscity").val().trim() + $("#mod-distribution-recaddress").val().trim() + $("#mod-distribution-recaddressdital").val().trim();
		AddressToCoordinates(distributionRecaddress,1);
	}

	//地址转换成经纬度
	function AddressToCoordinates(address,key) {
		var url = "http://api.map.baidu.com/geocoder/v2/?address="+address+"&output=json&ak=3hFCEOjrMGFeGUR4uLr5XznVnPvi0wZG";
		$.ajax(url, {
			data: {
			},
			dataType: 'jsonp',
			processData: false,
			type:'get',
			success: function(data) {
				var tempLat = String(data.result.location.lat) ;
				var tempLng = String(data.result.location.lng) ;
				if(key == 0){
					$("#mod-distribution-sendlongitude").val(tempLat.substring(0,tempLat.indexOf(".")+6));
					$("#mod-distribution-sendlatitude").val(tempLng.substring(0,tempLng.indexOf(".")+6));
				}else if(key == 1){
					$("#mod-distribution-reclongitude").val(tempLat.substring(0,tempLat.indexOf(".")+6));
					$("#mod-distribution-reclatitude").val(tempLng.substring(0,tempLng.indexOf(".")+6));
				}
			}

		});
	}

	//修改订单保存
	$("#modal-edit-order-submit").click(function () {
		var orderId=$("#mod-edit-orderId").val();
		var orderState = $("#mod-edit-state").val();
		var orderValid = $("#mod-edit-valid").val();
		// var isOldLawyer = $("#mod-edit-isOldLawyer").val();//是否老律师
		var isRepeat = $("#mod-edit-isRepeat").val();//是否重复订单
		var loginName = $("#mod-edit-companyLoginName").val();
		var sqbd = $("#mod-edit-sqbd").val();
		var court = $("#mod-edit-court").val();
		var plaintiff = $("#mod-edit-plaintiff").val();
		var bf = $("#mod-edit-bf").val();
		var backProportion = $("#mod-edit-backProportion").val();
		var serviceCostPro = $("#mod-edit-serviceCostPro").val();
		var changeReason = $("#mod-edit-changeReason").val();
		var accountName = $("#mod-edit-accountName").val();//账户名
		var accountNum = $("#mod-edit-accountNum").val();//账户
		var accountBank = $("#mod-edit-accountBank").val();//开户行
		var documentaryUser = $("#mod-edit-documentaryUser").val();
		var delivery = $("#delivery").val();
		var payeDate = $("#mod-edit-payedate").val();
		var managerName = $("#managerName").val();
		var name = $("#mod-edit-orderFpName").val();
		var taxNum = $("#mod-edit-taxNum").val();
		var addr = $("#mod-edit-addr").val();
		var tel = $("#mod-edit-tel").val();
		var bankName = $("#mod-edit-bankName").val();
		var bankAccount = $("#mod-edit-bankAccount").val();

		$.ajax({
			dataType : "json",
			url : "${contextPath}/sys/ssdbOrder/editOrder",
			type : "post",
			data : {
				'orderId' : orderId,
				'orderState' : orderState,
				'orderValid' : orderValid,
				// 'isOldLawyer' : isOldLawyer,
				'isRepeat' : isRepeat,
				'loginName' : loginName,
				'sqbd' : sqbd,
				'court' : court,
				'plaintiff' : plaintiff,
				'bf' : bf,
				'backProportion' : backProportion,
				'serviceCostPro' : serviceCostPro,
				'changeReason' : changeReason,
				'accountName' : accountName,
				'accountNum' : accountNum,
				'accountBank' : accountBank,
				'delivery' : delivery,
				'payedDate':payeDate,
				'managerName':managerName,
				'documentaryUser':documentaryUser,
				'name':name,
				'taxNum':taxNum,
				'addr':addr,
				'tel':tel,
				'bankName':bankName,
				'bankAccount':bankAccount
			},
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				if(ret.success){
					alert("修改成功");
					$("#modal-edit-order").modal("toggle");
					myGrid.trigger("reloadGrid");
				}else{
					alert(ret.message);
				}
			}
		});

	});




	/*========================================图片文件相关(start)=================================*/

	function loadPic(orderId, path, fileName, fileType,attachId,divId){
		var url = '${oss_bucket_ssdb_url}';
		var html = '<div style="text-align:center;display:inline-block;vertical-align:top;" id="'+attachId+'">';
		html += '<input type="hidden" id="in-' + divId + '" value="'+ attachId +'" />';
		html += '<a href="' + url + '/' + path + '" target="_blank">';
		html += '<img  src ="' + url  + '/' + path + '" height="100" width="100" />';
		html += '</a><br/><a href="javascript:void(0)" onclick="deletePic(\'' + attachId + '\')">删除</a>';
		html += '</div>&nbsp;';
		$("#" + divId).append(html);
		setTimeout(function () {
			$("img.lazy").lazyload({
				threshold : 200
			});
		}, 200);
		//$('#mod-pic').modal('toggle');
	}

	function loadGendanPic(orderId, path, fileName, fileType,attachId,divId){
		var url = '${oss_bucket_ssdb_url}';
		var html = '<div style="text-align:center;display:inline-block;vertical-align:top;" id="'+attachId+'">';
		html += '<input type="hidden" id="in-' + divId + '" value="'+ attachId +'" />';
		html += '<a href="' + url + '/' + path + '" target="_blank">';
		html += '<img  src ="' + url  + '/' + path + '" height="100" width="100" />';
		html += '</a><br/><a href="javascript:void(0)" onclick="deletePic(\'' + attachId + '\')">删除</a>';
		html += '</div>&nbsp;';
		$("#" + divId).append(html);
		setTimeout(function () {
			$("img.lazy").lazyload({
				threshold : 200
			});
		}, 200);
		//$('#mod-pic').modal('toggle');
	}

	function loadFile(orderId, path, fileName, fileType,attachId,divId){
		var url = '${oss_bucket_ssdb_url}';
		var html = '<div style="text-align:center;display:inline-block;vertical-align:top;" id="'+attachId+'">';
		html += '<input type="hidden" id="in-' + divId + '" value="'+ attachId +'" />';
		html += '<a href="' + url + '/' + path + '" target="_blank">';
		html += fileName;
		html += '</a><br/><a href="javascript:void(0)" onclick="deletePic(\'' + attachId + '\')">删除</a>';
		html += '</div><br/>';
		$("#" + divId).append(html);
		setTimeout(function () {
			$("img.lazy").lazyload({
				threshold : 200
			});
		}, 200);
		//$('#mod-pic').modal('toggle');
	}

	//删除图片
	function deletePic(id){
		//var orderId = $("#mod-edit-orderId").val();
		$('#picDiv' + id).hide();
		var url =  '${contextPath}/sys/ssdbOrder/deleteAttachById';
		var parameters = {"ids":id};
		$.ajax({
			dataType : "json",
			url : url,
			type : "post",
			data : parameters,
			complete : function(ret) {
				var ret = eval("(" + ret.responseText + ")");
				deletePiCallback(ret);
			}
		});
	}
	function deletePiCallback(data){
		var resData = data;
		if(resData.success){
			var id = resData.id ;
			$("#"+id).hide();
		}else{
			showMsg(data.message);
		}
	}

	function uploadEditPic(attachType,divId){
		document.getElementById('picform').reset();
		$("#mod-pic").modal("toggle");
		$("#mod-pic-attachType").val(attachType);
		$("#mod-pic-divId").val(divId);
		$("#mod-pic-orderId").val($('#mod-edit-orderId').text());
	}

	function uploadGendanPic(attachType,divId){
		document.getElementById('gendanform').reset();
		$("#mod-gendan").modal("toggle");
		$("#mod-gendan-attachType").val(attachType);
		$("#mod-gendan-divId").val(divId);
		$("#mod-gen-orderId1").val($('#mod-gendan-orderId1').val());
	}
	//上传文件
	function uploadEditFil(attachType,divId){
		document.getElementById('fileform').reset();
		$("#mod-file").modal("toggle");
		$("#mod-file-attachType").val(attachType);
		$("#mod-file-divId").val(divId);
		$("#mod-file-orderId").val($('#mod-edit-orderId').text());
	}

	/*上传图片*/
	function updatePic() {
		var orderId = $("#mod-pic-orderId1").val();
		picUpload(orderId);
	}

	function updateGendanPic() {
		var orderId = $("#mod-gendan-orderId1").val();
		picGendanUpload(orderId);
		$("#mod-gendan").modal("toggle");
	}

	/*上传文件*/
	function updateFile() {
		var orderId = $("#mod-file-orderId1").val();
		fileUpload(orderId);
	}

	//pic上传处理
	function picUpload(id) {
		lsOrderId = id ;
		applyTokenDo(uploadPic);
	}
	//pic上传处理
	function picGendanUpload(id) {
		lsOrderId = id ;
		applyTokenDo(uploadGendanFile);
	}

	//file上传处理
	function fileUpload(id) {
		lsOrderId = id ;
		applyTokenDo(uploadFile);
	}

	//图片
	var uploadPic = function(client) {
		var picFiles=document.getElementsByName('picfile')[0].files;
		var orderId=$("#mod-edit-orderId").val();
		var divId=document.getElementById('mod-pic-divId').value;
		for (var i = 0 ; i < picFiles.length ; i ++){
			//alert(i);
			var fileName = null;
			console.log(fileName);
			var fileType = null;
			var key = null;
			var picFile=picFiles[i];
			console.log(picFile);
			fileName = UUIDjs.create().hex;
			console.log(fileName);
			fileType = getFileType(picFile.name);
			key = "ssdb/"+orderId+"/"+fileName+"."+fileType;
			console.log(key);
			pppic(client,picFile,orderId, key, fileName, fileType, divId);
		}
		$("#mod-pic").modal("toggle");
	};

	//跟单图片
	var uploadGendanFile = function(client) {
		var file=document.getElementById('gendanId').files[0];
		var orderId=$("#mod-gen-orderId1").val();
		var divId=document.getElementById('mod-gendan-divId').value;
		var fileName = file.name;
		var fileType = getFileType(file.name);
		var key = "ssdb/"+orderId+"/"+fileName+"."+fileType;
		console.log(key);
		return client.multipartUpload(key, file, {
			progress: progress
		}).then(function(res) {
			console.log(orderId,key,fileName,fileType,divId);
			saveGendanToDB(orderId,key,fileName,fileType,divId);
		});
	};

	function pppic(client,picFile,orderId, key, fileName, fileType, divId) {
		client.multipartUpload(key, picFile, {
			progress: progress
		}).then(function(res) {
			saveToDB(orderId,key,fileName,fileType,divId);
		});
	}
	//文件
	var uploadFile = function(client) {
		var file=document.getElementById('FileId').files[0];
		var orderId=$("#mod-edit-orderId").val();
		var divId=document.getElementById('mod-file-divId').value;
		var fileName = file.name;
		var fileType = getFileType(file.name);
		var key = "ssdb/"+orderId+"/"+fileName+"."+fileType;
		return client.multipartUpload(key, file, {
			progress: progress
		}).then(function(res) {
			saveFileToDB(orderId,key,fileName,fileType,divId);
		});
	};

	function saveToDB(orderId,key,fileName,fileType,divId){
		var attachType = $("#mod-pic-attachType").val();
		var parameters = {"orderId":orderId,"attachType":attachType,"path":key,"fileName":fileName,"fileType":fileType};
		console.log(parameters);
		$.post('${contextPath}/sys/ssdbOrder/uploadPic',parameters,function(result){
			if(result.success){
				/*$("#mod-pic").modal("toggle");*/
				var picId = result.attathId ;
				loadPic(orderId,key,fileName,fileType,picId,divId);
			}else{
				alert(result.message);
			}

		});

	}

	function saveGendanToDB(orderId,key,fileName,fileType,divId){
		var attachType = $("#mod-gendan-attachType").val();
		var parameters = {"orderId":orderId,"attachType":attachType,"path":key,"fileName":fileName,"fileType":fileType};
		console.log(parameters);
		$.post('${contextPath}/sys/ssdbOrder/uploadPic',parameters,function(result){
			if(result.success){
				/*$("#mod-pic").modal("toggle");*/
				var picId = result.attathId ;
				loadGendanPic(orderId,key,fileName,fileType,picId,divId);
			}else{
				alert(result.message);
			}

		});

	}
	function saveFileToDB(orderId,key,fileName,fileType,divId){
		var attachType = $("#mod-file-attachType").val();
		var parameters = {"orderId":orderId,"attachType":attachType,"path":key,"fileName":fileName,"fileType":fileType};
		$.post('${contextPath}/sys/ssdbOrder/uploadPic',parameters,function(result){
			if(result.success){
				$("#mod-file").modal("toggle");
				var picId = result.attathId ;
				loadFile(orderId,key,fileName,fileType,picId,divId);
			}else{
				alert(result.message);
			}

		});

	}
	var appServer = 'http://b.duowenlvshi.com/oss/token?name=ssdb';
	var bucket = '${oss_bucket_ssdb}';
	var region = 'oss-cn-shenzhen';
	var applyTokenDo = function (func) {
				var url = appServer;
				$.ajax({
					type: "POST",
					url: url,
					data: "",
					dataType: "jsonp",
					success: function (e) {
						var client = new OSS.Wrapper({
							region: region,
							accessKeyId: e.AccessKeyId,
							accessKeySecret: e.AccessKeySecret,
							stsToken: e.SecurityToken,
							bucket: bucket
						});
						return func(client);
					},
					error: function (data) {
						console.log(data);
					}
				});
			}
	;


	//默认回调函数
	function errorCallbackDefault(data){
		//alert("enter errorCallbackDefault"+JSON.stringify(data));
	}

	//向后台请求数据
	function postData(url, parameters, successCallback, errorCallback){
		$.ajax({
			type : "POST",
			url : url,
			data : parameters,
			dataType : "json",
			success : function(data) {
				successCallback(data);
			},
			error : function(data) {
				errorCallback(data);
			}
		});
	}
	//显示信息
	function showMsg(msg){
		if(msg != undefined && msg.length > 0){
			alert(msg);
		}
	}

	function getFileType(fileName) {
		var ldot = fileName.lastIndexOf('.')
		if (ldot >= 0)
			return fileName.substring(ldot + 1);
		else
			return "";
	}

	var progress = function (p) {//上传成功的进度条
				return function (done) {
					done();
				};
			}
	;



	/*=================图片文件相关(end)===================*/
</script>
<script>
	var clipboard = new Clipboard('.copybtn');

	clipboard.on('success', function(e) {
		console.log("success");
		console.log(e);
		console.log(e.text);
	});

	clipboard.on('error', function(e) {
		console.log(e);
	});

	function updateCompany(orderId) {
		var company = window.prompt("请输入新的保险公司：");
		if (company){
			$.ajax({
				dataType : "json",
				url : "${contextPath}/sys/ssdbOrder/updateCompany",
				type : "post",
				data : {
					'orderId' : orderId,
					'company' : company,
				},
				complete : function(ret) {
					console.log(ret);
					var ret = eval("(" + ret.responseText + ")");
					alert(ret.message);
					myGrid.trigger("reloadGrid");
				}
			});
		}
	}
</script>
