<template>
  <d2-container class="page" id="personalInfo_index_scoped" v-loading="loading">
    <!--
    <el-card class="box-card" body-style="max-height: 180px;">
      <center>
        <div>
          <img :src="isEnroled?'./image/step/4.png':stepImg" style="width:1000px;">
        </div>
      </center>
    </el-card>
    -->
    <el-tabs value="first">
      <el-tab-pane label="基本信息" name="first">
        <el-row>
          <el-col :span="6">
            <el-row>
              <el-col :span="4">&nbsp;</el-col>
              <el-col :span="16">
                <table style="font-size: 14px;margin-top:5px;width:100%" >
                  
                    <tr>
                      <td align="center">
                        <div v-if="!stdRegInfo.photo_url" tabindex="0" @click="showImgUploadModal()" class="el-upload el-upload--text" style="width: 180px;height: 240px;border:solid 1.5px #000000;"><i class="el-icon-plus avatar-uploader-icon" style="margin-top: 60px;"></i></div>
                        
                        <img v-if="stdRegInfo.photo_url" @click="showImgUploadModal()" style="width: 180px;height: 240px;border:solid 1.5px #000000;cursor: pointer;" :src="photo_url">
                        
                      </td>
                    </tr>
                    <tr>
                    <td align="center">
                      <span v-if="stdRegInfo.photo_compliance=='1'">审核通过</span>
                      <span v-else-if="stdRegInfo.photo_compliance=='0'">审核不通过</span>
                      <span v-else>未审核</span>
                      
                    </td>
                    <tr>
                    <td align="center">
                      <el-button type="primary" size="middle" @click="is_photoReview=0;showImgUploadModal()">上传照片</el-button>

                    </td>
                  </tr>
                  <!--
                   <tr>
                    <td align="center">
                      <el-button v-if="stdRegInfo.photo_compliance!='1'" type="primary" size="middle" @click="is_photoReview=1;showImgUploadModalForCheck()">照片合规检查</el-button>

                    </td>
                  </tr>
                  -->
                </table>
              </el-col>
              <el-col :span="4">&nbsp;</el-col>
            </el-row>
            <!-- <img v-if="stdRegInfo.photo_url!=undefined" :src="src" style="width:170px;height:170px;border:1px;border-color:black">
            <img v-if="stdRegInfo.photo_url==undefined" src="/image/theme/sys/head.png" style="width:170px;height:170px;border:1px;border-color:black"><br> -->
          </el-col>
          <el-col :span="16">
            <div style="width:700px;border-left: 2px solid #eee;padding-left: 28px;">
              <el-form ref="stdRegInfo" :model="stdRegInfo" :rules="stdRegInfoRule" label-width="120px" size="mini">
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="证件号" v-if="stdRegInfo.ticket_no">
                        <el-input size="mini" v-if="stdRegInfo.cert_no_must_update == 1" clearable v-model="stdRegInfo.cert_no" style="width:200px;"></el-input>
                        <span v-else>
                           {{stdRegInfo.cert_no? stdRegInfo.cert_no.replace(/^(.{6})(?:\w+)(.{4})$/, "\$1********\$2"):""}}
                        </span>
                       
                    </el-form-item>

                    <el-form-item label="证件号" v-if="!stdRegInfo.ticket_no" prop="cert_no">
                      <el-input size="mini" clearable v-model="stdRegInfo.cert_no" style="width:200px;"></el-input>
                    </el-form-item>

                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="证件类型" prop="cert_type">
                      <el-select size="mini" clearable v-model="stdRegInfo.cert_type" filterable placeholder="请选择证件类型" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in certTypeArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>

                  
                </el-row>

                <el-row>
                  <el-col :span="12">
                    <el-form-item label="身份认证">
                     <span v-if="stdRegInfo.is_identfiy == 1" style="font-size: 14px;color: #606266;" id="is_identfiy_span"> 已认证</span>
                     <span v-else-if="stdRegInfo.is_identfiy == 2" style="font-size: 14px;color: #606266;" id="is_identfiy_span"> 未认证</span>
                     <span v-else style="font-size: 14px;color: #606266;" id="is_identfiy_span"> 未认证</span>
                     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;
                     <el-button v-if="!stdRegInfo.is_identfiy || stdRegInfo.is_identfiy != 1" type="primary" size="mini" @click="checkIdentifyCard">身份认证</el-button>

                    </el-form-item>

                  </el-col>
                  <el-col :span="12">
                    
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :span="12">
                   

                    <el-form-item label="姓名"  prop="std_name">
                     <el-input size="mini" clearable v-model="stdRegInfo.std_name"  maxlength="11" style="width:200px;"></el-input>
                    </el-form-item>

                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="准考证号">
                     <span style="font-size: 14px;color: #606266;"> {{stdRegInfo.ticket_no?stdRegInfo.ticket_no:'暂未生成'}}</span>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row>
                  <!--
                  <el-col :span="12">
                    <el-form-item label="英文名" prop="std_eng_name">
                      <el-input size="mini" clearable v-model="stdRegInfo.std_eng_name"  maxlength="20" style="width:200px;"></el-input>
                    </el-form-item>

                  </el-col>
                  -->
                  <el-col :span="12">
                    
                    <!-- <el-form-item label="性别" v-if="stdRegInfo.ticket_no">
                        {{stdRegInfo.std_sex?find({dict_value: stdRegInfo.std_sex},sexArray).dict_text:''}}
                    </el-form-item> -->

                    <!-- v-if="!stdRegInfo.ticket_no" -->
                    <el-form-item label="性别"  prop="std_sex">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_sex" filterable placeholder="请选择性别" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in sexArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                       
                    </el-form-item>

                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="政治面貌" prop="political_status">
                      <el-select size="mini" clearable v-model="stdRegInfo.political_status" filterable placeholder="请选择活动区域" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in politicalStatusArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item v-if="stdRegInfo.cert_type == 1" disabled label="出生日期" prop="std_birth">
                      <el-date-picker size="mini" value-format="yyyy-MM-dd" type="date" v-model="stdRegInfo.std_birth" placeholder="选择出生日期" style="width:200px;"></el-date-picker>
                    </el-form-item>

                    <el-form-item v-if="stdRegInfo.cert_type != 1"  label="出生日期" prop="std_birth">
                      <el-date-picker size="mini" value-format="yyyy-MM-dd" type="date" v-model="stdRegInfo.std_birth" placeholder="选择出生日期" style="width:200px;"></el-date-picker>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="民族" prop="std_nation">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_nation" filterable placeholder="请选择民族" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in nationArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="籍贯" prop="std_family_reg">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_family_reg" filterable placeholder="请选择籍贯" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in familyRegArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row>
                  <!--
                  <el-col :span="12">
                    <el-form-item label="考生来源" prop="std_source">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_source" filterable placeholder="请选择考生来源" @change="std_sourceChange" style="width:200px;">
                          
                          <el-option label="社会考生" value="1"></el-option>
                          <el-option label="助学考生" value="3"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  -->
                 
                </el-row>

                 <el-row>
                  <el-col :span="12">
                    <el-form-item label="报考专业层次" prop="major_level">
                    <el-select size="mini" v-model="stdRegInfo.major_level" filterable clearable placeholder="请选择专业层次" @change="majorLevelChange" style="width:200px;">
                       <el-option  v-for="(item,index) in majorLevelArray" :key="index" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value"></el-option>
                    </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="报考专业" prop="major_id">
                    <el-select size="mini" v-model="stdRegInfo.major_id" filterable clearable placeholder="请选择专业" @change="majorChange" style="width:200px;">
                      <el-option label="-请选择-" value=""></el-option>
                       <el-option  v-for="item in majorArray" :key="item.id" :label="item.major_code+' | '+item.major_name" :value="item.id"></el-option>
                    </el-select>
                    </el-form-item>
                  </el-col>
                 </el-row>
                 <el-row>
                 
                  <el-col :span="12">
                    <el-form-item label="主考院校" title="助学考生,备案后系统自动更改主考院校。">
                      <span style="font-size: 14px;color: #606266;"  title="助学考生,备案后系统自动更改主考院校。">{{school_name}}</span>

              

                    </el-form-item>
                  </el-col>
                   <el-col :span="12">
                    <el-form-item label="考前学历" prop="std_edu">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_edu" filterable placeholder="请选择考前学历" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in eduArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <!--
                  <el-col :span="12">
                  <el-form-item label="所属考区" prop="exam_area_id">
                    <el-select size="mini" v-model="stdRegInfo.exam_area_id" filterable clearable placeholder="请选择考生所属地市" style="width:200px;">
                      <el-option label="-请选择-" value=""></el-option>
                      <el-option v-for="item in exam_area_array" :key="item.org_code+' | '+item.org_name" :label="item.org_code+' | '+item.org_name" :value="item.id"></el-option>
                    </el-select>
                  </el-form-item>
                </el-col>
                -->
              </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="职业" prop="std_occupation">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_occupation" filterable placeholder="请选择职业" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in occupationArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="健康状况" prop="std_healthy">
                      <el-select size="mini" clearable v-model="stdRegInfo.std_healthy" filterable placeholder="请选择健康状况" style="width:200px;">
                        <el-option label="-请选择-" value=""></el-option>
                        <el-option v-for="(item,index) in healthyArray" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value" :key="index"></el-option>
                      </el-select>
                    </el-form-item>
                  </el-col>
                </el-row>

                 <el-row>
                  <el-col :span="12">
                     <el-form-item label="地（市）" prop="std_city">
                        <el-select v-model="stdRegInfo.std_city" filterable  placeholder="请选择地（市）" @change="cityChange" style="width:200px;">
                          <el-option v-for="(item) in city_county_data" :key="item.city_code" :label="item.full_name" :value="item.city_code"></el-option>
                        </el-select>
                      </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="区（县）" prop="std_county">
                      <el-select v-model="stdRegInfo.std_county" filterable  placeholder="请选择区（县）" @change="countyChange" style="width:200px;">
                        <el-option v-for="(item) in county_data" :key="item.country_code" :label="item.full_name" :value="item.country_code"></el-option>
                      </el-select>
                    </el-form-item>
                    
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :span="12">
                    <el-form-item label="绑定手机号码" prop="bindphone">
                      <span>
                           {{stdRegInfo.bindphone? stdRegInfo.bindphone.replace(/^(.{3})(?:\w+)(.{4})$/, "\$1****\$2"):""}}
                      </span>
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="绑定邮箱" prop="bind_email">
                      <span>
                           {{stdRegInfo.bind_email? stdRegInfo.bind_email.replace(/^(.{4})(?:\w+)(.{7})$/, "\$1******\$2"):""}}
                      </span>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row>
                  <el-col :span="12">
                    <el-form-item label="手机号码" prop="std_mobile">
                      <el-input size="mini" clearable v-model="stdRegInfo.std_mobile"  maxlength="11" style="width:200px;"></el-input>
                    </el-form-item>
                  </el-col>
                  <!--
                  <el-col :span="12">
                    <el-form-item label="邮编" prop="std_postcode">
                      <el-input size="mini" clearable v-model="stdRegInfo.std_postcode"  maxlength="6" style="width:200px;"></el-input>
                    </el-form-item>
                  </el-col>
                  -->

                   <el-col :span="12">
                    <el-form-item label="电子邮件" prop="std_email">
                      <el-input size="mini" clearable v-model="stdRegInfo.std_email" style="width:200px;"></el-input>
                    </el-form-item>
                  </el-col>

                </el-row>
                 
              <el-row style="color:#409EFF;">
                  <el-col :span="12">
                    现居住通信地址
                  </el-col>
                 
                </el-row>

                <el-row>
                  <el-col :span="12">
                     <el-form-item label="省(市、自治区)" prop="province">
                        <el-select v-model="stdRegInfo.province" filterable  placeholder="请选择省（市、自治区）" @change="cityChangeForAddress" style="width:200px;">
                          <el-option v-for="(item) in provinces" :key="item.code_id" :label="item.code_name" :value="item.code_id"></el-option>
                        </el-select>
                      </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="市" prop="city">
                      <el-select v-model="stdRegInfo.city" filterable  placeholder="请选择市" @change="countyChangeForAddress" style="width:200px;">
                          <el-option v-for="(item) in citys" :key="item.code_id" :label="item.code_name" :value="item.code_id"></el-option>
                      </el-select>
                    </el-form-item>
                    
                  </el-col>
                </el-row>

                 <el-row>
                  <el-col :span="12">
                     <el-form-item label="区（县）" prop="county">
                        <el-select v-model="stdRegInfo.county" filterable  placeholder="请选择区（县）" style="width:200px;">
                          <el-option v-for="(item) in countys" :key="item.code_id" :label="item.code_name" :value="item.code_id"></el-option>
                        </el-select>
                      </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item label="通信地址" prop="std_address">
                      <el-input size="mini" clearable v-model="stdRegInfo.std_address" placeholder="如街道、门牌号、小区、乡镇、村等" style="width:200px;"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>


              
                <el-row>
                  <el-col :span="24">
                    <el-form-item label="备注">
                      <el-input size="mini" clearable type="textarea" v-model="stdRegInfo.remark" style="width:550px;"></el-input>
                    </el-form-item>
                  </el-col>
                </el-row>

                <el-row>
                  <el-col :span="24">
                    <div style="text-align: center;margin-bottom: 3px">
                      <el-form-item>
                        <div style="margin-top: 10px;">
                           <el-button type="primary" size="mini" @click="onSubmit">保存修改信息</el-button>

                        </div>
                       
                      </el-form-item>
                    </div>
                  </el-col>
                </el-row>
              </el-form>
            </div>
          </el-col>
        </el-row>

      </el-tab-pane>
    </el-tabs>

    <!-- 考生图片上传  -->
    <el-dialog id="imgUploadDiv"
      title="照片上传"
      :visible.sync="imgUploadDialogVisible"
      width="800px"
      height="600px"
      center>
      <span>
          <el-row>
              <el-col :span="9" class="tip" style="margin:0px !important;height: 490px;font-size: 15px;">
