<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp" %>
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <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" 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" type="text/css" href="${ctxPlugin}/static/css/reset.css" />
  <link rel="stylesheet" href="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/dist/viewer.css" media="all">
  <style>
    .layui-form-select dl {
      max-height: 200px;
      width: 80%;
    }
    html {
      background-color: #fff;
    }
    .layui-table td, .layui-table th {
      text-align: center;
    }
    .hx_l > span {
      position: absolute;
      right: 10px;
      top: 5px
    }
    .form-span {
      display: block;
      padding: 5px 0;
      margin-left: 110px;
    }
    #attachFile > li {
      height: 26px
    }
  </style>
</head>
<body>
<div class="layui-form">
  <div class="layui-card">
    <div class="layui-card-body layui-col-xs12" id="LAY_app">
      <button class="layui-btn" style="margin-left: 94.5%;" onclick="approvalRecord()">审批记录</button>
      <div class="layui-row layui-col-space12 layui-form-item">
        <div class="layui-col-lg3 layui-col-sm3">
          <label class="layui-form-label">电站编号：</label>
          <div class="layui-input-block">
            <input type="text" id="powerStationCode" disabled name="powerStationCode"  class="layui-input" value="${entry.powerStationCode}">
          </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="entryStatus" name="entryStatus" disabled class="layui-input " value="" disabled>
          </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="traderName" name="traderName" class="layui-input layui-bg-gray" value="${entry.createTraderName}" disabled>
          </div>
        </div>
        <div class="layui-col-lg3 layui-col-sm3">
          <label class="layui-form-label">审核状态：</label>
          <div class="layui-input-block">
            <input type="text" name="status" class="layui-input layui-bg-gray" value="" disabled>
          </div>
        </div>
      <div class="layui-row layui-col-space12 layui-form-item">
        <div class="layui-col-lg3 layui-col-sm3">
          <label class="layui-form-label w-130">业主姓名：</label>
          <div class="layui-input-block ">
            <input type="text" id="tenantName" name="tenantName"  class="layui-input" value="${entry.tenantName}" disabled>
          </div>
        </div>
        <div class="layui-col-lg3 layui-col-sm3">
          <label class="layui-form-label w-130">身份证号：</label>
          <div class="layui-input-block ">
            <input type="text" id="idCode" name="idCode" class="layui-input" value="${entry.idCode}" disabled>
          </div>
        </div>
        <div class="layui-col-lg6 layui-col-sm6">
          <label class="layui-form-label w-130">安装地址：</label>
          <div class="layui-input-block ">
            <input type="text" id="address" name="address" class="layui-input" value="${entry.province}${entry.city}${entry.area}${entry.address}"  disabled>
          </div>
        </div>
        <div class="layui-col-lg3 layui-col-sm3">
          <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-col-lg3 layui-col-sm3">
          <label class="layui-form-label w-130">变更单号：</label>
          <div class="layui-input-block ">
            <input type="text" name="number" class="layui-input" value="${apply.number}" disabled>
          </div>
        </div>
        <div class="layui-col-lg3 layui-col-sm3">
          <label class="layui-form-label w-130">变更申请人：</label>
          <div class="layui-input-block ">
            <input type="text" name="creator" class="layui-input" value="${apply.creator}" disabled>
          </div>
        </div>
        <div class="layui-col-lg3 layui-col-sm3">
          <label class="layui-form-label w-130">申请时间：</label>
          <div class="layui-input-block ">
            <input type="text" name="creatTime" class="layui-input" value="${apply.createTime}" disabled>
          </div>
        </div>
      </div>
        <div class="clear-both">
          <p class="layui-elem-quote" style="margin: 0px 0px 0px 10px">产品信息</p>
          <div class="layui-form-item layui-row">
            <div class="layui-col-sm3 layui-col-md3">
              <label class="layui-form-label">备案类型：</label>
              <span class="form-span" id="filingType">
                        <c:choose>
                          <c:when test="${entry.filingType eq '1'}">
                            农户备案
                          </c:when>
                          <c:when test="${entry.filingType eq '2'}">
                            项目公司备案
                          </c:when>
                        </c:choose>
                    </span>
            </div>
            <div class="layui-col-sm3 layui-col-md3">
              <label class="layui-form-label">项目公司：</label>
              <span class="form-span" id="projectCompanyName">
                ${entry.projectCompanyName}
              </span>
            </div>
            <div class="layui-col-sm3 layui-col-md3">
              <label class="layui-form-label">业务属性：</label>
              <span class="form-span" id="productLine">
                        <c:choose>
                          <c:when test="${entry.productLine eq '1'}">
                            纯租25年业务
                          </c:when>
                          <c:when test="${entry.productLine eq '2'}">
                            经营性租赁
                          </c:when>
                          <c:when test="${entry.productLine eq '3'}">
                            融资租赁
                          </c:when>
                          <c:when test="${entry.productLine eq '4'}">
                            光伏贷
                          </c:when>
                          <c:when test="${entry.productLine eq '5'}">
                            全款
                          </c:when>
                          <c:when test="${entry.productLine eq '6'}">
                            其他
                          </c:when>
                          <c:otherwise>
                            ${entry.productLine}
                          </c:otherwise>
                        </c:choose>
                    </span>
            </div>
            <div class="layui-col-sm12 layui-col-md12" id="projectTab">
              <table class="layui-table">
                <colgroup>
                  <col width="25%">
                  <col width="25%">
                  <col width="25%">
                  <col width="25%">
                </colgroup>
                <thead>
                <tr style="background: white">
                  <th style="text-align: center">序号</th>
                  <th style="text-align: center">产品编号</th>
                  <th style="text-align: center">产品名称</th>
                  <th style="text-align: center">屋顶类型</th>
                </tr>
                </thead>
                <tbody id="projectList">
                <c:forEach items="${projectList}" varStatus="vs" var="project">
                  <tr style="text-align: center" class="projectTr" >
                    <td>${vs.count}</td>
                    <td>${project.columns.projectCode}</td>
                    <td>${project.columns.projectName}</td>
                    <td>${project.columns.roofType}</td>
                  </tr>
                </c:forEach>
                </tbody>
              </table>
            </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="" disabled class="layui-textarea">${apply.changeReason}</textarea>
            </div>
          </div>
        </div>
      <div class="layui-col-xs12 mb-20 pr-30 mt-10">
        <p class="layui-elem-quote" style="margin: 0px 0px 0px 10px">物料信息</p>
        <div class="layui-tab layui-tab-brief" lay-filter="materialTabBrief" id="materialInfoTab">
          <ul class="layui-tab-title" id="materialInfoUl">
            <c:forEach items="${projectList}" var="entryProject" varStatus="vs">
              <li class=" <c:if test="${vs.index eq 0}">layui-this</c:if>" id="${entryProject.columns.projectCode}">
                <c:choose>
                  <c:when test="${not empty entryProject.columns.roofType}">
                    ${entryProject.columns.roofType}
                  </c:when>
                  <c:otherwise>
                    ${entryProject.columns.projectName}
                  </c:otherwise>
                </c:choose>
              </li>
            </c:forEach>
          </ul>
          <c:forEach items="${projectList}" var="entryProject" varStatus="vs">
            <div class="layui-tab layui-tab-brief  materialTabContent <c:if test="${vs.index ne 0}">layui-hide</c:if>  " lay-filter="docDemoTabBrief">
              <ul class="layui-tab-title">
                <li class="layui-this">组件</li>
                <li>逆变器</li>
              </ul>
              <div class="layui-tab-content" style="overflow: auto;margin-bottom: 120px">
                <div class="layui-tab-item layui-show">
                  <table class="layui-table">
                    <thead>
                    <tr>
                      <th>序号</th>
                      <th>物料代码</th>
                      <th>物料名称</th>
                      <th>物料规格</th>
                      <th>品牌</th>
                      <th>变更前物料条码</th>
                      <th>变更后物料条码</th>
                    </tr>
                    </thead>
                    <tbody id="materialTable"+${vs.count}>
                    <c:forEach items="${entryProject.columns.zjList}" varStatus="vs" var="material">
                      <tr>
                        <td>${vs.count}</td>
                        <td>${material.columns.material_code}</td>
                        <td>${material.columns.material_name}</td>
                        <td>${material.columns.material_spec}</td>
                        <td>${material.columns.material_brand}</td>
                        <td>${material.columns.barcode}</td>
                        <td>${material.columns.new_barcode}</td>
                      </tr>
                    </c:forEach>
                    </tbody>
                  </table>
                </div>
                <div class="layui-tab-item">
                  <table class="layui-table">
                    <thead>
                    <tr>
                      <th>序号</th>
                      <th>物料代码</th>
                      <th>物料名称</th>
                      <th>物料规格</th>
                      <th>品牌</th>
                      <th>逆变器sn码</th>
                      <th>变更后逆变器sn码</th>
                      <th>通讯棒sn码</th>
                      <th>变更后通讯棒sn码</th>
                      <th>验证码</th>
                      <th>变更后验证码</th>
                    </tr>
                    </thead>
                    <tbody id="nbqTable"+${vs.count}>
                    <c:forEach items="${entryProject.columns.nbqList}" varStatus="vs" var="material">
                      <tr>
                        <td>${vs.count}</td>
                        <td>${material.columns.material_code}</td>
                        <td>${material.columns.material_name}</td>
                        <td>${material.columns.material_spec}</td>
                        <td>${material.columns.material_brand}</td>
                        <td>${material.columns.nbq_sn}</td>
                        <td>${material.columns.new_nbq_sn}</td>
                        <td>${material.columns.sn}</td>
                        <td>${material.columns.new_sn}</td>
                        <c:choose>
                          <c:when test="${material.columns.material_brand eq '固德威' || material.columns.material_brand eq '爱士惟'}">
                            <td>${material.columns.yz_code}</td>
                            <td>${material.columns.new_yz_code}</td>
                          </c:when>
                          <c:otherwise>
                            <td>--</td>
                            <td>--</td>
                          </c:otherwise>
                        </c:choose>
                      </tr>
                    </c:forEach>
                    </tbody>
                  </table>
                </div>
              </div>
            </div>
          </c:forEach>
        </div>
      </div>
      <div class="layui-inline layui-col-xs12" style="position: fixed;bottom: 30px;background: #F8F8F8;padding-bottom: 20px;">
        <label class="layui-form-label w-130">审核备注：</label>
        <div class="layui-input-block ">
          <textarea name="auditRemarks" disabled id="auditRemarks" placeholder="" class="layui-textarea">${apply.auditRemarks}</textarea>
        </div>
      </div>
    </div>
  </div>
