<template>
  <div>
    <div style="position: relative;padding: 15px 0;margin-top: 5px;">
      <!-- 企业审核通过 -->
      <img v-if="classForm.zigeperson.grshenhe == 1" src="../../../assets/images/qytg.png" style=" position: absolute;
    top: -5px;
    right: 20px;
    width: 150px;    z-index: 999;" alt="" />

      <!-- 企业审核中 -->
      <img v-if="classForm.zigeperson.grshenhe == 0" src="../../../assets/images/qyshz.png" style=" position: absolute;
    top: -5px;
    right: 20px;
    width: 150px;    z-index: 999;" alt="" />
      <!-- 培训点审核通过 -->
      <img v-if="classForm.zigeperson.pxshenhe == 1" src="../../../assets/images/pxtg.png" style=" position: absolute;
    top: -5px;
    right: 180px;
    width: 150px;    z-index: 999;" alt="" />
      <!-- 培训点审核不通过 -->
      <img v-if="classForm.zigeperson.pxshenhe == 2 || classForm.zigeperson.pxshenhe == 3"
        src="../../../assets/images/pxbtg.png" style=" position: absolute;
    top: -5px;
    right: 180px;
    width: 150px;    z-index: 999;" alt="" />
      <el-form ref="classForm" label-position="right" label-width="120px" inline :model="classForm" :rules="classRules"
        v-loading="formLoad">

        <el-row :gutter="40">
          <el-col :span="24" v-if="type == 0">
            <div style="background-color: #eee;font-weight: bold;text-align: center;font-size: 16px;"
              class="pd-10 m-b-10">
              {{ info.TrainName }}
            </div>
          </el-col>
          <el-col :span="24" v-else>
            <div style="
  background-color: #eee;
  font-weight: bold;
  text-align: center;
  font-size: 16px;

