<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
			<el-form-item label="培训类别" prop="ZcsZhuanYe">
				<el-select v-model="queryParams.ZcsZhuanYe" 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="培训名称" prop="TrainName">
				<el-input v-model="queryParams.TrainName" placeholder="请输入计划名称" clearable
					@keyup.enter.native="handleQuery" />
			</el-form-item>

			<!-- <el-form-item label="审核状态" prop="ShenHe">
				<el-select v-model="queryParams.ShenHe" placeholder="请选择审核状态" clearable>
					<el-option v-for="dict in dict.type.jxjy_shenhe" :key="dict.value" :label="dict.label"
						:value="dict.value" />
				</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" v-hasRole="['xiehui']">
			<el-col :span="1.5">
				<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd">新增</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single"
					@click="handleUpdate">修改</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple">删除</el-button>
			</el-col>
			<right-toolbar @queryTable="getList"></right-toolbar>
		</el-row>
		<el-table v-loading="loading" :data="ZigeTrainingList" @selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55" align="center"/>
			<el-table-column label="期次" width="110" align="center" prop="QiCi">
				<template slot-scope="scope">
					{{ scope.row.QiciYear + "年第" + scope.row.QiCi + "期" }}
				</template>
			</el-table-column>
			<el-table-column width="110" label="培训类别" align="center" prop="ZcsZhuanYe">
				<template slot-scope="scope">
					<dict-tag :options="dict.type.jxjy_zhuanye" :value="scope.row.ZcsZhuanYe" />
				</template>
			</el-table-column>
			<el-table-column label="培训计划名称" align="center" prop="TrainName" width="300" />
			<el-table-column label="培训起止日期" align="center" prop="StartDate" width="300">
				<template slot-scope="scope">
					<span>{{ parseTime(scope.row.StartDate, "{y}-{m}-{d}") }}</span>至
					<span>{{ parseTime(scope.row.EndDate, "{y}-{m}-{d}")}}</span>
				</template>
			</el-table-column>
			<el-table-column label="培训地点" align="center" prop="dishi"
				v-if="roles.indexOf('xiehui') != -1 || roles.indexOf('admin') != -1" />
			<el-table-column label="报名上限(人)" align="center" prop="BmNumMax" />
			<el-table-column label="已报人数(人)" align="center" prop="BmNum" />
			<el-table-column label="审核状态" width="80" align="center" prop="ShenHe"
				v-if="roles.indexOf('xiehui') != -1 || roles.indexOf('admin') != -1">
				<template slot-scope="scope">
					<el-switch v-model="scope.row.ShenHe" active-value="1" inactive-value="0"
						@change="handleStatusChange(scope.row)"></el-switch>
				</template>
			</el-table-column>
			<!-- <el-table-column label="操作" width="100" align="center" class-name="small-padding fixed-width"
				v-if="roles.indexOf('xiehui') != -1 || roles.indexOf('admin') != -1">
				<template slot-scope="scope">
					<el-button size="mini" type="text" icon="el-icon-edit"
						@click="handleUpdate(scope.row)">修改</el-button>
					<el-button size="mini" type="text" icon="el-icon-delete" style="color: #f56c6c"
						@click="handleDelete(scope.row)">删除</el-button>
				</template>
			</el-table-column> -->
			<el-table-column label="报名人员" align="center" class-name="small-padding fixed-width">
				<template slot-scope="scope">
					<el-button size="mini" type="text" icon="el-icon-view" @click="seePeo(scope.row)">查看</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="1200px" top="4vh" append-to-body>
			<el-form ref="form" :model="form" :rules="rules" label-width="120px">
				<el-row :gutter="20">
					<el-col :span="6">
						<el-form-item label="培训类别" prop="ZcsZhuanYe">
							<el-select v-model="form.ZcsZhuanYe" placeholder="请选择培训类别">
								<el-option v-for="dict in dict.type.jxjy_zhuanye" :key="dict.value" :label="dict.label"
									:value="dict.value"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="6">
						<el-form-item label-width="80px" label="培训专业" prop="ZhuanYeType">
							<el-select v-model="form.ZhuanYeType" placeholder="请选择培训专业">
								<el-option v-for="dict in dict.type.jxjy_pxzy" :key="dict.value" :label="dict.label"
									:value="dict.value"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
					<el-col :span="12">
						<el-form-item style="display: inline-block; " label=" 期次（年）" label-width="100px"
							prop="QiciYear">
							<el-date-picker format="yyyy" value-format="yyyy" v-model="form.QiciYear" type="year"
								placeholder="请选择期次（年）" @change="changeYearForm">
							</el-date-picker>
							<span style="display: inline-block; margin: 0 10px 0 15px">-</span>
						</el-form-item>
						<el-form-item style="display: inline-block" label-width="0" prop="QiCi">
							<el-input v-model="form.QiCi" :disabled="form.QiciYear == null" placeholder="期次"
								type="number" min="0"></el-input>
						</el-form-item>
						<!-- <el-form-item label="期次" prop="QiciYear">
                  <div class="flex-ac">
                    <el-input v-model="form.QiciYear" placeholder="请输入年" />年
                  </div>
                </el-form-item>
              </el-col>
              <el-col :span="11">
                <el-form-item label-width="40px" label="第" prop="QiCi">
                  <div class="flex-ac">
                    <el-input v-model="form.QiCi" placeholder="请输入期次" />
                    &nbsp;期
                  </div>
                </el-form-item> -->

					</el-col>
					<el-col :span="24">
						<el-form-item label="培训计划名称" prop="TrainName">
							<el-input v-model="form.TrainName" placeholder="请输入计划名称" />
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="地点" prop="dishi">
							<div style="width: 100%" v-for="(v, i) in dict.type.zgks_address" :key="i">
								<el-checkbox v-model="checks[i]" @change="chooseAddress(i, v.label, $event)">
									<div style="
                      display: flex;
                      align-items: center;
                      margin-bottom: 18px;
                    ">
										{{ v.label }}
										<el-form-item label-width="0" style="margin-left: 20px" :prop="'xbNum.' + i"
											:rules="{
                      required: true,
                      validator: (rule, value, callback) => {
                        if (checks[i] == true) {
                          if (!value) {
                            return callback('请填写限报人数');
                          } else {
                            callback();
                          }
                        } else {
                          callback();
                        }
                      },
                      trigger: ['blur', 'change'],
                    }">
											<el-input v-model="form.xbNum[i]" :disabled="!checks[i]" type="number"
												placeholder="请输入限报人数" />
										</el-form-item>
									</div>
								</el-checkbox>
							</div>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="培训开始时间" prop="StartDate">
							<el-date-picker @change="validateDates" clearable v-model="form.StartDate" type="date"
								value-format="yyyy-MM-dd" placeholder="请选择培训开始时间">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="培训结束时间" prop="EndDate">
							<el-date-picker @change="validateDates" clearable v-model="form.EndDate" type="date"
								value-format="yyyy-MM-dd" placeholder="请选择培训结束时间">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="8">
						<el-form-item label="报名截止日期" prop="BmEndDate">
							<el-date-picker @change="validateDates" clearable v-model="form.BmEndDate" type="date"
								value-format="yyyy-MM-dd" placeholder="请选择报名截止时间">
							</el-date-picker>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="附件">
							<FileUpload v-model="form.TongZhi"></FileUpload>
						</el-form-item>
					</el-col>
					<el-col :span="24">
						<el-form-item label="是否审核" prop="ShenHe">
							<el-select v-model="form.ShenHe" placeholder="请选择是否审核">
								<el-option v-for="dict in dict.type.jxjy_shenhe" :key="dict.value" :label="dict.label"
									:value="dict.value"></el-option>
							</el-select>
						</el-form-item>
					</el-col>
				</el-row>
			</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="peoShow" append-to-body fullscreen>

			<div>
				<el-form :model="peoData" ref="peoData" size="small" :inline="true" label-width="90px">
					<el-form-item label="姓名" prop="UserName">
						<el-input v-model="peoData.UserName" placeholder="请输入姓名" clearable
							@keyup.enter.native="handleQuery" />
					</el-form-item>
					<el-form-item label="身份证" prop="UserCord">
						<el-input v-model="peoData.UserCord" placeholder="请输入身份证" clearable
							@keyup.enter.native="handleQuery" />
					</el-form-item>
					<el-form-item label="地点" prop="City">
						<el-select v-model="peoData.City" placeholder="请选择地点" clearable>
							<el-option v-for="dict in dict.type.zgks_address" :key="dict.value" :label="dict.label"
								:value="dict.label" />
						</el-select>
					</el-form-item>
					<el-form-item label="执业单位" prop="DeptName">
						<el-input v-model="peoData.DeptName" placeholder="请输入执业单位" clearable
							@keyup.enter.native="handleQuery" />
					</el-form-item>
					<el-form-item>
						<el-button type="primary" icon="el-icon-search" size="mini"
							@click="peoHandleQuery">搜索</el-button>
						<el-button icon="el-icon-refresh" size="mini" @click="peoResetQuery">重置</el-button>
					</el-form-item>
				</el-form>
				<el-row :gutter="10" class="mb8">
					<el-col :span="1.5">
						<el-button type="primary" @click="handleImport" plain icon="el-icon-upload"
							size="mini">导入</el-button></el-col>
					<el-col :span="1.5">
						<el-button type="warning" @click="handleExportBaoming" plain icon="el-icon-download"
							size="mini">导出</el-button></el-col>
				</el-row>

				<el-table v-loading="peoLoading" :data="peoList" @selection-change="peoSelect">
					<el-table-column type="selection" width="55" align="center" />
					<el-table-column label="序号" align="center" prop="PersonId" width="55">
						<template slot-scope="scope">
							{{ getXvhao(scope.$index, queryParams) }}
						</template>
					</el-table-column>
					<el-table-column label="期次" align="center" prop="ZYIdList" width="120">
						<template slot-scope="scope">
							<span>{{
                scope.row.QiciYear + "年 第" + scope.row.QiCi + "期"
              }}</span>
						</template>
					</el-table-column>
					<el-table-column label="地点" align="center" prop="ZYIdList" width="55">
						<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" width="100">
						<template slot-scope="scope">
							<el-button type="text" @click="getPeoInfo(scope.row, false)">{{
                scope.row.UserName
              }}</el-button>
						</template>
					</el-table-column>
					<el-table-column label="性别" align="center" prop="UserSex" width="55" />
					<el-table-column label="身份证" align="center" prop="UserCord" width="175" />
					<el-table-column label="手机号码" align="center" prop="UserPhone" />
					<el-table-column 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 label="执业单位" align="center" prop="DeptName" width="200" />
					<el-table-column label="报名时间" align="center" prop="UserPwd">
						<template slot-scope="scope">
							{{ parseTime(scope.row.AddDate, "{y}-{m}-{d}") }}
						</template>
					</el-table-column>
					<el-table-column label="是否参加培训" align="center" prop="pxshenhe">
						<template slot-scope="scope">
							{{ scope.row.PeiXunFlg == 1 ? "已参加" : "未参加" }}
						</template>
					</el-table-column>
					<el-table-column label="考试是否通过" align="center" prop="OverFlg">
						<template slot-scope="scope">
							{{ scope.row.OverFlg == 1 ? "通过" : "未通过" }}
						</template>
					</el-table-column>
					<el-table-column label="培训点审核" align="center" prop="pxshenhe">
						<template slot-scope="scope">
							{{
                scope.row.pxshenhe == null || scope.row.pxshenhe == 0
                ? ""
                : scope.row.pxshenhe == 2
                  ? "不通过"
                  : scope.row.pxshenhe == 1
                    ? "审核通过"
                    : "材料补正"
              }}
						</template>
					</el-table-column>
					<el-table-column label="原因" align="center" prop="pxshyj">
					</el-table-column>
					<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
						<template slot-scope="scope">
							<el-button size="mini" type="text" icon="el-icon-s-check" v-if="scope.row.grshenhe == null ||
                      scope.row.grshenhe == 1 ||
                      scope.row.pxshenhe == 0
                      " @click="shenhe(scope.row, false)">审核</el-button>
							<el-button size="mini" type="text" icon="el-icon-delete" style="color: #f56c6c"
								@click="handleUpdate(scope.row, false)">删除</el-button>
						</template>
					</el-table-column>
				</el-table>
				<pagination v-show="peoTotal > 0" :total="peoTotal" :page.sync="peoData.pageNum"
					:limit.sync="peoData.pageSize" @pagination="getPeoList" />
			</div>
		</el-dialog>
		<el-dialog top="3vh" title="不通过原因" :visible.sync="shenheShow" width="40%">
			<div>
				<el-form ref="shenheForm" :model="shenheForm" :rules="shenheRules" label-width="100px">
					<el-form-item label="原因" prop="pxshenhe">
						<!-- <el-input v-model="form.TrainName" placeholder="请输入计划名称" /> -->
						<el-radio-group v-model="shenheForm.pxshenhe">
							<el-radio :label="3">材料补正</el-radio>
							<el-radio :label="2">不通过</el-radio>
						</el-radio-group>
					</el-form-item>
					<el-form-item label="具体原因" prop="pxshyj">
						<el-input v-model="shenheForm.pxshyj" type="textarea" placeholder="请输入具体原因" />
					</el-form-item>
				</el-form>
			</div>
			<div slot="footer" class="dialog-footer">
				<el-button type="primary" @click="shenheSubmit">确 认</el-button>
			</div>
		</el-dialog>
		<!-- 添加或修改资格考试报名对话框 -->
		<el-dialog top="3vh" title="报名信息" :visible.sync="bmShow" width="70%" :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 @click="bmCancel">取 消</el-button>
			</div>
		</el-dialog>
		<el-dialog top="3vh" :title="upload.title" :visible.sync="upload.open" width="500px" append-to-body>
			<el-upload ref="upload" :limit="1" accept=".xlsx, .xls" :headers="upload.headers" :action="uploadUrl"
				:on-progress="handleFileUploadProgress" :on-success="handleFileSuccess" drag>
				<i class="el-icon-upload"></i>
				<div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
				<div class="el-upload__tip text-center" slot="tip">
					<!-- <div class="el-upload__tip" slot="tip">
            <el-checkbox v-model="upload.updateSupport" /> 是否更新已经存在的用户数据
          </div> -->
					<span>仅允许导入xls、xlsx格式文件。</span>
					<!-- <el-link type="primary" :underline="false" style="font-size:12px;vertical-align: baseline;"
            @click="importTemplate">下载模板</el-link> -->
				</div>
			</el-upload>
			<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 {
		listZigeTraining,
		getZigeTraining,
		delZigeTraining,
		addZigeTraining,
		updateZigeTraining,
		zgksShenhe,
		pxShenhe,
		importPxResult
	} from "@/api/xiehui/zgks/ZigeTraining";
	import {
		getToken
	} from "@/utils/auth";
	import {
		listZigePerson,
		getZigePerson
	} from "@/api/xiehui/zgks/ZigePerson";
	import jly from "../../../components/baoming/jly.vue";
	import zj from "../../../components/baoming/zj.vue";
	import jlgcs from "../../../components/baoming/jlgcs.vue";
	export default {
		name: "ZigeTraining",
		dicts: ["jxjy_shenhe", "jxjy_zhuanye", "zgks_address", 'jxjy_pxzy'],
		components: {
			jly,
			zj,
			jlgcs,
		},
		data() {
			return {
				uploadUrl: process.env.VUE_APP_BASE_API + "/common/upload", //上传路径

				Baoming: false,
				// 遮罩层
				loading: true,
				// 选中数组
				ids: [],
				// 非单个禁用
				single: true,
				// 非多个禁用
				multiple: true,
				// 显示搜索条件
				showSearch: true,
				// 总条数
				total: 0,
				// 资格考试培训计划表格数据
				ZigeTrainingList: [],
				// 弹出层标题
				title: "",
				// 是否显示弹出层
				open: false,
				// 用户导入参数
				upload: {
					// 是否显示弹出层（用户导入）
					open: false,
					// 弹出层标题（用户导入）
					title: "",
					// 是否禁用上传
					isUploading: false,
					// 是否更新已经存在的用户数据
					updateSupport: 0,
					// 设置上传的请求头部
					headers: {
						Authorization: "Bearer " + getToken()
					},
					// 上传的地址
					url: process.env.VUE_APP_BASE_API + "/zgks/ZigePerson/importPxResult"
				},
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					TID: null,
					ECId: null,
					ClassIdList: null,
					ZYIdList: null,
					TrainName: null,
					ZcsZhuanYe: null,
					ZhuanYeType: null,
					QiciYear: null,
					QiCi: null,
					XueShi: null,
					StartDate: null,
					EndDate: null,
					TContent: null,
					BmEndDate: null,
					dishi: null,
					BmNum: null,
					BmNumMax: null,
					Bzq: null,
					OverFlg: null,
					ShenHe: null,
					AddDate: null,
					BeiZhu: null,
					TongZhi: null,
					Minute: null,
					Undef1: null,
					Undef2: null,
					Undef3: null,
					Undef4: null,
					Undef5: null,
					money: null,
					className: null,
					ksName: null,
				},
				// 表单参数
				form: {},
				// 表单校验
				rules: {
					ZcsZhuanYe: {
						required: true,
						message: "请选择培训类别",
						trigger: ["blur", "change"],
					},
					ZhuanYeType: {
						required: true,
						message: "请选择培训专业",
						trigger: ["blur", "change"],
					},
					QiciYear: {
						required: true,
						message: "请输入年",
						trigger: ["blur", "change"],
					},
					QiCi: {
						required: true,
						message: "请输入期次",
						trigger: ["blur", "change"],
					},
					TrainName: {
						required: true,
						message: "请输入培训计划名称",
						trigger: ["blur", "change"],
					},
					dishi: {
						required: true,
						message: "请选择培训地点",
						trigger: ["blur", "change"],
					},
					StartDate: {
						required: true,
						message: "请选择培训开始时间",
						trigger: ["blur", "change"],
					},
					EndDate: {
						required: true,
						message: "请选择培训结束时间",
						trigger: ["blur", "change"],
					},
					BmEndDate: {
						required: true,
						message: "请选择报名截止时间",
						trigger: ["blur", "change"],
					},
					ShenHe: {
						required: true,
						message: "请选择是否审核",
						trigger: ["blur", "change"],
					},
				},
				checks: [],
				ksAddress: [],
				//报名人员列表
				peoShow: false,
				peoLoading: false,
				peoList: [],
				peoTotal: 0,
				peoData: {
					pageSize: 10,
					pageNum: 1,
					TrainId: null,
					UserName: null,
					UserCord: null,
					QiciYear: null,
					QiCi: null,
					City: null,
					DeptName: null,
				},
				peoIds: [],
				Train: {
					QiciYear: null,
					QiCi: null,
				},
				shenheShow: false,
				shenheForm: {
					pxshenhe: null,
					pxshyj: null,
				},
				shenheRules: {
					pxshenhe: {
						required: true,
						message: "请选择原因",
						trigger: ["blur", "change"],
					},
					pxshyj: {
						required: true,
						message: "请输入具体原因",
						trigger: ["blur", "change"],
					},
				},
				//查看报名信息
				bmShow: false,
				zgks: null,
				zgksInfo: null,
				xiugaiType: false,
				importFile: null,
				shform: {},
				roles: []
			};
		},
		created() {
			this.roles = this.$store.getters.roles
			this.getDicts("zgks_address").then((res) => {
				this.ksAddress = res.data;
				this.reset();
			});
			this.getList();
		},
		methods: {
			validateDates() {
				const {
					StartDate,
					EndDate,
					BmEndDate
				} = this.form;

				if (StartDate && BmEndDate && new Date(BmEndDate) >= new Date(StartDate)) {
					this.$message.error('报名截止时间必须在培训开始之前');
					this.form.BmEndDate = ''; // 清空不合法的日期
				}

				if (StartDate && EndDate && new Date(EndDate) <= new Date(StartDate)) {
					this.$message.error('培训结束时间必须在培训开始时间之后');
					this.form.EndDate = ''; // 清空不合法的日期
				}
			},
			// 用户状态修改
			handleStatusChange(row) {
				console.log("?? ~ handleStatusChange ~ row:", row.ShenHe)
				let text = row.ShenHe == "0" ? "未审核" : "已审核";
				this.$modal.confirm('确认要将"' + row.TrainName + '"审核状态改为"' + text + '"吗？').then(function() {
					row.ShenHe = row.ShenHe == "0" ? "0" : "1";
					console.log("?? ~ row.ShenHe:", row.ShenHe)
					return updateZigeTraining(row);
				}).then(() => {
					this.$modal.msgSuccess("修改成功");
					this.getList();
				}).catch(function() {
					row.ShenHe = row.ShenHe == "1" ? "0" : "1";
				});
			},
			handleExportBaoming() {
				this.download('/zgks/ZigePerson/export', {
					TrainId: this.peoData.TrainId
				}, `报名人员_${new Date().getTime()}.xlsx`)
			},
			/** 导入按钮操作 */
			handleImport() {
				this.upload.title = "报名人员导入";
				this.upload.open = true;
			},
			/** 下载模板操作 */
			importTemplate() {
				// this.download('system/user/importTemplate', {
				// }, `user_template_${new Date().getTime()}.xlsx`)
			},
			// 文件上传中处理
			handleFileUploadProgress(event, file, fileList) {
				console.log("?? ~ handleFileUploadProgress ~ file:", file)
				this.upload.isUploading = true;
			},
			// 文件上传成功处理
			handleFileSuccess(response, file, fileList) {
				console.log("?? ~ handleFileSuccess ~ response:", response.fileName)
				// this.upload.open = false;
				this.importFile = response.fileName
				// this.upload.isUploading = false;
				// // this.$refs.upload.clearFiles();
				// // this.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
				// this.getPeoList();
			},
			// 提交上传文件
			submitFileForm() {
				importPxResult({
					TrainId: this.peoData.TrainId,
					importFile: this.importFile
				}).then(res => {
					this.$modal.msgSuccess("导入成功");
					this.upload.open = false;
					this.upload.isUploading = false;
					this.$refs.upload.clearFiles();
					this.getPeoList();
				})

			},
			// 取消按钮
			cancel() {
				this.Baoming = false;
				// this.resetBaoming();
			},
			// 不通过原因提交
			shenheSubmit() {
				this.shform.pxshenhe = this.shenheForm.pxshenhe;
				this.shform.pxshyj = this.shenheForm.pxshyj;
				pxShenhe(this.shform).then((response) => {
					setTimeout(() => {
						// instance.confirmButtonLoading = false;
						this.$modal.msgSuccess("提交成功");
					}, 300);
					this.shenheShow = false;
					this.getPeoList();
				});
			},
			submitSuccess() {},
			/** 查询资格考试培训计划列表 */
			getList() {
				this.loading = true;
				listZigeTraining(this.queryParams).then((response) => {
					this.ZigeTrainingList = response.rows;
					this.total = response.total;
					this.loading = false;
				});
			},
			// 取消按钮
			cancel() {
				this.open = false;
				this.reset();
			},
			// 表单重置
			reset() {
				this.form = {
					TrainName: "",
					TrainId: null,
					TID: null,
					ECId: null,
					ClassIdList: null,
					ZYIdList: null,
					TrainName: null,
					ZcsZhuanYe: null,
					ZhuanYeType: null,
					QiciYear: null,
					QiCi: null,
					XueShi: null,
					StartDate: null,
					EndDate: null,
					TContent: null,
					BmEndDate: null,
					dishi: null,
					BmNum: null,
					BmNumMax: null,
					Bzq: null,
					OverFlg: null,
					ShenHe: null,
					AddDate: null,
					BeiZhu: null,
					TongZhi: null,
					Minute: null,
					Undef1: null,
					Undef2: null,
					Undef3: null,
					Undef4: null,
					Undef5: null,
					money: null,
					className: null,
					ksName: null,
					createBy: null,
					createTime: null,
					updateBy: null,
					updateTime: null,
					address: [],
					xbNum: [],
					bmNum: [],
				};
				this.checks = [];
				this.ksAddress.forEach((item) => {
					this.checks.push(false);
					this.form.address.push(null);
					this.form.xbNum.push(null);
					this.form.bmNum.push(null);
				});
				this.resetForm("form");
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				this.getList();
			},
			/** 重置按钮操作 */
			resetQuery() {
				this.resetForm("queryForm");
				this.handleQuery();
			},
			// 多选框选中数据
			handleSelectionChange(selection) {
				this.ids = selection.map((item) => item.TrainId);
				this.single = selection.length !== 1;
				this.multiple = !selection.length;
			},
			/** 新增按钮操作 */
			handleAdd() {
				this.reset();
				this.open = true;
				this.title = "添加资格考试培训计划";
			},
			changeYear() {
				if (this.queryParams.QiciYear == null) {
					this.queryParams.QiCi = null
				}
			},
			changeYearForm() {
				console.log("?? ~ changeYearForm ~ this.form.QiciYear:", this.form.QiciYear)

				if (this.form.QiciYear == null) {
					this.form.QiCi = null
				}
			},
			/** 修改按钮操作 */
			handleUpdate(row) {
				this.reset();
				const TrainId = row.TrainId || this.ids;
				getZigeTraining(TrainId).then((response) => {
					this.form = {
						...this.form,
						...response.data
					};
					let arr = this.form.dishi.split("|");
					this.form.QiciYear = String(this.form.QiciYear)
					for (let i in arr) {
						let index = this.ksAddress.findIndex(
							(obj) => obj.dictLabel == arr[i]
						);
						this.form.address[index] = arr[i];
						this.form.xbNum[index] = this.form.BmNumMax.split("|")[i];
						this.form.bmNum[index] = this.form.BmNum.split("|")[i];
						this.checks[index] = true;
					}
					this.open = true;
					this.title = "修改资格考试培训计划";
				});
			},
			/** 提交按钮 */
			submitForm() {
				this.$refs["form"].validate((valid) => {
					if (valid) {
						this.form.ZYIdList = this.form.ZcsZhuanYe
						this.form.BmNumMax = this.form.xbNum
							.filter((item) => item !== null)
							.join("|");
						this.form.BmNum = this.form.bmNum
							.filter((item) => item !== null)
							.join("|");
						if (this.form.TrainId != null) {
							updateZigeTraining(this.form).then((response) => {
								this.$modal.msgSuccess("修改成功");
								this.open = false;
								this.getList();
							});
						} else {
							addZigeTraining(this.form).then((response) => {
								this.$modal.msgSuccess("新增成功");
								this.open = false;
								this.getList();
							});
						}
					}
				});
			},
			/** 删除按钮操作 */
			handleDelete(row) {
				const TrainIds = row.TrainId || this.ids;
				this.$modal
					.confirm(
						'是否确认删除资格考试培训计划编号为"' + TrainIds + '"的数据项？'
					)
					.then(function() {
						return delZigeTraining(TrainIds);
					})
					.then(() => {
						this.getList();
						this.$modal.msgSuccess("删除成功");
					})
					.catch(() => {});
			},
			/** 导出按钮操作 */
			handleExport() {
				this.download(
					"zgks/ZigeTraining/export", {
						...this.queryParams,
					},
					`ZigeTraining_${new Date().getTime()}.xlsx`
				);
			},
			//选择地点
			chooseAddress(index, label, e) {
				if (e == true) {
					this.form.address[index] = label;
					if (this.form.bmNum[index] == null) {
						this.form.bmNum[index] = 0;
					}
				} else {
					this.form.xbNum[index] = null;
					this.form.address[index] = null;
					if (this.form.bmNum[index] != null) {
						this.form.bmNum[index] = null;
					}
				}
				let arr = this.form.address.filter((item) => {
					return item !== null;
				});
				this.form.dishi = arr.join("|");
				this.$refs.form.validateField("dishi");
			},
			//查询报名人员
			seePeo(row) {
				this.$router.push({
					path: "/seePeo",
					query: {
						TrainId: row.TrainId,
						grshenhe: '1',
						pxshenhe: '9',
						title: row.TrainName,
						QiciYear: row.QiciYear,
						QiCi: row.QiCi,
					},
				});
				this.peoData.pageNum = 1;

				this.peoData.TrainId = row.TrainId;
				this.peoData.grshenhe = '1';
				this.peoData.pxshenhe = '9'

				this.Train = {
					TrainId: row.TrainId,
					grshenhe: '1',
					pxshenhe: '9'
				};
				// this.peoShow = true;
				this.getPeoList();
			},
			/** 查询资格考试报名列表 */
			getPeoList() {
				this.peoLoading = true;
				listZigePerson(this.peoData).then((response) => {
					this.peoList = response.rows;
					this.peoTotal = response.total;
					this.peoLoading = false;
				});
			},
			peoHandleQuery() {
				this.peoData.pageNum = 1;
				this.getPeoList();
			},
			peoResetQuery() {
				this.resetForm("peoData");
				this.peoData.TrainId = this.Train.TrainId;
				this.peoData.grshenhe = '1';
				this.peoData.pxshenhe = '9'
				this.getPeoList();
			},
			peoSelect(selection) {
				this.peoIds = selection.map((item) => item.PersonId);
			},
			//获取报名人员详情
			getPeoInfo(row) {
				const PersonId = row.PersonId;
				getZigePerson(PersonId).then((response) => {
					if (response.data.ZYIdList == "8") {
						this.zgks = "jlgcs";
					} else if (response.data.ZYIdList == "28") {
						this.zgks = "jly";
					} else {
						this.zgks = "zj";
					}
					this.zgksInfo = response.data;
					this.bmShow = true;
				});
			},
			//培训点审核
			shenhe(row) {
				// this.shform = { ...row };
				this.$confirm("是否审核通过？", {
					confirmButtonText: "通过",
					cancelButtonText: "不通过",
					type: "warning",
					distinguishCancelAndClose: true, // 添加这个属性
					beforeClose: (action, instance, done) => {
						this.shform.PersonId = row.PersonId;

						if (action === 'confirm') {
							instance.confirmButtonLoading = true;
							instance.confirmButtonText = "执行中...";
							this.shform.pxshenhe = 1;

							pxShenhe(this.shform).then((response) => {
								done();
								setTimeout(() => {
									instance.confirmButtonLoading = false;
									this.$modal.msgSuccess("审核成功");
								}, 300);
								this.getPeoList();
							});
						} else if (action === 'cancel') {
							this.shenheShow = true;

							done();
						} else if (action === 'close') {
							// 点击遮罩层或者叉号时，直接关闭
							done();
						}
					}
				}).then(() => {
					// 这里不需要处理
				}).catch((action) => {
					// 只有在点击取消按钮时才会进入这里
					if (action === 'cancel') {
						this.shenheShow = true;
					}
				});

			},
			// 取消按钮
			bmCancel() {
				this.$refs.zgks.reset();
				this.bmShow = false;
			},
		},
	};
</script>
<style scoped>
	::v-deep .el-upload-dragger {
		background-color: #fff;
		border: 1px dashed #d9d9d9;
		border-radius: 6px;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		width: 460px;
		height: 180px;
		text-align: center;
		cursor: pointer;
		position: relative;
		overflow: hidden;
	}

	::v-deep .el-dialog__body {
		padding: 0px 20px;
		color: #606266;
		font-size: 14px;
		word-break: break-all;
	}
</style>