
<%@ page import="com.fadu.app.util.SystemCache" %>
<%@ 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/datepicker.css" />
<link rel="stylesheet" href="${contextPath}/static/assets/css/ui.jqgrid.css" />
<%--<link rel="stylesheet" href="${contextPath}/static/assets/css/bootstrap-datetimepicker.css" />--%>

<style>
    #MyDiv{
        display: none;
        position: absolute;
        top: 0px;
        left: 300px;
    }
    #MyDiv2{
        width: 1300px;
        display: none;
        position: absolute;
        top: 0;
        left: -30px;
    }
    #MyDiv3{
        display: none;
        position: absolute;
        top: -100px;
        left: 300px;
    }
    .demo--label { /*flex布局让子元素水平垂直居中*/
        display: flex;
        align-items: center;
        justify-content: center;
    }
    /*.demo--radio {*/
    /*    height: 20px;*/
    /*    width: 20px;*/
    /*}*/
    /*.demo--radio:checked :after {*/
    /*    background-color:#57ad68;*/
    /*    border-radius:100%;*/
    /*    content:"";*/
    /*    display:inline-block;*/
    /*    height:12px;*/
    /*    margin:2px;*/
    /*    width:12px*/
    /*}*/
    input[type=radio] {
        -webkit-appearance: none;
        appearance: none;
        outline: none;
        width: 20px;
        height: 20px;
        cursor: pointer;
        vertical-align: center;
        background: #fff;
        border: 1px solid #ccc;
        position: relative;
    }

    input[type=radio]:checked::after {
        content: "";
        display: block;
        position: absolute;
        top: 3px;
        left: 3px;
        right: 0;
        bottom: 0;
        width: 12px;
        height: 12px;
        background-color: #20e712;
    }
    input[type=radio], input[type=radio]:checked::after {
        border-radius: 50%;
    }

</style>

<div style="background: rgba(1,1,2,0.05)">
    <br>
    筛选日期：
    <input type="text" class="input-sm" placeholder="开始日期"  id="startDate"/> <input style="width: 100px" placeholder="上午8点填08" id="startHour"> 至
    <input type="text" class="input-sm" placeholder="结束日期"  id="endDate"/> <input style="width: 100px" placeholder="下午15点填15" id="endtHour">
    <select id="keywordId">
        <option value=" " selected>请选择</option>
        <option value="1">订单号</option>
        <option value="2">律师姓名</option>
        <option value="3">律师电话</option>
        <option value="4">用户姓名</option>
        <option value="5">用户电话</option>
    </select>
    关键字:<input id="keywords" placeholder="输入关键字" class="input-medium search-query" type="text" />
    省：<select id="province">
    <option selected value="" >全部</option>
    <% for(String s: SystemCache.provinceMap.keySet()){ %>
    <option value="<%=s %>" ><%=SystemCache.getProvinceName(s) %></option>
    <%} %>
</select>
    案件来源:
    <select id='orderSource'>
        <option selected value="" >所有订单</option>
        <option  value="0" >免费打官司</option>
        <option  value="1" >法律咨询</option>
    </select>
    案件状态:
   <%-- <select id='orderType'>
        <option selected value="" >所有状态</option>
        <option value="0" >未发布</option>
        <option value="1" >待投标</option>
        <option value="2" >选标中</option>
        <option value="3" >已选标</option>
        <option value="4" >已取消</option>
        <option value="5" >不打官司</option>
    </select>--%>

    <select id='orderType'>
        <option selected value="" >所有状态</option>
        <option value="0" >未发布</option>
        <option value="1" >延期联系</option>
        <option value="2" >待投标</option>
        <option value="3" >洽谈中</option>
        <option value="4" >待上传协议</option>
        <option value="5" >待审核协议</option>
        <option value="11">协议审核失败</option>
        <option value="12">待支付前期服务费</option>
        <option value="6" >待上传判决书</option>
        <option value="7" >待审核判决书</option>
        <option value="13">判决书审核失败</option>
        <option value="14">待支付后期服务费</option>
<%--        <option value="8" >待支付服务费</option>--%>
        <option value="9" >已结案</option>
        <option value="10" >已取消</option>
    </select>
    案件类型:
    <select id='caseType'>
        <option selected value="" >所有订单</option>
    </select>
    跟单客服:
    <select id='gdUser'>
        <option selected value="" >所有订单</option>
    </select>
  <%--  是否涉及财产:
    <select id='property'>
        <option selected value="" >所有订单</option>
        <option value="1" >是</option>
        <option value="0" >否</option>
    </select>--%>
    &nbsp;<button id="searchd" type="button" class="btn" >搜索</button>
    &nbsp;<button id="addLawsuit" type="button" onclick="addLawsuit()" class="btn btn-info" >添加</button>
<%--    &nbsp;<button id="serviceCount" type="button" onclick="serviceCount()" class="btn" >设置跟单人员</button>--%>
    &nbsp;<button id="serviceCount" type="button" onclick="getSelecteds()" class="btn" >设置跟单人员</button>
    &nbsp;<button id="exportExcel" type="button" onclick="exportExcel()" class="btn" >导出数据</button>
    &nbsp;<button id="exportExcel" type="button" onclick="exportOutExcel()" class="btn" >导出外呼</button>
    <br>
    <br>
</div>


<div class="row">
    <div class="col-xs-12">
        <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="MyDiv" class="modal-dialog white_content">
    <div class="modal-content">
        <div class="modal-header no-padding">
            <div class="table-header">
                <button onclick="CloseDiv()" type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <span  class="white">&times;</span>
                </button>
                查看图片
            </div>
        </div>
        <br>
        <br>
        <div id="pic">

        </div>

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

<div id="modal-refund-body" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog">
        <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;">

                <input type="text" id="edit-id" style="display: none" class="form-control"/>
                <input type="text" id="edit-orderType" style="display: none" class="form-control"/>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label">用户名:</label>
                    <div class="col-sm-8 input-group">
                        <input type="text" id="edit-name" class="form-control"/>
                    </div>
                </div>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label"><span style="color: red">*</span>性别:</label>
                    <div class="col-sm-8 input-group">
                        <select id="edit-sex">
                            <option value="2" selected>请选择</option>
                            <option value="1">女</option>
                            <option value="0">男</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="edit-phone" class="form-control"/>
                    </div>
                </div>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label">案件地区:</label>
                    <div class="col-sm-3 input-group">
                        <%--                    <input type="text" id="edit-province" placeholder="省" class="form-control"/>--%>
                        <select id="edit-province" onchange="getCity(0,0)" class="form-control">
                        </select>
                        <%--                    <input type="text" id="edit-city" placeholder="市" class="form-control"/>--%>
                        <select id="edit-city" class="form-control">
                        </select>
                    </div>
                </div>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label">案件类型:</label>
                    <div class="col-sm-3 input-group">
                        <%--                    <input type="text" id="edit-caseType" class="form-control"/>--%>
                        <select id='edit-caseType' class="form-control">
                            <option selected value="" >请选择</option>
                        </select>
                    </div>
                </div>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label">是否涉及财产:</label>
                    <div class="col-sm-8 input-group">
                        <select id="edit-property" onchange="updateTargent(1)">
                            <option value="1">是</option>
                            <option value="0">否</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="edit-targetAmount" 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="edit-referralFee" class="form-control"/>
                    </div>
                </div>--%>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label"><span style="color: red">*</span>代理方式:</label>
                    <div class="col-sm-8 input-group">
                        <select id="edit-agentType">
                            <option value="-1" selected>请选择</option>
                            <option value="0">固定收费</option>
                            <option value="1">全风险代理</option>
                            <option value="2">半风险代理</option>
                        </select>
                    </div>
                </div>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label">案件描述:</label>
                    <div class="col-sm-8 input-group">
                        <textarea style="height:100px"  class="form-control limited autosize-transition" id="edit-txt" maxlength="1000"></textarea>
                    </div>
                </div>
                <div class="form-group"  >
                    <label class="col-sm-3 control-label">案件来源:</label>
                    <div class="col-sm-8 input-group">
                        <select id="edit-orderSource" >
                            <option value="0" selected = selected>免费打官司</option>
                            <option value="1">法律咨询</option>
                        </select>
                    </div>
                </div>
                <div class="form-group"  id="remark" >

                </div>
            </div>
            <div class="modal-footer no-margin-top">
                <div class="text-center">
                    <div class="modal-footer no-margin-top">
                        <div class="text-center" id="edit-button">

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

