<%@ 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" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no, minimum-sacle=1, maximum-scale=1" >

    <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" />
    <style>
        .xm-select-parent .xm-select {
            min-height: 32px;
        }
    </style>
</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="GFXMGL_LSDZXX_T" html='<a href="${ctx}/customerEntry/historyEntryManagement"><li class="layui-this">历史电站信息</li></a>'/>
                <sfTags:pagePermission authFlag="GFXMGL_LSDZSHCX_T" html='<a href="${ctx}/customerEntry/historyEntryJjsh"><li>历史电站审核查询</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-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" >
                    </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">
                    </div>
                </div>
                <div class="layui-col-lg2 layui-col-sm3" style="width: 33.3%">
                    <label class="layui-form-label">代理商名称：</label>
                    <div class="layui-input-block" >
                        <input type="text" name="traderName" id="traderName" 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="customerState" id="customerState">
                            <option value="">请选择</option>
                            <option value="10">待进件</option>
                            <option value="20">审核中</option>
                            <option value="30">成功</option>
                            <option value="40">失败</option>
                            <option value="50">审核不通过</option>
                            <option value="60">进行中</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="stationState" id="stationState">
                            <option value="">请选择</option>
                            <option value="10">待进件</option>
                            <option value="20">审核中</option>
                            <option value="30">成功</option>
                            <option value="40">失败</option>
                            <option value="50">审核不通过</option>
                            <option value="60">进行中</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="mobile" id="mobile" class="layui-input" >
                    </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" readonly name="inComingTimeSta" class="layui-input" id="inComingTimeSta" placeholder="开始日期">--%>
<%--                        </div>--%>
<%--                        <div class="layui-col-xs2 text-c lh-30">--%>
<%--                            —--%>
<%--                        </div>--%>
<%--                        <div class="layui-col-xs5">--%>
<%--                            <input type="text" readonly name="inComingTimeEnd" class="layui-input" id="inComingTimeEnd" placeholder="结束日期">--%>
<%--                        </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" readonly name="fixAcceptTimeSta" class="layui-input" id="fixAcceptTimeSta" placeholder="开始日期">--%>
<%--                        </div>--%>
<%--                        <div class="layui-col-xs2 text-c lh-30">--%>
<%--                            —--%>
<%--                        </div>--%>
<%--                        <div class="layui-col-xs5">--%>
<%--                            <input type="text" readonly name="fixAcceptTimeEnd" class="layui-input" id="fixAcceptTimeEnd" placeholder="结束日期">--%>
<%--                        </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" readonly name="checkAcceptTimeMin" class="layui-input" id="acceptEndStartTime" placeholder="开始日期">--%>
<%--                        </div>--%>
<%--                        <div class="layui-col-xs2 text-c lh-30">--%>
<%--                            —--%>
<%--                        </div>--%>
<%--                        <div class="layui-col-xs5">--%>
<%--                            <input type="text" readonly name="checkAcceptTimeMax" class="layui-input" id="acceptEndEndTime" placeholder="结束日期">--%>
<%--                        </div>--%>
<%--                    </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" name="address" class="layui-input">--%>

<%--                    </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>
            <script type="text/html" id="toolbarDemo">
                <div class="layui-btn-container">
