<template>
  <d2-container class="page" id="by_paperApply" style="margin-top:0px;padding-top:0px;">
    <el-tabs value="first">
      <el-tab-pane label="毕业论文答辩申请" name="first">
        <div style="margin-bottom: 8px; border-left: 3px solid; color: rgb(230, 162, 60);">
          <div role="alert" class="el-alert" style="height: 85px !important;background-color:#fdf6ec;" v-if="timeLimit">
            <div class="el-alert__content">
              <span class="el-alert__title">毕业论文答辩在线申请时间：<font style="color:red;">{{timeLimit.paper_start_time}} 到 {{timeLimit.paper_end_time}}</font></span>
               <br>
                <div class="el-alert__title" v-if="ByPaperApplyControl" v-html="ByPaperApplyControl"></div>

              
               

            </div>
          </div>
        </div>
        <!-- <div v-if="canApply"> -->
        <div v-if="canApply"> 
          <el-button type="primary" @click="goApply()">申请毕业论文答辩</el-button>
        </div>
        <el-table
          v-loading="loading"
          :data="applyList"
          style="width: 100%">
         
          <el-table-column
            prop="ticket_no"
            label="准考证"
            width="120">
          </el-table-column>
          <el-table-column
            prop="major_name"
            label="专业名称"
            width="220">
          </el-table-column>
          
          <el-table-column
            prop="major_level"
            label="专业层次"
            width="80"
            >
          </el-table-column>
          <el-table-column
            prop="school_name"
            label="主考院校"
            width="220"
            >
          </el-table-column>
          <el-table-column
            prop="status_text"
            label="状态"
            width="200">
          </el-table-column>
          <el-table-column
            label="操作"
            fixed="right"
            width="140">
              <template slot-scope="scope">
                <el-button @click="showAuditInfo(scope.row)">查看审批意见</el-button>
                <!-- 驳回 -->
                <div v-if="scope.row.is_auth_back == 1">
                  <el-button @click="goEdit(scope.row)">修改申请信息</el-button>
                </div>
              </template>
          </el-table-column>
        </el-table>
        <el-dialog title="审批信息列表" width="800px" :visible.sync="auditDialogVisible">
          <el-table
            v-loading="loading"
            :data="auditInfoArray"
            style="width: 800px">
            <el-table-column
              type="index"
              label="序号"
              width="60">
            </el-table-column>
            <el-table-column
              prop="auth_remark"
              label="审批内容"
              width="350">
            </el-table-column>
            <el-table-column
              prop="auth_type_text"
              label="审批环节"
              width="160">
            </el-table-column>
            <el-table-column
              prop="auth_time"
              label="审批时间"
              width="160"
              >
            </el-table-column>
          </el-table>
        </el-dialog>

        <el-dialog title="毕业论文答辩申请" width="800px" :visible.sync="applyDialogVisible">
          <div v-show="curStep == 1 && stdRegInfo">
            <table style="font-size: 14px;width:100%">
              <tr>
                <td align='right'>我是：</td>
                <td>
                   <el-select size="medium" v-model="stdRegInfo.std_source" filterable placeholder="请选择考生来源" @change="std_sourceChange">
                        <el-option label="社会考生" value="1"></el-option>
                        <el-option label="助学考生" value="3"></el-option>
                    </el-select>
                </td>

              </tr>
              <tr style="height: 40px;">
                <td align='right'>原报考专业：</td>
                <td>{{old_std_major}}</td>
              </tr>
              <tr style="height: 40px;" v-if="newMajorInfo">
                <td align='right'>对应新专业：</td>
                <td>{{newMajorInfo}}</td>
              </tr>
              <tr>
                <td align='right'>选择毕业专业层次：</td>
                <td>
                  <el-select size="medium" v-model="stdRegInfo.major_level" filterable clearable placeholder="请选择专业层次" @change="majorLevelChange" title="只有本科需要申请毕业论文答辩">
                       <el-option  v-for="(item,index) in majorLevelArray" v-if="item.dict_value == '1'" :key="index" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value"></el-option>
                  </el-select>
                </td>
              </tr>
              <tr>
                <td align='right'>选择毕业专业：</td>
                <td>
                   <el-select size="medium" v-model="selected_major_id" filterable clearable placeholder="请选择专业" @change="majorChange">
                     <el-option  v-for="item in byMajorArray" :key="item.id" :label="item.major_full_name" :value="item.id"></el-option>
                  </el-select>
                </td>

              </tr>
             <tr style="height: 40px;">
                      <td align='right'>对应旧专业：</td>
                      <td>
                        <table style="width:200px;font-size: 13px;">
                          <!-- <tr> -->
                            <!-- <td>序号</td> -->
                            <!-- <td>专业代码</td> -->
                            <!-- <td>专业名称</td> -->
                          <!-- </tr> -->
                          <tr  v-for="(item, index) in oldMajorArray" :key="index">
                            <!-- <td>{{index+1}}</td> -->
                            <td>{{item.major_code}} - {{item.major_name}}</td>
                          </tr>
                        </table>
                      </td>
                    </tr>
              
              <tr style="height: 40px;">
                <td align='right'>主考院校：</td>
                <td>
                  <span v-if="stdRegInfo.std_source == '1'" style="font-size: 14px;color: #606266;">{{school_name}}</span>

                  <el-select size="medium" v-if="stdRegInfo.std_source == '3'" clearable v-model="stdRegInfo.school_id" @change="schoolChange" filterable placeholder="请选择主考院校">
                      <el-option v-for="(item,index) in orgArray_std_source_3" :label="item.org_code+' | '+item.org_name" :value="item.id" :key="index"></el-option>
                  </el-select>
                </td>

              </tr>
              
            </table>
            <br>
            <center>
              <el-button type="primary" @click="applyInfoConfirm = true;goApply()">确定</el-button>
            </center>
          </div>

          <div v-show="curStep == 2">
            <el-row>
              <el-col :span="18">
                <table class="el-table" style="width:760px;margin-left:10px;">
                  <tr class="el-table__row">
                    <td colspan="6" style="text-overflow: ellipsis;">毕业论文答辩申请列表> 新增毕业论文答辩信息</td>
                  </tr>
                  <tr class="el-table__row">
                    <td>姓名</td>
                    <td>{{stdRegInfo.std_name}}</td>
                    <td>身份证号</td>
                    <td>{{stdRegInfo.cert_no}}</td>
                    <td rowspan="5">
                      <center>
                      <!-- 无毕业申请图片显示 考生图片-->
                      <img v-if="stdRegInfo.photo_url && !by_photo_url_p && (!selected_apply || !selected_apply.by_photo)" style="width:140px;height:170px;border:1px;border-color:black;" :src="photo_url">

                      <!-- 有毕业申请图片显示毕业图片-->
                      <!-- 
                      <img v-if="(selected_apply && selected_apply.by_photo) || by_photo_url_p" style="width:140px;height:170px;border:1px;border-color:black;" :src="by_photo_url"><br>
                      <el-button type="primary" @click="toUploadByImg()" title="考生照片不符合毕业要求时，请上传毕业照片。">上传照片</el-button>
                      -->
                      </center>
                    </td>
                    
                  </tr>
                  <tr class="el-table__row">
                    <td>民族</td>
                    <td>{{stdRegInfo.std_nation_text}}</td>
                    <td>政治面貌</td>
                    <td>{{stdRegInfo.political_status_text}}</td>
                  </tr>
                  <tr class="el-table__row">
                    <td>户籍类型</td>
                    <td>{{stdRegInfo.std_family_reg_text}}</td>
                    <td>学历</td>
                    <td>
                        {{stdRegInfo.std_edu_text}}
                    </td>
                  </tr>
                  <tr class="el-table__row">
                    <td>职业</td>
                    <td>{{stdRegInfo.std_occupation_text}}</td>
                    <td>联系电话</td>
                    <td>{{stdRegInfo.std_mobile}}</td>
                  </tr>
                  <tr class="el-table__row">
                    <td>邮政编码</td>
                    <td>{{stdRegInfo.std_postcode}}</td>
                    <td>电子邮箱</td>
                    <td>{{stdRegInfo.std_email}}</td>
                  </tr>
                </table>


                <br>

            <table style="font-size: 14px;width:100%">
              <tr>
                <td align='right' style="width: 80px;">专业层次：</td>
                <td>
                  <el-select size="medium" v-model="stdRegInfo.major_level" disabled="disabled" filterable clearable placeholder="请选择专业层次" @change="majorLevelChange" >
                       <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>
                </td>
              </tr>
              <tr>
                <td align='right'>毕业专业：</td>
                <td>
                   <el-select size="medium" v-model="selected_major_id" disabled="disabled" filterable clearable placeholder="请选择专业" @change="majorChange">
                     <el-option  v-for="item in byMajorArray" :key="item.id" :label="item.major_code+' | '+item.major_name" :value="item.id"></el-option>
                  </el-select>
                </td>

              </tr>
              
              <tr style="height: 40px;">
                <td align='right'>主考院校：</td>
                <td>
                  <span v-if="stdRegInfo.std_source == '1'" style="font-size: 14px;color: #606266;">{{school_name}}</span>

                  <el-select size="medium" v-if="stdRegInfo.std_source == '3'" disabled="disabled" clearable v-model="stdRegInfo.school_id" filterable placeholder="请选择主考院校">
                      <el-option v-for="(item,index) in orgArray_std_source_3" :label="item.org_code+' | '+item.org_name" :value="item.id" :key="index"></el-option>
                  </el-select>

                </td>

              </tr>
            </table>
              </el-col>
              <el-col :span="6">
                
              </el-col>
            </el-row>
            <el-row>
              <el-col :span="24">
                <table style="width:100%">
                    <tr>
                        <td colspan="4" align="center">
                           <h4>考生填写栏 </h4>
                        </td>
                      </tr>
                     <tr>
                       <!-- <td>
                         考生填写栏
                       </td> -->
                       <td>
                         <el-form ref="stdRegInfo" :model="stdRegInfo" :rules="stdRegInfoRule" label-width="80px" size="mini">
                           <el-row>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="姓名" prop="std_name" label-width="140px">
                                <el-input size="mini" disabled clearable v-model="stdRegInfo.std_name" style="width:180px;"></el-input>
                                <!-- {{stdRegInfo.std_name}} -->
                              </el-form-item>
                            </el-col>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="性别" prop="std_sex" label-width="140px">
                                <el-select v-model="stdRegInfo.std_sex" filterable placeholder="请选择性别" style="width:180px;">
                                  <el-option v-for="(item,index) in sexArray" :key="'sexArray_'+index" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value"></el-option>
                                </el-select>
                              </el-form-item>
                            </el-col>
                           </el-row>
    
                           <el-row>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="出生年月" required prop="std_birth" label-width="140px">
                                <el-date-picker size="mini" value-format="yyyy-MM-dd" type="date" v-model="stdRegInfo.std_birth" placeholder="选择出生年月" style="width:180px;"></el-date-picker>
                              </el-form-item>
                            </el-col>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="民族" prop="std_nation" label-width="140px">
                                <el-select size="mini" clearable v-model="stdRegInfo.std_nation" filterable placeholder="请选择民族" style="width:180px;">
                                  <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-row>

                           <el-row>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label="联系电话" prop="std_mobile" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_mobile"  maxlength="11" style="width:180px;"></el-input>
                              </el-form-item>
                            </el-col>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label="邮政编码" prop="std_postcode" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_postcode"  maxlength="6" style="width:180px;"></el-input>
                              </el-form-item>
                            </el-col>
                          </el-row>

                          <el-row>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label=" QQ号码" prop="qq" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.qq"  maxlength="16" style="width:180px;"></el-input>
                              </el-form-item>
                            </el-col>
                            <el-col :span="12" style="height:37px;">
                            
                            </el-col>
                          </el-row>
                          <!--
                           <el-row>
                            
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="专（本）科何专业及发证单位" prop="pre_edu" label-width="210px">
                                <el-input size="mini" clearable v-model="stdRegInfo.pre_edu"  maxlength="30" style="width:290px;"></el-input>
                              </el-form-item>
                            </el-col>
                          </el-row>