<%--<div  id="MyDiv1" class="modal-dialog white_content">
    <div class="modal-content">
        <div class="modal-header no-padding">
            <div class="table-header">
                <button onclick="CloseDiv1()" type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <span  class="white">&times;</span>
                </button>
                案件详情
            </div>
        </div>
        <br>
        <div class="modal-body">
            <input type="text" id="edit-id" style="display: none" class="form-control"/>
            <input type="text" id="edit-orderType" style="display: none" class="form-control"/>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">用户名:</label>
                <div class="col-sm-8 input-group">
                    <input type="text" id="edit-name" class="form-control"/>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label"><span style="color: red">*</span>性别:</label>
                <div class="col-sm-8 input-group">
                    <select id="edit-sex">
                        <option value="2" selected>请选择</option>
                        <option value="1">女</option>
                        <option value="0">男</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="edit-phone" class="form-control"/>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件地区:</label>
                <div class="col-sm-3 input-group">
                    &lt;%&ndash;                    <input type="text" id="edit-province" placeholder="省" class="form-control"/>&ndash;%&gt;
                    <select id="edit-province" onchange="getCity(0,0)" class="form-control">
                    </select>
                    &lt;%&ndash;                    <input type="text" id="edit-city" placeholder="市" class="form-control"/>&ndash;%&gt;
                    <select id="edit-city" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件类型:</label>
                <div class="col-sm-3 input-group">
                    &lt;%&ndash;                    <input type="text" id="edit-caseType" class="form-control"/>&ndash;%&gt;
                    <select id='edit-caseType' class="form-control">
                        <option selected value="" >请选择</option>
                    </select>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">是否涉及财产:</label>
                <div class="col-sm-8 input-group">
                    <select id="edit-property" onchange="updateTargent(1)">
                        <option value="1">是</option>
                        <option value="0">否</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="edit-targetAmount" 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="edit-referralFee" class="form-control"/>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label"><span style="color: red">*</span>代理方式:</label>
                <div class="col-sm-8 input-group">
                    <select id="edit-agentType">
                        <option value="-1" selected>请选择</option>
                        <option value="0">固定收费</option>
                        <option value="1">全风险代理</option>
                        <option value="2">半风险代理</option>
                    </select>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件描述:</label>
                <div class="col-sm-8 input-group">
                    <textarea style="height:100px"  class="form-control limited autosize-transition" id="edit-txt" maxlength="1000"></textarea>
                </div>
            </div>
            <div class="form-group"  id="remark" >

            </div>
            <div class="modal-footer no-margin-top">
                <div class="text-center" id="edit-button">

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

<div  id="MyDiv2" class="modal-dialog white_content">
    <div class="modal-content">
        <div class="modal-header no-padding">
            <div class="table-header">
                <button onclick="CloseDiv2()" type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <span  class="white">&times;</span>
                </button>
                查看投标
            </div>
        </div>
        <br>
        <div class="modal-body">
            <input type="text" id="bidd-id" style="display: none" class="form-control"/>
            <p id="count_5"></p>
            <table id="bidd-lawyers"  style="font-size: 14px; background-color: rgba(0,0,0,0.14)">

            </table>
            <div>&nbsp;</div>
            <div>&nbsp;</div>
            <%--<div class="modal-footer ">--%>
            <div class="text-center" id="bidd-button">

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



<div  id="MyDiv3" class="modal-dialog white_content">
    <div class="modal-content">
        <div class="modal-header no-padding">
            <div class="table-header">
                <button onclick="CloseDiv3()" type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <span  class="white">&times;</span>
                </button>
                添加案件
            </div>
        </div>
        <br>
        <div class="modal-body">
            <input type="text" id="add-id" style="display: none" class="form-control"/>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">用户名:</label>
                <div class="col-sm-8 input-group">
                    <input type="text" id="add-name" class="form-control"/>
                </div>
            </div>
            <%--<div class="form-group"  >
                <label class="col-sm-3 control-label"><span style="color: red">*</span>性别:</label>
                <div class="col-sm-8 input-group">
                    <select id="add-sex">
                        <option value="2" selected>请选择</option>
                        <option value="1">女</option>
                        <option value="0">男</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="add-phone" class="form-control"/>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件地区:</label>
                <div class="col-sm-3 input-group">
                    <%--                    <input type="text" id="edit-province" placeholder="省" class="form-control"/>--%>
                    <select id="add-province" onchange="getCity(2,0)" class="form-control">
                    </select>
                    <%--                    <input type="text" id="edit-city" placeholder="市" class="form-control"/>--%>
                    <select id="add-city" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">起诉地区:</label>
                <div class="col-sm-3 input-group">
                    <%--                    <input type="text" id="edit-province" placeholder="省" class="form-control"/>--%>
                    <select id="add-qsProvince" onchange="getCity(5,0)" class="form-control">
                    </select>
                    <%--                    <input type="text" id="edit-city" placeholder="市" class="form-control"/>--%>
                    <select id="add-qsCity" class="form-control">
                    </select>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件类型:</label>
                <div class="col-sm-3 input-group">
                    <%--                    <input type="text" id="edit-caseType" class="form-control"/>--%>
                    <select id='add-caseType' class="form-control">
                        <option selected value="" >请选择</option>
                    </select>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">是否涉及财产:</label>
                <div class="col-sm-8 input-group">
                    <select id="add-property" onchange="updateTargent(2)">
                        <option value="">请选择</option>
                        <option value="1">是</option>
                        <option value="0">否</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="add-targetAmount" 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="add-referralFee" class="form-control"/>
                </div>
            </div>--%>
            <%--<div class="form-group"  >
                <label class="col-sm-3 control-label"><span style="color: red">*</span>代理方式:</label>
                <div class="col-sm-8 input-group">
                    <select id="add-agentType">
                        <option value="-1" selected>请选择</option>
                        <option value="0">固定收费</option>
                        <option value="1">全风险代理</option>
                    </select>
                </div>
            </div>--%>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件描述:</label>
                <div class="col-sm-8 input-group">
                    <textarea style="height:100px"  class="form-control limited autosize-transition" id="add-txt" maxlength="1000"></textarea>
                </div>
            </div>
            <div class="form-group"  >
                <label class="col-sm-3 control-label">案件来源:</label>
                <div class="col-sm-8 input-group">
                    <select id="add-orderSource" >
                        <option value=0 selected = selected>免费打官司</option>
                        <option value=1>法律咨询</option>

                    </select>
                </div>
            </div>
            <div class="modal-footer no-margin-top">
                <div class="text-center" id="add-button">
                    <button onclick="addedLawsuit()" class="btn btn-sm btn-info">
                        确认
                    </button>
                    <button onclick="CloseDiv3()" class="btn btn-sm">
                        取消
                    </button>
                </div>
            </div>
        </div>
    </div><!-- /.modal-dialog -->
