<%@ 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" %>
<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/ui.jqgrid.css" />

<style>
    /*基本信息*/

    .div-1{
        border: 1px #E1E1E1 solid;
        width:800px;
        height:900px;
    }
    .title-p{
        width:500px;
        height:20px;
        font-size:14px;
        font-weight:bold;
        color:rgba(102,102,102,1);
        line-height:40px;
        position: absolute;
        left: 40px;
    }
    .title-t{
        width:800px;
        height:44px;
        background:rgba(188,224,255,1);
    }
    .inner-div1{
        position: absolute;
        margin: 10px 30px;
    }
    #inner-div1-orderId{
        top: 90px;
    }
    #inner-div-company{
        top: 90px;
        left: 230px;
    }
    #inner-div1-orderState{
        top: 85px;
        left: 460px;
    }
    #inner-div1-lawyerName{
        top: 140px;
    }
    #inner-div1-lawyerPhone{
        top: 140px;
        left: 230px;
    }
    .hr-line-dashed {
        background-color: #ffffff;
        border-top: 1px dashed #e7eaec;
        color: #ffffff;
        height: 1px;
        margin: 20px 0;
    }
    #inner-div1-managerId{
        top: 140px;
        left: 460px;
    }
    #inner-div1-bf{
        top: 190px;
    }
    #inner-div1-commisionLawyer{
        top: 190px;
        left: 230px;
    }
    #inner-div1-isBusy{
        top: 190px;
        left: 460px;
    }
    .select-div1{
        width: 120px;
        height: 30px;
        border-radius: 5px;
    }
    .footer-content{
        display: none;
    }
    .div-hr{
        width: 760px;
        height: 10px;
    }
    #div-1-hr-1{
        position: relative;
        top: 180px;
    }
    #inner-div1-court{
        top: 270px;
    }
    #inner-div1-sqbd{
        top: 270px;
        left: 340px;
    }
    #inner-div1-bdCode{
        top: 320px;
    }
    #inner-div1-plaintiff{
        top: 320px;
        left: 340px;
    }
    .div-1-input{
        position: relative;
        left: 25px;
    }
    .div-input{
        width: 180px;
        height: 30px;
        border-radius: 10px;
    }
    .div-1-6{
        position: relative;
        top: 270px;
        left: 30px;
        margin: 60px 0;
    }
    .xy-btn{
        width:200px;
        height:40px;
        border-radius: 5px;
    }
    #div-1-button{
        position: relative;
        top: 250px;
        left: 30px;
    }
    /*审核部分*/
    .div-2{
        border: 1px #E1E1E1 solid;
        width:800px;
        height:500px;
    }
    .inner-div2{
        position: absolute;
        margin: 10px 30px;
    }
    #inner-div2-createDate{
        top: 960px;
    }
    #inner-div2-checkCloseDate{
        top: 960px;
        left: 350px;
    }
    #inner-div2-checkDate{
        top: 1000px;
    }
    #inner-div2-checkHours{
        top: 1000px;
        left: 350px;
    }
    #div-2-hr-1{
        position: relative;
        top: 80px;
    }
    #inner-div2-pic{
        top: 1070px;
    }

    .row{
        height: 15px;
    }

</style>

<html>
<title><span id="title"></span></title>
<div id="modal-table-body">

</div>


<div id="modal-logReplys" class="modal fade" tabindex="-1">
    <div class="modal-dialog" style="max-width: 400px;">
        <div class="modal-content">
            <div class="modal-header">
                <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="form-group"><textarea placeholder="输入律师对案件审核结果的回复" cols="39" rows="5" id="content"></textarea></div>
            </div>
            <div class="modal-footer">
                <button class="btn " data-dismiss="modal"><i class="fa fa-share bigger-160"></i>取消</button>
                <button class="btn btn-primary" onclick="saveLogReplys()" type="button" id="mod-logReplys-submit"><strong><i class="fa fa-floppy-o bigger-160"></i>确定</strong></button>
            </div>
        </div>
    </div>
</div>

<div id="modal-orderwl" class="modal fade" tabindex="-1">
    <div class="modal-dialog" style="max-width: 400px;">
        <div class="modal-content">
            <div class="modal-header">
                <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-sm-12">配送方式：
                        <select id="sendType">
                            <option value="">请选择</option>
                            <option value="0">上门配送</option>
                            <option value="1">顺丰</option>
                        </select>
                    </div>
                </div>

                <div class="row">
                    <div class="col-sm-12">单号：<input type="text" id="wl_order"></div>
                </div>

            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" onclick="saveOrderwl()" type="button" ><strong><i class="fa fa-floppy-o bigger-160"></i>确定</strong></button>
                <button class="btn " data-dismiss="modal"><i class="fa fa-share bigger-160"></i>取消</button>

            </div>
        </div>
    </div>
</div>

<div id="mod-pic" class="modal fade" tabindex="-1">
    <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" style="height: 200px">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS  -->
                        <form id="picform" >
                            <input id="picFileId" type="file" name="file" multiple />
                            <input type="hidden" name="attachType" id="mod-pic-attachType"/>
                            <input type="hidden" name="orderId" id="mod-pic-orderId"/>
                            <div class="hr hr-12 dotted"></div>
                            <div class="text-center">
                                <button type="button" class="btn btn-sm btn-primary" onclick="picUpload();">上传</button>
                                <button type="reset" class="btn btn-sm">清除</button>
                            </div>
                        </form>
                    </div><!-- /.col -->
                </div><!-- /.row -->

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