<!--                <font style="font-weight:600">考生注意：</font><font color="red">右边照片为上传后的预览效果，请使用左边照片下方的按钮进行调整。</font><br>-->
                <font style="font-weight:600"></font><font color="red">本照片即为今后的毕业证照片，请注意照片形象和质量要求。</font><br>
 <!--               <font style="font-weight:600">位置要求：</font>高度，头上空1/10，头部占7/10；宽度，肩部占1/5，左右各空1/10<br>-->
                <font style="font-weight:600">背景要求：</font>蓝底<br>
                <font style="font-weight:600">文件格式：</font>jpg格式<br>
                <font style="font-weight:600">像素要求：</font>480*640，300DPI，文件最大不超过1MB<br>
                <font style="font-weight:600">形象要求：</font>免冠证件照，着有领衣服，表情评和，正面直视，衣着整洁。 <br>
                <font style="font-weight:600;">温馨提醒：</font>
                <br>
                <font color="red">请先下载【<a href="https://www.gxeea.cn/app/zp-zk.exe" target="new">照片合规检查工具</a>】，<br>对照片进行处理后，再上传处理后的照片。
                </font> 
                <br>
                 <font color="red">操作说明，请参考【<a href="https://zk1.gxeea.cn:8001/ses-upload/info/广西自考系统照片合规检查操作说明.docx" target="new">广西自考系统照片合规检查操作说明</a>】。
                </font> 
                <br>

              </el-col>
              <el-col :span="9">
                  <center>
                    <vueCropper style="border:solid 1.5px #000000;"
                      ref="cropper"
                      :img="option.img"
                      :outputSize="option.size"
                      :outputType="option.outputType"
                      :info="false"
                      :full="option.full"
                      :canMove="option.canMove"
                      :canMoveBox="option.canMoveBox"
                      :canScale="option.canScale"
                      :fixedBox="option.fixedBox"
                      :original="option.original"
                      :autoCrop="option.autoCrop"
                      :autoCropWidth="option.autoCropWidth"
                      :autoCropHeight="option.autoCropHeight"
                      :centerBox="option.centerBox"
                      :high="option.high"
                      :infoTrue="option.infoTrue"
                      @realTime="realTime"

                      @imgLoad="imgLoad"
                      @cropMoving="cropMoving"
                      :enlarge="option.enlarge"
                    ></vueCropper>
                  

                  <!-- <i class="el-icon-zoom-in"></i>
                  <i class="el-icon-zoom-out"></i>
                  <i class="el-icon-arrow-left"></i>
                  <i class="el-icon-arrow-right"></i> -->
                  <!-- <button @click="changeScale(1)" class="btn">+</button>
                  <button @click="changeScale(-1)" class="btn">-</button>
                  <button @click="rotateLeft" class="btn">rotateLeft</button>
                  <button @click="rotateRight" class="btn">rotateRight</button> -->
