<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta name="decorator" content="base" />
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiadmin/dist/layuiadmin/style/admin.css" media="all">
    <link rel="stylesheet" href="${ctxPlugin}/static/css/reset.css">
    <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
</head>
<body class="">
<div class="layui-fluid ">
    <div class="layui-card pl-30 pr-30 pt-10 over">
        <form class="layui-form" id="orderForm">
            <div class="layui-card-body layui-col-xs11" id="LAY_app">

                <div class="layui-card">
                    <blockquote class="layui-elem-quote">项目信息</blockquote>
                    <div class="layui-card-body">

                        <div class="layui-row layui-col-space12 layui-form-item">
                            <div class="layui-col-lg3 layui-col-sm3">
                                <label class="layui-form-label"><i class="mark">*</i>产品编号：</label>
                                <div class="layui-input-block">
                                    <select name="projectId" id="projectId" lay-filter="projectId" lay-search >
                                        <option value="">请选择</option>
                                        <c:forEach items="${project}" var="ject">
                                            <option value="${ject.columns.id}" title="${ject.columns.name}" data-anim="${ject.columns.management_type}" <c:if test="${ject.columns.id eq entry.projectId}" > selected</c:if>  data-key="${ject.columns.install_mode_id}" data-type="${ject.columns.install_mode_name}">${ject.columns.code}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                            <div class="layui-col-lg3 layui-col-sm3">
                                <label class="layui-form-label"><i class="mark">*</i>产品名称：</label>
                                <div class="layui-input-block">
                                    <input type="text"  id="projectName" disabled class="layui-input " value="${pro.name}" >
                                </div>
                            </div>
                            <div class="layui-col-lg3 layui-col-sm3">
                                <label class="layui-form-label"><i class="mark">*</i>代理商名称：</label>
                                <div class="layui-input-block">
                                    <input type="hidden" id="distributorId" name="distributorId" value="${trader.id}">
                                    <input type="text"  value="${trader.name}" disabled class="layui-input " >
                                </div>
                            </div>

                            <div class="layui-col-lg3 layui-col-sm3 " >
                                <label class="layui-form-label"><i class="mark">*</i>代理商电话：</label>
                                <div class="layui-input-block pos-r">
                                    <input type="text" disabled placeholder=""
                                           autocomplete="off" class="layui-input" value="${trader.telephone}">
                                </div>
                            </div>

                            <div class="layui-col-lg3 layui-col-sm3">
                                <label class="layui-form-label">资方名称：</label>
                                <div class="layui-input-block">
                                    <input type="text"  id="managementType" disabled class="layui-input "  value="${managementType}" >
                                </div>
                            </div>

                            <%--<div class="layui-col-lg3 layui-col-sm3">
                                <label class="layui-form-label"><i class="mark">*</i>物料单价：</label>
                                <div class="layui-input-block pos-r">
                                    <input type="text" name="equipValue"  id="equipValue" value="${entry.equipValue}" autocomplete="off" class="layui-input"   onkeyup="!/^(\d+\.?)?\d{0,2}$/.test(this.value)?(this.value=this.value.substring(0, this.value.length-1)): ''" >
                                    <span class="pos-a h-32 lh-32 layui-span-unit" >元</span>
                                </div>
                            </div>--%>

                        </div>

                    </div>
                </div>
                <div class="layui-card jibenxinxi ">
                    <blockquote class="layui-elem-quote">业主信息</blockquote>
                    <div class="layui-card-body ">
                        <div>
                            <div class="layui-row layui-col-space12 layui-form-item">

                                <div class="layui-col-lg3 layui-col-sm3">
                                    <label class="layui-form-label"><i class="mark">*</i>业主姓名：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="tenantName" id="tenantName" lay-verify="required"
                                               placeholder=""
                                               autocomplete="off" class="layui-input layui-bg-gray" readonly value="${entry.tenantName}">
                                    </div>
                                </div>
                                <div class="layui-col-lg3 layui-col-sm3" style="position:relative;">
                                    <div>
                                        <label class="layui-form-label"><i class="mark">*</i>联系方式：</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="mobile" id="mobile" readonly lay-verify="recevierMobile" class="layui-input layui-bg-gray" autocomplete="off" value="${entry.mobile}">
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-lg3 layui-col-sm3">
                                    <label class="layui-form-label"><i class="mark">*</i>身份证号：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="idCode" id="idCode"  lay-verify="identity"
                                               autocomplete="off" class="layui-input layui-bg-gray" value="${entry.idCode}" readonly>
                                    </div>
                                </div>
                             <%--   <div class="layui-col-lg3 layui-col-sm3">
                                    <label class="layui-form-label"><i class="mark">*</i>租赁状态：</label>
                                    <div class="layui-input-block">
                                        <select name="hireStatus" id="hireStatus" >
                                            <option value="">请选择</option>
                                            <option value="1" <c:if test="${entry.hireStatus eq 1}" > selected</c:if>>是</option>
                                            <option value="2" <c:if test="${entry.hireStatus eq 2}" > selected</c:if>>否</option>
                                        </select>
                                    </div>
                                </div>--%>



                              <%--  <div class="layui-col-lg8">--%>
                                <div class="layui-col-xs12 layui-form-item">
                                    <label class="layui-form-label"><i class="mark">*</i>安装地址：</label>
                                    <div class="layui-input-block">
                                        <div class="layui-col-lg2 layui-col-sm2 pr-30">
                                            <select name="province" id="province" lay-verify="required"
                                                    lay-filter="province" lay-search>
                                                <option value="">请选择省</option>
                                                <c:forEach items="${pros}" var="pro">
                                                        <option value="${pro.columns.ProvinceName}" title="${pro.columns.ProvinceID }" <c:if test="${entry.province eq pro.columns.ProvinceName}">selected</c:if>>${pro.columns.ProvinceName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                            <div class="layui-col-lg2 layui-col-sm2 pr-30">
                                                <select name="city" id="city" lay-verify="required" lay-filter="city" lay-search >
                                                    <option value="">请选择市</option>
                                                    <c:forEach items="${faccitys}" var="city">
                                                        <option value="${city.columns.CityName}" <c:if test="${entry.city eq city.columns.CityName}">selected</c:if> title="${city.columns.CityID}">${city.columns.CityName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                            <div class="layui-col-lg2 layui-col-sm2 pr-30">
                                                <select name="area" id="area" lay-verify="required" lay-search >
                                                    <option value="">请选择县/区</option>
                                                    <c:forEach items="${areas}" var="area">
                                                        <option value="${area.columns.DistrictName}" <c:if test="${entry.area eq area.columns.DistrictName}">selected</c:if> title="${area.columns.DistrictID}">${area.columns.DistrictName}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                            <div class="layui-col-lg6 layui-col-sm5">
                                                <input type="text" name="customerAddress" lay-verify="required" placeholder=""
                                                       autocomplete="off" class="layui-input layui-col-lg2 "  value="${entry.address}">
                                            </div>
                                        </div>

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

                                <div class="layui-col-lg3 layui-col-sm4">
                                    <label class="layui-form-label"><i class="mark">*</i>屋顶类型：</label>
                                    <div class="layui-input-block">
                                        <select name="roofType" id="roofType"  lay-verify="required" >
                                            <option value="">请选择</option>
                                            <option value="平屋顶" <c:if test="${entry.roofType eq '平屋顶'}">selected</c:if>>平屋顶</option>
                                            <option value="斜屋顶" <c:if test="${entry.roofType eq '斜屋顶'}">selected</c:if>>斜屋顶</option>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-lg3 layui-col-sm4" style="position:relative;">
                                    <div>
                                        <label class="layui-form-label"><i class="mark">*</i>朝向角度：</label>
                                        <div class="layui-input-block pr-30">
                                            <input type="text" name="angle" id="angle" class="layui-input"  autocomplete="off" value="${entry.angle}" >
                                        </div>
                                    </div>
                                </div>
                                <div class="layui-col-lg3 layui-col-sm4">
                                    <label class="layui-form-label"><i class="mark">*</i>安装方式：</label>
                                    <div class="layui-input-block">
                                        <select name="method" id="method">
                                            <option value="">请选择</option>
                                            <c:forEach items="${insta}" var="ins">
                                                <option value="${ins.columns.id}" <c:if test="${entry.method eq ins.columns.id}">selected</c:if>>${ins.columns.name}</option>
                                            </c:forEach>
                                        </select>
                                    </div>
                                </div>
                                <div class="layui-col-lg3 layui-col-sm3">
                                    <label class="layui-form-label"><i class="mark">*</i>并网距离：</label>
                                    <div class="layui-input-block">
                                        <input type="text" name="distance" id="distance"  placeholder=""
                                               autocomplete="off" class="layui-input "  value="${entry.distance}">
                                        <span class="pos-a h-32 lh-32 layui-span-unit" >米</span>
                                    </div>
                                </div>

                                <div class="layui-col-xs12">
                                    <label class="layui-form-label" id="changeDescribe">备注：</label>
                                    <div class="layui-input-block">
                                        <textarea name="remarks" id="remarks" placeholder="" class="layui-textarea" lay-verify="required">${entry.remarks}</textarea>
                                    </div>
                                </div>
                                <div class="layui-col-lg2 layui-col-sm2">
                                    <label class="layui-form-label" id="changeImgName"><i class="mark">*</i>房屋照片：</label>
                                    <div class="layui-input-block">
                                        <div id="imgsDiv1">
                                            <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="delImg(this,'uploaderone')"></span>
                                                <img src="${commonStaticImgPath}${entry.roofPhotoOne}" height="700" width="1200"/>
                                                <input type="hidden" class="roof_photo_one" value="${entry.roofPhotoOne}"/>
                                            </div>
                                        </div>
                                        <div class="upload-container hide" id="uploaderone">
                                            <img src="" alt="img placeholder" id="imgsAdd1">
                                        </div>
                                        <div style="width: 80px; text-align: center; color: #144856">俯拍图</div>
                                    </div>
                                </div>
                                <div  class="layui-col-lg2 layui-col-sm2">
                                    <div class="layui-input-block " >
                                        <div id="imgsDiv2">
                                            <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="delImg(this,'uploader2')"></span>
                                                <img src="${commonStaticImgPath}${entry.roofPhotoTwo}" height="700" width="1200"/>
                                                <input type="hidden" class="roof_photo_two" value="${entry.roofPhotoTwo}"/>
                                            </div>
                                        </div>
                                        <div class="upload-container hide" id="uploader2">
                                            <img src="" alt="img placeholder" id="imgsAdd2">
                                        </div>
                                        <div style="width: 80px; text-align: center; color: #144856">角度南</div>
                                    </div>

                                </div>
                                <div  class="layui-col-lg2 layui-col-sm2">
                                    <div class="layui-input-block " >
                                        <div id="imgsDiv3">
                                            <c:if test="${not empty entry.roofPhotoThree}">
                                                <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="delImg(this,'uploader3')"></span>
                                                    <img src="${commonStaticImgPath}${entry.roofPhotoThree}" height="700" width="1200"/>
                                                    <input type="hidden" class="roof_photo_three" value="${entry.roofPhotoThree}"/>
                                                </div>
                                            </c:if>
                                        </div>
                                        <div class="upload-container <c:if test="${not empty entry.roofPhotoThree}">hide</c:if>" id="uploader3">
                                            <img src="" alt="img placeholder" id="imgsAdd3">
                                        </div>
                                        <div style="width: 80px; text-align: center; color: #144856">补充图片1</div>
                                    </div>

                                </div>
                                <div  class="layui-col-lg2 layui-col-sm2">
                                    <div class="layui-input-block " >
                                        <div id="imgsDiv4">
                                        <c:if test="${not empty entry.roofPhotoFour}">
                                            <div class="bj-img imgSpan">
                                                <span class="layui-icon-close layui-icon" onclick="delImg(this,'uploader4')"></span>
                                                <img src="${commonStaticImgPath}${entry.roofPhotoFour}" height="700" width="1200"/>
                                                <input type="hidden" class="roof_photo_four" value="${entry.roofPhotoFour}"/>
                                            </div>
                                        </c:if>
                                        </div>
                                        <div class="upload-container <c:if test="${not empty entry.roofPhotoFour}">hide</c:if>" id="uploader4">
                                            <img src="" alt="img placeholder" id="imgsAdd4">
                                        </div>
                                        <div style="width: 80px; text-align: center; color: #144856">补充图片2</div>
                                    </div>

                                </div>

                                <div class="layui-col-lg6 layui-col-sm6">
                                    <label class="layui-form-label" ><i class="mark">*</i>屋顶尺寸：</label>
                                    <div class="layui-input-block">
                                        <div id="imgsDiv">
                                            <div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="delImg(this,'uploader')"></span>
                                                <img src="${commonStaticImgPath}${entry.dimensionsImgs}" height="700" width="1200"/>
                                                <input type="hidden" class="imgPicker" value="${entry.dimensionsImgs}"/>
                                            </div>
                                        </div>
                                        <div class="upload-container hide" id="uploader">
                                            <img src="" alt="img placeholder" id="imgsAdd">
                                        </div>
                                    </div>

                                </div>
                            </div>
                        </div>
                    </div>

                </div>
                <div class="layui-card">
                    <blockquote class="layui-elem-quote">方案信息</blockquote>
                    <div class="layui-card-body">

                        <div class="layui-row layui-col-space12 layui-form-item">
                            <div class="layui-col-lg12 layui-col-sm12">
                                <label class="layui-form-label"><i class="mark">*</i>匹配方式：</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="schemeType" value="2" title="组合方案" <c:if test="${entry.schemeType eq '2' }">checked</c:if> lay-filter="schemeType">
                                    <input type="radio" name="schemeType" value="1" title="标准方案" <c:if test="${entry.schemeType eq '1' }">checked</c:if> lay-filter="schemeType">
                                </div>
                            </div>
                            <div class="layui-col-lg6 layui-col-sm6 <c:if test="${entry.schemeType eq '2' }">layui-hide</c:if>" id="showSchemeId">
                                <label class="layui-form-label">匹配方案：</label>
                                <div class="layui-input-block">
                                    <select name="schemeId" id="schemeId" lay-search>
                                        <option value="">请选择</option>
                                        <c:forEach items="${plan}" var="pla">
                                            <option value="${pla.columns.id}" <c:if test="${entry.schemeId eq pla.columns.id}">selected</c:if> >${pla.columns.name}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                            <div id="zuhefangan" class="<c:if test="${entry.schemeType eq '1' }">layui-hide</c:if>">
                                <div class="layui-col-lg3 layui-col-sm3">
                                    <label class="layui-form-label"><i class="mark">*</i>组件规格：</label>
                                    <div class="layui-input-block pos-r">
                                        <input type="text" name="componentSpec" id="componentSpec" placeholder="" onchange="checkSpce(this.value)"
                                               autocomplete="off" class="layui-input" value="${entry.componentSpec}" >
                                        <span class="pos-a h-32 lh-32 layui-span-unit" >W</span>
                                    </div>
                                </div>

                                <div class="layui-col-lg3 layui-col-sm3">
                                    <label class="layui-form-label"><i class="mark">*</i>总组件块数：</label>
                                    <div class="layui-input-block pos-r">
                                        <input type="text" placeholder="" name="componentCount" id="componentCount"
                                               autocomplete="off" class="layui-input layui-bg-gray" value="${entry.componentCount}" readonly>
                                        <span class="pos-a h-32 lh-32 layui-span-unit" >块</span>
                                    </div>
                                </div>
                                <div class="layui-row planLie">

                                    <c:choose>
                                        <c:when test="${entry.schemeType eq '1' }">
                                            <div class="planbiao">
                                                <div class="layui-col-lg3 layui-col-sm3">
                                                    <label class="layui-form-label"><i class="mark">*</i>方案类型：</label>
                                                    <div class="layui-input-block">
                                                        <select lay-filter="planType" name="planType" class="planType">
                                                            <option value="">请选择</option>

                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3 " >
                                                    <label class="layui-form-label"><i class="mark">*</i>方案名称：</label>
                                                    <div class="layui-input-block pos-r">
                                                        <select  lay-filter="planName" name="planName" class="planName" lay-search>
                                                            <option value="">请选择</option>

                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3 " >
                                                    <label class="layui-form-label"><i class="mark">*</i>组件块数：</label>
                                                    <div class="layui-input-block pos-r">
                                                        <input type="hidden" class="yuanshiNum">
                                                        <input type="text" name="componentNum"  placeholder="" onchange="componentCountq(this.value)"
                                                               autocomplete="off" class="layui-input componentNum" value="">
                                                        <span class="pos-a h-32 lh-32 layui-span-unit" >块</span>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3" style="text-align: center" >
                                                    <input type="hidden" class="planId">
                                                    <input type="hidden" class="planCode">
                                                    <button type="button" class="layui-btn savePlan" onclick="savePlan(this)">新增方案</button>
                                                    <button type="button" class="layui-btn layui-btn-primary deletePlan layui-hide" onclick="deletePlan(this)">删除</button>
                                                </div>
                                            </div>
                                        </c:when>
                                        <c:when test="${entry.schemeType eq '2'&& empty compose}">
                                            <div class="planbiao">
                                                <div class="layui-col-lg3 layui-col-sm3">
                                                    <label class="layui-form-label"><i class="mark">*</i>方案类型：</label>
                                                    <div class="layui-input-block">
                                                        <select lay-filter="planType" name="planType" class="planType">
                                                            <option value="">请选择</option>

                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3 " >
                                                    <label class="layui-form-label"><i class="mark">*</i>方案名称：</label>
                                                    <div class="layui-input-block pos-r">
                                                        <select  lay-filter="planName" name="planName" class="planName" lay-search>
                                                            <option value="">请选择</option>

                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3 " >
                                                    <label class="layui-form-label"><i class="mark">*</i>组件块数：</label>
                                                    <div class="layui-input-block pos-r">
                                                        <input type="hidden" class="yuanshiNum">
                                                        <input type="text" name="componentNum"  placeholder="" onchange="componentCountq(this.value)"
                                                               autocomplete="off" class="layui-input componentNum" value="">
                                                        <span class="pos-a h-32 lh-32 layui-span-unit" >块</span>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3" style="text-align: center" >
                                                    <input type="hidden" class="planId">
                                                    <input type="hidden" class="planCode">
                                                    <button type="button" class="layui-btn savePlan" onclick="savePlan(this)">新增方案</button>
                                                    <button type="button" class="layui-btn layui-btn-primary deletePlan layui-hide" onclick="deletePlan(this)">删除</button>
                                                </div>
                                            </div>
                                        </c:when>
                                    </c:choose>
                                   <%-- <c:if test="${entry.schemeType eq '1' }">
                                        <div class="planbiao">
                                            <div class="layui-col-lg3 layui-col-sm3">
                                                <label class="layui-form-label"><i class="mark">*</i>方案类型：</label>
                                                <div class="layui-input-block">
                                                    <select lay-filter="planType" name="planType" class="planType">
                                                        <option value="">请选择</option>

                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-col-lg3 layui-col-sm3 " >
                                                <label class="layui-form-label"><i class="mark">*</i>方案名称：</label>
                                                <div class="layui-input-block pos-r">
                                                    <select  lay-filter="planName" name="planName" class="planName">
                                                        <option value="">请选择</option>

                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-col-lg3 layui-col-sm3 " >
                                                <label class="layui-form-label"><i class="mark">*</i>组件块数：</label>
                                                <div class="layui-input-block pos-r">
                                                    <input type="hidden" class="yuanshiNum">
                                                    <input type="text" name="componentNum"  placeholder="" onchange="componentCountq(this.value)"
                                                           autocomplete="off" class="layui-input componentNum" value="">
                                                    <span class="pos-a h-32 lh-32 layui-span-unit" >块</span>
                                                </div>
                                            </div>
                                            <div class="layui-col-lg3 layui-col-sm3" style="text-align: center" >
                                                <input type="hidden" class="planId">
                                                <input type="hidden" class="planCode">
                                                <button type="button" class="layui-btn savePlan" onclick="savePlan(this)">新增方案</button>
                                                <button type="button" class="layui-btn layui-btn-primary deletePlan layui-hide" onclick="deletePlan(this)">删除</button>
                                            </div>
                                        </div>
                                    </c:if>
                                    <c:if test="${empty compose}">

                                            <div class="planbiao">
                                                <div class="layui-col-lg3 layui-col-sm3">
                                                    <label class="layui-form-label"><i class="mark">*</i>方案类型：</label>
                                                    <div class="layui-input-block">
                                                        <select lay-filter="planType" name="planType" class="planType">
                                                            <option value="">请选择</option>

                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3 " >
                                                    <label class="layui-form-label"><i class="mark">*</i>方案名称：</label>
                                                    <div class="layui-input-block pos-r">
                                                        <select  lay-filter="planName" name="planName" class="planName">
                                                            <option value="">请选择</option>

                                                        </select>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3 " >
                                                    <label class="layui-form-label"><i class="mark">*</i>组件块数：</label>
                                                    <div class="layui-input-block pos-r">
                                                        <input type="hidden" class="yuanshiNum">
                                                        <input type="text" name="componentNum"  placeholder="" onchange="componentCountq(this.value)"
                                                               autocomplete="off" class="layui-input componentNum" value="">
                                                        <span class="pos-a h-32 lh-32 layui-span-unit" >块</span>
                                                    </div>
                                                </div>
                                                <div class="layui-col-lg3 layui-col-sm3" style="text-align: center" >
                                                    <input type="hidden" class="planId">
                                                    <input type="hidden" class="planCode">
                                                    <button type="button" class="layui-btn savePlan" onclick="savePlan(this)">新增方案</button>
                                                    <button type="button" class="layui-btn layui-btn-primary deletePlan layui-hide" onclick="deletePlan(this)">删除</button>
                                                </div>
                                            </div>

                                    </c:if>--%>
                                    <c:forEach items="${compose}" var="com" varStatus="ind">
                                    <div class="planbiao <c:if test="${ind.index ne 0}">addplan</c:if>">
                                        <div class="layui-row ">
                                        <div class="layui-col-lg3 layui-col-sm3">
                                            <label class="layui-form-label"><i class="mark">*</i>方案类型：</label>
                                            <div class="layui-input-block">
                                                <select lay-filter="planType" name="planType" class="planType" lay-search>
                                                    <option value="">请选择 </option>

                                                    <c:forEach items="${comPlan}" var="pla">
                                                        <option value="${pla.columns.id}" title="${pla.columns.assembly_count}" date ="${pla.columns.code}" <c:if test="${com.planType eq pla.columns.plan_type}">selected</c:if>  >${pla.columns.plan_type}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-col-lg3 layui-col-sm3 " >
                                            <label class="layui-form-label"><i class="mark">*</i>方案名称：</label>
                                            <div class="layui-input-block pos-r">
                                                <select  lay-filter="planName" name="planName" class="planName" lay-search>
                                                    <option value="" >请选择</option>
                                                    <option value="${com.planId}" title="${com.componentNum}" date ="${com.code}" selected >${com.name}</option>
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-col-lg3 layui-col-sm3 " >
                                            <label class="layui-form-label"><i class="mark">*</i>组件块数：</label>
                                            <div class="layui-input-block pos-r">
                                                <input type="hidden" class="yuanshiNum" value="${com.componentNum}">
                                                <input type="text" name="componentNum"  placeholder="" onchange="componentCountq(this.value)"
                                                       autocomplete="off" class="layui-input componentNum" value="${com.componentNum}">
                                                <span class="pos-a h-32 lh-32 layui-span-unit" >块</span>
                                            </div>
                                        </div>
                                        <div class="layui-col-lg3 layui-col-sm3" style="text-align: center" >
                                            <input type="hidden" class="planId" value="${com.planId}">
                                            <input type="hidden" class="planCode" value="${com.code}">
                                           <c:if test="${ind.last}">
                                            <button type="button" class="layui-btn savePlan" onclick="savePlan(this)">新增方案</button>
                                           </c:if>
                                            <c:if test="${!ind.last}">
                                            <button type="button" class="layui-btn layui-btn-primary deletePlan " onclick="deletePlan(this)">删除</button>
                                            </c:if>
                                        </div>
                                        </div>
                                    </div>
                                    </c:forEach>
                                </div>

                                <div class="layui-col-xs12">
                                    <label class="layui-form-label" >方案备注：</label>
                                    <div class="layui-input-block">
                                        <textarea name="schemeRemarks" id="schemeRemarks" placeholder="" class="layui-textarea" lay-verify="required" >${entry.schemeRemarks}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-card-body layui-col-xs1 right-btn pr-10">
                <div class="layui-btn-container">

                        <button type="button" class="layui-btn  reSubmi" >提交审核</button>

                    <button type="button" class="layui-btn  cancelorder layui-btn-primary" >取消</button>
                </div>
            </div>
        </form>
    </div>
</div>


<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.js"></script>
<script>
    //图片查看效果
    var viewer = new Viewer(document.getElementById('LAY_app'));
    var imgsCount=0;
    var serviceType = '${order.serviceType}';
    var reg = /^(?:[1-9]\d*|0)(?:\.\d+)?$/;
    var plan_html ="<option value=''>请选择</option>";
    var plan_type_html ="<option value=''>请选择</option>";
    layui.config({
        base: '${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'form', 'layedit', 'laydate','jquery','upload','layer'], function () {
          $ = layui.$
            , element = layui.element
            , form = layui.form
            , layer = layui.layer
            ,laydate = layui.laydate;
       var  upload = layui.upload;
        //执行实例

      /*  if(_checkProjectCode('${entry.projectCode}')){
            $(".reSubmi").hide();
            return
        }*/

        var uploadInst = upload.render({
            elem: '#uploader' //绑定元素
            , url: '${ctx}/common/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                });
            }
            , done: function (res) {
                //上传完毕回调
                addImg(res.path,"uploader","imgsDiv","imgPicker");
            }
            , error: function () {
                //请求异常回调
            }
        });

        upload.render({
            elem: '#uploaderone' //绑定元素
            , url: '${ctx}/common/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                });
            }
            , done: function (res) {
                //上传完毕回调
                addImg(res.path,"uploaderone","imgsDiv1","roof_photo_one");
            }
            , error: function () {
                //请求异常回调
            }
        });

        upload.render({
            elem: '#uploader2' //绑定元素
            , url: '${ctx}/common/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                });
            }
            , done: function (res) {
                //上传完毕回调
                addImg(res.path,"uploader2","imgsDiv2","roof_photo_two");
            }
            , error: function () {
                //请求异常回调
            }
        });
        upload.render({
            elem: '#uploader3' //绑定元素
            , url: '${ctx}/common/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                });
            }
            , done: function (res) {
                //上传完毕回调
                addImg(res.path,"uploader3","imgsDiv3","roof_photo_three");
            }
            , error: function () {
                //请求异常回调
            }
        });
        upload.render({
            elem: '#uploader4' //绑定元素
            , url: '${ctx}/common/uploadFile' //上传接口
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                });
            }
            , done: function (res) {
                //上传完毕回调
                addImg(res.path,"uploader4","imgsDiv4","roof_photo_four");
            }
            , error: function () {
                //请求异常回调
            }
        });

        function addImg(data,id,imgsDiv,classimg){
            $("#"+id).hide();
            var html = '<div class="bj-img imgSpan"><span class="layui-icon-close layui-icon" onclick="delImg(this,\''+id+'\')"></span>';
            html += '<img src="${commonStaticImgPath}'+data+'" height="700" width="1200"/>';
            html += '<input type="hidden" class="'+classimg+'" value="'+data+'"/> </div>';
            $("#"+imgsDiv).append(html);
            //图片查看效果
            viewer.update();
        }

        //日期
        laydate.render({
            elem: '#applianceBuyTime'
            ,trigger: 'click'
        });
        //预约时间
        laydate.render({
            elem: '#promiseTime'
            ,trigger: 'click'
        });
        laydate.render({
            elem: '#repairTime'
            ,value: '${data}'
            ,type: 'datetime'
            ,trigger: 'click'
        });
        form.render(null, 'component-form-element');
        //自定义验证规则
        form.verify({
            title: function(value){
                if(value.length < 5){
                    return '标题至少得5个字符啊';
                }
            }
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
            ,recevierMobile : [ /^((0\d{2,3}-\d{7,8})|([1][3,4,5,7,8,8,9][0-9]{9}))$/
                , '请输入正确格式的联系电话！'
            ]
            ,content: function(value){
                layedit.sync(editIndex);
            }
        });

        form.on('radio(schemeType)', function(data){
            var type= data.value;
            if('1'==type){
                //标准
                $("#showSchemeId").removeClass("layui-hide");
                $("#zuhefangan").addClass("layui-hide");
                //清除
                $(".planType").empty();
                $(".planName").empty();
                $(".componentNum").val('');
                $("#componentCount").val('0');
                $(".addplan").remove();
                $("#componentSpec").val('');
                form.render('select');
            }else{
                $("#zuhefangan").removeClass("layui-hide");
                $("#showSchemeId").addClass("layui-hide");
                $("#schemeId").val('');
                form.render('select');
                $(".deletePlan").hide();
                $(".savePlan").show();
            }
        });

        form.on('select(projectId)',function(data){
            var name = $(data.elem).find("option:selected").attr("title");

            var modeId = $(data.elem).find("option:selected").attr("data-key");

            var management=$(data.elem).find("option:selected").attr("data-anim");

            var data =$(data.elem).find("option:selected").attr("data-type");
            $("#projectName").val(name);

            $("#managementType").val("");
            if(!isBlank(management)){
                if("2"==management){
                    $("#managementType").val("浙江浙银金融租赁股份有限公司");
                }

            }
            if(!isBlank(modeId)){
                $("#method").empty();
                var htmls =" <option value=''>请选择</option>";
                var result =modeId.split(",");
                var dataName = data.split(",");
                for(var i=0;i<result.length;i++){
                    var city = result[i];
                    htmls =htmls+ '<option value="'+city+'" >'+dataName[i]+'</option>';
                }

                $("#method").append(htmls);
                form.render('select');
            }

        })

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

        });


        form.on('select(planType)',function(data){

            var value = $(data.elem).find("option:selected").text();
            if(isBlank(value)){
                return
            }
            var that_=$(this);
            var va = $("#componentSpec").val();
         /*   var planName = $(this).parents(".planbiao").find(".planName").find("option:selected").val();
            if(isBlank(planName)){*/
                //获取当前类型下的方案名称
                $.ajax({
                    url:"${ctx}/planManage/findPlanByAssembly",
                    type:"POST",
                    data:{
                        assembly:va,
                        planType:value
                    }
                    ,success:function (result) {
                        that_.parents(".planbiao").find(".planName").empty();
                        var modeId = $("#projectId").find("option:selected").attr("data-key");
                        var length = result.length;
                        var plan_name_html ="<option value=''>请选择</option>";
                        for(var i =0;i<length;i++){

                            if(isBlank(modeId)){
                                plan_name_html +="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.code+"'>"+result[i].columns.name+"</option>";
                            }else if(modeId.search(result[i].columns.id)){
                                plan_name_html +="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.code+"'>"+result[i].columns.name+"</option>";
                            }
                        }
                        that_.parents(".planbiao").find(".planName").append(plan_name_html);
                        form.render('select');
                    }
                })
        /*    }else{
                //名称已选，获取块数
                var num = $(data.elem).find("option:selected").attr("title");
                var code = $(data.elem).find("option:selected").attr("date");
                var id = data.value;
                console.log(num)
                console.log(id)
                $(this).parents(".planbiao").find(".planId").val(id);
                $(this).parents(".planbiao").find(".componentNum").val(num);
                $(this).parents(".planbiao").find(".yuanshiNum").val(num);
                $(this).parents(".planbiao").find(".planCode").val(code);
                componentNum();
            }*/

        })


        form.on('select(planName)',function(data){

            //   var value = data.value;
            var value = $(data.elem).find("option:selected").text();
            if(isBlank(value)){
                return
            }
            var that_=$(this);
            var va = $("#componentSpec").val();
            /*var planType = $(this).parents(".planbiao").find(".planType").find("option:selected").val();
            if(isBlank(planType)){
                //获取当前类型下的方案名称
                $.ajax({
                    url:"${ctx}/planManage/findPlanByAssembly",
                    type:"POST",
                    data:{
                        assembly:va,
                        name:value
                    }
                    ,success:function (result) {
                        that_.parents(".planbiao").find(".planType").empty();
                        var length = result.length;
                        var type_html ="<option value=''>请选择</option>";
                        for(var i =0;i<length;i++){
                            type_html +="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.id+"'>"+result[i].columns.plan_type+"</option>";
                        }
                        that_.parents(".planbiao").find(".planType").append(type_html);
                        form.render('select');
                    }
                })
            }else{*/
                //名称已选，获取块数
                var num = $(data.elem).find("option:selected").attr("title");
                var code = $(data.elem).find("option:selected").attr("date");
                var id = data.value;
                $(this).parents(".planbiao").find(".planId").val(id);
                $(this).parents(".planbiao").find(".componentNum").val(num);
                $(this).parents(".planbiao").find(".yuanshiNum").val(num);
                $(this).parents(".planbiao").find(".planCode").val(code);
                componentNum();
          //  }

        })


        if("2"==${entry.schemeType}&&!isBlank(${entry.componentSpec})){
            $.ajax({
                url:"${ctx}/planManage/findPlanByAssembly",
                type:"POST",
                data:{
                    assembly:"${entry.componentSpec}",
                    projectId:"${entry.projectId}"
                }
                ,success:function (result) {
                    var length = result.length;
                    for(var i =0;i<length;i++){
                        plan_type_html+="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.code+"'>"+result[i].columns.plan_type+"</option>";
                        plan_html +="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.code+"'>"+result[i].columns.name+"</option>";
                    }
                    <c:if test="${empty compose}">
                    $(".planType").empty();

                    $(".planType").append(plan_type_html);
                    //  $(".planName").append(plan_html);
                    form.render('select');
                    </c:if>


                }
            })
        }

        //重新计算组件块数
        function componentNum(){
            var numco = 0;
            $(".componentNum").each(function(){
                if(!isBlank($(this).val())){
                    numco = numco+parseInt($(this).val());
                }
            });
            $("#componentCount").val(parseInt(numco));
        }

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

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

        }

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

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

        }

        //保存
        var saveFlag=false;
        $(".saveOrder").click(function(){
            if(saveFlag){
                return;
            }
            //验证不必填项的值格式
            var shuzi = /[0-9]*[1-9][0-9]*$/;
            var projectId=$("#projectId").val();  //信息来源
            var id = "${entry.id}";

            if(isBlank(projectId)){
                layer.msg("请输入选择项目!",{icon:2});
                return false;
            }
            var distributorId = $("#distributorId").val();
            var tenantName = $("input[name=tenantName]").val();//用户姓名
            var mobile = $("input[name=mobile]").val();//联系方式1
            var idCode = $("input[name=idCode]").val();//
            var province = $("#province").find("option:selected").val();//省
            var city = $("#city").find("option:selected").val();//市
            var area = $("#area").find("option:selected").val();//区
            var address = $("input[name=customerAddress]").val();//用户地址
            var hireStatus=$("#hireStatus").val();

            var roofType=$("#roofType").val(); //类型
            var angle=$("#angle").val();//
            var method=$("#method").val();
            var distance=$("#distance").val(); //
            var remarks = $("textarea[name=remarks]").val();//


            var imgs = $(".imgPicker").val();
            var one = $(".roof_photo_one").val();
            var two = $(".roof_photo_two").val();
            var three = $(".roof_photo_three").val();
            var four = $(".roof_photo_four").val();


            var schemeRemarks = $("#schemeRemarks").val();
            var componentCount = $("#componentCount").val();
            var componentSpec = $("#componentSpec").val();
            var schemeType = $("input[name=schemeType]:checked").val();
            var schemeId = "";


            <c:if test="${entry.status ne '0'}">

            if (isBlank(tenantName)) {
                layer.msg("请输入业主姓名!", {icon: 2});
                return false
            }
            if (isBlank(mobile)) {
                layer.msg("请输入联系方式",{icon:2});
                return
            } else if (!isPhoneNo($.trim(mobile))) {
                layer.msg("手机号码格式不正确",{icon:2});
                return
            } ;
            if (isBlank(idCode)) {
                layer.msg("请输入身份证号",{icon:2});
                return
            } else if (!IsCard($.trim(idCode))) {
                layer.msg("身份证号码格式不正确",{icon:2});
                return
            }
        /*    if (isBlank(hireStatus)) {
                layer.msg("请选择租赁状态",{icon:2});
                return
            }*/
            if(isBlank(province)){
                layer.msg("请输入省",{icon:2});
                return
            }
            if(isBlank(city)){
                layer.msg("请输入市",{icon:2});
                return
            }
            if(isBlank(area)){
                layer.msg("请输入区",{icon:2});
                return
            }
            if (isBlank(address)) {
                layer.msg("请输入详细地址",{icon:2});
                return
            }


            if (isBlank(roofType)) {
                layer.msg("请选择房屋类型",{icon:2});
                return
            }
            if (isBlank(angle)) {
                layer.msg("请输入角度朝向",{icon:2});
                return
            }
            if (isBlank(method)) {
                layer.msg("请选择安装方式",{icon:2});
                return
            }
            if (isBlank(distance)) {
                layer.msg("请输入并网距离",{icon:2});
                return
            }else if (!isNumber($.trim(distance))) {
                layer.msg("并网距离格式不正确",{icon:2});
                return
            }
            if (isBlank(one)) {
                layer.msg("请上传房屋俯拍图照片",{icon:2});
                return
            }
            if (isBlank(two)) {
                layer.msg("请上传房屋角度南照片",{icon:2});
                return
            }
            if (isBlank(imgs)) {
                layer.msg("请上传屋顶尺寸照片",{icon:2});
                return
            }
            </c:if>


            var arr = [];
            if("2"==schemeType){
                var checkNum=false;
                $('.planbiao').each(function(){
                    var material = {};
                    if(isBlank($(this).find(".planCode").val())){
                        return
                    }
                    var na = $(this).find(".planName").find("option:selected").text();
                    if("请选择"==na){
                        na="";
                    }
                    var ty = $(this).find(".planType").find("option:selected").text();
                    if("请选择"==na){
                        ty="";
                    }
                    var coum=$(this).find(".componentNum").val()
                    if(isBlank(coum)){
                        coum =0;
                    }
                    material.code = $(this).find(".planCode").val();
                    material.name = na;
                    material.planType = ty;
                    material.componentNum = coum;
                    material.planId=$(this).find(".planId").val()
                    arr.push(material);
                    var yuanshiNum = $(this).find(".yuanshiNum").val();
                    if($(this).find(".componentNum").val() != yuanshiNum){
                        checkNum = true;
                    }
                });
                if(checkNum){
                    if(isBlank(schemeRemarks)){
                        layer.msg("请输入方案备注",{icon:2});
                        return
                    }
                }
            }else{
                schemeId = $("#schemeId").val();
            }
            var order={
                id:id,
                projectId:projectId,
                distributorId:distributorId,
                tenantName:tenantName,
                mobile:mobile,
                idCode:idCode,
                province:province,
                city:city,
                area:area,
                address:address,
                hireStatus:hireStatus,
                roofType:roofType,
                angle:angle,
                method:method,
                distance:distance,
                remarks:remarks,
                dimensionsImgs:imgs,
                roofPhotoOne:one,
                roofPhotoTwo:two,
                roofPhotoThree:three,
                roofPhotoFour:four,
                type:0,
                schemeRemarks:schemeRemarks,
                componentCount:componentCount,
                componentSpec:componentSpec,
                schemeType:schemeType,
                schemeId:schemeId
            };
            order.composePlanLists = arr;
            saveFlag=true;
            $.ajax({
                url:"${ctx}/customerEntry/updateCustomerEntry",
                type:"POST",
                contentType : "application/json;charsetset=UTF-8",
                data:JSON.stringify(order)
                ,success:function (result) {
                   // console.log(JSON.stringify(order));
                    if(result.code=="202"){
                        layer.msg("必填信息为空",{icon:2});
                    }
                    if(result.code=="2001"){
                        layer.msg("当前账号已禁用或已删除，不可操作！",{icon:2});
                    }if(result.code == '200'){

                        layer.msg("保存成功",{icon:1,time:1000},function(){
                           location.reload(); //刷新父页面
                        })
                    }else{
                        layer.msg(result.errMsg,{icon:2});
                    }
                    saveFlag=false;

                },error:function () {
                    layer.msg("保存失败",{icon:2});
                    saveFlag=false;
                }
            })
        })

        //重新提交
        $(".reSubmi").click(function (){
            if(saveFlag){
                return;
            }
            //验证不必填项的值格式
            var shuzi = /[0-9]*[1-9][0-9]*$/;
            var projectId=$("#projectId").val();  //信息来源
            var id = "${entry.id}";

            if(isBlank(projectId)){
                layer.msg("请输入选择项目!",{icon:2});
                return false;
            }
            var distributorId = $("#distributorId").val();
            var tenantName = $("input[name=tenantName]").val();//用户姓名
            var mobile = $("input[name=mobile]").val();//联系方式1
            var idCode = $("input[name=idCode]").val();//
            var province = $("#province").find("option:selected").val();//省
            var city = $("#city").find("option:selected").val();//市
            var area = $("#area").find("option:selected").val();//区
            var address = $("input[name=customerAddress]").val();//用户地址
            var hireStatus=$("#hireStatus").val();

            if (isBlank(tenantName)) {
                layer.msg("请输入业主姓名!", {icon: 2});
                return false
            }
            if (isBlank(mobile)) {
                layer.msg("请输入联系方式",{icon:2});
                return
            } else if (!isPhoneNo($.trim(mobile))) {
                layer.msg("手机号码格式不正确",{icon:2});
                return
            } ;
            if (isBlank(idCode)) {
                layer.msg("请输入身份证号",{icon:2});
                return
            } else if (!IsCard($.trim(idCode))) {
                layer.msg("身份证号码格式不正确",{icon:2});
                return
            }
         /*   if (isBlank(hireStatus)) {
                layer.msg("请选择租赁状态",{icon:2});
                return
            }*/
            if(isBlank(province)){
                layer.msg("请输入省",{icon:2});
                return
            }
            if(isBlank(city)){
                layer.msg("请输入市",{icon:2});
                return
            }
            if(isBlank(area)){
                layer.msg("请输入区",{icon:2});
                return
            }
            if (isBlank(address)) {
                layer.msg("请输入详细地址",{icon:2});
                return
            }

            var roofType=$("#roofType").val(); //类型
            var angle=$("#angle").val();//
            var method=$("#method").val();
            var distance=$("#distance").val(); //
            var remarks = $("textarea[name=remarks]").val();//


            var imgs = $(".imgPicker").val();
            var one = $(".roof_photo_one").val();
            var two = $(".roof_photo_two").val();
            var three = $(".roof_photo_three").val();
            var four = $(".roof_photo_four").val();

            var schemeRemarks = $("#schemeRemarks").val();
            var componentCount = $("#componentCount").val();
            var componentSpec = $("#componentSpec").val();
            var schemeType = $("input[name=schemeType]:checked").val();

            if (isBlank(roofType)) {
                layer.msg("请选择房屋类型",{icon:2});
                return
            }
            if (isBlank(angle)) {
                layer.msg("请输入角度朝向",{icon:2});
                return
            }
            if (isBlank(method)) {
                layer.msg("请选择安装方式",{icon:2});
                return
            }
            if (isBlank(distance)) {
                layer.msg("请输入并网距离",{icon:2});
                return
            }else if (!isNumber($.trim(distance))) {
                layer.msg("并网距离格式不正确",{icon:2});
                return
            }
      /*      if (isBlank(one)) {
                layer.msg("请上传房屋俯拍图照片",{icon:2});
                return
            }
            if (isBlank(two)) {
                layer.msg("请上传房屋角度南照片",{icon:2});
                return
            }
            if (isBlank(imgs)) {
                layer.msg("请上传屋顶尺寸照片",{icon:2});
                return
            }*/

            var order={
                id:id,
                projectId:projectId,
                distributorId:distributorId,
                tenantName:tenantName,
                mobile:mobile,
                idCode:idCode,
                province:province,
                city:city,
                area:area,
                address:address,
                hireStatus:hireStatus,
                roofType:roofType,
                angle:angle,
                method:method,
                distance:distance,
                remarks:remarks,
                dimensionsImgs:imgs,
                roofPhotoOne:one,
                roofPhotoTwo:two,
                roofPhotoThree:three,
                roofPhotoFour:four,
                type:3,
                schemeRemarks:schemeRemarks,
                componentCount:componentCount,
                componentSpec:componentSpec,
                schemeType:schemeType
            };
            var arr = [];
            $('.planbiao').each(function(){
                var material = {};
                material.code = $(this).find(".planCode").val();
                material.name = $(this).find(".planName").find("option:selected").text();
                material.planType = $(this).find(".planType").find("option:selected").text();
                material.componentNum = $(this).find(".componentNum").val();
                material.planId=$(this).find(".planId").val()
                arr.push(material);
            });
            order.composePlanLists = arr;
            console.log(order)
            saveFlag=true;
            $.ajax({
                url:"${ctx}/customerEntry/updateCustomerEntry",
                type:"POST",
                contentType : "application/json;charsetset=UTF-8",
                data:JSON.stringify(order)
                ,success:function (result) {
                    // console.log(JSON.stringify(order));
                    if(result.code=="202"){
                        layer.msg("必填信息为空",{icon:2});
                    }
                    if(result.code=="2001"){
                        layer.msg("当前账号已禁用或已删除，不可操作！",{icon:2});
                    }if(result.code == '200'){

                        layer.msg("保存成功",{icon:1,time:1000},function(){
                            location.reload(); //刷新父页面
                        })
                    }else if(result.code=="504"){
                        layer.msg(result.msg,{icon:2});
                    }else{
                        layer.msg("保存失败"+result.errMsg,{icon:2});
                    }
                    saveFlag=false;

                },error:function () {
                    layer.msg("保存失败",{icon:2});
                    saveFlag=false;
                }
            })
        })

        //取消
        $(".cancelorder").click(function(){
            parent.layer.closeAll();
           parent.searchOrder();

        })


        // 验证手机号
        function isPhoneNo(phone) {
           // var tel = /(^1\d{10}$)|(^(\d{3,4}\-)?\d{5,9}$)/;包含座机号
            var tel =  /^1[3|4|5|6|7|8|9][0-9]{9}$/;
            return tel.test($.trim(phone));
        }
        function IsCard(str) {
            var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            return reg.test(str);
        }
        function isNumber(value){
            var z_reg = /^(([0-9])|([1-9]([0-9]+)))(.[0-9]+)?$/;
            return z_reg.test(value);
        };

    });

    function deletePlan(that){
        $(that).parents(".planbiao").remove();
        var numco = 0;
        $(".componentNum").each(function(){
            if(!isBlank($(this).val())){
                numco = numco+parseInt($(this).val());
            }
        });
        $("#componentCount").val(parseInt(numco));
    }

    function savePlan(that){
        var componentSpec = $("#componentSpec").val();
        if(isBlank(componentSpec)){
            layer.msg("请输入组件规格",{icon:2});
            return
        }
        var planType= $(that).parents(".planbiao").find(".planType").val();
        var planName= $(that).parents(".planbiao").find(".planName").val();
        var componentNum= $(that).parents(".planbiao").find(".componentNum").val();
        if(isBlank(planType)){
            layer.msg("请选择方案类型",{icon:2});
            return
        }
        if(isBlank(planName)){
            layer.msg("请选择方案名称",{icon:2});
            return
        }
        if(isBlank(componentNum)){
            layer.msg("请输入组件块数",{icon:2});
            return
        }
        $(that).hide();
        $(that).next().removeClass("layui-hide").show();

        var html = '';
        html +='<div class="planbiao addplan"><div class="layui-row ">';
        html +='<div class="layui-col-lg3 layui-col-sm3">';
        html +=' <label class="layui-form-label"><i class="mark">*</i>方案类型：</label>';
        html +='<div class="layui-input-block">';
        html +='<select lay-filter="planType" name="planType" class="planType" lay-search>';
        html += plan_type_html;

        html +='</select>';
        html += '</div> </div>';
        html +='<div class="layui-col-lg3 layui-col-sm3 " >';
        html += '<label class="layui-form-label"><i class="mark">*</i>方案名称：</label>';
        html +='<div class="layui-input-block pos-r">';
        html +='<select  lay-filter="planName" name="planName" class="planName" lay-search>';
        html +='<option value="">请选择</option>';
        html +='</select>';
        html +='</div> </div>';
        html +=' <div class="layui-col-lg3 layui-col-sm3 " >';
        html +='<label class="layui-form-label"><i class="mark">*</i>组件块数：</label>';
        html +='<div class="layui-input-block pos-r"> <input type="hidden" class="yuanshiNum">';
        html +='<input type="text" name="componentNum" placeholder="" autocomplete="off" class="layui-input componentNum"  onchange="componentCountq(this.value)" value="">';
        html +='<span class="pos-a h-32 lh-32 layui-span-unit" >块</span>';
        html +='</div> </div>';
        html +='<div class="layui-col-lg3 layui-col-sm3" style="text-align: center" >';
        html +='<input type="hidden" class="planId">';
        html +='<input type="hidden" class="planCode">';
        html +='<button type="button" class="layui-btn savePlan" onclick="savePlan(this)">新增方案</button>';
        html +='<button type="button" class="layui-btn layui-btn-primary deletePlan layui-hide" onclick="deletePlan(this)">删除</button>';
        html +='</div> </div></div>';
        $(that).parents(".planLie").append(html);
        form.render('select');
    }

    //改变规格值
    function checkSpce(va){
        if(isBlank(va)){
            layer.msg("请输入组件规格",{icon:2});
            return
        }
        if(va>0){
            //清空之前的数据
            $(".addplan").remove();
            $("#componentCount").val('0');
            $(".componentNum").val('');

            $(".deletePlan").hide();
            $(".savePlan").show();
            //获取数据

            $.ajax({
                url:"${ctx}/planManage/findPlanByAssembly",
                type:"POST",
                data:{
                    assembly:va,
                    projectId:"${entry.projectId}"
                }
                ,success:function (result) {
                    $(".planType").empty();
                    $(".planName").empty();
                    console.log(result);
                    var length = result.length;
                    plan_type_html ="<option value=''>请选择</option>";
                    plan_html ="<option value=''>请选择</option>";
                    // var plan_html ="<option value=''>请选择</option>";
                    for(var i =0;i<length;i++){
                        plan_type_html+="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.code+"'>"+result[i].columns.plan_type+"</option>";
                        plan_html +="<option value='"+result[i].columns.id+"' title='"+result[i].columns.assembly_count+"' date='"+result[i].columns.code+"'>"+result[i].columns.name+"</option>";
                    }

                    $(".planType").append(plan_type_html);
                  //  $(".planName").append(plan_html);
                    form.render('select');
                }
            })
        }
    }

    function componentCountq(){
        var numco = 0;
        $(".componentNum").each(function(){
            if(!isBlank($(this).val())){
                numco = numco+parseInt($(this).val());
            }
          //  numco = numco+parseInt($(this).val());
        });
        $("#componentCount").val(parseInt(numco));
    }

    function isBlank(val) {
        if (val == null || val == '' || val == undefined) {
            return true;
        }
        return false;
    }
    function delImg(that,id){
            $("#"+id).show();
        $(that).parent().remove();
    }
</script>
</body>
</html>
