<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="108px"
    >
      <el-form-item label="姓名" prop="name">
        <el-input
          v-model="queryParams.name"
          placeholder="请输入姓名"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="曾用名" prop="formerName">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.formerName"-->
      <!--          placeholder="请输入曾用名"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="民族" prop="nation">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.nation"-->
      <!--          placeholder="请输入民族"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="身份证号" prop="identityCard">
        <el-input
          v-model="queryParams.identityCard"
          placeholder="请输入身份证号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="出生日期" prop="birthday">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.birthday"-->
      <!--          placeholder="请输入出生日期"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="籍贯" prop="nativePlace">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.nativePlace"-->
      <!--          placeholder="请输入籍贯"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="学历" prop="education">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.education"-->
      <!--          placeholder="请输入学历"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="专业" prop="major">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.major"-->
      <!--          placeholder="请输入专业"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="所在学校" prop="graduationSchool">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.graduationSchool"-->
      <!--          placeholder="请输入所在学校"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="入学年份" prop="entranceYear">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.entranceYear"-->
      <!--          placeholder="请输入入学年份"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="联系方式" prop="contactInformation">
        <el-input
          v-model="queryParams.contactInformation"
          placeholder="请输入联系方式"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="省ID" prop="provinceId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.provinceId"-->
      <!--          placeholder="请输入省ID"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="市ID" prop="cityId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.cityId"-->
      <!--          placeholder="请输入市ID"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="区" prop="areaId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.areaId"-->
      <!--          placeholder="请输入区"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="省名" prop="provinceName">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.provinceName"-->
      <!--          placeholder="请输入省名"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="市名" prop="cityName">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.cityName"-->
      <!--          placeholder="请输入市名"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="区名" prop="areaName">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.areaName"-->
      <!--          placeholder="请输入区名"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="详细地址" prop="address">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.address"-->
      <!--          placeholder="请输入详细地址"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="邮编" prop="zipCode">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.zipCode"-->
      <!--          placeholder="请输入邮编"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="联系电话" prop="contactPhone">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.contactPhone"-->
      <!--          placeholder="请输入联系电话"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <!--      <el-form-item label="电子邮箱" prop="email">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.email"-->
      <!--          placeholder="请输入电子邮箱"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="机构名称" prop="agencyName">
        <el-input
          v-model="queryParams.agencyName"
          placeholder="请输入机构名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="职业名称" prop="careerName">
        <el-input
          v-model="queryParams.careerName"
          placeholder="请输入职业名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="报名批次" prop="registrationBatch">
        <el-input
          v-model="queryParams.registrationBatch"
          placeholder="请输入报名批次"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="订单编号" prop="orderNo">
        <el-input
          v-model="queryParams.orderNo"
          placeholder="请输入订单编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <!--      <el-form-item label="学习中心ID" prop="studyCenterId">-->
      <!--        <el-input-->
      <!--          v-model="queryParams.studyCenterId"-->
      <!--          placeholder="请输入学习中心ID"-->
      <!--          clearable-->
      <!--          @keyup.enter.native="handleQuery"-->
      <!--        />-->
      <!--      </el-form-item>-->
      <el-form-item label="学习中心" prop="studyCenter">
        <el-input
          v-model="queryParams.studyCenter"
          placeholder="请输入学习中心"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="机构代码" prop="agencyCode">
        <el-input
          v-model="queryParams.agencyCode"
          placeholder="请输入机构代码"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="考试状态" prop="examineStatus">
        <el-select
          v-model="queryParams.examineStatus"
          placeholder="请选择考试状态"
          clearable
        >
          <el-option
            v-for="dict in dict.type.examination_state"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="考试等级" prop="examLevel">
        <el-select
          v-model="queryParams.examLevel"
          placeholder="请选择考试等级"
          clearable
        >
          <el-option
            v-for="dict in dict.type.tb_exam_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="支付状态" prop="examLevel">
        <el-select
          v-model="queryParams.examLevel"
          placeholder="请选择支付状态"
          clearable
        >
          <el-option
            v-for="dict in dict.type.tb_exam_level"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          />
        </el-select>
      </el-form-item> -->
      <el-form-item label="创建时间">
        <el-date-picker
          v-model="daterangeCreateTime"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['hezhi:examRegistration:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['hezhi:examRegistration:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['hezhi:examRegistration:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['hezhi:examRegistration:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="info"
          icon="el-icon-upload2"
          size="mini"
          @click="handleImport"
          >导入</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>

    <el-table
      v-loading="loading"
      :data="examRegistrationList"
      @selection-change="handleSelectionChange"
    >
      <el-table-column type="selection" width="55" align="center" />
      <!--      <el-table-column label="考试报名主键ID" align="center" prop="examRegistrationId" />-->
      <!--      <el-table-column label="用户ID" align="center" prop="memberUserId" />-->
      <!--      <el-table-column label="考试ID" align="center" prop="examId" />-->
      <el-table-column
        label="姓名"
        align="center"
        prop="name"
        min-width="100px"
      >
        <!-- <template></template> -->
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.name"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.name }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="性别" align="center" prop="sex" min-width="60px">
        <template slot-scope="scope">
          {{ selectDictLabel(sexOptions, scope.row.sex) }}
        </template>
      </el-table-column>
      <el-table-column
        label="身份证号"
        align="center"
        prop="identityCard"
        width="120px"
      >
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.identityCard"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.identityCard }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        label="联系方式"
        align="center"
        prop="contactInformation"
        width="110px"
      />
      <el-table-column
        label="职业名称"
        align="center"
        prop="careerName"
        width="100px"
      >
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.careerName"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.careerName }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        label="考试等级"
        align="center"
        prop="examLevel"
        width="80px"
      />
      <el-table-column
        label="考试状态"
        align="center"
        prop="examineStatus"
        width="80px"
      >
        <template slot-scope="scope">
          <dict-tag
            :options="dict.type.examination_state"
            :value="scope.row.examineStatus"
          />
        </template>
      </el-table-column>
      <el-table-column
        label="学习中心"
        align="center"
        prop="studyCenter"
        width="120px"
      >
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.studyCenter"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.studyCenter }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        label="机构代码"
        align="center"
        prop="agencyCode"
        width="120px"
      >
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.agencyCode"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.agencyCode }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        label="学历层次"
        align="center"
        prop="education"
        width="90px"
      />
      <el-table-column
        label="所学专业"
        align="center"
        prop="major"
        width="100px"
      >
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.major"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.major }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        label="学校名称"
        align="center"
        prop="graduationSchool"
        width="120px"
      >
        <template slot-scope="scope">
          <el-tooltip
            class="item"
            effect="dark"
            :content="scope.row.graduationSchool"
            placement="top-start"
          >
            <p class="text_ellispsis">{{ scope.row.graduationSchool }}</p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column label="报名费用" align="center" width="80px">
        <template #default="{ row }">
          {{
            row.orderPrice === null || row.orderPrice === ""
              ? "- -"
              : row.orderPrice
          }}
        </template>
      </el-table-column>

      <el-table-column label="支付金额" align="center" width="80px">
        <template #default="{ row }">
          {{
            row.payPrice === 0 || row.payPrice === null || row.payPrice === ""
              ? "- -"
              : row.payPrice
          }}
        </template>
      </el-table-column>
      <el-table-column label="支付方式" align="center" width="80px">
        <template #default="{ row }">
          {{ formatPayType(row) }}
        </template>
      </el-table-column>
      <el-table-column label="订单号码" align="center" width="160px">
        <template #default="{ row }">
          <el-tooltip
            class="item"
            effect="dark"
            :content="row.orderNo"
            placement="top-start"
          >
            <p class="text_ellispsis">
              {{
                row.orderNo === null || row.orderNo === "" ? "- -" : row.orderNo
              }}
            </p>
          </el-tooltip>
        </template>
      </el-table-column>
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="120px"
      />
      <el-table-column
        label="考试抓拍"
        align="center"
        prop="screenTeacher"
        width="100px"
      >
        <template slot-scope="scope">
          <el-link type="primary" @click="getStudyCenterFileList(scope.row)">
            <span class="text_ellispsis">考试抓拍</span>
          </el-link>
        </template>
      </el-table-column>
      <!--      <el-table-column label="曾用名" align="center" prop="formerName" />-->
      <!--      <el-table-column label="民族" align="center" prop="nation" />-->
      <!--      <el-table-column label="出生日期" align="center" prop="birthday" />-->
      <!--      <el-table-column label="生源类型" align="center" prop="sourceType" />-->
      <!--      <el-table-column label="籍贯" align="center" prop="nativePlace" />-->
      <!--      <el-table-column label="政治面貌" align="center" prop="politicalStatus" />-->

      <!--      <el-table-column label="入学年份" align="center" prop="entranceYear" />-->
      <!--      <el-table-column label="省ID" align="center" prop="provinceId" />-->
      <!--      <el-table-column label="市ID" align="center" prop="cityId" />-->
      <!--      <el-table-column label="区" align="center" prop="areaId" />-->
      <!--      <el-table-column label="省名" align="center" prop="provinceName" />-->
      <!--      <el-table-column label="市名" align="center" prop="cityName" />-->
      <!--      <el-table-column label="区名" align="center" prop="areaName" />-->
      <!--      <el-table-column label="详细地址" align="center" prop="address" />-->
      <!--      <el-table-column label="邮编" align="center" prop="zipCode" />-->
      <!--      <el-table-column label="联系电话" align="center" prop="contactPhone" />-->
      <!--      <el-table-column label="电子邮箱" align="center" prop="email" />-->
      <!--      <el-table-column label="蓝底证件照" align="center" prop="idPhoto" width="100">-->
      <!--        <template slot-scope="scope">-->
      <!--          <image-preview :src="scope.row.idPhoto" :width="50" :height="50"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="身份证国徽面" align="center" prop="identityCardBadge" width="100">-->
      <!--        <template slot-scope="scope">-->
      <!--          <image-preview :src="scope.row.identityCardBadge" :width="50" :height="50"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="身份证人像面" align="center" prop="identityCardPortrait" width="100">-->
      <!--        <template slot-scope="scope">-->
      <!--          <image-preview :src="scope.row.identityCardPortrait" :width="50" :height="50"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->
      <!--      <el-table-column label="毕业证书" align="center" prop="graduationCertificate" />-->
      <!--      <el-table-column label="机构ID" align="center" prop="agencyId" />-->
      <!-- <el-table-column label="机构名称" align="center" prop="agencyName" /> -->
      <!--      <el-table-column label="职业ID" align="center" prop="careerId" />-->
      <!-- <el-table-column
        label="报名批次"
        align="center"
        prop="registrationBatch"
      /> -->
      <!--      <el-table-column label="学习中心ID" align="center" prop="studyCenterId" />-->

      <!--      <el-table-column label="是否自查申请资料完整性" align="center" prop="isInspect" />-->
      <!--      <el-table-column label="签字照" align="center" prop="signPhoto" />-->
      <!--      <el-table-column label="类型" align="center" prop="type" />-->

      <!--      <el-table-column label="审核反馈" align="center" prop="examineFeedback" />-->
      <!--      <el-table-column label="排序" align="center" prop="sort" />-->
      <!--      <el-table-column label="备注" align="center" prop="remarks" />-->
      <!--      <el-table-column label="状态" align="center" prop="status">-->
      <!--        <template slot-scope="scope">-->
      <!--          <dict-tag :options="dict.type.tb_status" :value="scope.row.status"/>-->
      <!--        </template>-->
      <!--      </el-table-column>-->

      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
        fixed="right"
        min-width="190px"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-info"
            @click="handleCertificate(scope.row)"
            v-hasPermi="['hezhi:examRegistration:remove']"
            >证书邮寄</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['hezhi:examRegistration:edit']"
            >修改</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['hezhi:examRegistration:remove']"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改考试报名对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="750px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <!--        <el-form-item label="用户ID" prop="memberUserId">-->
        <!--          <el-input v-model="form.memberUserId" placeholder="请输入用户ID" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="考试ID" prop="examId">-->
        <!--          <el-input v-model="form.examId" placeholder="请输入考试ID" />-->
        <!--        </el-form-item>-->
        <el-form-item
          label="姓名"
          prop="name"
          :rules="[{ required: true, message: '姓名不能为空' }]"
        >
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item
          label="性别"
          prop="sex"
          :rules="[{ required: true, message: '性别不能为空' }]"
        >
          <el-select v-model="form.sex" placeholder="请选择性别" clearable>
            <el-option
              v-for="dict in dict.type.tb_sex"
              :key="dict.value"
              :label="dict.label"
              :value="parseInt(dict.value)"
            />
          </el-select>
        </el-form-item>
        <el-form-item label="曾用名" prop="formerName">
          <el-input v-model="form.formerName" placeholder="请输入曾用名" />
        </el-form-item>
        <el-form-item
          label="民族"
          prop="nation"
          :rules="[{ required: true, message: '民族不能为空' }]"
        >
          <el-select v-model="form.nation" placeholder="请选择民族">
            <el-option
              v-for="(item, index) in nationData"
              :key="index"
              :label="item.value"
              :value="item.value"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="身份证号"
          prop="identityCard"
          :rules="[{ required: true, message: '身份证号不能为空' }]"
        >
          <el-input v-model="form.identityCard" placeholder="请输入身份证号" />
        </el-form-item>
        <el-form-item
          label="出生日期"
          prop="birthday"
          :rules="[{ required: true, message: '出生日期不能为空' }]"
        >
          <el-date-picker
            clearable
            v-model="form.birthday"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择出生日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="籍贯"
          prop="nativePlace"
          :rules="[{ required: true, message: '籍贯不能为空' }]"
        >
          <!-- <el-input v-model="form.nativePlace" placeholder="请输入籍贯" /> -->
          <el-cascader
            v-model="form.nativePlace"
            :options="newCity"
            :props="jiguan"
            @change="nativePlaceleChange"
            placeholder="请选择省市区"
          />
        </el-form-item>
        <el-form-item
          label="学历"
          prop="education"
          :rules="[{ required: true, message: '学历不能为空' }]"
        >
          <el-select
            v-model="form.education"
            placeholder="请选择学历"
            clearable
          >
            <el-option
              v-for="dict in dict.type.tb_education"
              :key="dict.value"
              :label="dict.label"
              :value="dict.label"
            />
          </el-select>
        </el-form-item>
        <el-form-item
          label="专业"
          prop="major"
          :rules="[{ required: true, message: '专业不能为空' }]"
        >
          <el-input v-model="form.major" placeholder="请输入专业" />
        </el-form-item>
        <el-form-item
          label="所在学校"
          prop="graduationSchool"
          :rules="[{ required: true, message: '所在学校不能为空' }]"
        >
          <el-input
            v-model="form.graduationSchool"
            placeholder="请输入所在学校"
          />
        </el-form-item>
        <el-form-item
          label="入学年份（毕业年份）"
          prop="entranceYear"
          :rules="[{ required: true, message: '入学年份不能为空' }]"
        >
          <!-- <el-date-picker clearable v-model="form.entranceYear" type="years" placeholder="请选择入学年份">
          </el-date-picker> -->
          <el-date-picker
            type="years"
            v-model="form.entranceYear"
            placeholder="选择入学年份（毕业年份）"
            value-format="yyyy"
            @change="handleYearChange"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item
          label="联系方式"
          prop="contactInformation"
          :rules="[{ required: true, message: '联系方式不能为空' }]"
        >
          <el-input
            v-model="form.contactInformation"
            placeholder="请输入联系方式"
          />
        </el-form-item>
        <el-form-item
          label="省"
          prop="provinceId"
          :rules="[{ required: true, message: '省不能为空' }]"
        >
          <el-select
            v-model="form.provinceId"
            placeholder="请选择省"
            @change="getCityOrArea"
          >
            <el-option
              v-for="item in getProvinceList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="市"
          prop="cityId"
          :rules="[{ required: true, message: '市不能为空' }]"
        >
          <el-select
            v-model="form.cityId"
            placeholder="请选择市"
            @change="getCityOrAreacity"
          >
            <el-option
              v-for="item in getCityOrAreaList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="区"
          prop="areaId"
          :rules="[{ required: true, message: '区不能为空' }]"
        >
          <el-select v-model="form.areaId" placeholder="请选择区">
            <el-option
              v-for="item in getCityOrAreacityList"
              :key="item.name"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="详细地址"
          prop="address"
          :rules="[{ required: true, message: '详细地址不能为空' }]"
        >
          <el-input v-model="form.address" placeholder="请输入详细地址" />
        </el-form-item>
        <el-form-item label="邮编" prop="zipCode">
          <el-input v-model="form.zipCode" placeholder="请输入邮编" />
        </el-form-item>
        <el-form-item
          label="联系电话"
          prop="contactPhone"
          :rules="[{ required: true, message: '联系电话不能为空' }]"
        >
          <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="电子邮箱" prop="email">
          <el-input v-model="form.email" placeholder="请输入电子邮箱" />
        </el-form-item>
        <el-form-item
          label="蓝底证件照"
          prop="idPhoto"
          :rules="[{ required: true, message: '蓝底证件照不能为空' }]"
        >
          <image-upload v-model="form.idPhoto" :limit="1" />
        </el-form-item>
        <el-form-item
          label="身份证国徽面"
          prop="identityCardBadge"
          :rules="[{ required: true, message: '身份证国徽面不能为空' }]"
        >
          <image-upload v-model="form.identityCardBadge" :limit="1" />
        </el-form-item>
        <el-form-item
          label="身份证人像面"
          prop="identityCardPortrait"
          :rules="[{ required: true, message: '身份证人像面不能为空' }]"
        >
          <image-upload v-model="form.identityCardPortrait" :limit="1" />
        </el-form-item>
        <el-form-item label="毕业证书" prop="graduationCertificate">
          <image-upload v-model="form.graduationCertificate" :limit="1" />
        </el-form-item>
        <!--        <el-form-item label="机构ID" prop="agencyId">-->
        <!--          <el-input v-model="form.agencyId" placeholder="请输入机构ID" />-->
        <!--        </el-form-item>-->

        <el-form-item
          label="机构名称"
          prop="agencyName"
          :rules="[
            { required: true, message: '机构名称不能为空', trigger: 'blur' },
          ]"
        >
          <el-select
            v-model="form.agencyName"
            placeholder="请选择机构名称"
            @change="changeOp"
          >
            <el-option
              :label="item.evaluateAgencyName"
              :value="item.evaluateAgencyName"
              v-for="(item, index) in agencyList"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="职业名称"
          prop="careerName"
          :rules="[
            { required: true, message: '职业名称不能为空', trigger: 'blur' },
          ]"
        >
          <el-select
            v-model="form.careerName"
            placeholder="请选择职业名称"
            @change="changeOc"
            filterable
          >
            <el-option
              :label="item.courseName"
              :value="item.courseId"
              v-for="(item, index) in classMapList"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="学习中心"
          prop="studyCenter"
          :rules="[
            { required: true, message: '学习中心不能为空', trigger: 'blur' },
          ]"
        >
          <el-select
            v-model="form.studyCenter"
            @change="StuChange"
            placeholder="请选择学习中心"
          >
            <el-option
              :label="item.studyCenterName"
              :value="item.studyCenterName"
              v-for="(item, index) in studyCenterList"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item
          label="机构代码"
          prop="agencyCode"
          :rules="[{ required: true, message: '机构代码不能为空' }]"
        >
          <el-input
            v-model="form.agencyCode"
            placeholder="请输入机构代码"
            :disabled="true"
          ></el-input>
        </el-form-item>

        <el-form-item
          label="考试等级"
          prop="examLevel"
          :rules="[{ required: true, message: '考试等级不能为空' }]"
        >
          <el-select
            v-model="form.examLevel"
            @change="getgrade"
            placeholder="请选择"
            :disabled="true"
          >
            <el-option
              :label="item.dictValue"
              :value="item.dictValue"
              v-for="(item, index) in paramList"
              :key="index"
            ></el-option>
          </el-select>
        </el-form-item>

        <!--        <el-form-item label="职业ID" prop="careerId">-->
        <!--          <el-input v-model="form.careerId" placeholder="请输入职业ID" />-->
        <!--        </el-form-item>-->
        <el-form-item
          label="报名批次"
          prop="registrationBatch"
          :rules="[{ required: true, message: '报名批次不能为空' }]"
        >
          <el-input v-model="form.registrationBatch" :disabled="true" />
        </el-form-item>
        <!--        <el-form-item label="学习中心ID" prop="studyCenterId">-->
        <!--          <el-input v-model="form.studyCenterId" placeholder="请输入学习中心ID" />-->
        <!--        </el-form-item>-->
        <el-form-item label="签字照" prop="signPhoto">
          <image-upload v-model="form.signPhoto" :limit="1" />
        </el-form-item>
        <!--        <el-form-item label="考试状态" prop="examineStatus">-->
        <!--          <el-radio-group v-model="form.examineStatus">-->
        <!--            <el-radio-->
        <!--              v-for="dict in dict.type.examination_state"-->
        <!--              :key="dict.value"-->
        <!--              :label="parseInt(dict.value)"-->
        <!--            >{{dict.label}}</el-radio>-->
        <!--          </el-radio-group>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="审核状态" prop="examineStatus">-->
        <!--          <el-radio-group v-model="form.examineStatus">-->
        <!--            <el-radio-->
        <!--              v-for="dict in dict.type.tb_examine_status"-->
        <!--              :key="dict.value"-->
        <!--              :label="parseInt(dict.value)"-->
        <!--            >{{dict.label}}</el-radio>-->
        <!--          </el-radio-group>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="审核反馈" prop="examineFeedback">-->
        <!--          <el-input v-model="form.examineFeedback" type="textarea" placeholder="请输入内容" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="排序" prop="sort">-->
        <!--          <el-input v-model="form.sort" placeholder="请输入排序" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="备注" prop="remarks">-->
        <!--          <el-input v-model="form.remarks" type="textarea" placeholder="请输入内容" />-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="状态" prop="status">-->
        <!--          <el-radio-group v-model="form.status">-->
        <!--            <el-radio-->
        <!--              v-for="dict in dict.type.tb_status"-->
        <!--              :key="dict.value"-->
        <!--              :label="parseInt(dict.value)"-->
        <!--            >{{dict.label}}</el-radio>-->
        <!--          </el-radio-group>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="发布时间" prop="publicationTime">-->
        <!--          <el-date-picker clearable-->
        <!--            v-model="form.publicationTime"-->
        <!--            type="date"-->
        <!--            value-format="yyyy-MM-dd"-->
        <!--            placeholder="请选择发布时间">-->
        <!--          </el-date-picker>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item label="发布人" prop="publisher">-->
        <!--          <el-input v-model="form.publisher" placeholder="请输入发布人" />-->
        <!--        </el-form-item>-->
        <el-form-item label="证书" prop="certificate">
          <image-upload v-model="form.certificate" :limit="1" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>

    <!--考试图片列表-->
    <el-dialog
      title="考试拍摄"
      :visible.sync="openExamFile"
      @close="openExamFileCancel"
      width="1000px"
      append-to-body
    >
      <exam-file
        :member-user-id="memberUserId"
        :exam-id="examId"
        :key="memberUserId"
      />
      <div slot="footer" class="dialog-footer">
        <el-button @click="openExamFileCancel">关 闭</el-button>
      </div>
    </el-dialog>

    <!--考试图片列表-->
    <el-dialog
      title="证书发货"
      :visible.sync="sendOpen"
      width="1000px"
      append-to-body
    >
      <el-form ref="form" :model="form" :rules="rules" label-width="110px">
        <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" placeholder="请输入姓名" />
        </el-form-item>
        <el-form-item label="联系方式" prop="contactInformation">
          <el-input
            v-model="form.contactInformation"
            placeholder="请输入联系方式"
          />
        </el-form-item>
        <el-form-item label="省名" prop="provinceName">
          <el-input v-model="form.provinceName" placeholder="请输入省名" />
        </el-form-item>
        <el-form-item label="市名" prop="cityName">
          <el-input v-model="form.cityName" placeholder="请输入市名" />
        </el-form-item>
        <el-form-item label="区名" prop="areaName">
          <el-input v-model="form.areaName" placeholder="请输入区名" />
        </el-form-item>
        <el-form-item label="详细地址" prop="address">
          <el-input v-model="form.address" placeholder="请输入详细地址" />
        </el-form-item>
        <el-form-item label="邮编" prop="zipCode">
          <el-input v-model="form.zipCode" placeholder="请输入邮编" />
        </el-form-item>
        <el-form-item label="联系电话" prop="contactPhone">
          <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
        </el-form-item>
        <el-form-item label="证书" prop="certificate">
          <image-upload v-model="form.certificate" :limit="1" />
        </el-form-item>
        <el-form-item label="寄件人姓名" prop="sendManName">
          <el-input v-model="form.sendManName" placeholder="请输入寄件人姓名" />
        </el-form-item>
        <el-form-item label="寄件人手机号" prop="sendManMobile">
          <el-input
            v-model="form.sendManMobile"
            placeholder="请输入寄件人手机号"
          />
        </el-form-item>
        <el-form-item label="寄件人地址" prop="sendManPrintAddr">
          <el-input
            v-model="form.sendManPrintAddr"
            placeholder="请输入寄件人地址"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFormSend">确 定</el-button>
        <el-button @click="cancelSend">取 消</el-button>
      </div>
    </el-dialog>

    <!-- 用户导入对话框 -->
    <el-dialog :title="upload.title" :visible.sync="upload.open" width="750px">
      <el-form ref="form" :model="upload" label-width="100px">
        <el-form-item label="" prop="">
          <el-button type="primary" @click="importTemplate">下载模板</el-button>
        </el-form-item>
        <el-form-item label="上传文件">
          <el-upload
            ref="upload"
            :limit="1"
            accept=".xlsx"
            :headers="upload.headers"
            :action="upload.url + '?dateTime=' + upload.dateTime"
            :disabled="upload.isUploading"
            :on-progress="handleFileUploadProgress"
            :on-success="handleFileSuccess"
            :auto-upload="false"
            drag
          >
            <i class="el-icon-upload"></i>
            <div class="el-upload__text">
              将文件拖到此处，或
              <em>点击上传</em>
            </div>
            <div class="el-upload__tip" style="color: #f60303" slot="tip">
              提示：仅允许导入“xls”或“xlsx”格式文件！
            </div>
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitFileForm">确 定</el-button>
        <el-button @click="upload.open = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listExamRegistration,
  getExamRegistration,
  delExamRegistration,
  addExamRegistration,
  updateExamRegistration,
  certificateSend,
  getRegionTreeList,
} from "@/api/hezhi/examRegistration";
import ExamFile from "@/views/hezhi/examFile/index";
import { selectDictLabel } from "../../../utils/ruoyi";
import { getToken } from "@/utils/auth";
import { getExamRegistrationFahuo } from "../../../api/hezhi/examRegistration";
import request from "@/utils/request";
import { getCityOrArea, getProvince } from "@/api/hezhi/region";
import { nationDataList } from "@/api/nation";
export default {
  name: "ExamRegistration",
  components: { ExamFile },
  dicts: [
    "examination_state",
    "tb_status",
    "tb_education",
    "tb_sex",
    "tb_exam_level",
  ],
  data() {
    return {
      nationData: nationDataList,
      // 用户导入参数
      upload: {
        // 是否显示弹出层（用户导入）
        open: false,
        // 弹出层标题（用户导入）
        title: "",
        // 是否禁用上传
        isUploading: false,
        // 是否更新已经存在的用户数据
        dateTime: null,
        // 设置上传的请求头部
        headers: { Authorization: "Bearer " + getToken() },
        // 上传的地址
        url:
          process.env.VUE_APP_BASE_API + "/hezhi/examRegistration/importData",
      },
      sexOptions: [
        {
          label: "男",
          value: 0,
        },
        {
          label: "女",
          value: 1,
        },
        {
          label: "未知",
          value: 2,
        },
      ],
      openExamFile: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 考试报名表格数据
      examRegistrationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 删除标记时间范围
      daterangeCreateTime: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        memberUserId: null,
        examId: null,
        name: null,
        sex: null,
        formerName: null,
        nation: null,
        identityCard: null,
        birthday: null,
        sourceType: null,
        nativePlace: null,
        politicalStatus: null,
        education: null,
        major: null,
        graduationSchool: null,
        entranceYear: "",
        contactInformation: null,
        provinceId: null,
        cityId: null,
        areaId: null,
        provinceName: null,
        cityName: null,
        areaName: null,
        address: null,
        zipCode: null,
        contactPhone: null,
        email: null,
        agencyId: null,
        agencyName: null,
        careerId: null,
        careerName: null,
        examLevel: null,
        registrationBatch: null,
        studyCenterId: null,
        studyCenter: null,
        agencyCode: null,
        isInspect: null,
        signPhoto: null,
        type: null,
        examineStatus: null,
        examineFeedback: null,
        sort: null,
        remarks: null,
        status: null,
        createTime: null,
        deleteTime: null,
        deleteBy: null,
        orderNo: null,
      },
      classMapList: [],
      agencyList: [],
      studyCenterList: [],
      paramList: [],
      //省
      getProvinceList: [],
      //市
      getCityOrAreaList: [],
      //区
      getCityOrAreacityList: [],
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        certificate: [
          { required: true, message: "证书不能为空", trigger: "blur" },
        ],
        sendManName: [
          { required: true, message: "寄件人姓名不能为空", trigger: "blur" },
        ],
        sendManMobile: [
          { required: true, message: "寄件人手机号不能为空", trigger: "blur" },
        ],
        sendManPrintAddr: [
          { required: true, message: "寄件人地址不能为空", trigger: "blur" },
        ],
      },
      memberUserId: null,
      examId: null,
      // 证书发货
      sendOpen: false,
      newCity: [],
      jiguan: {
        value: "name", // 选项中每个节点的值字段
        label: "name", // 选项中每个节点的标签字段
        children: "childrenList", // 子节点字段
      },
    };
  },
  created() {
    this.getList();
    this.getGetEvaluateAgencyListData(); //机构名称下拉
    // this.getGetCareerClassMapListData(); //职业下拉
    this.getGetDictParamListData(); //考试等级下拉
    // this.getGetStudyCenterListtData(); //学习中心下拉
    this.getCourseListByEvaluateAgencyData(); //职业课程下拉（逻辑修改后）
    this.getStudyListByCourseData(); //学习中心下拉（逻辑修改后）
    this.getProvince();
    this.getRegionListData();
  },
  methods: {
    handleYearChange(value) {
      if (this.form.entranceYear && this.form.entranceYear.length > 2) {
        this.$message.warning("最多只能选择两个年份");
        this.form.entranceYear = value.slice(0, 2); // 只保留前两个年份
      }
      // let newArr = [];
      // value.forEach((item, index) => {
      //   newArr.push(item.slice(0, 4));
      // });
      // this.form.entranceYear = newArr.join(",");
      // console.log(this.form.entranceYear);
    },
    selectDictLabel,
    /** 列表弹窗 */
    getStudyCenterFileList(row) {
      this.memberUserId = row.memberUserId;
      this.examId = row.examId;
      this.openExamFile = true;
    },
    openExamFileCancel() {
      this.memberUserId = null;
      this.examId = null;
      this.openExamFile = false;
    },

    /** 查询考试报名列表 */
    getList() {
      this.loading = true;
      this.queryParams.params = {};
      if (null != this.daterangeCreateTime && "" != this.daterangeCreateTime) {
        this.queryParams.params["beginCreateTime"] =
          this.daterangeCreateTime[0];
        this.queryParams.params["endCreateTime"] = this.daterangeCreateTime[1];
      }
      listExamRegistration(this.queryParams).then((response) => {
        this.examRegistrationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    nativePlaceleChange(val) {
      this.form.nativePlace = val.join(",");
      console.log(val, "机关鸟");
    },
    // 表单重置
    reset() {
      this.form = {
        examRegistrationId: null,
        memberUserId: null,
        examId: null,
        name: null,
        sex: null,
        formerName: null,
        nation: null,
        identityCard: null,
        birthday: null,
        sourceType: null,
        nativePlace: null,
        politicalStatus: null,
        education: null,
        major: null,
        graduationSchool: null,
        entranceYear: null,
        contactInformation: null,
        provinceId: null,
        cityId: null,
        areaId: null,
        provinceName: null,
        cityName: null,
        areaName: null,
        address: null,
        zipCode: null,
        contactPhone: null,
        email: null,
        idPhoto: null,
        identityCardBadge: null,
        identityCardPortrait: null,
        graduationCertificate: null,
        agencyId: null,
        agencyName: null,
        careerId: null,
        careerName: null,
        examLevel: null,
        registrationBatch: null,
        studyCenterId: null,
        studyCenter: null,
        agencyCode: null,
        isInspect: null,
        signPhoto: null,
        type: null,
        examineStatus: null,
        examineFeedback: null,
        sort: null,
        remarks: null,
        status: null,
        publicationTime: null,
        publisher: null,
        createTime: null,
        createBy: null,
        updateTime: null,
        updateBy: null,
        deleteTime: null,
        deleteBy: null,
        delFlag: null,
        certificate: null,
        sendManName: null,
        sendManMobile: null,
        sendManPrintAddr: null,
        orderNo: null,
        orderPrice: null,
        payPrice: null,
        payType: null,
      };
      this.resetForm("form");
    },
    getRegionListData() {
      getRegionTreeList().then((res) => {
        this.newCity = res.data;
      });
    },
    formatPayType(row) {
      const payTypes = {
        0: "未支付",
        1: "微信",
        2: "支付宝",
        3: "线下",
        // 可以继续添加其他支付方式
      };
      return payTypes[row.payType] || "未知支付方式";
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 下载模板操作 */
    importTemplate() {
      this.download(
        "/hezhi/examRegistration/importTemplate",
        {},
        `考试报名导入模板.xlsx`
      );
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.daterangeCreateTime = [];
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.examRegistrationId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加考试报名";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const examRegistrationId = row.examRegistrationId || this.ids;
      getExamRegistration(examRegistrationId).then((response) => {
        this.form = response.data;
        this.form.nativePlace = response.data.nativePlace.split(",");
        this.form.entranceYear = response.data.entranceYear.split(",");
        this.open = true;
        this.title = "修改考试报名";
        //判断是否有市Id和区Id
        if (this.form.provinceId && this.form.cityId) {
          //获取市
          this.loading = true;
          getCityOrArea(this.form.provinceId).then((response) => {
            this.getCityOrAreaList = response.data.data;
            this.loading = false;
          });
          this.loading = false;
        }
        if (this.form.provinceId && this.form.cityId && this.form.areaId) {
          //获取区
          this.loading = true;
          getCityOrArea(this.form.cityId).then((response) => {
            this.getCityOrAreacityList = response.data.data;
            this.loading = false;
          });
          this.loading = false;
        }
      });
    },
    /** 提交按钮 */
    submitForm() {
      console.log(this.form);

      this.$refs["form"].validate((valid) => {
        if (valid) {
          //判断entranceYear是否是数组
          if (Array.isArray(this.form.entranceYear)) {
            // 如果是数组，则直接使用
            this.form.entranceYear = this.form.entranceYear.join(",");
          }
          //判断nativePlace是否是数组
          if (Array.isArray(this.form.nativePlace)) {
            this.form.nativePlace = this.form.nativePlace.join(",");
          }
          if (this.form.examRegistrationId != null) {
            updateExamRegistration(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addExamRegistration(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const examRegistrationIds = row.examRegistrationId || this.ids;
      this.$modal
        .confirm(
          '是否确认删除考试报名编号为"' + examRegistrationIds + '"的数据项？'
        )
        .then(function () {
          return delExamRegistration(examRegistrationIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "hezhi/examRegistration/export",
        {
          ...this.queryParams,
        },
        `考试报名导出.xlsx`
      );
    },
    /** 导入按钮操作 */
    handleImport() {
      this.upload.title = "考试报名导入";
      this.upload.dateTime = null;
      this.upload.open = true;
    },
    // 文件上传中处理
    handleFileUploadProgress(event, file, fileList) {
      this.upload.isUploading = true;
    },
    // 文件上传成功处理
    handleFileSuccess(response, file, fileList) {
      this.upload.open = false;
      this.upload.isUploading = false;
      this.$refs.upload.clearFiles();
      this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
      this.getList();
    },
    // 提交上传文件
    submitFileForm() {
      this.$refs.upload.submit();
    },
    handleCertificate(row) {
      this.reset();
      const examRegistrationId = row.examRegistrationId;
      getExamRegistrationFahuo(examRegistrationId).then((response) => {
        this.form = response.data;
        this.sendOpen = true;
      });
    },
    submitFormSend() {
      if (this.form.certificateStatus !== 1) {
        this.$modal.msgWarning("不是待发货状态，发货失败");
        return;
      }
      certificateSend(this.form).then((response) => {
        this.$modal.msgSuccess("修改成功");
        this.sendOpen = false;
        this.getList();
      });
    },
    cancelSend() {
      this.sendOpen = false;
      this.reset();
    },
    changeOp(e) {
      console.log(e, "e");
      this.form.careerName = "";
      this.form.registrationBatch = "";
      this.form.examLevel = "";
      this.form.studyCenter = "";
      this.agencyList.forEach((item, index) => {
        if (item.evaluateAgencyName == e) {
          this.form.agencyId = item.evaluateAgencyId;
          this.evaluateAgency = item.evaluateAgencyId;
          this.form.agencyCode = item.evaluateAgencyCode;
        }
      });
      this.getCourseListByEvaluateAgencyData();
    },
    changeOc(e) {
      console.log(e, this.classMapList);

      this.classMapList.forEach((item, index) => {
        if (item.courseId == e) {
          this.form.courseId = item.courseId;
          this.form.registrationBatch = item.examBatch;
          this.form.examLevel = item.level;
          this.form.careerName = item.courseName;
          this.form.examId = item.examId;
          this.form.studyCenter = "";
        }
      });
      this.getStudyListByCourseData();
    },
    StuChange(e) {
      this.studyCenterList.forEach((item) => {
        if (e == item.studyCenterName) {
          this.form.studyCenterId = item.studyCenterId;
          this.form.studyCenterTeacherList = item.studyCenterTeacherList;
        }
      });
    },
    getGetEvaluateAgencyListData() {
      request({
        url: "/api/list/getEvaluateAgencyList",
        method: "get",
      }).then((res) => {
        // let arr = this.agencyList.concat(res.data);
        let arr = res.data.concat(this.agencyList);
        this.agencyList = arr;
      });
    },
    getCourseListByEvaluateAgencyData() {
      request({
        url: "/api/pc/getCourseListByEvaluateAgency",
        method: "get",
        params: {
          evaluateAgencyId: this.evaluateAgency,
        },
      }).then((res) => {
        this.classMapList = res.data;
      });
    },
    getStudyListByCourseData() {
      request({
        url: "/api/pc/getStudyListByCourse",
        method: "get",
        params: {
          courseId: this.form.courseId,
        },
      }).then((res) => {
        this.studyCenterList = res.data;
      });
    },
    getGetDictParamListData() {
      request({
        url: "/api/class/getDictParamList",
        method: "get",
        params: {
          paramType: "tb_exam_level",
        },
      }).then((res) => {
        this.paramList = res.data;
        this.form.examLevel = res.data[res.data.length - 1].dictValue;
      });
    },
    getgrade(e) {
      console.log(e);

      this.form.examLevel = e;
      this.$forceUpdate();
      // window.location.reload();
    },

    // 获取省
    getProvince() {
      this.loading = true;
      getProvince(this.queryParams).then((response) => {
        this.getProvinceList = response.data.data;
        this.loading = false;
      });
      this.loading = false;
    },
    // 获取市
    getCityOrArea() {
      this.loading = true;
      //清除市数据
      this.form.cityId = null;
      this.form.cityName = null;
      this.form.areaId = null;
      this.form.areaName = null;
      let ida = this.form.provinceId || this.queryParams.provinceId;
      getCityOrArea(ida).then((response) => {
        this.getCityOrAreaList = response.data.data;
        this.loading = false;
      });
      this.loading = false;
    },
    //区
    getCityOrAreacity() {
      this.loading = true;
      this.form.areaId = null;
      this.form.areaName = null;
      let ida = this.form.cityId || this.queryParams.cityId;
      getCityOrArea(ida).then((response) => {
        this.getCityOrAreacityList = response.data.data;
        this.loading = false;
      });
      this.loading = false;
    },
  },
};
</script>
<style lang="scss">
.el-year-table .today .cell {
  color: #606266 !important;
  font-weight: 100 !important;
}
.item {
  margin: 4px;
}
.text_ellispsis {
  // width: 200px; /* 限制宽度 */
  white-space: nowrap; /* 禁止换行 */
  overflow: hidden; /* 超出部分隐藏 */
  text-overflow: ellipsis; /* 显示省略号 */
}
</style>