<!--                  <div style="margin-top:5px">-->
<!--                    <el-button icon="el-icon-refresh" size="mini" @click="refreshCrop"></el-button>-->
<!--                    <el-button icon="el-icon-download" size="mini" @click="down('blob')"></el-button>-->
<!--                    -->
<!--                    <el-button icon="el-icon-zoom-in" size="mini" @click="changeScale(1)"></el-button>-->
<!--                    <el-button icon="el-icon-zoom-out" size="mini" @click="changeScale(-1)"></el-button>-->
<!--                    <el-button icon="fa fa-rotate-left" size="mini" @click="rotateLeft"></el-button>-->
<!--                    <el-button icon="fa fa-rotate-right" size="mini" @click="rotateRight"></el-button>-->
<!--                  </div>-->
                </center>
              </el-col>
<!--              <el-col :span="9">-->
<!--                <center>-->
<!--                  <div class="show-preview" :style="{'width': previews.w + 'px', 'height': previews.h + 'px',  'overflow': 'hidden',}">-->
<!--                    <div :style="previews.div">-->
<!--                      <img :src="previews.url" :style="previews.img" title="上传后的照片预览效果">-->
<!--                    </div>-->
<!--                  </div>-->
<!--                </center>-->
<!--              </el-col>-->
            </el-row>
      </span>


      <span slot="footer" class="dialog-footer">
        <!-- image/png, image/jpeg, image/gif,  -->
        <input type="file" id="uploads" ref="uploadBtn" :value="imgFile" style="position:absolute; clip:rect(0 0 0 0);" accept="image/jpg" @change="uploadImg($event, 1)">
        <el-button size="mini" @click="chooseFile()">选择本地图片</el-button>
        <el-button size="mini" type="primary" @click="finishUpload('blob')">上传图片</el-button>
        <el-button size="mini" @click="imgUploadDialogVisible = false">关闭</el-button>
      </span>
    </el-dialog>
    <el-dialog title="提示" width="400px" :visible.sync="OkDialogVisible">
      &nbsp;&nbsp;&nbsp;&nbsp;您的准考证号是： <font style="color:red"><span style="font-weight:600;font-size:26px">{{ticket_no_new}}</span></font> 请记录准考证号信息，
      如忘记，可以在个人信息里面查询准考证号!你可以同时通过身份证号或准考证号登录系统.
        <center>
          <el-button type="primary" @click="closeWin()">关闭</el-button>
        </center>
    </el-dialog>

    <el-dialog title="考生信息确认" width="400px" :visible.sync="confirmGenTicketNoDialogVisible">
        <table>
          <tr>
            <td align="center">
              <img v-if="stdRegInfo.photo_url" style="width:230px;height:307px;border:1px;border-color:black;cursor: pointer;" :src="photo_url">
            </td>
           
          </tr>
          <tr>
             <td align="center">
              <table>
                <tr>
                  <td>证件号:</td>
                  <td>{{stdRegInfo.cert_no}}</td>
                </tr>
                <tr>
                  <td>姓名:</td>
                  <td>{{stdRegInfo.std_name}}</td>
                </tr>
                <tr>
                  <td>性别:</td>
                  <td>{{stdRegInfo.std_sex?find({dict_value: stdRegInfo.std_sex},sexArray).dict_text:''}}</td>
                </tr>
              </table>

            </td>
          </tr>
          <tr>
            <td colspan="2">
              <font style="color:red;font-size:16px">
                请确定以上考生信息的准确性，准考证号一旦生成，将无法修改。
              </font>
            </td>
          </tr>
        </table>
        <br>
        <center>
          <el-button type="primary" @click="confirmGenTicketNo(true)">确定生成准考证</el-button>
          <el-button type="primary" @click="closeConfirmWin()">去完善信息</el-button>
        </center>
    </el-dialog>
  </d2-container>
</template>

<script>
import { mapState, mapActions } from "vuex";
import { VueCropper } from "vue-cropper";
import { log, debuglog } from 'util';
import { close } from 'fs';