" class="pd-10 m-b-10">
              报名信息

            </div>
          </el-col>
          <el-col :span="24">
            <div class="formTitle m-b-20">
              企业信息
            </div>
          </el-col>
          <!-- <el-col :span="16"> -->
          <el-form-item class="qiye" style="width:790px" label="企业名称" prop="zigeperson.DeptName">
            <el-select style="width: 100%;" v-model="classForm.zigeperson.DeptName" filterable remote reserve-keyword
              clearable :disabled="type == 0 ? false : true" placeholder="输入企业名称自动匹配后再进行选择" :remote-method="remoteMethod"
              :loading="loading" @change="chooseQy">
              <el-option v-for="(item, index) in options" :key="item.id" :label="item.DeptName" :value="index">
              </el-option>
            </el-select>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="负责人姓名" prop="zigeperson.DeptLxr">
            <el-input v-model="classForm.zigeperson.DeptLxr" type="text" readonly auto-complete="off"
              placeholder="请输入负责人姓名"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="手机号码" prop="zigeperson.DeptLxrPhone">
            <el-input v-model="classForm.zigeperson.DeptLxrPhone" type="text" auto-complete="off" readonly
              placeholder="请输入手机号码"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="邮政编码" prop="zigeperson.DeptZipcode">
            <el-input v-model="classForm.zigeperson.DeptZipcode" type="text" auto-complete="off" readonly
              placeholder="请输入邮政编码"></el-input>
          </el-form-item>
          <!-- </el-col>

          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="电子邮箱" prop="zigeperson.DeptEmail">
            <el-input v-model="classForm.zigeperson.DeptEmail" type="text" auto-complete="off" readonly
              placeholder="请输入电子邮箱"></el-input>
          </el-form-item>
          <!-- </el-col> -->
          <el-col :span="24">
            <div class="formTitle m-b-20">
              监理员信息
            </div>
          </el-col>
          <!-- <el-col :span="8"> -->
          <el-form-item style="width:390px" label="姓名" prop="zigeperson.UserName">
            <el-input v-model="classForm.zigeperson.UserName" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入姓名"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="性别" prop="zigeperson.UserSex">
            <el-select v-model="classForm.zigeperson.UserSex" clearable placeholder="请选择性别"
              :disabled="type == 1 && xiugai == false ? true : false">
              <el-option label="男" value="男">
                男
              </el-option>
              <el-option label="女" value="女">
                女
              </el-option>
            </el-select>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="身份证号" prop="zigeperson.UserCord">
            <el-input v-model="classForm.zigeperson.UserCord" type="text" :readonly="type == 0 ? false : true"
              auto-complete="off" placeholder="请输入身份证号"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="民族" prop="zigeperson.minzu">
            <el-input v-model="classForm.zigeperson.minzu" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入民族"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="职称" prop="zigeperson.zhicheng">
            <el-select v-model="classForm.zigeperson.zhicheng" placeholder="请选择职称" clearable
              :disabled="type == 1 && xiugai == false ? true : false">
              <el-option v-for="dict in dict.type.job_title" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
            <!-- <el-input v-model="classForm.zigeperson.zhicheng" type="text" auto-complete="off"
                :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入职称"></el-input> -->
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="职称专业" prop="zigeperson.zhichengZhuanYe">
            <el-input v-model="classForm.zigeperson.zhichengZhuanYe" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入职称专业"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="手机号码" prop="zigeperson.UserPhone">
            <el-input v-model="classForm.zigeperson.UserPhone" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入手机号码"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="工作年限" prop="zigeperson.zygznx">
            <el-input min="0" v-model="classForm.zigeperson.zygznx" type="number" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入工作年限"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="职务" prop="zigeperson.zhiwu">
            <el-input v-model="classForm.zigeperson.zhiwu" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入职务"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="16"> -->
          <el-form-item style="width:390px" label="毕业院校" prop="zigeperson.BYschool">
            <el-input v-model="classForm.zigeperson.BYschool" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入毕业院校"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="毕业证专业" prop="zigeperson.sxzy">
            <el-input v-model="classForm.zigeperson.sxzy" type="text" auto-complete="off"
              :readonly="type == 1 && xiugai == false ? true : false" placeholder="请输入毕业证专业"></el-input>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="毕业时间" prop="zigeperson.BYTime">
            <el-date-picker style="width: 200px;display: inline-block;" v-model="classForm.zigeperson.BYTime"
              value-format="yyyy-MM-dd" type="date" placeholder="选择日期时间"
              :readonly="type == 1 && xiugai == false ? true : false">
            </el-date-picker>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="学历" prop="zigeperson.xueli">
            <el-select v-model="classForm.zigeperson.xueli" placeholder="请选择学历" clearable
              :disabled="type == 1 && xiugai == false ? true : false">
              <el-option v-for="dict in dict.type.jxjy_xl" :key="dict.value" :label="dict.label" :value="dict.value" />
            </el-select>
          </el-form-item>
          <!-- </el-col>
          <el-col :span="8"> -->
          <el-form-item style="width:390px" label="考试地点" prop="zigeperson.City">
            <el-input v-model="classForm.zigeperson.City" type="text" readonly auto-complete="off"
              placeholder="请输入考试地点"></el-input>
          </el-form-item>
          <!-- </el-col> -->
          <el-col :span="24">
            <el-form-item label="工作简历" prop="yeji">
              <Editor1 v-if="type == 1 && xiugai == false ? true : false" width="100%" :min-height="200" :height="350"
                ref="editor" :typeInfo="type == 1 && xiugai == false ? true : false" v-model="classForm.yeji" />
              <Editor2 v-else width="100%" :min-height="200" :height="350" ref="editor"
                :typeInfo="type == 1 && xiugai == false ? true : false" v-model="classForm.yeji" />
            </el-form-item>
          </el-col>
          <el-col :span="24" v-if="type == 0">
            <div class="formTitle m-b-20">
              开票信息
            </div>
          </el-col>
          <el-col :span="24" v-if="type == 0">
            <div style="color:#F56C6C;">
              注意事项：发票均每人单独开，开票信息为空的，请联系企业完善开票信息。
            </div>
            <div class="m-t-10">
              <el-form-item label="开票类型" prop="zigeperson.KplxFlg">
                <el-radio-group v-model="classForm.zigeperson.KplxFlg"
                  @change="$refs.classForm.clearValidate(['zigeperson.Email', 'qiye.kplx', 'qiye.kpfs', 'qiye.kpdw', 'qiye.nsrsbh', 'qiye.dzfpyx'])">
                  <!-- <el-radio :label="0">不需要开发票</el-radio> -->
                  <el-radio :label="1">全电普票</el-radio>
                  <el-radio :label="2">全电专票</el-radio>
                </el-radio-group>
              </el-form-item>
            </div>
            <el-row :gutter="40" v-if="classForm.zigeperson.KplxFlg == 1">
              <el-col :span="12">
                <el-form-item label="个人姓名" prop="zigeperson.UserName">
                  <el-input v-model="classForm.zigeperson.UserName" readonly type="text" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="身份证号" prop="zigeperson.UserCord">
                  <el-input readonly @blur="validateIDCard" v-model="classForm.zigeperson.UserCord" type="text"
                    auto-complete="off" placeholder="请输入身份证号"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="电子发票邮箱" prop="zigeperson.dzfpyx"
                  :rules="{ required: true, message: '请联系企业负责人先完善发票信息，再进行报名', trigger: ['blur', 'change'] }">
                  <el-input v-model="classForm.zigeperson.dzfpyx" readonly type="text" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
            <el-row :gutter="40" v-if="classForm.zigeperson.KplxFlg == 2">
              <el-col :span="12">
                <el-form-item label="开票单位" prop="zigeperson.DeptName"
                  :rules="{ required: true, message: '请联系企业负责人先完善发票信息，再进行报名', trigger: ['blur', 'change'] }">
                  <el-input v-model="classForm.zigeperson.DeptName" readonly type="text" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="12">
                <el-form-item label="纳税人识别号" prop="zigeperson.nsrsbh"
                  :rules="{ required: true, message: '请联系企业负责人先完善发票信息，再进行报名', trigger: ['blur', 'change'] }">
                  <el-input v-model="classForm.zigeperson.nsrsbh" readonly type="text" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="电子发票邮箱" prop="zigeperson.dzfpyx"
                  :rules="{ required: true, message: '请联系企业负责人先完善发票信息，再进行报名', trigger: ['blur', 'change'] }">
                  <el-input v-model="classForm.zigeperson.dzfpyx" readonly type="text" auto-complete="off"></el-input>
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
          <el-col :span="24">
            <div class="formTitle m-b-20">
              证件上传
            </div>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="100px" label="身份证" prop="personcord.0.ZJImgUrl">
              <el-upload accept="image/jpeg,image/jpg,image/png" class="avatar-uploader" :action="uploadUrl" :limit="1"
                list-type="picture-card" :file-list="fileList0"
                :on-success="function (file) { return handleAvatarSuccess(file, 0) }"
                :on-remove="function (file) { return handleRemove(file, 0) }"
                :class="classForm.personcord[0].ZJImgUrl == null ? '' : 'hide'"
                v-if="type == 1 && xiugai == false ? false : true">
                <i class="el-icon-plus"></i>
              </el-upload>
              <span v-else> <image-preview v-if="fileList0.length != 0" :src="fileList0[0].url" :width="'140px'"
                  :height="'140px'" /></span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="100px" label="毕业证" prop="personcord.1.ZJImgUrl">
              <el-upload accept="image/jpeg,image/jpg,image/png" class="avatar-uploader" :action="uploadUrl" :limit="1"
                list-type="picture-card" :file-list="fileList1"
                :on-success="function (file) { return handleAvatarSuccess(file, 1) }"
                :on-remove="function (file) { return handleRemove(file, 1) }"
                :class="classForm.personcord[1].ZJImgUrl == null ? '' : 'hide'"
                v-if="type == 1 && xiugai == false ? false : true">
                <i class="el-icon-plus"></i>
              </el-upload>
              <span v-else><image-preview v-if="fileList1.length != 0" :src="fileList1[0].url" :width="'140px'"
                  :height="'140px'" /> </span>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="100px" label="职称证" prop="personcord.2.ZJImgUrl">
              <el-upload class="avatar-uploader" accept="image/jpeg,image/jpg,image/png" :action="uploadUrl" :limit="1"
                list-type="picture-card" :file-list="fileList2"
                :on-success="function (file) { return handleAvatarSuccess(file, 2) }"
                :on-remove="function (file) { return handleRemove(file, 2) }"
                v-if="type == 1 && xiugai == false ? false : true"
                :class="classForm.personcord[2].ZJImgUrl == null ? '' : 'hide'">
                <i class="el-icon-plus"></i>
              </el-upload>
              <image-preview :src="fileList2[0].url" :width="'140px'" :height="'140px'"
                v-else-if="fileList2.length > 0" />
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label-width="100px" label="学信网证明" prop="personcord.3.ZJImgUrl">
              <el-upload class="avatar-uploader" :action="uploadUrl" accept="image/jpeg,image/jpg,image/png" :limit="1"
                list-type="picture-card" :file-list="fileList3"
                :on-success="function (file) { return handleAvatarSuccess(file, 3) }"
                :on-remove="function (file) { return handleRemove(file, 3) }"
                v-if="type == 1 && xiugai == false ? false : true"
                :class="classForm.personcord[3].ZJImgUrl == null ? '' : 'hide'">
                <i class="el-icon-plus"></i>
              </el-upload>
              <image-preview :src="fileList3[0].url" :width="'140px'" :height="'140px'"
                v-else-if="fileList3.length > 0" />
            </el-form-item>
          </el-col>
        </el-row>
        <div style="color:#F56C6C;">
          2001年前在学信网查不到的，请单位开具证明信并盖章
        </div>
      </el-form>
    </div>
  </div>