<%--&lt;%&ndash;基本信息&ndash;%&gt;--%>
<%--<div class="div-1 div-div">--%>
<%--    <div class="title-t">--%>
<%--        <div  class="title-p">基本信息</div>--%>
<%--    </div>--%>
<%--    <div class="div-1-1">--%>
<%--        <div class="inner-div1" id="inner-div1-orderId">--%>
<%--            订单号：<span id="div-1-orderId"></span>--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div-company">--%>
<%--            保险公司：<span id="div-1-company"></span>--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-orderState">--%>
<%--            订单状态：--%>
<%--            <select class="select-div1" id="div-1-orderState">--%>
<%--                <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="div-1-2">--%>
<%--        <div class="inner-div1" id="inner-div1-lawyerName">--%>
<%--            律师：<span id="div-1-lawyerName"></span>--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-lawyerPhone">--%>
<%--            电话：<span id="div-1-lawyerPhone"></span>--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-managerId">--%>
<%--            客户经理：<span id="div-1-managerId"></span>--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <div class="div-1-3">--%>
<%--        <div class="inner-div1" id="inner-div1-bf">--%>
<%--            保费：<input type="text" id="div-1-bf"></input>元--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-commisionLawyer">--%>
<%--            返点：<input type="text" id="div-1-commisionLawyer"></input>%--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-isBusy">--%>
<%--            是否加急：--%>
<%--            <select class="select-div1" id="div-1-isBusy">--%>
<%--                <option value="">请选择</option>--%>
<%--                <option value="0">是</option>--%>
<%--                <option value="1">否</option>--%>
<%--            </select>--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <hr class="div-hr" id="div-1-hr-1">--%>
<%--    <div class="div-1-4">--%>
<%--        <div class="inner-div1" id="inner-div1-court">--%>
<%--            法院：<input type="text" class="div-1-input div-input"  id="div-1-court">--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-sqbd">--%>
<%--            保全金额：<input type="text" class="div-input" id="div-1-sqbd">--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <div class="div-1-5">--%>
<%--        <div class="inner-div1" id="inner-div1-bdCode">--%>
<%--            案件类型：<input type="text" class="div-input"  id="div-1-bdCode">--%>
<%--        </div>--%>
<%--        <div class="inner-div1" id="inner-div1-plaintiff">--%>
<%--            原告：<input type="text" class="div-1-input div-input" id="div-1-plaintiff">--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <div class="div-1-6">--%>
<%--        <p id="div-1-pic-1">起诉状</p>--%>
<%--        <div id="div-1-img-1"><img src=""></div>--%>
<%--    </div>--%>
<%--    <div class="div-1-6">--%>
<%--        <p id="div-1-pic-2">保全申请书</p>--%>
<%--        <div id="div-1-img-2"><img src=""></div>--%>
<%--    </div>--%>
<%--    <div class="div-1-6">--%>
<%--        <p id="div-1-pic-3">原/被告身份资料</p>--%>
<%--        <div id="div-1-img-3"><img src=""></div>--%>
<%--    </div>--%>
<%--    <div class="div-1-6">--%>
<%--        <p id="div-1-pic-4">证据资料</p>--%>
<%--        <div id="div-1-img-4"><img src=""></div>--%>
<%--    </div>--%>
<%--    <div class="div-1-7">--%>
<%--        <button id="div-1-button" onclick="editOrder()"  class="btn btn-sm btn-primary xy-btn">保存</button>--%>
<%--    </div>--%>
<%--</div>--%>


<%--&lt;%&ndash;审核&ndash;%&gt;--%>

<%--<div class="div-2 div-div">--%>
<%--    <div class="title-t">--%>
<%--        <div  class="title-p">审核</div>--%>
<%--    </div>--%>
<%--    <div class="div-2-1">--%>
<%--        <div class="inner-div2" id="inner-div2-createDate">--%>
<%--            提交时间：<span id="div-2-createDate"></span>--%>
<%--        </div>--%>
<%--        <div class="inner-div2" id="inner-div2-checkCloseDate">--%>
<%--            承诺首次审核时间：<span id="div-2-checkCloseDate"></span>--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <div class="div-2-2">--%>
<%--        <div class="inner-div2" id="inner-div2-checkDate">--%>
<%--            实际首次审核时间：<span id="div-2-checkDate"></span>--%>
<%--        </div>--%>
<%--        <div class="inner-div2" id="inner-div2-checkHours">--%>
<%--            审核时效：<span id="div-2-checkHours"></span>--%>
<%--        </div>--%>
<%--    </div>--%>
<%--    <hr class="div-hr" id="div-2-hr-1">--%>
<%--    <div class="div-2-3">--%>
<%--        <div class="inner-div2" id="inner-div2-pic">--%>
<%--            保险公司要求补充资料：--%>
<%--            <span id="div-2-pic"></span>--%>
<%--        </div>--%>
<%--    </div>--%>
<%--</div>--%>

</html>



