<%@ 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">
                <sfTags:pagePermission authFlag="XMGL_BWYS_T_${partner}" html='<a href="${ctx}/customerEntry/waitAccept/${partner}"><li class="layui-this">并网验收</li></a>'/>
                <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>
        <form class="layui-card-body layuiadmin-card-header-auto" id="searchForm">
            <div class="layui-form-item">
                <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" id="powerStationCode" class="layui-input" autocomplete="off">
                        </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" id="tenantName" class="layui-input" autocomplete="off">
                        </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="traderId" 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>

                    </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" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-lg2 layui-col-sm3">
                        <label class="layui-form-label">产品编码：</label>
                        <div class="layui-input-block" >
                            <select name="projectCode" id="projectId" lay-search>
                                <option value="">请选择</option>
                                <c:forEach items="${projectList}" var="project">
                                    <option value="${project.columns.id}">${project.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="stageStatus" id="stageStatus">
                                <option value="">全部</option>
                                <option value="d">资方审核驳回</option>
                                <option value="c">待并网验收</option>
                                <option value="b">资方审核中</option>
                                <option value="a">已完成</option>
                            </select>
                        </div>
                    </div>

                    <div class="layui-col-lg2 layui-col-sm3">
                        <label class="layui-form-label">进件状态：</label>
                        <div class="layui-input-block">
                            <select name="applyStatus" id="applyStatus" lay-search>
                                <option 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="6">进件审核成功</option>
                                <option value="7">进件审核驳回</option>
                                <option value="8">合同待签约</option>
                                <option value="9">合同已签约</option>
                                <option value="10">合同审核中</option>
                                <option value="11">合同签约驳回</option>
                                <option value="12">合同已审核</option>
                                <option value="13">待提交完工资料</option>
                                <option value="14">完工资料审核中</option>
                                <%--                            <option value="15">完工资料审核通过</option>--%>
                                <option value="16">完工资料审核驳回</option>
                                <option value="17">待提交并网资料</option>
                                <option value="18">并网资料待审核</option>
                                <option value="19">并网资料审核中</option>
                                <option value="21">并网资料审批拒绝</option>
                                <option value="20">并网资料审批通过</option>
                            </select>
                        </div>
                    </div>

                </div>

                <div class="layui-col-lg6 layui-col-sm6">
                    <label class="layui-form-label">安装地址：</label>
                    <div class="layui-input-block">
                        <div class="layui-col-lg2 layui-col-sm2 pr-10">
                            <select name="province" id="province"
                                    lay-filter="province" lay-search>
                                <option value="">请选择省</option>
                                <c:forEach items="${pros}" var="pro">
                                    <option value="${pro.columns.ProvinceName}"
                                            title="${pro.columns.ProvinceID }"
                                            <c:if test="${entry.province eq pro.columns.ProvinceName}">selected</c:if>>${pro.columns.ProvinceName}</option>
                                </c:forEach>
                            </select>
                        </div>
                        <div class="layui-col-lg2 layui-col-sm2 pr-10">
                            <select name="city" id="city"  lay-filter="city"
                                    lay-search>
                                <option value="">请选择市</option>

                            </select>
                        </div>
                        <div class="layui-col-lg2 layui-col-sm2 pr-10">
                            <select name="area" id="area"  lay-search>
                                <option value="">请选择县/区</option>

                            </select>
                        </div>
                        <div class="layui-col-lg6 layui-col-sm6">

                            <input type="text" name="address"
                                   autocomplete="off" class="layui-input layui-col-lg2 "
                                   value="${entry.customerAddress}">
                        </div>
                    </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>
        </form>
    </div>
    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" lay-skin="row" id="test" lay-filter="test"></table>
        </div>
    </div>
</div>
<!-- toolbar -->
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
        <sfTags:pagePermission authFlag="XMGL_BWYS_SQZG_B_${partner}" html='<button class="layui-btn layui-btn-sm" lay-event="retrialBtn" id="retrialBtn"><i class="layui-icon layui-icon-ok-circle"></i>申请整改</button>'/>
        <sfTags:pagePermission authFlag="XMGL_BWYS_DCLB_B_${partner}" html='<button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出列表</button>'/>
    </div>
</script>
<!--操作栏-->
<script type="text/html" id="optTpl">
  <%--      {{#if(d.apply_status !=='18' && d.next_apply_status !=='APPROVED'){ }}
      &lt;%&ndash;  <a class="layui-table-opt-link" lay-event="preInputEntry">推送并网信息</a>&ndash;%&gt;
        {{# }else --%>

         {{#if(d.merge_flag =='1' && d.review_flag){ }}
        <c:if test="${user.userType ne '6' && user.userType ne '7'}">
            <sfTags:pagePermission authFlag="XMGL_BWYS_YS_B_${partner}" html='<a class="layui-table-opt-link" lay-event="sureAccept" id="sureAccept">验收</a>'/>
        </c:if>
       {{# }   }}


</script>
<!-- 电站编码 -->
<script type="text/html" id="stationCodeTpl">
    {{#if(d.design_capacity !== d.actual_capacity){ }}
    <i class="orderNum-diff-icon"></i>
    {{#}    }}
    <c:if test="${user.userType ne '6' && user.userType ne '7'}">
        {{#if(isBlank(d.flag)){ }}
        <i class="icon iconfont" style="color: #8D8D8D" onclick="customerEntryFlag('{{d.id}}')">&#xe6b0;</i>
        {{# }else{  }}
        <i class="icon iconfont " style="color: {{d.flag_type}};" onclick="customerEntryFlag('{{d.id}}')">&#xe6b0;</i>
        {{# }   }}
    </c:if>
    <a href="#" class="layui-table-link" onclick="psDetail('{{d.id}}')">{{d.power_station_code}}</a>
</script>
<!-- 验收报告 -->
<script type="text/html" id="reportTpl">
<%--    <sfTags:pagePermission authFlag="XMGL_BWYS_BWYS_CKYSBG" html=''/>--%>
    <a href="#" class="layui-table-link" onclick="downloadReport('{{d.id}}')">查看</a>
</script>
<!-- 发票 -->
<script type="text/html" id="billTpl">
    {{#if(!isBlank(d.bill)){    }}
    <a href="#" class="layui-table-opt-link" lay-event="viewBill">查看</a>
    {{#}    }}
</script>
<!-- 购售电合同 -->
<script type="text/html" id="gsdContractTpl">
    {{#if(!isBlank(d.gsd_contract)){    }}
    <a href="#" class="layui-table-opt-link" lay-event="viewGdsContract">查看</a>
    {{#}    }}
</script>
<!-- 合同 -->
<script type="text/html" id="contractTpl">
    {{#if(!isBlank(d.contract)){    }}
    <a href="#" class="layui-table-opt-link" lay-event="viewContract">查看</a>
    {{#}    }}
</script>
<!-- 上传文件 -->
<script type="text/html" id="uploadFileTpl">
    <div>
        <div style="padding: 100px;margin: 20px;border: 1px dotted #716666;" id="uploadDIV">
            <button type="button" class="layui-btn" id="uploadBtn" style="width: 100%;height: 40px;">
                <i class="layui-icon"></i>将文件拖拽到此处或点击上传
            </button>
        </div>
    </div>
    <p class="ml-20"><i class="red">* </i><span>只能上传pdf文件</span></p>
</script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/lib/formSelects-v4.js"></script>
<script>
    var entrycount=0;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form', 'upload', 'laytpl'], 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;
        laytpl = layui.laytpl;
        table = tableExt.getLayTable();

        var upload = layui.upload;


        //开始日期
        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
                 });*/
            }
        });

        tableExt.render({
            elem: '#test'
            , title:'并网验收'
            , height: 'full-220'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/ajaxForWaitOrder?status=7,BN&partner='+'${partner}'
            , method:"post"
            , where: _serializeJson($("#searchForm"))
            , cols: [[
                {type: 'numbers', fixed: 'left', title: '序号'}
                , {field: 'id', minWidth: '4%', checkbox: true, align: 'center', rowspan: '2', fixed: 'left'}
                , {
                    field: 'id',
                    minWidth: 120,
                    title: '操作',
                    align: 'center',
                    rowspan: '2',
                    fixed: 'left',
                    templet: '#optTpl'
                }
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, sort: false, align: 'center', fixed: 'left',exportable:true, templet: '#stationCodeTpl'}
                , {field: 'tenant_name', title: '业主姓名', minWidth: 150, sort: false,fixed: 'left', align: 'center', exportable: true}
                ,{field : 'status', minWidth : 120 , title: '电站状态', align : 'center',rowspan:'2',exportable:true, templet: function(d){
                        if (d.on_grid_flag === '3') {
                            return '资方审核驳回';
                        }
                        if (d.merge_flag === '1') {
                            return '待并网验收';
                        }
                        if (d.merge_flag === '3') {
                            return '资方审核中';
                        }
                        if (d.merge_flag === '4') {
                            return '已完成';
                        }

                        return '';
                    },expFormat:function(d){
                        if (d.status === 'd') {
                            return '资方审核驳回';
                        }
                        if (d.status === 'c') {
                            return '待并网验收';
                        }
                        if (d.status === 'b') {
                            return '资方审核中';
                        }
                        if (d.status === 'a') {
                            return '已完成';
                        }
                        return '';
                    }}
                ,{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: 'if_state_grid_status', title: '国网授权状态', minWidth: 130, align: 'center', exportable: true, templet: function(d){
                        if (isBlank(d.if_state_grid_status)) {
                            return '未导入';
                        }else if(d.if_state_grid_status === '0'){
                            return '未导入';
                        }else if(d.if_state_grid_status === '1'){
                            return '已导入';
                        }else if(d.if_state_grid_status === '2'){
                            return '已授权';
                        }
                    },expFormat:function(d){
                        if (isBlank(d.if_state_grid_status)) {
                            return '未导入';
                        }else if(d.if_state_grid_status === '0'){
                            return '未导入';
                        }else if(d.if_state_grid_status === '1'){
                            return '已导入';
                        }else if(d.if_state_grid_status === '2'){
                            return '已授权';
                        }
                    }}
                , {field: 'sign_status', title: '合同状态', minWidth: 150, align: 'center',exportable:true ,
                    templet: function (d) {
                        if (d.sign_status === 'f') {
                            return "待上传";
                        } else if (d.sign_status === 'g') {
                            return "已上传";
                        }else if (d.sign_status === '1') {
                            return "待签约";
                        }else if (d.sign_status === '2') {
                            return "已签约";
                        }else if (d.sign_status === '3') {
                            return "待审核";
                        }else if (d.sign_status === '4') {
                            return "签署驳回";
                        }else if (d.sign_status === '5') {
                            return "已审核";
                        }else if (d.sign_status === '6') {
                            return "待生成";
                        }else if (d.sign_status === 'a') {
                            return "承租人已签";
                        }else if (d.sign_status === 'b') {
                            return "签署中";
                        }else if (d.sign_status === 'c') {
                            return "待盖章";
                        }else if (d.sign_status === 'd') {
                            return "盖章中";
                        }else if (d.sign_status === 'e') {
                            return "已完成";
                        }else if (d.sign_status === 'h') {
                            return "作废";
                        }else if (d.sign_status === 'i') {
                            return "已撤销";
                        }else if (d.sign_status === 'j') {
                            return "已过期";
                        }else if (d.sign_status === 'k') {
                            return "已拒签";
                        }
                        return "--";
                    },
                    expFormat: function (d) {
                        if (d.sign_status === 'f') {
                            return "待上传";
                        } else if (d.sign_status === 'g') {
                            return "已上传";
                        }else if (d.sign_status === '1') {
                            return "待签约";
                        }else if (d.sign_status === '2') {
                            return "已签约";
                        }else if (d.sign_status === '3') {
                            return "待审核";
                        }else if (d.sign_status === '4') {
                            return "签署驳回";
                        }else if (d.sign_status === '5') {
                            return "已审核";
                        }else if (d.sign_status === '6') {
                            return "待生成";
                        }else if (d.sign_status === 'a') {
                            return "承租人已签";
                        }else if (d.sign_status === 'b') {
                            return "签署中";
                        }else if (d.sign_status === 'c') {
                            return "待盖章";
                        }else if (d.sign_status === 'd') {
                            return "盖章中";
                        }else if (d.sign_status === 'e') {
                            return "已完成";
                        }else if (d.sign_status === 'h') {
                            return "作废";
                        }else if (d.sign_status === 'i') {
                            return "已撤销";
                        }else if (d.sign_status === 'j') {
                            return "已过期";
                        }else if (d.sign_status === 'k') {
                            return "已拒签";
                        }
                        return "--";
                    }
                }
                , {field: 'id_code', title: '身份证号',minWidth: 180, sort: false, align: 'center', exportable:true}
                , {field: 'address', title: '安装地址',minWidth: 300, sort: false, align: 'center',exportable:true}
                , {field: 'powerStationAmount', title: '电站金额',minWidth: 300, sort: false, align: 'center',exportable:true}
                , {field: 'partners_contract_number', title: '进件编号',minWidth: 300, sort: false, align: 'center',exportable:true}
                , {field: 'insurance_amount', title: '保单投保金额',minWidth: 300, sort: false, align: 'center',exportable:true,templet: function (d) {
                        if(isBlank(d.insurance_amount)){
                            return "--";
                        }else{
                            return d.insurance_amount
                        }
                    },
                    expFormat: function (d) {
                        if(isBlank(d.insurance_amount)){
                            return "--";
                        }else{
                            return d.insurance_amount
                        }
                    }
                }
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                , {field: 'traderName', title: '代理商名称', minWidth: 200, sort: false, align: 'center', exportable: true}
                </c:if>
                <c:if test="${'2' ne ifTop}">
                , {field: 'createTraderName',title: '二级代理商',minWidth: '200',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: 'engineer_name', title: '施工团队', minWidth: 150, align: 'center', exportable: true}

                , {
                    field: 'actual_capacity',
                    title: '实际安装容量(kW)',
                    minWidth: 150,
                    sort: false,
                    align: 'center',
                    exportable: true
                    ,templet: function (d) {
                        let num = d.actual_capacity / 1000;
                        return num;
                    },
                    expFormat: function (d) {
                        let num = d.actual_capacity / 1000;
                        return num;
                    }
                }

                , {
                    field: 'project_company_name',
                    title: '项目公司',
                    minWidth: '200',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'projectCode', title: '产品编码', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'projectName', title: '产品名称', minWidth: 130, sort: false, align: 'center', exportable: true}

                , {
                    field: 'create_time',
                    title: '登记时间',
                    minWidth: '180',
                    sort: false,
                    align: 'center',
                    exportable: true
                }
                , {field: 'in_coming_time', title: '进件时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'install_audit_finish_time', title: '安装提交验收时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'first_generation_time', title: '首日发电时间',minWidth: 180, sort: false, align: 'center',exportable:true}
            ]]
            ,exportOpt:{                           //导出选项配置
                ele:'#exportBtn',                   //导出的Dom元素
                headerTitle: '并网验收',             //excel表格的标题
                pageData:false,                     //true:导出的数据为页面数据，false:最大导出maxAmount条数据
                maxAmount: 5000,                    //当pageData为false生效
                fileName: '并网验收',
                where: function (){                 //当pageData为false时生效，过滤的条件
                    return _serializeJson($("#searchForm"));
                }
            },done: function(res, curr, count){
                //得到数据总量
                entrycount = count;
            }
        });

        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 === 'retrialBtn') {
                if(checkStatus.data.length < 1){
                    layer.msg("请先选择数据",{icon:5,anim:6});
                    return;
                }
                var ids = [];
                for(var i=0; i<checkStatus.data.length; i++){
                    if(checkStatus.data[i].create_trader_id != '${user.traderId}'){
                        layer.msg("第"+(i+1)+"条数据,没有整改权限!",{icon:5,anim:6});
                        return;
                    }
                    ids.push(checkStatus.data[i].id);
                }
                layer.open({
                    type: 2,
                    content: "${ctx}/customerEntry/applyChangeDetail?ids="+ids
                    ,title: "申请整改"
                    ,area:["50%","60%"]
                });


            }else  if (obj.event === 'exportfittingBtn') {
                if(entrycount<1){
                    layer.msg('当前无数据导出', {time: 1000});
                    return ;
                }

                let hideSubmitForm = document.createElement("form");
                hideSubmitForm.id = "tempForm1";
                hideSubmitForm.method = "post";
                hideSubmitForm.action = "${ctx}/excel/doExportUserExcel";
                hideSubmitForm.target = "_blank";
                hideSubmitForm.appendChild(createHideInput("status", "6,10"));
                hideSubmitForm.appendChild(createHideInput("projectId", isBlank($("#projectId").val())?"":$("#projectId").val()));
                hideSubmitForm.appendChild(createHideInput("powerStationCode", isBlank($("#powerStationCode").val())?"":$("#powerStationCode").val()));
                hideSubmitForm.appendChild(createHideInput("tenantName", isBlank($("#tenantName").val())?"":$("#tenantName").val()));
                hideSubmitForm.appendChild(createHideInput("tenantAddress", isBlank($("#tenantAddress").val())?"":$("#tenantAddress").val()));
                hideSubmitForm.appendChild(createHideInput("installWay", isBlank($("#installWay").val())?"":$("#installWay").val()));
                hideSubmitForm.appendChild(createHideInput("roofType", isBlank($("#roofType").val())?"":$("#roofType").val()));
                hideSubmitForm.appendChild(createHideInput("plan", isBlank($("#plan").val())?"":$("#plan").val()));
                hideSubmitForm.appendChild(createHideInput("flag", isBlank($("#flag").val())?"":$("#flag").val()));
                hideSubmitForm.appendChild(createHideInput("remarks", isBlank($("#remarks").val())?"":$("#remarks").val()));
                hideSubmitForm.appendChild(createHideInput("installEndEndTime",isBlank($("#endStartTime").val())?"": $("#endStartTime").val()));
                hideSubmitForm.appendChild(createHideInput("installEndEndTime", isBlank($("#endEndTime").val())?"":$("#endEndTime").val()));

                hideSubmitForm.addEventListener('onsubmit',function(){
                    // this.openDownloadWindow(name);
                });
                document.body.appendChild(hideSubmitForm);
                hideSubmitForm.submit();
                document.body.removeChild(hideSubmitForm);

                //  window.open("${ctx}/excel/doExportUserExcel?status=3&"+$("#searchForm"))
            }
        });

        table.on('tool(test)', function (obj) {
            var data = obj.data; //获得当前行数据
            var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
            var tr = obj.tr; //获得当前行 tr 的 DOM 对象（如果有的话）

            if (layEvent === 'viewContract') {
                window.open('${commonStaticImgPath}' + data.contract)
            } else if (layEvent === 'viewGdsContract') {
                window.open('${commonStaticImgPath}' + data.gsd_contract)
            } else if (layEvent === 'preInputEntry') {
                var nextApplyStatus=data.next_apply_status;
                if(nextApplyStatus !='WAITING'){
                    layer.msg("当前阶段无法进行并网信息推送",{icon:5,anim:6});
                    return;
                }
                //三次进件申请
                preInputEntry(data.id)
            }else if(layEvent === 'viewBill'){
                window.open('${commonStaticImgPath}' + data.bill)
            }  else if (layEvent === 'sureAccept') {
                //验收
                layer.open({
                    type: 2,
                    title: '验收报告',
                    content: '${ctx}/customerEntry/toMergeAccept?opt=TwoMergeAccept&id=' + data.id,
                    area: ['100%', '100%']
                });
            }


        });

        function createHideInput(name, value) {
            let hideInput = document.createElement("input");
            hideInput.type = "hidden";
            hideInput.name = name;
            hideInput.value = value;
            return hideInput;
        };

        //监听搜索
        form.on('submit(LAY-user-back-search)', function(data){
            var field = data.field;
            //执行重载
            tableExt.reload('test', {
                where: field,
                page:{
                    curr:1
                }
            });
        });

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

    function downloadReport(id){
        layer.open({
            type: 2,
            title: '验收报告',
            content: '${ctx}/customerEntry/toMergeAccept?opt=view&id=' + id,
            area: ['90%', '90%']
        });
    }

    function downloadAttach(attach) {
        attach = decodeURI(attach);
        attach = attach.replace(/\+/g, "%2B"); //
        window.location.href = '${commonStaticImgPath}' + attach;
    }

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

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

            }
        });
    }

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

    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 planDetail(entryId){
        layer.open({
            type: 2,
            title: '查看',
            content: '${ctx}/planManage/viewMatchedPlan?entryId=' + entryId,
            area: ['80%','80%']
        });
    }

    function margeAccept(id){
        layer.open({
            type: 2,
            title: '验收报告',
            content: '${ctx}/customerEntry/toMergeAccept?opt=merge&id=' + id,
            area: ['90%', '90%']
        });
    }

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

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

    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  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 "/";
        }
    }
</script>
</body>
</html>

