<%@ 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" href="${ctxPlugin}/static/css/reset.css" media="all">
  <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;
    }
    .w-130{ width: 150px}
    .w-130+.layui-input-block{margin-left: 150px}
    .layui-tab-title li {
      line-height: 40px !important;
    }
    .form-span {
      display: block;
      padding: 8px 0;
      margin-left: 110px;
    }
    .link-blue{ color: #1b6073; cursor: pointer;}
  </style>
</head>
<body>
<div class="layui-form">
  <div class="layui-card" id="LAY_app">
    <div class="layui-card-body pt-20 pb-40 h-350">
      <div class="layui-col-xs12 mb-10 pr-30">
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="red">*</i>公司名称：</label>
          <div class="layui-input-block">
            <input type="text"  name="name"  autocomplete="off" placeholder="请输入" lay-verify="required"  class="layui-input" value="${company.columns.name}" disabled>
          </div>
        </div>
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130" ><i class="red">*</i>公司性质：</label>
          <div class="layui-input-block" >
            <select  name="type"  lay-verify="required"  lay-filter="projectCompany" disabled>
              <option value="">请选择</option>
              <option value="0" ${company.columns.type eq '0'?'selected':''}>项目公司</option>
              <option value="1" ${company.columns.type eq '1'?'selected':''}>EPC公司</option>
            </select>
          </div>
        </div>
      </div>
      <div class="layui-col-xs12 mb-10 pr-30">
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="red">*</i>统一社会信用代码：</label>
          <div class="layui-input-block">
            <input type="text"  name="enterpriseQualificationNumber"  autocomplete="off" placeholder="请输入" lay-verify="required"  class="layui-input" value="${company.columns.enterprise_qualification_number}" disabled>
          </div>
        </div>
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="red">*</i>法定代表人：</label>
          <div class="layui-input-block ">
            <input type="text"  name="chargePerson"  autocomplete="off" placeholder="请输入" lay-verify="required"  class="layui-input" value="${company.columns.charge_person}" disabled>
          </div>
        </div>
      </div>
      <div class="layui-col-xs12 mb-10 pr-30">
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="red">*</i>代表人身份证号：</label>
          <div class="layui-input-block">
            <input type="text" name="chargePersonIdCard"  placeholder="请输入"  lay-verify="required"  class="layui-input" value="${company.columns.charge_person_id_card}" disabled>
          </div>
        </div>
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130">联系电话：</label>
          <div class="layui-input-block" >
            <input type="text" name="telephone" lay-verify="telephone" autocomplete="off"  class="layui-input" value="${company.columns.telephone}" disabled>
          </div>
        </div>
      </div>
      <div class="layui-col-xs12 mb-10 pr-30">
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="red">*</i>公司代码：</label>
          <div class="layui-input-block">
            <input type="text" name="companyCode" lay-verify="required" autocomplete="off" placeholder="请输入公司代码" class="layui-input" value="${company.columns.company_code}" disabled>
          </div>
        </div>
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130" ><i class="red">*</i>所属资方：</label>
          <div class="layui-input-block" >
            <select  name="partner" class="partner" id="partner"  lay-verify="required" lay-filter="partner" disabled>
              <option value="">请选择</option>
              <c:forEach items="${paterns}" var="patern">
                <option value="${patern.columns.id}" <c:if test="${company.columns.partner == patern.columns.id}">selected</c:if>>${patern.columns.name}</option>
              </c:forEach>
            </select>
          </div>
        </div>
      </div>
      <div class="layui-col-xs12 mb-10 pr-30">
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="mark">*</i>备案方式：</label>
          <div class="layui-input-block">
            <select name="filingType" lay-verify="required" disabled>
              <option value="">请选择</option>
              <option value="1" <c:if test="${company.columns.filing_type eq '1'}">selected</c:if>>农户备案</option>
              <option value="2" <c:if test="${company.columns.filing_type eq '2'}">selected</c:if>>项目公司备案</option>
            </select>
          </div>
        </div>
        <div class="layui-inline layui-col-xs6">
          <label class="layui-form-label w-130"><i class="red">*</i>法人授权电话：</label>
          <div class="layui-input-block" >
            <input type="text" name="psnAccount"  lay-verify="required"  disabled  autocomplete="off" class="layui-input" value="${company.columns.psn_account}">
          </div>
        </div>
      </div>

      <div class="layui-col-xs12 mb-10 pr-30">
        <label class="layui-form-label w-130" ><i class="red">*</i>注册地址：</label>
        <div class="layui-input-block ml-130">
          <div class="layui-col-xs2 pr-20">
            <select class="province" id="province" name="province"  lay-verify="required"  lay-filter="province" lay-search disabled>
              <option value="">请选择省</option>
              <c:forEach items="${province}" var="pro">
                <option value="${pro.columns.ProvinceName}" title="${pro.columns.ProvinceID}" <c:if test="${company.columns.province == pro.columns.ProvinceName}">selected</c:if>>${pro.columns.ProvinceName}</option>
              </c:forEach>
            </select>
          </div>
          <div class="layui-col-xs2 pr-20">
            <select class="city" name="city" id="city" lay-verify="required"  lay-filter="city" lay-search disabled>
              <option value="">请选择市</option>
              <c:forEach items="${city}" var="cityList">
                <option value="${cityList.columns.CityName}" title="${cityList.columns.CityID}" <c:if test="${company.columns.city==cityList.columns.CityName}">selected</c:if>>${cityList.columns.CityName}</option>
              </c:forEach>
            </select>
          </div>
          <div class="layui-col-xs2 pr-20">
            <select class="area" name="area" id="area" lay-verify="required"  lay-filter="area" lay-search disabled>
              <option value="">请选择县/区</option>
              <c:forEach items="${area}" var="areaList">
                <option value="${areaList.columns.DistrictName}" <c:if test="${company.columns.area==areaList.columns.DistrictName}">selected</c:if>>${areaList.columns.DistrictName}</option>
              </c:forEach>
            </select>
          </div>
          <div class="layui-col-xs5 pr-20">
            <input type="text" id="address" name="address" lay-verify="required" placeholder="请输入详细地址" class="layui-input layui-col-lg2"
                   value="${company.columns.address}" disabled>
          </div>
        </div>
      </div>
      <div id="insuranceDiv" <c:if test="${company.columns.partner ne '03'}">class="layui-hide"</c:if>>
        <div class="layui-col-xs12 mb-10 pr-30">
          <div class="layui-inline layui-col-xs4">
            <label class="layui-form-label w-130">保险公司：</label>
            <div class="layui-input-block">
              <input type="text" name="insuranceName" id="insuranceName"  autocomplete="off" placeholder="请输入保险公司" class="layui-input" value="${company.columns.insurance_name}" disabled>
            </div>
          </div>
          <div class="layui-inline layui-col-xs4">
            <label class="layui-form-label w-130">保险单号：</label>
            <div class="layui-input-block">
              <input type="text" name="insuranceId" id="insuranceId"  autocomplete="off" placeholder="请输入保险单号" class="layui-input" value="${company.columns.insurance_id}" disabled>
            </div>
          </div>
          <div class="layui-inline layui-col-xs4">
            <label class="layui-form-label w-130">保单：</label>
            <div class="layui-input-block ">
              <div class="display-flex">
                <a style="color:#2890ac;" class="upload-txt hide download-link" id="showA"  href="${commonStaticImgPath}${company.columns.insurance_url}" download="${company.columns.insurance_url}" >
                  <c:if test="${not empty company.columns.insurance_url}">查看</c:if></a>
              </div>
            </div>
            <input type="text" class="hide" name="insuranceUrl" id="insuranceUrl" lay-verify="insuranceUrl" value="${company.columns.insurance_url}"/>
          </div>
        </div>
      </div>
      <div class="layui-col-xs12 layui-form-item">
        <label class="layui-form-label w-130"><i class="red">*</i>公司营业执照：</label>
        <div class="layui-input-block">
          <div id="imgsDiv" class="${company.columns.business_license eq null ? 'hide':''}">
            <div class="bj-img imgSpan">
              <img id="imgShow" src="${commonStaticImgPath.concat(company.columns.business_license)}" data-img="${commonStaticImgPath.concat(company.columns.business_license)}"  height="700" width="1200"/>
              <input type="hidden" name="businessLicense"  lay-filter="required" class="imgPicker" value="${company.columns.business_license}"/>
              <input type="hidden" name="certificationImgName"  lay-filter="required"  value="${company.columns.certification_img_name}"/>
            </div>
          </div>
          <div class="upload-container ${company.columns.business_license eq null ? '':'hide'}" id="uploader" >
            <img src="" alt="img placeholder" id="imgsAdd">
          </div>
        </div>
      </div>
      <input type="hidden" name="id" id="id" value="${company.columns.id}">
    </div>

    <div class="layui-form-item">
      <div class="layui-col-xs12 mb-15 mt-20">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
          <ul class="layui-tab-title">
            <li class="layui-this" >授权区域</li>
            <c:if test="${company.columns.partner eq '04'}">
              <li>授权印章</li>
            </c:if>
          </ul>
          <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
              <table class="layui-table" style="margin-bottom: 60px">
                <thead>
                <tr>
                  <th>省</th>
                  <th>市</th>
                  <th>区/县</th>
                </tr>
                </thead>
                <tbody id="areaSetListBody">
                <c:forEach items="${areaList}" var="al">
                  <tr>
                    <td>${al.province}</td>
                    <td>${al.city}</td>
                    <td>${al.area}</td>
                  </tr>
                </c:forEach>
                </tbody>
              </table>
            </div>

            <c:if test="${company.columns.partner eq '04'}">
              <div class="layui-tab-item ">
                <div class="layui-form-item layui-row">
                  <div class="layui-col-sm4 layui-col-md4">
                    <label class="layui-form-label">授权状态：</label>
                    <span class="form-span">${company.columns.seal_external_auth eq '3' ?'已授权':'未授权'}</span>
                  </div>

                  <div class="layui-col-sm4 layui-col-md4">
                    <label class="layui-form-label">印章授权书：</label>
                    <c:if test="${company.columns.seal_external_auth eq '3'}">
                      <span class="link-blue form-span" onclick="viewSealContract('${company.columns.id}')">查看</span>
                    </c:if>
                  </div>

                  <div class="layui-col-sm12 layui-col-md12">
                    <label class="layui-form-label">授权有效期：</label>
                    <span class="form-span">生效日期：${company.columns.effectiveTime}  &nbsp;&nbsp;&nbsp;&nbsp; 失效日期：${company.columns.expireTime}</span>
                  </div>
                </div>

              </div>
            </c:if>

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

  </div>
  <div class="operate-footer">
    <button type="button" class="layui-btn layui-btn-primary " onclick="closeDiv();" >取消</button>
  </div>
</div>

<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/layui.js"></script>
<script src="${ctxPlugin}/lib/layuiAdmin/dist/layuiadmin/layui/data.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'));
  //初始数据
  var $form;
  var form;
  var upload;
  var $;
  var imgs='';
  var myreg=/^[1][3,4,5,6,7,8,9][0-9]{9}$/;
  layui.use(['form', 'table', 'upload', 'jquery','element'], function () {
    $ = layui.jquery;
    form = layui.form;
    upload = layui.upload;
    $form = $('form');
    var element = layui.element;

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

    form.verify({
      telephone:function(value,item){
        if(!$.trim(value)){
          return "手机号码不能为空,请输入手机号码后保存！";
        }
        if(!myreg.test($.trim(value))){
          return "请输入正确的手机号码后保存！";
        }
      }
    });

    form.on('select(province)', function (data) {
      var province = $(data.elem).find("option:selected").attr("title");
      $("#city").empty();
      $("#detailAddress").val("");
      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 = "";
          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');
        },
        complete: function () {
          var city = $("#city").find("option:selected").attr("title");
          $("#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 = "";
              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);
              form.render('select');
            }
          });
        }

      });

    });

    form.on('select(city)', function (data) {
      var city = $(data.elem).find("option:selected").attr("title");
      $("#area").empty();
      $("#detailAddress").val("");
      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 = "";
          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);
          form.render('select');
        }
      });
    });

    form.on('select(partner)', function (data) {
      var partner = $(data.elem).find("option:selected").val();
      if(partner == '03'){
        console.log(partner);
        $('#insuranceDiv').removeClass('layui-hide');
      }else {
        $('#insuranceDiv').addClass('layui-hide');
        $('#insuranceName').val('');
        $('#insuranceId').val('');
        $('#insuranceName').val('');
        $('#insuranceUrl').val('');
        $('#showA').text('');
      }

    });

    //授权区域选择
    form.on('select(authorizeProvince)', function (data) {
      var province = $(data.elem).find("option:selected").attr("title");
      console.log("123456")
      $("#authorizeCity").empty();
      $("#detailAddress").val("");
      if (isBlank(province)) {
        $("#authorizeCity").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>';
          }
          $("#authorizeCity").append(html);
          form.render('select');
        },
        complete: function () {
          var city = $("#authorizeCity").find("option:selected").attr("title");
          $("#authorizeArea").empty()
          if (isBlank(city)) {
            $("#authorizeArea").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>';
              }
              $("#authorizeArea").append(html);
              form.render('select');
            }
          });
        }

      });

    });

    form.on('select(authorizeCity)', function (data) {
      console.log("654321")
      var city = $(data.elem).find("option:selected").attr("title");
      $("#authorizeArea").empty();
      $("#detailAddress").val("");
      if (isBlank(city)) {
        $("#authorizeArea").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>';
          }
          $("#authorizeArea").append(html);
          form.render('select');
        }
      });
    });



    var saveFlag=false;
    form.on('submit(confirm)', function(data){
      console.log("点击",data);
      if (isBlank(data.field.businessLicense)) {
        layer.msg('公司营业执照不能为空', {icon: 5,anim:6});
        return;
      }
      // if ( data.field.partner == '03') {
      //     if(isBlank(data.field.insuranceUrl)){
      //         layer.msg('保单不能为空', {icon: 5,anim:6});
      //         return;
      //     }
      //     if(isBlank(data.field.insuranceId)){
      //         layer.msg('保险单号不能为空', {icon: 5,anim:6});
      //         return;
      //     }
      //     if(isBlank(data.field.insuranceName)){
      //         layer.msg('保险名称不能为空', {icon: 5,anim:6});
      //         return;
      //     }
      // }
      if(saveFlag){
        return false;
      }
      saveFlag=true;
      let areaList = [];
      $("#areaSetListBody").find("tr").each(function (index) {
        let province = $(this).find("td").eq(0).text();
        let city = $(this).find("td").eq(1).text();
        let area = $(this).find("td").eq(2).text();
        let addAreaVo = {
          province: province,
          city: city,
          area: area
        };
        areaList.push(addAreaVo);
      })
      data.field.areaList = areaList

      $.ajax({
        url:'${ctx}/projectCompany/saveProjectCompany',
        method:'post',
        contentType : "application/json;charsetset=UTF-8",
        data:JSON.stringify(data.field),
        success:function(res){
          if(res.code=="200"){
            top.layer.msg("保存成功",{time:1000});
            closeDiv();
            parent.table.reload('test');
          }else{
            saveFlag=false;
            layer.msg(res.errMsg,{time:1000});
          }
        },
        error:function (data) {
          saveFlag=false;
        }
      }) ;
    });

    var uploadInst = upload.render({
      elem: '#uploader' //绑定元素
      , url: '${ctx}/common/uploadFile' //上传接口
      ,before: function(obj){
        //预读本地文件示例，不支持ie8
        obj.preview(function (index, file, result) {

        });
      }
      , done: function (res) {
        $("input[name='businessLicense']").val(res.path);
        $("input[name='certificationImgName']").val(res.filename + res.extName);
        $("#imgShow").attr("src", '${commonStaticImgPath}' + res.path);
        $("#uploader").hide();
        $("#imgsDiv").show();
      }
      , error: function () {
        //请求异常回调
      }
    });

    upload.render({
      elem: '#uploaderFile' //绑定元素
      ,accept:'file'
      ,exts:'pdf'
      , url: '${ctx}/common/uploadFile' //上传接口
      ,before: function(obj){
        //预读本地文件示例，不支持ie8
        obj.preview(function (index, file, result) {

        });
      }
      , done: function (res) {
        console.log(res.path);
        //上传完毕回调
        $("input[name='insuranceUrl']").val(res.path);
        $("#showA").attr("href", "${commonStaticImgPath}" + res.path);
        $("#showA").text('查看');
        $("#showA").removeClass("hide");
      }
      , error: function () {
        //请求异常回调
      }
    });
  })


  function addArea(){
    layer.open({
      type: 2,
      title: '添加区域',
      content: '${ctx}/projectCompany/toAddAreaPage',
      area: ['60%','90%'],
      success : function(layero) {
        layero.find('.layui-layer-btn').css('text-align', 'center');
        layero.find('.layui-layer-btn').find(".layui-layer-btn0").css("background-color","#009688");
      }
    });
  }

  function addAreaHtml(province, city, area) {
    let flag = false;
    $("#areaSetListBody").find("tr").each(function (index){
      let pro = $(this).find("td").eq(0).text();
      let cit = $(this).find("td").eq(1).text();
      let are = $(this).find("td").eq(2).text();
      if (pro === province) {
        if (isBlank(city)) {
          layer.msg('区域已存在');
          flag = true;
          return false;
        } else if (city.includes(cit)) {
          if (isBlank(area)) {
            layer.msg('区域已存在');
            flag = true;
            return false;
          } else {
            let split = area.split(",");
            for (let i = 0; i < split.length; i++) {
              if (are === split[i]) {
                layer.msg('区域已存在');
                flag = true;
                return false;
              }
            }
          }
          if (isBlank(are)){
            layer.msg('区域已存在');
            flag = true;
            return false;
          }
        }
        if (isBlank(cit)){
          layer.msg('区域已存在');
          flag = true;
          return false;
        } else if (city.includes(cit)) {
          if (isBlank(area)) {
            layer.msg('区域已存在');
            flag = true;
            return false;
          } else {
            let split = area.split(",");
            for (let i = 0; i < split.length; i++) {
              if (are === split[i]) {
                layer.msg('区域已存在');
                flag = true;
                return false;
              }
            }
          }
        }

      }
    })
    if (flag) {
      return;
    }
    let html = '';
    if (isBlank(area)) {
      let split = city.split(",");
      for (let i = 0; i < split.length; i++) {
        html += '<tr>';
        html += '<td>' + province + '</td>';
        html += '<td>' + split[i] + '</td>';
        html += '<td>' + area + '</td>';
        html += '<td><span onclick="delOne(this)" style="color: #0e8ee7">删除</span></td>';
        html += '</tr>';
      }
      $("#areaSetListBody").append(html);
    } else {
      let citys = city.split(",");
      let areas = area.split(",");
      for (let i = 0; i < citys.length; i++) {
        let areaList = []
        $.ajax({
          type: "POST",
          url: "${ctx}/main/redirect/getAreaByCityName",
          data: {
            city: citys[i]
          },
          success: function (result) {
            if (result == "205") {
              layer.msg("暂无数据!")
              return
            }
            console.log(result);
            for (let z = 0; z < result.length; z++) {
              areaList.push(result[z].columns.DistrictName)
            }
            var z = 0;
            for (let j = 0; j < areas.length; j++) {
              console.log(areas[j]);
              if (areaList.includes(areas[j])) {
                console.log("中了奥")
                html += '<tr>';
                html += '<td>' + province + '</td>';
                html += '<td>' + citys[i] + '</td>';
                html += '<td>' + areas[j] + '</td>';
                html += '<td><span onclick="delOne(this)" style="color: #0e8ee7">删除</span></td>';
                html += '</tr>';
                z++
                console.log(z)
              }
            }
            if (z === 0){
              html += '<tr>';
              html += '<td>' + province + '</td>';
              html += '<td>' + citys[i] + '</td>';
              html += '<td>' + '' + '</td>';
              html += '<td><span onclick="delOne(this)" style="color: #0e8ee7">删除</span></td>';
              html += '</tr>';
            }
            areaList = []
            $("#areaSetListBody").append(html);
            html = ''
          }
        });

      }
    }


  }



  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 delImg(that){
    $("input[name='businessLicense']").val("");
    $("input[name='certificationImgName']").val("");
    $("#imgShow").attr("src", "");
    $("#uploader").show();
    $("#imgsDiv").hide();
  }

  function delOne(that) {
    $(that).parent().parent().remove();
  }

  function viewSealContract(id){
    var index= layer.load(2, {shade: [0.5,'#fff'], content:''});
    $.ajax({
      type: 'post',
      url: '${ctx}/projectCompany/viewSealAuthContract',
      data: {
        companyId: id
      },
      success: function (data) {
        if ('200' == data.code) {
          let url = data.data;
          console.log(url);
          window.open(url);
        } else {
          layer.msg(data.errMsg, {icon: 2});
        }
      },
      complete: function () {
        layer.close(index);
      }
    });
  }

</script>
</body>
</html>

