<style>
  .heightauto .el-input {
    height: auto !important;
  }

  .addPassenger .btmTitle {
    padding: 0 10px;
    margin: 20px 0 20px 0;
    border-left: 3px solid #e95252;
    font-size: 14px;
    color: #000000;
  }

  .addPassenger .contOut {
    width: 100%;
    height: auto;
    overflow: hidden;
    border: 1px solid #ccc;
    padding: 20px 0;
    border-radius: 4px;
    display: flex;
    background: #fff;
  }

  .addPassenger .contOut .contForm {
    flex: 1;
  }

  .addPassenger .contOut .contPic {
    width: 450px;
    padding-right: 10px;
  }

  .addPassenger .contOut .contPicNav {
    width: 450px;
    background: #f9f9f9;
    height: 34px;
    padding-right: 10px;
  }

  .addPassenger .contOut .contPicNav li {
    float: left;
    min-width: 90px;
    line-height: 34px;
    text-align: center;
    cursor: pointer;
    font-size: 12px;
  }

  .addPassenger .contOut .contPicNav li>div {
    width: 23px;
    height: 3px;
    margin: -2px auto;
    background: #e95252;
  }

  .addPassenger .contOut .contPicNav li.active {
    background: #fff;
  }

  .addPassenger .contOut .contPic img {
    height: 200px;
  }

  .addPassenger .contOut .contForm li {
    float: left;
    width: 450px;
  }

  .addPassenger .cont,
  .addPassenger .cont1 {
    flex: auto;
    height: auto;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #ccc;
    padding: 20px;
    overflow: hidden;
  }

  .addPassenger .el-date-editor.el-input {
    width: 100%;
  }

  .addPassenger .el-form-item__label {
    font-size: 12px;
  }

  .addPassenger .cont .el-form-item,
  ._Ec_Box .el-form-item {
    float: left;
    width: 500px;
  }

  .addPassenger .cont ._AddressDetail {
    width: 57%;
  }

  .addPassenger textarea {
    resize: none;
  }

  ._addPassengerEconomicCapability {
    line-height: 22px;
    padding-left: 60px;
    overflow: hidden;
    width: 100%;
  }

  ._addPassengerEconomicCapability span {
    display: inline-block;
    padding: 2px 4px;
    border: 1px solid #c0c4cc;
    margin: 1px;
    cursor: pointer;
    color: #c0c4cc;
    font-size: 12px;
    border-radius: 4px;
  }

  ._addPassengerEconomicCapability span._active {
    border: 1px solid rgb(123, 194, 245);
    color: rgb(123, 194, 245);
  }

  .fileContainer [type="file"] {
    z-index: 50;
    display: block;
    filter: alpha(opacity=0);
    height: 100%;
    width: 100%;
    opacity: 0;
    position: absolute;
    right: 0;
    top: 0;
    cursor: pointer;
  }

  .colorRed input {
    color: red !important;
  }