-->
                           <el-row>
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="工作单位" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_work_unit" style="width:360px;" title="如有工作单位，请填写工作单位。" maxlength="30"></el-input>
                              </el-form-item>
                            </el-col>
                          </el-row>

                           <el-row>
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="通讯地址" prop="std_address" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_address" style="width:360px;" maxlength="75"></el-input>
                              </el-form-item>
                            </el-col>
                           
                          </el-row>

                          <el-row>
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="申报论题" prop="paper_title" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.paper_title" maxlength="50" style="width:360px;"></el-input>
                              </el-form-item>
                            </el-col>
                           
                          </el-row>

                          <el-row>
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="备注" prop="remark" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.remark" maxlength="75" style="width:360px;"></el-input>
                              </el-form-item>
                            </el-col>
                           
                          </el-row>

                          
                          
                         
                      
                          
                         </el-form>
                         
                       </td>
                     </tr>
                </table>
              </el-col>
            </el-row>
            

            
              
            
              <center>
                <br>
                <el-button type="primary" @click="submit()">提交申请</el-button>
                <el-button type="primary" @click="colseWin()">关闭</el-button>
              </center>
            
          </div>
          <div v-show="curStep == 3">
            <!-- v-if="this.isAllowGraduate" -->
            <div>
              <center>
                 <div v-if="msgArray.length >0" style="font-size: 16px;margin-buttom:5px;color:red">
                    <div v-for="(msg,index) in msgArray" :key="index">
                      <table style="margin-left:20px">
                        <tr>
                          <td>{{index+1}}.</td>
                          <td>{{msg}}</td>
                        </tr>
                      </table>
                    </div>
                   <br>
                   
                </div>

                <div>
                  <!-- {{checkMsg}}请完善【考生填写栏】信息 -->
                 <span style="font-size: 35px;color: black;margin-buttom:5px">毕&nbsp;&nbsp;业&nbsp;&nbsp;生&nbsp;&nbsp;登&nbsp;&nbsp;记&nbsp;&nbsp;表 </span> 
                   <br>
                   <table width="100%">
                      <tr>
                        <td colspan="4" align="center">
                          <font style="font-size:20px" v-if="selected_major">
                          (大学<u>{{selected_major.major_level==0?'专':'本'}}</u>科)
                          </font>
                          
                        </td>
                      </tr>
                     <tr>
                       <!-- <td style="width:20px">
                         考生基础信息
                       </td> -->
                       <td>
                         <table width="100%" height="100%">
                            <tr>
                              <td colspan="4" align="center">
                                <h4>考生基础信息</h4>
                              </td>
                            </tr>
                            <tr v-if="countryCityMap">
                              <td align="right">市&nbsp;地：</td>
                              <td align="left">
                                <!-- {{countryCityMap.city_name}} -->
                              </td>
                              <td align="right">县&nbsp;(市)：</td>
                              <td align="left">
                                <!-- {{countryCityMap.country_name}} -->
                              </td>

                            </tr>
                            <tr>
                              <td align="right">主考院校：</td>
                              <td align="left">
                                {{school_name}}
                              </td>
                              <td align="right">专业：</td>
                              <td align="left" v-if="selected_major">
                                {{selected_major.major_code}} - {{selected_major.major_name}}
                              </td>

                            </tr>
                            <tr>
                              <td align="right">毕业证号：</td>
                              <td align="left">
                                {{diaplmaNo}}
                              </td>
                              <td align="right">身份证号：</td>
                              <td align="left">
                                {{stdRegInfo.cert_no}}
                              </td>
                            </tr>
                          </table>
                       </td>
                     </tr>

                     <tr>
                       <td colspan="5">
                        <el-table
                          v-loading="loading"
                          :data="courseScoreList"
                          style="width: 760px">
                          <el-table-column
                          label="序号"
                            type="index"
                            width="50">
                          </el-table-column>
                          <el-table-column
                            prop="course_code"
                            label="课程代码"
                            width="80">
                          </el-table-column>
                          <el-table-column
                            prop="course_name"
                            label="课程名称"
                            width="200">
                          </el-table-column>
                          <!-- <el-table-column
                            prop="score_source"
                            label="成绩来源"
                            width="80"
                            >
                          </el-table-column> -->
                          <el-table-column
                            prop="score_source"
                            label="成绩来源"
                            width="100"
                            >
                            <template slot-scope="scope">
                              <span v-if="scope.row.final_score == 0">
                                  实践课
                                </span>
                                <span v-else-if="scope.row.final_score == 3">
                                  沟通课
                                </span>
                                <span  v-else>
                                  <span v-if="scope.row.score_source == 0">
                                      <!-- 校考导入 -->
                                      校考
                                  </span>
                                  <span v-if="scope.row.score_source == 1">
                                      <!-- 统考导入 -->
                                      统考
                                  </span>
                                  <span v-if="scope.row.score_source == 2">
                                      顶替
                                  </span>
                                  <span v-if="scope.row.score_source == 3">
                                      被顶替
                                  </span>
                                  <span v-if="scope.row.score_source == 4">
                                      手工增加
                                  </span>
                                  <span v-if="scope.row.score_source == 5">
                                      免考
                                  </span>
                                  <span v-if="scope.row.score_source == 6">
                                      外省转入
                                  </span>
                                  <span v-if="scope.row.score_source == 7">
                                      <!-- 网考合成 -->
                                      合成成绩
                                  </span>
                                  <span v-if="scope.row.score_source == 8">
                                      <!-- 衔接合成 -->
                                      合成成绩
                                  </span>
                                  <span v-if="scope.row.score_source == 9">
                                      <!-- 百分百合成 -->
                                      合成成绩
                                  </span>
                                  <span v-if="scope.row.score_source == 10">
                                      <!-- 手工评卷 -->
                                      统考
                                  </span>
                                  <span v-if="scope.row.score_source == 11">
                                      毕业论文
                                  </span>
                                  <span v-if="scope.row.score_source == 12">
                                      关联准考证
                                  </span>
                                  <span v-if="scope.row.score_source == 13">
                                      手工转入
                                  </span>
                                  <span v-if="scope.row.score_source == 14">
                                      违规
                                  </span>
                                  <span v-if="scope.row.score_source == 15">
                                      作弊
                                  </span>
                                </span>
                            
                            </template>
                          </el-table-column>
                          <!-- <el-table-column
                            prop="origin_score"
                            label="原始成绩"
                            width="100"
                            >
                          </el-table-column> -->
                          <el-table-column
                            prop="final_score"
                            label="最终成绩(合成后)"
                            width="150">
                              <template slot-scope="scope">
                                <span v-if="scope.row.final_score == 998 || scope.row.final_score == 999 || scope.row.final_score == 200 ">
                                  免考
                                </span>
                                <span v-else-if="scope.row.final_score == 887 || scope.row.final_score == 888">
                                  课程顶替
                                </span>
                                <span v-else-if="scope.row.final_score == 201">
                                  及格
                                </span>
                                <span v-else-if="scope.row.final_score == 202">
                                  良好
                                </span>
                                <span v-else-if="scope.row.final_score == 203">
                                  中等
                                </span>
                                <span v-else-if="scope.row.final_score == 204">
                                  优秀
                                </span>
                                <span v-else-if="scope.row.final_score == -1">
                                  舞弊
                                </span>
                                <span v-else-if="scope.row.final_score == -3">
                                  违纪
                                </span>
                                <span v-else-if="scope.row.final_score == -9">
                                  缺考
                                </span>

                                <span v-else-if="scope.row.final_score != 887 && scope.row.final_score != 888 && scope.row.final_score != 998 && scope.row.final_score != 999">
                                  {{scope.row.final_score}}
                                </span>
                              </template>
                          </el-table-column>
                          <el-table-column
                            prop="is_pass"
                            label="是否合格"
                            width="100">
                        
                          </el-table-column>
                        </el-table>
                       </td>
                     </tr>
                      <tr>
                        <td colspan="4" align="center">
                           <h4>考生填写栏 </h4>
                        </td>
                      </tr>
                     <tr>
                       <!-- <td>
                         考生填写栏
                       </td> -->
                       <td>
                         <el-form ref="stdRegInfo" :model="stdRegInfo" :rules="stdRegInfoRule" label-width="80px" size="mini">
                           <el-row>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="姓名" prop="std_name" label-width="140px">
                                <el-input size="mini" disabled clearable v-model="stdRegInfo.std_name" style="width:180px;"></el-input>
                                <!-- {{stdRegInfo.std_name}} -->
                              </el-form-item>
                            </el-col>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="性别" prop="std_sex" label-width="140px">
                                <el-select v-model="stdRegInfo.std_sex" filterable placeholder="请选择性别" style="width:180px;">
                                  <el-option v-for="(item,index) in sexArray" :key="'sexArray_'+index" :label="item.dict_value+' | '+item.dict_text" :value="item.dict_value"></el-option>
                                </el-select>
                              </el-form-item>
                            </el-col>
                           </el-row>
                            <el-row>
                              <el-col :span="24">
                                <font style="color:red;margin-left:10px;margin-bottom:0px;">
                                注意：以下省（市、自治区），市（县）请填写籍贯信息
                                </font>
                              </el-col>
                            </el-row>
                          

                           <el-row>
                             <el-col :span="12" style="height:37px;">
                              <el-form-item label="出生年月" required prop="std_birth" label-width="140px">
                                <el-date-picker size="mini" value-format="yyyy-MM-dd" type="date" v-model="stdRegInfo.std_birth" placeholder="选择出生年月" style="width:180px;"></el-date-picker>
                              </el-form-item>
                            </el-col>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label="考前学历" prop="std_edu" label-width="140px">
                                <el-select size="mini" clearable v-model="stdRegInfo.std_edu" filterable placeholder="请选择学历" style="width:180px;">
                                  <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-row>
                           <el-row>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label="民族" prop="std_nation" label-width="140px">
                                <el-select size="mini" clearable v-model="stdRegInfo.std_nation" filterable placeholder="请选择民族" style="width:180px;">
                                  <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" style="height:37px;">
                              <el-form-item label="政治面貌" prop="political_status" label-width="140px">
                                <el-select size="mini" clearable v-model="stdRegInfo.political_status" filterable placeholder="请选择政治面貌" style="width:180px;">
                                  <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-row>
                          <el-row>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label="联系电话" prop="std_mobile" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_mobile"  maxlength="11" style="width:180px;"></el-input>
                              </el-form-item>
                            </el-col>
                            <el-col :span="12" style="height:37px;">
                              <el-form-item label="邮政编码" prop="std_postcode" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_postcode"  maxlength="6" style="width:180px;"></el-input>
                              </el-form-item>
                            </el-col>
                          </el-row>
                          <el-row>
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="工作单位" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_work_unit" style="width:360px;" title="如有工作单位，请填写工作单位。"></el-input>
                              </el-form-item>
                            </el-col>
                          </el-row>
                           <el-row>
                            <el-col :span="24" style="height:37px;">
                              <el-form-item label="家庭地址" prop="std_address" label-width="140px">
                                <el-input size="mini" clearable v-model="stdRegInfo.std_address" style="width:360px;"></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"></el-input>
                              </el-form-item>
                            </el-col> -->
                          </el-row>
                      
                          <el-row>
                            <el-col :span="24">
                              <el-form-item label="学历证明">
                                <div style="width:500px">
                                    <el-upload
                                      :http-request = "customUpload"
                                      action=""
                                      class="upload-demo"
                                      ref="upload"
                                      :on-preview="handlePreview"
                                      :on-remove="handleRemove"
                                      :before-upload="beforeUpload"
                                      :before-remove="beforeRemove"
                                      
                                      :limit="1"
                                      :on-exceed="handleExceed"
                                      :on-change="handleChange"
                                      :auto-upload="true"
                                      :file-list="fileList"
                                      >
                                      <el-button size="small" type="primary">点击上传</el-button>
                                      <div slot="tip" class="el-upload__tip" style="color:red">注意：申请本科毕业，学信网学历验证不通过，请上传学历证明文件（如专科毕业证等）</div>
                                      <div slot="tip" class="el-upload__tip" style="color:red">只允许上传一个文件（图片或者压缩包），多个文件请压缩成压缩包再上传</div>

                                    </el-upload>

                                  </div>
                              </el-form-item>
                            </el-col>
                          </el-row>
                         </el-form>
                         
                       </td>
                     </tr>
                   </table>

                   <table>
                    <thead>
                       <tr>
                        <td colspan="5" align="center">
                           <h4>个人简历(考生本人填写) </h4>
                        </td>
                      </tr>
                      <tr>
                        <th valign="bottom" style="width:35px">序号</th>
                        <th valign="bottom" style="width:145px">起止年月</th>
                        <th valign="bottom" style="width:350px">在何地,何单位学习和工作<br><font style="color:red">简历信息从高中阶段开始</font></th>
                        <th valign="bottom" style="width:170px">任何职务</th>
                        <!-- <th><el-button type="primary" @click="addRow(i)">添加</el-button></th> -->
                        
                        <th> <li class="el-icon-plus" style="color:green;cursor:pointer;" title="点击新增一行"  @click="addRow(i)"></li></th>
                      </tr>
                    </thead>
                    <tr v-for="(i,index) in stdResumeList" :key="i.id" v-if="i != null">
                      <td valign="bottom" align="center">{{index+1}}</td>
                      <td valign="bottom" align="center">
                        <el-date-picker size="mini" value-format="yyyy-MM-dd" type="date" v-model="i.start_date" placeholder="选择开始日期" style="width:135px;padding:0px;margin:0px;"></el-date-picker>
                        <br>
                        <el-date-picker size="mini" value-format="yyyy-MM-dd" type="date" v-model="i.end_date" placeholder="选择结束日期" style="width:135px;padding:0px;margin:0px;"></el-date-picker>
                      </td>
                      <td valign="bottom">
                        <el-input size="medium" v-model="i.work_exp" placeholder="请输入工作经验。简历起止年月不允许断档。"></el-input>
                      </td>
                      <td valign="bottom">
                        <el-input size="medium" v-model="i.position" placeholder="请输入职务"></el-input>
                      </td>
                      <td valign="bottom" align="center">
                        <!-- <el-button type="primary" @click="delRow(i)">删除</el-button> -->
                       
                          <li class="el-icon-close" style="color:red;cursor:pointer;" title="点击删除该行" @click="delRow(index)"></li>
                        
                      </td>
                    
                    </tr>
                  </table>

                   
                    <el-button type="primary" @click="submit()">核实并提交申请</el-button>
                    <el-button type="primary" @click="colseWin()">关闭</el-button>
                </div>
              </center>
            </div>

            <!-- <div v-if="!this.isAllowGraduate">
              <center>
                <div style="font-size: 25px;color: green;margin-buttom:5px;color:red">
                    <div v-for="(msg,index) in msgArray" :key="index">
                      <table style="margin-left:20px">
                        <tr>
                          <td>{{index+1}}.</td>
                          <td>{{msg}}</td>
                        </tr>
                      </table>
                    </div>
                   <br>
                    <el-button disabled="" type="primary" @click="submit()">核实并提交申请</el-button>
                    <el-button type="primary" @click="colseWin()">关闭</el-button>
                </div>
              </center>
            </div> -->
             

          </div>

        </el-dialog>

        <!-- 考生图片上传  -->
        <el-dialog id="imgUploadDiv"
          title="图片上传"
          :visible.sync="imgUploadDialogVisible"
          width="1200px"
          height="600px"
          center>
          <span>
              <el-row>
                  <el-col :span="6" 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>高度，头上空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>288*384，300DPI，文件最大不超过1MB<br>
                    <font style="font-weight:600">形象要求：</font>免冠证件照，着有领衣服，表情评和，正面直视，衣着整洁。 <br>
                    <font style="font-weight:600;">上传限制：</font><font color="red">照片上传后，不允许再修改，请慎重点击上传图片。</font> <br>
                  </el-col>
                  <el-col :span="9">
                      <center>
                        <vueCropper
                          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">
                        </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-tab-pane>
    </el-tabs>
  </d2-container>
