<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="90px">
      <el-form-item label="期次" prop="qi">
        <el-cascader v-model="queryParams.qi" placeholder="请选择期次" :props="prop" :options="options" @change="handleChange">
			<template slot-scope="{ node, data }">
			    <span v-if="data.children != null">{{ data.year+'年' }}</span>
			    <span v-else> {{ '第 '+data.year+' 期' }} </span>
			</template>
		  </el-cascader>
      </el-form-item>
      <el-form-item label="培训类别" prop="ZYIdList">
        <el-select v-model="queryParams.ZYIdList" placeholder="请选择培训类别" clearable>
          <el-option v-for="dict in dict.type.jxjy_zhuanye" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label-width="50px" label="地点" prop="City">
        <el-select v-model="queryParams.City" placeholder="请选择地点" clearable>
          <el-option v-for="dict in dict.type.zgks_address" :key="dict.value" :label="dict.label" :value="dict.value" />
        </el-select>
      </el-form-item>
      <el-form-item label-width="50px" label="姓名" prop="UserName">
        <el-input v-model="queryParams.UserName" placeholder="请输入姓名" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label-width="60px" label="身份证" prop="UserCord">
        <el-input v-model="queryParams.UserCord" placeholder="请输入身份证" clearable @keyup.enter.native="handleQuery" />
      </el-form-item>
      <!-- <el-form-item label="审核状态" prop="pxshenhe">
        <el-select v-model="queryParams.pxshenhe" placeholder="请选择审核状态" clearable>
          <el-option :label="'待审核'" :value="0" />
          <el-option :label="'审核通过'" :value="1" />
          <el-option :label="'不通过'" :value="2" />
          <el-option :label="'材料补正'" :value="3" />
        </el-select>
      </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="['zgks:ZigePerson: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="['zgks:ZigePerson: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="['zgks:ZigePerson:remove']">删除</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-download" size="mini" @click="handleExport">导出</el-button>
        <!-- v-hasPermi="['zgks:ZigePerson:export']" -->
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane :label="'待审核 (' + daishenhe + ')'" name="first">
        <el-table v-loading="loading" :data="ZigePersonList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="45" align="center" />
          <el-table-column label="报名表" width="80" align="center" prop="">
            <template slot-scope="scope">
              <el-button plain @click="handleDownload(scope.row)" size="mini" type="primary">下载</el-button>
              <!-- <span>{{
            scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
          }}</span> -->
            </template>
          </el-table-column>
          <el-table-column label="序号" width="80" align="center" prop="PersonId">
            <template slot-scope="scope">
              {{ getXvhao(scope.$index, queryParams) }}
            </template>
          </el-table-column>
          <el-table-column width="130" label="期次" align="center" prop="ZYIdList">
            <template slot-scope="scope">
              <span>{{
                scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column label="地点" width="60" align="center" prop="ZYIdList">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.zgks_address" :value="scope.row.City" />
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center" prop="UserName">
            <template slot-scope="scope">
              <el-button type="text" @click="handleUpdate(scope.row, false)">{{
                scope.row.UserName
              }}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="性别" width="50" align="center" prop="UserSex" />
          <el-table-column label="身份证" align="center" width="170" prop="UserCord" />
          <el-table-column label="手机号码" align="center" width="110" prop="UserPhone" />
          <el-table-column width="110" label="培训类别" align="center">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.jxjy_zhuanye" :value="scope.row.ZYIdList" />
            </template>
          </el-table-column>
          <el-table-column width="250" label="执业单位" align="center" prop="DeptName" />
          <el-table-column label="报名时间" width="150" align="center" prop="AddDate">
            <template slot-scope="scope">
              {{ parseTime(scope.row.AddDate, "{y}-{m}-{d} {h}:{i}:{s}") }}
            </template>
          </el-table-column>
          <el-table-column width="100" label="企业审核状态" align="center" prop="grshenhe">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.grshenhe == 0">未审核</el-tag>
              <el-tag type="success" v-if="scope.row.grshenhe == 1">审核通过</el-tag>
              <el-tag type="danger" v-if="scope.row.grshenhe == 2">已撤回</el-tag>
              <el-tag type=""
                v-if="scope.row.grshenhe != 0 && scope.row.grshenhe != 2 && scope.row.grshenhe != 1"></el-tag>
              <!-- {{
                scope.row.grshenhe == 0
                ? "未审核"
                : scope.row.grshenhe == 1
                  ? "审核通过" : scope.row.grshenhe == 2 ?
                    "已撤回" : ''
              }} -->
            </template>
          </el-table-column>
          <el-table-column label="培训点审核状态" width="120" align="center" prop="pxshenhe">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.pxshenhe == 0">待审核</el-tag>
              <el-tag type="success" v-if="scope.row.pxshenhe == 1">审核通过</el-tag>
              <el-popover v-else-if="scope.row.pxshenhe == 2" placement="left" width="200" trigger="hover">
                <template slot="reference">
                  <el-tag type="danger">不通过(原因)</el-tag>
                </template>
                <div v-html="scope.row.pxshyj"></div>
              </el-popover>
              <el-tag type="warning" v-if="scope.row.pxshenhe == 3">材料补正</el-tag>
            </template>
          </el-table-column>
          <el-table-column fixed="right" width="170" label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <!-- <el-button size="mini" type="text" icon="el-icon-s-check" @click="shenhe(scope.row)"
                v-if="scope.row.grshenhe != 1">审核</el-button> -->
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row, true)"
                v-if="scope.row.grshenhe != 1">查看</el-button>
              <el-button style="color: #f56c6c" size="mini" type="text" icon="el-icon-sort-down"
                @click="chehui(scope.row)" v-if="scope.row.pxshenhe != 1 && scope.row.grshenhe == 1">撤回</el-button>
              <el-button style="color: #f56c6c" size="mini" type="text" icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-if="scope.row.grshenhe != 1 && scope.row.pxshenhe != 1 && scope.row.grshenhe != 2">删除</el-button>
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row, false)"
                v-if="scope.row.grshenhe == 1 && scope.row.pxshenhe == 1">详细</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>
      <el-tab-pane :label="'已审核 (' + yishenhe + ')'" name="second">
        <el-table v-loading="loading" :data="ZigePersonList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="45" align="center" />
          <el-table-column label="报名表" width="80" align="center" prop="">
            <template slot-scope="scope">
              <el-button plain @click="handleDownload(scope.row)" size="mini" type="primary">下载</el-button>
              <!-- <span>{{
            scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
          }}</span> -->
            </template>
          </el-table-column>
          <el-table-column label="序号" width="80" align="center" prop="PersonId">
            <template slot-scope="scope">
              {{ getXvhao(scope.$index, queryParams) }}
            </template>
          </el-table-column>
          <el-table-column width="130" label="期次" align="center" prop="ZYIdList">
            <template slot-scope="scope">
              <span>{{
                scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column label="地点" width="60" align="center" prop="ZYIdList">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.zgks_address" :value="scope.row.City" />
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center" prop="UserName">
            <template slot-scope="scope">
              <el-button type="text" @click="handleUpdate(scope.row, false)">{{
                scope.row.UserName
              }}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="性别" width="50" align="center" prop="UserSex" />
          <el-table-column label="身份证" align="center" width="170" prop="UserCord" />
          <el-table-column label="手机号码" align="center" width="110" prop="UserPhone" />
          <el-table-column width="110" label="培训类别" align="center">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.jxjy_zhuanye" :value="scope.row.ZYIdList" />
            </template>
          </el-table-column>
          <el-table-column width="250" label="执业单位" align="center" prop="DeptName" />
          <el-table-column label="报名时间" width="150" align="center" prop="AddDate">
            <template slot-scope="scope">
              {{ parseTime(scope.row.AddDate, "{y}-{m}-{d} {h}:{i}:{s}") }}
            </template>
          </el-table-column>
          <el-table-column width="100" label="企业审核状态" align="center" prop="grshenhe">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.grshenhe == 0">未审核</el-tag>
              <el-tag type="success" v-if="scope.row.grshenhe == 1">审核通过</el-tag>
              <el-tag type="danger" v-if="scope.row.grshenhe == 2">已撤回</el-tag>
              <el-tag type=""
                v-if="scope.row.grshenhe != 0 && scope.row.grshenhe != 2 && scope.row.grshenhe != 1"></el-tag>

              <!-- {{
                scope.row.grshenhe == 0
                ? "未审核"
                : scope.row.grshenhe == 1
                  ? "审核通过" : scope.row.grshenhe == 2 ?
                    "已撤回" : ''
              }} -->
            </template>
          </el-table-column>
          <el-table-column label="培训点审核状态" width="120" align="center" prop="pxshenhe">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.pxshenhe == 0">待审核</el-tag>
              <el-tag type="success" v-if="scope.row.pxshenhe == 1">审核通过</el-tag>
              <el-popover v-else-if="scope.row.pxshenhe == 2" placement="left" width="200" trigger="hover">
                <template slot="reference">
                  <el-tag type="danger">不通过(原因)</el-tag>
                </template>
                <div v-html="scope.row.pxshyj"></div>
              </el-popover>
              <el-tag type="warning" v-if="scope.row.pxshenhe == 3">材料补正</el-tag>
            </template>
          </el-table-column>
          <el-table-column fixed="right" width="170" label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <el-button size="mini" type="text" icon="el-icon-s-check" @click="shenhe(scope.row)"
                v-if="scope.row.grshenhe != 1">审核</el-button>
              <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row, true)"
                v-if="scope.row.grshenhe != 1">修改</el-button>
              <el-button style="color: #f56c6c" size="mini" type="text" icon="el-icon-sort-down"
                @click="chehui(scope.row)" v-if="scope.row.pxshenhe != 1 && scope.row.grshenhe == 1">撤回</el-button>
              <el-button style="color: #f56c6c" size="mini" type="text" icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-if="scope.row.grshenhe != 1 && scope.row.pxshenhe != 1 && scope.row.grshenhe != 2">删除</el-button>
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row, false)"
                v-if="scope.row.grshenhe == 1 && scope.row.pxshenhe == 1">详细</el-button>
            </template>
          </el-table-column>
        </el-table></el-tab-pane>
      <el-tab-pane :label="'已撤回 (' + yichexiao + ')'" name="third">
        <el-table v-loading="loading" :data="ZigePersonList" @selection-change="handleSelectionChange">
          <el-table-column type="selection" width="45" align="center" />
          <el-table-column label="报名表" width="80" align="center" prop="">
            <template slot-scope="scope">
              <el-button plain @click="handleDownload(scope.row)" size="mini" type="primary">下载</el-button>
              <!-- <span>{{
            scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
          }}</span> -->
            </template>
          </el-table-column>
          <el-table-column label="序号" width="80" align="center" prop="PersonId">
            <template slot-scope="scope">
              {{ getXvhao(scope.$index, queryParams) }}
            </template>
          </el-table-column>
          <el-table-column width="130" label="期次" align="center" prop="ZYIdList">
            <template slot-scope="scope">
              <span>{{
                scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
              }}</span>
            </template>
          </el-table-column>
          <el-table-column label="地点" width="60" align="center" prop="ZYIdList">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.zgks_address" :value="scope.row.City" />
            </template>
          </el-table-column>
          <el-table-column label="姓名" align="center" prop="UserName">
            <template slot-scope="scope">
              <el-button type="text" @click="handleUpdate(scope.row, false)">{{
                scope.row.UserName
              }}</el-button>
            </template>
          </el-table-column>
          <el-table-column label="性别" width="50" align="center" prop="UserSex" />
          <el-table-column label="身份证" align="center" width="170" prop="UserCord" />
          <el-table-column label="手机号码" align="center" width="110" prop="UserPhone" />
          <el-table-column width="110" label="培训类别" align="center">
            <template slot-scope="scope">
              <dict-tag :options="dict.type.jxjy_zhuanye" :value="scope.row.ZYIdList" />
            </template>
          </el-table-column>
          <el-table-column width="250" label="执业单位" align="center" prop="DeptName" />
          <el-table-column label="报名时间" width="150" align="center" prop="AddDate">
            <template slot-scope="scope">
              {{ parseTime(scope.row.AddDate, "{y}-{m}-{d} {h}:{i}:{s}") }}
            </template>
          </el-table-column>
          <el-table-column width="100" label="企业审核状态" align="center" prop="grshenhe">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.grshenhe == 0">未审核</el-tag>
              <el-tag type="success" v-if="scope.row.grshenhe == 1">审核通过</el-tag>
              <el-tag type="danger" v-if="scope.row.grshenhe == 2">已撤回</el-tag>
              <el-tag type=""
                v-if="scope.row.grshenhe != 0 && scope.row.grshenhe != 2 && scope.row.grshenhe != 1"></el-tag>
              <!-- {{
                scope.row.grshenhe == 0
                ? "未审核"
                : scope.row.grshenhe == 1
                  ? "审核通过" : scope.row.grshenhe == 2 ?
                    "已撤回" : ''
              }} -->
            </template>
          </el-table-column>
          <el-table-column label="培训点审核状态" width="120" align="center" prop="pxshenhe">
            <template slot-scope="scope">
              <el-tag type="primary" v-if="scope.row.pxshenhe == 0">待审核</el-tag>
              <el-tag type="success" v-if="scope.row.pxshenhe == 1">审核通过</el-tag>
              <el-popover v-else-if="scope.row.pxshenhe == 2" placement="left" width="200" trigger="hover">
                <template slot="reference">
                  <el-tag type="danger">不通过(原因)</el-tag>
                </template>
                <div v-html="scope.row.pxshyj"></div>
              </el-popover>
              <el-tag type="warning" v-if="scope.row.pxshenhe == 3">材料补正</el-tag>

            </template>
          </el-table-column>
          <el-table-column fixed="right" width="170" label="操作" align="center" class-name="small-padding fixed-width">
            <template slot-scope="scope">
              <!-- <el-button size="mini" type="text" icon="el-icon-s-check" @click="shenhe(scope.row)"
                v-if="scope.row.grshenhe != 1">审核</el-button> -->
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row, true)"
                v-if="scope.row.grshenhe != 1">查看</el-button>
              <el-button style="color: #f56c6c" size="mini" type="text" icon="el-icon-sort-down"
                @click="chehui(scope.row)" v-if="scope.row.pxshenhe != 1 && scope.row.grshenhe == 1">撤回</el-button>
              <el-button style="color: #f56c6c" size="mini" type="text" icon="el-icon-delete"
                @click="handleDelete(scope.row)"
                v-if="scope.row.grshenhe != 1 && scope.row.pxshenhe != 1 && scope.row.grshenhe != 2">删除</el-button>
              <el-button size="mini" type="text" icon="el-icon-view" @click="handleUpdate(scope.row, false)"
                v-if="scope.row.grshenhe == 1 && scope.row.pxshenhe == 1">详细</el-button>
            </template>
          </el-table-column>
        </el-table></el-tab-pane>
    </el-tabs>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 添加或修改资格考试报名对话框 -->
    <el-dialog top="3vh" title="报名信息" :visible.sync="open" width="1250px" :close-on-click-modal="false" destroy-on-close>
      <div style="
          height: 74vh;
          overflow-y: auto;
          overflow-x: hidden;
          padding-top: 0;
        " class="pd-10">
        <component ref="zgks" :is="zgks" :info="zgksInfo" :type="1" :xiugai="xiugaiType" @submitSuccess="submitSuccess">
        </component>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm"
          v-if="(activeName == 'first' && baocunType == true) || activeName == 'third'">保
          存</el-button>
        <el-button type="primary" @click="shenhe" v-if="xiugaiType == true">审核通过</el-button>
        <el-button @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listZigePerson,
  getZigePerson,
  delZigePerson,
  addZigePerson,
  updateZigePerson,
  zgksShenhe,
  downloadZigePerson
} from "@/api/xiehui/zgks/ZigePerson";
import { searchZgksQici } from "@/api/xiehui/zgks/ZigeTraining"
import jly from "../../../components/baoming/jly.vue";
import zj from "../../../components/baoming/zj.vue";
import jlgcs from "../../../components/baoming/jlgcs.vue";
export default {
  name: "ZigePerson",
  dicts: ["jxjy_shenhe", "jxjy_zhuanye", "zgks_address"],
  components: {
    jly,
    zj,
    jlgcs,
  },
  data() {
    return {
      baocunType: true,
      activeName: "first",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 资格考试报名表格数据
      ZigePersonList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        UserName: null,
        UserCord: null,
        QiciYear: null,
        QiCi: null,
        City: null,
        ZYIdList: null,
        BMdept: null,
        grshenhe: 0,
        orderByColumn: "adddate",
        isAsc: "desc",
        qi: null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {},
      zgks: null,
      zgksInfo: null,
      xiugaiType: false,
      daishenhe: 0,
      yishenhe: 0,
      yichexiao: 0,
      options: [],
      prop: {
        label: "year",
        value: "year"
      }
    };
  },
  created() {
    this.queryParams.BMdept = this.$store.getters.userInfo.id
    this.qiciSearch()
    this.getList();
  },
  methods: {
    qiciSearch() {
      searchZgksQici().then(res => {
        this.options = res.data
      })
    },
    //选择期次
    handleChange(e) {
      this.queryParams.QiciYear = e[0]
      this.queryParams.QiCi = e[1]
    },
    handleDownload(row) {
      window.open(process.env.VUE_APP_BASE_API + "/zgks/ZigePerson/download/person/" + row.PersonId);
    },
    /** 查询资格考试报名列表 */
    getList() {
      this.loading = true;
      listZigePerson(this.queryParams).then((response) => {
        this.ZigePersonList = response.rows;
        this.total = response.total;
        this.loading = false;
        this.daishenhe = response.extendMap.undototal
        this.yishenhe = response.extendMap.passtotal
        this.yichexiao = response.extendMap.backtotal
      });
    },

    // 表单重置
    reset() {
      this.form = {
        PersonId: null,
        TrainId: null,
        ZYIdList: null,
        UserName: null,
        UserPwd: null,
        UserSex: null,
        UserCord: null,
        UserDate: null,
        UserPhone: null,
        UserEmail: null,
        City: null,
        ZcsZhuanYe: null,
        ZhuanYeType: null,
        Zsbh: null,
        Yxqz: null,
        BMdept: null,
        DeptName: null,
        DeptTel: null,
        DeptLxr: null,
        DeptLxrPhone: null,
        DeptEmail: null,
        DeptAddress: null,
        DeptZipcode: null,
        FeeFlg: null,
        Bzq: null,
        AddDate: null,
        OverFlg: null,
        QianFaDate: null,
        BeiZhu: null,
        ShenHe: null,
        PeiXunFlg: null,
        Undef1: null,
        Undef2: null,
        Undef3: null,
        Undef4: null,
        Undef5: null,
        wanchengflg: null,
        zongxueshi: null,
        BYschool: null,
        xueli: null,
        zhicheng: null,
        ZCpizhunDept: null,
        minzu: null,
        zygznx: null,
        jlgznx: null,
        zcpdsj: null,
        sxzy: null,
        zhiwu: null,
        bmfs: null,
        grshenhe: null,
        pxshenhe: null,
        pxshyj: null,
        zhichengZhuanYe: null,
        BYTime: null,
        KplxFlg: null,
        KpGRName: null,
        kpzcdz: null,
        kpzcdh: null,
        kpkhyh: null,
        kpyhzh: null,
        kpGRemail: null,
        dzfpyx: null,
        sjr: null,
        sjrsj: null,
        yjdz: null,
        yjbm: null,
        kplx: null,
        kpfs: null,
        kpdw: null,
        nsrsbh: null,
        zsyxq: null,
        zgzsh: null,
        sfsgz: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      this.resetForm("form");
    },
    handleClick(tab, event) {
      console.log(tab, event);
      if (tab.name == "first") {
        this.queryParams.grshenhe = 0
        this.getList()
      } else if (tab.name == "second") {
        this.queryParams.grshenhe = 1
        this.getList()
      } else if (tab.name == "third") {
        this.queryParams.grshenhe = 2
        this.getList()
      }
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm")
      this.queryParams.QiciYear = null
      this.queryParams.QiCi = null
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.PersonId);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加资格考试报名";
    },
    /** 修改按钮操作 */
    handleUpdate(row, type) {

      this.reset();
      this.form = { ...row };
      const PersonId = row.PersonId || this.ids;
      if (type == undefined) {
        this.xiugaiType = true
      } else {
        this.xiugaiType = type
        this.baocunType = type
      }
      // this.xiugaiType = type == undefined ? true : false;
      this.loading = true;
      getZigePerson(PersonId).then((response) => {
        console.log("?? ~ getZigePerson ~ response.data:", response.data)
        this.form = response.data;
        if (response.data.ZcsZhuanYe == "8" || response.data.ZcsZhuanYe == "监理工程师") {
          this.zgks = "jlgcs";
        } else if (response.data.ZcsZhuanYe == "28" || response.data.ZcsZhuanYe == "监理员") {
          this.zgks = "jly";
        } else {
          this.zgks = "zj";
        }
        this.zgksInfo = response.data;
        console.log("?? ~ getZigePerson ~ response.data:", response.data)
        this.loading = false;
        this.open = true;
      });
    },
    //审核
    shenhe() {
      // this.reset();
      // this.form = { ...row };
      // this.submitForm()

      this.form.grshenhe = 1;
      zgksShenhe(this.form)
        .then((response) => {
          this.$modal.msgSuccess("审核成功");
          this.open = false;
          this.getList();
        })
      // this.$msgbox({
      //   title: "提示",
      //   message: "审核通过？",
      //   showCancelButton: true,
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   beforeClose: (action, instance, done) => {
      //     if (action === "confirm") {
      //       instance.confirmButtonLoading = true;
      //       instance.confirmButtonText = "执行中...";
      //       this.form.grshenhe = 1;
      //       zgksShenhe(this.form)
      //         .then((response) => {
      //           done();
      //           setTimeout(() => {
      //             instance.confirmButtonLoading = false;
      //             this.$modal.msgSuccess("审核成功");
      //           }, 300);
      //           this.getList();
      //         })
      //         .catch((error) => {
      //           done();
      //           instance.confirmButtonLoading = false;
      //         });
      //     } else {
      //       done();
      //     }
      //   },
      // });
    },
    //撤回
    chehui(row) {
      this.reset();
      // const PersonId = row.PersonId || this.ids
      // getZigePerson(PersonId).then(response => {
      // this.form = response.data;
      this.form = { ...row };
      this.$msgbox({
        title: "提示",
        message: "确认撤回吗？",
        showCancelButton: true,
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        beforeClose: (action, instance, done) => {
          if (action === "confirm") {
            instance.confirmButtonLoading = true;
            instance.confirmButtonText = "执行中...";
            this.form.grshenhe = 2;
            zgksShenhe(this.form)
              .then((response) => {
                done();
                setTimeout(() => {
                  instance.confirmButtonLoading = false;
                  this.$modal.msgSuccess("撤回成功");
                }, 300);
                this.getList();
              })
              .catch((error) => {
                done();
                instance.confirmButtonLoading = false;
              });
          } else {
            done();
          }
        },
      });
      // });
    },
    changeYear() {
      if (this.queryParams.QiciYear == null) {
        this.queryParams.QiCi = null
      }
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs.zgks.submit();
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const PersonIds = row.PersonId || this.ids;
      this.$modal
        .confirm('是否确认删除"' + row.UserName + '"的报名信息？')
        .then(function () {
          return delZigePerson(PersonIds);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => { });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "/zgks/ZigePerson/qyExport",
        {
          ...this.queryParams,
        },
        `培训报名汇总表_${new Date().getTime()}.xlsx`
      );
    },
    //修改提交成功回调
    submitSuccess(e) {
      this.$refs.zgks.reset();
      // this.open = false;
      this.getList();
    },
    // 取消按钮
    cancel() {
      this.$refs.zgks.reset();
      this.open = false;
    },
  },
};
</script>
<style scoped>
.el-form-item--small.el-form-item {
  margin-bottom: 6px;
}
</style>