<script type="text/javascript">

    console.log(window.location.href);
    var str = window.location.href;
    let list =  str.split('?');
    var orderId = decodeURI(list[1]);
    $("#title").html(orderId);//将页面 title 改为订单号
    $("#div-1-orderId").html(orderId);

    //获取当前时间
    function getDate(){
        var d = new Date();
        var date = d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes();
        return date;
    }

    //pic上传处理
    function picUpload() {
        applyTokenDo(uploadFile);
    }

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

    //添加律师的回复
    function saveLogReplys(){
        var content = $("#content").val();
        if(!content){
            alert("请输入内容");
            return;
        }
        $.ajax({
            type : "POST",
            url : "${contextPath}/ssdb/new/saveLogReplys",
            data : {
                'orderId' : orderId,
                'content' : content
            },
            dataType : "json",
            success : function(data) {
                saveRecord(getDate()+" 添加了律师回复");
                alert("操作成功");
                location.reload();
            }
        });
    }

    function saveToDB(orderId,key,fileName,fileType){
        var attachType = $("#mod-pic-attachType").val();
        var parameters = {"orderId":orderId,"attachType":attachType,"path":key,"fileName":fileName,"fileType":fileType};
        console.log(parameters);
        $.getJSON('${contextPath}/ssdb/new/saveOrderAttach',parameters,function(result){
            if(result.success){
                var type = $("#mod-pic-attachType").val();
                var record = getDate();

                if(type == 74){
                    record +=" 上传了未签名投保单图片";
                }else if(type == 70){
                    record +=" 上传了未盖章保函模板图片";
                }else if(type == 71){
                    record +=" 上传了盖章保函图片";
                }else if(type == 72){
                    record +=" 上传了盖章保单图片";
                }else if(type == 31){
                    record +=" 上传了补充资料";
                }
                saveRecord(record);
                uploadSuccess();
            }else
                alert(result.message);
        });

    }

    function uploadSuccess(){
        $("#mod-pic").modal("toggle");
        var t = $("#mod-pic-attachType").val();
        loadPic(t);
    }

    function loadPic(attachType){
        var url = '${contextPath}/ssdb/new/ssdbOrderAdditionalMaterials';
        var parameters = {"orderId":orderId,"attachType":attachType};
        postData(url, parameters, loadPiCallback, errorCallbackDefault);
    }

    //回显图片
    function loadPiCallback(data){
        location.reload();
        <%--debugger;--%>
        <%--if(data.length > 0){--%>
        <%--    var url = '${oss_bucket_ssdb_url}';--%>
        <%--    var thum = '${oss_bucket_ssdb_url_img}';--%>
        <%--    var size = '${oss_bucket_ssdb_url_img_size}';--%>
        <%--    var v = null;--%>
        <%--    var sec = '';--%>
        <%--    for(var i in data){--%>
        <%--        v = data.[i];--%>
        <%--        //url = "${ServerC}/ssdbOrderPic?orderAttachId="+v.id;--%>

        <%--        sec += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + v.id + '">';--%>
        <%--        sec += '<a href="' + url + v.path + '" target="_blank">';--%>
        <%--        sec += '<img class="lazy" src="' + thum + v.path + size  + '" data-original="' + thum + v.path + size  + '" height="100" width="100" id="' + v.id + '"/>';--%>
        <%--        sec += '</a>';--%>
        <%--        sec += '</div>&nbsp;';--%>
        <%--    }--%>
        <%--    if (data.length >0) {--%>
        <%--        $("#div" + data.attachType).next().hide();--%>
        <%--    }--%>
        <%--    $("#div" + data.attachType).html(sec);--%>
        <%--    setTimeout(function () {--%>
        <%--        $("img.lazy").lazyload({--%>
        <%--            threshold : 200--%>
        <%--        });--%>
        <%--    }, 200);--%>
        <%--}else{--%>
        <%--    showMsg(data.message);--%>
        <%--}--%>
    }



    function errorCallbackDefault(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);
            }
        });
    }

    var uploadFile = function(client) {
        var picFile=document.getElementById('picFileId').files[0];
        var orderId=document.getElementById('mod-pic-orderId').value;
        var fileName = UUIDjs.create().hex;
        var fileType = getFileType(picFile.name);
        var key = "ssdb/"+orderId+"/"+fileName+"."+fileType;
        return client.multipartUpload(key, picFile, {
            progress: progress
        }).then(function(res) {
            saveToDB(orderId,key,fileName,fileType);
        });
    };

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


    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 getSsdbOrder() {
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ssdb/new/ssdbOrderDetails",
            type : "post",
            async: false,
            data : {
                'orderId' : orderId,
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                //订单基本信息
                var order = ret.order;
                //订单资料
                var attachs = ret.attachs;
                //基本信息
                var html = "";
                html +='<label class="col-sm-12" style="\n' +
                    '    height: 30px;\n' +
                    '    margin-right: 700px;\n' +
                    '    line-height: 30px;\n' +
                    '    font-size: 14px;\n' +
                    '    font-weight: bold;\n' +
                    '    background-color: #6fb3e0;\n' +
                    '">基本信息</label>';
                html +='<div class="row">'+
                    ' <label class="col-sm-3">订单号：'+isNull(order.orderId)+'</label>' +
                    ' <label class="col-sm-3">保险公司：'+isNull(order.companyName)+'</label>' +
                    ' <label class="col-sm-5">订单状态：            <select  id="orderState">\n' +
                    '<option value="0">审核中</option>\n' +
                    '<option value="10">已取消</option>\n' +
                    '<option value="20">审核失败</option>\n' +
                    '<option value="21">审核反馈</option>\n' +
                    '<option value="22">待付款</option>\n' +
                    '<option value="30">待确认</option>\n' +
                    '<option value="31">付款反馈</option>\n' +
                    '<option value="32">待出函</option>\n' +
                    '<option value="40">已出函</option>\n' +
                    '<option value="41">已配送</option>\n' +
                    '<option value="50">退保处理中</option>\n' +
                    '<option value="51">退保成功</option>\n' +
                    '<option value="52">退保失败</option>\n' +
                    '</select></label></div>'
                html +='<div class="row">'+
                    ' <label class="col-sm-3">律师：'+isNull(order.realName)+'</label>' +
                    ' <label class="col-sm-3">电话：'+isNull(order.lawyerPhone)+'</label>' +
                    ' <label class="col-sm-4">客户经理：'+isNull(order.manager)+'</label>'
                +'</div>';
                html +='<div class="row">'+
                    ' <label class="col-sm-3">保费：<input type="text" id="bf" value="'+order.bf+'">元 </label>' +
                    ' <label class="col-sm-3">返点：<input type="text" id="commisionLawyer" value="'+order.commisionLawyer+'">% </label>' +
                    ' <label class="col-sm-4">加急状态：  <select id="isBusy">\n' +
                    ' <option value="">请选择</option>\n' +
                    ' <option value="1">是</option>\n' +
                    '<option value="0">否</option></select></label></div>';
                html+= '<div class="hr-line-dashed"></div>';
                html += '<div class="row">'
                html += ' <label class="col-sm-4">法院：<input type="text" id="courtName" value="'+order.courtName+'"> </label>';
                html += ' <label class="col-sm-3">保全金额：<input type="text" id="sqbd" value="'+order.sqbd+'"> </label>';
                html += '</div>';
                html += '<div class="row">'
                html += ' <label class="col-sm-3">案件类型：<select id="bdCode"></select></label> ';
                var plaintiff = "";
                if(order.plaintiff){
                    plaintiff = order.plaintiff;
                }
                html += ' <label class="col-sm-5">原告：<input type="text" id="plaintiff" value="'+plaintiff+'"> </label>';
                html += '</div>';

                html +='<div class="row">'+
                    ' <label class="col-sm-3">省：'+isNull(order.province)+'</label>' +
                    ' <label class="col-sm-3">市：'+isNull(order.region)+'</label>' +
                    ' <label class="col-sm-4">是否重复订单：  <select id="isRepeat">\n' +
                    ' <option value="">请选择</option>\n' +
                    ' <option value="0">否</option>\n' +
                    '<option value="1">是</option></select></label></div>';

                html += '<div class="row"> <label class="col-sm-12">是否无效订单：  <select id="validState">\n' +
                ' <option value="">请选择</option>\n' +
                ' <option value="0">否</option>\n' +
                '<option value="1">是</option></select></label>'
                    +'</div>';


                var aBean,name,oa = null;
                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-12">';
                        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="' + thum + oa.path + size + '" 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="' + thum + oa.path + size + '" data-original="' + thum + oa.path + size + '" height="100" width="100">';
                                    html +='</a>&nbsp;';
                                }

                            }
                        }
                        html +=   '</div>'
                            + '</div>';
                    }
                }
                html +='<div  class="modal-footer no-margin-top">' +
                    '<div class="text-center">' +
                    '<button onclick="editOrder()" id="mod-updateOrder-submit" type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '保存' +
                    '</button>' +
                    '</div>' +
                    '</div>'

                //审核信息
                html +='<label class="col-sm-12" style="\n' +
                    '    height: 30px;\n' +
                    '    margin-right: 700px;\n' +
                    '    line-height: 30px;\n' +
                    '    font-size: 14px;\n' +
                    '    font-weight: bold;\n' +
                    '    background-color: #6fb3e0;\n' +
                    '">审核</label>';
                html += '<div class="row">'
                    + '<div class="col-md-3 ma">提交时间：'+formatString(order.createDate) +'</div>'
                    + '<div class="col-md-3 ma">承诺首次审核时间：'+formatString(order.lcDate)+'</div>'
                    + '<div class="col-md-3 ma">实际首次审核时间：'+ formatString(order.checkDate)+'</div>'
                    + '<div class="col-md-3 ma">审核时效：'+ getHour(order.lcDate,order.checkDate) +'</div>'
                    + '</div>';
                html+= '<div class="hr-line-dashed"></div>';

                var logReplys = ret.logReplys;
                if(logReplys.length>0){
                    html += '<div class="row">'
                        + '<div class="col-md-5 ma">保险公司要求补充资料：</div>';
                    for(var j in logReplys){
                        row = logReplys[j];
                        if(row.attachType == 21 || row.attachType == 52){
                            var content = row.createDate +" "+row.content;
                            html +="<strong>"+content+"</strong>";
                        }
                    }
                    html += '</div>'
                }else{
                    html += '<div class="row">'
                        + '<div class="col-md-5 ma">保险公司要求补充资料：</div>'
                        + '</div>'
                        + '<div class="hr-line-dashed"></div>';
                }
                html+= '<div class="hr-line-dashed"></div>';
                $.ajax({
                    dataType : "json",
                    url : "${contextPath}/ssdb/new/ssdbOrderAdditionalMaterials",
                    type : "post",
                    data : {
                        'orderId' : orderId
                    },
                    async: false,
                    success: function (data) {
                        html += '<div class="row">'
                            + '<div class="col-md-12 ma" id="div31">律师上传的补充资料：';
                        var additionalMaterials = data;
                        if(additionalMaterials.length > 0){
                            for(var m in additionalMaterials){
                                oa = additionalMaterials[m];
                                html +='<a href="' + url + oa.path + '" target="_blank">';
                                html += '<img class="lazy" src="' + thum + oa.path + size+ '" data-original="' + thum + oa.path + size + oa.suffix.toLowerCase() + '" height="100" width="100">';
                                html +='</a>&nbsp;';
                            }
                        }
                        html+='</div>'
                            + '</div>'
                            + '<div class="hr-line-dashed"></div>';
                    }
                });

                //律师对审核结果的回复
                html += '<div class="row">'
                    + '<div class="col-md-12">律师对审核结果的回复：</div>';
                for(var j in logReplys){
                    row = logReplys[j];
                    if(row.attachType == 51){
                        var content = row.createDate +" "+row.content;
                        html +='<div class="col-md-12"><strong>'+content+'</strong></div>';
                    }
                }
                html+= '<div class="hr-line-dashed"></div>';

                html +='<div  class="modal-footer no-margin-top">' +
                    '<div class="text-center">' +
                    '<button onclick="uploadPic(31)" type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '上传补充资料' +
                    '</button>' +
                    '<button onclick="showLogReplys()"  type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '输入律师回复' +
                    '</button>' +
                    '</div>' +
                    '</div>'


                //付款信息
                html +='<label class="col-sm-12" style="\n' +
                    '    height: 30px;\n' +
                    '    margin-right: 700px;\n' +
                    '    line-height: 30px;\n' +
                    '    font-size: 14px;\n' +
                    '    font-weight: bold;\n' +
                    '    background-color: #6fb3e0;\n' +
                    '">付款</label>';
                html += '<div class="row ma">'
                    + '<div class="col-md-12">保险公司收款信息</div>'
                    + '</div>';

                $.ajax({
                    dataType : "json",
                    url : "${contextPath}/ssdb/new/getCompanyInfo",
                    type : "post",
                    data : {
                        'orderId' : orderId
                    },
                    async: false,
                    success: function (companyInfo) {
                        //账户名
                        var accountName = "";
                        //账号
                        var accountNum = "";
                        //开户行
                        var accountBank = "";
                        if(companyInfo.accountName){
                            accountName = companyInfo.accountName;
                        }
                        if(companyInfo.accountNum){
                            accountNum = companyInfo.accountNum;
                        }
                        if(companyInfo.accountBank){
                            accountBank = companyInfo.accountBank;
                        }
                        html += '<div class="form-group">'
                            +'<div class="row ma">'
                            +'<label class="col-sm-12 control-label"> 账户名：'+accountName+'</label>'
                            +'</div>'
                            +'<div class="row ma">'
                            +'<label class="col-sm-12 control-label">账号：'+accountNum+'</label>'
                            +'</div>'
                            +'<div class="row ma">'
                            +'<label class="col-sm-12 control-label">开户行：'+accountBank+'</label>'
                            +'</div>'
                            +'</div>'
                            +'<div class="row ma">'
                        +'</div>'
                        html += '<div class="hr-line-dashed"></div>';
                    }
                });


                //未签名的投保单
                var SsdbOrderAttach74;
                //未盖章保函模板
                var SsdbOrderAttach70;
                //律师上传的投保单
                var SsdbOrderAttach52;
                //律师上传的付款凭证
                var SsdbOrderAttach41;
                //盖章保函图片
                var SsdbOrderAttach71;
                //盖章保单图片
                var SsdbOrderAttach72;
                //律师回寄投保单的快递单照片
                var SsdbOrderAttach78;

                //图片资源
                $.ajax({
                    dataType : "json",
                    url : "${contextPath}/ssdb/new/getAttachs",
                    type : "post",
                    data : {
                        'orderId' : orderId
                    },
                    async: false,
                    success: function (ssdbOrderAttachList) {

                        if(ssdbOrderAttachList && ssdbOrderAttachList.length > 0){
                            for(var j in ssdbOrderAttachList){
                                switch (ssdbOrderAttachList[j].attachType) {
                                    case 70:
                                        //未盖章保函模板
                                        SsdbOrderAttach70 = ssdbOrderAttachList[j];
                                        break;
                                    case 74:
                                        //未签名的投保单
                                        SsdbOrderAttach74 = ssdbOrderAttachList[j];
                                        break;
                                    case 52:
                                        //律师上传的投保单
                                        SsdbOrderAttach52 = ssdbOrderAttachList[j];
                                        break;
                                    case 41:
                                        //律师上传的付款凭证
                                        SsdbOrderAttach41 = ssdbOrderAttachList[j];
                                        break;
                                    case 71:
                                        //盖章保函图片
                                        SsdbOrderAttach71 = ssdbOrderAttachList[j];
                                        break;
                                    case 72:
                                        //盖章保单图片
                                        SsdbOrderAttach72 = ssdbOrderAttachList[j];
                                        break;
                                    case 78:
                                        //律师回寄投保单的快递单照片
                                        SsdbOrderAttach78 = ssdbOrderAttachList[j];
                                        break;
                                }
                            }
                        }

                        html += '<div class="form-group">'
                            +'<div class="row ma">'
                            +'<label class="col-sm-2 control-label">未签名的投保单 </label>'
                            +'<div class="col-sm-9 text-left">'
                            +'<div id="div74" class="checkbox-inline">'
                        if(SsdbOrderAttach74){
                            html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach74.id + '">';
                            html += '<a href="' + url +'/' +SsdbOrderAttach74.path + '" target="_blank">';
                            html += '<img class="lazy" src="' + thum +'/'+ SsdbOrderAttach74.path + size +  '" data-original="' + thum +'/'+ SsdbOrderAttach74.path + size +  '" height="100" width="100" id="' + SsdbOrderAttach74.id + '"/>';
                            html += '</a>';
                            html += '</div>';
                        }
                        html +='</div>';
                        if(!SsdbOrderAttach74){
                            html += '<button class="btn btn-primary btn-white checkbox-inline" type="button" onclick="uploadPic(74)">上传</button>'
                        }else{
                            html += '<button class="btn btn-primary btn-white checkbox-inline" type="button" onclick="downExamineData(74)">下载</button>'
                        }
                        html += '</div></div> '
                            +'<div class="row ma">'
                            +'<label class="col-sm-2 control-label">未盖章保函模板</label>'
                            +'<div class="col-sm-9 text-left">'
                            +'<div id="div70" class="checkbox-inline">';
                        if(SsdbOrderAttach70){
                            html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach70.id + '">';
                            html += '<a href="' + url + '/' +SsdbOrderAttach70.path + '" target="_blank">';
                            html += '<img class="lazy" src="' + thum + '/'+SsdbOrderAttach70.path + size + '" data-original="' + thum + '/'+SsdbOrderAttach70.path + size + '" height="100" width="100" id="' + SsdbOrderAttach70.id + '"/>';
                            html += '</a>';
                            html += '</div>';
                        }
                        html +='</div>';
                        if(!SsdbOrderAttach70){
                            html += '<button class="btn btn-primary btn-white checkbox-inline" type="button" onclick="uploadPic(70)">上传</button>';
                        }else{
                            html += '<button class="btn btn-primary btn-white checkbox-inline" type="button" onclick="downExamineData(70)">下载</button>';
                        }
                        html+='</div> '
                            + '</div></div>';
                        html +='<div class="row ma">' +
                            '<label class="col-sm-5 control-label"><p style="color: red">请提醒律师，投保单、付款凭证的要求：\n' +
                            '投保单：\n' +
                            '<br/>1、原告为个人，可由律师代签，但签名必须是原告的名字；\n<br/>' +
                            '2、原告为公司，投保单必须要盖公章，同时加盖骑缝章；\n<br/>' +
                            '3、投保单需要回寄给保险公司，并提交快递单号\n<br/>' +
                            '\n' +
                            '付款：1、付款由原告付款，不能代付。</p></label>'+
                            '</div>'
                        html += '<div class="hr-line-dashed ma"></div>';
                    }
                });
                html += '<div class="row ma">'
                    + '<div class="col-md-12">投保单回寄信息</div>'
                    + '</div>';
                html += '<div class="row">'
                html += ' <label class="col-sm-4">收件人：<input type="text" id="recipient" value="'+formatString(order.recipient)+'"> </label>';
                html += ' <label class="col-sm-8">收件人电话：<input type="text" id="recipientPhone" value="'+formatString(order.recipientPhone)+'"> </label>';
                html += '</div>';
                html += '<div class="row">'
                html += ' <label class="col-sm-12">收件地址：<input type="text" id="recipientAddess" value="'+formatString(order.recipientAddess)+'"> </label>';
                html += '</div>';

                html +='<div  class="modal-footer no-margin-top col-sm-12">' +
                    '<div class="text-center col-sm-12">' +
                    '<button onclick="savePostBack()" type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '保存' +
                    '</button>' +
                    '</div>' +
                    '</div>'
                html += '<div class="hr-line-dashed ma"></div>';

                html += '<div class="row ma">'
                    +'<label class="col-sm-12 control-label">律师上传的投保单</label>'
                    +'<div class="col-sm-12 text-left">'
                    +'<div id="div70" class="checkbox-inline">';
                if(SsdbOrderAttach52){
                    html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach52.id + '">';
                    html += '<a href="' + url + '/' +SsdbOrderAttach52.path + '" target="_blank">';
                    html += '<img class="lazy" src="' + thum + '/'+SsdbOrderAttach52.path + size + '" data-original="' + thum + '/'+SsdbOrderAttach52.path + size + '" height="100" width="100" id="' + SsdbOrderAttach52.id + '"/>';
                    html += '</a>';
                    html += '</div>';
                }
                html += '</div>'
                    +'</div>'
                    +'</div>';


                html += '<div class="row ma">'
                    +'<label class="col-sm-12 control-label">律师回寄投保单的快递单照片：</label>'
                    +'<div class="col-sm-12 text-left">'
                    +'<div id="div70" class="checkbox-inline">';
                if(SsdbOrderAttach78){
                    html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach78.id + '">';
                    html += '<a href="' + url + '/' +SsdbOrderAttach78.path + '" target="_blank">';
                    html += '<img class="lazy" src="' + thum + '/'+SsdbOrderAttach78.path + size +  '" data-original="' + thum + '/'+SsdbOrderAttach78.path + size +  '" height="100" width="100" id="' + SsdbOrderAttach78.id + '"/>';
                    html += '</a>';
                    html += '</div>';
                }
                html += '</div>'
                    +'</div>'
                    +'</div>';


                html += '<div class="row ma">'
                    +'<label class="col-sm-12 control-label">律师上传的付款凭证</label>'
                    +'<div class="col-sm-12 text-left">'
                    +'<div id="div70" class="checkbox-inline">';
                if(SsdbOrderAttach41){
                    html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach41.id + '">';
                    html += '<a href="' + url + '/' +SsdbOrderAttach41.path + '" target="_blank">';
                    html += '<img class="lazy" src="' + thum + '/'+SsdbOrderAttach41.path + size + '" data-original="' + thum + '/'+SsdbOrderAttach41.path + size + '" height="100" width="100" id="' + SsdbOrderAttach41.id + '"/>';
                    html += '</a>';
                    html += '</div>';
                }
                html += '</div>'
                    +'</div>'
                    +'</div>';
                html += '<div class="hr-line-dashed"></div>';

                //发票信息
                html += '<div class="row ma">'
                    + '<div class="col-md-12 ma">律师付款的备注：'+formatString(order.failReason)+'</div></div>';
                html += '<div class="hr-line-dashed"></div>';
                html += '<div class="row ma">'
                    + '<div class="col-md-12">开票信息</div>'
                    + '</div>';
                var invoType;
                $.ajax({
                    dataType : "json",
                    url : "${contextPath}/ssdb/new/getOrderInvoiceByOrderId",
                    type : "post",
                    data : {
                        'orderId' : orderId
                    },
                    async: false,
                    success: function (orderFPBean) {
                        invoType = formatString(orderFPBean.invoType);
                        html +='<div class="row ma"><div class="col-md-12 ma">发票类型：<select id="invoType"><option value="">请选择</option><option value="0">普通发票</option><option value="1">增值税发票</option></select></div></div>';
                        html +='<div class="row ma"><div class="col-md-12 ma">发票抬头：<input type="text" id="name" value="'+formatString(orderFPBean.name)+'"></div></div>';
                        html +='<div class="row ma"><div class="col-md-12 ma">纳税人识别号：<input type="text" id="taxNum" value=" '+formatString(orderFPBean.taxNum)+'"></div></div>';
                        html += '<div class="hr-line-dashed"></div>';
                    }
                });
                html +='<div  class="modal-footer no-margin-top col-sm-12">' +
                    '<div class="text-center col-sm-12">' +
                    '<button onclick="saveInvoice()" type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '保存' +
                    '</button>' +
                    '</div>' +
                    '</div>';


                //出函信息
                html +='<label class="col-sm-12" style="\n' +
                    '    height: 30px;\n' +
                    '    margin-right: 700px;\n' +
                    '    line-height: 30px;\n' +
                    '    font-size: 14px;\n' +
                    '    font-weight: bold;\n' +
                    '    background-color: #6fb3e0;\n' +
                    '">出函</label>';
                html += '<div class="row">'
                    + '<div class="col-md-5 ma"><strong>付款时间：'+formatString(order.payedDate) +'</strong></div>'
                    + '<div class="col-md-12 ma"><strong style="color: red">承诺出函时间：'+formatString(order.lsDate)+'</strong></div>'
                    + '</div>'
                    + '<div class="row">'
                    + '<div class="col-md-5 ma"><strong>实际出函时间：'+ formatString(order.sendDate)+'</strong></div>'
                    + '<div class="col-md-12 ma"><strong>出函时效：'+ getHour(order.lsDate,order.sendDate) +'</strong></div>'
                    + '</div>'
                    + '<div class="hr-line-dashed"></div>';

                //出函图片
                html += '<div class="row ma">'
                    +'<label class="col-sm-12 control-label">盖章保函图片</label>'
                    +'<div class="col-sm-12 text-left">'
                    +'<div id="div71" class="checkbox-inline">';
                if(SsdbOrderAttach71){
                    html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach71.id + '">';
                    html += '<a href="' + url + '/' +SsdbOrderAttach71.path + '" target="_blank">';
                    html += '<img class="lazy" src="' + thum + '/'+SsdbOrderAttach71.path + size + '" data-original="' + thum + '/'+SsdbOrderAttach71.path + size + '" height="100" width="100" id="' + SsdbOrderAttach71.id + '"/>';
                    html += '</a>';
                    html += '</div>';
                }
                html += '</div>';
                // if(!SsdbOrderAttach71){
                //     html += '<button class="btn btn-primary btn-white checkbox-inline" type="button" onclick="uploadPic(71)">上传</button>'
                // }
                html += '</div>'
                    +'</div>';

                html += '<div class="row ma">'
                    +'<label class="col-sm-12 control-label">盖章保单图片</label>'
                    +'<div class="col-sm-12 text-left">'
                    +'<div id="div72" class="checkbox-inline">';
                if(SsdbOrderAttach72){
                    html += '<div style="text-align:center;display:inline-block;vertical-align:top;" id="picDiv' + SsdbOrderAttach72.id + '">';
                    html += '<a href="' + url + '/' +SsdbOrderAttach72.path + '" target="_blank">';
                    html += '<img class="lazy" src="' + thum + '/'+SsdbOrderAttach72.path + size +  '" data-original="' + thum + '/'+SsdbOrderAttach72.path + size +  '" height="100" width="100" id="' + SsdbOrderAttach72.id + '"/>';
                    html += '</a>';
                    html += '</div>';
                }
                html += '</div>';
                // if(!SsdbOrderAttach72){
                //     html += '<button class="btn btn-primary btn-white checkbox-inline" type="button" onclick="uploadPic(72)">上传</button>'
                // }
                html += '</div>'
                    +'</div>'
                    + '<div class="hr-line-dashed"></div>';


                //配送信息
                html +='<label class="col-sm-12" style="\n' +
                    '    height: 30px;\n' +
                    '    margin-right: 700px;\n' +
                    '    line-height: 30px;\n' +
                    '    font-size: 14px;\n' +
                    '    font-weight: bold;\n' +
                    '    background-color: #6fb3e0;\n' +
                    '">配送管理</label>';

                html += '<div class="row">'
                html += ' <label class="col-sm-4">收件人：<input type="text" id="deliveryRecipient" value="'+formatString(order.deliveryRecipient)+'"> </label>';
                html += ' <label class="col-sm-8">收件人电话：<input type="text" id="deliveryRecipientPhone" value="'+formatString(order.deliveryRecipientPhone)+'"> </label>';
                html += '</div>';
                html += '<div class="row">'
                html += ' <label class="col-sm-12">收件地址：<input type="text" id="deliveryRecipientAddress" value="'+formatString(order.deliveryRecipientAddress)+'"> </label>';
                html += '</div>';

                html +='<div  class="modal-footer no-margin-top col-sm-12">' +
                    '<div class="text-center col-sm-12">' +
                    '<button onclick="updateDelivery()" type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '保存' +
                    '</button>' +
                    '<button onclick="showDelivery()" id="markButton" type="button" class="btn btn-sm btn-primary">' +
                    '<i class="ace-icon fa fa-floppy-o bigger-160"></i>' +
                    '添加配送信息' +
                    '</button>'+
                '</div>' +
                    '</div>'
                html += '<div class="hr-line-dashed ma"></div>';

                var mark;
                $.ajax({
                    dataType : "json",
                    url : "${contextPath}/ssdb/new/getSsdbOrderWlByOrderId",
                    type : "post",
                    data : {
                        'orderId' : orderId
                    },
                    async: false,
                    success: function (data) {
                        if(data.sendType != null){
                            mark = true;
                        }
                        var sendType;
                        if(data.sendType != null && data.sendType == 0){
                            sendType ='上门配送';
                        }else if(data.sendType != null && data.sendType == 1){
                            sendType = '顺丰';
                        }
                        html += '<div class="row">'
                            + '<div class="col-md-6 ma"><strong>配送方式：'+formatString(sendType) +'</strong></div>'
                            + '<div class="col-md-12 ma"><strong>单号：'+formatString(data.logisticsNo)+'</strong></div>'
                            + '</div>'
                            + '<div class="row">'
                            + '<div class="col-md-12 ma"><strong>配送时间：'+ formatString(data.logisticsDate) +'</strong></div>'
                            + '</div>'
                            + '<div class="hr-line-dashed"></div>';
                    }
                });

                //跟单管理
                html +='<label class="col-sm-12" style="\n' +
                    '    height: 30px;\n' +
                    '    margin-right: 700px;\n' +
                    '    line-height: 30px;\n' +
                    '    font-size: 14px;\n' +
                    '    font-weight: bold;\n' +
                    '    background-color: #6fb3e0;\n' +
                    '">跟单管理</label>';
                html += '<div class="row">'
                    + '<label class="col-sm-12 ma" id="gendanRecordShow">跟单备注 '+formatString(order.gendanRecord)+'</label>'
                    +'<div class="row">'
                    + '<div class="col-sm-12 form-group ">'
                    + 	'<textarea style="margin-left: 15px" cols="70" rows="5" id="gendanRecord" placeholder="输入跟单备注信息"></textarea>'
                    + '</div>'
                    +'</div>'
                    + '<div class="col-sm-2 text-center no-padding">';
                html += '<button class="btn btn-primary" type="button" onClick="saveCompanyFeedback()" >保存</button>';
                html +=  '</div>'
                    + '</div>'
                + '<div class="hr-line-dashed"></div>';


                //操作记录
                html += '<div class="hr-line-dashed"></div>';
                html += '<div class="row ma">'
                    + '<div class="col-md-12" style="padding-top: 15px">操作记录</div>'
                    + '</div>';

                html += '<span id="record">';
                if(order.record){
                    var recordList =order.record.split('|');
                    for(var j = 0;j<recordList.length-1;j++){
                        html += '<div class="row"><label class="col-sm-12">'+recordList[j]+'</label></div>'
                    }
                }
                html += '</span>';

                $("#modal-table-body").html(html);
                $(".ma").css("margin-bottom","30px");
                $.ajax({
                    dataType : "json",
                    url : "${contextPath}/sys/ssdbOrder/extractAdsFieldList",
                    type : "post",
                    async: false,
                    success: function (data) {
                        if(data && data.length > 0){
                            var html ="";
                            for(var i = 0 ;i < data.length; i ++) {
                                html += '<option value="'+data[i].dataKey+'">'+data[i].dataVal+'</option>';
                            }
                            $("#bdCode").html(html);
                        }
                    }
                });

                if(mark){
                    $("#markButton").hide();
                }

                $("#orderState").find('option').each(function(){
                    if($(this).val() == order.orderStateValue){
                        $(this).attr("selected", "selected");
                    }
                });
                $("#isRepeat").find('option').each(function(){
                    if($(this).val() == order.isRepeat){
                        $(this).attr("selected", "selected");
                    }
                });

                $("#invoType").find('option').each(function(){
                    if($(this).val() == invoType){
                        $(this).attr("selected", "selected");
                    }
                })
                $("#validState").find('option').each(function(){
                    if($(this).val() == order.validState){
                        $(this).attr("selected", "selected");
                    }
                });
                $("#isBusy").find('option').each(function(){
                    if($(this).val() ==  order.isBusy){
                        $(this).attr("selected", "selected");
                    }
                });
                $("#bdCode").find('option').each(function(){
                    if($(this).val() ==  order.dictCode){
                        $(this).attr("selected", "selected");
                    }
                });


            }
        });
    }
    getSsdbOrder();

    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 ];



    $('.page-content-area').ace_ajax('loadScripts', scripts, function() {

        jQuery(function ($) {

        });

    });



    //添加操作记录
    function saveRecord(record){
        $.ajax({
            type : "POST",
            url : "${contextPath}/ssdb/new/saveRecord",
            data : {
                'record' : record,
                'orderId':orderId
            },
            dataType : "json",
            success : function(data) {
                $("#record").append('<div class="row"><label class="col-sm-5" >'+record+'</label></div>');
            },
            error : function(data) {
                errorCallback(data);
            }
        });
    }

    //保存公司回复律师信息
    function saveCompanyFeedback(){
        var gendanRecord = $('#gendanRecord').val();
        if(!gendanRecord){
            alert('跟单备注信息不能为空');
        }else{
            $.ajax({
                dataType : "json",
                url : "${contextPath}/ssdb/new/updateGendanRecord",
                type : "post",
                data : {
                    'orderId' : orderId,
                    'gendanRecord' : gendanRecord
                },
                complete : function(ret) {
                    // $('#mod-addorder-submit').removeAttr('disabled')
                    var ret = eval("(" + ret.responseText + ")");
                    if(ret.success){
                        saveRecord(getDate()+" 添加了跟单管理信息");
                        alert("操作成功");
                        location.reload();
                    }else{
                        alert(ret.message);
                    }
                }
            });

            var url = '${contextPath}/order/updateGendanRecord';
            var parameters = {"gendanRecord":gendanRecord,"orderId":currentOrderId};
            postData(url, parameters, saveCompanyFeedbackCallback2, errorCallbackDefault);
        }
    }

    //下载审核资料
    function downExamineData(type) {
        window.open('${contextPath}/ssdb/new/downloadOrderAttachsByType?id=' + orderId + '&key='+type+'');
        if(type == 70){
            saveRecord(getDate()+" 下载了未盖章保函模板")
        }else if(type == 74){
            saveRecord(getDate()+" 下载了未签名的投保单");
        }

    }

    //添加配送信息
    function saveOrderwl(){
        var wl_order = $("#wl_order").val();
        var sendType = $("#sendType").val();
        if(sendType == null || sendType == "" || sendType == 1 && !wl_order){
            alert("请完善信息");
            return;
        }
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ssdb/new/saveOrderwl",
            type : "post",
            data : {
                'orderId' : orderId,
                'wl_order' : wl_order,
                'sendType' : sendType
            },
            complete : function(ret) {
                // $('#mod-addorder-submit').removeAttr('disabled')
                var ret = eval("(" + ret.responseText + ")");
                if(ret.success){
                    saveRecord(getDate()+" 添加了配送信息");
                    alert("操作成功");
                    location.reload();
                }else{
                    alert(ret.message);
                }
            }
        });

    }

    function showDelivery() {
        $("#modal-orderwl").modal("toggle");
    }

    function showLogReplys(){
        $("#modal-logReplys").modal("toggle");
    }

    //保存发票信息
    function saveInvoice(){
        var invoType = $("#invoType").val();
        var name = $("#name").val();
        var taxNum = $("#taxNum").val();
        if(!invoType || !name ||!taxNum){
            alert("请完善信息");
            return;
        }
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ssdb/new/saveInvoice",
            type : "post",
            data : {
                'orderId' : orderId,
                'invoType' : invoType,
                'name' : name,
                'taxNum' : taxNum
            },
            complete : function(ret) {
                // $('#mod-addorder-submit').removeAttr('disabled')
                var ret = eval("(" + ret.responseText + ")");
                if(ret.success){
                    saveRecord(getDate()+" 修改了开票信息");
                    alert("操作成功");
                }else{
                    alert(ret.message);
                }
            }
        });
    }

    //修改配送管理信息
    function updateDelivery(){
        var deliveryRecipient = $("#deliveryRecipient").val();
        var deliveryRecipientPhone = $("#deliveryRecipientPhone").val();
        var deliveryRecipientAddress = $("#deliveryRecipientAddress").val();
        if(!deliveryRecipient ||!deliveryRecipientPhone ||!deliveryRecipientAddress){
            alert("请完善信息");
            return;
        }
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ssdb/new/updateDelivery",
            type : "post",
            data : {
                'orderId' : orderId,
                'deliveryRecipient' : deliveryRecipient,
                'deliveryRecipientPhone' : deliveryRecipientPhone,
                'deliveryRecipientAddress' : deliveryRecipientAddress
            },
            complete : function(ret) {
                // $('#mod-addorder-submit').removeAttr('disabled')
                var ret = eval("(" + ret.responseText + ")");
                if(ret.success){
                    saveRecord(getDate()+" 修改了配送管理信息");
                    alert("操作成功");
                }else{
                    alert(ret.message);
                }
            }
        });
    }

    //保存回寄信息
    function savePostBack(){
        var recipient = $("#recipient").val();
        var recipientPhone = $("#recipientPhone").val();
        var recipientAddess = $("#recipientAddess").val();
        if(!recipient || !recipientPhone || !recipientAddess ){
            alert("请完善信息");
            return;
        }

        $.ajax({
            dataType : "json",
            url : "${contextPath}/ssdb/new/savePostBack",
            type : "post",
            data : {
                'orderId' : orderId,
                'recipient' : recipient,
                'recipientPhone' : recipientPhone,
                'recipientAddess' : recipientAddess
            },
            complete : function(ret) {
                // $('#mod-addorder-submit').removeAttr('disabled')
                var ret = eval("(" + ret.responseText + ")");
                if(ret.success){
                    saveRecord(getDate()+" 修改了投保单回寄信息");
                    alert("操作成功");
                }else{
                    alert(ret.message);
                }
            }
        });
    }

    function uploadPic(attachType){
        $("#mod-pic").modal("toggle");
        $("#mod-pic-attachType").val(attachType);
        $("#mod-pic-orderId").val(orderId);
    }

    //获取审核时效
    function getHour(lcDate,checkDate){
        if(lcDate && checkDate){
            var date1 = new Date(checkDate);

            var date2 = new Date(lcDate);
            var s1 = date1.getTime(),s2 = date2.getTime();
            var total = (s2 - s1)/1000;
            var day = parseInt(total / (24*60*60));//计算整数天数
            var afterDay = total - day*24*60*60;//取得算出天数后剩余的秒数
            var hour = parseInt(afterDay/(60*60));//计算整数小时数
            return hour+"工作时";
        }else{
            return "";
        }
    }

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


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

    function isNull(str){
        if(!str){
            return "未录入";
        }
        return str;
    }

    //基本信息保存
    function editOrder() {
        var orderState = $("#orderState").val();
        var bf = $("#bf").val();
        var commisionLawyer  = $("#commisionLawyer").val();
        var isBusy = $("#isBusy").val();
        var courtName = $("#courtName").val();
        var plaintiff = $("#plaintiff").val();
        var bdCode = $("#bdCode").val();
        var sqbd = $("#sqbd").val();
        var isRepeat  = $("#isRepeat").val();
        var validState = $("#validState").val();
        if(!orderState||!bf||!commisionLawyer||!isBusy||!courtName||!plaintiff||!bdCode||!sqbd||!isRepeat||!validState){
            alert("请完善基本信息");
            return;
        }
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ssdb/new/updateOrder",
            type : "post",
            data : {
                'orderState':orderState,
                'orderId' : orderId,
                'bf' : bf,
                'jfCommision' : commisionLawyer,
                'isBusy' : isBusy,
                'courtName' : courtName,
                'plaintiff' : plaintiff,
                'lawyerTel' : bdCode,
                'bdSum' : sqbd,
                'validState' : validState,
                'isRepeat' : isRepeat
            },
            complete : function(ret) {
                // $('#mod-addorder-submit').removeAttr('disabled')
                var ret = eval("(" + ret.responseText + ")");
                if(ret.success){
                    saveRecord(getDate()+" 修改了基本信息");
                    alert("修改成功");
                    location.reload();
                }else{
                    alert(ret.message);
                }
            }
        });

    }



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

        $('#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);

                });
            }
        });
    });


</script>