<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>勘测设计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta name="decorator" content="base" />
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/style/formSelects-v4.css" media="all">
    <link rel="stylesheet" type="text/css" href="${ctxPlugin}/lib/font/iconfont.css" />
</head>
<body>

<div class="layui-fluid">
    <div class="layui-form layui-card">
        <div class="layui-tab layui-tab-brief">
            <ul class="layui-tab-title">
                <c:if test="${partner eq '03'}">
                    <sfTags:pagePermission authFlag="XMGL_KCDA_T_${partner}" html='<a href="${ctx}/customerEntry/customerList/${partner}"><li class="layui-this">勘测设计</li></a>'/>
                </c:if>
                <c:if test="${partner ne '03'}">
                    <sfTags:pagePermission authFlag="XMGL_KCDA_T_${partner}" html='<a href="${ctx}/customerEntry/customerList/${partner}"><li class="layui-this">勘测档案</li></a>'/>
                </c:if>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10 " type="reset"  onclick="reset()" >
                    <i class="layui-icon fs-12">&#xe9aa;</i>
                    重置
                </button>
                <button class="layui-btn f-r mt-10 mr-15 pl-10 pr-10" id="searchBtn" lay-submit lay-filter="LAY-user-back-search"><i class="layui-icon fs-12">&#xe615;</i>查询</button>
            </ul>
        </div>
        <div class="layui-card-body layuiadmin-card-header-auto" >
            <form class="layui-form layui-card" action="" id="searchForm">
            <div class="layui-form-item">
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">电站编码：</label>
                    <div class="layui-input-block">
                        <input type="text" name="powerStationCode" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">业主姓名：</label>
                    <div class="layui-input-block">
                        <input type="text" name="tenantName" class="layui-input">
                    </div>
                </div>
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                    <div class="layui-col-lg2 layui-col-sm3" style="width: 33.3%">
                        <label class="layui-form-label">代理商名称：</label>
                        <div class="layui-input-block" >
                            <select name="distributorId" lay-search>
                                <option value="">请选择</option>
                                <c:forEach items="${traderList}" var="trader">
                                    <option value="${trader.columns.id}">${trader.columns.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                    <%--                    <div class="layui-col-lg2 layui-col-sm3">--%>
                    <%--                        <label class="layui-form-label">代理商电话：</label>--%>
                    <%--                        <div class="layui-input-block">--%>
                    <%--                            <input type="text" name="traderMobile" class="layui-input" >--%>
                    <%--                        </div>--%>
                    <%--                    </div>--%>
                </c:if>

                <c:if test="${'2' ne ifTop}">
                    <div class="layui-col-lg2 layui-col-sm3" style="width: 33.3%">
                        <label class="layui-form-label">二级代理商：</label>
                        <div class="layui-input-block">
                            <select name="twoTrader" lay-search>
                                <option value="">请选择</option>
                                <c:forEach items="${twoTrader}" var="trader">
                                    <option value="${trader.columns.id}">${trader.columns.name}</option>
                                </c:forEach>
                            </select>
                        </div>
                    </div>
                </c:if>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">产品名称：</label>
                    <div class="layui-input-block">
                        <input type="text" name="projectName" class="layui-input" >
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">产品编号：</label>
                    <div class="layui-input-block">
                        <select name="projectId" lay-search>
                            <option value="">请选择</option>
                            <c:forEach items="${projectList}" var="pro">
                                <option value="${pro.columns.id}" >${pro.columns.code}</option>
                            </c:forEach>

                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">勘测状态：</label>
                    <div class="layui-input-block">
                        <select name="designAuditFlag" id="designAuditFlag">
                            <option value="">请选择</option>
                            <option value="1">待踏勘</option>
                            <option value="2">待自审</option>
                            <option value="a">待设计</option>
                            <option value="3">自审驳回</option>
                            <option value="4">自审通过</option>
                            <option value="5">设计审核驳回</option>
                            <option value="6">设计审核通过</option>
                            <option value="7">进件审核驳回</option>
                            <option value="8">进件审核中</option>
                        </select>
                    </div>
                </div>
                <c:if test="${partner ne '03'}">
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">档案状态：</label>
                    <div class="layui-input-block">
                        <select name="archivesStatus" id="archivesStatus">
                            <option value="">请选择</option>
                            <option value="0">待提交</option>
                            <option value="1">待审核</option>
                            <option value="2">审核不通过</option>
                            <option value="3">审核通过</option>
                        </select>
                    </div>
                </div>
                </c:if>


               <%-- <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">安装地址：</label>
                    <div class="layui-input-block">
                        <input type="text" name="tenantAddress" class="layui-input">
                    </div>
                </div>--%>
<%--                <div class="layui-col-lg2 layui-col-sm3">--%>
<%--                    <label class="layui-form-label">备注：</label>--%>
<%--                    <div class="layui-input-block">--%>
<%--                        <input type="text" name="remarks" class="layui-input">--%>
<%--                    </div>--%>
<%--                </div>--%>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">设计审核人：</label>
                    <div class="layui-input-block">
                        <input type="text" name="examineName" class="layui-input">
                    </div>
                </div>

                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">审核备注：</label>
                    <div class="layui-input-block">
                        <input type="text" name="examineRemarks" class="layui-input" >
                    </div>
                </div>
                <%--<div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">安装方式：</label>
                    <div class="layui-input-block" >
                        <select name="method" >
                            <option value="">请选择</option>
                            <c:forEach items="${installWays}" var="installWay">
                                <option value="${installWay.columns.id}">${installWay.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>--%>
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">屋顶类型：</label>
                    <div class="layui-input-block" >
                        <select name="roofType" id="roofType" lay-filter="roofType" >
                            <option value="">请选择</option>
                            <c:forEach items="${roofTypeList}" var="roofType">
                                <option value="${roofType.columns.dict_value}">${roofType.columns.dict_value}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">标记类型：</label>
                    <div class="layui-input-block" >
                        <select name="flag" xm-select="flag"  xm-select-type="1" xm-select-height="25px" xm-select-show-count="6">
                            <option value="">请选择</option>
                            <option value="0">不标记</option>
                            <c:forEach items="${typeList}" var="flag">
                                <option value="${flag.columns.id}" >${flag.columns.name}</option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
                </c:if>
                <div class="layui-col-lg4 layui-col-sm4 layui-col-md4" style="margin-top: 5px" >
                    <label class="layui-form-label">安装地址：</label>
                    <div class="inline-block" style="width: 18%">
                        <select name="province" lay-search lay-filter="province"  id="province">
                            <option value="">省</option>
                            <c:forEach items="${province}" var="trader">
                                <option value="${trader.columns.ProvinceName}"  title="${trader.columns.ProvinceID}">${trader.columns.ProvinceName}</option>
                            </c:forEach>
                        </select>

                    </div>
                    <div class="inline-block" style="width: 18%;">
                        <select name="city" id="city" lay-filter="city"
                                lay-search>
                            <option value="">市</option>

                        </select>
                    </div>
                    <div class="inline-block" style="width: 18%">
                        <select name="area" id="area" lay-search>
                            <option value="">县/区</option>

                        </select>
                    </div>
                    <div class="inline-block" style="width: 20%">
                        <input type="text" id="address" name="address" class="layui-input">

                    </div>
                </div>
                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">登记时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="createTimeMin" class="layui-input" id="createEndStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="createTimeMax" class="layui-input" id="createEndEndTime" placeholder="结束日期">
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                <div class="layui-col-lg4 layui-col-sm6">
                    <label class="layui-form-label">审核时间：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-xs5">
                            <input type="text" name="examineTimeMin" class="layui-input" id="examineTimeStartTime" placeholder="开始日期">
                        </div>
                        <div class="layui-col-xs2 text-c lh-30">
                            —
                        </div>
                        <div class="layui-col-xs5">
                            <input type="text" name="examineTimeMax" class="layui-input" id="examineTimeEndTime" placeholder="结束日期">
                        </div>
                    </div>
                </div>
                </div>
               <%-- <div class="layui-col-lg2 layui-col-sm3">
                    <label class="layui-form-label">征信结果：</label>
                    <div class="layui-input-block" >
                        <select name="credit" >
                            <option value="">请选择</option>
                            <option value="1" >通过</option>
                            <option value="2" >驳回</option>
                        </select>
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3 mt-5">
                    <label class="layui-form-label">进件状态：</label>
                    <div class="layui-input-block" >
                        <select name="applyStatus">
                            <option value="">请选择</option>
                            <option value="NW">未审批</option>
                            <option value="AP">审批中</option>
                            <option value="RJ">拒绝</option>
                            <option value="PR">审批通过</option>
                            <option value="QY">签约</option>
                            <option value="a">未申请</option>
                        </select>
                    </div>
                </div>--%>
<%--                <div class="layui-col-lg4 layui-col-sm4 layui-col-md4" style="margin-top: 5px" >--%>
<%--                    <label class="layui-form-label">安装地址：</label>--%>
<%--                    <div class="inline-block" style="width: 18%">--%>
<%--                        <select name="province" lay-search lay-filter="province"  id="province">--%>
<%--                            <option value="">省</option>--%>
<%--                            <c:forEach items="${province}" var="trader">--%>
<%--                                <option value="${trader.columns.ProvinceName}"  title="${trader.columns.ProvinceID}">${trader.columns.ProvinceName}</option>--%>
<%--                            </c:forEach>--%>
<%--                        </select>--%>

<%--                    </div>--%>
<%--                    <div class="inline-block" style="width: 18%;">--%>
<%--                        <select name="city" id="city" lay-filter="city"--%>
<%--                                lay-search>--%>
<%--                            <option value="">市</option>--%>

<%--                        </select>--%>
<%--                    </div>--%>
<%--                    <div class="inline-block" style="width: 18%">--%>
<%--                        <select name="area" id="area" lay-search>--%>
<%--                            <option value="">县/区</option>--%>

<%--                        </select>--%>
<%--                    </div>--%>
<%--                    <div class="inline-block" style="width: 20%">--%>
<%--                        <input type="text" id="address" name="address" class="layui-input">--%>

<%--                    </div>--%>
<%--                </div>--%>
            </div>

            </form>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
                    <sfTags:pagePermission authFlag="XMGL_KCDA_DC_B_${partner}" html='<button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出列表</button>'/>
                    <sfTags:pagePermission authFlag="XMGL_KCDA_THKC_B_${partner}" html='<button class="layui-btn layui-btn-sm" lay-event="thkcBtn" id="thkcBtn"><i class="layui-icon layui-icon-export"></i>退回勘测</button>'/>
                </div>
            </script>
        </div>
    </div>
</div>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form'], function(){
        //layui.use(['table','layer','laypage','laydate','form'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();

        var type = "${user.userType}";
        var traderType="${user.traderType}";

        //开始日期
        var endStartTime = laydate.render({
            elem: '#createEndStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                endEndTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                endEndTime.config.elem[0].focus();
            }
        });
        //结束日期
        var endEndTime = laydate.render({
            elem: '#createEndEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                endStartTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        var startTime = laydate.render({
            elem: '#examineTimeStartTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新结束日期的最小日期
                endTime.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });
                //自动弹出结束日期的选择器
                endTime.config.elem[0].focus();
            }
        });
        //结束日期
        var endTime = laydate.render({
            elem: '#examineTimeEndTime'
            /* ,type: 'datetime'*/
            ,done: function(value, date){
                //更新开始日期的最大日期
                startTime.config.max = lay.extend({}, date, {
                    month: date.month - 1
                });
            }
        });

        if("${types}"=="1"){
            parent.window.location.reload(true);
        }
        //按钮权限
        var toExamine = '${fns:checkPagePermission(request, toExaminePermission)}';//设计审核
        var zsExamine= '${fns:checkPagePermission(request, zsExaminePermission)}';//自审
        var fileReview = '${fns:checkPagePermission(request, fileReviewPermission)}';//档案审核
        var kcBth = '${fns:checkPagePermission(request, kcBthPermission)}';//勘测
        var daBth = '${fns:checkPagePermission(request, daBthPermission)}';//档案
        var sjBth = '${fns:checkPagePermission(request, sjBthPermission)}';//设计

        tableExt.render({
            elem: '#test'
            , title:'勘测档案'
            , height: 'full-260'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/getCustomerList?partner=${partner}'
            , method:"post"
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                , {field: 'id', type: 'checkbox',fixed: 'left'}
                , {field: 'id', title: '操作',minWidth:'180', sort: false, align: 'center',fixed: 'left', templet:function(d){
                        var html = "";
                        if (type != '6' && type != '7') {
                          //非代理商--只能查看
                           if(d.status !== '1'){
                               if (fileReview === '0' && d.archivesStatus === '1' && d.archive_review_flag) {
                                   return "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"fileReview('" + d.id + "')\">档案审核</a>&nbsp;&nbsp;";
                               } else {
                                   return "--";
                               }
                           }
                           if (toExamine === '0' && d.design_audit_flag !='6' && d.review_flag) {
                               html +=  "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"ProhibitTwo('"+d.id+"')\">设计审核</a>&nbsp;&nbsp;";
                           }
                           if (fileReview === '0' && d.archivesStatus === '1' && d.archive_review_flag) {
                               html +=  "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"fileReview('"+d.id+"')\">档案审核</a>&nbsp;&nbsp;";
                           }
                       }else{
                            if (d.design_audit_flag =='1' || d.design_audit_flag =='3'  || d.design_audit_flag =='b'){
                                if (kcBth === '0'){
                                    html += "<a href=\"#\" class=\"layui-table-link layui-icon   \" style='font-size:14px;' onclick=\"editCustomerEntry2('" + d.id + "')\">勘测</a>&nbsp;&nbsp;";
                                }
                            }
                            if (d.archivesStatus === '0' || d.archivesStatus === '2') {
                                if (daBth === '0'){
                                    html += "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"fileReview2('" + d.id + "')\">档案</a>&nbsp;&nbsp;";
                                }
                            }
                            if (d.design_audit_flag == 'a'){
                                if (sjBth === '0'){
                                    html += "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"designCustomerEntry('" + d.id + "')\">设计</a>&nbsp;&nbsp;";
                                }
                            }
                           // if (d.status == '1' || d.status == '0') {
                           //     return "--";
                           // }
                           // 代理商只能操作设计自审
                            if (d.design_audit_flag =='2' || d.design_audit_flag =='5'){
                                if('1'==traderType && zsExamine === '0'){
                                    html += "<a href=\"#\" class=\"layui-table-link layui-icon   \" style='font-size:14px;' onclick=\"editCustomerEntry('" + d.id + "')\">自审</a>&nbsp;&nbsp;";
                                }
                            }

                           // // 针对BT业务的逻辑 暂时使用不到
                           // if(d.status == '1' && d.management_type =='2' && d.credit == '2'){
                           //     html += "<a href=\"#\" class=\"layui-table-link layui-icon   \" style='font-size:14px;' onclick=\"editCustomerEntry('"+d.id+"')\">编辑</a>&nbsp;&nbsp;";
                           //     html += "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"deleteWarranty('"+d.id+"')\">删除</a>";
                           //     return html;
                           // }
                       }
                       // 这里面的操作  是平台和代理商都可以操作的
                        console.log(d.credit+"-----------"+d.status +">>>>>"+d.management_type)
                        if(d.management_type =='2' ){
                           if(isBlank(d.credit)){
                               console.log(html)
                               return html +"<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"findResult('"+d.id+"')\">查询征信</a>";
                           }/*else if(d.credit == '1' && (isBlank(d.apply_status) || d.apply_status == '0' || d.apply_status == '1' || d.apply_status =='3' || d.apply_status =='RJ')){
                               return jjExamine =='0'?html +"<a href=\"#\" class=\"layui-table-link layui-icon   \" style='font-size:14px;' onclick=\"preInputEntry('"+d.id+"')\">进件申请</a>":'';
                           }else if(d.apply_status =='NW' || d.apply_status =='AP'){
                               return html +'<a href="#" class="layui-table-link" onclick="lookInputEntryStatus(\''+d.id+'\')">查看进件状态</a>';
                           }*/
                       }
                        if (d.design_audit_flag === '8') {
                            if (fileReview === '0' && d.archivesStatus === '1' && d.archive_review_flag) {
                                return "<a href=\"#\" class=\"layui-table-link layui-icon  \" style='font-size:14px;' onclick=\"fileReview('"+d.id+"')\">档案审核</a>&nbsp;&nbsp;";
                            } else {
                                return "--";
                            }
                        } else if (!isBlank(html)) {
                            return html;
                        } else {
                            return "--";
                        }


                    }
                    }
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, sort: false,fixed: 'left', align: 'center', exportable: true, templet: function(d){
                        var flag = d.flag;
                        var html="";
                    <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                        if(isBlank(flag)){//
                            html ="<i class=\"icon iconfont\" style=\"color: #8D8D8D\" onclick=\"customerEntryFlag('"+d.id+"')\">&#xe6b0;</i>";
                        }else{
                            html ="<i class=\"icon iconfont \" style=\"color: "+d.flag_type+";\" onclick=\"customerEntryFlag('"+d.id+"')\">&#xe6b0;</i>";
                        }
                    </c:if>
                        return html +  '<a href="#" class="layui-table-link" onclick="psDetail(\''+d.id+'\')">'+d.power_station_code+'</a>';
                    }}
                , {field: 'tenant_name', title: '业主姓名', minWidth: '150', sort: false,fixed: 'left', align: 'center', exportable: true}
                , {field: 'design_audit_flag', title: '勘测状态',minWidth:'160', sort: false, fixed: 'left',align: 'center',exportable:true,  templet:function(d){
                        if (d.design_audit_flag === '1' && d.zs_result !== '4') {
                            return "待踏勘";
                        } else if (d.design_audit_flag === '1' && d.zs_result === '4') {
                            return "设计审核驳回";
                        } else if (d.design_audit_flag === '2') {
                            return "待自审";
                        } else if (d.design_audit_flag === '3') {
                            return "<span data-pass = \"passed\">自审驳回</span>";
                        } else if (d.design_audit_flag === '4') {
                            return "自审通过";
                        } else if (d.design_audit_flag === '5') {
                            return "<span data-pass = \"passed\">设计审核驳回</span>";
                        } else if (d.design_audit_flag === '6') {
                            return "设计审核通过";
                        } else if (d.design_audit_flag === '7') {
                            return "<span data-pass = \"passed\">进件审核驳回</span>";
                        } else if(d.design_audit_flag ==='8'){
                            return "进件审核中";
                        } else if(d.design_audit_flag ==='9'){
                            return "进件审核通过";
                        } else if(d.design_audit_flag ==='a'){
                            return "待设计";
                        } else {
                            return "----";
                        }
                    },
                    expFormat: function (d) {
                        if (d.design_audit_flag === '1') {
                            return "待踏勘";
                        } else if (d.design_audit_flag === '2') {
                            return "待自审";
                        } else if (d.design_audit_flag === '3') {
                            return "自审驳回";
                        } else if (d.design_audit_flag === '4') {
                            return "自审通过";
                        } else if (d.design_audit_flag === '5') {
                            return "设计审核驳回";
                        } else if (d.design_audit_flag === '6') {
                            return "设计审核通过";
                        } else if (d.design_audit_flag === '7') {
                            return "进件审核驳回";
                        } else if(d.design_audit_flag ==='8'){
                            return "进件审核中";
                        } else if(d.design_audit_flag ==='9'){
                            return "进件审核通过";
                        } else if(d.design_audit_flag ==='a'){
                            return "待设计";
                        } else {
                            return "----";
                        }
                    }
                },
                <!--% 广发不显示 %-->
                <c:if test="${partner ne '03'}">
                {field: 'archivesStatus', title: '档案状态',minWidth:'160', sort: false, fixed: 'left',align: 'center',exportable:true, templet:function(d){
                        if (d.archivesStatus === '0') {
                            return "待提交";
                        } else if (d.archivesStatus === '1') {
                            return "待审核";
                        } else if (d.archivesStatus === '2') {
                            return "审核不通过";
                        } else if (d.archivesStatus === '3') {
                            return "审核通过";
                        } else {
                            return "--";
                        }
                    },
                    expFormat: function (d) {
                        if (d.archivesStatus === '0') {
                            return "待提交";
                        } else if (d.archivesStatus === '1') {
                            return "待审核";
                        } else if (d.archivesStatus === '2') {
                            return "审核不通过";
                        } else if (d.archivesStatus === '3') {
                            return "审核通过";
                        } else {
                            return "--";
                        }
                    }
                },
                </c:if>
                {field: 'apply_status', title: '进件状态', minWidth: 130, align: 'center', exportable: true
                    , templet:function(d){
                        return applyStatusStr(d.apply_status);
                    }
                    , expFormat: function(d){
                        return applyStatusStr(d.apply_status);
                    }
                }
                ,{field: 'projectCode', title: '产品编号',minWidth:'130', sort: false, align: 'center',exportable:true}
                , {field: 'projectName', title: '产品名称',minWidth:'200', sort: false, align: 'center',exportable:true}
                , {
                    field: 'planName',
                    title: '方案名称',
                    minWidth: 200,
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        if (d.scheme_type === '1') {
                            if (isBlank(d.scheme_id)) {
                                return '——';
                            }
                            return '<a href="#" class="layui-table-link" onclick="planDetail(\'' + d.id + '\')">' + d.scheme_name + '</a>';
                        } else if (isBlank(d.scheme_name)) {
                            return '<a href="#" class="layui-table-link" onclick="planDetail(\'' + d.id + '\')">查看方案</a>';
                        } else {
                            return '<a href="#" class="layui-table-link" onclick="planDetail(\'' + d.id + '\')">' + d.scheme_name + '</a>';
                        }
                    }
                }, {
                    field: 'province',
                    title: '项目名称',
                    minWidth: '260',
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                        return d.province + '' + d.area + d.tenant_name + d.design_capacity / 1000 + "KW光伏电站";
                    },
                    expFormat: function (d) {
                        return d.province + '' + d.area + d.tenant_name + d.design_capacity / 1000 + "KW光伏电站";
                    }
                }
                , {
                    field: 'design_capacity',
                    title: '设计安装容量(kW)',
                    minWidth: 150,
                    sort: false,
                    align: 'center',
                    exportable: true
                    ,templet: function (d) {
                        let num = d.design_capacity / 1000;
                        return num;
                    },
                    expFormat: function (d) {
                        let num = d.design_capacity / 1000;
                        return num;
                    }
                }
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                , {field: 'distributorName', title: '代理商名称',minWidth:'300', sort: false, align: 'center', exportable:true}
                , {field: 'distributorMobile', title: '代理商电话',minWidth:'150', sort: false, align: 'center', exportable:true}
                </c:if>
                <c:if test="${'2' ne ifTop}">
                , {field: 'createTraderName',title: '二级代理商',minWidth: '300',sort: false,align: 'center',exportable: true
                    ,templet: function (d) {
                        if(d.distributor_id==d.create_trader_id){
                            return "";
                        }else{
                            return d.createTraderName
                        }
                    },
                    expFormat: function (d) {
                        if(d.distributor_id==d.create_trader_id){
                            return "";
                        }else{
                            return d.createTraderName
                        }
                    }

                }
                </c:if>
                , {field: 'mobile', title: '联系电话', minWidth: '120', sort: false, align: 'center', exportable: true}
                , {field: 'address', title: '安装地址', minWidth: '300', sort: false, align: 'center', exportable: true}
                , {field: 'roof_type', title: '屋顶类型', minWidth: '100', sort: false, align: 'center', exportable: true}
                // , {field: 'angle', title: '朝向角度(度)', minWidth: '130', sort: false, align: 'center', exportable: true}

                // , {
                //     field: 'product_line_name',
                //     title: '产品线',
                //     minWidth: '150',
                //     sort: false,
                //     align: 'center',
                //     exportable: true
                // }
                // , {
                //     field: 'product_line',
                //     title: '业务属性',
                //     minWidth: '100',
                //     sort: false,
                //     align: 'center',
                //     exportable: true,
                //     templet: function (d) {
                //         return transAttribute(d.product_line);
                //     },
                //     expFormat: function (d) {
                //         return transAttribute(d.product_line);
                //     }
                // }
                , {
                    field: 'project_company_name',
                    title: '所属项目公司',
                    minWidth: '280',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'remarks', title: '备注',minWidth:'150', sort: false, align: 'center',exportable:true}
                , {field: 'create_time', title: '登记时间',minWidth:'180', sort: false, align: 'center',exportable:true}
                , {field: 'examine_name', title: '设计审核人',minWidth:'100', sort: false, align: 'center',exportable:true}
                , {field: 'examine_remarks', title: '审核备注',minWidth:'150', sort: false, align: 'center',exportable:true}
                , {field: 'examine_time', title: '审核时间',minWidth:'180', sort: false, align: 'center',exportable:true}

            ]] ,done:function(res,cuss,count){
              //  console.log(res,cuss,count)
                $('span[data-pass="passed"]').parent().parent().parent().css('background-color','#ffeaf2');
                $('.layui-table-header .laytable-cell-checkbox input').attr('disabled','disabled');
            }
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '勘测档案',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 5000,                    //当pageData为false生效
                fileName: '勘测档案',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            }
        });


        function  applyStatusStr(applyStatus){
            if(applyStatus == '0'){
                return "待预审";
            }else if(applyStatus == '1'){
                return "预审中";
            }else if(applyStatus == '2'){
                return "预审成功";
            }else if(applyStatus == '3'){
                return "预审驳回";
            }else if(applyStatus == '4'){
                return "待进件";
            }else if(applyStatus == '5'){
                return "进件审核中";
            }else if(applyStatus == '6'){
                return "进件审核成功";
            }else if(applyStatus == '7'){
                return "进件审核驳回";
            }else if(applyStatus == '8'){
                return "合同待签约";
            }else if(applyStatus == '9'){
                return "合同已签约";
            }else if(applyStatus == '10'){
                return "合同审核中";
            }else if(applyStatus == '11'){
                return "合同签约驳回";
            }else if(applyStatus == '12'){
                return "合同已审核";
            }else if(applyStatus == '13'){
                return "待提交完工资料";
            }else if(applyStatus == '14'){
                return "完工资料审核中";
            }else if(applyStatus == '15'){
                return "完工资料审核通过";
            }else if(applyStatus == '16'){
                return "完工资料审核驳回";
            }else if(applyStatus == '17'){
                return "待提交并网资料";
            }else if(applyStatus == '18'){
                return "并网资料待审核";
            }else if(applyStatus == '19'){
                return "并网资料审核中";
            }else if(applyStatus == '20'){
                return "并网资料审核通过";
            }else if(applyStatus == '21'){
                return "并网资料审批拒绝";
            }else {
                return "";
            }
        }


        function transAttribute(productLineAttribute) {
            switch (productLineAttribute) {
                case '1':
                    return '纯租25年业务';
                case '2':
                    return '经营性租赁';
                case '3':
                    return '融资租赁';
                case '4':
                    return '光伏贷';
                case '5':
                    return '全款';
                case '6':
                    return '其他';
                default:
                    return '';
            }
        }
        table.on('toolbar(test)',function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if(obj.event === 'thkcBtn'){
                var data = checkStatus.data;
                let id = data[0].id;
                if (data.length <1) {
                    layer.msg("请选择数据",{icon:5,anim:6});
                    return false;
                }
                if (data.length >1) {
                    layer.msg("只能选择一条数据",{icon:5,anim:6});
                    return false;
                }
                if (data[0].design_audit_flag != '6' && data[0].design_audit_flag != '7')  {
                    layer.msg("当前电站状态不可退回勘测",{icon:5,anim:6});
                    return false;
                }
                layer.confirm('确认要退回勘测吗？', {
                    icon:3,
                    btn:['确定','取消'] //按钮
                }, function(){
                    $.ajax({
                        type: 'post',
                        url: '${ctx}/customerEntry/returnToSurvey',
                        data: {
                            id:id
                        },
                        success: function(data){
                            if (data.code === '200') {
                                layer.msg('操作成功', {time: 1000}, function () {
                                    searchOrder();
                                });
                            }else {
                                layer.msg('操作失败', {time: 1000});
                            }
                        }
                    })
                });

            }
        });
        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            tableExt.reload('test', {
                where: field,
                page:{
                    curr:1
                }
                ,height: 'full-260'
                ,done: function(res, curr, count){
                    //this.where={};
                    console.log("不清空，有问题：搜索条件会保留")
                    //不清空，有问题：搜索条件会保留
                    //清空，  有问题：分页的时候没有搜索条件了,分页会受到影响
                    console.log(res, curr, count)
                }
            });
        });

        form.on('select(province)', function (data) {
            var province = $(data.elem).find("option:selected").attr("title");
            provinceOrder(province);
        });
        form.on('select(city)', function (data) {
            var city = $(data.elem).find("option:selected").attr("title");
            cityOrder(city);

        });

        function provinceOrder(province) {
            $("#city").empty();
            $("#area").empty();
            if (isBlank(province)) {
                $("#city").append("<option value=''>市</option>");
                return "";
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/main/redirect/getCitysByProId",
                data: {
                    province: province
                },
                success: function (result) {

                    if (result == "205") {
                        layer.msg("暂无数据!")
                        return
                    }
                    var html = " <option value=''>市</option>";
                    for (var i = 0; i < result.length; i++) {
                        var city = result[i];
                        html = html + '<option value="' + city.columns.CityName + '" title="' + city.columns.CityID + '">' + city.columns.CityName + '</option>';
                    }
                    $("#city").append(html);
                    form.render('select');
                }
            });

        }

        function cityOrder(city, arean) {
            $("#area").empty()
            if (isBlank(city)) {
                $("#area").append("<option value=''>区/县</option>");
                return "";
            }
            $.ajax({
                type: "POST",
                url: "${ctx}/main/redirect/getAreaByCityId",
                data: {
                    city: city
                },
                success: function (result) {
                    if (result == "205") {
                        layer.msg("暂无数据!")
                        return
                    }
                    var html = "<option value=''>区/县</option>";
                    for (var i = 0; i < result.length; i++) {
                        var area = result[i];
                        html = html + '<option value="' + area.columns.DistrictName + '" value="' + area.columns.DistrictId + '">' + area.columns.DistrictName + '</option>';
                    }
                    $("#area").append(html);
                    if (!isBlank(arean)) {
                        $("#area").val(arean)
                    }

                    form.render('select');
                }
            });

        }

        document.addEventListener('keydown', function (event) {
            if (event.keyCode === 13) {
                //执行相关操作
                $("#searchBtn").click();
            }
        });
    })


    function searchOrder() {
        layer.closeAll();
        //执行重载
        var wherobj =_serializeJson($("#searchForm"));
        tableExt.reload('test', {
            where: wherobj
        });
    }

    //查看详情
    function psDetail(id){
        layer.open({
            type: 2
            , title: '电站详情'
            , content: '${ctx}/customerEntry/entryDetail?entryId=' + id
            , area: ['100%', '100%']
            , yes: function(index, layero){

            }
        });
    }

    function customerEntryFlag(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/getFlagcustomerEntry?customerEntryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,title: "标记项目"
            ,area:["300px","260px"]
            ,closeBtn: 0
            ,shadeClose:true

        });
    }

    function editCustomerEntryFa(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/getDqrCustomerEntryForm?entryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,area: ['83%','96%']
            ,title: false //不显示标题栏
            ,closeBtn: 0
            ,shadeClose:true
            /*,shade: 0.8*/
            /*  ,btn: ['确认生成', '取消']*/
            /*,btnAlign: 'c'*/
            /*,scrollbar:false*/
            ,cancel: function(){
                searchOrder();
            }
        });
    }

    function editCustomerEntry(id){
            layer.open({
                type: 2,
                content: "${ctx}/customerEntry/getUpdateCustomerEntryForm?entryId=" + id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
                , title: '信息详情' //不显示标题栏
                ,area: ['100%', '100%']
                ,cancel: function(){
                    searchOrder();
                }
            });
    }

    function editCustomerEntry2(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/getUpdateCustomerEntryForm2?entryId=" + id +"&type=1"//这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            , title: '勘测' //不显示标题栏
            ,area: ['100%', '100%']
            ,cancel: function(){
                searchOrder();
            }
        });
    }

    function askToContract(id){
        layer.confirm('确认邀请农户签约？', {
            icon:3,
            btn:['确定','取消'] //按钮
        }, function(){
            $.ajax({
                type: 'GET',
                url: '${ctx}/customerEntry/inviteSignQr',
                contentType: 'application/json',
                data: {id:id},
                success: function(data){
                    if (data.code === '200') {
                        layer.msg('操作成功', {time: 2000});
                        searchOrder();
                    }else {
                        layer.msg(data.errMsg, {time: 2500});
                    }
                }
            })
        });
    }

    function findResult(id){
        layer.open({
            type: 2,
            title: '征信查询',
            content: '${ctx}/customerEntryExtra/findResult?id='+id,
            area : [ '650px', '316px' ],
            cancel:function(){
                table.reload('test'); //数据刷新
            }
        });
    }
    function preInputEntry(id){
        layer.open({
            type: 2,
            title: '进件申请',
            content: '${ctx}/customerEntryExtra/preInputEntry?id='+id,
            area: ['63%','85%']
        });
    }

    function lookInputEntryStatus(id,type){
        layer.open({
            type: 2,
            title: '查看进件状态',
            content: '${ctx}/customerEntryExtra/lookInputEntryStatus?id='+id+'&type='+type,
            area : [ '650px', '450px' ],
            cancel:function(){
                table.reload('test'); //数据刷新
            }
        });
    }

    function deleteWarranty(id){
        var indexla = layer.confirm('您确定要删除项目信息吗？', {
            icon: 3,
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "POST",
                url: "${ctx}/customerEntry/deleteCustomerEntry",
                data: {
                    cusId: id
                },
                success: function (result) {
                    if(result.code=='200'){
                        layer.msg('删除成功！', {icon: 1, time: 1000}, function () {
                            searchOrder();
                        });
                    }else {
                        console.log(result)
                        layer.msg('删除失败!', {icon: 2});
                    }
                },
                error:{
                }
            })
        }, function () {
            layer.close(indexla);
        });
    }

    function  admittance(id) {
        $.ajax({
            type: "POST",
            url: "${ctx}/customerEntry/shoudongCustomerEntry",
            data: {
                id: id
            },
            success: function (result) {
                if(result.code=='200'){
                    layer.msg('准入成功！', {icon: 1, time: 1000}, function () {
                        searchOrder();
                    });
                }else {
                    console.log(result)
                    layer.msg('准入失败!', {icon: 2});
                }
            },
            error:{
            }
        })
    }

    function Prohibit(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/toExamineForm?type=1&entryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,area: ['100%', '100%']
            ,title: '审核信息' //不显示标题栏

        });
    }

    function ProhibitTwo(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/toExamineForm?type=2&entryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,area: ['100%', '100%']
            ,title: '审核信息' //不显示标题栏

        });
    }

    function fileReview(id){
        layer.open({
            type: 2,
            content: "${ctx}/customer/org/files/toFileReviewForm?entryId="+id,
            area: ['100%', '100%'],
            title: '档案审核'
        });
    }

    function fileReview2(id){
        layer.open({
            type: 2,
            content: "${ctx}/customer/org/files/toFileReviewForm2?entryId="+id,
            area: ['100%', '100%'],
            title: '编辑档案'
        });
    }

    function designCustomerEntry(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/getUpdateCustomerEntryForm2?entryId="+id+"&type=2",
            area: ['100%', '100%'],
            title: '设计'
        });
    }

    function examineInputEntry(id){
        layer.open({
            type: 2,
            title: '进件申请',
            content: '${ctx}/customerEntryExtra/examineInputEntryPage?id='+id,
            area: ['63%','85%']
        });
    }

    function planDetail(entryId){
        layer.open({
            type: 2,
            title: '查看',
            content: '${ctx}/planManage/viewMatchedPlan?entryId=' + entryId,
            area: ['80%','80%']
        });
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }

    function reset(){
        layui.form.render();
        $("#searchForm").find("select").val("");
        $("#searchForm").find("input").val("");
    }
</script>
</body>
</html>