</style>
<template>
  <div class="addPassenger">
    <p class="btmTitle">旅客基本资料</p>
    <div class="contOut" v-loading='loading' element-loading-text="努力识别中...." element-loading-spinner="el-icon-loading"
      element-loading-background="rgba(0, 0, 0, 0.7)">
      <div class="contForm">
        <el-form :model="addMsg" ref="addMsg" label-position="right" :rules="rules" label-width="100px">
          <li>
            <el-form-item label="身份证号码" prop="IdCard" v-if="LineId === 14 || LineId === 2">
              <el-input v-model="addMsg.IdCard" type="text" size=mini class="w230" maxlength="50" placeholder="请填写"
                @blur.prevent="authentication()">
              </el-input>
            </el-form-item>
            <el-form-item label="身份证号码" v-else>
              <el-input v-model="addMsg.IdCard" type="text" size=mini class="w230" maxlength="50" placeholder="请填写"
                @blur.prevent="authentication()">
              </el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="中文姓" prop="SurName">
              <el-input v-model='addMsg.SurName' class="w230" @input="Transformation(addMsg.SurName,'SurName')"
                placeholder="请输入中文"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="中文名" prop="Name">
              <el-input v-model='addMsg.Name' class="w230" @input="Transformation(addMsg.Name,'Name')"
                placeholder="请输入中文"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="性别" prop="Sex">
              <el-checkbox v-model="addMsg.Sex" true-label='1' false-label='2' @change="Roominformation()">男
              </el-checkbox>
              <el-checkbox v-model="addMsg.Sex" true-label='2' false-label='1' @change="Roominformation()">女
              </el-checkbox>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="英文姓" prop="ESurName">
              <el-input v-model='addMsg.ESurName' type="text" size=mini class="w230" maxlength="20" placeholder="请输入英文">
              </el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="英文名" prop="EName">
              <el-input v-model='addMsg.EName' type="text" size=mini class="w230" maxlength="20" placeholder="请输入英文">
              </el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="手机号码" prop="MobilePhone">
              <el-input v-model="addMsg.MobilePhone" type="text" size=mini class="w230" maxlength="20"
                placeholder="请填写"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="出生日期" prop="Birthday">
              <el-date-picker v-model='addMsg.Birthday' class="w230" @change="zhanchuangTips(addMsg.Birthday)"
                value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="出生地" prop="BirthdayAddress">
              <el-input v-model="addMsg.BirthdayAddress" type="text" size=mini class="w230" maxlength="20"
                placeholder="请填写"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="护照号" v-if="LineId==90">
              <el-input v-model='addMsg.PassportNo' type="text" size=mini class="w230" maxlength="20"
                placeholder="请填写护照号"></el-input>
            </el-form-item>
            <el-form-item label="护照号" prop="PassportNo" v-else>
              <el-input v-model='addMsg.PassportNo' type="text" size=mini class="w230" maxlength="20"
                placeholder="请填写护照号"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="护照签发地" v-if="LineId==90">
              <el-input v-model='addMsg.PassportAddress' type="text" size=mini class="w230" maxlength="100"
                placeholder="请填写"></el-input>
            </el-form-item>
            <el-form-item label="护照签发地" prop="PassportAddress" v-else>
              <el-input v-model='addMsg.PassportAddress' type="text" size=mini class="w230" maxlength="100"
                placeholder="请填写"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="护照签发日期" v-if="LineId==90">
              <el-date-picker v-model='addMsg.PassportIssued' class="w230" value-format="yyyy-MM-dd" type="date"
                placeholder="选择日期"></el-date-picker>
            </el-form-item>
            <el-form-item label="护照签发日期" prop="PassportIssued" v-else>
              <el-date-picker v-model='addMsg.PassportIssued' class="w230" value-format="yyyy-MM-dd" type="date"
                placeholder="选择日期"></el-date-picker>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="护照过期日" v-if="LineId==90">
              <el-date-picker v-model='addMsg.PassportExpiry' class="w230" :class=" guoqi ? 'colorRed' : ''"
                @change="timeOver" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
            <el-form-item label="护照过期日" prop="PassportExpiry" v-else>
              <el-date-picker v-model='addMsg.PassportExpiry' class="w230" :class=" guoqi ? 'colorRed' : ''"
                @change="timeOver" value-format="yyyy-MM-dd" type="date" placeholder="选择日期"></el-date-picker>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="国籍" prop="Nationality">
              <el-select v-model="addMsg.Nationality" filterable size=mini class="w230">
                <el-option v-for="item in countryList" :key="item.ID" :label="item.Name" :value="item.ID">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="婚姻" prop="Marriage">
              <el-select v-model="addMsg.Marriage" filterable size=mini class="w230">
                <el-option v-for="item in MarriageType" :key="item.Id" :label="item.Name" :value="item.Id">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="家庭居住地" prop="Address">
              <el-input v-model="addMsg.Address" type="text" size=mini class="w230" maxlength="50" placeholder="请填写">
              </el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="家庭详细地址" prop="AddressDetail">
              <el-input v-model="addMsg.AddressDetail" type="text" class="w230" size=mini maxlength="200"
                placeholder="请填写"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="身份确认" prop="IdentityType">
              <el-select v-model="addMsg.IdentityType" filterable size=mini class="w230" v-if="addMsg.IdentityType==''">
                <el-option v-for="item in VisaIdentityTypeEnum" :key="item.Id" :label="item.Name" :value="item.Name">
                </el-option>
              </el-select>
              <el-input v-else v-model="addMsg.IdentityType" type="text" size=mini class="w230" maxlength="50">
              </el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="出境记录" prop="HistoryRecord">
              <el-select v-model="addMsg.HistoryRecord" filterable size=mini class="w230"
                v-if="addMsg.HistoryRecord==''">
                <el-option v-for="item in VisaDeparturesType" :key="item.Id" :label="item.Name" :value="item.Name">
                </el-option>
              </el-select>
              <el-input v-else v-model="addMsg.HistoryRecord" type="text" size=mini class="w230" maxlength="50">
              </el-input>
              <el-checkbox v-model='addMsg.IsRecommend' :true-label='1' :false-label='2'>推荐</el-checkbox>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="职务" prop="Duty">
              <el-select v-model="addMsg.Duty" filterable size=mini class="w230" v-if="addMsg.Duty==''">
                <el-option v-for="item in VisaDutyTypeEnum" :key="item.Id" :label="item.Name" :value="item.Name">
                </el-option>
              </el-select>
              <el-input v-else v-model="addMsg.Duty" type="text" size=mini class="w230" maxlength="50"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="备注">
              <el-input v-model="addMsg.Remarks" type="text" size=mini class="w230" maxlength="1000"></el-input>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="出游类型" prop="TravelType">
              <el-select v-model="addMsg.TravelType" filterable size=mini class="w230">
                <el-option v-for="item in TravelTypeList" :key="item.Code" :label="item.Content" :value="item.Code">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="单位类型" prop="UnitType">
              <el-select v-model="addMsg.UnitType" filterable size=mini class="w230">
                <el-option v-for="item in UnitTypeList" :key="item.Code" :label="item.Content" :value="item.Code">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="职务类型" prop="DutyType">
              <el-select v-model="addMsg.DutyType" filterable size=mini class="w230">
                <el-option v-for="item in DutyTypeList" :key="item.Code" :label="item.Content" :value="item.Code">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="高校学生">
              <el-checkbox v-model="addMsg.IsHightSchool" :true-label='1' :false-label='2'></el-checkbox>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="是否占床">
              <el-checkbox v-model="addMsg.IsBed" name="IsBed" :true-label='1' :false-label='0'
                @change="Roominformation()">是</el-checkbox>
              <el-checkbox v-model="addMsg.IsBed" name="IsBed" :true-label='0' :false-label='1'
                @change="Roominformation()">否</el-checkbox>
            </el-form-item>
          </li>
          <li v-if="isOneDay !== 1">
            <el-form-item label="房间信息" prop="HouseId">
              <el-select v-model="addMsg.HouseId" filterable size=mini class="w230">
                <el-option v-for="item in roomlist" :key="item.ID" :label="item.HouseInfo" :value="item.ID">
                </el-option>
              </el-select>
              <input type="button" value="新增房间" class="normalBtn" v-if="!UpdateOrderHouseBtn" @click="addhouse()"
                title="需要拼房，但没有双人间（半间）的点击新增房间" />
              <input type="button" value="刷新房间" class="normalBtn" v-if="UpdateOrderHouseBtn"
                @click="SellUpdateOrderHouse()" title="选择人数后没有房间的点击刷新" />
            </el-form-item>
          </li>
          <li>
            <el-form-item label="是否需签证">
              <el-checkbox v-model='addMsg.IsVisaFree' name="IsVisaFree"
                :disabled="IsMustVisa==1||(IsMustVisa==2&&addMsg.Id<=0)" :true-label='2' :false-label='1'>是
              </el-checkbox>
              <el-checkbox v-model='addMsg.IsVisaFree' name="IsVisaFree"
                :disabled="IsMustVisa==1||(IsMustVisa==2&&addMsg.Id<=0)" :true-label='1' :false-label='2'>否
              </el-checkbox>
              &nbsp;&nbsp;
              <el-select v-model="addMsg.VisaReplaceId" filterable size=mini class="w120"
                v-if="IsMustVisa==2&addMsg.Id>0&VisaStartStatus==2&addMsg.IsVisaFree==1">
                <el-option v-for="item in VisaNotNeedList" :key="item.Id" :label="item.Name" :value="item.Id">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="签证状态">
              <el-select v-model="addMsg.VisaState" filterable size=mini class="w120">
                <el-option :key="0" label="正常" :value="0">
                </el-option>
                <el-option :key="1" label="拒签" :value="1">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="是否单地接">
              <el-checkbox v-model='addMsg.IsNeedAirticket' name="IsNeedAirticket"
                :disabled="IsMustAir==1||(IsMustAir==2&&addMsg.Id<=0)" :true-label='1' :false-label='2'>是</el-checkbox>
              <el-checkbox v-model='addMsg.IsNeedAirticket' name="IsNeedAirticket"
                :disabled="IsMustAir==1||(IsMustAir==2&&addMsg.Id<=0)" :true-label='2' :false-label='1'>否</el-checkbox>
              &nbsp;&nbsp;
              <el-select v-model="addMsg.AirReplaceId" filterable size=mini class="w120"
                v-if="IsMustAir==2&addMsg.Id>0&AirStartStatus==1&addMsg.IsNeedAirticket==2">
                <el-option v-for="item in AirNoeNeedList" :key="item.Id" :label="item.Name" :value="item.Id">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li>
            <el-form-item label="是否需保险">
              <el-checkbox v-model='addMsg.IsNeedSafe' name="IsNeedSafe"
                :disabled="IsMustSafe==1||(IsMustSafe==2&&addMsg.Id<=0)" :true-label='1' :false-label='2'>是
              </el-checkbox>
              <el-checkbox v-model='addMsg.IsNeedSafe' name="IsNeedSafe"
                :disabled="IsMustSafe==1||(IsMustSafe==2&&addMsg.Id<=0)" :true-label='2' :false-label='1'>否
              </el-checkbox>
              &nbsp;&nbsp;
              <el-select v-model="addMsg.SafeReplaceId" filterable size=mini class="w120"
                v-if="IsMustSafe==2&addMsg.Id>0&SafeStartStatus==1&addMsg.IsNeedSafe==2">
                <el-option v-for="item in SafeNotNeedList" :key="item.Id" :label="item.Name" :value="item.Id">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="景点">
              <el-select v-model="addMsg.CouponsIds" multiple placeholder="请选择" class="heightauto">
                <el-option v-for="item in JingDianList" :key="item.CouponsId" :label="item.CouponsName"
                  :value="item.CouponsId">
                </el-option>
              </el-select>
            </el-form-item>
          </li>
          <li v-for='(item,index) in EconomicCapabilityS'>
            <el-form-item :label="item.Name" v-if='item.isShow' :key='index'>
              <el-input v-model="item.Content" type="text" size=mini class="w230" maxlength="50"></el-input>
            </el-form-item>
          </li>
        </el-form>
        <div class="_addPassengerEconomicCapability">
          <span v-for="item in EconomicCapabilityS" @click="addEconomicCapability(item)"
            :class="{_active:item.isShow}">{{item.Name}}</span>
        </div>
      </div>
      <div class="contPic">
        <div class="contPicNav">
          <li @click="templateType=1" :class="{active:templateType==1}">
            身份证
            <div v-show="templateType==1"></div>
          </li>
          <li @click="templateType=2" :class="{active:templateType==2}">
            护照
            <div v-show="templateType==2"></div>
          </li>
          <li v-show="templateType==2">
            <el-select class='w200' v-model='templateSign'>
              <el-option label='台湾护照' value='7224a048d0fcc94413c3a729e481a775'></el-option>
              <el-option label='中国护照' value='2625f80ec957a0c837ca14f8ce608a51'></el-option>
              <el-option label='中国护照旧版' value='2dc78a37e516f18ebe56aeacc6d49203'></el-option>
              <el-option label='台湾通行证' value='2cd1d05f5efc5eec23ffad6358bdb70f'></el-option>
            </el-select>
          </li>
        </div>
        <p>
        </p>
        <div
          style="width: 100%; min-height: 200px; background: #f1f1f1; line-height: 200px; margin: 10px 0; border-radius: 4px;position: relative; text-align: center;">
          <img id="img" src="" style="position: absolute; left: 0 ; top: 0;" />
          <label class="fileContainer">
            <input id='file' type="file" @change="onUpload" />
            <i class="iconfont icon-img_haha color999" style="font-size: 80px;"></i>
          </label>
        </div>
        <input type="button" value="开始识别" class="normalBtn" @click="commonTextDiscern" />
      </div>
    </div>
    <p class="btmTitle">日本签证补录资料</p>
    <div class="cont1">
      <el-form label-width="120px">
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="护照签发机关">
              <el-input v-model='addMsg.IssuingAuthority' size=mini maxlength="50"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="曾用中文名">
              <el-input v-model='addMsg.CName' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="曾用英文名">
              <el-input v-model='addMsg.CEName' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="曾有国籍">
              <el-input v-model='addMsg.CNationality' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="联系电话">
              <el-input v-model='addMsg.Tel' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="单位名称">
              <el-input v-model='addMsg.UnitName' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="单位电话">
              <el-input v-model='addMsg.UnitPhone' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="配偶/监护人职位">
              <el-input v-model='addMsg.UnitPost' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="单位地址">
              <el-input v-model='addMsg.UnitAddress' size=mini maxlength="200"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="赴日目的">
              <el-input v-model='addMsg.Purpose' size=mini maxlength="200"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="有无出境记录">
              <el-select v-model='addMsg.IsDepartureRecord'>
                <el-option key="1" label="有" value="1"> </el-option>
                <el-option key="2" label="无" value="2"> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="上次去时间" prop="Birthday">
              <el-date-picker v-model='addMsg.LastTime' value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="上次取得截至时间">
              <el-date-picker v-model='addMsg.DeadlineTime' value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="出境国家">
              <el-input size=mini v-model='addMsg.NCNationality' maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="酒店名称/友人名称">
              <el-input v-model='addMsg.HotelName' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="酒店电话/友人电话" prop="Birthday">
              <el-input v-model='addMsg.HotelTel' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="酒店地址/友人地址">
              <el-input v-model='addMsg.HotelAddress' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="紧急联络人">
              <el-input v-model='addMsg.EmergencyContact' size=mini maxlength="100"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="紧急人地址">
              <el-input v-model='addMsg.EmergencyAddress' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="紧急人电话" prop="Birthday">
              <el-input v-model='addMsg.EmergencyTel' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="紧急人关系">
              <el-input v-model='addMsg.EmergencyRelation' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="犯罪记录">
              <el-select v-model='addMsg.IsCriminalRecord'>
                <el-option key="1" label="有" value="1"> </el-option>
                <el-option key="2" label="无" value="2"> </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="参团费用">
              <el-input v-model='addMsg.TravelCost' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="40">
          <el-col :span="6">
            <el-form-item label="报名旅行社" prop="Birthday">
              <el-input v-model='addMsg.TravelName' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="一同报名亲友">
              <el-input v-model='addMsg.MutualFriends' size=mini maxlength="20"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="申请日期/报名时间">
              <el-date-picker v-model='addMsg.Date' value-format="yyyy-MM-dd" type="date" placeholder="选择日期">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <p style="text-align: center; padding: 20px 0;">
      <input type="button" class="hollowFixedBtn" value="取消" @click="goBack" />
      <input type="button" class="normalBtn" value="保存" :style="btnState===true?'':'background-color: gray'"
        @click="submitForm('addMsg',1)" />
      <input v-if="this.addMsg.Id==0" type="button" class="normalBtn" value="保存并继续添加"
        :style="btnState===true?'':'background-color: gray'" @click="submitForm('addMsg',2)" />
    </p>
  </div>