</template>

<script>
import {
  zgksQySearch, getPeoInfo, zgksBaoming
} from "@/api/userIndex"
import {
  getPersonInfo,
  getYeji
} from "@/api/xiehui/jxjy/Person"
import Editor1 from "../../../components/Editor1.vue";
import Editor2 from "../../../components/Editor2.vue";
function hebing(obj1, obj2) {
  const result = {}
  // 合并obj1和obj2的属性
  for (const key of new Set([...Object.keys(obj1), ...Object.keys(obj2)])) {
    if (obj1.hasOwnProperty(key) && obj2.hasOwnProperty(key) && obj1[key] === null && obj2[key] === null) {
      // 如果两个对象都有这个key，并且值都为null，则合并后的值也为null
      result[key] = null;
    } else if (obj1.hasOwnProperty(key) !== null) {
      // 如果obj1有这个key，但obj2没有或者obj2的值为null，则使用obj1的值
      result[key] = obj1[key];
    } else {
      // 如果obj2有这个key（并且obj1没有），则使用obj2的值
      result[key] = obj2[key];
    }
  }
  return result;
}

function getObj(obj) {
  let result = {}
  for (let key in obj) {
    if (obj[key] != null) {
      result[key] = obj[key]
    }
  }
  return result
}
export default {
  name: "Jly",
  components: { Editor1, Editor2 },

  props: {
    info: { // 传入的继续教育name
      type: Object,
      default: {},
    },
    type: {
      type: Number,
      default: 0,//0 报名  1 修改 详细
    },
    xiugai: {
      type: Boolean,
      default: false
    }
  },
  dicts: ['jxjy_xl', 'job_title'],
  data() {
    //身份证验证
    const cardNum = (rule, value, callback) => {
      if (/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) {
        // proxy.getage(value)
        callback()
      } else {
        callback(new Error('身份证号不正确'))
      }
    }
    var validator2 = (rule, val, callback) => {
      if (!val) {
        callback(new Error("请输入工作年限"));
      } else {
        const reg = /^(0|[1-9]\d*)(\.\d{1})?$/;
        if (reg.test(val)) {
          return callback();
        } else {
          callback(
            new Error(
              "格式错误，请输入正整数或最多一位小数的数字"
            )
          );
        }
      }
    };
    return {
      uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", //上传路径
      loading: false, //按钮加载
      formLoad: false,
      classForm: {
        yeji: null, //业绩
        personcord: [{
          UserCord: null,
          ZJLX: "0",
          ZJImgUrl: null,
        }, {
          UserCord: null,
          ZJLX: "1",
          ZJImgUrl: null,
        },
        {
          UserCord: null,
          ZJLX: "3",
          ZJImgUrl: null,
        },
        {
          UserCord: null,
          ZJLX: "4",
          ZJImgUrl: null,
        }
        ],
        zigeperson: {
          TrainId: this.info.id,
          UserCord: null,
          City: this.info.City,
          DeptName: null,
          ZcsZhuanYe: this.info.ZcsZhuanYe,
          ZYIdList: this.info.ZYIdList
        },
        jianli: []
      },
      classRules: {
        'zigeperson.DeptName': {
          required: true,
          message: '请输入企业名称',
          trigger: ['blur', 'change']
        },
        'zigeperson.DeptLxr': {
          required: true,
          message: '请输入负责人姓名',
          trigger: ['blur', 'change']
        },
        'zigeperson.DeptLxrPhone': {
          required: true,
          message: '请输入手机号码',
          trigger: ['blur', 'change']
        },
        'zigeperson.DeptZipcode': {
          required: true,
          message: '请输入邮政编码',
          trigger: ['blur', 'change']
        },
        'zigeperson.DeptEmail': {
          required: true,
          message: '请输入电子邮箱',
          trigger: ['blur', 'change']
        },
        'zigeperson.UserName': {
          required: true,
          message: '请输入姓名',
          trigger: ['blur', 'change']
        },
        'zigeperson.UserSex': {
          required: true,
          message: '请选择性别',
          trigger: ['blur', 'change']
        },
        'zigeperson.UserCord': [{
          type: 'string',
          required: true,
          message: '请输入身份证号',
          trigger: ['blur', 'change']
        },
        {
          validator: cardNum,
          trigger: ['blur', 'change']
        },
        ],
        'zigeperson.minzu': {
          required: true,
          message: '请输入民族',
          trigger: ['blur', 'change']
        },
        'zigeperson.zhicheng': {
          required: true,
          message: '请输入职称',
          trigger: ['blur', 'change']
        },
        'zigeperson.zhichengZhuanYe': {
          required: true,
          message: '请输入职称专业',
          trigger: ['blur', 'change']
        },
        'zigeperson.UserPhone': {
          required: true,
          message: '请输入手机号码',
          trigger: ['blur', 'change']
        },
        'zigeperson.zygznx': {
          required: true,
          trigger: ['blur', 'change'],
          validator: validator2,
        },
        'zigeperson.zhiwu': {
          required: true,
          message: '请输入职务',
          trigger: ['blur', 'change']
        },
        'zigeperson.BYschool': {
          required: true,
          message: '请输入毕业院校',
          trigger: ['blur', 'change']
        },
        'zigeperson.sxzy': {
          required: true,
          message: '请输入毕业证专业',
          trigger: ['blur', 'change']
        },
        'zigeperson.BYTime': {
          required: true,
          message: '请选择毕业时间',
          trigger: ['blur', 'change']
        },
        'zigeperson.xueli': {
          required: true,
          message: '请选择学历',
          trigger: ['blur', 'change']
        },
        'zigeperson.nsrsbh': {
          required: true,
          message: '请输入纳税人识别号',
          trigger: ['blur', 'change']
        },
        'zigeperson.KplxFlg': {
          required: true,
          message: '请选择开票类型',
          trigger: ['blur', 'change']
        },
        yeji: [{
          required: true,
          message: '请输入监理工程师业绩/简历',
          trigger: ['blur', 'change']
        },
        {
          min: 10,
          message: '业绩内容需为10字以上',
          trigger: 'blur'
        }
        ],
        'personcord.0.ZJImgUrl': {
          required: true,
          message: '请上传身份证',
          trigger: ['blur', 'change']
        },
        'personcord.1.ZJImgUrl': {
          required: true,
          message: '请上传毕业证',
          trigger: ['blur', 'change']
        },
        'personcord.2.ZJImgUrl': {
          required: true,
          message: '请上传职称证',
          trigger: ['blur', 'change']
        },
        'personcord.3.ZJImgUrl': {
          required: true,
          message: '请上传学信网证明',
          trigger: ['blur', 'change']
        }
      },
      //企业列表
      options: [],
      fileList0: [],
      fileList1: [],
      fileList2: [],
      fileList3: [],
      baseUrl: process.env.VUE_APP_BASE_API2,
    }
  },
  created() {
    console.log('info', this.info)

  },
  watch: {
    info: {
      immediate: true, // 立即调用处理函数
      handler(newInfo) {
        console.log('newInfo', newInfo)
        this.initializeForm(newInfo);
      }
    }
  },
  methods: {

    initializeForm(newInfo) {
      if (this.type == 1) {
        this.formLoad = true
        this.classForm.zigeperson = { ...this.info }
        this.classForm.personcord = [...this.info.personcords]
        this.classForm.yeji = this.info.yeji.replaceAll("&lt;/p&gt;", "</p>")
          .replaceAll("&lt;br&gt;", "<br>")
          .replaceAll("&lt;/br&gt;", "</br>")
          .replaceAll("&lt;p&gt;", "<p>")
          .replaceAll("&nbsp;", " ")
          .replace(/&lt;/g, "<") // 替换 &lt; 为 <
          .replace(/&gt;/g, ">") // 替换 &gt; 为 >
          .replace(/&amp;nbsp;/g, " ") // 替换 &amp;nbsp; 为普通空格
          .replace(/\s+/g, " ") // 将多个空格替换为一个空格
          .trim(); // 去除首尾空格
        console.log("?? ~ initializeForm ~ this.classForm.yeji:", this.classForm.yeji)

        // getYeji({
        //   ShenFenZheng: this.classForm.zigeperson.UserCord
        // }).then(qwe => {
        //   if (qwe.data.length != 0) {
        //     this.classForm.yeji = qwe.data[qwe.data.length - 1].zyJianSheYeJi;
        //   }
        // })
        if (this.info.personcords.length > 0) {
          for (let i in this.info.personcords) {
            if (this.info.personcords[i].ZJLX == '0') {
              this.classForm.personcord[0] = {
                UserCord: this.info.personcords[i].UserCord,
                ZJLX: "0",
                ZJImgUrl: this.info.personcords[i].ZJImgUrl,
                ID: this.info.personcords[i].ID
              }
              this.fileList0 = [{ url: this.baseUrl + this.info.personcords[i].ZJImgUrl }]
            } else if (this.info.personcords[i].ZJLX == '1') {
              this.classForm.personcord[1] = {
                UserCord: this.info.personcords[i].UserCord,
                ZJLX: "1",
                ZJImgUrl: this.info.personcords[i].ZJImgUrl,
                ID: this.info.personcords[i].ID
              }
              this.fileList1 = [{ url: this.baseUrl + this.info.personcords[i].ZJImgUrl }]
            } else if (this.info.personcords[i].ZJLX == '3') {
              this.classForm.personcord[2] = {
                UserCord: this.info.personcords[i].UserCord,
                ZJLX: "3",
                ZJImgUrl: this.info.personcords[i].ZJImgUrl,
                ID: this.info.personcords[i].ID
              }
              this.fileList2 = [{ url: this.baseUrl + this.info.personcords[i].ZJImgUrl }]
            } else if (this.info.personcords[i].ZJLX == '4') {
              this.classForm.personcord[3] = {
                UserCord: this.info.personcords[i].UserCord,
                ZJLX: "4",
                ZJImgUrl: this.info.personcords[i].ZJImgUrl,
                ID: this.info.personcords[i].ID
              }
              this.fileList3 = [{ url: this.baseUrl + this.info.personcords[i].ZJImgUrl }]
            }
          }
        }

        console.log('this.fileList0', this.fileList0)

        this.formLoad = false
      }
    },
    //表单重置
    reset() {
      this.options = []
      this.classForm = {
        yeji: null, //业绩
        personcord: [{
          UserCord: null,
          ZJLX: "0",
          ZJImgUrl: null,
        }, {
          UserCord: null,
          ZJLX: "1",
          ZJImgUrl: null,
        },
        {
          UserCord: null,
          ZJLX: "3",
          ZJImgUrl: null,
        },
        {
          UserCord: null,
          ZJLX: "4",
          ZJImgUrl: null,
        }
        ], //附件
        zigeperson: {
          UserCord: null,
          City: this.info.City,
          DeptName: null,
          ZcsZhuanYe: this.info.ZYIdList
        },
      }
      this.fileList0 = []
      this.fileList1 = []
      this.fileList2 = []
      this.fileList3 = []
      this.resetForm("classForm")
    },
    //查询企业
    remoteMethod(query) {
      if (this.type == 0) {
        if (query !== '') {
          this.loading = true;
          zgksQySearch(query).then(res => {
            this.options = res.data
            this.loading = false;
          })
        } else {
          this.options = [];
        }
      }

    },
    //选择企业
    chooseQy(v) {
      // this.classForm.zigeperson = {
      // 	...this.options[v]
      // }
      this.classForm.zigeperson = {
        ...this.classForm.zigeperson,
        ...getObj(this.options[v])
      }
    },
    //根据身份证号查询人员信息
    searchPerson() {
      if (this.type == 0) {
        if (this.classForm.zigeperson.BMdept == null) {
          this.$message({
            type: "error",
            message: "请先选择企业"
          })
        } else {
          this.$refs.classForm.validate((valid, results) => {
            if (results["zigeperson.UserCord"] == undefined) {
              getPeoInfo({
                ZYIdList: this.classForm.zigeperson.ZYIdList,
                UserCord: this.classForm.zigeperson.UserCord,
                BMdept: this.classForm.zigeperson.BMdept
              }).then(res => {
                this.classForm.zigeperson = {
                  ...this.classForm.zigeperson,
                  ...getObj(res.data)
                }
                for (let i in res.data.personcords) {
                  if (res.data.personcords[i].ZJLX == '0') {
                    this.classForm.personcord[0].ZJImgUrl = res.data.personcords[i].ZJImgUrl
                    this.classForm.personcord[0] = { ...res.data.personcords[i], ...this.classForm.personcord[0] }
                    this.fileList0 = [{ url: this.baseUrl + res.data.personcords[i].ZJImgUrl }]
                    this.$refs.classForm.validateField('personcord.0.ZJImgUrl')
                  } else if (res.data.personcords[i].ZJLX == '1') {
                    this.classForm.personcord[1].ZJImgUrl = res.data.personcords[i].ZJImgUrl
                    this.classForm.personcord[1] = { ...res.data.personcords[i], ...this.classForm.personcord[1] }
                    this.fileList1 = [{ url: this.baseUrl + res.data.personcords[i].ZJImgUrl }]
                    this.$refs.classForm.validateField('personcord.1.ZJImgUrl')
                  } else if (res.data.personcords[i].ZJLX == '3') {
                    this.classForm.personcord[2].ZJImgUrl = res.data.personcords[i].ZJImgUrl
                    this.classForm.personcord[2] = { ...res.data.personcords[i], ...this.classForm.personcord[2] }
                    this.fileList2 = [{ url: this.baseUrl + res.data.personcords[i].ZJImgUrl }]
                    this.$refs.classForm.validateField('personcord.2.ZJImgUrl')
                  } else if (res.data.personcords[i].ZJLX == '4') {
                    this.classForm.personcord[3].ZJImgUrl = res.data.personcords[i].ZJImgUrl
                    this.classForm.personcord[3] = { ...res.data.personcords[i], ...this.classForm.personcord[3] }
                    this.fileList3 = [{ url: this.baseUrl + res.data.personcords[i].ZJImgUrl }]
                    this.$refs.classForm.validateField('personcord.3.ZJImgUrl')
                  }
                }
                getYeji({
                  ShenFenZheng: this.classForm.zigeperson.UserCord
                }).then(qwe => {
                  this.classForm.jianli = qwe.data
                })
              })
            }
          })
        }
      }

    },
    //删除图片
    //上传成功
    handleAvatarSuccess(file, index) {
      if (index == 0) {
        this.classForm.personcord[0].ZJImgUrl = file.fileName
        this.$refs.classForm.validateField('personcord.0.ZJImgUrl')
        this.$forceUpdate()
      } else if (index == 1) {
        this.classForm.personcord[1].ZJImgUrl = file.fileName
        this.$refs.classForm.validateField('personcord.1.ZJImgUrl')
        this.$forceUpdate()
      } else if (index == 2) {
        this.classForm.personcord[2].ZJImgUrl = file.fileName
        this.$refs.classForm.validateField('personcord.2.ZJImgUrl')
        this.$forceUpdate()
      } else if (index == 3) {
        this.classForm.personcord[3].ZJImgUrl = file.fileName
        this.$refs.classForm.validateField('personcord.3.ZJImgUrl')
        this.$forceUpdate()
      }
    },
    //移除成功
    handleRemove(file, index) {
      // this.classForm.yyzz = null
      if (index == 0) {
        this.classForm.personcord[0].ZJImgUrl = null
        this.classForm.personcord[0].ID = null
        this.fileList0 = []
      } else if (index == 1) {
        this.classForm.personcord[1].ZJImgUrl = null
        this.classForm.personcord[1].ID = null
        this.fileList1 = []
      } else if (index == 2) {
        this.classForm.personcord[2].ZJImgUrl = null
        this.classForm.personcord[2].ID = null
        this.fileList2 = []
      } else if (index == 3) {
        this.classForm.personcord[3].ZJImgUrl = null
        this.classForm.personcord[3].ID = null
        this.fileList3 = []
      }
    },
    submit() {
      this.$refs.classForm.validate(valid => {
        if (valid) {
          zgksBaoming(this.classForm).then(res => {
            this.$message({
              type: "success",
              message: '修改成功'
            })
            // this.reset()
            this.$emit('submitSuccess', false)
          })
        } else {

        }
      })
    },
    //资格考试报名信息报名
    zgksXiugai() {
      this.$refs.classForm.validate(valid => {
        if (valid) {
          zgksBaoming(this.classForm).then(res => {
            this.$message({
              type: "success",
              message: '报名成功'
            })
            this.reset()
            this.$emit('submitSuccess', false)
          })
        } else {

        }
      })
    }

  }
}
</script>