</template>

<script>
import { mapState, mapActions } from "vuex";
import { json } from "body-parser";
import { isIPv4 } from "net";
import { log } from 'util';
import { VueCropper } from "vue-cropper";


export default {
  components: { VueCropper },
  computed: {
    ...mapState({
      stdReg: state => state.enrol.StdReg,
      StdImageArray: state => state.enrol.StdImageArray,
      FrameParam: state => state.enrol.FrameParam
    }),
    photo_url() {
      if(window.isRemotePhoto =='1'){
      return `${window.photoHttp}${this.stdReg.photo_path}`;
      }else{
         this.randomNum = new Date().getTime();
          return `${window.uploadServerUrl}${this.stdReg.photo_url}?${
            this.randomNum
          }`;
          }
    },
    by_photo_url() {
      this.randomNum = new Date().getTime();
      if(this.selected_apply && this.selected_apply.by_photo){
        return `${window.uploadServerUrl}${this.selected_apply.by_photo}?${
          this.randomNum
        }`;

      }else if(this.by_photo_url_p){
        return `${window.uploadServerUrl}${this.by_photo_url_p}?${
          this.randomNum
        }`;
      }
    },
  },

  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,
      majorList: null,
      applyDialogVisible: false,
      auditDialogVisible: false,
      auditInfoArray: null,
      curStep: 1,

      selected_major_id: null,
      selected_major: null,
      selected_apply: null,
      canApply: false,
      timeLimit: null,
      applyList: null,
      ByPaperApplyControl: null,

      // isAllowGraduate: false,
      inBlackList: false,
      blackList: null,
      isNeedPreEduApply: true,
      courseScoreList: null,
      paperFailed: false,
      diaplmaNo: null, //毕业证号
      msgArray: [],
      checkMsg: null,

      ticketList: null,
      std: null,
      courseScoreList: null,

      //数据字典 start
      majorArray: null,
      nationArray: null,
      occupationArray: null,
      familyRegArray: null,
      politicalStatusArray: null,
      sexArray: null,
      healthyArray: null,
      eduArray: null,
      //数据字典 end
      stdResumeList: [],
      stdRegInfo: {
        std_name: "",
        std_pass1: "",
        std_pass2: "",
        std_eng_name: "",
        cert_no: "",
        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: "",
        std_mobile: "",
        std_postcode: "",
        std_address: "",
        email: "",
        remark: "",
        std_work_unit: "",
        major_level:"",
        navtiv_prov:"",
        navtiv_city:"",
        paper_title:"",
        qq:"",

      },
      // remark: "",
      stdRegInfoRule: {
        std_source: [
          { 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: "请输入籍贯", trzaigger: "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" }
        ],
      
        
       //  pre_edu: [
      //    { 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"]
          }
        ],
        std_work_unit: [
          { required: true, message: "请输入工作单位", trigger: "blur" }
        ],
        native_prov: [
          { required: true, message: "请输入省", trigger: "blur" }
        ],
        native_city: [
          { required: true, message: "请输入市", trigger: "blur" }
        ],

        
      },

      orgArray_std_source_3:[],
      school_name:"",
      majorLevelArray:[],
      majorArraySource:[],
      byMajorArray:[],
      byMajorArraySource:[],
      majorLevelArray:[],
      applyInfoConfirm:false,
      oldMajorInfo:"",
      old_std_major:"",
      newMajorInfo:"",
      oldMajorArray:[],
      countryCityMap:null,

      city_data:[],
      prov:[],
      city:[],
      showByImgDialog:false,
      orderOrgArray_std_source_1:[],
      by_photo_url_p:"",
      by_file_item:"",//前端临时使用
      by_file:"",//后台参数
      imgUploadDialogVisible: false,
      crap: false,
      previews: {},
      option: {
        img: "",
        size: 0.9,//压缩质量
        full: false,
        outputType: "jpg",
        canMove: true,
        fixedBox: true,
        original: true,
        canMoveBox: true,
        canScale:true,
        autoCrop: true,
        // 只有自动截图开启 宽度高度才生效
        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: "",
      fileList: [],
    };
  },

  async mounted() {
    this.loading = true;
    this.init();
    this.loading = false;

    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.byMajorArraySource = dict["byMajorArray"];
    this.initStdApplyInfo();
  },
  methods: {
    //初始化列表查询
    async init() {
      
      this.applyInfoConfirm = false;
      let res = await this.$http.post(
        "/by/byPaperApply/listAll.htm",
        {},
        this.$http.headers.FORM
      );
      this.canApply = res.data.map.canApply;
      this.timeLimit = res.data.map.byTimeConfig;
      this.majorList = res.data.map.majorList;
      this.applyList = res.data.map.applyList;
      this.ByPaperApplyControl = res.data.map.ByPaperApplyControl;

      await this.initorderOrgArray_std_source_1();
    },
    async initStdApplyInfo(){
      //初始化考生类型
      this.stdRegInfo.std_source = String(this.stdReg.std_source);
      this.std_sourceChange(this.stdRegInfo.std_source);
      //初始化专业等级
      this.initMajorLevel();


      //初始化专业
      // this.selected_major_id = this.stdReg.major_id;
      // console.log(this.selected_major_id);
      // this.majorChange(this.selected_major_id);

      //主考院校
      // this.stdRegInfo.school_id = this.stdReg.school_id;
    },
    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);
      this.old_std_major = stdMajor.major_code + '-' + stdMajor.major_name;
      // let majorArray = this.$options.filters["dataArrayFilter"](this.majorArraySource, {
      //   major_level:stdMajor.major_level
      //   });
      // 
      // this.majorArray.concat(majorArray); 
      await this.majorLevelChange(this.stdRegInfo.major_level);
      // this.byMajorArray.push(stdMajor);
      await this.initNewMajor(stdMajor.id);
      return  stdMajor;
    },
    async showAuditInfo(item) {
      let { data } = await this.$http.post(
        "/by/byPaperApplyAudit/listByApply.htm",
        this.Qs.stringify({
          apply_id: item.id
        }),
        this.$http.headers.FORM
      );
      this.auditInfoArray = data.array;
      this.auditDialogVisible = true;
    },

    //跳转申请页面
    async goApply(apply) {
      if(!String(this.selected_major_id)){
        this.alert("请选择毕业专业!");
        return;
      }

      if(null != this.stdRegInfo && null != this.stdRegInfo.major_level && "1" != this.stdRegInfo.major_level){
         this.stdRegInfo.major_level = '1';
         this.majorLevelChange(this.stdRegInfo.major_level);
        // this.stdRegInfo.major_id = '';
       //  this.stdMajor.major_level = '1';
       //  this.stdMajor.major_id= '';
        //this.alert("专科毕业不需要申请毕业论文答辩!个人信息修改专业层次为本科后，可以申请。");
        //return;
      }
      
      if (this.selected_apply) {
        // this.selected_apply = apply;
        // this.remark = this.selected_apply.remark;
        
        //处理附件的初始化
        //if(this.selected_apply.by_file){
        //  this.fileList = [{name:`${this.selected_apply.by_file}`,url:`${window.uploadServerUrl}${this.selected_apply.by_file}`}]
        //  this.by_file = this.selected_apply.by_file ;
        //}
        
      

      } else {
        this.selected_apply = null;
        // this.remark = "";
      }
      if (!this.applyInfoConfirm) {
        this.curStep = 1;
        this.$nextTick(() => {
          if (this.majorList.length > 0 && !this.selected_major_id) {
            this.selected_major_id = this.majorList[0].major_id;
          }
        });
        // return;
      }
      for (const key in this.item) {
        if (this.item.hasOwnProperty(key)) {
          this.item[key] = "";
        }
      }

      // this.loading = true;
      // let loading = this.showLoading();

      const resp = await this.$http.get("/std/stdRegInfo/init.htm");
      let dict = resp.data.map.dict;
      this.majorArray = dict["majorArray"];
      this.nationArray = dict["nationArray"];
      this.occupationArray = dict["occupationArray"];
      this.familyRegArray = dict["familyRegArray"];
      this.politicalStatusArray = dict["politicalStatusArray"];
      this.sexArray = dict["sexArray"];
      this.healthyArray = dict["healthyArray"];
      this.eduArray = dict["eduArray"];

      if (!this.applyInfoConfirm) {
        this.applyDialogVisible = true;
        return;
      }

      if(!String(this.stdRegInfo.school_id)){
        this.alert("主考院校不能为空");
        return ;
      }

      let { data } = await this.$http.post(
        "/by/byPaperApply/getcheckinfo.htm",
        this.Qs.stringify({
          stdId: this.stdReg.id,
          majorId: this.selected_major_id,
          schoolId: this.stdRegInfo.school_id
        }),
        this.$http.headers.FORM
      );
      if(!data.success){
        this.alert(data.errorMsg);
        // this.hideLoading(loading);
       // return;
      }
      this.selected_major = data.map.major;
      let std_source = this.stdRegInfo.std_source;
      let major_level = this.stdRegInfo.major_level;
      let school_id = this.stdRegInfo.school_id;
      
      this.stdRegInfo = this.initStdRegInfo(data.map.stdRegInfo); //data.map.stdRegInfo ;//
      this.stdRegInfo.std_source = std_source;
      this.stdRegInfo.major_level = major_level;
      this.stdRegInfo.school_id = school_id;

      if(this.selected_apply){
        if(this.selected_apply.std_birth){
          this.stdRegInfo.std_birth = this.selected_apply.std_birth;
        }

        if(this.selected_apply.telephone){
          this.stdRegInfo.std_mobile = this.selected_apply.telephone;
        }

        if(this.selected_apply.post_code){
          this.stdRegInfo.std_postcode = this.selected_apply.post_code;
        }

        if(this.selected_apply.qq){
          this.stdRegInfo.qq = this.selected_apply.qq;
        }

        //if(this.selected_apply.pre_edu){
        //  this.stdRegInfo.pre_edu = this.selected_apply.pre_edu;
       // }

        if(this.selected_apply.work_unit){
          this.stdRegInfo.std_work_unit = this.selected_apply.work_unit;
        }

        if(this.selected_apply.address){
          this.stdRegInfo.std_address = this.selected_apply.address;
        }

        if(this.selected_apply.paper_title){
          this.stdRegInfo.paper_title = this.selected_apply.paper_title;
        }

        if(this.selected_apply.remark){
          this.stdRegInfo.remark = this.selected_apply.remark;
        }

      }


      this.initDictData();

      this.curStep = 2;
      // this.loading = false;
      // this.hideLoading(loading);
      this.applyDialogVisible = true;
    },

    async initorderOrgArray_std_source_1(){
      let { data } = await this.$http.get("/pl/byApply/orderOrgList.htm");
      if(data.success){
        this.orderOrgArray_std_source_1 = data.array;
      }else{
        this.alert(data.errorMsg);
      }
    },

    initStdRegInfo(std) {
      std.std_edu = String(std.std_edu);
      std.std_nation = String(std.std_nation);
      std.std_family_reg = String(std.std_family_reg);
      std.political_status = String(std.political_status);
      return std;
    },
    goEdit(item) {
      // test TODO
      if(!this.timeLimit){
        this.alert("现时间段不允许修改!");
        return;
      } 
      this.selected_apply = item;
      // test TODO
      this.timeLimit.id = item.by_time_config_id;
      // this.selected_major_id = item.major_id;
      this.stdRegInfo.std_source = String(item.std_source);
      this.std_sourceChange(this.stdRegInfo.std_source);
      
      this.stdRegInfo.school_id = item.school_id;
      this.stdRegInfo.remark = item.remark;
      this.stdRegInfo.std_sex = item.std_sex;
      this.stdRegInfo.native_prov = item.native_prov;
      this.stdRegInfo.native_city = item.native_city;
      this.stdRegInfo.std_nation = item.nation;
      this.stdRegInfo.political_status = item.political;

    

      this.stdRegInfo.std_work_unit = item.work_unit;
      this.stdRegInfo.std_address = item.address;
      this.stdRegInfo.std_postcode = item.post_code;
      this.diaplma_no = item.diaplma_no;
      this.stdRegInfo.std_mobile = item.telephone;
      this.diaplmaNo = item.diaplmaNo;

      this.school_name = item.school_name;
      

      this.goApply(item);
    },
    //初始化话个人信息字典数据
    initDictData() {
      this.stdRegInfo.std_nation_text = this.findDict(
        this.nationArray,
        this.stdRegInfo.std_nation
      );
      this.stdRegInfo.std_occupation_text = this.findDict(
        this.occupationArray,
        this.stdRegInfo.std_occupation
      );
      this.stdRegInfo.std_family_reg_text = this.findDict(
        this.familyRegArray,
        this.stdRegInfo.std_family_reg
      );
      this.stdRegInfo.political_status_text = this.findDict(
        this.politicalStatusArray,
        this.stdRegInfo.political_status
      );
      this.stdRegInfo.std_edu_text = this.findDict(
        this.eduArray,
        this.stdRegInfo.std_edu
      );
    },
    

    newStdResume() {
      return {
        start_date: "",
        end_date: "",
        work_exp: "",
        position: ""
      };
    },

    async initStep3() {
      if(this.selected_apply){
       //初始化简历
        let { data } = await this.$http.post(
        "/by/byPaperApply/getResumeList.htm",
        this.Qs.stringify({
          id: this.selected_apply.id
        }),
          this.$http.headers.FORM
        );
        let resumeList = data.array;
        
        this.stdResumeList = [];
        for (let i = 0; i < resumeList.length; i++) {
          const item = resumeList[i];
          this.stdResumeList.push({
              start_date: item.start_date,
              end_date:  item.end_date,
              work_exp:  item.work_exp,
              position:  item.position
            })
        }
      }else{
        this.stdResumeList = [];
        this.stdResumeList.push(this.newStdResume());
        this.stdResumeList.push(this.newStdResume());
        this.stdResumeList.push(this.newStdResume());
      }
    },

    addRow() {
      if (this.stdResumeList.length == 8) {
        this.alert("最多8条数据");
        return;
      }
      this.stdResumeList.push(this.newStdResume());
    },

    delRow(index) {
      let newList = [];
      for (let i = 0; i < this.stdResumeList.length; i++) {
        if (i != index) {
          // this.stdResumeList[i] == null;
          newList.push(this.stdResumeList[i]);
        }
      }
      this.stdResumeList = newList;
    },

    async submit(file_path) {
     

     // if(null == this.stdRegInfo.pre_edu|| "" == this.stdRegInfo.pre_edu){
      //  this.alert("请填写专（本）科何专业及发证单位!");
     //   return;
     // }

      if(null == this.stdRegInfo.std_address|| "" == this.stdRegInfo.std_address){
        this.alert("请填写通讯地址!");
        return;
      }

     

      let loading = this.showLoading();
      this.$refs["stdRegInfo"].validate(async valid =>   {
        if (valid) {
          //验证
          if (this.selected_apply) {
             
            let loading = this.showLoading();
          
           let { data } = await this.$http.post(
              "by/byPaperApply/reApply.htm",
              this.Qs.stringify({
                id: this.selected_apply.id,
                major_id: this.selected_major_id,
                std_source: this.stdRegInfo.std_source,
                school_id: this.stdRegInfo.school_id,
               
                remark: this.stdRegInfo.remark,
                std_sex: this.stdRegInfo.std_sex,
              
                nation: this.stdRegInfo.std_nation,
                political: this.stdRegInfo.political_status,
                //pre_edu: this.stdRegInfo.pre_edu,
                work_unit: this.stdRegInfo.std_work_unit,
                address: this.stdRegInfo.std_address,
                post_code: this.stdRegInfo.std_postcode,
               
                std_birth_str: this.stdRegInfo.std_birth,
                
                telephone: this.stdRegInfo.std_mobile,
               
                by_photo:this.by_photo_url_p,
                paper_title:this.stdRegInfo.paper_title,
                qq:this.stdRegInfo.qq
                
                
              }),
              this.$http.headers.FORM
            );
            this.hideLoading(loading);
            if (data.success) {
              this.alert("提交成功");
              this.init();
              this.$nextTick(() => {
                this.applyDialogVisible = false;
              });
            } else {
              this.hideLoading(loading);
              this.alert(data.errorMsg);
            }
          } else {
            

            if(!String(this.stdRegInfo.school_id)){
              this.hideLoading(loading);
              this.alert("主考院校id为空!");
              return;
            }
            
            let { data } = await this.$http.post(
              "by/byPaperApply/apply.htm",
              this.Qs.stringify({
                major_id: this.selected_major_id,
                std_source: this.stdRegInfo.std_source,
                school_id: this.stdRegInfo.school_id,
               
                remark: this.stdRegInfo.remark,
                std_sex: this.stdRegInfo.std_sex,
              
                nation: this.stdRegInfo.std_nation,
                political: this.stdRegInfo.political_status,
               // pre_edu: this.stdRegInfo.pre_edu,
                work_unit: this.stdRegInfo.std_work_unit,
                address: this.stdRegInfo.std_address,
                post_code: this.stdRegInfo.std_postcode,
               
                std_birth_str: this.stdRegInfo.std_birth,
                
                telephone: this.stdRegInfo.std_mobile,
               
                by_photo:this.by_photo_url_p,
                paper_title:this.stdRegInfo.paper_title,
                qq:this.stdRegInfo.qq
                
              }),
              this.$http.headers.FORM
            );
            this.hideLoading(loading);
            if (data.success) {
              this.alert("提交成功");
              this.init();
              this.$nextTick(() => {
                this.applyDialogVisible = false;
              });
            } else {
             
              this.hideLoading(loading);
              this.alert(data.errorMsg);
              return false;
            }
          }
        } else {
          this.hideLoading(loading);
          this.alert("请完成必填项!");
          return false;
        }
        
      });
    },
    colseWin() {
      this.applyDialogVisible = false;
      this.curStep = 1;
      this.selected_major_id = null;
      this.applyInfoConfirm = false;
      this.stdRegInfo.major_level = "";
      this.stdRegInfo.school_id = "";

      this.initStdApplyInfo();
    },

    async schoolChange(school_id){
     let sch =  _.find(this.orgArray_std_source_3,(item,index)=>{
        return item.id == school_id;
      })
      ;
      if(sch){
        this.school_name = sch.org_code + "-" + sch.org_name;
      }
    },

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

    async std_sourceChange(std_source){
        //非助学班返回
        // console.log("std_source:"+std_source+" orgArray_std_source_3:"+this.orgArray_std_source_3.length);
        if(std_source != '3' || this.orgArray_std_source_3.length >0){
          //社会考生 联动主考院校名称
          if(String(this.selected_major_id)){
            this.majorChange(this.selected_major_id);
          }

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

          this.orgArray_std_source_3 = res.data.array;

    },
    async majorChange(major_id){
      if(!String(major_id))return;
      this.school_name = "";
      this.initOldMajor(major_id);
      if(String(this.stdRegInfo.std_source) != "1")  return;
      this.initSchoolName(major_id);
    },
    async initOldMajor(major_id){
      
      let res = await this.$http.post("/by/byPaperApply/getOlaMajorInfoBynewMajorId.htm",
          this.Qs.stringify({
            major_id: major_id,
          }));
          this.oldMajorArray = res.data.array;
      // let major = res.data.map;

      // if(major){
      //   this.oldMajorInfo =  major.major_code + "-" + major.major_name;
      // }else{
      //   this.oldMajorInfo = "无";
      // }
      // console.log(this.oldMajorInfo);
      
    },
    //初始化
    async initNewMajor(major_id){
        let res = await this.$http.post("/by/byPaperApply/getNewMajorInfoByOldMajorId.htm",
          this.Qs.stringify({
            major_id: major_id,
          }));
          if(res.data.array.length >0){
            let major = res.data.array[0];
            this.newMajorInfo = major.major_code + major.major_name;
            this.selected_major_id = major.id;
            this.majorChange(major.id);
          }
    },

    

    async majorLevelChange(value){
     if(!value){ return;}
    //  if(!this.firstLoad)
     this.stdRegInfo.major_id = "";
     this.selected_major_id = null;
     this.oldMajorArray = [];
     this.school_name = "";

     let loading = this.showLoading();
 
     this.byMajorArray = this.$options.filters["dataArrayFilter"](this.byMajorArraySource, {
          major_level:parseInt(value)
        });

     this.hideLoading(loading);
   },

  

    cityChange(name){
       if(!name) return;
       this.stdRegInfo.native_city = String(name);
       this.$forceUpdate();


    },
    toUploadByImg(){
      this.imgUploadDialogVisible = true;
      this.$forceUpdate();
    },

     // 图片操作--------------------------------
    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;
      }
      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", data, _this.fileName);
          _this.$http
            .post('/pl/byPaperApply/upload.htm', formData, {
              contentType: false,
              processData: false,
              headers: { "Content-Type": "application/x-www-form-urlencoded" }
            })
            .then( res => {
              _this.hideLoading(loading);
              _this.by_photo_url_p =  res.data.map.file_path;
              _this.randomNum = new Date().getTime();

              if (res.data.success) {
                _this.$message({
                  type: "success",
                  message: "上传成功"
                });
               
              }else{
                 
                _this.alert(res.data.errorMsg, "信息提示");
              }
            });
        });
      } else {
        this.$refs.cropper.getCropData(data => {
          this.model = true;
          this.modelSrc = data;
        });
      }
   
    },

    // 上传附件 start
    handleRemove(file, fileList) {
      return;
      // debugger
      // this.by_file_item = null;
    },
    handlePreview(file) {
      console.log(file);
    },
    handleExceed(files, fileList) {
      this.$message.warning("只能上传一个附件!");
    },
    beforeUpload(file, fileList) {
      return true;
    },
    beforeRemove(file, fileList) {
      //解决删除上传 文件错误问题
      this.$refs.upload.clearFiles();
    },
    handleChange(file, fileList) {
      if (fileList.length > 0) {
        this.by_file_item = file;
      } else {
        this.by_file = "";
      }
    },
    customUpload(file) {
        this.fileUpload(file).then(response => {
          //上传成功提交表单
          if (response.data.success) {
            let filePath = response.data.entity;
            this.by_file = filePath;
          } else {
            this.alert(response.data.errorMsg);
            //异常自动清除文件列表
            this.$refs.upload.clearFiles();
          }
        });

        //解决删除上传 文件错误问题
        const prom = new Promise((resolve, reject) => {})
        prom.abort = () => {}
        return prom
    },

    fileUpload(fileobj) {
      let param = new FormData();
      param.append("file", fileobj.file);
      return this.$http.request({
        method: "post",
        url: "pl/byApply/uploadFile.htm",
        headers: { "Content-Type": "multipart/form-data" },
        data: param
      });
    },


  },
  
};
</script>

<style lang="scss" scoped>
@import "~@/assets/style/public.scss";
#by_paperApply {
  .el-dialog__body {
    padding: 5px !important;
    margin: 5px;
  }
  .vue-cropper {
    height: 490px;
    width: 400px;
  }
  .show-preview {
    border: 1px solid #6fb8ff;
  }
}
</style>