</template>
<script>
  import Vue from "vue";
  export default {
    data() {
      return {
        TravelTypeList: [],
        UnitTypeList: [],
        DutyTypeList: [],
        ppAge: 0,
        loading: false,
        appkey_ocr: "OGAhU38ib8EweXMtPVqCbkpN",
        secretKey_ocr: "OcqfFF5hlleWovzA6vLweykxPgwE8XF2",
        BD_GET_ACCESS_TOKEN: "https://aip.baidubce.com/oauth/2.0/token",
        BD_COMMON_TEXT_DISCERN_IDCARD: "https://aip.baidubce.com/rest/2.0/ocr/v1/idcard",
        BD_COMMON_TEXT_DISCERN: "https://aip.baidubce.com/rest/2.0/solution/v1/iocr/recognise",
        access_token_ocr: "",
        templateType: 1,
        templateSign: "",
        imgBase64String: "",
        imgBase64String1: "",
        addMsg: {
          Id: 0,
          TCID: 0,
          OrderId: 0,
          SurName: "",
          Name: "",
          Sex: "",
          EName: "",
          ESurName: "",
          Birthday: "",
          BirthdayAddress: "",
          PassportAddress: "",
          PassportExpiry: "",
          PassportNo: "",
          Nationality: 2,
          Marriage: "",
          Address: "",
          AddressDetail: "",
          HistoryRecord: "",
          IdentityType: "",
          Duty: "",
          EconomicCapabilityList: [],
          Remarks: "",
          TravelType: '',
          UnitType: '',
          DutyType: '',
          IsHightSchool: "2",
          IsRecommend: "2",
          PassportIssued: "",
          IssuingAuthority: "",
          IdCard: "",
          CEName: "",
          CName: "",
          CNationality: "",
          Tel: "",
          MobilePhone: "",
          UnitAddress: "",
          UnitName: "",
          UnitPhone: "",
          UnitPost: "",
          Purpose: "观光",
          IsDepartureRecord: "2",
          LastTime: "",
          DeadlineTime: "",
          NCNationality: "",
          HotelTel: "",
          HotelAddress: "",
          HotelName: "参照\"赴日予定表\"",
          EmergencyContact: "",
          EmergencyAddress: "",
          EmergencyTel: "",
          IsCriminalRecord: "2",
          TravelCost: "",
          TravelName: "",
          MutualFriends: "",
          Date: "",
          IsBed: 1,
          IsVisaFree: 2,
          IsNeedAirticket: 1,
          IsNeedSafe: 1,
          AirReplaceId: "0",
          VisaReplaceId: "0",
          SafeReplaceId: "0",
          VisaState: 0, //签证状态
          HouseId: '', //房间信息
          CouponsIds: []
        },
        UpdateOrderHouseBtn: false,
        EconomicCapabilityS: [],
        rules: {
          DutyType: [{
            required: true,
            message: '请选择职务类型',
            trigger: 'change'
          }],
          UnitType: [{
            required: true,
            message: '请选择单位类型',
            trigger: 'change'
          }],
          TravelType: [{
            required: true,
            message: '请选择出游类型',
            trigger: 'change'
          }],
          IdCard: [{
            required: true,
            message: "请填身份证号码",
            trigger: "blur"
          }],
          SurName: [{
            required: true,
            message: "请填写中文姓",
            trigger: "blur"
          }],
          Name: [{
            required: true,
            message: "请填写中文名",
            trigger: "blur"
          }],
          Sex: [{
            required: true,
            message: "请填选择性别",
            trigger: "change"
          }],
          ESurName: [{
              required: true,
              message: "请填写英文姓",
              trigger: "blur"
            },
            {
              pattern: /^[a-zA-Z]/,
              message: "请输入英文姓"
            }
          ],
          EName: [{
              required: true,
              message: "请填写英文名",
              trigger: "blur"
            },
            {
              pattern: /^[a-zA-Z]/,
              message: "请输入英文姓"
            }
          ],
          Birthday: [{
            required: true,
            message: "请填选择出生日期",
            trigger: "blur"
          }],
          PassportNo: [{
              required: true,
              message: "请填写护照号",
              trigger: "blur"
            },
            {
              pattern: /^[0-9a-zA-Z]+$/,
              message: "正确的护照号"
            }
          ],
          PassportIssued: [{
            required: true,
            message: "请选择护照签发日期",
            trigger: "blur"
          }],
          PassportExpiry: [{
            required: true,
            message: "请选择护照过期日",
            trigger: "blur"
          }],
          PassportAddress: [{
            required: true,
            message: "请填写签发地",
            trigger: "blur"
          }],
          MobilePhone: [{
            required: true,
            message: "请填写手机号码",
            trigger: "blur"
          }],
          Nationality: [{
            required: true,
            message: "请选择国籍",
            trigger: "change"
          }],
          BirthdayAddress: [{
            required: true,
            message: "请填写出生地",
            trigger: "change"
          }]
        },
        //返回数据
        VisaApplyForTypeEnum: [],
        JapanAirportList: [],
        ChinaAirportList: [],
        countryList: [],
        MarriageType: [],
        VisaDeparturesType: [],
        VisaDutyTypeEnum: [],
        VisaIdentityTypeEnum: [],
        FilghtForAirIn: [],
        FilghtForAirOut: [],
        IsMustVisa: 2,
        IsMustAir: 2,
        IsMustSafe: 2,
        VisaNotNeedList: [],
        AirNoeNeedList: [],
        SafeNotNeedList: [],
        VisaStartStatus: 2,
        AirStartStatus: 2,
        SafeStartStatus: 2,
        btnState: true,
        roomlist: [],
        isOneDay: 0,
        LineId: 0,
        EndDateStr: '',
        guoqi: false,
        JingDianList: []
      };
    },
    methods: {
      getDutyType() {
        this.apipost(
          "dict_get_GetDictValueCommonList", {
            Key: 'SK_CRM_DutyType',
          },
          res => {
            if (res.data.resultCode == 1) {
              this.DutyTypeList = res.data.data
            } else {}
          },
          err => {}
        );
      },
      getUnitType() {
        this.apipost(
          "dict_get_GetDictValueCommonList", {
            Key: 'SK_CRM_UnitType',
          },
          res => {
            if (res.data.resultCode == 1) {
              this.UnitTypeList = res.data.data
            } else {}
          },
          err => {}
        );
      },
      getTravelType() {
        this.apipost(
          "dict_get_GetDictValueCommonList", {
            Key: 'SK_CRM_TravelType',
          },
          res => {
            if (res.data.resultCode == 1) {
              this.TravelTypeList = res.data.data
            } else {}
          },
          err => {}
        );
      },
      jsGetAge(strBirthday) {
        let returnAge;
        let strBirthdayArr = strBirthday.split("-");
        let birthYear = Number(strBirthdayArr[0]);
        let birthMonth = Number(strBirthdayArr[1]);
        let birthDay = Number(strBirthdayArr[2]);
        let d = new Date();
        let nowYear = d.getFullYear();
        let nowMonth = d.getMonth() + 1;
        let nowDay = d.getDate();
        if (nowYear === birthYear) {
          returnAge = 1; //同年 则为0岁
        } else {
          let ageDiff = nowYear - birthYear; //年之差
          if (ageDiff > 0) {
            if (nowMonth == birthMonth) {
              let dayDiff = nowDay - birthDay; //日之差
              if (dayDiff < 0) {
                returnAge = ageDiff - 1;
              } else {
                returnAge = ageDiff;
              }
            } else {
              let monthDiff = nowMonth - birthMonth; //月之差
              if (monthDiff < 0) {
                returnAge = ageDiff - 1;
              } else {
                returnAge = ageDiff;
              }
            }
          } else {
            returnAge = -1; //返回-1 表示出生日期输入错误 晚于今天
          }
        }
        return returnAge; //返回周岁年龄
      },
      zhanchuangTips: function (b) {
        let age = this.jsGetAge(b)
        this.ppAge = age
        if (age == -1) {
          this.$message.error('出生日期' + b + '有误')
          this.addMsg.Birthday = ''
          return
        }
      },
      getJingDIan: function () {
        this.apipost(
          "sellorder_post_GetGuestScenicRefundList", {
            TCID: this.addMsg.TCID,
            OrderId: this.addMsg.OrderId,
            GuestId: this.addMsg.Id
          },
          res => {
            if (res.data.resultCode == 1) {
              this.JingDianList = res.data.data
            } else {
              this.$message.error('操作失败')
            }
          },
          err => {}
        );
      },
      CompareDate(d1, d2) {
        return ((new Date(d1.replace(/-/g, "\/"))) < (new Date(d2.replace(/-/g, "\/"))));
      },
      timeOver: function () {
        if (this.addMsg.PassportExpiry && this.addMsg.PassportExpiry != '') {
          this.guoqi = this.CompareDate(this.addMsg.PassportExpiry, this.EndDateStr)
          if (this.guoqi) {
            this.$message.error("客人护照过期时间小于团队出发日期后六个月")
            return
          }
        }
      },
      getAccessToken() {
        let url =
          this.BD_GET_ACCESS_TOKEN +
          "?grant_type=client_credentials&client_id=" +
          this.appkey_ocr +
          "&client_secret=" +
          this.secretKey_ocr;
        this.$http.get("https://bird.ioliu.cn/v1?url=" + url).then(res => {
          this.access_token_ocr = res.data.access_token;
        });
      },
      // 月份转换
      getMonthWithEn: function (enMonth) {
        enMonth = enMonth.toLowerCase();
        let month = '';
        if ('jan'.indexOf(enMonth) != -1) {
          month = '01';
        } else if ('feb'.indexOf(enMonth) != -1) {
          month = '02';
        } else if ('mar'.indexOf(enMonth) != -1) {
          month = '03';
        } else if ('apr'.indexOf(enMonth) != -1) {
          month = '04';
        } else if ('may'.indexOf(enMonth) != -1) {
          month = '05';
        } else if ('june'.indexOf(enMonth) != -1) {
          month = '06';
        } else if ('july'.indexOf(enMonth) != -1) {
          month = '07';
        } else if ('aug'.indexOf(enMonth) != -1) {
          month = '08';
        } else if ('sept'.indexOf(enMonth) != -1) {
          month = '09';
        } else if ('oct'.indexOf(enMonth) != -1 || '0ct'.indexOf(enMonth) != -1) {
          month = '10';
        } else if ('nov'.indexOf(enMonth) != -1 || 'n0v'.indexOf(enMonth) != -1 || 'nv'.indexOf(enMonth) != -1) {
          month = '11';
        } else if ('dec'.indexOf(enMonth) != -1) {
          month = '12';
        }
        return month;
      },
      formatDateWithTaiwan: function (word) {
        if (word.length > 0) {
          try {
            let dateArr = word.match(/(^\d+)|(\d+$)/g);
            let day = dateArr[0];
            day = day.length > 2 ? (parseInt(day) > 0 ? day.substring(0, 2) : '01') : day;
            let year = dateArr[1];
            if (year.length != 4) {
              if (year.length == 3) {
                year = year + '0';
              } else if (year.length == 2) {
                year = year + '00'
              } else if (year.length == 1) {
                year = '2020';
              } else {
                year = Tool.getCurrentYear().toString();
              }
            }
            let month = this.getMonthWithEn(word.replace(/[0-9]/ig, ""));
            day = day.length == 0 ? '01' : day;
            month = month.length == 0 ? '01' : month;
            return year + '-' + month + '-' + day;
          } catch (e) {
            return '';
          }
        } else {
          return '';
        }
      },
      formatDateWithChina(word) {
        if (word.length > 0) {
          try {
            let arr = word.match(/(^\d+)|(\d+$)/g);
            let y = arr[1];
            let d = '';
            let mon = this.getMonthWithEn(word.replace(/[^a-zA-Z]/g, ''));
            let dayAndMonth = arr[0];
            if (dayAndMonth.length == 1) {
              d = '0' + dayAndMonth;
              if (mon.length == 0) {
                mon = '0' + dayAndMonth;
              }
            } else if (dayAndMonth.length == 2) {
              if (parseInt(dayAndMonth) > 31) {
                d = '0' + dayAndMonth.substring(0, 1);
                if (mon.length == 0) {
                  mon = '0' + dayAndMonth.substring(1, 2);
                }
              } else {
                if (parseInt(dayAndMonth) < 13) {
                  if (mon.length == 0) {
                    mon = dayAndMonth;
                  }
                  d = dayAndMonth;
                } else {
                  d = '0' + dayAndMonth.substring(0, 1);
                  if (mon.length == 0) {
                    mon = '0' + dayAndMonth.substring(1, 2);
                  }
                }
              }
            } else if (dayAndMonth.length == 3) {
              d = dayAndMonth.substring(0, 2);
              if (mon.length == 0) {
                mon = '0' + dayAndMonth.substring(2, 3);
              }
            } else if (dayAndMonth.length == 4) {
              d = dayAndMonth.substring(0, 2);
              if (mon.length == 0) {
                mon = dayAndMonth.substring(2, 4);
              }
            }
            if (y.length != 4) {
              if (y.length == 3) {
                y = y + '0';
              } else if (y.length == 2) {
                y = y + '00'
              } else if (y.length == 1) {
                y = '2020';
              } else {
                y = Tool.getCurrentYear().toString();
              }
            }
            d = d.length == 0 ? '01' : d;
            mon = mon.length == 0 ? '01' : mon;
            return y + '-' + mon + '-' + d;
          } catch (e) {
            return '';
          }
        } else {
          return '';
        }
      },
      // 中国护照数据处理
      formatDataWithChina: function (results) {
        let formatData = null;
        let chinaFirstName = '';
        let chinaLastName = '';
        let sex = {
          'Id': 1,
          'Name': '男'
        };
        let birthday = '';
        let enFirstName = '';
        let enLastName = '';
        let passportNo = '';
        let passportAddress = '';
        let passportExpiry = '';
        let nationality = {
          'ID': '',
          'Name': ''
        };

        let birthplace = '';
        let passportDate = '';
        for (let i = 0; i < results.length; i++) {
          let item = results[i];
          let word_name = item.word_name;
          let word = item.word != null ? item.word : '';
          if (word_name == '姓名') {
            if (word != null && word.length > 0) {
              try {
                if (word.length == 1) {
                  chinaFirstName = word;
                } else if (word.length == 2) {
                  chinaFirstName = word.substring(0, 1);
                  chinaLastName = word.substring(1, 2);
                } else if (word.length == 3) {
                  chinaFirstName = word.substring(0, 1);
                  chinaLastName = word.substring(1, 3);
                } else if (word.length == 4) {
                  chinaFirstName = word.substring(0, 2);
                  chinaLastName = word.substring(2, 4);
                } else {
                  chinaFirstName = word.substring(0, 1);
                  chinaLastName = word.substring(1, word.length);
                }
              } catch (e) {}
            }
          } else if (word_name == '性别') {
            if (word == '女/F' || word.indexOf('女') != -1 || word.indexOf('F') != -1) {
              sex = {
                'Id': 2,
                'Name': '女'
              };
            } else {
              sex = {
                'Id': 1,
                'Name': '男'
              };
            }
          } else if (word_name == '出生日期') {
            birthday = this.formatDateWithTaiwan(word)
          } else if (word_name == 'name') {
            if (word.length > 0) {
              try {
                if (word.indexOf('.') != -1) {
                  enFirstName = word.split('.')[0];
                  enLastName = word.split('.')[1];
                } else if (word.indexOf(',') != -1) {
                  enFirstName = word.split(',')[0];
                  enLastName = word.split(',')[1];
                } else if (word.indexOf('。') != -1) {
                  enFirstName = word.split('。')[0];
                  enLastName = word.split('。')[1];
                } else if (word.indexOf('，') != -1) {
                  enFirstName = word.split('，')[0];
                  enLastName = word.split('，')[1];
                }
              } catch (e) {}
            }
          } else if (word_name == '护照号码') {
            if (word.indexOf('i') != -1) {
              word = word.replace(/i/g, '1');
            }
            if (word.indexOf('I') != -1) {
              word = word.replace(/I/g, '1');
            }
            if (word.indexOf('l') != -1) {
              word = word.replace(/l/g, '1');
            }
            if (word.indexOf('L') != -1) {
              word = word.replace(/L/g, '1');
            }
            if (word.indexOf('|') != -1) {
              word = word.replace(/\|/g, '1');
            }
            passportNo = word;
          } else if (word_name == '签发地点') {
            passportAddress = word;
            if (word.indexOf('/') != -1) {
              passportAddress = word.split('/')[0];
            }
          } else if (word_name == '有效期至') {
            passportExpiry = this.formatDateWithChina(word);
          } else if (word_name == '国籍') {
            nationality = {
              'ID': 2,
              'Name': '中国'
            };
          } else if (word_name == '出生地点') {
            birthplace = word;
            if (word.indexOf('/') != -1) {
              birthplace = word.split('/')[0];
            }
          } else if (word_name == '签发日期') {
            passportDate = this.formatDateWithChina(word);
          }
        }
        formatData = {
          'chinaFirstName': chinaFirstName,
          'chinaLastName': chinaLastName,
          'sex': sex,
          'birthday': birthday,
          'enFirstName': enFirstName,
          'enLastName': enLastName,
          'passportNo': passportNo,
          'passportAddress': passportAddress,
          'passportExpiry': passportExpiry,
          'nationality': nationality,
          'birthplace': birthplace,
          'passportDate': passportDate
        }
        return formatData;
      },
      // 中国护照旧版
      formatDataWithChina_old(results) {
        let formatData = null;
        let chinaFirstName = '';
        let chinaLastName = '';
        let sex = {
          'Id': 1,
          'Name': '男'
        };
        let birthday = '';
        let enFirstName = '';
        let enLastName = '';
        let passportNo = '';
        let passportAddress = '';
        let passportExpiry = '';
        let nationality = {
          'ID': '',
          'Name': ''
        };
        let birthplace = '';
        let passportDate = '';
        for (let i = 0; i < results.length; i++) {
          let item = results[i];
          let word_name = item.word_name;
          let word = item.word != null ? item.word : '';
          if (word_name == '姓') {
            try {
              chinaFirstName = word;
              enFirstName = word;
              if (word.indexOf('/') != -1) {
                chinaFirstName = word.split('/')[0];
                enFirstName = word.split('/')[1];
              }
            } catch (e) {}
          } else if (word_name == '名') {
            try {
              chinaLastName = word;
              enLastName = word;
              if (word.indexOf('/') != -1) {

                chinaLastName = word.split('/')[0];
                enLastName = word.split('/')[1];
              }
            } catch (e) {}
          } else if (word_name == '性别') {
            try {
              if (word == 'M' || word.indexOf('M') != -1 || word.indexOf('m') == -1 || word.indexOf('男') != -1) {
                sex = {
                  'Id': 1,
                  'Name': '男'
                };
              } else {
                sex = {
                  'Id': 2,
                  'Name': '女'
                };
              }
            } catch (e) {}
          } else if (word_name == '出生日期') {
            birthday = this.formatDateWithTaiwan(word)
          } else if (word_name == '护照号') {
            if (word.indexOf('i') != -1) {
              word = word.replace(/i/g, '1');
            }
            if (word.indexOf('I') != -1) {
              word = word.replace(/I/g, '1');
            }
            if (word.indexOf('l') != -1) {
              word = word.replace(/l/g, '1');
            }
            if (word.indexOf('L') != -1) {
              word = word.replace(/L/g, '1');
            }
            if (word.indexOf('|') != -1) {
              word = word.replace(/\|/g, '1');
            }
            passportNo = word;
          } else if (word_name == '签发机关') {
            passportAddress = word;
          } else if (word_name == '有效期至') {
            passportExpiry = this.formatDateWithTaiwan(word);
          } else if (word_name == '国家码') {
            nationality = {
              'ID': 2,
              'Name': '中国'
            };
          } else if (word_name == '出生地点') {
            birthplace = word;
            if (word.indexOf('/') != -1) {
              birthplace = word.split('/')[0];
            }
          } else if (word_name == '签发日期') {
            passportDate = this.formatDateWithTaiwan(word);
          }
        }
        formatData = {
          'chinaFirstName': chinaFirstName,
          'chinaLastName': chinaLastName,
          'sex': sex,
          'birthday': birthday,
          'enFirstName': enFirstName,
          'enLastName': enLastName,
          'passportNo': passportNo,
          'passportAddress': passportAddress,
          'passportExpiry': passportExpiry,
          'nationality': nationality,
          'birthplace': birthplace,
          'passportDate': passportDate
        };
        return formatData;
      },
      // 台湾护照数据处理
      formatDataWithTaiwan(results) {
        let formatData = null;
        let chinaFirstName = '';
        let chinaLastName = '';
        let sex = {
          'Id': 1,
          'Name': '男'
        };
        let birthday = '';
        let enFirstName = '';
        let enLastName = '';
        let passportNo = '';
        let passportAddress = '';
        let passportExpiry = '';
        let nationality = {
          'ID': '',
          'Name': ''
        };

        let birthplace = '';
        let passportDate = '';

        for (let i = 0; i < results.length; i++) {
          let item = results[i];
          let word_name = item.word_name;
          let word = item.word != null ? item.word : '';
          if (word_name == '姓名') {
            try {
              if (word != null && word.length > 0) {
                if (word.length == 1) {
                  chinaFirstName = word;
                } else if (word.length == 2) {
                  chinaFirstName = word.substring(0, 1);
                  chinaLastName = word.substring(1, 2);
                } else if (word.length == 3) {
                  chinaFirstName = word.substring(0, 1);
                  chinaLastName = word.substring(1, 3);
                } else if (word.length == 4) {
                  chinaFirstName = word.substring(0, 2);
                  chinaLastName = word.substring(2, 4);
                } else {
                  chinaFirstName = word.substring(0, 1);
                  chinaLastName = word.substring(1, word.length);
                }
              }
            } catch (e) {
              chinaFirstName = word;
              chinaLastName = word;
            }
          } else if (word_name == '性别') {
            try {
              if (word == 'M' || word.indexOf('M') != -1 || word.indexOf('m') == -1) {
                sex = {
                  'Id': 1,
                  'Name': '男'
                };
              } else {
                sex = {
                  'Id': 2,
                  'Name': '女'
                };
              }
            } catch (e) {}
          } else if (word_name == '出生日期') {
            birthday = this.formatDateWithTaiwan(word)
          } else if (word_name == 'name') {
            if (word.length > 0) {
              try {
                if (word.indexOf('.') != -1) {
                  enFirstName = word.split('.')[0];
                  enLastName = word.split('.')[1];
                } else if (word.indexOf(',') != -1) {
                  enFirstName = word.split(',')[0];
                  enLastName = word.split(',')[1];
                } else if (word.indexOf('。') != -1) {
                  enFirstName = word.split('。')[0];
                  enLastName = word.split('。')[1];
                } else if (word.indexOf('，') != -1) {
                  enFirstName = word.split('，')[0];
                  enLastName = word.split('，')[1];
                } else {
                  enFirstName = word;
                  enLastName = word;
                }
              } catch (e) {}
            }
          } else if (word_name == '护照号码') {
            if (word.indexOf('i') != -1) {
              word = word.replace(/i/g, '1');
            }
            if (word.indexOf('I') != -1) {
              word = word.replace(/I/g, '1');
            }
            if (word.indexOf('l') != -1) {
              word = word.replace(/l/g, '1');
            }
            if (word.indexOf('L') != -1) {
              word = word.replace(/L/g, '1');
            }
            if (word.indexOf('|') != -1) {
              word = word.replace(/\|/g, '1');
            }
            passportNo = word;
          } else if (word_name == '发照机构') {
            passportAddress = word;
          } else if (word_name == '有效期截止') {
            passportExpiry = this.formatDateWithTaiwan(word);
          } else if (word_name == '国籍') {
            nationality = {
              'ID': 2,
              'Name': '中国'
            };
          } else if (word_name == '出生地') {
            birthplace = word;
          } else if (word_name == '发照日期') {
            passportDate = this.formatDateWithTaiwan(word);
          }
        }
        formatData = {
          'chinaFirstName': chinaFirstName,
          'chinaLastName': chinaLastName,
          'sex': sex,
          'birthday': birthday,
          'enFirstName': enFirstName,
          'enLastName': enLastName,
          'passportNo': passportNo,
          'passportAddress': passportAddress,
          'passportExpiry': passportExpiry,
          'nationality': nationality,
          'birthplace': birthplace,
          'passportDate': passportDate
        };
        return formatData;
      },

      commonTextDiscern() {
        let params = "";
        let url = "";
        if (this.templateType == 1) {
          //身份证
          params =
            "detect_direction=true&id_card_side=front&image=" +
            encodeURIComponent(this.imgBase64String);
          url =
            this.BD_COMMON_TEXT_DISCERN_IDCARD +
            "?access_token=" +
            this.access_token_ocr;
        } else {
          //自定义模板
          if (this.templateSign == "") {
            this.$message.error("请选择护照类型！");
            return;
          }
          params =
            "templateSign=" +
            this.templateSign +
            "&image=" +
            encodeURIComponent(this.imgBase64String);
          url =
            this.BD_COMMON_TEXT_DISCERN +
            "?access_token=" +
            this.access_token_ocr;
        }
        this.loading = true;
        this.apipost(
          "admin_get_ApiLinkAgency", {
            Path: url,
            Image: params
          },
          res => {
            if (res.data.resultCode == 1) {
              this.loading = false;
              if (this.templateType == 1) {
                //身份证
                let obj = JSON.parse(res.data.data).words_result;
                this.addMsg.Nationality = 2;
                for (let key in obj) {
                  switch (key) {
                    case "姓名":
                      this.addMsg.SurName = obj[key].words.substring(0, 1);
                      this.addMsg.Name = obj[key].words.substring(
                        1,
                        obj[key].words.length
                      );
                      this.Transformation(this.addMsg.SurName, "SurName");
                      this.Transformation(this.addMsg.Name, "Name");
                      break;
                    case "公民身份号码":
                      this.addMsg.IdCard = obj[key].words;
                      break;
                    case "住址":
                      this.addMsg.AddressDetail = obj[key].words;
                      break;
                    case "性别":
                      obj[key].words == "男" ?
                        (this.addMsg.Sex = "1") :
                        (this.addMsg.Sex = "2");
                      break;
                    case "出生":
                      this.addMsg.Birthday =
                        obj[key].words.substring(0, 4) +
                        "-" +
                        obj[key].words.substring(4, 6) +
                        "-" +
                        obj[key].words.substring(6, 8);
                    default:
                      break;
                  }
                }
              } else {
                //自定义模板
                if (this.templateSign == "7224a048d0fcc94413c3a729e481a775") {
                  //台湾护照
                  let obj = JSON.parse(res.data.data);
                  let myObj = this.formatDataWithTaiwan(obj.data.ret)
                  this.addMsg.Birthday = myObj.birthday
                  this.addMsg.SurName = myObj.chinaFirstName.trim()
                  this.addMsg.Name = myObj.chinaLastName.trim()
                  this.addMsg.ESurName = myObj.enFirstName.trim()
                  this.addMsg.EName = myObj.enLastName.trim()
                  this.addMsg.Nationality = myObj.nationality.ID
                  this.addMsg.PassportAddress = myObj.passportAddress
                  this.addMsg.PassportExpiry = myObj.passportExpiry
                  this.addMsg.PassportNo = myObj.passportNo
                  this.addMsg.Sex = myObj.sex.Id.toString()
                  this.addMsg.PassportIssued = myObj.passportDate
                  this.addMsg.BirthdayAddress = myObj.birthplace
                } else if (this.templateSign == "2625f80ec957a0c837ca14f8ce608a51") {
                  //大陆护照
                  let obj = JSON.parse(res.data.data);
                  let myObj = this.formatDataWithChina(obj.data.ret)
                  this.addMsg.Birthday = myObj.birthday
                  this.addMsg.SurName = myObj.chinaFirstName.trim()
                  this.addMsg.Name = myObj.chinaLastName.trim()
                  this.addMsg.ESurName = myObj.enFirstName.trim()
                  this.addMsg.EName = myObj.enLastName.trim()
                  this.addMsg.Nationality = myObj.nationality.ID
                  this.addMsg.PassportAddress = myObj.passportAddress
                  this.addMsg.PassportExpiry = myObj.passportExpiry
                  this.addMsg.PassportNo = myObj.passportNo
                  this.addMsg.Sex = myObj.sex.Id.toString()
                  this.addMsg.PassportIssued = myObj.passportDate
                  this.addMsg.BirthdayAddress = myObj.birthplace
                } else if (this.templateSign == "2dc78a37e516f18ebe56aeacc6d49203") {
                  //大陆护照旧版
                  let obj = JSON.parse(res.data.data);
                  let myObj = this.formatDataWithChina_old(obj.data.ret)
                  this.addMsg.Birthday = myObj.birthday
                  this.addMsg.SurName = myObj.chinaFirstName.trim()
                  this.addMsg.Name = myObj.chinaLastName.trim()
                  this.addMsg.ESurName = myObj.enFirstName.trim()
                  this.addMsg.EName = myObj.enLastName.trim()
                  this.addMsg.Nationality = myObj.nationality.ID
                  this.addMsg.PassportAddress = myObj.passportAddress
                  this.addMsg.PassportExpiry = myObj.passportExpiry
                  this.addMsg.PassportNo = myObj.passportNo
                  this.addMsg.Sex = myObj.sex.Id.toString()
                  this.addMsg.PassportIssued = myObj.passportDate
                  this.addMsg.BirthdayAddress = myObj.birthplace
                } else if (this.templateSign == "2cd1d05f5efc5eec23ffad6358bdb70f") {
                  //台湾通行证
                }
              }
            } else {
              this.loading = false;
            }
          },
          err => {}
        );
      },
      onUpload(val) {
        let preview = document.getElementById("img");
        let file = document.getElementById("file").files[0];
        let reader = new FileReader();
        reader.onloadend = function () {
          preview.src = reader.result;
        };
        if (file) {
          reader.readAsDataURL(file);
        } else {
          preview.src = "";
        }
        this.lrz(file, {
          quality: 0.7
        }).then(res => {
          this.imgBase64String = res.base64.slice(23);
        });
      },
      goBack() {
        history.go(-1);
      },
      submitForm(addMsg, type) {
        if (this.btnState === true) {
          //提交创建、修改表单
          this.$refs[addMsg].validate(valid => {
            this.btnState = false
            if (valid) {
              this.savePassenger(type);
            } else {
              this.btnState = true
              return false;
            }
          });
        }
      },
      savePassenger(type) {
        this.timeOver()
        if ((this.LineId === 14 || this.LineId === 2) && this.addMsg.IdCard === '') {
          return this.$message.error('请填写身份证号码！');
        }
        this.addMsg.EconomicCapabilityList = [];
        this.EconomicCapabilityS.forEach(x => {
          if (x.isShow == true) {
            this.addMsg.EconomicCapabilityList.push({
              Key: x.Name,
              Value: x.Content,
              ID: x.ID
            });
          }
        });
        if (this.addMsg.Marriage == "") {
          this.addMsg.Marriage = "0";
        }
        if (this.ppAge <= 10 && this.addMsg.IsBed == 1) {
          this.$confirm(this.$t('该游客未满十岁确认占床?'), this.$t('tips.tips'), {
            confirmButtonText: '确认',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.seveInfo(type)
          }).catch(() => {
            this.btnState = true
          });
        } else {
          this.seveInfo(type)
        }
      },
      seveInfo(type) {
        this.apipost(
          "sellorder_post_SetTravelGuestInfo_V2",
          this.addMsg,
          res => {
            if (res.data.resultCode == 1) {
              this.$message.success(res.data.message);
              if (type == 1) {
                history.go(-1);
              } else {
                this.btnState = true
                this.ClearData();
              }
            } else {
              this.btnState = true
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getEconomicCapability() {
        //获取经济能力
        this.apipost(
          "dict_post_GetList", {
            Key: "SK_Visa_EconomicCapability",
            IsTimer: 1
          },
          res => {
            this.EconomicCapabilityS = res.data.data;
            if (this.$route.query.guestId != 0) {
              this.addMsg.Id = this.$route.query.guestId;
              this.getInfo();
            }
          },
          err => {}
        );
      },
      addEconomicCapability(obj) {
        // 添加经济能力说明
        this.EconomicCapabilityS.forEach(x => {
          if (x.ID == obj.ID) {
            x.isShow ? (x.isShow = false) : (x.isShow = true);
          }
        });
        this.$forceUpdate();
      },
      Transformation(val, type) {
        let text = this.pinyin(val, {
          style: this.pinyin.STYLE_NORMAL
        });
        if (type == "SurName") {
          let upText = text.join("").toLocaleUpperCase()
          this.addMsg.ESurName = upText;
        }
        if (type == "Name") {
          let upText = text.join("").toLocaleUpperCase()
          this.addMsg.EName = upText;
        }
      },
      getVisaIdentityTypeEnum() {
        //获取身份证明
        let msg = {};
        this.apipost(
          "dmc_get_visa_GetVisaIdentityTypeEnum",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.VisaIdentityTypeEnum = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getVisaDutyTypeEnum() {
        //获取职务
        let msg = {};
        this.apipost(
          "dmc_get_visa_GetVisaDutyTypeEnum",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.VisaDutyTypeEnum = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getVisaDeparturesType() {
        //获取出境记录状态
        let msg = {};
        this.apipost(
          "dmc_get_visa_GetVisaDeparturesTypeEnum",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.VisaDeparturesType = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getMarriageType() {
        //获取婚姻
        let msg = {};
        this.apipost(
          "dmc_get_visa_GetVisaMarriageTypeEnum",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.MarriageType = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getCountry() {
        //获取国家
        let msg = {};
        this.apipost(
          "dict_post_Destination_GetCountry",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.countryList = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getVisaApplyForTypeEnum() {
        // 获取申请类型
        this.apipost(
          "dmc_get_visa_GetVisaApplyForTypeEnum", {},
          res => {
            if (res.data.resultCode == 1) {
              this.VisaApplyForTypeEnum = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getChinaAirportList() {
        // 获取国内机场
        let msg = {
          City_id: 0,
          Country_id: 2,
          TrafficType: 1,
        };
        this.apipost(
          "airport_post_GetList",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.ChinaAirportList = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getJapanAirportList() {
        // 获取日本机场
        let msg = {
          City_id: 0,
          Country_id: 651,
          TrafficType: 1
        };
        this.apipost(
          "airport_post_GetList",
          msg,
          res => {
            if (res.data.resultCode == 1) {
              this.JapanAirportList = res.data.data;
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      goUrl(path) {
        this.$router.push({
          name: path
        });
      },
      getInfo() {
        this.apipost(
          "sellorder_get_GetTravelGuestInfo", {
            GuestId: this.$route.query.guestId
          },
          res => {
            if (res.data.resultCode == 1) {
              let obj = res.data.data;
              this.addMsg = obj;
              this.addMsg.Sex = obj.Sex.toString();
              this.addMsg.DutyType = obj.DutyType.toString();
              this.addMsg.UnitType = obj.UnitType.toString();
              this.addMsg.TravelType = obj.TravelType.toString();
              this.addMsg.Marriage = obj.Marriage.toString();
              if (this.addMsg.Marriage == "0") {
                this.addMsg.Marriage = "";
              }
              this.addMsg.IsCriminalRecord = obj.IsCriminalRecord === null ? '' : obj.IsCriminalRecord.toString();
              this.addMsg.IsDepartureRecord = obj.IsDepartureRecord.toString();
              this.EconomicCapabilityS.forEach(x => {
                if (obj.EconomicCapabilityList) {
                  obj.EconomicCapabilityList.forEach(y => {
                    if (x.ID == y.ID) {
                      x.isShow = true;
                      x.Content = y.Value;
                    }
                  });
                }
              });
              this.VisaStartStatus = this.addMsg.IsVisaFree;
              this.AirStartStatus = this.addMsg.IsNeedAirticket;
              this.SafeStartStatus = this.addMsg.IsNeedSafe;
              this.zhanchuangTips(obj.Birthday)
              this.$forceUpdate();
              this.getHouselist(obj.Sex.toString(), obj.TCID, obj.OrderId, obj.IsBed)
              if (this.$route.query.isOneDay === 1) {
                this.addMsg.IsBed = 0
              }
            } else {
              this.$message.error();
            }
          },
          err => {}
        );
      },
      GetGuestMustVisaAir() {
        this.apipost(
          "sellorder_get_GetGuestMustVisaAir", {
            OrderId: this.$route.query.orderId
          },
          res => {
            if (res.data.resultCode == 1) {
              let obj = res.data.data;
              this.IsMustVisa = obj.IsMustVisa;
              this.IsMustAir = obj.IsMustAir;
              this.IsMustSafe = obj.IsMustSafe;
              this.VisaNotNeedList = obj.VisaNotNeedList;
              this.AirNoeNeedList = obj.AirNoeNeedList;
              this.SafeNotNeedList = obj.SafeNotNeedList;
              if (obj.IsMustAir == 0) {
                this.addMsg.IsNeedAirticket = 2;
              }
              if (obj.IsMustVisa == 0) {
                this.addMsg.IsVisaFree = 1;
              }
              if (obj.IsMustSafe == 0) {
                this.addMsg.IsNeedSafe = 2;
              }
            }
          }
        );
      },
      ClearData() {
        this.addMsg.SurName = "";
        this.addMsg.Name = "";
        this.addMsg.Sex = "";
        this.addMsg.EName = "";
        this.addMsg.ESurName = "";
        this.addMsg.Birthday = "";
        this.addMsg.BirthdayAddress = "";
        this.addMsg.PassportAddress = "";
        this.addMsg.PassportExpiry = "";
        this.addMsg.PassportNo = "";
        this.addMsg.Nationality = 2;
        this.addMsg.Marriage = "";
        this.addMsg.Address = "";
        this.addMsg.AddressDetail = "";
        this.addMsg.HistoryRecord = "";
        this.addMsg.IdentityType = "";
        this.addMsg.Duty = "";
        this.addMsg.EconomicCapabilityList = [];
        this.addMsg.Remarks = "";
        this.addMsg.TravelType = "";
        this.addMsg.UnitType = "";
        this.addMsg.DutyType = "";
        this.addMsg.IsHightSchool = "2";
        this.addMsg.IsRecommend = "2";
        this.addMsg.PassportIssued = "";
        this.addMsg.IssuingAuthority = "";
        this.addMsg.IdCard = "";
        this.addMsg.CEName = "";
        this.addMsg.CName = "";
        this.addMsg.CNationality = "";
        this.addMsg.Tel = "";
        this.addMsg.MobilePhone = "";
        this.addMsg.UnitAddress = "";
        this.addMsg.UnitName = "";
        this.addMsg.UnitPhone = "";
        this.addMsg.UnitPost = "";
        this.addMsg.Purpose = "观光";
        this.addMsg.IsDepartureRecord = "2";
        this.addMsg.LastTime = "";
        this.addMsg.DeadlineTime = "";
        this.addMsg.NCNationality = "";
        this.addMsg.HotelTel = "";
        this.addMsg.HotelAddress = "";
        this.addMsg.HotelName = "参照\"赴日予定表\"";
        this.addMsg.EmergencyContact = "";
        this.addMsg.EmergencyAddress = "";
        this.addMsg.EmergencyTel = "";
        this.addMsg.IsCriminalRecord = "2";
        this.addMsg.TravelCost = "";
        this.addMsg.TravelName = "";
        this.addMsg.MutualFriends = "";
        this.addMsg.Date = "";
        this.addMsg.IsBed = 1;
        this.addMsg.IsVisaFree = 2;
        this.addMsg.IsNeedAirticket = 1;
        this.addMsg.IsNeedSafe = 1;
        this.addMsg.AirReplaceId = "0";
        this.addMsg.VisaReplaceId = "0";
        this.addMsg.SafeReplaceId = "0";
        this.addMsg.VisaState = 0;
        this.GetGuestMustVisaAir();
        let userInfo = this.getLocalStorage();
        var BranchName = userInfo.BranchName;
        if (BranchName.search("武汉") != -1) {
          this.addMsg.BirthdayAddress = "湖北";
          this.addMsg.PassportAddress = "湖北";
        } else if (BranchName.search("西安") != -1) {
          this.addMsg.BirthdayAddress = "陕西";
          this.addMsg.PassportAddress = "陕西";
        } else if (BranchName.search("长沙") != -1) {
          this.addMsg.BirthdayAddress = "湖南";
          this.addMsg.PassportAddress = "湖南";
        }
        this.addMsg.IssuingAuthority = "公安部出入境管理局";
      },
      Roominformation() {
        let TCIDs = this.addMsg.TCID;
        let OrderId = this.addMsg.OrderId;
        let IsBed = this.addMsg.IsBed;
        let Sex = this.addMsg.Sex;
        if (Sex == 1 || Sex == 2) {
          this.apipost(
            "sellorder_post_GetHouseDetailsByOrderID", {
              TCIDs: TCIDs,
              OrderId: OrderId,
              Sex: Sex,
              IsBed: IsBed
            },
            res => {
              if (res.data.resultCode == 1) {
                this.roomlist = res.data.data;

                if (this.roomlist.length < 1) {
                  this.UpdateOrderHouseBtn = true
                }
              } else {
                this.$message.error(res.data.message);
              }
            },
            err => {}
          );
        }
      },
      SellUpdateOrderHouse() {
        let OrderId = this.addMsg.OrderId;
        this.apipost(
          "sellorder_post_SellUpdateOrderHouse_V2", {
            OrderId: OrderId
          },
          res => {
            if (res.data.resultCode == 1) {
              this.Roominformation()
              this.UpdateOrderHouseBtn = false
            } else {
              this.$message.error(res.data.message);
            }
          },
          err => {}
        );
      },
      getHouselist(Sex, TCID, OrderId, IsBed) {
        if (Sex == 1 || Sex == 2) {
          this.apipost(
            "sellorder_post_GetHouseDetailsByOrderID", {
              TCIDs: TCID,
              OrderId: OrderId,
              Sex: Sex,
              IsBed: IsBed
            },
            res => {
              if (res.data.resultCode == 1) {
                this.roomlist = res.data.data;
              } else {
                this.$message.error(res.data.message);
              }
            },
            err => {}
          );
        } else {
          this.$message.error('请选择性别');
        }
      },
      addhouse() {
        let orderId = this.addMsg.OrderId;
        let sex = this.addMsg.Sex;
        if (sex == 1 || sex == 2) {
          this.apipost(
            "sellorder_get_BatchSetOrderHouse_V2", {
              orderId: orderId,
              sex: sex,
            },
            res => {
              if (res.data.resultCode == 1) {
                this.Roominformation()
              } else {
                this.$message.error(res.data.message);
              }
            },
            err => {}
          );
        }
      },
      authentication() {
        let IdCard = this.addMsg.IdCard;
        if (this.$route.query.guestId == 0) {
          if (IdCard.length == 18) {
            this.apipost(
              "sellorder_post_GetGusetByIDCard", {
                IdCard: this.addMsg.IdCard,
              },
              res => {
                if (res.data.resultCode == 1) {
                  let obj = res.data.data;
                  this.addMsg.SurName = obj.SurName;
                  this.addMsg.Name = obj.Name;
                  this.addMsg.ESurName = obj.ESurName;
                  this.addMsg.EName = obj.EName;
                  this.addMsg.Sex = obj.Sex.toString();
                  this.addMsg.MobilePhone = obj.MobilePhone;
                  this.addMsg.Birthday = obj.Birthday;
                  this.addMsg.BirthdayAddress = obj.BirthdayAddress;
                  this.addMsg.PassportNo = obj.PassportNo;
                  this.addMsg.PassportAddress = obj.PassportAddress;
                  this.addMsg.PassportIssued = obj.PassportIssued;
                  this.addMsg.PassportExpiry = obj.PassportExpiry;
                  this.addMsg.Nationality = obj.Nationality;
                  this.addMsg.Marriage = obj.Marriage.toString();
                  if (this.addMsg.Marriage == "0") {
                    this.addMsg.Marriage = "";
                  }
                  this.addMsg.Address = obj.Address;
                  this.addMsg.AddressDetail = obj.AddressDetail;
                  this.addMsg.IdentityType = obj.IdentityType;
                  this.addMsg.HistoryRecord = obj.HistoryRecord;
                  this.addMsg.Duty = obj.Duty;
                  this.addMsg.Remarks = obj.Remarks;
                  this.addMsg.TravelType = Number(obj.TravelType);
                  this.addMsg.UnitType = Number(obj.UnitType);
                  this.addMsg.DutyType = Number(obj.DutyType);
                  this.addMsg.IsHightSchool = obj.IsHightSchool;
                  this.addMsg.IsRecommend = obj.IsRecommend;
                  this.addMsg.Id = this.$route.query.guestId;
                  this.addMsg.TCID = this.$route.query.TCID;
                  this.addMsg.OrderId = this.$route.query.orderId;
                  this.Roominformation() //调取下房间信息
                }
              },
              err => {}
            );
          }
        }
      }
    },
    mounted() {
      this.getTravelType();
      this.getDutyType();
      this.getUnitType();
      this.getCountry();
      this.getMarriageType();
      this.getVisaDeparturesType();
      this.getVisaDutyTypeEnum();
      this.getVisaIdentityTypeEnum();
      this.getEconomicCapability();
      this.GetGuestMustVisaAir();
      this.getAccessToken();
      this.isOneDay = this.$route.query.isOneDay;
      this.LineId = this.$route.query.LineId;
      this.addMsg.TCID = this.$route.query.TCID;
      this.addMsg.OrderId = this.$route.query.orderId;
      this.EndDateStr = this.$route.query.EndDateStr;
      let userInfo = this.getLocalStorage();
      var BranchName = userInfo.BranchName;
      if (BranchName.search("武汉") != -1) {
        this.addMsg.BirthdayAddress = "湖北";
        this.addMsg.PassportAddress = "湖北";
      } else if (BranchName.search("西安") != -1) {
        this.addMsg.BirthdayAddress = "陕西";
        this.addMsg.PassportAddress = "陕西";
      } else if (BranchName.search("长沙") != -1) {
        this.addMsg.BirthdayAddress = "湖南";
        this.addMsg.PassportAddress = "湖南";
      }
      this.addMsg.IssuingAuthority = "公安部出入境管理局";
      this.getJingDIan();
    }
  };

</script>