<%--                    <sfTags:pagePermission authFlag="" html='<button class="layui-btn layui-btn-sm" lay-event="editKHBtn" id="editKHBtn"><i class="layui-icon layui-icon-ok-circle"></i>编辑客户信息</button>'/>--%>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_EDITKC_B" html='<button class="layui-btn layui-btn-sm" lay-event="editKCBtn" id="editKCBtn"><i class="layui-icon layui-icon-ok-circle"></i>编辑勘测信息</button>'/>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_EDITWG_B" html='<button class="layui-btn layui-btn-sm" lay-event="editWGBtn" id="editWGBtn"><i class="layui-icon layui-icon-ok-circle"></i>编辑完工信息</button>'/>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_EDITBW_B" html='<button class="layui-btn layui-btn-sm" lay-event="editBWBtn" id="editBWBtn"><i class="layui-icon layui-icon-ok-circle"></i>编辑并网信息</button>'/>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_ZTTB_B" html='<button class="layui-btn layui-btn-sm" lay-event="tbStatusBtn" id="tbStatusBtn"><i class="layui-icon layui-icon-ok-circle"></i>状态同步</button>'/>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_INPUTKH_B" html='<button class="layui-btn layui-btn-sm" lay-event="inputKHBtn" id="inputKHBtn"><i class="layui-icon layui-icon-ok-circle"></i>推送客户信息</button>'/>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_INPUTDZ_B" html='<button class="layui-btn layui-btn-sm" lay-event="inputDZBtn" id="inputDZBtn"><i class="layui-icon layui-icon-ok-circle"></i>推送电站信息</button>'/>
                    <sfTags:pagePermission authFlag="GFXMGL_LSDZXX_DCLB_B" html='<button class="layui-btn layui-btn-sm" lay-event="export" id="exportBtn"><i class="layui-icon layui-icon-export"></i>导出列表</button>'/>
            </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>
    var formSelects;
    var entrycount=0;
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'tableExt', 'jquery', 'layer','laypage','laydate','form','formSelects'], function(){
        $ = layui.$;
        tableExt = layui.tableExt;
        layer = layui.layer;
        laypage = layui.laypage;
        laydate = layui.laydate;
        form = layui.form;
        table = tableExt.getLayTable();
        formSelects = layui.formSelects;
        var type = "${user.userType}";

        var downloadReport = '${fns:checkPagePermission(request, "XMGL_XMCX_XMCX_XZYSBG_B")}';
        //  var downloadForm = '${fns:checkPagePermission(request, "XMGL_XMCX_XMCX_XZJFQSB_B")}';

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


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

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

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

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

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

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

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

        function  applyStatusStr(applyStatus){
            if(applyStatus == '10'){
                return "待进件";
            }else if(applyStatus == '20'){
                return "审核中";
            }else if(applyStatus == '30'){
                return "成功";
            }else if(applyStatus == '40'){
                return "失败";
            }else if(applyStatus == '50'){
                return "审核不通过";
            }else if(applyStatus == '60'){
                return "进行中";
            }else {
                return "/";
            }
        }

        function getStatus(d) {
            var status =d.status;

            if (status == '0') {
                //预审状态 0.暂存 1.待预审 2.预审待审批 3.预审审批中 4.预审通过 5.预审拒绝
                if(d.credit=='1'){
                    return '待预审';
                }
                if(d.credit=='2'){
                    return '预审审批中';
                }
                if(d.credit=='3'){
                    return '预审审批中';
                }
                if(d.credit=='4'){
                    if(d.design_audit_flag == '3'){
                        return '自审驳回';
                    }
                    else if(d.design_audit_flag == 'a'){
                        return '待设计';
                    } else {
                        return '待踏勘';
                    }
                }
                if(d.credit=='5'){
                    return '预审拒绝';
                }
                return '暂存';
            }
            if (status == '1') {
                //设计审核状态：1.待踏勘 2.待自审 3.自审驳回 4.自审通过 5.设计审核驳回 6.设计审核通过/已完成 7.进件审核驳回
                if(d.design_audit_flag=='1'){
                    return '待踏勘';
                }else if(d.design_audit_flag=='2'){
                    return '待自审';
                }else if(d.design_audit_flag == 'a'){
                    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 '进件审核驳回';
                }
                return '待审核';
            }
            if (status == '2') {
                return '审核驳回';
            }
            if (status == '3') {
                return '待下单';
            }
            if (status == '4') {
                if (d.install_flag == '1'){
                    return '待派工';
                }else if (d.install_flag == '2'){
                    return '待安装';
                }else if (d.install_flag == '3'){
                    return '自审驳回';
                }else if (d.install_flag == '4'){
                    return '安装完成';
                }

            }
            if(status == '5'){
                return '待安装验收';
            }
            if(status == 'f'){
                return '安装验收退回';
            }
            if(status == '6'){
                return '待并网';
            }
            if(status == '7'){
                return '待并网验收';
            }
            if(status == '8'){
                return '待交付';
            }
            if(status == '9'){
                return '待归档';
            }
            if(status == '10'){
                return '验收驳回';
            }
            if(status == '11'){
                return '归档驳回';
            }
            if(status == 'a'){
                return '已完成';
            }if(status == 'c'){
                return '待代理商确认';
            }
            // if(status == 'd'){
            //     return '待上传发票';
            // }
            if(status == 'e'){
                return '待签署合同';
            }
            if(status == 'w'){
                return '信息登记';
            }
            if(status == 'g'){
                return '设计审核';
            }
            if(status == 'AN'){
                return '待安装确认';
            }
            if(status == 'AT'){
                return '安装确认驳回';
            }
            if(status == 'BW'){
                return '待并网确认';
            }
            if(status == 'BN'){
                return '并网确认驳回';
            }
            if(status == 'h'){
                return '设计自审';
            }
            if(status == 'i'){
                return '安装自审';
            }
        }

        tableExt.render({
            elem: '#test'
            , title:'历史电站信息'
            , height: 'full-180'
            , toolbar: '#toolbarDemo'
            , defaultToolbar: false
            , limits : [ 20, 50, 100 ]
            , limit:20
            , page : true //开启分页
            , url: '${ctx}/customerEntry/getHistoryEntryList'
            , where: _serializeJson($("#searchForm"))
            , method:"post"
            , cols: [[
                {type: 'numbers',fixed:'left',title:'序号'}
                ,{field : 'id', minWidth : '4%',checkbox : true,align : 'center',fixed: 'left'}
                , {field: 'power_station_code', title: '电站编码',minWidth: 200, sort: false, align: 'center',fixed:'left',
                    exportable: true
                    ,templet: function (d) {
                        var html="";
                        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, align: 'center',fixed:'left', exportable: true}
                // , {field: 'entryStratus', title: '电站状态', minWidth: 120, align: 'center', exportable: true,fixed:'left',
                //     templet: function(d){
                //         return getStatus(d);
                //     },
                //     expFormat: function(d){
                //         return getStatus(d);
                //     }}
                , {field: 'customer_state', title: '客户信息状态', minWidth: 130, align: 'center', exportable: true
                    , templet:function(d){
                        return applyStatusStr(d.customer_state);
                    }
                    , expFormat: function(d){
                        return applyStatusStr(d.customer_state);
                    }
                }
                , {field: 'station_state', title: '电站档案状态', minWidth: 130, align: 'center', exportable: true
                    , templet:function(d){
                        return applyStatusStr(d.station_state);
                    }
                    , expFormat: function(d){
                        return applyStatusStr(d.station_state);
                    }
                }
                <c:if test="${user.userType ne '6' && user.userType ne '7'}">
                , {field: 'traderName', title: '代理商名称', minWidth: 280, sort: false, align: 'center', exportable: true}
                </c:if>
                , {field: 'mobile', title: '联系方式', minWidth: 130, sort: false, align: 'center', exportable: true}
                , {field: 'id_code', title: '身份证号', minWidth: 200, sort: false, align: 'center', exportable: true}
                , {field: 'address', title: '安装地址', minWidth: 300, sort: false, align: 'center', exportable: true}
                , {
                    field: 'province',
                    title: '电站名称',
                    minWidth: '300',
                    sort: false,
                    align: 'center',
                    exportable: true,
                    templet: function (d) {
                       return d.province + '' + d.area + d.tenant_name + d.actual_capacity  + "KW光伏电站";
                    },
                    expFormat: function (d) {
                       return d.province + '' + d.area + d.tenant_name + d.actual_capacity  + "KW光伏电站";
                    }
                }
                , {field: 'project_id', title: '产品编号',minWidth: 130, sort: false, align: 'center',exportable:true}
                , {field: 'project_company_name',title: '项目公司',minWidth: '220',sort: false,align: 'center',exportable: true}
                , {field: 'component_spec', title: '安装组件规格',minWidth: 150, sort: false, align: 'center',exportable:true,  templet:function(d){
                        if(isBlank(d.componentSpec)){
                            return d.component_spec;
                        }else {
                            return d.componentSpec;
                        }
                    },
                    expFormat: function (d) {
                        if (isBlank(d.componentSpec)) {
                            return d.component_spec;
                        } else {
                            return d.componentSpec;
                        }
                    }
                }
                , {field: 'component_num', title: '安装组件块数',minWidth: 150, sort: false, align: 'center',exportable:true}
                , {field: 'actual_capacity', title: '实际安装容量（kW）',minWidth: 180, sort: false, align: 'center',exportable:true
                    ,templet: function (d) {
                        let num = d.actual_capacity;
                        return num;
                    },
                    expFormat: function (d) {
                        let num = d.actual_capacity;
                        return num;
                    }
                }
                , {field: 'generator_no', title: '发电户号',minWidth: 150, sort: false, align: 'center',exportable:true}
                , {field: 'creator', title: '业务员',minWidth: 150, sort: false, align: 'center',exportable:true}
                , {field: 'create_time', title: '登记时间',minWidth: 180, sort: false, 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: 'examine_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: 'install_accept_time', title: '安装验收时间',minWidth: 180, sort: false, align: 'center',exportable:true}
                , {field: 'first_generation_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}
            ]]
            ,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;
                // $('span[data-oneself="oneselfFlag"]').parent().parent().parent().css('background-color', '#E2D5D2');
            }
        });

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

        }

        table.on('toolbar(test)',function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            if (obj.event === 'editKHBtn') {//编辑客户信息
                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;
                layer.open({
                    type: 2,
                    content: "${ctx}/nhPowerStation/editCustomerInfo?entryId=" + entryId
                    , title: '编辑客户信息'
                    ,area: ['100%', '100%']
                    , cancel: function () {
                        searchOrder();
                    }
                });
            }else if(obj.event === 'editKCBtn'){//编辑勘测设计信息
                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;
                layer.open({
                    type: 2,
                    content: "${ctx}/nhPowerStation/editSurveyRecordInfo?entryId=" + entryId
                    , title: '编辑勘测信息'
                    ,area: ['100%', '100%']
                    , cancel: function () {
                        searchOrder();
                    }
                });
            }else  if (obj.event === 'editWGBtn') {//编辑完工
                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;
                layer.open({
                    type: 2,
                    content: "${ctx}/nhPowerStation/editWGInfo?entryId=" + entryId
                    , title: '编辑完工信息'
                    ,area: ['100%', '100%']
                    , cancel: function () {
                        searchOrder();
                    }
                });
            }else  if (obj.event === 'editBWBtn') {//编辑并网
                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;
                layer.open({
                    type: 2,
                    content: "${ctx}/nhPowerStation/editBWInfo?entryId=" + entryId
                    , title: '编辑并网信息'
                    ,area: ['85%', '85%']
                    , cancel: function () {
                        searchOrder();
                    }
                });
            }else  if (obj.event === 'tbStatusBtn') {//同步状态
                if (checkStatus.data.length < 1) {
                    layer.msg("请先选择数据", {icon: 5, anim: 6});
                    return;
                }
                var ids = [];
                for(var i=0; i<checkStatus.data.length; i++){
                    ids.push(checkStatus.data[i].id);
                }
                var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
                $.ajax({
                    type:"POST",
                    url:"${ctx}/nhPowerStation/tbStatus",
                    contentType: 'application/json',
                    data:JSON.stringify(ids),
                    success:function(res){
                        if(res.code=="200"){
                            layer.close(index);
                            layer.msg('同步成功！', {icon: 1,time:1000}, function () {
                                searchOrder();
                            });
                        } else{
                            layer.msg(res.errMsg,{time:1000});
                            layer.close(index);
                        }
                    },
                    error:function (data) {
                        layer.close(index);
                    }
                }) ;
            }else  if (obj.event === 'inputKHBtn') {//推送客户信息
                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;
                let customerState = checkStatus.data[0].customer_state;
                if (customerState == '20' || customerState == '30' || customerState == '60') {
                    layer.msg("当前电站状态不可推送客户信息", {icon: 5, anim: 6});
                    return;
                }
                var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
                $.ajax({
                    type:"POST",
                    url:"${ctx}/nhPowerStation/inputCustomerInfo",
                    data:{
                        entryId:entryId
                    },
                    success:function(res){
                        if(res.code=="200"){
                            layer.msg('同步成功！', {icon: 1, time: 1000}, function () {
                                layer.close(index);
                                searchOrder();
                            });
                        } else{
                            layer.msg(res.errMsg,{time:1000});
                            layer.close(index);
                        }
                    },
                    error:function (data) {
                        layer.close(index);
                    }
                }) ;
            }else  if (obj.event === 'inputDZBtn') {//推送电站信息
                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;
                let customerState = checkStatus.data[0].customer_state;
                if (customerState == '10' || customerState == '40') {
                    layer.msg("当前电站状态不可推送电站信息", {icon: 5, anim: 6});
                    return;
                }
                let stationState = checkStatus.data[0].station_state;
                if (stationState == '20' || stationState == '30' || stationState == '60') {
                    layer.msg("当前电站状态不可推送电站信息", {icon: 5, anim: 6});
                    return;
                }
                var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
                $.ajax({
                    type:"POST",
                    url:"${ctx}/nhPowerStation/inputStockEntryInfo",
                    data:{
                        entryId:entryId
                    },
                    success:function(res){
                        if(res.code=="200"){
                            layer.msg('推送成功！', {icon: 1, time: 1000}, function () {
                                layer.close(index);
                                searchOrder();
                            });
                        } else{
                            layer.msg(res.errMsg,{time:1000});
                            layer.close(index);
                        }
                    },
                    error:function (data) {
                        layer.close(index);
                    }
                }) ;
            }

        });
        //监听搜索
        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 downloadAttach(attach) {
        attach = decodeURI(attach);
        attach = attach.replace(/\+/g, "%2B"); //
        window.location.href = '${commonStaticImgPath}' + attach;
    }

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

    function deliver() {

    }

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

            }
        });
    }

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

    function downloadImg(attach) {
        var name = attach.substring(0, attach.lastIndexOf(".") - 1);
        var suffix = attach.substring(attach.lastIndexOf("."));
        window.open('${commonStaticImgPath}'+attach)
        // location.href = '${ctx}/technical/imgDownload?path=' + '${commonStaticImgPath}' + attach + "&fileGS=" + suffix + "&name=" + name;
    }

    function inDoc(id){

    }
    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'); //数据刷新
            }
        });
    }
</script>
</body>
</html>

