<%@ 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_XMGL_DJJSH_T" html='<a href="${ctx}/customerEntry/customerListJjsh"><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>
        <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="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>
                            <option value="23">并网发电审核中</option>
                        </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="jjPowerStationCode" class="layui-input" >
                    </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="customerAddress"
                                   autocomplete="off" class="layui-input layui-col-lg2 "
                                   value="${entry.customerAddress}">

                        </div>
                    </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="examineRemarks" 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>
            </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">
                    <button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出列表</button>
                    <c:if test="${user.userType eq '1'}">
                        <button class="layui-btn layui-btn-sm" lay-event="uploadFile" id="uploadFile"><i class="layui-icon layui-icon-auz"></i>推送附件</button>
                    </c:if>
                    <sfTags:pagePermission authFlag="JJGL_JJGL_ZTTB_B"
                                           html='<button class="layui-btn layui-btn-sm" lay-event="tbStatus" id="tbStatus"><i class="layui-icon layui-icon-auz"></i>状态同步</button>'/>
                    <sfTags:pagePermission authFlag="JJGL_JJGL_JJXX_T"
                                           html='<button class="layui-btn layui-btn-sm" lay-event="oneIncoming" id="oneIncoming"><i class="layui-icon layui-icon-auz"></i>推送进件信息</button>'/>
                    <sfTags:pagePermission authFlag="JJGL_JJGL_TSJJ_T"
                                           html='<button class="layui-btn layui-btn-sm" lay-event="twoIncoming" id="twoIncoming"><i class="layui-icon layui-icon-auz"></i>推送完工信息</button>'/>
                    <sfTags:pagePermission authFlag="JJGL_JJGL_BWXX_T" html='<button class="layui-btn layui-btn-sm" lay-event="threeIncoming" id="threeIncoming"><i class="layui-icon layui-icon-auz"></i>推送并网信息</button>'/>
                    <%--<button class="layui-btn layui-btn-sm" lay-event="findFile" id="findFile"><i class="layui-icon layui-icon-auz"></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 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);
        }

        tableExt.render({
            elem: '#test'
            , title:'待进件审核'
            , height: 'full-190'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/getJjshCustomerList?partner=01'
            , method:"post"
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                , {type: 'checkbox', fixed: 'left'}
                , {field: 'partners_contract_number', title: '进件序号',minWidth: 180, align: 'center',fixed: 'left',exportable:true,
                    templet:function(d){
                        if(isBlank(d.partners_contract_number)){
                            return '';
                        }else {
                            return '<a href="#" class="layui-table-link" onclick="jjDetail(\''+d.id+'\')">'+d.partners_contract_number+'</a>';
                        }
                    },expFormat:function(d){
                        if(isBlank(d.partners_contract_number)){
                            return '';
                        }else {
                            return d.partners_contract_number;
                        }
                    }
                }
                , {field: 'apply_status', title: '进件状态', minWidth: 130, fixed: 'left', align: 'center', exportable: true
                    , templet:function(d){
                       return applyStatusStr(d.apply_status);
                    }
                    , expFormat: function(d){
                        return applyStatusStr(d.apply_status);
                    }
                }
                , {field: 'sign_status', title: '农户合同', minWidth: 150,  fixed: 'left',align: 'center',exportable:true ,
                    templet: function (d) {
                        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 "已审核";
                        }
                        return "--";
                    },
                    expFormat: function (d) {
                        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 "已审核";
                        }
                        return "--";
                    }
                }
                , {field: 'payment_status', title: '回款状态', minWidth: 130, fixed: 'left', align: 'center', exportable: true
                    , templet:function(d){
                        if (d.payment_status == '0'){
                            return "--";
                        }else if( d.payment_status == '1'){
                            return "等待放款";
                        }else if( d.payment_status == '2'){
                            return "请款完成";
                        }else if( d.payment_status == '3'){
                            return "已放款";
                        }else {
                            return "--"
                        }
                    }
                    , expFormat: function(d){
                        if (d.payment_status == '0'){
                            return "--";
                        }else if( d.payment_status == '1'){
                            return "等待放款";
                        }else if( d.payment_status == '2'){
                            return "请款完成";
                        }else if( d.payment_status == '3'){
                            return "已放款";
                        }else {
                            return "--"
                        }
                    }
                }
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, 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, align: 'center', fixed: 'left', exportable: true}
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                , {field: 'trader_name', title: '代理商名称', minWidth: 150, align: 'center', exportable: true}
                , {field: 'trader_tel', title: '代理商电话', minWidth: 100, align: 'center', exportable: true}
                </c:if>
                , {field: 'projectName', title: '产品名称',minWidth: 130, align: 'center',exportable:true}
                , {field: 'address', title: '安装地址', minWidth: 100, 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: 'companyName',title: '出租人',minWidth: '100',sort: false,align: 'center',exportable: true}
                , {field: 'create_time', title: '登记时间',minWidth: 180, align: 'center',exportable:true}
                , {field: 'pre_audit_time', title: '预审通过时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'in_coming_time', title: '进件时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'merge_time', title: '提交并网验收时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'check_accept_time', title: '并网验收时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'amount', title: '电站金额', minWidth: 150, align: 'center', exportable: true}
                , {field: 'actual_capacity', title: '电站安装容量', minWidth: 150, align: 'center', exportable: true}
                , {field: 'apply_back_time', title: '驳回时间', minWidth: 150, align: 'center', exportable: true}
                , {field: 'apply_back_reason', title: '驳回原因', minWidth: 150, align: 'center', exportable: true}

            ]] ,done:function(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: 20000,                    //当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 if(applyStatus == '23'){
                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 '';
            }
        }

        function managementTypeStr(managementType){
            switch (managementType){
                case '3001':
                    return '广州越秀融资租赁有限公司';
                case '3074':
                    return '广州越秀能辉投资有限公司';
                case '3081':
                    return '广州越能光伏科技有限公司';
                case '3093':
                    return '广州越能光伏科技有限公司';
                default:
                    return '';
            }
        }

        table.on('toolbar(test)',function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if (obj.event === 'uploadFile') {
                layer.open({
                    type: 2,
                    content: "${ctx}/customerEntryExtra/toUploadFilePage"
                    ,title: "推送附件"
                    ,area:["50%","50%"]
                });
            } else if (obj.event === 'findFile') {
                layer.open({
                    type: 2,
                    content: "${ctx}/customerEntryExtra/toFindFileStatus"
                    ,title: "附件推送状态"
                    ,area:["40%","40%"]
                });
            }else if(obj.event ==='tbStatus'){
                if (checkStatus.data.length < 1) {
                    layer.msg("请先选择数据", {icon: 5, anim: 6});
                    return;
                }
                if (checkStatus.data.length > 1) {
                    layer.msg("只能选择数据一条数据", {icon: 5, anim: 6});
                    return;
                }
                var entryId =checkStatus.data[0].id;
                var powerStationCode=checkStatus.data[0].power_station_code;
                $.ajax({
                    type:"POST",
                    url:"${ctx}/customerEntry/queryDocumentStatus",
                    data:{
                        entryId:entryId
                        ,powerStationCode:powerStationCode
                    },
                    success:function(res){
                        console.log(res+'----');
                        if(res.code=="200"){
                            layer.msg('同步成功！', {icon: 1, time: 1000}, function () {
                                searchOrder();
                            });
                        } else{
                            layer.msg(res.errMsg,{time:2000});
                        }
                    },
                    error:function (data) {
                    }
                }) ;

            }else if(obj.event ==='tbGfStatus'){
                if (checkStatus.data.length < 1) {
                    layer.msg("请先选择数据", {icon: 5, anim: 6});
                    return;
                }
                if (checkStatus.data.length > 1) {
                    layer.msg("只能选择数据一条数据", {icon: 5, anim: 6});
                    return;
                }
                var entryId =checkStatus.data[0].id;
                $.ajax({
                    type:"POST",
                    url:"${ctx}/customerEntry/queryGuangFaStatus",
                    data:{
                        entryId:entryId
                    },
                    success:function(res){
                        console.log(res+'----');
                        if(res.code=="200"){
                            layer.msg('同步成功！', {icon: 1, time: 1000}, function () {
                                searchOrder();
                            });
                        } else{
                            layer.msg(res.errMsg,{time:2000});
                        }
                    },
                    error:function (data) {
                    }
                }) ;

            }else if(obj.event ==='oneIncoming' || obj.event ==='twoIncoming' || obj.event ==='threeIncoming'){
                if (checkStatus.data.length < 1) {
                    layer.msg("请先选择数据", {icon: 5, anim: 6});
                    return;
                }
                if (checkStatus.data.length > 1) {
                    layer.msg("只能选择数据一条数据", {icon: 5, anim: 6});
                    return;
                }
                var entryId =checkStatus.data[0].id;
                var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
                $.ajax({
                    type:"POST",
                    url:"${ctx}/incomingManagement/againPushIncoming",
                    data:{
                        entryId:entryId
                        ,type:obj.event
                    },
                    success:function(res){
                        console.log(res+'----');
                        if(res.code=="200"){
                            layer.msg('同步成功！', {icon: 1, time: 2000}, function () {
                                layer.close(index);
                                searchOrder();
                            });
                        } else{
                            layer.msg(res.errMsg,{time:2000});
                            layer.close(index);
                        }
                    },
                    error:function (data) {
                        layer.close(index);
                    }
                }) ;

            }
        })

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

        });
        //监听搜索
        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 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 + '" >' + area.columns.DistrictName + '</option>';
                }
                $("#area").append(html);
                if (!isBlank(arean)) {
                    $("#area").val(arean)
                }

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

    }


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

    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: ['65%','88%']
        });
    }

    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 Prohibit(id){
        layer.open({
            type: 2,
            content: "${ctx}/customerEntry/toExamineForm?entryId="+id //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
            ,area: ['65%','88%']
            ,title: '审核信息' //不显示标题栏
            ,shade: 0.8
            ,btnAlign: 'c'
            ,scrollbar:false
        });
    }

    function examineInputEntry(id){
        layer.open({
            type: 2,
            title: '进件申请',
            content: '${ctx}/customerEntryExtra/examineInputEntryPage?id='+id,
            area: ['65%','88%']
        });
    }
    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 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>