</div>

<div id="modal-remark-body" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog">
        <form id="checkForm">
            <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-edit-tip" class="red clearfix"></div>
                    <input type="hidden" id="modal-refund-orderid" value="">
                    <div class="form-group" style="margin-left: 30px;">
                        <label class="control-label">请输入备注：</label>
                    </div>
                    <div class="form-group" style="margin-left: 30px;">
						<textarea id="modal-refund-reason" rows="4" cols="60"
                                  placeholder="请输入备注"></textarea>
                    </div>
                </div>
                <div class="modal-footer no-margin-top">
                    <div class="text-center">
                        <button id="mod-check-success" type="button" class="btn btn-sm btn-primary"
                                onclick="breakLawsuit();">
                            确定
                        </button>
                        <button class="btn btn-sm" data-dismiss="modal">
                            取消
                        </button>
                    </div>
                </div>
            </div><!-- /.modal-content -->
        </form>
    </div><!-- /.modal-dialog -->
</div>

<div id="modal-time-body" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog">
            <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-time-tip" class="red clearfix"></div>
                    <input type="hidden" id="modal-time-lawsuitId" value="">
                    <div class="form-group" style="margin-left: 30px;" id="modal-time-lawTime">
                    </div>
                    <div class="form-group" style="margin-left: 30px;">
                        <input type="text" class="input-sm" placeholder="点击选择" id="lawTime"/>
                        <button class="btn btn-sm " onclick="addTime()" >
                            确认添加
                        </button>
                    </div>
                </div>
                <div class="modal-footer no-margin-top">
                    <div class="text-center">
                        <button class="btn btn-sm" data-dismiss="modal">
                            取消
                        </button>
                    </div>
                </div>
            </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

<div id="modal-service-body" class="modal fade" tabindex="-1" data-backdrop="static">
    <div class="modal-dialog">
        <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" style="margin-left: 30px;">
                    <p>当前条件共筛选出：<span id="count"></span>条</p>
                </div>
                <div class="form-group" style="margin-left: 30px;">
                    <label class="control-label">分配给当事人跟单人员：</label>
                    <select id="userSer"></select>
                </div>
             <%--   <div class="form-group" style="margin-left: 30px;">
                    <input  type="text" class="input-sm" value="0" id="userStart">&nbsp;&nbsp;至&nbsp;&nbsp;<input  type="text" class="input-sm" value="0" id="userEnd">条
                </div>--%>

                <div class="form-group" style="margin-left: 30px;">
                    <label class="control-label">分配给律师跟单人员：</label>
                    <select id="lawyerSer"></select>
                </div>
             <%--   <div class="form-group" style="margin-left: 30px;">
                    <input  type="text" class="input-sm" value="0" id="lawyerStart">&nbsp;&nbsp;至&nbsp;&nbsp;<input  type="text" value="0" class="input-sm" id="lawyerEnd">条
                </div>--%>

            </div>
            <div class="modal-footer no-margin-top">
                <div class="text-center">
                    <button id="mod-shenHe-success" type="button" class="btn btn-sm btn-primary"
                            onclick="toSet();">
                        确定
                    </button>
                    <button class="btn btn-sm" data-dismiss="modal">
                        取消
                    </button>
                </div>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div>

<%--<script src="${contextPath}/static/js/laydate/laydate.js"></script> <!-- 改成你的路径 -->--%>
<%--<script>
    // lay('#version').html('-v'+ laydate.v);
    //执行一个laydate实例
    laydate.render({
        elem: '#startDate'
        ,type: 'datetime'
    });
</script>--%>