<style scoped lang="scss">
.formTitle {
  color: #409EFF;
  border-bottom: 1px solid #409EFF;
  padding: 10px;
  font-size: 16px;
  font-weight: bold;
}

::v-deep .el-input--medium .el-input__inner {
  height: 36px;
  line-height: 36px;
  width: 265px;
}

::v-deep .qiye .el-input--medium .el-input__inner {
  height: 36px;
  line-height: 36px;
  width: 665px;
}


::v-deep .el-select>.el-input {
  display: block;
  width: 200px;
}

::v-deep .tox .tox-editor-container {
  width: 1050px;
}

::v-deep .qiye .el-select>.el-input {
  // display: block;
  width: 650px !important;
}

::v-deep .el-input__suffix {
  position: absolute;
  height: 100%;
  right: -55px;
  top: 0;
  text-align: center;
  color: #C0C4CC;
  -webkit-transition: all 0.3s;
  transition: all 0.3s;
  pointer-events: none;
}

// ::v-deep .el-form-item__label {
//   text-align: justify !important;

//   text-align-last: justify !important;
// }

::v-deep .el-select {
  width: 100% !important;
}

::v-deep .select-container {
  width: 100%;
  /* 如果需要，可以设置外部容器的宽度 */
}

::v-deep .select-container .el-select {
  width: 100%;
  /* 让 el-select 占满外部容器的宽度 */
}

::v-deep .hide .el-upload--picture-card {
  display: none;
}
</style>