export default {
  components: { VueCropper },
  computed: {
     stepImg: function() {
      if (!this.std) return "";
      // let uploadedPic = this.std.photo_url ? true : false;
      // let enterMajor =
      //   this.std.major_id + "" || this.std.major_id == undefined ? false : true;

      let exist_ticket_no = this.std.ticket_no ? true : false;
      //std/stdEnrol/existStdEnrolPayed
  
      //图片未上传 专业未报考
      if (!exist_ticket_no) {
        return "./image/step/2.png";
      }
      //图片已经上传 专业未报考
      if (exist_ticket_no) {
        return "./image/step/3.png";
      }
      //图片已经上传 专业已报考
      console.log("exist_ticket_no:"+exist_ticket_no+" isEnroled:"+this.isEnroled);
      
      if (exist_ticket_no && this.isEnroled =="true") {
        return "./image/step/4.png";
      }
    },
    ...mapState({
      std: state => state.enrol.StdReg,
      StdImageArray: state => state.enrol.StdImageArray,
      FrameParam: state => state.enrol.FrameParam,
      dict: state => state.enrol.dict,
      isEnroled:state => state.enrol.isEnroled
    }),
    photo_url() {
      
      if(window.isRemotePhoto =='1'){
      return `${window.photoHttp}${this.std.photo_path}`;
      }else{
      this.randomNum = new Date().getTime();
      return `${window.uploadServerUrl}${this.std.photo_url}?${this.randomNum}`;
      }
      
    },
    exam_area_array(){
      let exam_area_open =  _.filter(this.dict['examAreaOrgArray'],{status:1}); 
      //新注册考生
      if(this.std.is_new_std == 1){
        return exam_area_open; 
      }
      else{
        if(this.std.exam_area_id){
         // exam_area_open.push(_.find(this.dict['examAreaOrgArray'],{id:this.std.exam_area_id}));
          return exam_area_open;
        }else{
          return exam_area_open;
        }
      }

    },
    // activeMajorList() {
    //   let majorArray = this.dict["majorArray"];
    //   return (
    //     this.$options.filters["dataArrayFilter"](majorArray, {
    //       status: 1
    //     })
    //   );
    // },
  },
  data() {
    var checkPhone = (rule, value, callback) => {
      if (!value) {
        return callback(new Error("请输入联系电话"));
      } else {
        const reg = /^1[0|1|2|3|4|5|6|7|8|9][0-9]\d{8}$/;
        // console.log(reg.test(value));
        if (reg.test(value)) {
          callback();
        } else {
          return callback(new Error("请输入正确的手机号"));
        }
      }
    };
    return {
      loading: false,
      randomNum: "", //刷新图片使用
      majorLevelArray:[],
      majorArraySource:[],
      majorArray: [],
      nationArray: [],
      occupationArray: [],
      familyRegArray: [],
      politicalStatusArray: [],
      sexArray: [],
      certTypeArray: [],
      healthyArray: [],
      eduArray: [],
      orgArray: [],
      orgArray_std_source_3: [],

      city_county_data:[],
      county_data:[],

      provinces:[],
      citys:[],
      countys:[],

      // assistOrgArray: [],
      // socialSchoolArray : null,
      // socialMajorList: null,
      ticket_no_new: null,
      OkDialogVisible: false,
      school_name: "",
      firstLoad: true,
      confirmGenTicketNoDialogVisible:false,
      old_std_source:"",
      stdRegInfo: {
        std_name: "",
        std_pass1: "",
        std_pass2: "",
        std_eng_name: "",
        cert_no: "",
        cert_type: "",
        std_sex: "",
        std_source: "",
        political_status: "",
        std_nation: "",
        std_family_reg: "",
        school_id: "",
        std_edu: "",
        std_occupation: "",
        std_healthy: "",
        std_birth: "",
        major_id: "",
        major_code: "",
        major_name: "",
        major_level:"",
        std_mobile: "",
        std_postcode: "",
        std_address: "",
        email: "",
        remark: "",
        bindphone:""
      },
      stdRegInfoRule: {
        cert_no: [
          { required: true, message: "请输入证件号", trigger: "blur" }
        ],
        std_name: [
          { required: true, message: "请输入姓名", trigger: "blur" }
        ],
        std_sex: [
          { required: true, message: "请输入性别", trigger: "blur" }
        ],
        major_level: [
          { required: true, message: "请输入专业层次", trigger: "blur" }
        ],
 
        political_status: [
          { required: true, message: "请输入政治面貌", trigger: "blur" }
        ],
        std_nation: [
          { required: true, message: "请输入民族", trigger: "blur" }
        ],
        std_family_reg: [
          { required: true, message: "请输入籍贯", trigger: "blur" }
        ],
        // school_id: [
        //   { required: true, message: "请输入考生来源", trigger: "blur" }
        // ],
        std_edu: [{ required: true, message: "请输入学历", trigger: "blur" }],
        std_occupation: [
          { required: true, message: "请输入职业", trigger: "blur" }
        ],
        std_healthy: [
          { required: true, message: "请输入健康状况", trigger: "blur" }
        ],
        std_birth: [
          { required: true, message: "请输入出生日期", trigger: "blur" }
        ],
        std_mobile: [
          { required: true, message: "请输入联系电话", trigger: "blur" },
          { validator: checkPhone, trigger: "blur" }
        ],
        std_address: [
          { required: true, message: "请输入通信地址", trigger: "blur" }
        ],
        // std_postcode: [
        //   { required: true, message: "请输入邮编", trigger: "blur" }
        // ],
        // major_id: [{ required: true, message: "请输入专业", trigger: "blur" }],
        std_email: [
          {
            type: "email",
            message: "请输入正确的邮箱地址",
            trigger: ["blur", "change"]
          }
        ],
        major_id:[
          { required: true, message: '请选择专业', trigger: 'blur' },
        ],
        //school_id:[
        //  { required: true, message: '请选择主考院校', trigger: 'blur' },
        //],
  
         std_city: [
          { required: true, message: "请选择地（市）", trigger: "blur" }
        ],
         std_county: [
          { required: true, message: "请选择区（县）", trigger: "blur" }
        ],
      },

      imgUploadDialogVisible: false,
      model: false,
      modelSrc: "",
      crap: false,
      previews: {},
      option: {
        img: "",
        size: 0.4,//压缩质量
        full: false,
        outputType: "jpg",
        canMove: false,
        fixedBox: true,
        original: true,
        canMoveBox: false,
        canScale:false,
        autoCrop: false,
        // 只有自动截图开启 宽度高度才生效
        autoCropWidth: 320,//288 % 0.9 = 288
        autoCropHeight: 426.7,//384 % 0.9 = 384
        centerBox: false,
        high: true,
        cropData: {},
        enlarge: 0.9,//值为1时有bug
        infoTrue: false
      },
      fileName: "", //本机文件地址
      imgFile: "",
      is_photoReview:"",
      img_file:"",
      img_file_name:""
    };
  },
  async mounted() {
    // let loading = this.showLoading();
    this.loading = true;
    const resp = await this.$http.get("/std/stdRegInfo/init.htm");
    let dict = resp.data.map.dict;
    this.majorLevelArray = dict["majorLevelArray"];
    this.majorArraySource = dict["majorArray"];
    this.nationArray = dict["nationArray"];
    this.occupationArray = dict["occupationArray"];
    this.familyRegArray = dict["familyRegArray"];
    this.politicalStatusArray = dict["politicalStatusArray"];
    this.sexArray = dict["sexArray"];
    this.certTypeArray = dict["certTypeArray"];
    this.healthyArray = dict["healthyArray"];
    this.eduArray = dict["eduArray"];

    this.stdRegInfo = resp.data.map.stdRegInfo; 
    if(!this.stdRegInfo.std_source){
      this.stdRegInfo.std_source = "1";
    }

    this.old_std_source = this.stdRegInfo.std_source;

     if(!this.stdRegInfo.exam_area_id){
        this.stdRegInfo.exam_area_id = "1020";
      }
    
    this.city_county_data = resp.data.map.std_citys; 
    this.county_data = resp.data.map.std_countys; 

    this.provinces = resp.data.map.provinces; 
    this.citys = resp.data.map.citys; 
    this.countys = resp.data.map.countys; 

    

    let _this = this;
    this.$nextTick(() => {
      let cloneStd = _.cloneDeep(this.std);
  
      if(typeof (cloneStd.political_status) =='undefined'){
        cloneStd.political_status = "";
      }
      if(typeof (cloneStd.std_birth) =='undefined'){
        cloneStd.std_birth = "";
      }
      if(typeof (cloneStd.std_nation) =='undefined'){
        cloneStd.std_nation = "";
      }
      if(typeof (cloneStd.cert_type) =='undefined'){
        cloneStd.cert_type = "";
      }
      
      if(typeof (cloneStd.std_family_reg) =='undefined'){
        cloneStd.std_family_reg = "";
      }
      if(typeof (cloneStd.std_edu) =='undefined'){
        cloneStd.std_edu = "";
      }
      if(typeof (cloneStd.major_id) =='undefined'){
        cloneStd.major_id = "";
      }
      if(typeof (cloneStd.std_occupation) =='undefined'){
        cloneStd.std_occupation = "";
      }
      if(typeof (cloneStd.std_healthy) =='undefined'){
        cloneStd.std_healthy = "";
      }
     
      // if ((cloneStd.std_nation + "").length == 1) {
      //   cloneStd.std_nation = "0" + cloneStd.std_nation;
      // }
      cloneStd.std_nation = String(cloneStd.std_nation);
      cloneStd.cert_type = String(cloneStd.cert_type);
      
      // if ((cloneStd.std_occupation + "").length == 1) {
      //   cloneStd.std_occupation = "0" + cloneStd.std_occupation;
      // }
      cloneStd.std_occupation = String(cloneStd.std_occupation);
      cloneStd.political_status += "";
      cloneStd.std_healthy += "";
      cloneStd.std_edu += "";
      cloneStd.std_family_reg += "";
      cloneStd.std_source += "";

      

      _this.stdRegInfo = cloneStd;
      // this.hideLoading(loading);
      this.initMajor();
      this.std_sourceChange(parseInt(cloneStd.std_source));

      this.loading = false;
    });
    // setTimeout(() => {
    //   _this.stdRegInfo.std_nation = '09';
    //   // _this.stdRegInfo = _.cloneDeep(this.std);
    // }, 300);
    
    //

    let stdMajor = await this.initMajorLevel();
    if(stdMajor){
      this.majorLevelChange(stdMajor.major_level);
      this.majorChange(stdMajor.id);
    }

    this.firstLoad = false;
  },
  methods: {
    async initMajorLevel(){
      let res = await this.$http.post("/std/stdRegInfo/getStdMajor.htm");
      if(!res.data.entity) return null;
      let stdMajor = res.data.entity;
      this.stdRegInfo.major_level = String(stdMajor.major_level);
      // let majorArray = this.$options.filters["dataArrayFilter"](this.majorArraySource, {
      //   major_level:stdMajor.major_level
      //   });
      // this.majorArray.concat(majorArray); 
      this.majorLevelChange(this.stdRegInfo.major_level);
      this.majorArray.push(stdMajor);
      return  stdMajor;
    },
   //专业层次联动专业列表
   async majorLevelChange(value){
     if(!value){ return;}
     if(!this.firstLoad)
     this.stdRegInfo.major_id = "";
     let loading = this.showLoading();
 
     this.majorArray = this.$options.filters["dataArrayFilter"](this.majorArraySource, {
          major_level:parseInt(value)
        });

     
     this.hideLoading(loading);
   },
   async initMajor(){
      let loading = this.showLoading();
      let _this = this;
      let stdReg = {};

      if(this.stdRegInfo.std_name == "Ghost"){
        let res = await this.$http.post("/std/stdRegInfo/get.htm");
        stdReg = res.data.entity;
      } else{
        stdReg = this.stdRegInfo
      }

      if(!String(stdReg.std_source)){
        this.hideLoading(loading);
        this.alert("请先在个人信息完善基本信息填写后，再填报专业信息!", "信息提示", {
            confirm:function(){
              _this.goUrl("/personalInfo");
            }
          });
        return;
      }

        let res = await this.$http.post("/std/stdRegInfo/getStdMajor.htm");
        let stdMajor = res.data.entity;

        if(stdMajor){
            let stdMajorArray = this.$options.filters["dataArrayFilter"](this.majorArray, {
              id: stdMajor.id
            });

            if(stdMajorArray.length == 0){
              this.majorArray.push(stdMajor);
            }
        }
 
      this.stdRegInfo.major_id = stdReg.major_id || "";
      this.stdRegInfo.exam_area_id = stdReg.exam_area_id || "";
      this.stdRegInfo.school_id = stdReg.school_id || "";
      this.stdRegInfo.exam_area_id = this.stdRegInfo.exam_area_id || "";

      this.hideLoading(loading);
      
    },
    downloadImg(imgsrc, name, callback) {
      var image = new Image();
      // 解决跨域 Canvas 污染问题
      image.setAttribute("crossOrigin", "anonymous");
      image.onload = function() {
        var canvas = document.createElement("canvas");
        canvas.width = image.width;
        canvas.height = image.height;
        var context = canvas.getContext("2d");
        context.drawImage(image, 0, 0, image.width, image.height);
        var url = canvas.toDataURL(); //得到图片的base64编码数据
        // console.log(url);
        if (callback) {
          callback(url);
        }
 
      };
      image.src = imgsrc;
    },
    /**
     * 根据图片 URL 直接获取到 DataURL
     **/
    convertImgToDataURLviaCanvas(url, callback, outputFormat) {
      const img = new Image();
      img.crossOrigin = "Anonymous"; // canvas 不能处理跨域图片，如果要处理，除了服务端要开启跨域外，执行canvas操作前也要开启跨域
      img.onload = function() {
        let canvas = document.createElement("canvas");
        const ctx = canvas.getContext("2d");
        let dataURL = "";
        canvas.height = this.height;
        canvas.width = this.width;
        ctx.drawImage(this, 0, 0);
        // outputFormat
        dataURL = canvas.toDataURL();
        callback(dataURL);
        canvas = null;
      };
      img.src = url;
    },
    convertFileToDataURLviaFileReader(url, callback) {
      const xhr = new XMLHttpRequest();
      xhr.responseType = "blob";
      xhr.onload = function() {
        const reader = new FileReader();
        reader.onloadend = function() {
          callback(reader.result);
        };
        reader.readAsDataURL(xhr.response);
      };
      xhr.open("GET", url);
      xhr.send();
    },
    async showImgUploadModal() {
      //验证是否允许上传图片
      let res = await this.$http.post("/std/validateUploadPhtooUrl.htm",{});
      let existEnrol = res.data.map.existEnrol;
      let existCjold = res.data.map.existCjold;
	  //老考生图片为空 无需验证
	  let res_ = await this.$http.post("/std/stdEnrol/existFacePic.htm");
    
      if (!res_.data.success) {
     // if(!this.stdRegInfo.photo_url){
    	if(existEnrol || existCjold){
          this.alert("因该考生存在历史成绩或已报考的信息,上传个人图片后无法修改,请慎重提交!");
        }

      }else{
        // 20200108应梁老师要求（觉得集体报名后，考生不满意照片随意修改），照片存在后，不允许考生再修改
        // 20200526应梁老师要求 取消20200108的要求限制
        //this.alert("照片已存在，不允许修改。请进入个人中心->考生信息变更，提交申请单!");
        //return;
        
        // 20200526应梁老师要求 存在报考记录也允许修改考生照片
        //if(existEnrol){
        //  this.alert("当前批次内存在报考信息,无法重新上传图片!");
        //  return;
       // }
       
        if(existCjold){
          this.confirm(
              "存在历史成绩,无法重新上传图片!请提交考生信息变更申请,现在处理?",
              "提示",
              {
                confirm: () => {
                  this.goUrl("/stdInfoModify");
                }
              }
            );

          return;
        }

      }

      this.imgUploadDialogVisible = true;

      // this.downloadImg(`${window.uploadServerUrl}${this.std.photo_url}`);
      // this.downloadImg(`http://localhost:8080/image/logo/logo.png`,null,(dataURL)=>{
      this.downloadImg(
        `${window.uploadServerUrl}${this.std.photo_url}`,
        null,
        dataURL => {
          this.option.img = dataURL;
        }
      );
    },

 async showImgUploadModalForCheck() {
   // 考生照片合规校验已经通过（读取考生表照片合规校验是否通过标识），则提醒考生照片合规校验已经通过。
    if(this.stdRegInfo.photo_compliance =='1'){
          this.alert("照片合规检查已审核通过。");
          return;
    }

      //验证是否允许上传图片
      let res = await this.$http.post("/std/validateUploadPhtooUrl.htm",{});
      let existEnrol = res.data.map.existEnrol;
      let existCjold = res.data.map.existCjold;

    // 对于没有成绩的考生，提醒考生进入个人基本信息页面自主上传照片（点击提醒链接进入个人基本信息页面）。
    if(!existCjold){
          this.alert("请点击上传照片按钮，直接更换照片。");
          return;
    }

     // 照片合规检查校验
     let res_ = await this.$http.post("/std/stdRegInfo/validateIdCardForPhotoReview.htm");
     if (!res_.data.success) {
         if(res_.data.errorCode=='-2'){
           this.confirm(
              res_.data.errorMsg+",现在处理?",
              "提示",
              {
                confirm: () => {
                  this.goUrl("/stdInfoModify");
                }
              }
            );
         }else{
          this.alert(res_.data.errorMsg);
          
         }
         return;
     }

      this.imgUploadDialogVisible = true;

      this.downloadImg(
        `${window.uploadServerUrl}${this.std.photo_url}`,
        null,
        dataURL => {
          this.option.img = dataURL;
        }
      );
    },

    async initSchoolName(major_id){
      if(this.firstLoad && this.stdRegInfo.school_id){
        let res = await this.$http.post("/std/cfOrganization/get.htm",
              this.Qs.stringify({
                  id: this.stdRegInfo.school_id
                }));
              
              
              if(res.data.entity){
                this.school_name = res.data.entity.org_code + "-" + res.data.entity.org_name;
                
              }

      }else{
        if(!major_id)return;
              this.orgArray = [];
              this.stdRegInfo.school_id = "";
              let res = await this.$http.post("/std/cfOrganization/querySchoolListByMajorId.htm",
              this.Qs.stringify({
                  major_id: major_id,
                }));
              this.orgArray = res.data.array;
              
              if(this.orgArray.length >=0){
                this.school_name = this.orgArray[0].org_code + "-" + this.orgArray[0].org_name;
                this.stdRegInfo.school_id = this.orgArray[0].id;
              }
      }
      

      
      //跟已选数据无法匹配则清空数据
      
    },

    async std_sourceChange(std_source){
      if(std_source != 3 || this.orgArray_std_source_3.length >0){
        //社会考生 联动主考院校名称
        if(String(this.stdRegInfo.major_id)){
          this.majorChange(this.stdRegInfo.major_id);
        }

        return;
      }
      //请求所有主考院校数据
       let res = await this.$http.post("/std/cfOrganization/listOrderBy.htm",
        this.Qs.stringify({
          org_type: 1,
        }));

        this.orgArray_std_source_3 = res.data.array;

    },

    async majorChange(major_id){
      // console.log("major_id:"+major_id);
      if(!major_id)return;
      if(!this.firstLoad)
        this.school_name = "";
      //社会考生
      
      //if(this.stdRegInfo.std_source != "1")  return;
      
      this.initSchoolName(major_id);
      /*
      if(this.stdRegInfo.std_source == 1){
        let loading =this.showLoading();
        // let major = this.dict['socialSchoolArray'].find((item)=>{ return item.major_id == major_id;});
        res = await this.$http.post("/std/stdRegInfo/getOrgBySocialMajor.htm",
        this.Qs.stringify({
            major_id: major_id,
          }));
        this.stdRegInfo.school_id = "";
        this.socialSchoolArray = res.data.array;
        if(this.socialSchoolArray.length == 1) {
          this.$nextTick(() => {
            this.stdRegInfo.school_id = this.socialSchoolArray[0].id;
          })
        }
        this.hideLoading(loading);
      }
      */

    },
    /*
    async schoolIdChange(schoolId, o1, o2) {
      // let loading = this.showLoading();
      this.loading = true;
      this.assistOrgArray = [];
      //非社会考生查询助学班
      if (!schoolId && schoolId + "" != "99999999") return;
      const resp = await this.$http.post(
        "/std/assistListAll.htm",
        this.Qs.stringify({
          pid: schoolId
        })
      );
      this.assistOrgArray = resp.data.array;
      // this.hideLoading(loading);
      this.loading = false;
    },
    */
    validateForm() {
      this.$refs["stdRegInfo"].validate(valid => {
        if (valid) {
          return true;
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    onSubmit() {
      this.$refs["stdRegInfo"].validate(valid => {
        if (valid) {
         
          if(!this.stdRegInfo.std_source || this.stdRegInfo.std_source=='undefined'){
            this.stdRegInfo.std_source = "1";
          }

           //20220424 蓝剑 考生不允许选择助学考生，主考学校网络助学、专本衔接考生备案审核通过时才更新
          // 切换考生来源时，如果旧考生来源不是助学考生，要切换成助学考生，不允许。
          if(!(this.old_std_source && this.old_std_source == '3') && this.stdRegInfo.std_source =='3'){
              this.alert("考生来源不允许选择助学考生，助学考生由主考院校考生备案后统一修改。");
              return;
          }

          //助学考生 验证主考院校
          if(String(this.stdRegInfo.std_source) == "3" && !String(this.stdRegInfo.school_id)){
            this.alert("助学考生,主考院校为必填项!");
            return;
          }

          //社会考生 主考院校为空
          if(String(this.stdRegInfo.std_source) == "1"){
            this.stdRegInfo.school_id = "";
          }

          //证件类型为身份证 证件号非空 证件件号长度18
          if(this.stdRegInfo.cert_type == 1 && this.stdRegInfo.cert_no && this.stdRegInfo.cert_no.length == 18){
            //性别 
            let cert_no_sex = (parseInt(this.stdRegInfo.cert_no.substring(16,17)) % 2) == 1?"1":"2";
            if(cert_no_sex != this.stdRegInfo.std_sex){
              this.alert("性别与身份证性别不符合,不允许修改!");
              return;
            }
          }

          //clone对象
          var stdRegInfo = JSON.parse(JSON.stringify(this.stdRegInfo));
          stdRegInfo.std_id = this.stdRegInfo.id;
          this.$http
            .post(
              "/std/stdRegInfo/edit.htm",
              this.Qs.stringify(this.stdRegInfo),
              this.$http.headers.FORM
            )
            .then( async res => {
              if (res.data.errorMsg) {
                // this.hideLoading();
                this.alert(res.data.errorMsg, "信息提示");
                return false;
              } else {
                this.updateStdReg(res.data.entity);
                this.initCertNoMustUpdate(0);
                this.stdRegInfo.cert_no_must_update = 0;
                this.editMajor();
                
                let resTicketNo = await this.$http.post("/std/stdRegInfo/handleGenTicketNo.htm",
                  this.Qs.stringify({
                      std_id:this.std.id
                    }));

                if(resTicketNo.data.success){
                  this.confirmGenTicketNoDialogVisible = true;
                }else{
                  this.alert("编辑数据保存成功!");
                }
              }
            });
        } else {
          console.log("error submit!!");
        }
      });
    },

    checkIdentifyCard() {
      let _this = this;
         

           if(!this.stdRegInfo.std_source || this.stdRegInfo.std_source == 'undefined'){
            this.stdRegInfo.std_source = "";
          }

          //clone对象
          var stdRegInfo = JSON.parse(JSON.stringify(this.stdRegInfo));
          stdRegInfo.std_id = this.stdRegInfo.id;
         

          this.$http
            .post(
              "/std/stdRegInfo/identifyCard.htm",
              this.Qs.stringify(this.stdRegInfo),
              this.$http.headers.FORM
            )
            .then( async res => {
              if (res.data.errorMsg) {
                // this.hideLoading();
                this.alert(res.data.errorMsg, "信息提示");
                return false;
              } else {
                _this.updateStdReg(res.data.entity);
                _this.stdRegInfo.is_identfiy=1;
               
                _this.$forceUpdate();
                _this.alert("身份认证成功!");
              }
            });
        
      
    },

    //提示确定生成准考证信息窗口
    async confirmGenTicketNo(isConfirm){
      let resTicketNo = await this.$http.post("/std/stdRegInfo/handleGenTicketNo.htm",
        this.Qs.stringify({
            std_id:this.std.id,
            handleConfirm:isConfirm?isConfirm:false
          }));
        if(resTicketNo.data.success){
          if(isConfirm){
            this.ticket_no_new = resTicketNo.data.entity;
            this.stdRegInfo.ticket_no = resTicketNo.data.entity;
            this.OkDialogVisible = true;
          }else{
            this.confirmGenTicketNoDialogVisible = true;
          }
        }else{
          this.confirmGenTicketNoDialogVisible = false;
        }
    },
    closeConfirmWin(){
      this.imgUploadDialogVisible = false;
      this.OkDialogVisible = false;
      this.confirmGenTicketNoDialogVisible = false;
      this.alert("点击'保存修改信息'按钮可生成准考证号!");
    },

    async editMajor(){
      let res = await this.$http.post("/std/stdRegInfo/editMajor.htm",
        this.Qs.stringify({
            id: this.std.id,
            major_id: this.stdRegInfo.major_id,
            school_id: this.stdRegInfo.school_id,
            exam_area_id: this.stdRegInfo.exam_area_id,
            std_id:this.std.id
          }));
      if(res.data.success){
        //准考证 生成提示
        if(!this.std.ticket_no && res.data.map.stdReg.ticket_no){
          this.ticket_no_new = res.data.map.stdReg.ticket_no;
          this.OkDialogVisible = true;
          this.stdRegInfo.ticket_no = res.data.map.stdReg.ticket_no;

          // this.alert("您的准考证号是:" + res.data.entity.ticket_no+"请记录准考证号信息，如忘记，可以在个人信息里面查询准考证号!你可以同时通过身份证号或准考证号登录系统,")
        }else{
          // this.alert("专业修改信息提交成功","信息提示")
          // this.message("success","专业修改信息提交成功!");
        }
        this.updateStdReg(res.data.map.stdReg);
        this.updateStdMajor(res.data.map.stdMajor);
      }else{
        this.alert(res.data.errorMsg,"错误提示")
      }
    },
    async save() {
      // this.showLoading("保存中...");
      const res = await this.$http.post(
        "/enrol/std/info/link.htm",
        this.Qs.stringify(this.stdRegInfo),
        this.$http.headers.FORM
      );
      if (res.data.errorMsg) {
        // this.hideLoading();
        this.alert(res.data.errorMsg, "信息提示");
        return false;
      }
      // this.updateStdReg(res.data.entity);
      // this.hideLoading();
      this.initData();
      this.alert("考生信息更新成功", "信息提示s");
    },
    // 图片操作--------------------------------
    chooseFile() {
      this.$refs["uploadBtn"].click();
    },
    changeImg() {
      this.option.img = this.lists[~~(Math.random() * this.lists.length)].img;
    },
    startCrop() {
      // start
      this.crap = true;
      this.$refs.cropper.startCrop();
    },
    stopCrop() {
      //  stop
      this.crap = false;
      this.$refs.cropper.stopCrop();
    },
    clearCrop() {
      // clear
      this.$refs.cropper.clearCrop();
    },
    refreshCrop() {
      // clear
      this.$refs.cropper.refresh();
    },
    changeScale(num) {
      num = num || 1;
      this.$refs.cropper.changeScale(num);
    },
    rotateLeft() {
      this.$refs.cropper.rotateLeft();
    },
    rotateRight() {
      this.$refs.cropper.rotateRight();
    },

    //下载图片
    down(type) { 
        console.log('down')
        var aLink = document.createElement('a') 
        aLink.download = 'author-img' 
        if (type === 'blob') { 
          this.$refs.cropper.getCropBlob((data) => { 
            this.downImg = window.URL.createObjectURL(data)
            aLink.href = window.URL.createObjectURL(data) 
            aLink.click() 
          }) 
        } else { 
          this.$refs.cropper.getCropData((data) => { 
            this.downImg = data;
            aLink.href = data; 
            aLink.click() 
          }) 
        } 
    }, 
    finish(type) {
      // 输出
      // var test = window.open('about:blank')
      // test.document.body.innerHTML = '图片生成中..'
      if (type === "blob") {
        this.$refs.cropper.getCropBlob(data => {
          var img = window.URL.createObjectURL(data);
          this.model = true;
          this.modelSrc = img;
        });
      } else {
        this.$refs.cropper.getCropData(data => {
          this.model = true;
          this.modelSrc = data;
        });
      }
    },
    //上传图片到剪切板
    uploadImg(e, num) {
      console.log("uploadImg");
      let _this = this;
      //上传图片
      let file = e.target.files[0];
      _this.fileName = file.name;

      if (!/\.(gif|jpg|jpeg|png|bmp|GIF|JPG|PNG)$/.test(e.target.value)) {
        this.alert("图片类型必须是.gif,jpeg,jpg,png,bmp中的一种", "信息提示");
        return false;
      }

      this.img_file = file;
      this.img_file_name = file.name;

      let reader = new FileReader();
      reader.onload = e => {
        let data;
        if (typeof e.target.result === "object") {
          // 把Array Buffer转化为blob 如果是base64不需要
          data = window.URL.createObjectURL(new Blob([e.target.result]));
        } else {
          data = e.target.result;
        }
        if (num === 1) {
          _this.option.img = data;
        } else if (num === 2) {
          _this.example2.img = data;
        }
      };
      // 转化为base64
      // reader.readAsDataURL(file)
      // 转化为blob
      reader.readAsArrayBuffer(file);
    },
    // 实时预览函数
    realTime(data) {
      var previews = data;
      var h = 0.5;
      var w = 0.2;

      this.previewStyle1 = {
        width: previews.w + "px",
        height: previews.h + "px",
        overflow: "hidden",
        margin: "0",
        zoom: h
      };

      this.previewStyle2 = {
        width: previews.w + "px",
        height: previews.h + "px",
        overflow: "hidden",
        margin: "0",
        zoom: w
      };
      if (data.url) {
        // data.img['position'] = 'absolute';
        data.img["left"] = "490px";
      }
     
      data.img['margin-right']='29px';
      this.previews = data;
    },
    cropMoving(data) {
      this.option.cropData = data;
    },
    imgLoad(msg) {
      console.log(msg);
    },
    //剪裁图片完成上传
    finishUpload(type) {
      console.log("finish");
      let _this = this;
      let formData = new FormData();
      // 输出

      if(!this.$refs.cropper.imgs){
        this.alert("请选择图片再上传");
        return;
      }
      if (type === "blob") {
        this.$refs.cropper.getCropBlob(data => {
          
          let loading = this.showLoading();
          let img = window.URL.createObjectURL(data);
          _this.model = true;
          _this.modelSrc = img;
          formData.append("file", _this.img_file, _this.img_file_name);
          let url = "";
          if(this.is_photoReview=='1'){
            url = "/std/stdRegInfo/uploadImgForPhotoReview.htm";
          }else{
            url = "/std/stdRegInfo/uploadImg.htm";
          }
          
          _this.$http
            .post(url, formData, {
              contentType: false,
              processData: false,
              headers: { "Content-Type": "application/x-www-form-urlencoded" }
            })
            .then( response => {
              _this.hideLoading(loading);
              var res = response.data;
               
              if (res.success) {
                //  if(!_this.std.ticket_no && res.entity.ticket_no){
                //     _this.ticket_no_new = res.entity.ticket_no;
                //     _this.OkDialogVisible = true;
                //     _this.stdRegInfo.ticket_no = res.entity.ticket_no;
                //   }else{
                //     _this.message("success","专业修改信息提交成功!");
                //   }

                this.$nextTick(() => {
                      _this.stdRegInfo.photo_url = res.entity.photo_url;
                      _this.stdRegInfo.status = res.entity.status
                      this.initMajor();

                    });

                _this.updateStdReg(res.entity);
                _this.stdRegInfo.photo_compliance = res.entity.photo_compliance;
                
                setTimeout(() => {
                  _this.randomNum = new Date().getTime();
                }, 500);
        

                _this.$message({
                  type: "success",
                  message: "上传成功"
                });

                if(!_this.std.ticket_no){
                    _this.$http.post("/std/stdRegInfo/handleGenTicketNo.htm",
                          _this.Qs.stringify({
                              std_id:_this.std.id
                            })).then((resTicketNo)=>{
                        if(resTicketNo.data.success){
                          _this.confirmGenTicketNoDialogVisible = true;
                        }else{
                         // _this.message("success","专业修改信息提交成功!");
                        }

                        
                      });
                }
                
               
              }else{
                 
                _this.alert(res.errorMsg, "信息提示");
              }
            });
        });
      } else {
        this.$refs.cropper.getCropData(data => {
          this.model = true;
          this.modelSrc = data;
        });
      }
   
    },

    closeWin(){
      this.OkDialogVisible = false;
      this.confirmGenTicketNoDialogVisible = false;
      this.imgUploadDialogVisible = false;
    },

    

    async cityChangeForAddress(){
      if(!this.stdRegInfo.province) return;
      let loading = this.showLoading();


       //请求地市区县数据
        let res = await this.$http.post("/std/stdRegInfo/queryBzmbGbXzqhdm.htm",
        this.Qs.stringify({
          parent_id: this.stdRegInfo.province
        }));
      
      this.citys = res.data.map.data; 
      this.stdRegInfo.city ="";

      this.hideLoading(loading);

    },

    async countyChangeForAddress(){
     if(!this.stdRegInfo.city) return;
      let loading = this.showLoading();


       //请求地市区县数据
        let res = await this.$http.post("/std/stdRegInfo/queryBzmbGbXzqhdm.htm",
        this.Qs.stringify({
          parent_id: this.stdRegInfo.city
        }));
        
        this.countys =  res.data.map.data; 
        this.stdRegInfo.county ="";

      this.hideLoading(loading);

    },

    async cityChange(areaId){
      if(!areaId) return;
      let loading = this.showLoading();

      this.stdRegInfo.std_county= '';

       //请求地市区县数据
       let res = await this.$http.post("/std/stdRegInfo/queryCityCounty.htm",
        this.Qs.stringify({
          std_city: areaId
        }));

        this.county_data = res.data.array;

      this.hideLoading(loading);

    },

   async countyChange(areaId){
       if(!areaId) return;
       this.stdRegInfo.std_county = String(areaId);
       this.$forceUpdate();
    },
  }
};
</script>

<style lang="scss">
#personalInfo_index_scoped {
  .el-upload {
    border: 1px solid #ddd !important;
    background-color: #ddd;
  }
  .el-card__body {
    padding: 5px 5px !important;
  }
  .el-card__header {
    padding: 11px 20px;
  }
  .avatar-uploader .el-upload {
    border: 1px dashed #d9d9d9;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    /* margin: 10px 10px ; */
    background-color: #d5d5d5 !important;
  }
  .avatar-uploader .el-upload:hover {
    border-color: #409eff;
  }
  .avatar-uploader-icon {
    font-size: 28px;
    color: #0a0a0a;
    width: 178px;
    height: 178px;
    line-height: 178px;
    text-align: center;
  }
  .avatar {
    width: 288px;
    height: 300px;
    display: block;
  }
  .green {
    color: green;
  }
  .red {
    color: red;
  }
  .yellow {
    color: sandybrown;
  }
  .tip {
    padding: 8px 16px;
    background-color: #ecf8ff;
    border-radius: 4px;
    border-left: 5px solid #50bfff;
    margin: 20px 0;
  }
}

#reupload {
  .el-upload {
    width: 100% !important;
  }
}

#imgUploadDiv {
  .vue-cropper {
    height: 640px;
    width: 480px;
  }
 
  .el-dialog {
    width: 500px;
    // height: 395px;
  }
  .show-preview {
    border: 1px solid #6fb8ff;
  }
 
  .el-dialog__body {
    padding-top: 5px !important;
    padding-bottom: 0px !important;
  }
  
}
</style>