</div>
</div>
<div class="layui-form-item text-c operate-footer">
  <button class="layui-btn layui-btn-primary" onclick="closeDiv()">关闭</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 type="text/javascript">

  //图片查看效果
  var viewer = new Viewer(document.getElementById('LAY_app'));
  layui.use(['form', 'table', 'upload', 'jquery', 'element'], function () {
    $ = layui.$;
    layer = layui.layer;
    element = layui.element;

    element.on('tab(materialTabBrief)', function (data) {
      $('.materialTabContent').eq(data.index).removeClass('layui-hide').siblings('.materialTabContent').addClass('layui-hide');
    });


    $(function(){
      $("input[name='entryStatus']").val(getStatus('${entry.status}','${entry.credit}','${entry.designAuditFlag}'));
      $("input[name='status']").val(getStatus2('${apply.status}'));
    })

  })

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

  // 状态 0.待审核 1.审核通过 2.审核驳回
  function getStatus2(status){
    if (status == '0'){
      return '待审核';
    }else if (status == '1') {
      return '审核通过';
    }else if (status == '2') {
      return '审核驳回';
    }else if (status == '3') {
      return '已撤回';
    }
  }

  function closeDiv() {
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index);
  }

  function isBlank(val) {
    if (val == null || val == '' || val == undefined) {
      return true;
    }
    return false;
  }
  function approvalRecord(){
    layer.open({
      title: '审批记录',
      type: 2,
      area: ['35%', '100%'],
      offset: 'rt',
      content: '${ctx}/customerEntry/approvalRecordPage?entryId=${entry.id}'
    })
  }
</script>
</body>
</html>


