<%@ 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/dist/viewer.css" media="all">
    <style>
        html {
            background-color: #fff;
            padding-bottom: 50px;
        }
        .form-span {
            display: block;
            padding: 8px 0;
            margin-left: 110px;
        }

        .page-iframe {
            border: none;
            width: 100%;
            min-height: calc(100vh - 250px);
        }
        .mb-10{
            margin-bottom: 10px !important;
        }
        .pd-10{
            padding: 10px;
        }
        .idea-text{
            width: 320px; height: 100px;outline: none; padding: 3px
        }
        .msg-title{
            text-align: center;
            margin: 10px 0;
            font-size: 16px;
        }
        .title1 {
            border-left: 4px solid #1b6073;
            padding-left: 20px;
            font-size: 14px;
            margin: 10px auto;
            font-weight: 600;
            height: 34px;
            line-height: 34px;
            background-color: #f4f6f9;
            color: #666666;
        }
        .layui-input-block {
            margin-left: 110px;
        }

        .layui-form-label {
            width: 110px;
        }
        .clearfix{*zoom:1;}
        .clearfix:before,.clearfix:after{display:table; line-height:0; content:"";}
        .clearfix:after{clear:both;}

        .layui-tab-title{
            margin: 0 0 0 20px;
        }
        .layui-tab-content{
            margin: 0 0 0 20px;
        }
        .bj-img {
            margin-right: 5px;
        }
        .blank-img {
            background: url('${ctxPlugin}/static/imgs/blankImg.png') center center no-repeat;
            width: 80px;
            height: 80px;
            display: inline-block;
        }
        .link-blue{ color: #1b6073; cursor: pointer;}
        .two-col {
            display: flex;
        }
        .two-col .scheme-item,.component-item {
            padding-right: 20px;
            flex-grow: 1;
            flex-shrink: 1;
            flex-basis: 0;
        }
        .two-col .design-item {
            flex-grow: 1;
            flex-shrink: 1;
            padding-right: 20px;
            flex-basis: 0;
        }
        div.sep {
            border-bottom: 1px dashed #ccc;
            padding-top: 10px;
            clear: both;
            margin-bottom: 10px;
        }
        .two-col .design-doc {
            flex-grow: 1;
            flex-shrink: 1;
            padding-right: 20px;
            flex-basis: 0;
        }
        .design-item-title {
            margin-bottom: 10px;
        }
    </style>
</head>
<body>
<div class="layui-fluid pd-10">
    <div class="order-win layui-form">
        <div class="layui-card-body pt-20 pb-40">
            <div class="layui-col-xs12 form-box">
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">电站编码：</label>
                    <div class="layui-input-block ">
                        <input type="text" autocomplete="off"  name="stationCode" lay-verify="stationCode" class="layui-input" value="" disabled>
                        <input type="text" style="width: 78%;float: left;"  id="stationId" lay-verify="stationCode" class="layui-input hide" value="">
                        <a href="#" class="pos-a h-32 lh-32 layui-span-unit pl-10 layui-table-link" onclick="selectEntry('${partnerId}')" style="font-size: 20px">+</a>
<%--                        <button type="button" class="layui-btn layui-btn-sm" onclick="searchCode()">--%>
<%--                            <i class="layui-icon">&#xe615;</i>--%>
<%--                        </button>--%>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">电站状态：</label>
                    <div class="layui-input-block ">
                        <input type="text"  name="status" class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">代理商：</label>
                    <div class="layui-input-block ">
                        <input type="text" name="traderName" class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">产品名称：</label>
                    <div class="layui-input-block ">
                        <input type="hidden" id="projectId" value="">
                        <input type="text" name="projectName"  class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">项目公司：</label>
                    <div class="layui-input-block ">
                        <input type="text" name="projectCompanyName" class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">所属资方：</label>
                    <div class="layui-input-block ">
                        <input type="text" name="partnerName" class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">业主姓名：</label>
                    <div class="layui-input-block ">
                        <input type="text" name="tenantName"  class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs3">
                    <label class="layui-form-label w-130">身份证号：</label>
                    <div class="layui-input-block ">
                        <input type="text" name="idCode" class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs9">
                    <label class="layui-form-label w-130">安装地址：</label>
                    <div class="layui-input-block ">
                        <input type="text" name="address" class="layui-input" value="" disabled>
                    </div>
                </div>
                <div class="layui-inline layui-col-xs12">
                    <label class="layui-form-label w-130">变更原因：</label>
                    <div class="layui-input-block ">
                        <textarea name="reason" id="reason" placeholder="" class="layui-textarea"></textarea>
<%--                        <input type="text" name="reason" id="reason" class="layui-input" value="">--%>
                    </div>
                </div>
            </div>
        </div>
        <div class="clear-both">
            <p class="layui-elem-quote" style="margin: 0px 0px 0px 10px">设计方案信息</p>
            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief" id="LAY_app">

                <div class="layui-tab-content two-col" style="padding: 0">
                    <div class="scheme-item">
                        <div>变更前方案：</div>
                        <table class="layui-table">
                            <thead>
                            <th>方案类型</th>
                            <th>方案名称</th>
                            </thead>
                            <tbody id="contentBody">
                            <tr>
                                <td id="schemeTypeName">-</td>
                                <td id="schemeName">-</td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div class="scheme-item">
                        <div>变更后方案：</div>
                        <table class="layui-table">
                            <thead>
                            <th>方案类型</th>
                            <th>方案名称</th>
                            </thead>
                            <tbody id="contentBody2">
                            <tr>
                                <td>
                                    <select lay-filter="planType" name="planType" class="planType" lay-search>
                                        <option value="">请选择</option>
                                    </select>
                                </td>
                                <td>
                                    <select lay-filter="planName" name="planName" class="planName" lay-search>
                                        <option value="">请选择</option>
                                    </select>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>

                <div class="sep"></div>

                <div class="layui-tab-content  two-col" style="padding: 0">
                    <div class="component-item">
                        <div>变更前物料：</div>
                        <table class="layui-table" id="preComponentTable">
                            <thead>
                            <th>序号</th>
                            <th>物料类型</th>
                            <th width="50%">物料规格</th>
                            <th>数量</th>
                            </thead>
                            <tbody id="preComponentTableContent">
                            </tbody>
                        </table>
                        <div>变更前设计安装容量：<span id="preDesignCapacity">-</span>kW</div>
                    </div>
                    <div class="component-item">
                        <div>变更后物料：</div>
                        <table class="layui-table">
                            <thead>
                            <th width="50">序号</th>
                            <th width="100">物料类型</th>
                            <th>物料规格</th>
                            <th width="80">数量</th>
                            <th width="70">操作</th>
                            </thead>
                            <tbody id="postComponentTableContent">
                            </tbody>
                        </table>
                        <div>变更后设计安装容量：<span id="postDesignCapacity">-</span>kW</div>
                    </div>
                </div>

                <div class="sep"></div>

                <div class="layui-tab-content two-col" style="padding: 0;margin-top: 5px;">
                    <div class="design-doc">
                        <div class=" design_drawings change hide">
                        变更前<i class="design_drawings_name">设计图纸：</i>
                        <div id="preDocs">

                        </div>
                        </div>
                        <div class="zjpb_img change hide">
                            变更前<i class="zjpb_img_name">组件排布图：</i>
                        <div id="zjpb_img_pre">

                        </div>
                        </div>
                        <div  class="zjzx_img change hide">
                            变更前<i class="zjzx_img_name">组件接线图：</i>
                        <div id="zjzx_img_pre">

                        </div>
                        </div>
                        <div  class="zjcs_img change hide">
                            变更前<i class="zjcs_img_name">组件支架图：</i>
                        <div id="zjcs_img_pre">

                        </div>
                        </div>
                        <div  class="zjhs_img change hide">
                            变更前<i class="zjhs_img_name">一次接线图/电气图：</i>
                        <div id="zjhs_img_pre">

                        </div>
                        </div>
                    </div>
                    <div class="design-doc">
                        <div class="design_drawings change hide">
                            变更后<i class="design_drawings_name">设计图纸：</i><span style="color:blue;cursor: pointer" id="attachFilesUploader">上传</span>
                            <div style="color:#aaa;font-size:12px;" id="design_drawings_reson"></div>
                            <div id="postDocs">

                            </div>
                        </div>

                        <div class="zjpb_img change hide">
                            变更后<i class="zjpb_img_name">组件排布图：</i><span style="color:blue;cursor: pointer" id="zjpbImgUploader">上传</span>
                            <div style="color:#aaa;font-size:12px;" id="zjpb_img_reson"></div>
                        <div id="zjpb_img_post">

                        </div>
                        </div>
                        <div  class=" zjzx_img change hide">
                            变更后<i class="zjzx_img_name">组件接线图：</i><span style="color:blue;cursor: pointer" id="zjzxImgUploader">上传</span>
                            <div style="color:#aaa;font-size:12px;" id="zjzx_img_reson"></div>
                        <div id="zjzx_img_post">

                        </div>
                        </div>
                        <div  class=" zjcs_img change hide">
                            变更后<i class="zjcs_img_name">组件支架图：</i><span style="color:blue;cursor: pointer" id="zjcsImgUploader">上传</span>
                            <div style="color:#aaa;font-size:12px;" id="zjcs_img_reson"></div>
                        <div id="zjcs_img_post">

                        </div>
                        </div>
                        <div  class=" zjhs_img  change hide">
                            变更后<i class="zjhs_img_name">一次接线图/电气图：</i><span style="color:blue;cursor: pointer" id="zjhsImgUploader">上传</span>
                            <div style="color:#aaa;font-size:12px;" id="zjhs_img_reson"></div>
                        <div id="zjhs_img_post">

                        </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="layui-form-item text-c operate-footer">
    <button type="button" class="layui-btn" id="save">提交</button>
    <button class="layui-btn layui-btn-primary" onclick="closeSelf()">取消</button>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.js"></script>
<script>
    //图片查看效果
    let form = null;
    let entry = null;
    let formSet = null;
    let info2 = null;
    let preComponents = [];
    var viewer = new Viewer(document.getElementById('LAY_app'));
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'jquery', 'layer','upload','form'], function () {
        $ = layui.$;
        layer = layui.layer;
        upload = layui.upload;
        form = layui.form;

        upload.render({
            elem: '#attachFilesUploader',
            url: '${ctx}/common/uploadFile3',
            accept: 'file',
            exts: 'pdf|dwg',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                let size = $('#postDocs').find('a').size();
                if (size >= 4) {
                    layer.msg('最多只能上传4个文件')
                    return false;
                }
            },
            done: function (res) {
                //上传完毕回调
                let imgCount = $('#postDocs').find('a').size();
                if (imgCount >= 4) {
                    return;
                }
                appendSingleDoc(res.path,'postDocs');
            },
            error: function () {
                //请求异常回调
            }
        });
        upload.render({
            elem: '#zjhsImgUploader',
            url: '${ctx}/common/uploadFile3',
            accept: 'file',
            exts: 'jpg|png|gif|doc|docx|ppt|pdf|xls|xlsx',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                let size = $('#zjhs_img_post').find('a').size();
                if (size >= 6) {
                    layer.msg('最多只能上传6个文件')
                    return false;
                }
            },
            done: function (res) {
                //上传完毕回调
                let imgCount = $('#zjhs_img_post').find('a').size();
                if (imgCount >= 6) {
                    return;
                }
                appendSingleDoc(res.path,'zjhs_img_post');
            },
            error: function () {
                //请求异常回调
            }
        });
        upload.render({
            elem: '#zjpbImgUploader',
            url: '${ctx}/common/uploadFile3',
            accept: 'file',
            exts: 'jpg|png|gif|doc|docx|ppt|pdf|xls|xlsx',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                let size = $('#zjpb_img_post').find('a').size();
                if (size >= 6) {
                    layer.msg('最多只能上传6个文件')
                    return false;
                }
            },
            done: function (res) {
                //上传完毕回调
                let imgCount = $('#zjpb_img_post').find('a').size();
                if (imgCount >= 6) {
                    return;
                }
                appendSingleDoc(res.path,'zjpb_img_post');
            },
            error: function () {
                //请求异常回调
            }
        });
        upload.render({
            elem: '#zjzxImgUploader',
            url: '${ctx}/common/uploadFile3',
            accept: 'file',
            exts: 'jpg|png|gif|doc|docx|ppt|pdf|xls|xlsx',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                let size = $('#zjzx_img_post').find('a').size();
                if (size >= 6) {
                    layer.msg('最多只能上传6个文件')
                    return false;
                }
            },
            done: function (res) {
                //上传完毕回调
                let imgCount = $('#zjzx_img_post').find('a').size();
                if (imgCount >= 6) {
                    return;
                }
                appendSingleDoc(res.path,'zjzx_img_post');
            },
            error: function () {
                //请求异常回调
            }
        });
        upload.render({
            elem: '#zjcsImgUploader',
            url: '${ctx}/common/uploadFile3',
            accept: 'file',
            exts: 'jpg|png|gif|doc|docx|ppt|pdf|xls|xlsx',
            before: function (obj) {
                //预读本地文件示例，不支持ie8
                let size = $('#zjcs_img_post').find('a').size();
                if (size >= 6) {
                    layer.msg('最多只能上传6个文件')
                    return false;
                }
            },
            done: function (res) {
                //上传完毕回调
                let imgCount = $('#zjcs_img_post').find('a').size();
                if (imgCount >= 6) {
                    return;
                }
                appendSingleDoc(res.path,'zjcs_img_post');
            },
            error: function () {
                //请求异常回调
            }
        });
        let saving = false;
        $("#save").click(function() {
            if (saving) {
                return;
            }

            let tds = $("#contentBody2").find("td");
            let schemeTypeSelect = tds.eq(0).find('select');
            let schemeNameSelect = tds.eq(1).find('select');
            let schemeTypeId = schemeTypeSelect.val();
            let schemeTypeName = schemeTypeSelect.find('option:selected').text();
            let schemeId = schemeNameSelect.val();
            let schemeName = schemeNameSelect.find('option:selected').text();

            let dzDocsEl = $('#postDocs').find('input.postDocs');
            let dzDocs = [];
            dzDocsEl.each(function() {
                dzDocs.push($(this).val());
            });
            let dzDoc = dzDocs.join(",");
            let zjpbImg = $('#zjpb_img_post').find('input.zjpb_img_post');
            let zjpbImgDocs = [];
            zjpbImg.each(function() {
                zjpbImgDocs.push($(this).val());
            });
            let zjpbImgDoc = zjpbImgDocs.join(",");
            let zjzxImg = $('#zjzx_img_post').find('input.zjzx_img_post');
            let zjzxImgDocs = [];
            zjzxImg.each(function() {
                zjzxImgDocs.push($(this).val());
            });
            let zjzxImgDoc = zjzxImgDocs.join(",");
            let zjcsImg = $('#zjcs_img_post').find('input.zjcs_img_post');
            let zjcsImgDocs = [];
            zjcsImg.each(function() {
                zjcsImgDocs.push($(this).val());
            });
            let zjcsImgDoc = zjcsImgDocs.join(",");
            let zjhsImg = $('#zjhs_img_post').find('input.zjhs_img_post');
            let zjhsImgDocs = [];
            zjhsImg.each(function() {
                zjhsImgDocs.push($(this).val());
            });
            let zjhsImgDoc = zjhsImgDocs.join(",");

            let components = [].concat(preComponents);
            let postComponentsTable = $("#postComponentTableContent");
            let postComponents = [];
            postComponentsTable.find('tr').each(function() {
                let tr = $(this);
                let tds = tr.find('td');
                let spec = tds.eq(2).find('option:selected').data("power");
                if(isBlank(spec)){
                    spec = tds.eq(2).find('option:selected').text();
                    if(spec.includes("|")){
                        spec = spec.substring(spec.indexOf("|")+1);
                    }
                }
                postComponents.push({
                    type: tr.data('type'),
                    spec: spec,
                    itemId: tds.eq(2).find('select').val(),
                    num: $.trim(tds.eq(3).find('input').val()),
                    flag: '1'
                });
            });
            let reason = $("#reason").val();
            let entryId = $("#stationId").val();

            if (isBlank(entryId)) {
                layer.msg("未选择电站信息");
                return;
            }
            if (isBlank(schemeTypeId)) {
                layer.msg("请选择方案类型");
                return;
            }
            if (isBlank(schemeId)) {
                layer.msg("请选择方案名称");
                return;
            }
            for(var i=0;i<postComponents.length;i++) {
                const c = postComponents[i];
                if (c.type === '1' || c.type === '3') {
                    if (!c.itemId) {
                        layer.msg('请选择第'+(i+1)+'行物料规格');
                        return;
                    }
                    if (!c.num) {
                        layer.msg('请输入第'+(i+1)+'行物料数量');
                        return;
                    }
                } else {
                    if (c.num && !c.itemId) {
                        layer.msg('请选择第'+(i+1)+'行物料规格');
                        return;
                    }
                    if (c.itemId && !c.num) {
                        layer.msg('请输入第'+(i+1)+'行物料数量');
                        return;
                    }
                }
                if (c.num && !/^\d+$/.test(c.num)) {
                    layer.msg('第'+(i+1)+'行物料数量必须为整数');
                    return;
                }
            }
            var checkRe = false;
            for (i = 0; i < formSet.length; i++) {
                let columnKey = formSet[i].columnKey;
                let useFlag = formSet[i].useFlag;
                let mustFillFlag = formSet[i].mustFillFlag;
                if (columnKey.includes(partnerId)) {
                    columnKey = columnKey.substring(0, columnKey.indexOf(partnerId) - 1);
                }
                if (useFlag == '1' && columnKey == 'design_drawings' && mustFillFlag == '1'&&!dzDoc) {
                    layer.msg( "请上传1-6个"+ $(".design_drawings_name").first().text()+"PDF 附件");
                    checkRe = true;
                    return;
                }
                if (useFlag == '1' && columnKey == 'zjpb_img' && mustFillFlag == '1'&&!zjpbImgDoc) {
                    layer.msg('请上传1-6个'+$(".zjpb_img_name").first().text()+' 附件');
                    checkRe = true;
                    return;
                }
                if (useFlag == '1' && columnKey == 'zjzx_img' && mustFillFlag == '1'&&!zjzxImgDoc) {
                    layer.msg('请上传1-6个'+$(".zjzx_img_name").first().text()+' 附件');
                    checkRe = true;
                    return;
                }
                if (useFlag == '1' && columnKey == 'zjcs_img' && mustFillFlag == '1'&&!zjcsImgDoc) {
                    layer.msg('请上传1-6个'+$(".zjcs_img_name").first().text()+' 附件');
                    checkRe = true;
                    return;
                }
                if (useFlag == '1' && columnKey == 'zjhs_img' && mustFillFlag == '1'&&!zjhsImgDoc) {
                    layer.msg('请上传1-6个'+$(".zjhs_img_name").first().text()+' 附件');
                    checkRe = true;
                    return;
                }
            }
            if( checkRe ){
                return;
            }
            postComponents = postComponents.filter(e => !!e.itemId);
            components = components.concat(postComponents);
            let projectId = $("#projectId").val();
            saving = true;
            // schemeType不会变，只有一种标准方案，没有组合方案
            $.ajax({
                url: "${ctx}/entryChanges/designInfo/addDesignChange",
                type: "POST",
                contentType : "application/json;charsetset=UTF-8",
                data: JSON.stringify({
                    reason: reason,
                    entryId: entryId,
                    projectId: projectId,
                    components: components,
                    schemeType: entry.schemeType,
                    preSchemeType:entry.schemeType,
                    schemeTypeId: schemeTypeId,
                    preSchemeTypeId: entry.schemeTypeId,
                    schemeTypeName: schemeTypeName,
                    preSchemeTypeName:entry.schemeTypeName,
                    schemeName: schemeName,
                    preSchemeName:entry.schemeName,
                    schemeId: schemeId,
                    preSchemeId: entry.schemeId,
                    dzDoc: dzDoc,
                    preDzDoc:entry.designDrawings,
                    zjzxImgDoc: zjzxImgDoc,
                    preZjzxImgDoc: entry.zjzxImg,
                    zjhsImgDoc: zjhsImgDoc,
                    preZjhsImgDoc: entry.zjhsImg,
                    zjcsImgDoc: zjcsImgDoc,
                    preZjcsImgDoc: entry.zjcsImg,
                    zjpbImgDoc: zjpbImgDoc,
                    preZjpbImgDoc: entry.zjpbImg
                }),
                success: function (data) {
                    if (data.code === "200") {
                        top.layer.msg("操作成功");
                        parent.searchOrder();
                        closeSelf();
                    } else {
                        saving = false;
                        layer.msg(data.errMsg);
                    }
                },
                error: function () {
                    saving = false;
                }
            });
        });

        form.on('select(planType)', function (data) {
            var value = $(data.elem).find("option:selected").val();
            fillPlanNameSelect(value);
        });

        form.on('select(spec)', function (data) {
            doCalcPostDesignCapacity();
        });
    });

    function fillPlanNameSelect(value, sel) {
        if (isBlank(value)) {
            return
        }
        //获取当前类型下的方案名称
        $.ajax({
            url: "${ctx}/planManage/findPlanByAssembly",
            type: "POST",
            data: {
                planType: value
            },
            success: function (result) {
                let planNameSelect = $(".planName");
                planNameSelect.empty();
                var length = result.length;
                var planNameHtml = "<option value=''>请选择</option>";
                planNameSelect.append(planNameHtml);
                for (var i = 0; i < length; i++) {
                    let option = $("<option></option>");
                    option.val(result[i].columns.id);
                    option.text(result[i].columns.name);
                    planNameSelect.append(option);
                }
                if (sel) {
                    planNameSelect.val(sel);
                }
                form.render('select');
            }
        });
    }

    function selectEntry(partnerId) {
        layer.open({
            type: 2,
            title: '选择电站',
            content: '${ctx}/entryChanges/designInfo/toSelectEntry?partnerId='+partnerId,
            area: ['80%','80%']
        });
    }

    function setPreDesignDocs(entry) {
        if(!isBlank(entry.designDrawings)){
            $("#preDocs").empty();
            let designDrawings = entry.designDrawings;
            let drawings = designDrawings.split(",");
            for(var i=0;i<drawings.length;i++) {
                let s = $(preDesignDocTempl());
                let file = s.find('a').eq(0);
                file.attr('href', '${commonStaticImgPath}'+drawings[i]);
                file.attr('download', drawings[i]);
                file.text(filename(drawings[i]));
                $("#preDocs").append(s);
            }
        }
        if(!isBlank(entry.zjpbImg)){
            $("#zjpb_img_pre").empty();
            let zjpbImgs = entry.zjpbImg;
            let zjpbImg = zjpbImgs.split(",");
            for(var i=0;i<zjpbImg.length;i++) {
                let s = $(preDesignDocTempl());
                let file = s.find('a').eq(0);
                file.attr('href', '${commonStaticImgPath}'+zjpbImg[i]);
                file.attr('download', zjpbImg[i]);
                file.text(filename(zjpbImg[i]));
                $("#zjpb_img_pre").append(s);
            }
        }
        if(!isBlank(entry.zjzxImg)){
            $("#zjzx_img_pre").empty();
            let zjzxImgs = entry.zjzxImg;
            let zjzxImg = zjzxImgs.split(",");
            for(var i=0;i<zjzxImg.length;i++) {
                let s = $(preDesignDocTempl());
                let file = s.find('a').eq(0);
                file.attr('href', '${commonStaticImgPath}'+zjzxImg[i]);
                file.attr('download', zjzxImg[i]);
                file.text(filename(zjzxImg[i]));
                $("#zjzx_img_pre").append(s);
            }
        }
        if(!isBlank(entry.zjcsImg)){
            $("#zjcs_img_pre").empty();
            let zjcsImgs = entry.zjcsImg;
            let zjcsImg = zjcsImgs.split(",");
            for(var i=0;i<zjcsImg.length;i++) {
                let s = $(preDesignDocTempl());
                let file = s.find('a').eq(0);
                file.attr('href', '${commonStaticImgPath}'+zjcsImg[i]);
                file.attr('download', zjcsImg[i]);
                file.text(filename(zjcsImg[i]));
                $("#zjcs_img_pre").append(s);
            }
        }
        if(!isBlank( entry.zjhsImg)){
            $("#zjhs_img_pre").empty();
            let zjhsImgs = entry.zjhsImg;
            let zjhsImg = zjhsImgs.split(",");
            for(var i=0;i<zjhsImg.length;i++) {
                let s = $(preDesignDocTempl());
                let file = s.find('a').eq(0);
                file.attr('href', '${commonStaticImgPath}'+zjhsImg[i]);
                file.attr('download', zjhsImg[i]);
                file.text(filename(zjhsImg[i]));
                $("#zjhs_img_pre").append(s);
            }
        }
    }

    function filename(filePath) {
        if (!filePath) {
            return '';
        }
        let index = filePath.lastIndexOf("/");
        if (index !== -1) {
            return filePath.substring(index+1);
        }
        return filePath;
    }

    function preDesignDocTempl() {
        return "<div style=\"margin-top: 5px\">\n" +
            "    <a href=\"\" class=\"download-link\"></a>\n" +
            "</div>";
    }

    function postDesignDocTempl(index) {
        return "<div style=\"margin-top: 5px\">\n" +
            "    <span class=\"layui-icon-close layui-icon\" onclick=\"delDoc(this)\"></span>\n" +
            "    <a href=\"\" class=\"download-link\"></a>\n" +
            "    <input type=\"hidden\" class=\""+index+"\">\n" +
            "</div>";
    }

    function setPostDesignDocs(entry) {
        if(!isBlank(entry.designDrawings)){
            $("#postDocs").empty();
            let designDrawings = entry.designDrawings;
            let drawings = designDrawings.split(",");
            for(var i=0;i<drawings.length;i++) {
                appendSingleDoc(drawings[i],'postDocs');
            }
        }
        if(!isBlank(entry.zjpbImg)){
            $("#zjpb_img_post").empty();
            let zjpbImgs = entry.zjpbImg;
            let zjpbImg = zjpbImgs.split(",");
            for(var i=0;i<zjpbImg.length;i++) {
                appendSingleDoc(zjpbImg[i],'zjpb_img_post');
            }
        }
        if(!isBlank(entry.zjzxImg)){
            $("#zjzx_img_post").empty();
            let zjzxImgs = entry.zjzxImg;
            let zjzxImg = zjzxImgs.split(",");
            for(var i=0;i<zjzxImg.length;i++) {
                appendSingleDoc(zjzxImg[i],'zjzx_img_post');
            }
        }
        if(!isBlank(entry.zjcsImg)){
            $("#zjcs_img_post").empty();
            let zjcsImgs = entry.zjcsImg;
            let zjcsImg = zjcsImgs.split(",");
            for(var i=0;i<zjcsImg.length;i++) {
                appendSingleDoc(zjcsImg[i],'zjcs_img_post');
            }
        }
        if(!isBlank( entry.zjhsImg)){
            $("#zjhs_img_post").empty();
            let zjhsImgs = entry.zjhsImg;
            let zjhsImg = zjhsImgs.split(",");
            for(var i=0;i<zjhsImg.length;i++) {
                appendSingleDoc(zjhsImg[i],'zjhs_img_post');
            }
        }
    }

    function delDoc(el) {
        $(el).closest('div').remove();
    }

    function appendSingleDoc(path, index) {
        let s = $(postDesignDocTempl(index));
        let file = s.find('a').eq(0);
        file.attr('href', '${commonStaticImgPath}'+path);
        file.attr('download', path);
        file.text(filename(path));
        $("#"+index).append(s);
        s.find('input').val(path);
    }

    function calcPostDesignCapacity() {
        doCalcPostDesignCapacity();
    }

    function doCalcPostDesignCapacity() {
        let tds = $("#postComponentTableContent").find('tr').eq(0).find('td');
        const num = tds.eq(3).find('input').val();
        var value = tds.eq(2).find("option:selected").data('power');
        const capacity = parseInt(value) * parseInt(num);
        $('#postDesignCapacity').text(isNaN(capacity) ? "-" : (capacity/1000).toFixed(3));
    }

    function addRow(r) {
        let target = $(r).closest('tr');
        const nextRow = target.clone();
        nextRow.data('type', target.data('type'));
        function _resetRow(nextRow) {
            let tds = nextRow.find('td');
            tds.eq(2).find('select').val('');
            tds.eq(3).find('input').val('');
            tds.eq(4).find('i.layui-icon-delete').removeClass('layui-hide');
        }
        _resetRow(nextRow);
        nextRow.insertAfter(target);
        initRowNums($('#postComponentTableContent'));
        invalidate('select');
    }

    function deleteRow(r) {
        let target = $(r).closest('tr');
        target.remove();
        initRowNums($('#postComponentTableContent'));
    }

    function invalidate(target) {
        setTimeout(function() {
            form.render(target);
        }, 0);
    }

    function initRowNums(table) {
        let trs = table.find('tr');
        trs.each(function(index, el) {
            $("td:first", $(this)).text(index+1);
        });
    }

    function compChange(t) {
        doCalcPostDesignCapacity();
    }

    function searchCode(code){
        $("input[name='stationCode']").val(code);
        var stationCode = code;
        if (isBlank(stationCode)) {
            layer.msg('请输入电站编码')
            return;
        }
        $.ajax({
            type: 'post',
            url: '${ctx}/entryChanges/designInfo/selectNumber/' + stationCode,
            dataType: 'json',
            data: {
                stationCode: stationCode
            },
            success: function(res) {
                clearHtml();
                if (res.code === "200") {
                    var customerEntry = res.data.customerEntry;
                    entry = customerEntry;
                    formSet = res.data.formSet;
                    info2 = res.data.info2;
                    partnerId = res.data.customerEntry.partnerId;
                    var project = res.data.project;
                    $("#stationId").val(customerEntry.id);
                    $("input[name='status']").val(getStatus(customerEntry));
                    $("input[name='traderName']").val(customerEntry.createTraderName);
                    $("input[name='projectName']").val(project.name);
                    $("#projectId").val(project.id);
                    $("input[name='projectCompanyName']").val(customerEntry.projectCompanyName);
                    $("input[name='partnerName']").val(customerEntry.partnerName);
                    $("input[name='tenantName']").val(customerEntry.tenantName);
                    $("input[name='idCode']").val(customerEntry.idCode);
                    $("input[name='address']").val(customerEntry.province + customerEntry.city + customerEntry.area + customerEntry.address);
                    // 方案
                    $("#schemeTypeName").text(customerEntry.schemeTypeName);
                    $("#schemeTypeName").data('schemeTypeId', customerEntry.schemeTypeId);
                    $("#schemeTypeName").data('schemeType', customerEntry.schemeType);
                    $("#schemeName").text(customerEntry.schemeName);
                    $("#schemeName").data('schemeId', customerEntry.schemeId);
                    // 方案下拉列表
                    fillPlanTypeSelect(res.data.insta, form, customerEntry.schemeTypeId);
                    fillPlanNameSelect(customerEntry.schemeTypeId, customerEntry.schemeId);
                    // 物料 pre
                    setComponentInfo(res.data.assemblyList, res.data.inverterList, res.data.gridConnectionList, res.data.gridSupportList);
                    savePreComponentInfo(res.data.assemblyList, res.data.inverterList, res.data.gridConnectionList, res.data.gridSupportList);
                    // 物料 post
                    setComponentInfoPost(res.data, form);
                    $('#preDesignCapacity').text((customerEntry.designCapacity/1000).toFixed(2));
                    // 设置设计文档和设计图纸
                    setPreDesignDocs(customerEntry)
                    setPostDesignDocs(customerEntry)
                    calcPostDesignCapacity();
                    hideOrShowHtml(formSet,customerEntry.partnerId);
                } else {
                    clearHtml();
                    layer.msg(res.errMsg);
                }
            }
        });
    }
    function hideOrShowHtml(setData,partnerId) {
        for (var i = 0; i < setData.length; i++) {
            let columnKey = setData[i].columnKey;
            if (setData[i].useFlag == '0') {//不启用
                $("." + columnKey).addClass("hide");
            } else {
                if (columnKey.includes(partnerId)) {
                    columnKey = columnKey.substring(0, columnKey.indexOf(partnerId)-1);
                }
                $("." + columnKey).removeClass("hide");
                $("." + columnKey+'_name').text(setData[i].columnName);
                $("#" + columnKey+'_reson').text(setData[i].remarks);
            }
        }
        resetSort();
    }


    function addImg(data, classimg, count) {
        let icons = $('#postDzImgsDiv').find('.imgSpan').size();
        const uploader = $('#dzImgsUploader');
        if(icons+1>=count){
            uploader.hide();
        }
        var html = '<div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="deleteIcon(this)"></span>';
        html += '<img src="${commonStaticImgPath}' + data + '" height="700" width="1200"/>';
        html += '<input type="hidden" class="' + classimg + '" value="' + data + '"/> </div>';
        $(html).insertBefore(uploader);
        //图片查看效果
        viewer.update();
    }

    function setDzImgs(data) {
        const imgItem = "<div class=\"bj-img imgSpan\">\n" +
            "    <img src=\"\" height=\"700\" width=\"1200\"/>\n" +
            "    <input type=\"hidden\" name=\"preDzImgs\" class=\"dzImgs\" value=\"\">\n" +
            "</div>";
        const imgs = data.dzImgs.split(',');
        const imgContainer = $('#preDzImgsDiv');
        imgContainer.empty();
        for (var i=0;i<imgs.length;i++) {
            const imgItemEl = $(imgItem);
            imgItemEl.find('img').attr('src', "${commonStaticImgPath}"+imgs[i]);
            imgItemEl.find('input').val(imgs[i]);
            imgContainer.append(imgItemEl);
        }
    }

    function deleteIcon(r) {
        const uploader = $('#dzImgsUploader');
        $(r).closest('.imgSpan').remove();
        let icons = $('#postDzImgsDiv').find('.imgSpan').size();
        if (icons >= 4) {
            uploader.hide();
        } else {
            uploader.show();
        }
    }

    function setDzImgsPost(data) {
        const imgItem = "<div class=\"bj-img imgSpan\">\n" +
            "    <span class=\"layui-icon-close layui-icon\" onclick=\"deleteIcon(this)\"></span>\n" +
            "    <img src=\"\" height=\"700\" width=\"1200\"/>\n" +
            "    <input type=\"hidden\" name=\"postDzImgs\" class=\"dzImgs\" value=\"\">\n" +
            "</div>";
        const imgs = data.dzImgs.split(',');
        const imgContainer = $('#postDzImgsDiv');
        $('.imgSpan', imgContainer).remove();
        const uploader = $('#dzImgsUploader');
        for (var i=0;i<imgs.length;i++) {
            const imgItemEl = $(imgItem);
            imgItemEl.find('img').attr('src', "${commonStaticImgPath}"+imgs[i]);
            imgItemEl.find('input').val(imgs[i]);
            imgItemEl.insertBefore(uploader);
        }
        if (imgs.length >= 4) {
            uploader.hide();
        }
    }

    function setComponentInfoPost(data, form) {
        let assemblyList = data.assemblyList;
        let sysAssemblyList = data.sysAssemblyList;
        let inverterList = data.inverterList;
        let sysInverterList = data.sysInverterList;
        let gridConnectionList = data.gridConnectionList;
        let sysGridConnectionList = data.sysGridConnectionList;
        let gridSupportList = data.gridSupportList;
        let sysGridSupportList = data.sysGridSupportList;
        let tableBody = $("#postComponentTableContent");
        tableBody.empty();
        var i, c=0;

        function fillComponentSelect(row, list, item) {
            let select = row.find('select').eq(0);
            for(var i=0;i<list.length;i++) {
                let option = $("<option></option>");
                option.val(list[i].columns.id);
                option.data("power",list[i].columns.model);
                if (item.columns.item_type === '3') {
                    if(info2.columns.component3_model!=null&&info2.columns.component3_model.status == '1'){
                        option.text(list[i].columns.material_model+"|"+list[i].columns.model);
                    }else {
                        option.text(list[i].columns.model);
                    }
                }else if(item.columns.item_type === '1'){
                    if(info2.columns.component1_model!=null&&info2.columns.component1_model.status == '1'){
                        option.text(list[i].columns.material_model+"|"+list[i].columns.model);
                    }else {
                        option.text(list[i].columns.model);
                    }
                }else {
                    option.text(list[i].columns.model);
                }


                select.append(option);
            }
            if (item) {
                select.val(item.columns.item_id);
            }
            setTimeout(function() {
                form.render('select');
            }, 0);
        }

        for(i=0;i<assemblyList.length;i++) {
            let row = $(createComponentRowTempl("spec"));
            row.data('type', assemblyList[i].columns.item_type);
            let tds = row.find("td");
            tds.eq(0).text(++c);
            tds.eq(1).html('<i class="mark">*</i>组件');
            fillComponentSelect(row, sysAssemblyList, assemblyList[i]);
            tds.eq(3).find('input').eq(0).val(assemblyList[i].columns.num);
            tableBody.append(row);
        }
        for(i=0;i<inverterList.length;i++) {
            let row = $(createComponentRowTempl2("inverter"));
            row.data('type', inverterList[i].columns.item_type);
            let tds = row.find("td");
            tds.eq(0).text(++c);
            tds.eq(1).html('<i class="mark">*</i>逆变器');
            fillComponentSelect(row, sysInverterList, inverterList[i]);
            tds.eq(3).find('input').eq(0).val(inverterList[i].columns.num);
            if (i>0) {
                tds.eq(4).find('i.layui-icon-delete').removeClass('layui-hide');
            }
            tableBody.append(row);
        }
        for(i=0;i<gridConnectionList.length;i++) {
            let row = $(createComponentRowTempl2("gridConnection"));
            row.data('type', gridConnectionList[i].columns.item_type);
            let tds = row.find("td");
            tds.eq(0).text(++c);
            tds.eq(1).html('并网箱');
            fillComponentSelect(row, sysGridConnectionList, gridConnectionList[i]);
            tds.eq(3).find('input').eq(0).val(gridConnectionList[i].columns.num);
            if (i>0) {
                tds.eq(4).find('i.layui-icon-delete').removeClass('layui-hide');
            }
            tableBody.append(row);
        }
        // if (gridConnectionList.length === 0) {
        //     let row = $(createComponentRowTempl2("gridConnection"));
        //     row.data('type', '2');
        //     let tds = row.find("td");
        //     tds.eq(0).text(++c);
        //     tds.eq(1).html('并网箱');
        //     fillComponentSelect(row, sysGridConnectionList, null);
        //     tableBody.append(row);
        // }

        for(i=0;i<gridSupportList.length;i++) {
            let row = $(createComponentRowTempl2("gridSupport"));
            row.data('type', gridSupportList[i].columns.item_type);
            let tds = row.find("td");
            tds.eq(0).text(++c);
            tds.eq(1).html('支架');
            fillComponentSelect(row, sysGridSupportList, gridSupportList[i]);
            tds.eq(3).find('input').eq(0).val(gridSupportList[i].columns.num);
            if (i>0) {
                tds.eq(4).find('i.layui-icon-delete').removeClass('layui-hide');
            }
            tableBody.append(row);
        }
        // if (gridSupportList.length === 0) {
        //     let row = $(createComponentRowTempl2("gridSupport"));
        //     row.data('type', '4');
        //     let tds = row.find("td");
        //     tds.eq(0).text(++c);
        //     tds.eq(1).html('支架');
        //     fillComponentSelect(row, sysGridSupportList, null);
        //     tableBody.append(row);
        // }
    }

    function createComponentRowTempl(name) {
        return "<tr>\n" +
            "   <td data-seq></td>\n" +
            "   <td></td>\n" +
            "   <td>\n" +
            "       <select lay-filter=\"" + name + "\" name=\"" + name + "\" lay-search>\n" +
            "           <option value=\"\">请选择</option>\n" +
            "       </select>\n" +
            "       <span class=\"pos-a layui-span-unit\" style=\"right: 30px;top:10px;\">Wp</span>" +
            "   </td>\n" +
            "   <td>\n" +
            "       <input type=\"text\" name=\"num\" oninput=\"compChange(this)\" class=\"layui-input\"/>\n" +
            "   </td>\n" +
            "   <td></td>\n" +
            "</tr>";
    }

    function createComponentRowTempl2(name) {
        return "<tr>\n" +
            "   <td data-seq></td>\n" +
            "   <td></td>\n" +
            "   <td>\n" +
            "       <select lay-filter=\""+name+"\" lay-search>\n" +
            "           <option value=\"\">请选择</option>\n" +
            "       </select>\n" +
            "   </td>\n" +
            "   <td>\n" +
            "       <input type=\"text\" name=\"num\" class=\"layui-input\" />\n" +
            "   </td>\n" +
            "   <td>\n" +
            "       <i class=\"layui-icon layui-icon-add-circle\" style=\"color: #1b6073;font-size: 25px;\"\n" +
            "          onclick=\"addRow(this)\"></i>\n" +
            "       <i class=\"layui-icon layui-icon-delete layui-hide\"\n" +
            "          style=\"color: #1b6073;font-size: 25px;\" onclick=\"deleteRow(this)\"></i>\n" +
            "   </td>\n" +
            "</tr>";
    }

    function savePreComponentInfo(assemblyList, inverterList, gridConnectionList, gridSupportList) {
        let ret = []
        let list = [];
        list = list.concat(assemblyList);
        list = list.concat(inverterList);
        list = list.concat(gridConnectionList);
        list = list.concat(gridSupportList);
        for (var i=0;i<list.length;i++) {
            let el = list[i].columns;
            let item = {
                type: el.item_type,
                spec: el.model,
                itemId: el.item_id,
                num: $.trim(el.num),
                flag: '0'
            }
            ret.push(item);
        }
        preComponents = ret;
    }

    function setComponentInfo(assemblyList, inverterList, gridConnectionList, gridSupportList) {
        let row = "<tr>\n" +
            "  <td></td>\n" +
            "  <td></td>\n" +
            "  <td></td>\n" +
            "  <td></td>\n" +
            " </tr>";
        let list = [];
        list = list.concat(assemblyList);
        list = list.concat(inverterList);
        list = list.concat(gridConnectionList);
        list = list.concat(gridSupportList);
        let length = list.length;
        let tableBody = $("#preComponentTableContent");
        tableBody.empty();
        for (var i = 0; i < length; i++) {
            let tr = $(row);
            let tds = tr.find('td');
            tds.eq(0).text(i+1+"");
            tds.eq(1).text(list[i].columns.label);
            tds.eq(2).data("power",list[i].columns.model);
            if (list[i].columns.item_type === '3') {
                if(info2.columns.component3_model!=null&&info2.columns.component3_model.status == '1'){
                    tds.eq(2).text(list[i].columns.material_model+"Wp");
                }else {
                    tds.eq(2).text(list[i].columns.model+"Wp");
                }

            } else if(list[i].columns.item_type === '1'){
                if(info2.columns.component1_model!=null&&info2.columns.component1_model.status == '1') {
                    tds.eq(2).text(list[i].columns.material_model);
                }else {
                    tds.eq(2).text(list[i].columns.model);
                }
            }else {
                tds.eq(2).text(list[i].columns.model);
            }
            tds.eq(3).text(list[i].columns.num);
            tableBody.append(tr);
        }
    }

    function fillPlanTypeSelect(planTypes, form, planTypeId) {
        let planTypeSelect = $("select[name=planType]");
        planTypeSelect.empty();
        var length = planTypes.length;
        var planTypeHtml = "<option value=''>请选择</option>";
        planTypeSelect.append($(planTypeHtml));
        for (var i = 0; i < length; i++) {
            let option = $('<option></option>');
            option.val(planTypes[i].columns.id);
            option.text(planTypes[i].columns.name);
            planTypeSelect.append(option);
        }
        planTypeSelect.val(planTypeId);
        form.render('select');
    }

    function clearHtml(){
        $("#stationId").val("");
        $("input[name='status']").val("");
        $("input[name='traderName']").val("");
        $("input[name='projectName']").val("");
        $("input[name='projectCompanyName']").val("");
        $("input[name='tenantName']").val("");
        $("input[name='idCode']").val("");
        $("input[name='address']").val("");
        $("#preDocs").empty();
        $("#zjpb_img_pre").empty();
        $("#zjzx_img_pre").empty();
        $("#zjzx_img_pre").empty();
        $("#zjhs_img_pre").empty();
        $("#postDocs").empty();
        $("#zjzx_img_post").empty();
        $("#zjpb_img_post").empty();
        $("#zjhs_img_post").empty();
        $("#zjcs_img_post").empty();
        $(".change").addClass("hide");
    }
    function appendHtml(data){
    }

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

    window.closeSelf = function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);//关闭当前页
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
    function resetSort(){
        var sort = 1;
        $("#contentBody").find("tr").each(function (index) {
            if (!$(this).hasClass("hide")) {
                $(this).find("td:first").text(sort);
                sort++;
            }
        });
    }
</script>
</body>
</html>