<script type="text/javascript" >

    var myGrid = null;
    var scripts = [ null,
        "${contextPath}/static/assets/js/date-time/bootstrap-datepicker.js",
        "${contextPath}/static/assets/js/date-time/bootstrap-datetimepicker.js",
        "${contextPath}/static/assets/js/date-time/locales/bootstrap-datepicker.zh-CN.js",
        <%--"${contextPath}/static/assets/js/date-time/locales/bootstrap-datetimepicker.js",--%>
        <%--"${contextPath}/static/js/laydate/laydate.js",--%>
        "${contextPath}/static/assets/js/date-time/moment.js",
        "${contextPath}/static/assets/js/jqGrid/jquery.jqGrid.js",
        "${contextPath}/static/assets/js/jqGrid/i18n/grid.locale-cn.js",
        null ]

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

            var grid_selector = "#grid-table";
            var pager_selector = "#grid-pager";

            /*搜索框  主要对Jquery grid进行刷新 带参数刷新    */
            $("#searchd").click(function(){
                var startDate = $("#startDate").val();
                var startHour = $("#startHour").val();
                var endDate = $("#endDate").val();
                var endtHour = $("#endtHour").val();
                var keywordId = $("#keywordId").val();
                var keywords = $("#keywords").val();
                if(!keywordId && keywords){
                    alert("请选择关键字选项");
                    return;
                }
                var orderType = $("#orderType").val();
                // var property = $("#property").val();
                var caseType = $("#caseType").val();
                var province = $("#province").val();
                var orderSource = $("#orderSource").val();
                var gdUser = $("#gdUser").val();
                myGrid.setGridParam({postData:{startDate:startDate ,endDate:endDate,
                        keywords:keywords,keywordId:keywordId,orderType:orderType,province:province,startHour:startHour,endtHour:endtHour,
                        caseType:caseType,orderSource:orderSource,gdUser:gdUser,page:1},
                    url : '${contextPath}/ads/vip/getAdsVipLawsuit',page:1}).trigger('reloadGrid');
            });


            $(document).keydown(function (event) {
                var key = window.event ? event.keyCode : event.which;
                if (key == 13) {
                    $("#searchd").click();
                }
            });
            /*$('#startDate').datetimepicker({
                language:  'zh-CN',
                weekStart: 1,
                todayBtn:  1,
                autoclose: 1,
                todayHighlight: 1,
                startView: 2,
                forceParse: 0,
                showSecond:1,
                minuteStep:1,

            });*/
            $('#startDate').datepicker({
                language: 'zh-CN',
                pickTime: true,
                todayBtn: true,
                autoclose: true,
                minView: '2',
                forceParse: false,
                format: "yyyy-mm-dd"
            });
            /*$("#startDate").datepicker({
                autoclose: true,   //选择后自动关闭当前时间控件
                // isRTL: Metronic.isRTL(), //RTL：right to left（从右向左显示），默认为false，即：从左向右显示
                format: "yyyy-mm-dd hh:ii:ss", //时间格式
                // pickerPosition: (Metronic.isRTL() ? "bottom-right" : "bottom-left")//控件显示位置
            });*/
           $('#endDate').datepicker({
                language: 'zh-CN',
                pickTime: false,
                todayBtn: true,
                autoclose: true,
                minView: '2',
                forceParse: false,
                format:"yyyy-mm-dd"
            });
            $('#lawTime').datepicker({
                language: 'zh-CN',
                pickTime: false,
                todayBtn: true,
                autoclose: true,
                minView: '2',
                forceParse: false,
                format: "yyyy-mm-dd"
            });

            myGrid=	jQuery(grid_selector).jqGrid({
                subGrid : false,
                url : "${contextPath}/ads/vip/getAdsVipLawsuit",
                datatype : "json",
                mtype:'POST',
                shrinkToFit:false,
                autoScroll: false,//设置http方式为post以解决乱码问题
                colNames : [/*'number',*/'订单号',/*'提交时间',*/'用户名', '联系电话','起诉地级市','案件类型','案件来源',
                    '代理方式','案件状态','是否新案件',/*'是否涉及财产','标的额'*//*,'平台介绍费'*//*'律师费','案件描述',*/
                    '当事人跟单人员','当事人到期时间','律师跟单人员','律师到期时间'/*,'案件状态'*/,'投标人数','操作'],
                colModel : [/*{
                    name : 'number',
                    index : 'number',
                    width : 50,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*/{
                    name : 'id',
                    index : 'id',
                    width : 120,
                    search : false,
                    editable : false,
                    // editoptions:{custom_element:multiCheckElem, custom_value:multiCheckVal}
                    //sorttype : 'date'
                },/*{
                    name : 'createDate',
                    index : 'createDate',
                    width : 130,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*/{
                    name : 'name',
                    index : 'name',
                    width : 90,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'phone',
                    index : 'phone',
                    width : 90,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'proAndCity',
                    index : 'proAndCity',
                    width : 100,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'caseType',
                    index : 'caseType',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'orderSource',
                    index : 'orderSource',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'agentType',
                    index : 'agentType',
                    width : 80,
                    search : false,
                    editable : false,
                    formatter : agentTypeFormatter
                    //sorttype : 'date'
                },/*{
                    name : 'property',
                    index : 'property',
                    width : 50,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*/{
                    name : 'orderType',
                    index : 'orderType',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'isNew',
                    index : 'isNew',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },/*{
                    name : 'targetAmount',
                    index : 'targetAmount',
                    width : 50,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*//*{
                    name : 'referralFee',
                    index : 'referralFee',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*//*{
                    name : 'cost',
                    index : 'cost',
                    width : 60,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*//*{
                    name : 'txt',
                    index : 'txt',
                    width : 100,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },*/{
                    name : 'xcxservice',
                    index : 'xcxservice',
                    width : 100,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'userOverdue',
                    index : 'userOverdue',
                    width : 100,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'appservice',
                    index : 'appservice',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'lawyerOverdue',
                    index : 'lawyerOverdue',
                    width : 80,
                    search : false,
                    editable : false,
                    //sorttype : 'date'
                },{
                    name : 'biddCount',
                    index : 'biddCount',
                    width : 100,
                    search : false,
                    editable : false,
                    // hidden: true,
                    //sorttype : 'date'
                },{
                    name : 'type',
                    index : 'type',
                    width : 200,
                    editable : false,
                    search : false,
                    sortable : false,
                    fixed:true,
                    formatter : optionFormatter
                }],
                sortname : "createDate",
                sortorder : "desc",
                viewrecords : true,
                multiselect: true,//复选框
                rowNum : 10,
                rowList : [ 10, 50, 100 ],
                pager : pager_selector,
                altRows : true,
                height:"auto",//自动根据每页条数弹性调整表格高度
                loadComplete : function() {
                    var table = this;
                    setTimeout(function(){
                        /*styleCheckbox(table);
                        updateActionIcons(table);*/
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                }
            });


            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 optionFormatter(cellvalue, options, cell) {
                // console.log(cell);
                // var template = "&nbsp;<button data-toggle='modal' onclick='showPic(\""+cell.id+"\")' class='btn btn-minier btn-yellow'>查看图片</button>";
                var template = "&nbsp;&nbsp; <button data-toggle='modal' onclick='showedit(\""+cell.id+"\",\""+cell.orderType+"\",\""+cell.name+"\",\""+cell.phone+"\",\""+cell.orderSource+"\")' class='btn btn-minier btn-blue'>案件详情</button>";
                // template += "&nbsp;|&nbsp; <a data-toggle='modal' href='../adsLawsuit/adsLawsuitDetails.jsp?id=\"\""+cell.id+"\"&orderType=\"\""+cell.orderType+"\"' target='_blank' class='btn btn-minier btn-blue'>案件详情</a>";
                // template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='showBidd(\""+cell.id+"\",\""+cell.orderType+"\")' class='btn btn-minier btn-info'>查看投标("+cell.biddCount+")</button>";
                /*if (cell.orderType === "未发布"){
                    template += "&nbsp;|&nbsp;<button data-toggle='modal' onclick='showLawTime(\""+cell.id+"\",\""+1+"\")' class='btn btn-minier btn-info'>面谈时间</button>";
                }*/
                return template;
            }
            function agentTypeFormatter(cellvalue, options, cell) {
                console.log(cellvalue);
                if (cellvalue === 0){
                    return "固定收费";
                }else if (cellvalue === 1){
                    return "全风险代理";
                }else if (cellvalue === 2){
                    return "半风险代理";
                }else{
                    return "未设置";
                }
            }

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


        });
    });




    function showPic(id) {
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/getPic",
            type : "post",
            data : {
                'id' : id
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                var all = "";
                for (var i = 0 ; i < ret.length;i++){
                    all += "<a style='padding: 8px;' href='"+ret[i].url+"' target='newPic'>" +
                        "<img src='"+ret[i].url+"' width='180px' height='320px'/>" +
                        "<a/>"
                }
                $("#pic").html(all);
                console.log(ret);
            }
        });
        $("#MyDiv").show();
    }

    function showedit(id,orderType,name,phone,orderSource) {
        var pageUrl;
        if (orderSource === '免费打官司'){
            pageUrl = id+"?"+orderType+"?"+name+"?"+phone;
        }else{
            pageUrl = id+"?"+orderType+"?"+" "+"?"+phone;
        }
        // console.log("WebContent/WEB-INF/page/back/adsLawsuit/adsLawsuitDetails.jsp");
        url = "home#page/adsLawsuitDetails?"+pageUrl;
        // url = "../adsLawsuit/adsLawsuitOrder.html?id="+id+"&orderType="+orderType;
        window.open(url, "_blank");
    }

    function showedit1(id,orderType,property) {
        // getProvince(1);
        $("#edit-name").val("");
        $("#edit-phone").val("");
        $("#edit-province").val("");
        // $("#edit-referralFee").val("");
        $("#edit-city").val("");
        $("#edit-caseType").val("");
        $("#edit-targetAmount").val("");
        $("#edit-txt").val("");
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/getLawsuitById",
            type : "post",
            data : {
                'id' : id
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                // getProvince(1);
                $("#edit-id").val(ret.id);
                $("#edit-orderType").val(ret.orderType);
                $("#edit-name").val(ret.name);
                // $("#edit-referralFee").val(ret.referralFee);
                console.log(ret.sex);
                if (ret.sex !== "1" && ret.sex !== "0"){
                    $("#edit-sex").val("2");
                    console.log("000");
                }else{
                    $("#edit-sex").val(ret.sex);
                    console.log("111");
                }
                $("#edit-phone").val(ret.phone);
                $("#edit-province").val(ret.province);
                getCity(ret.province,ret.city);
                $("#edit-city").val(ret.city);
                $("#edit-caseType").val(ret.caseType);
                $("#edit-targetAmount").val(ret.targetAmount);
                $("#edit-property").val(ret.property);
                $("#edit-txt").val(ret.txt);
                if (ret.agentType !== null) {
                    $("#edit-agentType").val(ret.agentType);
                }else{
                    $("#edit-agentType").val("-1");
                }
                updateTargent(1);
                if (orderType === "未发布"){
                    /*$("#edit-name").attr('disabled',false);
                    $("#edit-referralFee").attr('disabled',false);
                    $("#edit-phone").attr('disabled',false);
                    $("#edit-sex").attr('disabled',false);
                    $("#edit-province").attr('disabled',false);
                    $("#edit-city").attr('disabled',false);
                    $("#edit-caseType").attr('disabled',false);
                    $("#edit-txt").attr('disabled',false);
                    $("#edit-property").attr('disabled',false);
                    $("#edit-agentType").attr('disabled',false);
                    if (property !== "不涉及"){
                        $("#edit-targetAmount").attr('disabled',false);
                    }else{
                        $("#edit-targetAmount").attr('disabled',true);
                    }*/
                    $("#edit-button").html("<button id=\"modal-remark-confirm\" type=\"button\" onclick='editOrder()' class=\"btn btn-sm btn-primary\">\n" +
                        "                        <i class=\"ace-icon fa fa-floppy-o bigger-160\"></i>\n" +
                        "                        保存\n" +
                        "                    </button>\n" +
                        "<button id=\"modal-remark-confirm\" type=\"button\" onclick='noLawsuit()' class=\"btn btn-sm btn-default\">\n" +
                        "                        <i class=\"ace-icon fa fa-floppy-o bigger-160\"></i>\n" +
                        "                        不打官司\n" +
                        "                    </button>\n" +
                        "                    <button class=\"btn btn-sm btn-info\" onclick='pulishOrder()' >\n" +
                        "                        <i class=\"ace-icon fa fa-share bigger-160\"></i>\n" +
                        "                        发布案件\n" +
                        "                    </button>");
                    $("#remark").html("")
                }else if (orderType === "不打官司"){
                    $("#edit-button").html("<button id=\"modal-remark-confirm\" type=\"button\" onclick='editOrder()' class=\"btn btn-sm btn-primary\">\n" +
                        "                        <i class=\"ace-icon fa fa-floppy-o bigger-160\"></i>\n" +
                        "                        保存\n" +
                        "                    </button>\n" +
                        "</button>\n" +
                        "<button id=\"modal-remark-confirm\" type=\"button\" onclick='colseEdit()' class=\"btn btn-sm\">\n" +
                        "                        <i class=\"ace-icon fa fa-floppy-o bigger-160\"></i>\n" +
                        "                        取消\n" +
                        "                    </button>");
                    $("#remark").html("<label class=\"col-sm-3 control-label\">不打官司备注:</label>\n" +
                        "                <div class=\"col-sm-8 input-group\">\n" +
                        "                    <textarea style=\"height:100px\"  class=\"form-control limited autosize-transition\" id=\"edit-remark\" maxlength=\"1000\"></textarea>\n" +
                        "                </div>");
                    $("#edit-remark").val(ret.remark)
                }else {
                    /*$("#edit-name").attr('disabled',true);
                    $("#edit-referralFee").attr('disabled',true);
                    $("#edit-phone").attr('disabled',true);
                    $("#edit-sex").attr('disabled',true);
                    $("#edit-province").attr('disabled',true);
                    $("#edit-city").attr('disabled',true);
                    $("#edit-caseType").attr('disabled',true);
                    $("#edit-targetAmount").attr('disabled',true);
                    $("#edit-txt").attr('disabled',true);
                    $("#edit-property").attr('disabled',true);
                    $("#edit-agentType").attr('disabled',true);*/
                    $("#edit-button").html("<button id=\"modal-remark-confirm\" type=\"button\" onclick='editOrder()' class=\"btn btn-sm btn-primary\">\n" +
                        "                        <i class=\"ace-icon fa fa-floppy-o bigger-160\"></i>\n" +
                        "                        保存\n" +
                        "                    </button>\n" +
                        "<button id=\"modal-remark-confirm\" type=\"button\" onclick='quitOrder()' class=\"btn btn-sm\">\n" +
                        "                        <i class=\"ace-icon fa fa-floppy-o bigger-160\"></i>\n" +
                        "                        取消订单\n" +
                        "                    </button>");
                    $("#remark").html("");
                }
            }
        });

        $("#modal-refund-body").modal("toggle");
    }

    function quitOrder() {
        if (confirm("确认取消订单么？")){
            makeSure()
        }
    }

    function makeSure() {
        var id = $("#edit-id").val();
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/quitOrder",
            type : "post",
            data : {
                'id' : id
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                alert(ret.message);
                $("#modal-refund-body").modal("toggle");
                jQuery("#grid-table").trigger("reloadGrid");
            }
        });
    }

    function editOrder() {
        var id = $("#edit-id").val();
        var orderType = $("#edit-orderType").val();
        var name = $("#edit-name").val();
        // var referralFee = $("#edit-referralFee").val();
        var sex = $("#edit-sex").val();
        var phone = $("#edit-phone").val();
        var province = $("#edit-province").val();
        var city = $("#edit-city").val();
        var caseType = $("#edit-caseType").val();
        var targetAmount = $("#edit-targetAmount").val();
        var property = $("#edit-property").val();
        var txt = $("#edit-txt").val();
        var agentType = $("#edit-agentType").val();
        var remark = $("#edit-remark").val();
        if (orderType !== "不打官司"){
            if (sex > 1 ){
                alert("请选择性别！");
                return
            }
            if (agentType < 0){
                alert("请选择代理方式！");
                return
            }
            if (targetAmount === ""){
                alert("请输入标的额！");
                return
            }
        }
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/editLawsuitOrder",
            type : "post",
            data : {
                'id' : id,
                'name' : name,
                // 'referralFee' : referralFee,
                'sex' : sex,
                'phone' : phone,
                'province' : province,
                'city' : city,
                'caseType' : caseType,
                'targetAmount' : targetAmount,
                'property' : property,
                'txt' : txt,
                'remark' : remark,
                'agentType' : agentType
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                if (ret.succ === "true"){
                    alert(ret.message);
                    $("#modal-refund-body").modal("toggle");
                    jQuery("#grid-table").trigger("reloadGrid");
                }else{
                    alert(ret.message);
                }
            }
        });
    }

    function CloseDiv() {
        $("#MyDiv").hide();
    }
    // function CloseDiv1() {
    //     $("#modal-refund-body").modal("toggle");
    // }
    function CloseDiv2() {
        $("#MyDiv2").hide();
    }
    function CloseDiv3() {
        $("#add-targetAmount").val(0);
        $("#MyDiv3").hide();
    }

    function pulishOrder() {
        var id = $("#edit-id").val();
        var name = $("#edit-name").val();
        // var referralFee = $("#edit-referralFee").val();
        var sex = $("#edit-sex").val();
        var phone = $("#edit-phone").val();
        var province = $("#edit-province").val();
        var city = $("#edit-city").val();
        var caseType = $("#edit-caseType").val();
        var targetAmount = $("#edit-targetAmount").val();
        var property = $("#edit-property").val();
        var txt = $("#edit-txt").val();
        var agentType = $("#edit-agentType").val();
        if (sex > 1 ){
            alert("请选择性别！");
            return
        }
        if (agentType < 0){
            alert("请选择代理方式！");
            return
        }
        /*if (editOrder()){*/
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/publishOrder",
            type : "post",
            data : {
                'id' : id,
                'name' : name,
                // 'referralFee' : referralFee,
                'sex' : sex,
                'phone' : phone,
                'province' : province,
                'city' : city,
                'caseType' : caseType,
                'targetAmount' : targetAmount,
                'property' : property,
                'txt' : txt,
                'agentType' : agentType
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                if (ret.succ === "true"){
                    alert(ret.message);
                    $("#modal-refund-body").modal("toggle");
                    jQuery("#grid-table").trigger("reloadGrid");
                }else{
                    alert(ret.message);
                }
            }
        });
        /*  }else{
              alert("保存失败！")
          }*/

    }

    function colseEdit() {
        $("#modal-refund-body").modal("toggle");
    }

    function countLawyer(id) {
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/countBidd",
            type : "post",
            data : {
                'id' : id,
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                $("#count_5").html("投标结束，投标人数满 "+ret.count+" 人共用 " + ret.countTime + " 分钟");
            }
        });
    }

    function showBidd(id,orderType) {
        if (orderType === "选标中"){
            countLawyer(id)
        }else{
            $("#count_5").html("");
        }
        $("#bidd-lawyers").html("");
        var ccc = "";
        // var sec = document.getElementById('bidd-lawyers');
        var sss = "";
        sss = "<tr>\n" +
            "                    <td class=\"col-lg-1\">律师姓名</td>\n" +
            "                    <td class=\"col-lg-1\">律师电话</td>\n" +
            "                    <td class=\"col-lg-1\">律师地区</td>\n" +
            "                    <td class=\"col-lg-1\">面谈时间</td>\n" +
            "                    <td class=\"col-lg-1\">投标状态</td>\n" +
            "                    <td class=\"col-lg-3\">投标优势</td>\n" +
            "                    <td class=\"col-lg-2\">投标时间</td>\n" +
            "                    <td class=\"col-lg-1\">放弃原因</td>\n" +
            "                    <td class=\"col-lg-1\">勾选</td>\n" +
            "                </tr>" ;
        /*            "                 <tr>\n" +
                    "                    <td>&nbsp;</td>\n" +
                    "                </tr>\n";*/
        $.getJSON("${contextPath}/ads/vip/showBidd?id="+id,function(result){
            $.each(result, function(i, v){
                console.log(i);
                console.log(v);
                if ((i + 3) % 2 === 1){
                    sss += "<tr style='background-color:rgb(243,243,243)'>" ;
                            if( v.isRed === "1"){
                                sss += "<td class=\"col-sm-1\" >"+v.lawyerName+"<span style='color: red'>（红）</span></td>\n" ;
                            }else{
                                sss += "<td class=\"col-sm-1\" >"+v.lawyerName+"</td>\n" ;
                            }
                    sss += "                    <td class=\"col-lg-1\">"+v.phone+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.proAndCity+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.time+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.progress+"</td>\n" +
                        "                    <td class=\"col-lg-3\">"+v.odds+"</td>\n" +
                        "                    <td class=\"col-lg-2\">"+v.createDate+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.giveUp+"</td>\n" +
                        "                    <td class=\"col-lg-1\">";
                    if (v.isBidd === "a"){
                        if (orderType === "已选标"){
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio'  name='biddLawyer' disabled checked = 'checked' value='"+v.id+"'/>" +
                                " </label>"
                        }else{
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio'  name='biddLawyer'  checked = 'checked' value='"+v.id+"'/>" +
                                " </label>"
                        }
                    } else{
                        if (orderType === "已选标"){
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio' name='biddLawyer' disabled value='"+v.id+"'/>" +
                                " </label>"
                        }else{
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio' name='biddLawyer'  value='"+v.id+"'/>" +
                                " </label>"
                        }
                    }
                    sss += "</td>\n" +
                        "                </tr>";
                } else{
                    sss += "<tr style='background-color:rgb(255,255,255)'>" ;
                    if(  v.isRed === "1"){
                        sss += "<td class=\"col-sm-1\" >"+v.lawyerName+"<span style='color: red'>（红）</span></td>\n" ;
                    }else{
                        sss += "<td class=\"col-sm-1\" >"+v.lawyerName+"</td>\n" ;
                    }
                    sss += "                    <td class=\"col-lg-1\">"+v.phone+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.proAndCity+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.time+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.progress+"</td>\n" +
                        "                    <td class=\"col-lg-3\">"+v.odds+"</td>\n" +
                        "                    <td class=\"col-lg-2\">"+v.createDate+"</td>\n" +
                        "                    <td class=\"col-lg-1\">"+v.giveUp+"</td>\n" +
                        "                    <td class=\"col-lg-1\">";
                    if (v.isBidd === "a"){
                        if (orderType === "已选标"){
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio'  name='biddLawyer' disabled checked = 'checked' value='"+v.id+"'/>" +
                                " </label>"
                        }else{
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio'  name='biddLawyer'  checked = 'checked' value='"+v.id+"'/>" +
                                " </label>"
                        }
                    } else{
                        if (orderType === "已选标"){
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio' name='biddLawyer' disabled value='"+v.id+"'/>" +
                                " </label>"
                        }else{
                            sss += "<label class='demo--label''>" +
                                " <input type='radio' class='demo--radio' name='biddLawyer'  value='"+v.id+"'/>" +
                                " </label>"
                        }
                    }
                    sss += "</td>\n" +
                        "                </tr>";
                }
            });
            $("#bidd-id").val(id);
            $("#bidd-lawyers").html(sss);
        });
        if (orderType === "已选标"){
            console.log(orderType);
            $("input[name='biddLawyer']").attr("disabled",true);
            $("input[name='biddLawyer']").attr("disabled","disabled");
            // $(':radio').attr('disabled', true);
            // $("#demo--radio").attr('disabled');
            // document.getElementsByClassName("demo--radio")
            ccc = " <button class=\"btn btn-sm btn-grey\" onclick='CloseDiv2()' data-dismiss=\"modal\">\n" +
                "           取消\n" +
                "      </button>";
        }else{
            console.log(orderType);
            /*ccc = "<button class=\"btn btn-sm btn-info\" onclick='makepartner()' data-dismiss=\"modal\">\n" +
                "                        确定合作\n" +
                "                    </button>\n" +*/
            ccc = "                    <button class=\"btn btn-sm btn-grey\" onclick='CloseDiv2()' data-dismiss=\"modal\">\n" +
                "                        取消\n" +
                "                    </button>";
        }
        $("#bidd-button").html(ccc);
        $("#MyDiv2").show();
    }

    /*function makepartner() {
        var id = $("input[name='biddLawyer']:checked").val();
        var adsLawsuitId = $("#bidd-id").val();
        console.log(id);
        console.log(adsLawsuitId);
        $.ajax({
            dataType : "json",
            <%--url : "${contextPath}/ads/vip/makepartner",--%>
            type : "post",
            data : {
                'id' : id,
                'adsLawsuitId': adsLawsuitId
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                alert(ret.message);
                $("#MyDiv2").hide();
                jQuery("#grid-table").trigger("reloadGrid");
            }
        });
    }*/

    function getCaseType(type) {
        var sec = document.getElementById('caseType');
        var sss = document.getElementById('edit-caseType');
        var aaa = document.getElementById('add-caseType');
        sec.innerHTML = "<option value=''>全部订单</option>";
        sss.innerHTML = "<option value=''>请选择</option>";
        aaa.innerHTML = "<option selected value=''>请选择</option>";
        $.getJSON("${contextPath}/ads/vip/getCaseType",function(result){
            $.each(result, function(i, v){
                if (type === 1){
                    sec.innerHTML += "<option value='" + v.code + "'>" + v.name + "</option>";
                }else if (type === 3){
                    aaa.innerHTML += "<option value='" + v.code + "'>" + v.name + "</option>";
                }else{
                    sss.innerHTML += "<option value='" + v.code + "'>" + v.name + "</option>";
                }
            });
        });
    }
    getCaseType(1);
    getCaseType(2);

    function getAllGdUser() {
        var sec = document.getElementById('gdUser');
        sec.innerHTML = "<option value=''>全部订单</option>";
        $.getJSON("${contextPath}/ads/vip/getAllGdUser",function(result){
            $.each(result, function(i, v){
                sec.innerHTML += "<option value='" + v.id + "'>" + v.gdUser + "</option>";
            });
        });
    }
    getAllGdUser();

    function getProvince(type) {
        var sec = document.getElementById('edit-province');
        var sss = document.getElementById('add-province');
        var ccc = document.getElementById('add-qsProvince');
        sec.innerHTML = "<option value=''>请选择</option>";
        sss.innerHTML = "<option value=''>请选择</option>";
        ccc.innerHTML = "<option value=''>请选择</option>";
        $.getJSON("${contextPath}/ads/vip/getProvince",function(result){
            $.each(result, function(i, v){
                // console.log(v);
                if (type === 1){
                    sec.innerHTML += "<option value='" + v[0] + "'>" + v[1] + "</option>";
                }else if (type === 2){
                    sss.innerHTML += "<option value='" + v[0] + "'>" + v[1] + "</option>";
                }else{
                    ccc.innerHTML += "<option value='" + v[0] + "'>" + v[1] + "</option>";
                }
            });
        });
    }
    getProvince(1);
    getProvince(3);


    function getCity(type,city) {
        var proId = null;
        if (type === 0){
            proId = $("#edit-province").val();
        }else if(type === 1){
            proId = "";
        }else if(type === 2){
            proId = $("#add-province").val();
            var sss = document.getElementById('add-city');
            sss.innerHTML = "<option selected value=''>请选择</option>";
        }else if(type === 5){
            proId = $("#add-qsProvince").val();
            var ccc = document.getElementById('add-qsCity');
            ccc.innerHTML = "<option selected value=''>请选择</option>";
        }else{
            proId = type;
        }
        var sec = document.getElementById('edit-city');
        sec.innerHTML = "<option value=''>请选择</option>";
        $.getJSON("${contextPath}/ads/vip/getCity?proId="+proId,function(result){
            $.each(result, function(i, v){
                // console.log(v);
                if (type === 2){
                        // console.log("呵呵呵");
                        sss.innerHTML += "<option value='" + v[0] + "'>" + v[1] + "</option>";
                }else if (type === 5){
                        // console.log("呵呵呵");
                        ccc.innerHTML += "<option value='" + v[0] + "'>" + v[1] + "</option>";
                }else{
                    if (city !== 0 && city === v[0]+""){
                        // console.log("哈哈哈");
                        sec.innerHTML += "<option selected value='" + v[0] + "'>" + v[1] + "</option>";
                    }else{
                        sec.innerHTML += "<option value='" + v[0] + "'>" + v[1] + "</option>";
                    }
                }
            });
        });
    }
    getCity(1,0);
    getCity(5,0);

    function updateTargent(type) {
        if (type === 1){
            var a = $("#edit-property").val();
            if (a === "1"){
                $("#edit-targetAmount").attr('disabled',false);
            }else if (a === "0"){
                $("#edit-targetAmount").attr('disabled',true);

            }
        }else if (type === 2){
            var b = $("#add-property").val();
            if (b === "1"){
                $("#add-targetAmount").attr('disabled',false);
            }else if (b === "0"){
                $("#add-targetAmount").attr('disabled',true);
                $("#add-targetAmount").val(0);
            }
        }

    }


    function noLawsuit() {
        $("#modal-refund-reason").val("");
        $("#modal-remark-body").modal("toggle");
    }
    function breakLawsuit() {
        var id = $("#edit-id").val();
        var remark = $("#modal-refund-reason").val();
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/noLawsuit",
            type : "post",
            data : {
                'id' : id,
                'remark' : remark,
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                alert(ret.message);
                $("#modal-remark-body").modal("toggle");
                $("#modal-refund-body").modal("toggle");
                jQuery("#grid-table").trigger("reloadGrid");
            }
        });
    }

    function addLawsuit() {
        $("#add-name").val("");
        // $("#add-referralFee").val("");
        // $("#add-sex").val("2");
        $("#add-phone").val("");
        $("#add-province").val("");
        $("#add-qsProvince").val("");
        $("#add-qsCity").val("");
        $("#add-city").val("");
        $("#add-caseType").val("");
        $("#add-targetAmount").val("");
        $("#add-property").val("");
        $("#add-txt").val("");
        $("#add-orderSource").val(0);
        // $("#add-agentType").val("-1");
        getProvince(2);
        getProvince(3);
        getCaseType(3);
        $("#MyDiv3").show();
    }

    function addedLawsuit() {
        var name = $("#add-name").val();
        // var referralFee = $("#add-referralFee").val();
        // var sex = $("#add-sex").val();
        var phone = $("#add-phone").val();
        var province = $("#add-province").val();
        var qsProvince = $("#add-qsProvince").val();
        var city = $("#add-city").val();
        var qsCity = $("#add-qsCity").val();
        var caseType = $("#add-caseType").val();
        var targetAmount = $("#add-targetAmount").val();
        var property = $("#add-property").val();
        var txt = $("#add-txt").val();
        var orderSource = $("#add-orderSource").val();
        // var agentType = $("#add-agentType").val();
        console.log(name);
        console.log(phone);
        console.log(province);
        console.log(city);
        console.log(caseType);
        console.log(targetAmount);
        console.log(property);
        console.log(txt);
        // console.log(orderSource);
        if (name === "" ||   phone === null || province === "" || city === ""
        || caseType === "" || property === null || txt === "" ){
            alert("请把信息填写完整！！");
            return
        }

        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/addLawsuit",
            type : "post",
            data : {
                'name' : name,
                // 'referralFee' : referralFee,
                // 'sex' : sex,
                'phone' : phone,
                'province' : province,
                'qsProvince' : qsProvince,
                'city' : city,
                'qsCity' : qsCity,
                'caseType' : caseType,
                'targetAmount' : targetAmount,
                'property' : property,
                'orderSource' : orderSource,
                'txt' : txt
                // 'agentType' : agentType
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                alert(ret.message);
                $("#MyDiv3").hide();
                jQuery("#grid-table").trigger("reloadGrid");
                getProvince(1);
                getCaseType(2);
            }
        });

    }
    function showLawTime(id , type) {
        $("#modal-time-lawTime").html("");
        $("#lawTime").val("");
        $("#modal-time-lawsuitId").val(id);
        var sec = document.getElementById('modal-time-lawTime');
        $.getJSON("${contextPath}/ads/vip/getTime?id="+id,function(result){
            $.each(result, function(i, v){
                // console.log(v);
                sec.innerHTML += "<p>"+v.time+"&nbsp;&nbsp;&nbsp;&nbsp;<button onclick='deleteTime(\""+v.id+"\")'>删除</button></p>";
            });
        });
        if (type === "1"){
            $("#modal-time-body").modal("toggle");
        }
    }

    function addTime() {
        var lawsuitId = $("#modal-time-lawsuitId").val();
        var lawTime = $("#lawTime").val();
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/addTime",
            type : "post",
            data : {
                'lawsuitId' : lawsuitId,
                'lawTime' : lawTime,
            },
            complete : function(ret) {
                showLawTime(lawsuitId , "2");
            }
        });
    }

    function deleteTime(id) {
        var lawsuitId = $("#modal-time-lawsuitId").val();
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/deleteTime",
            type : "post",
            data : {
                'id' : id
            },
            complete : function(ret) {
                showLawTime(lawsuitId , "2");
            }
        });
    }

    function exportExcel1() {
        var keys = [], ii = 0, rows = "";
        var grid_selector = "#grid-table";
        var ids = $(grid_selector).getDataIDs(); // Get All IDs
        var row = $(grid_selector).getRowData(ids[0]); // Get First row to get the labels
        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律师到期时间";
        console.log(row);
        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);
            console.log(row);
            row[keys[0]] = row[keys[0]] + "`";
            for (j = 0; j < keys.length-1; j++){
                console.log(row[keys[j]]);
                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=adsLawsuit' 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 serviceCount11() {
        $("#count").html("");
        $("#userSer").html("");
        $("#lawyerSer").html("");
        $("#userStart").val(0);
        $("#userEnd").val(0);
        $("#lawyerStart").val(0);
        $("#lawyerEnd").val(0);
        var startDate = $("#startDate").val();
        var endDate = $("#endDate").val();
        var keywords = $("#keywords").val();
        var orderType = $("#orderType").val();
        var property = $("#property").val();
        var caseType = $("#caseType").val();
        var province = $("#province").val();
        var orderSource = $("#orderSource").val();
        var type = "2";
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/getAdsVipLawsuit",
            type : "post",
            data : {
                'startDate' : startDate,
                'endDate' : endDate,
                'keywords' : keywords,
                'orderType' : orderType,
                'property' : property,
                'caseType' : caseType,
                'province' : province,
                'orderSource' : orderSource,
                'type' : type,
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                console.log(ret);
                $("#count").html(ret.count);
                var userSer = ret.userSer;
                var lawyerSer = ret.lawyerSer;
                var sec = document.getElementById('userSer');
                var sss = document.getElementById('lawyerSer');
                // sec.innerHTML += "<option value = ''>请选择</option>";
                // sss.innerHTML += "<option value = ''>请选择</option>";
                /*for (var i = 0 ; i < userSer.length ; i++){
                    sec.innerHTML += "<option value = '"+userSer[i].id+"'>"+userSer[i].gdUser+"</option>";
                }
                for (var j = 0 ; j < lawyerSer.length ; j++){
                    sss.innerHTML += "<option value = '"+lawyerSer[j].id+"'>"+lawyerSer[j].gdUser+"</option>";
                }*/
                $("#modal-service-body").modal("toggle");
            }
        });
    }

    function getSelecteds(){
        $("#lawyerSer").val("0");
        $("#userSer").val("0");
        var ids = $("#grid-table").jqGrid("getGridParam", "selarrrow");

        $("#count").html(ids.length);
        $("#modal-service-body").modal("toggle");
    }
    function toSet() {
        var ids = $("#grid-table").jqGrid("getGridParam", "selarrrow");
        for (var i = 0 ; i < ids.length ; i++){
            toSett(ids[i]+"");
        }
        setTimeout(function () {//加 0.3 秒的延迟，防止状态没有改完就刷新页面
            $("#modal-service-body").modal("toggle");
            jQuery("#grid-table").trigger("reloadGrid");
        }, 300);
    }

    function toSett(id) {
        var lawyerSer = $("#lawyerSer").val();
        var userSer = $("#userSer").val();
        console.log(id);
        console.log(lawyerSer);
        console.log(lawyerSer);
        $.ajax({
            dataType : "json",
            url : "${contextPath}/ads/vip/toSetService",
            type : "post",
            data : {
                'lawyerSer' : lawyerSer,
                'userSer' : userSer,
                'adsLawsuitId' : id,
            },
            complete : function(ret) {
                var ret = eval("(" + ret.responseText + ")");
                // console.log(ret);
            }
        });
    }

    getService(1);
    getService(0);
    function getService(type) {
        var sec = document.getElementById('userSer');
        var sss = document.getElementById('lawyerSer');
        if (type === 0){
            sec.innerHTML += "<option value = '0'>请选择</option>";
        }else{
            sss.innerHTML += "<option value = '0'>请选择</option>";
        }
        $.getJSON("${contextPath}/ads/vip/getService?type="+type,function(result){
            $.each(result, function(i, v){
                if (type === 0){
                    sec.innerHTML += "<option value = '"+v.id+"'>"+v.gdUser+"</option>";
                }else{
                    sss.innerHTML += "<option value = '"+v.id+"'>"+v.gdUser+"</option>";
                }
            });
        });
    }

    function exportExcel() {
        <%--var keys = [], ii = 0, rows = "";--%>
        <%--var grid_selector = "#grid-table";--%>
        <%--var ids = $(grid_selector).getDataIDs(); // Get All IDs--%>
        <%--var row = $(grid_selector).getRowData(ids[0]); // Get First row to get the labels--%>
        <%--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投标人数";--%>
        <%--console.log(row);--%>
        <%--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);--%>
        <%--    console.log(row);--%>
        <%--    row[keys[0]] = row[keys[0]] + "`";--%>
        <%--    for (j = 0; j < keys.length-1; j++){--%>
        <%--        console.log(row[keys[j]]);--%>
        <%--        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='csvexportform2' action='${contextPath}/fs/report/getExcel?fileName=案件数据汇总Excel' method='post'>";--%>
        <%--form = form + "<input type='hidden' name='csvBuffer' value='" + encodeURIComponent(rows) + "'>";--%>
        <%--form = form + "</form><script>document.csvexportform2.submit();</sc" + "ript>";--%>
        <%--OpenWindow = window.open('', '');--%>
        <%--OpenWindow.document.write(form);--%>
        <%--OpenWindow.document.close();--%>

        var startDate = $("#startDate").val();
        var startHour = $("#startHour").val();
        var endDate = $("#endDate").val();
        var endtHour = $("#endtHour").val();
        var keywords = $("#keywords").val();
        var orderType = $("#orderType").val();
        // var property = $("#property").val();
        var caseType = $("#caseType").val();
        var province = $("#province").val();
        var orderSource = $("#orderSource").val();
        var gdUser = $("#gdUser").val();
        var url = '${contextPath}/ads/vip/getAdsVipLawsuit?type=5&startDate='+startDate+
            "&startHour="+startHour+
            "&endDate="+endDate+
            "&endtHour="+endtHour+
            "&keywords="+keywords+
            "&orderType="+orderType +
            "&caseType="+caseType +
            "&province="+province +
            "&orderSource="+orderSource +
            "&gdUser="+gdUser ;
        console.info(url);
        window.open(url);
    }

    function exportOutExcel() {
        var startDate = $("#startDate").val();
        var startHour = $("#startHour").val();
        var endDate = $("#endDate").val();
        var endtHour = $("#endtHour").val();
        var keywords = $("#keywords").val();
        var orderType = $("#orderType").val();
        // var property = $("#property").val();
        var caseType = $("#caseType").val();
        var province = $("#province").val();
        var orderSource = $("#orderSource").val();
        var gdUser = $("#gdUser").val();
        var url = '${contextPath}/ads/vip/getAdsVipLawsuit?type=4&startDate='+startDate+
            "&startHour="+startHour+
            "&endDate="+endDate+
            "&endtHour="+endtHour+
            "&keywords="+keywords+
            "&orderType="+orderType +
            "&caseType="+caseType +
            "&province="+province +
            "&orderSource="+orderSource +
            "&gdUser="+gdUser ;
        console.info(url);
        window.open(url);
    }
</script>

