<template>
    <div class="addResume" style="padding-bottom: 20px">
        <div class="info flex align-center justify-center">
            <div class="info-box">
                <div class="info-boxs flex justify-between">
                    <div class="info-box-l" style="width:calc(100% - 640px)">
                        <div class="info-box-l-box">
                            <div class="info-box-l-title">
                                个人中心
                                <div class="info-box-l-line"></div>
                            </div>
                            <div class="info-box-l-info-hover">
                                <!----------------------------  查看个人信息 ---------------------------------->
                                <div class="info-box-l-info-hovers" v-if="userInfoEdit == false">
                                    <div class="info-box-l-info flex align-center justify-between">
                                        <div class="info-box-l-info-l flex align-center">
                                            <div class="info-box-l-info-avatar" style="flex-shrink: 0;">
                                                <el-upload class="avatar-uploader flex align-center justify-center"
                                                    :action="action" :show-file-list="false" :on-success="handleAvatarSuccess
                                                        ">
                                                    <img v-if="avatar" :src="avatar" style="
                                                            width: 100%;
                                                            height: 100%;
                                                        " class="avatar" />
                                                    <el-icon color="#00DD9A" v-else class="avatar-uploader-icon">
                                                        <Plus />
                                                    </el-icon>
                                                </el-upload>
                                            </div>
                                            <div class="info-box-l-info-info">
                                                <div class="info-box-l-info-info-t flex align-center">
                                                    <div>
                                                        {{ nickName }}
                                                    </div>
                                                    <!-- <div v-if="isVip==false">
														升级VIP
													</div> -->
                                                    <!-- <div v-if="isVip" style="
                                                            background-color: #00dd9a;
                                                            color: #ffffff;
                                                        ">
                                                        会员用户
                                                    </div> -->
                                                </div>
                                                <div class="info-box-l-info-info-b flex align-center">
                                                    <!-- 工作经验·年龄·学历·性别 -->
                                                    {{
                                                    resumeInfo.workExpTimes ||
                                                    0
                                                    }}年经验·
                                                    {{
                                                    userEntity &&
                                                    userEntity.age
                                                    ? userEntity.age
                                                    : 18
                                                    }}岁·
                                                    {{ this.getHighestEducation().degree || ''}}·
                                                    {{
                                                    userEntity &&
                                                    userEntity.sex == 1
                                                    ? '男'
                                                    : userEntity &&
                                                    userEntity.sex ==
                                                    2
                                                    ? '女'
                                                    : ''
                                                    }}
                                                </div>
                                            </div>
                                        </div>
                                        <div class="info-box-l-info-r flex align-center">
                                            <div class="info-box-l-info-r-item" @click="goInterview(0)">
                                                <div class="info-box-l-info-r-item-t">
                                                    {{ deliveryCount }}
                                                </div>
                                                <div class="info-box-l-info-r-item-b">
                                                    投递记录
                                                </div>
                                            </div>
                                            <div class="info-box-l-info-r-item" @click="goInterview(4)">
                                                <div class="info-box-l-info-r-item-t">
                                                    {{ browseCount }}
                                                </div>
                                                <div class="info-box-l-info-r-item-b">
                                                    浏览记录
                                                </div>
                                            </div>
                                            <div class="info-box-l-info-r-item" @click="goInterview(3)">
                                                <div class="info-box-l-info-r-item-t">
                                                    {{ collectionCount }}
                                                </div>
                                                <div class="info-box-l-info-r-item-b">
                                                    我的收藏
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- 求职状态 -->
                                    <div class="info-box-l-btm flex align-center justify-between">
                                        <div class="info-box-l-status">
                                            {{
                                            resumesStatus == 0
                                            ? '离职-随时到岗'
                                            : resumesStatus == 1
                                            ? '在职-月内到岗'
                                            : resumesStatus == 2
                                            ? '在职-考虑机会'
                                            : '在职-暂不考虑'
                                            }}
                                        </div>

                                        <div @click="hideFrom('userInfoEdit')"
                                            class="info-box-l-seid flex align-center">
                                            <el-icon class="info-box-l-seid-icon" style="cursor: pointer"
                                                color="#00DD9A" size="20">
                                                <Edit />
                                            </el-icon>
                                            编辑
                                        </div>
                                    </div>
                                </div>
                                <!----------------------------  编辑个人信息 ---------------------------------->
                                <div v-else class="info-box-l-edit">
                                    <view class="info-box-l-edit-title">
                                        编辑个人信息
                                    </view>
                                    <el-form ref="formResume" v-loading="loading" size="large" style="margin-top: 20px"
                                        class="flex align-center justify-between" label-position="top" :inline="true"
                                        :model="form" label-width="120px">
                                        <el-form-item prop="resumesName" :rules="[
                                            {
                                                required: true,
                                                message: '请输入姓名',
                                                trigger: 'blur'
                                            }
                                        ]" class="row45" label="姓名">
                                            <el-input placeholder="请输入姓名" class="inputClass"
                                                v-model="form.resumesName" />
                                        </el-form-item>
                                        <el-form-item class="row45" label="性别">
                                            <div class="info-box-l-edit-sex flex align-center justify-between">
                                                <div @click="
                                                    current = item.id;
                                                form.resumesSex =
                                                    item.id;
                                                " :class="current == item.id
                                                            ? 'activeSex'
                                                            : ''
                                                        "
                                                    class="info-box-l-edit-sex-item flex align-center justify-center"
                                                    v-for="(item, index) in sexList" :key="index">
                                                    {{ item.name }}
                                                </div>
                                            </div>
                                        </el-form-item>
                                        <el-form-item prop="resumesPhone" :rules="[
                                            {
                                                required: true,
                                                message: '请输入手机号',
                                                trigger: 'blur'
                                            }
                                        ]" class="row45" label="手机号">
                                            <el-input v-model="form.resumesPhone" maxlength="11" placeholder="请输入手机号" />
                                        </el-form-item>
                                        <el-form-item class="row45" label="年龄">
                                            <el-input-number style="width: 100%" v-model="form.resumesAge" :min="1"
                                                :max="100" controls-position="right" />
                                        </el-form-item>
                                        <el-form-item prop="resumesEmail" :rules="[
                                            {
                                                required: true,
                                                message: '请输入电子邮箱',
                                                trigger: 'blur'
                                            }
                                        ]" class="row45" label="电子邮箱">
                                            <el-input v-model="form.resumesEmail" type="email" placeholder="请输入电子邮箱" />
                                        </el-form-item>
                                        <el-form-item prop="resumesStatus" :rules="[
                                            {
                                                required: true,
                                                message: '请选择求职状态',
                                                trigger: 'blur'
                                            }
                                        ]" class="row45" label="当前求职状态">
                                            <el-select style="width: 100%" v-model="form.resumesStatus"
                                                placeholder="请选择求职状态">
                                                <el-option v-for="item in qiuzhiStatus" :key="item.value"
                                                    :label="item.label" :value="item.value" />
                                            </el-select>
                                        </el-form-item>
                                        <el-form-item class="row45"></el-form-item>
                                        <el-form-item class="row45">
                                            <div class="info-box-l-edit-btn flex align-center justify-end">
                                                <el-button @click="
                                                    userInfoEdit = false
                                                    " style="width: 100px" type="Info">取消</el-button>
                                                <el-button @click="saveResumesInfo()" style="
                                                        width: 100px;
                                                        margin-left: 30px;
                                                    " type="primary">保存</el-button>
                                            </div>
                                        </el-form-item>
                                    </el-form>
                                </div>
                            </div>
                        </div>
                        <div class="info-box-l-lines"></div>
                        <div class="info-box-l-gw">
                            <!----------------------------  查看求职意向 ---------------------------------->
                            <div v-if="!gangweiEdit" class="info-box-l-gw-box info-box-l-gw-boxs">
                                <div class="info-box-l-gw-title flex align-center justify-between">
                                    求职意向
                                    <div @click="addIntentionJob()" class="info-box-l-gw-box-edit flex align-center">
                                        <el-icon class="info-box-l-gw-box-edit-icon" style="cursor: pointer"
                                            color="#00DD9A" size="20">
                                            <CirclePlus />
                                        </el-icon>
                                        添加
                                    </div>
                                </div>
                                <div v-if="jobTypeList.length == 0" style="margin-top: 20px">
                                    暂无求职意向
                                </div>
                                <div style="margin-top: 20px"
                                    class="info-box-l-gw-box flex align-center flex-wrap justify-between">
                                    <div style="width: 90%" class="flex align-center flex-wrap">
                                        <div @click="getInteJob(item)" class="info-box-l-gw-box-item flex align-center" style="margin-bottom: 20px;"
                                            v-for="(item, index) in jobTypeList" :key="index">
                                            {{ item.ruleClassifyName }}
                                            <div class="fontCOlor" style="margin-left: 10px">
                                                |
                                                <span class="font333" style="margin-left: 10px">
                                                    {{ item.salaryRange }}
                                                </span>
                                            </div>
                                            <div class="fontCOlor" style="margin-left: 10px">
                                                |
                                                <span style="margin-left: 10px">
                                                    {{ item.citys }}
                                                </span>
                                            </div>
                                            <el-icon class="info-box-l-gw-box-item-edit" color="#00DD9A">
                                                <EditPen />
                                            </el-icon>
                                            <img v-if="item.isDefault == 1" class="info-box-l-gw-box-item-biaoji"
                                                src="../../../public/images/index/biaoji.png" />
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!----------------------------  添加求职意向 ---------------------------------->
                            <div v-else class="info-box-l-gw-box" style="padding: 0 40px">
                                <div class="info-box-l-gw-title">
                                    添加求职意向
                                </div>
                                <el-form ref="formRef" v-loading="loading" size="large" style="margin-top: 20px"
                                    class="flex align-center justify-between" label-position="top" :inline="true"
                                    :model="intentionJob" label-width="120px">
                                    <el-form-item prop="ruleClassifyName" :rules="[
                                        {
                                            required: true,
                                            message: '请选择工作职位',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="工作职位">
                                        <el-input @click="openDialog()" :readonly="true" placeholder="请选择工作职位"
                                            suffix-icon="ArrowRight" class="inputClass" v-model="intentionJob.ruleClassifyName
                                                ">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="citys" :rules="[
                                        {
                                            required: true,
                                            message: '请选择期望工作地点',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="期望地点">
                                        <el-input @click="openCityDialog()" :readonly="true" placeholder="请选择期望工作地点"
                                            suffix-icon="ArrowRight" class="inputClass" v-model="intentionJob.citys">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="industry" :rules="[
                                        {
                                            required: true,
                                            message: '请选择从事方向',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="从事方向">
                                        <el-input @click="openIndustry()" :readonly="true" placeholder="请选择从事方向"
                                            suffix-icon="ArrowRight" class="inputClass" v-model="intentionJob.industry">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="salaryRange" :rules="[
                                        {
                                            required: true,
                                            message: '请选择期望薪资',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="期望薪资">
                                        <div style="display: flex; gap: 10px; align-items: center; width: 100%">
                                            <!-- 最低薪资 -->
                                            <el-select v-model="intentionJob.minSalary" placeholder="最低薪资"
                                                style="flex: 1">
                                                <el-option v-for="item in desireSalary" :key="item.value"
                                                    :label="item.label" :value="item.value" />
                                            </el-select>
                                            <span>-</span>
                                            <!-- 最高薪资 -->
                                            <el-select v-model="intentionJob.maxSalary" placeholder="最高薪资"
                                                style="flex: 1">
                                                <el-option
                                                    v-for="item in desireSalary.filter(i => Number(i.value) >= Number(intentionJob.minSalary))"
                                                    :key="item.value" :label="item.label" :value="item.value" />
                                            </el-select>
                                        </div>
                                    </el-form-item>
                                    <el-form-item prop="postType" :rules="[
                                        {
                                            required: true,
                                            message: '请选择工作性质',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="工作性质">
                                        <el-select style="width: 100%" v-model="intentionJob.postType"
                                            placeholder="请选择工作性质">
                                            <el-option v-for="item in workStatus" :key="item.value" :label="item.label"
                                                :value="item.value" />
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item class="row45"></el-form-item>
                                    <el-form-item class="row45"></el-form-item>
                                    <el-form-item class="row45">
                                        <div class="info-box-l-edit-btn flex align-center justify-end">
                                            <el-button @click="gangweiEdit = false" style="width: 100px"
                                                type="Info">取消</el-button>
                                            <el-button v-if="intentionId" @click="deleteInteJob()" style="
                                                    width: 100px;
                                                    margin-left: 30px;
                                                " type="danger">删除</el-button>
                                            <el-button @click="editInteJob()" style="
                                                    width: 100px;
                                                    margin-left: 30px;
                                                " type="primary">保存</el-button>
                                        </div>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </div>
                    </div>
                    <!----------------------------  右边简历预览 ---------------------------------->
                    <div class="info-box-r flex justify-center flex-wrap" style="width: 350px;">
                        <div class="info-box-r-t">
                            <div>
                                <el-card class="box-card" shadow="hover" style="
                                        cursor: pointer;
                                        border: none;
                                        border-radius: 15px;
                                    ">
                                    <template #header>
                                        <div class="card-header" style="padding: 2px">
                                            <span style="font-weight: 500">简历预览</span>
                                        </div>
                                    </template>
                                    <div class="box-card-i flex align-center">
                                        <el-icon style="margin-right: 10px">
                                            <User />
                                        </el-icon>姓名：{{ form.resumesName ? form.resumesName : '暂无'}}
                                    </div>
                                    <div class="box-card-i flex align-center">
                                        <el-icon style="margin-right: 10px">
                                            <Message />
                                        </el-icon>邮箱：{{
                                        form.resumesEmail
                                        ? form.resumesEmail
                                        : '暂无'
                                        }}
                                    </div>
                                    <div class="box-card-i flex align-center">
                                        <el-icon style="margin-right: 10px">
                                            <Finished />
                                        </el-icon>岗位：<template v-if="jobTypeList.length > 0">
                                            <template v-for="(item, index) in jobTypeList" :key="index">
                                                {{ item.ruleClassifyName }}
                                            </template>
                                        </template>
                                        <template v-else>暂无岗位</template>
                                    </div>
                                    <div class="box-card-i flex align-center">
                                        <el-icon style="margin-right: 10px">
                                            <Discount />
                                        </el-icon>学校：{{
                                        form.school ? form.school : '暂无'
                                        }}
                                    </div>
                                    <div class="box-card-i flex align-center">
                                        <el-icon style="margin-right: 10px">
                                            <Operation />
                                        </el-icon>专业：{{
                                        form.major ? form.major : '暂无'
                                        }}
                                    </div>
                                </el-card>
                            </div>
                        </div>
                        <div class="info-box-r-b flex align-center justify-around" style="margin-top: 20px;padding-bottom: 10px;">
                            <div class="info-box-r-b-item" @click="goInterview(0)">
                                <div class="info-box-r-b-item-t flex align-center justify-center">
                                    <img src="/images/resume/lljl.png" alt="" srcset="" />
                                </div>
                                <div class="info-box-r-b-item-b">投递记录</div>
                            </div>
                            <div class="info-box-r-b-item" @click="goInterview(1)">
                                <div class="info-box-r-b-item-t flex align-center justify-center">
                                    <img src="/images/resume/myLove.png" alt="" srcset="" />
                                </div>
                                <div class="info-box-r-b-item-b">沟通记录</div>
                            </div>
                            <div class="info-box-r-b-item" @click="goInterview(2)">
                                <div class="info-box-r-b-item-t flex align-center justify-center">
                                    <img src="/images/resume/ms.png" alt="" srcset="" />
                                </div>
                                <div class="info-box-r-b-item-b">我的面试</div>
                            </div>
                            <div class="info-box-r-b-item" @click="goInterview(3)">
                                <div class="info-box-r-b-item-t flex align-center justify-center">
                                    <img src="/images/resume/sx.png" alt="" srcset="" />
                                </div>
                                <div class="info-box-r-b-item-b">我的收藏</div>
                            </div>
                        </div>
                    </div>
                    <!-- 附件简历 -->
                     <upload-resume v-model="resumeFiles" :limit="3" @change="handleChange" />
                </div>
                <!----------------------------  工作经历 ---------------------------------->
                <div class="info-boxsWork flex align-center justify-center">
                    <div class="info-boxsWorks">
                        <div class="info-boxsWorks-title flex align-center justify-between">
                            工作经历
                            <div @click="workIndex = -1;hideFrom('workExperience')"
                                class="info-boxsWorks-title-add flex align-center">
                                <el-icon class="info-boxsWorks-title-adds" style="cursor: pointer" color="#00DD9A"
                                    size="20">
                                    <CirclePlus />
                                </el-icon>
                                添加
                            </div>
                        </div>
                        <div class="info-boxsWorks-content" v-if="
                            workExps.length == 0 &&
                            !workExperience
                        ">
                            暂无工作经历
                        </div>
                        <div v-if="!workExperience" class="info-boxsWorks-content" v-for="(item, index) in workExps"
                            :key="index">
                            <div class="info-boxsWorks-content-title flex align-center justify-between">
                                {{ item.companyName || '未填写公司名称' }}
                                <div class="info-boxsWorks-content-title-cz flex align-center">
                                    <div @click="editWorkHis(item, index)"
                                        class="info-boxsWorks-content-title-cz-i flex align-center">
                                        <el-icon class="info-boxsWorks-content-title-cz-is" style="cursor: pointer"
                                            color="#00DD9A" size="14">
                                            <Edit />
                                        </el-icon>
                                        编辑
                                    </div>
                                    <div @click="deleteWorkHis(item, index)"
                                        class="info-boxsWorks-content-title-cz-i flex align-center">
                                        <el-icon class="info-boxsWorks-content-title-cz-is" style="cursor: pointer"
                                            color="#00DD9A" size="14">
                                            <Delete />
                                        </el-icon>
                                        删除
                                    </div>
                                </div>
                            </div>
                            <!-- 显示该公司下的所有职位信息 -->
                            <div v-for="(detail, detailIndex) in workExpList.filter(exp => exp.workExpId === item.workExpId)"
                                :key="detailIndex" class="info-boxsWorks-content-position">
                                <div class="info-boxsWorks-content-job">
                                    <span>担任岗位：</span>
                                    {{ detail.position || '未填写岗位' }}
                                    <span v-if="detail.department" class="info-boxsWorks-content-department">
                                        ({{ detail.department }})
                                    </span>
                                </div>
                                <div class="info-boxsWorks-content-time flex align-center">
                                    <span>在职时间：</span>
                                    {{
                                    detail.startTime
                                    ? this.getFormDate(detail.startTime)
                                    : '未填写开始时间'
                                    }}
                                    <div class="info-boxsWorks-content-timez">
                                        至
                                    </div>
                                    {{
                                    detail.endTime
                                    ? this.getFormDate(detail.endTime)
                                    : '至今'
                                    }}
                                </div>
                                <div class="info-boxsWorks-content-con" style="white-space: pre-wrap;">
                                    <span>工作内容：</span>
                                    <div>
                                        {{ detail.workContent || '未填写工作内容' }}
                                    </div>
                                </div>
                                <!-- 显示技能标签 -->
                                <div v-if="detail.skills && detail.skills.length > 0"
                                    class="info-boxsWorks-content-time flex align-center">
                                    <span>专业技能：</span>
                                    <div class="info-boxsWorks-content-skills-tags">
                                        <span v-for="(skill, skillIndex) in detail.skills" :key="skillIndex"
                                            class="info-boxsWorks-content-skill-tag">
                                            {{ skill }}
                                        </span>
                                    </div>
                                </div>
                                <div v-if="detailIndex < workExpList.filter(exp => exp.workExpId === item.workExpId).length - 1"
                                    class="info-boxsWorks-content-divider"></div>
                            </div>
                            <!-- 是否屏蔽该公司 -->
                            <div class="flex align-center" style="margin-top: 10px;">
                                <div style="color: #999;font-size: 14px;margin-right: 10px;">不对该公司展示</div>
                                <el-switch :active-value="1" :inactive-value="0" v-model="item.isShield" @change="changeIsDisplay(item)" />
                            </div>
                        </div>
                        <!-- 添加/编辑工作经历 -->
                        <div v-else class="info-boxsWorks-edit flex align-center justify-center">
                            <div class="info-boxsWorks-edits">
                                <el-form ref="formRefWork" v-loading="loading" size="large" style="margin-top: 20px"
                                    class="flex align-center justify-between" label-position="top" :inline="true"
                                    :model="workObj" label-width="120px">
                                    <el-form-item prop="resumesTitle" :rules="[
                                        {
                                            required: true,
                                            message: '请输入公司名称',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="公司名称">
                                        <el-input placeholder="请输入公司名称" suffix-icon="ArrowRight" class="inputClass"
                                            v-model="workObj.resumesTitle">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="businessType" :rules="[
                                        {
                                            required: true,
                                            message: '请选择公司业务类型',
                                            trigger: 'change'
                                        }
                                    ]" class="row45" label="公司业务类型">
                                        <el-checkbox-group v-model="workObj.businessType">
                                            <el-checkbox v-for="item in businessTypeOptions" :key="item.value"
                                                :label="item.label">
                                            </el-checkbox>
                                        </el-checkbox-group>
                                    </el-form-item>

                                    <el-form-item prop="department" :rules="[
                                        {
                                            required: true,
                                            message: '请选择所在部门',
                                            trigger: 'change'
                                        }
                                    ]" class="row45" label="所在部门">
                                        <el-select placeholder="请选择所在部门" v-model="workObj.departmentId"
                                            @change="handleDepartmentChange">
                                            <el-option v-for="item in departments" :key="item.departmentId"
                                                :label="item.departmentName" :value="item.departmentId">
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item prop="resumesTime" :rules="[
                                        {
                                            required: true,
                                            message: '请选择在职时间',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="在职时间">
                                        <el-date-picker v-model="workObj.resumesTime" type="daterange"
                                            range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
                                    </el-form-item>
                                    <el-form-item prop="selectedJobPost" :rules="[
                                        {
                                            required: true,
                                            message: '请选择工作职位',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="工作职位">
                                        <el-input @click="openDialogForWorkExp()" :readonly="true" placeholder="请选择工作职位"
                                            v-model="workObj.selectedJobPost" suffix-icon="ArrowRight"
                                            class="inputClass">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="positionSkills" :rules="[
                                        {
                                            required: true,
                                            message: '请选择岗位职业技能',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="岗位职业技能">
                                        <el-input @click="openIndustryForWorkExp()" :readonly="true"
                                            placeholder="请选择岗位职业技能" v-model="workObj.positionSkills"
                                            suffix-icon="ArrowRight" class="inputClass">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="resumesContent" :rules="[
                                        {
                                            required: true,
                                            message: '请输入工作内容',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="工作内容">
                                        <el-input v-model="workObj.resumesContent" :autosize="{
                                            minRows: 4,
                                            maxRows: 6
                                        }" type="textarea" placeholder="请输入工作内容" />
                                    </el-form-item>
                                    <el-form-item prop="workPerformance" class="row45" label="工作业绩">
                                        <el-input v-model="workObj.workPerformance" :autosize="{
                                            minRows: 4,
                                            maxRows: 6
                                        }" type="textarea" placeholder="请输入工作业绩" />
                                    </el-form-item>
                                     <el-form-item class="row45"> </el-form-item>
                                    <el-form-item class="row45">
                                        <div class="info-box-l-edit-btn flex align-center justify-end">
                                            <el-button @click="workExperience = false" style="width: 100px"
                                                type="Info">取消</el-button>
                                            <el-button @click="editInteWork()" style="
                                                    width: 100px;
                                                    margin-left: 30px;
                                                " type="primary">保存</el-button>
                                        </div>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </div>
                    </div>
                </div>
                <!----------------------------  教育经历 ---------------------------------->
                <div class="info-boxsWork flex align-center justify-center">
                    <div class="info-boxsWorks">
                        <div class="info-boxsWorks-title flex align-center justify-between">
                            <div>教育经历<text style="font-size: 12px; color: #999;font-weight: 400;">(请填写最高学历)</text></div>
                            <div @click="workIndex = -1; hideFrom('perExperience')"
                                class="info-boxsWorks-title-add flex align-center">
                                <el-icon class="info-boxsWorks-title-adds" style="cursor: pointer" color="#00DD9A"
                                    size="20">
                                    <CirclePlus />
                                </el-icon>
                                添加
                            </div>
                        </div>
                        <div class="info-boxsWorks-content" v-if="eduList.length == 0 && !perExperience">
                            暂无教育经历
                        </div>
                        <div v-if="!perExperience" class="info-boxsWorks-content" v-for="(item, index) in eduList"
                            :key="index">
                            <div class="info-boxsWorks-content-title flex align-center justify-between">
                                {{ item.school || '未填写学校' }}
                                <div class="info-boxsWorks-content-title-cz flex align-center">
                                    <div @click="editPerHis(item, index)"
                                        class="info-boxsWorks-content-title-cz-i flex align-center">
                                        <el-icon class="info-boxsWorks-content-title-cz-is" style="cursor: pointer"
                                            color="#00DD9A" size="14">
                                            <Edit />
                                        </el-icon>
                                        编辑
                                    </div>
                                    <div @click="deletePerHis(item, index)"
                                        class="info-boxsWorks-content-title-cz-i flex align-center">
                                        <el-icon class="info-boxsWorks-content-title-cz-is" style="cursor: pointer"
                                            color="#00DD9A" size="14">
                                            <Delete />
                                        </el-icon>
                                        删除
                                    </div>
                                </div>
                            </div>
                            <div class="info-boxsWorks-content-job">
                                <span>专业：</span>
                                {{ item.profession || '未填写专业' }}
                            </div>
                            <div class="info-boxsWorks-content-job">
                                <span>学历：</span>
                                {{ item.degree || '未填写学历' }}
                            </div>
                            <div class="info-boxsWorks-content-time flex align-center">
                                <span>就读时间：</span>
                                {{
                                item.startTime
                                ? this.getFormDate(item.startTime)
                                : '未填写开始时间'
                                }}
                                <div class="info-boxsWorks-content-timez">
                                    至
                                </div>
                                {{
                                item.endTime
                                ? this.getFormDate(item.endTime)
                                : '至今'
                                }}
                            </div>
                            <div class="info-boxsWorks-content-con" style="white-space: pre-wrap;">
                                <span>详细描述：</span>
                                <div>{{ item.detail || '未填写详细描述' }}</div>
                            </div>
                        </div>
                        <!-- 添加/编辑教育经历 -->
                        <div v-else class="info-boxsWorks-edit flex align-center justify-center">
                            <div class="info-boxsWorks-edits">
                                <el-form ref="formRefperject" v-loading="loading" size="large" style="margin-top: 20px"
                                    class="flex align-center justify-between" label-position="top" :inline="true"
                                    :model="perjectObj" label-width="120px">
                                    <el-form-item prop="resumesTitle" :rules="[
                                        {
                                            required: true,
                                            message: '请输入学校名称',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="学校名称">
                                        <el-input placeholder="请输入学校名称" suffix-icon="ArrowRight" class="inputClass"
                                            v-model="perjectObj.resumesTitle">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="resumesPost" :rules="[
                                        {
                                            required: true,
                                            message: '请输入专业',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="专业">
                                        <el-input placeholder="请输入专业" suffix-icon="ArrowRight" class="inputClass"
                                            v-model="perjectObj.resumesPost">
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item prop="degree" :rules="[
                                        {
                                            required: true,
                                            message: '请选择学历',
                                            trigger: 'change'
                                        }
                                    ]" class="row45" label="学历">
                                        <el-select placeholder="请选择学历" v-model="perjectObj.degree" class="inputClass">
                                            <el-option v-for="(item, index) in degreeOptions" :key="index" :label="item"
                                                :value="item"></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item prop="resumesTime" :rules="[
                                        {
                                            required: true,
                                            message: '请选择在校时间',
                                            trigger: 'blur'
                                        }
                                    ]" class="row45" label="在校时间">
                                        <el-date-picker v-model="perjectObj.resumesTime" type="daterange"
                                            range-separator="至" start-placeholder="开始时间" end-placeholder="结束时间" />
                                    </el-form-item>
                                    <el-form-item prop="resumesContent" class="row45" label="在校经历（选填）">
                                        <el-input v-model="perjectObj.resumesContent" :autosize="{
                                            minRows: 6,
                                            maxRows: 8
                                        }" maxlength="300" show-word-limit type="textarea" placeholder="1.在校担任职务...
2.获得荣誉...
3.所学主要课程..." />
                                    </el-form-item>
                                    <el-form-item class="row45"> </el-form-item>
                                     <el-form-item class="row45"> </el-form-item>
                                    <el-form-item class="row45">
                                        <div class="info-box-l-edit-btn flex align-center justify-end">
                                            <el-button @click="perExperience = false" style="width: 100px"
                                                type="Info">取消</el-button>
                                            <el-button @click="editIntePer()" style="
                                                    width: 100px;
                                                    margin-left: 30px;
                                                " type="primary">保存</el-button>
                                        </div>
                                    </el-form-item>
                                </el-form>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>

        <!-- 求职岗位选择 -->
        <el-dialog @close="type = false" class="workDialog" :draggable="true" destroy-on-close align-center center
            v-model="workDialog" title="工作地址">
            <template #header>
                <div class="my-header flex align-center">
                    <div class="my-header-title" style="font-weight: bold">
                        求职岗位
                    </div>
                    <div class="my-header-title" style="margin-left: 40px">
                        <el-autocomplete style="width: 300px" prefix-icon="Search" v-model="workSearch"
                            :fetch-suggestions="querySearchAsync" placeholder="请输入岗位名称" @select="handleSelect" />
                    </div>
                </div>
            </template>
            <div class="work flex align-center">
                <div class="work-left flex align-center justify-center">
                    <div class="work-left-box">
                        <ul class="work-left-box-list" style="overflow: auto">
                            <li @click="workCurrent = index" :class="workCurrent == index ? 'workActive' : ''
                                " v-for="(item, index) in workTypeList" :key="index"
                                class="work-left-box-list-item flex align-center justify-center">
                                <div class="work-left-box-list-items">
                                    {{ item.ruleClassifyName }}
                                </div>
                            </li>
                        </ul>
                    </div>
                </div>
                <div class="work-right flex align-center justify-center">
                    <div class="work-right-box">
                        <div class="work-right-box-item" v-for="(item, index) in rightList" :key="index">
                            <div class="work-right-box-item-title">
                                {{ item.title }}
                            </div>
                            <div class="work-right-box-item-name flex align-center flex-wrap">
                                <div @click="selectJob(ite)" class="work-right-box-item-names"
                                    v-for="(ite, ind) in item.childrens">
                                    {{ ite.ruleClassifyName }}
                                </div>
                            </div>
                        </div>
                        <el-empty v-if="rightList.length == 0" description="暂无岗位" />
                    </div>
                </div>
            </div>
        </el-dialog>
        <!-- 城市选择 -->
        <el-dialog @close="type = false" :draggable="true" destroy-on-close align-center center v-model="cityDialog"
            title="工作地址">
            <template #header>
                <div class="my-header flex align-center">
                    <div class="my-header-title" style="font-weight: bold">
                        工作地址
                    </div>
                    <div class="my-header-title flex" style="margin-left: 40px; width: 300px">
                        <el-input v-model="search" prefix-icon="Search" size="default" placeholder="请输入城市名称"
                            class="input-with-select" @input="handleSearch" />
                        <el-button @click="handleSearch" style="margin-left: 10px" type="primary">搜索</el-button>
                    </div>
                </div>
            </template>
            <div class="city flex align-center justify-center">
                <div class="city-box">
                    <div class="city-box-city">
                        <div class="city-box-cityt flex align-center justify-between">
                            定位城市
                            <div @click="getLocation()" class="city-box-cityt-r flex align-center">
                                <el-icon size="18">
                                    <Location />
                                </el-icon>
                                重新定位
                            </div>
                        </div>
                        <div @click="selectCity(city)" class="city-box-citys">
                            {{ city }}
                        </div>
                    </div>
                    <div class="city-box-list">
                        <ul class="city-box-lists" style="overflow: auto">
                            <li class="city-box-lists-title">热门城市</li>
                            <li class="city-box-lists-title-cs flex align-center flex-wrap">
                                <div @click="selectCity(item)" class="city-box-lists-title-css"
                                    v-for="(item, index) in rmCity" :key="index">
                                    {{ item }}
                                </div>
                            </li>
                            <li v-for="(item, index) in cityList" :key="index" class="city-box-lists-item">
                                <div v-if="item.city.length > 0">
                                    <div class="city-box-lists-item-title">
                                        {{ item.letter.toUpperCase() }}
                                    </div>
                                    <div class="flex align-center flex-wrap">
                                        <div class="city-box-lists-item-titles flex align-center"
                                            v-for="(ite, ind) in item.city" :key="ind">
                                            <div @click="selectCity(ite)">
                                                {{ ite }}
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </li>
                        </ul>
                    </div>
                    <el-empty v-if="cityList.length == 0" description="暂无城市" />
                </div>
            </div>
        </el-dialog>
        <!-- 从事方向选择 -->
        <el-dialog class="workDialog" @close="type = false" :draggable="true" destroy-on-close align-center center
            v-model="industryDialog" title="选择从事方向">
            <template #header>
                <div class="my-header flex align-center">
                    <div class="my-header-title" style="font-weight: bold">
                        选择从事方向
                    </div>
                    <div class="my-header-title flex align-center" style="margin-left: 40px; width: 600px">
                        <el-select @remove-tag="removeTag" :collapse-tags="true" :max-collapse-tags="2"
                            class="my-header-title-se" multiple-limit="5" v-model="industryArr" multiple
                            placeholder="请选择从事方向">
                            <el-option v-for="item in industryArrList" :key="item.postSkillName"
                                :label="item.postSkillName" :value="item.postSkillName" />
                        </el-select>
                        <span style="
                                margin-left: 10px;
                                font-size: 13px;
                                color: #999999;
                            ">{{ industryArr.length }}</span>
                        <el-button @click="addHangye()" style="margin-left: 10px" type="primary">确定</el-button>
                    </div>
                </div>
            </template>
            <div class="preference-grid">
                <div v-for="(parent, pIndex) in industryList" :key="pIndex" class="preference-group">
                    <!-- 一级标题 -->
                    <div class="preference-title">
                        <span>{{ parent.postSkillName }}</span>
                    </div>

                    <!-- 二级可选项 -->
                    <div class="preference-children">
                        <div v-for="(child, cIndex) in parent.childrenList" :key="cIndex" class="preference-tag"
                            :class="{ active: industryArr.includes(child.postSkillName) }"
                            @click="togglePreference(pIndex,child.postSkillName)">
                            <span>{{ child.postSkillName }}</span>
                        </div>
                    </div>
                </div>
                <el-empty v-if="industryList.length == 0" description="暂无从事方向" />
            </div>
        </el-dialog>
    </div>
</template>

<script>
import axios from 'axios';
import jsonp from 'axios-jsonp';
import cityJs from '../../publicJs/city.js';
import citySelect from '../../publicJs/citySelect.js';
import { ElMessageBox, ElMessage } from 'element-plus';
import { ROOTPATH } from '../../../comment/httpUrl.js';
import UploadResume from "../../components/UploadResume/UploadResume.vue";
export default {
    components: { UploadResume },
    data() {
        return {
            resumeFiles: [],
            cityAll: cityJs, //城市数据
            action: ROOTPATH + '/alioss/upload', //上传图片地址
            industryDialog: false, //是否打开行业选择
            workDialog: false, //是否打开岗位选择
            cityDialog: false, //是否打开城市选择弹窗
            loading: false, //设置加载中
            isWork: false, // 防止重复提交
            gangweiEdit: false,
            current: 1,
            sexList: [
                {
                    name: '男',
                    id: 1
                },
                {
                    name: '女',
                    id: 2
                }
            ],
            userInfoEdit: false,
            form: {
                resumesName: '', //姓名
                resumesSex: 1, //性别
                graduationTime: '', //毕业时间
                resumesAge: 18, //年龄
                resumesPhone: '', //手机号
                resumesEducation: '', //学历
                resumesMarriage: '', //婚姻状态
                major: '', //专业
                school: '', //学校
                resumesWorkExperience: '', //工作经验
                resumesEmail: '', //电子邮箱
                resumesCompensation: '', //期望薪资
                industryName: '', //行业
                city: '', //意向城市
                resumesPost: '', //求职岗位
                ruleClassifyId: '', //岗位id
                resumesWorkList: [], //项目经验
                resumesCompanyList: [] //工作经历
            },
            workObj: {
                //工作经历
                resumesTitle: '', //公司名称
                resumesTime: [], //时间
                resumesContent: '', //工作内容
                resumesClassify: 1, //状态
                // 添加新的字段以支持新的数据结构
                workExpId: '',
                workExpDetailId: '',
                companyName: '', // 公司名称
                position: '', // 岗位
                positionId: 0,
                startTime: '', // 开始时间
                endTime: '', // 结束时间
                department: '',
                departmentId: 0,
                positionLevel: '初级', // 默认初级
                workPerformance: '', // 工作业绩
                skills: '[]', // 技能，格式为JSON字符串
                businessType: [], // 公司业务类型
                positionSkills: [], // 岗位职业技能，格式为数组
                selectedJobPost: '' // 选择的工作职位
            },
            // 与app端一致的业务类型选项
            businessTypeOptions: [
                { label: '跨境电商', value: '0' },
                { label: '国内电商', value: '1' },
                { label: '外贸', value: '2' },
                { label: '其他', value: '3' }
            ],
            // 与app端一致的岗位职级选项
            positionLevels: ['初级', '资深'],
            // 学历选项
            degreeOptions: ['初中', '高中', '中专', '大专', '本科', '硕士', '博士', '博士后'],
            forWorkExp: false, // 是否为工作经历选择数据
            perjectObj: {
                //项目经验
                resumesTitle: '', //公司名称
                resumesTime: [], //时间
                resumesPost: '', //岗位
                resumesContent: '', //工作内容
                resumesClassify: 2 //状态
            },

            qiuzhiStatus: [
                {
                    value: 0,
                    label: '离职-随时到岗'
                },
                {
                    value: 1,
                    label: '在职-月内到岗'
                },
                {
                    value: 2,
                    label: '在职-考虑机会'
                },
                {
                    value: 3,
                    label: '在职-暂不考虑'
                }
            ], //求职状态
            workStatus: [], //工作性质
            deliveryCount: 0, //投递记录
            browseCount: 0, //浏览记录
            collectionCount: 0, //我的收藏
            nickName: '',
            avatar: '',
            userType: 1, // 1:用户 2:企业
            resumesStatus: 1, //求职状态
            resumeInfo: {}, //简历信息
            userEntity: {}, //用户实体信息
            resumesId: '', //简历id
            screenHeight: 0, //屏幕高度
            jobTypeList: [], //求职意向
            cityList: [], //城市列表
            departments: [], // 部门列表
            intentionJob: {
                ruleClassifyId: '', //岗位id
                ruleClassifyName: '', //岗位名称
                citys: '', //工作城市
                salaryRange: '', //薪资范围
                industry: '', //行业
                postType: '', //工作性质
                isDefault: 0,//是否是第一意向
                minSalary: '',
                maxSalary: ''
            }, //求职意向
            desireSalary: [], //期望薪资
            intentionId: '', //求职意向id
            search: '', //城市搜索内容
            latitude: '',
            longitude: '',
            city: '', //定位城市
            rmCity: [], //热门城市列表
            workTypeList: [], //岗位类型
            workCurrent: 0,
            workSearch: '', //岗位搜索
            industryArr: [], //选择的行业数组
            industryArrList: [], //可选择的行业列表
            industryList: [], //行业列表
            type: false, //简历还是求职意向的 true:简历 false:求职意向
            workExperience: false, //是否显示工作经历添加或者修改
            perExperience: false, //是否显示项目经验添加或者修改
            workIndex: -1, //记录修改工作经历/工作经验的index值
            userInfoEdit: false, //个人信息编辑状态
            // 工作经历相关数据，定义为响应式属性
            workExps: [], // 工作经历列表
            workExpList: [],// 工作经历详细信息列表
            eduList: [], // 教育经历列表
        };
    },
    created() {
        for (let i = 5000; i <= 50000; i += 1000) {
            this.desireSalary.push({ value: i.toString(), label: i.toString() })
        }
    },
    computed: {
        rightList() {
            return this.workTypeList.length > 0
                ? this.workTypeList[this.workCurrent].childrens
                : [];
        },
        isVip() {
            return this.$store.state.isVip;
        }
    },
    mounted() {
        if (this.$route.query.isExpand === '1') {
            this.gangweiEdit = true
        }
        this.screenHeight = window.innerHeight;
        this.token = localStorage.getItem('token');
        if (this.token) {
            this.getUserData();
            this.getUserInfo();
            this.getJlInfo();
            this.getJobType();
            this.getPostType();
            this.getDepartment(); // 获取部门列表
            this.getJobList();
        }
    },
    watch: {
        //监听行业选择变化
        industryArr: {
            handler(newItems) {
                this.industryArr.map(item => {
                    this.industryList.map(ite => {
                        ite.childrenList.map(it => {
                            if (item == it.industryName) {
                                it.select = true;
                            }
                        });
                    });
                });
            },
            deep: true
        },
        // 监听教育经历变化，自动更新最高学历信息
        eduList: {
            handler(newList) {
                // 获取最高学历的学校和专业
                const highestEdu = this.getHighestEducation();
                this.form.school = highestEdu.school;
                this.form.major = highestEdu.major;
                this.form.resumesEducation = highestEdu.degree;
            },
            deep: true
        },
        'intentionJob.minSalary'(val) {
            this.updateSalaryRange()
        },
        'intentionJob.maxSalary'(val) {
            this.updateSalaryRange()
        }
    },
    methods: {
        // 是否屏蔽该公司
        changeIsDisplay(item) {
            console.log(item)
            let data = {
                workExp: {
                    isShield: item.isShield,
                    workExpId: item.workExpId
                }
            }
            this.$Request.post("/app/userFirst/addWorkExp", data, { type: 'json' }).then((res) => {
                if (res.code == 0) {
                    ElMessage({
                        message: '修改成功',
                        type: 'success',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                }
            });
        },
        updateSalaryRange() {
            const { minSalary, maxSalary } = this.intentionJob
            if (minSalary && maxSalary && Number(maxSalary) > Number(minSalary)) {
                this.intentionJob.salaryRange = `${minSalary}-${maxSalary}`
            } else {
                this.intentionJob.salaryRange = ''
            }
        },
        handleChange(list) {
            console.log("当前上传的简历文件列表：", list);
        },
        querySearch(queryString, cb) {
            const results = queryString
                ? this.cityAll.filter(city =>
                    city.label
                        .toLowerCase()
                        .includes(queryString.toLowerCase())
                )
                : '';
            // call callback function to return suggestions
            cb(results);
        },

        //去面试记录页面
        goInterview(index) {
            this.$router.push({
                name: 'interview',
                query: { index }
            });
        },
        //上传头像成功后的回调
        handleAvatarSuccess(res) {
            this.avatar = res.data;
            let that = this;
            that.$Request
                .post(
                    '/app/user/updateUser',
                    { avatar: that.avatar },
                    { type: 'json' }
                )
                .then(res => {
                    if (res.code === 0) {
                        ElMessage({
                            message: '上传成功',
                            type: 'success',
                            duration: 1500,
                            offset: this.screenHeight / 2
                        });
                        that.getUserInfo();
                    } else {
                        this.avatar = '';
                        ElMessage({
                            message: res.msg,
                            type: 'info',
                            duration: 1500,
                            offset: this.screenHeight / 2
                        });
                    }
                });
        },

        //隐藏表单
        hideFrom(name) {
            //传递哪个哪个就打开，剩下的全部关闭
            let arr = [
                'gangweiEdit',
                'userInfoEdit',
                'workExperience',
                'perExperience'
            ];
            arr.map(item => {
                if (item == name) {
                    this[item] = true;
                    // 如果是添加教育经历，初始化教育经历编辑表单
                    if (item == 'perExperience' && this.workIndex == -1) {
                        this.perjectObj = {
                            //教育经历
                            resumesTitle: '', //学校名称
                            resumesTime: [], //时间
                            resumesPost: '', //专业
                            resumesContent: '', //详细描述
                            degree: '', //学历
                            resumesClassify: 2, //状态
                            // 添加新的字段以支持新的数据结构
                            eduId: '',
                            school: '', // 学校名称
                            profession: '', // 专业
                            startTime: '', // 开始时间
                            endTime: '', // 结束时间
                            detail: '', // 详细描述
                            isUse: 1
                        };
                    }
                    // 如果是添加工作经历，初始化工作经历编辑表单
                    if (item == 'workExperience' && this.workIndex == -1) {
                        this.workObj = {
                            //工作经历
                            resumesTitle: '', //公司名称
                            resumesTime: [], //时间
                            resumesPost: '', //岗位
                            resumesContent: '', //工作内容
                            resumesClassify: 1, //状态
                            // 添加新的字段以支持新的数据结构
                            workExpId: '',
                            workExpDetailId: '',
                            companyName: '', // 公司名称
                            position: '', // 岗位
                            positionId: 0,
                            startTime: '', // 开始时间
                            endTime: '', // 结束时间
                            department: '',
                            departmentId: '',
                            positionLevel: '初级', // 默认初级
                            workPerformance: '', // 工作业绩
                            skills: '[]', // 技能，格式为JSON字符串
                            businessType: [], // 公司业务类型
                            positionSkills: [], // 岗位职业技能，格式为数组
                            selectedJobPost: '', // 选择的工作职位
                            ruleClassifyId: 0 // 工作职位ID
                        };
                    }
                    // 如果是个人信息编辑模式，从新的数据结构中同步简历信息到form
                    if (item == 'userInfoEdit') {
                        // 首先从userEntity中获取基本用户信息
                        if (this.userEntity) {
                            this.form.resumesName =
                                this.userEntity.userName || '';
                            this.form.resumesAge = this.userEntity.age || '';
                            this.form.resumesSex = this.userEntity.sex || 1;
                            this.form.resumesPhone =
                                this.userEntity.phone || '';
                            // 更新性别选择的当前值
                            this.current = this.userEntity.sex || 1;
                        }

                        // 然后从resumeList中获取其他简历信息
                        if (this.resumeInfo && this.resumeInfo.resumeList) {
                            const resumeData = this.resumeInfo.resumeList;
                            this.form.resumesMarriage =
                                resumeData.resumesMarriage || '';
                            this.form.address = resumeData.address || '';
                            this.form.graduationTime =
                                resumeData.graduationTime || '';
                            this.form.school = resumeData.school || '';
                            this.form.major = resumeData.major || '';
                            this.form.resumesWorkExperience =
                                resumeData.resumesWorkExperience || '';
                            this.form.resumesEmail =
                                resumeData.resumesEmail || '';
                            this.form.resumesStatus =
                                resumeData.resumesStatus || 0;
                            this.form.resumesCompensation =
                                resumeData.resumesCompensation || '';
                            this.form.city = resumeData.city || '';
                            // this.form.birthday = resumeData.birthday || '';
                            // this.form.resumesAttachment =
                            //     resumeData.resumesAttachment || '';
                            // this.form.resumesImage =
                            //     resumeData.resumesImage || '';
                            // this.form.resumesImageName =
                            //     resumeData.resumesImageName || '';
                            this.resumesStatus = resumeData.resumesStatus;
                            this.resumesId = resumeData.resumesId;
                        }
                    }
                } else {
                    this[item] = false;
                }
            });
        },
        //保存教育经历
        editIntePer() {
            let formRef = this.$refs.formRefperject;
            formRef.validate(valid => {
                if (valid) {
                    this.loading = true;
                    // 构建新的数据结构用于保存
                    let eduData = {
                        eduId: this.perjectObj.eduId || '',
                        school: this.perjectObj.resumesTitle || '', // 学校名称
                        profession: this.perjectObj.resumesPost || '', // 专业
                        degree: this.perjectObj.degree || '', // 学历
                        startTime: this.getFormDate(
                            this.perjectObj.resumesTime[0]
                        ), // 开始时间
                        endTime: this.getFormDate(
                            this.perjectObj.resumesTime[1]
                        ), // 结束时间
                        detail: this.perjectObj.resumesContent || '', // 详细描述
                    };

                    // 调用保存API
                    let apiUrl = '/app/userFirst/addEdu';
                    this.$Request.post(apiUrl, eduData,{type:'json'}).then(res => {
                        if (res.code == 0) {
                            ElMessage({
                                message: '保存成功',
                                type: 'success',
                                duration: 1500,
                                offset: this.screenHeight / 2
                            });
                            // 重置表单
                            this.perjectObj = {
                                //教育经历
                                resumesTitle: '', //学校名称
                                resumesTime: [], //时间
                                resumesPost: '', //专业
                                resumesContent: '', //详细描述
                                degree: '', //学历
                                resumesClassify: 2 //状态
                            };
                            // 重新获取最新的数据
                            this.getUserInfo();
                            this.getJlInfo();
                            this.loading = false;
                            this.perExperience = false;
                        } else {
                            this.loading = false;
                            ElMessageBox.alert(res.msg, '提示', {
                                confirmButtonText: '确认'
                            });
                        }
                    });
                    this.workIndex = -1;
                } else {
                    console.log('error submit!');
                    return false;
                }
            });
        },
        //编辑教育经历
        editPerHis(item, index) {
            this.workIndex = index;
            // 从eduList数组获取数据并转换为编辑表单需要的格式
            let edu = JSON.parse(JSON.stringify(item));

            // 构建编辑表单需要的数据结构
            this.perjectObj = {
                // 保留原有的resumesTitle字段用于向后兼容，这里存储学校名称
                resumesTitle: edu.school || '',
                // 保留原有的resumesPost字段用于向后兼容，这里存储专业和学历
                resumesPost: edu.profession || '',
                // 保留原有的resumesContent字段用于向后兼容，这里存储详细描述
                resumesContent: edu.detail || '',
                // 设置时间范围
                resumesTime: [
                    edu.startTime ? new Date(edu.startTime) : '',
                    edu.endTime ? new Date(edu.endTime) : ''
                ],
                // 保存实际的eduId用于更新
                eduId: edu.eduId,
                // 保存学历信息
                degree: edu.degree || ''
            };
            this.hideFrom('perExperience');
        },
        //删除教育经历
        deletePerHis(item, index) {
            ElMessageBox.alert('确认删除此段教育经历吗？', '提示', {
                confirmButtonText: '确认',
                showCancelButton: true,
                callback: res => {
                    if (res == 'confirm') {
                        //确认
                        this.loading = true;
                        let eduId = item.eduId;

                        // 调用删除API
                        this.$Request
                            .post('/app/userFirst/deleteEdu', {eduId: eduId},{type:'json'})
                            .then(res => {
                                if (res.code == 0) {
                                    ElMessage({
                                        message: '已删除',
                                        type: 'success',
                                        duration: 1500,
                                        offset: this.screenHeight / 2
                                    });
                                    // 重新获取最新的数据
                                    this.getUserInfo();
                                    this.getJlInfo();
                                    this.loading = false;
                                } else {
                                    this.loading = false;
                                    ElMessageBox.alert(res.msg, '提示', {
                                        confirmButtonText: '确认'
                                    });
                                }
                            });
                    }
                }
            });
        },
        //编辑工作经历
        editWorkHis(item, index) {
            this.workIndex = index;
            // 从workExps数组获取数据
            let workExp = JSON.parse(JSON.stringify(item));
            
            // 先设置基本的workObj，主要是workExpId
            this.workObj = {
                workExpId: workExp.workExpId,
                businessType: workExp.businessType || []
            };
            
            // 调用getDepartment获取部门列表，在获取成功后会自动调用getData获取详细数据
            this.getDepartment();
            
            this.hideFrom('workExperience');
        },
        //删除工作经历
        deleteWorkHis(item, index) {
            ElMessageBox.confirm('确认删除该条内容么？', '提示', {
                confirmButtonText: '确认',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                // 确认删除
                this.loading = true;
                let action = 'userFirst/deleteWorkExp';
                let params = {
                    workExpId: item.workExpId
                };

                this.$Request.post("/app/" + action, params,{type:'json'}).then((res) => {
                    this.loading = false;
                    if (res.code == 0) {
                        ElMessage({
                            message: '已删除',
                            type: 'success',
                            duration: 1500,
                            offset: this.screenHeight / 2
                        });
                        // 直接在本地数组中过滤掉删除的项，与app端逻辑一致
                        this.workExps = this.workExps.filter(function(workItem) {
                            return workItem.workExpId != item.workExpId;
                        });
                        // 同时过滤workExpList数组中对应的详细信息，确保页面正确渲染
                        this.workExpList = this.workExpList.filter(function(detailItem) {
                            return detailItem.workExpId != item.workExpId;
                        });
                    } else {
                        ElMessage({
                            message: res.msg,
                            type: 'error',
                            duration: 1500,
                            offset: this.screenHeight / 2
                        });
                    }
                }).catch(() => {
                    this.loading = false;
                    // 用户取消删除
                });
            });
        },
        //时间对象转：2023-11-21格式
        getFormDate(formData) {
            let time = new Date(formData);
            return (
                time.getFullYear() +
                '-' +
                (time.getMonth() + 1 < 10
                    ? '0' + (time.getMonth() + 1)
                    : time.getMonth() + 1) +
                '-' +
                (time.getDate() < 10 ? '0' + time.getDate() : time.getDate())
            );
        },
        //修改/添加工作经验
        editInteWork() {
            // 防止重复提交
            if (this.isWork) {
                return;
            }
            let formRef = this.$refs.formRefWork;
            formRef.validate(valid => {
                if (valid) {
                    this.isWork = true;
                    this.loading = true;
                    console.log(this.workObj)
                    // 构建与app端一致的数据结构用于保存
                    let workExpDetailData = {
                        workExpDetailId: this.workObj.workExpDetailId || '',
                        workExpId: this.workObj.workExpId || '',
                        department: this.workObj.department || '',
                        departmentId: this.workObj.departmentId || 0,
                        positionLevel: this.workObj.positionLevel || '',
                        position: this.workObj.selectedJobPost || '',
                        positionId: this.workObj.ruleClassifyId || 0,
                        workContent: this.workObj.resumesContent || '', // 工作内容
                        workPerformance: this.workObj.workPerformance || '', // 工作业绩
                        skills: typeof this.workObj.positionSkills === 'string' ? this.workObj.positionSkills : JSON.stringify(this.workObj.positionSkills), // 技能，格式为JSON字符串，使用positionSkills字段的值
                        startTime: this.getFormDate(this.workObj.resumesTime[0]), // 开始时间
                        endTime: this.getFormDate(this.workObj.resumesTime[1]), // 结束时间
                    };

                    let workExpData = {
                        workExp: {
                            workExpId: this.workObj.workExpId || '',
                            companyName: this.workObj.resumesTitle || '', // 公司名称
                            type: JSON.stringify(this.workObj.businessType || []), // 公司业务类型
                        },
                        workExpDetails: [workExpDetailData]
                    };
                    console.log(workExpDetailData)
                    let apiUrl = '/app/userFirst/addWorkExp';
                    this.$Request.post(apiUrl, workExpData,{type:'json'}).then(res => {
                        this.isWork = false;
                        this.loading = false;
                        
                        if (res.code == 0) {
                            ElMessage({
                                message: '保存成功',
                                type: 'success',
                                duration: 1500,
                                offset: this.screenHeight / 2
                            });
                            // 重置表单
                        this.workObj = {
                            //工作经历
                            resumesTitle: '', //公司名称
                            resumesTime: [], //时间
                            resumesPost: '', //岗位
                            resumesContent: '', //工作内容
                            resumesClassify: 1, //状态
                            // 添加新的字段以支持新的数据结构
                            workExpId: '',
                            workExpDetailId: '',
                            companyName: '', // 公司名称
                            position: '', // 岗位
                            positionId: 0,
                            startTime: '', // 开始时间
                            endTime: '', // 结束时间
                            department: '',
                            departmentId: 0,
                            positionLevel: '初级',
                            workPerformance: '', // 工作业绩
                            skills: '[]', // 技能，格式为JSON字符串
                            businessType: [], // 公司业务类型
                            positionSkills: [], // 岗位职业技能，格式为数组
                            selectedJobPost: '', // 选择的工作职位
                            ruleClassifyId: 0 // 工作职位ID
                        };
                            // 重新获取最新的数据
                            this.getUserInfo();
                            this.getJlInfo();
                            this.workExperience = false;
                        } else {
                            ElMessage({
                                message: res.msg || '保存失败',
                                type: 'error',
                                duration: 1500,
                                offset: this.screenHeight / 2
                            });
                        }
                    }).catch(() => {
                        this.isWork = false;
                        this.loading = false;
                    });
                    this.workIndex = -1;
                } else {
                    console.log('error submit!');
                    return false;
                }
            });
        },
        removeTag(e) {
            console.log(e, '2222222');
            this.industryList.map(item => {
                if (item.childrenList.length > 0) {
                    item.childrenList.map(ite => {
                        if (ite.industryName == e) {
                            ite.select = false;
                        }
                    });
                }
            });
            console.log(this.industryList, '111111111');
            console.log(this.industryArr, '已出tag');
        },
        // 分割时间
        splitTime(time) {
            // 使用字符串的 split() 方法将时间分割为数组
            return time ? time.split(/ - /) : [];
        },
        //确认行业/岗位职业技能
        addHangye() {
            if (this.forWorkExp) {
                // 为工作经历设置岗位职业技能
                this.workObj.positionSkills = this.industryArr;
            } else if (this.type) {
                // 为表单设置行业
                this.form.industryName = this.industryArr.join('/');
            } else {
                // 为求职意向设置行业
                this.intentionJob.industry = this.industryArr.join('/');
            }

            this.industryDialog = false;
        },
        //打开行业选择弹框（用于求职意向）
        openIndustry(type) {
            this.type = type;
            this.forWorkExp = false; // 标志是求职意向使用
            
            // 检查是否已选择工作职位
            let ruleClassifyId = this.type ? this.form.ruleClassifyId : this.intentionJob.ruleClassifyId;
            
            if (!ruleClassifyId) {
                ElMessage({
                    message: '请先选择工作职位',
                    type: 'warning',
                    duration: 1500,
                    offset: this.screenHeight / 2
                });
                return;
            }
            
            this.industryArr = [];
            this.getIndustryList();
        },
        
        // 为工作经历打开工作职位选择
        openDialogForWorkExp() {
            this.forWorkExp = true;
            this.workDialog = true;
        },
        
        // 为工作经历打开岗位职业技能选择
        openIndustryForWorkExp() {
            this.forWorkExp = true;
            
            // 检查是否已选择工作职位
            if (!this.workObj.selectedJobPost || !this.workObj.ruleClassifyId) {
                ElMessage({
                    message: '请先选择工作职位',
                    type: 'warning',
                    duration: 1500,
                    offset: this.screenHeight / 2
                });
                return;
            }
            
            this.industryArr = [];
            this.getIndustryListForWorkExp();
        },
        
        /**
         * 获取工作经历的岗位职业技能数据
         */
        getIndustryListForWorkExp() {
            let data = {
                ruleClassifyId: this.workObj.ruleClassifyId
            };
            
            this.$Request.get('/app/userFirst/getPostSkill', { params: data }).then(res => {
                if (res.code == 0) {
                    // 处理返回的层级数据
                    this.industryList = res.data;
                    
                    // 构建可选择的行业列表（扁平化）
                    let flatList = [];
                    this.industryList.forEach(parent => {
                        parent.childrenList.forEach(child => {
                            flatList.push(child);
                        });
                    });
                    this.industryArrList = flatList;
                    
                    this.industryDialog = true;
                } else {
                    ElMessage({
                        message: res.msg,
                        type: 'error',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                }
            });
        },
        // 切换从事方向选择状态
        // togglePreference(a,skillName) {
        //     // 查找索引
        //     const index = this.industryArr.indexOf(skillName);
            
        //     if (index > -1) {
        //         // 如果已选择，则取消选择
        //         this.industryArr.splice(index, 1);
        //     } else {
        //         // 如果未选择，检查是否达到选择上限
        //         if (this.industryArr.length >= 5) {
        //             ElMessage({
        //                 message: '最多添加五条',
        //                 type: 'info',
        //                 duration: 1500,
        //                 offset: this.screenHeight / 2
        //             });
        //             return;
        //         }
        //         // 添加选择
        //         this.industryArr.push(skillName);
        //     }
        // },
        // 切换从事方向选择状态
        togglePreference(pIndex, skillName) {
            const parent = this.industryList[pIndex]; // 当前分类
            console.log(parent)
            console.log(this.industryArr)
            const selectedInGroup = parent.childrenList.filter(item =>
                this.industryArr.includes(item.postSkillName)
            );

            const index = this.industryArr.indexOf(skillName);

            if (index > -1) {
                // 取消选择
                this.industryArr.splice(index, 1);
            } else {
                // 检查当前分类是否已选满 5 个
                if (selectedInGroup.length >= 5) {
                    ElMessage({
                        message: '每个分类最多选择五个',
                        type: 'info',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                    return;
                }
                // 添加选择
                this.industryArr.push(skillName);
            }
        },
        
        // 添加行业
        addIndustry(ite) {
            if (ite.select == false) {
                if (this.industryArr.length == 5) {
                    ElMessage({
                        message: '最多添加五条',
                        type: 'info',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                    return;
                }
                this.industryArr.push(ite.industryName);
            } else {
                console.log('ccccccccccc');
                this.industryArr.splice(
                    this.industryArr.indexOf(ite.industryName),
                    1
                );
            }
            ite.select = !ite.select;
        },
        /**
         * 获取行业数据（从事方向）
         */
        getIndustryList() {
            // 获取当前选择的工作职位ID
            let ruleClassifyId = this.type ? this.form.ruleClassifyId : this.intentionJob.ruleClassifyId;
            
            let data = {
                ruleClassifyId: ruleClassifyId
            };
            
            this.$Request.get('/app/userFirst/getPostSkill', { params: data }).then(res => {
                if (res.code == 0) {
                    // 处理返回的层级数据
                    this.industryList = res.data;
                    
                    // 构建可选择的行业列表（扁平化）
                    let flatList = [];
                    this.industryList.forEach(parent => {
                        parent.childrenList.forEach(child => {
                            flatList.push(child);
                        });
                    });
                    this.industryArrList = flatList;
                    
                    this.industryDialog = true;
                } else {
                    ElMessage({
                        message: res.msg,
                        type: 'error',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                }
            });
        },
        //选择岗位
        handleSelect(item) {
            if (this.forWorkExp) {
                // 为工作经历选择
                this.workObj.ruleClassifyId = item.ruleClassifyId; //岗位分类id
                this.workObj.selectedJobPost = item.ruleClassifyName; //岗位分类名称
            } else if (this.type) {
                // 为表单选择
                this.form.ruleClassifyId = item.ruleClassifyId; //岗位分类id
                this.form.resumesPost = item.ruleClassifyName; //岗位分类名称
            } else {
                // 为求职意向选择
                this.intentionJob.ruleClassifyId = item.ruleClassifyId; //岗位分类id
                this.intentionJob.ruleClassifyName = item.ruleClassifyName; //岗位分类名称
            }
            this.workDialog = false;
        },
        // 岗位的搜索
        querySearchAsync(queryString, cd) {
            if (!queryString) {
                cd([]);
                return;
            }
            let data = {
                ruleClassifyName: queryString
            };
            this.$Request
                .get('/app/rule/userGetClassify', { params: data })
                .then(res => {
                    if (res.code == 0) {
                        let arr = res.data;
                        arr.map(item => {
                            item.value = item.ruleClassifyName;
                        });
                        cd(arr);
                    }
                });
        },
        //打开岗位选择
        openDialog(type) {
            this.type = type;
            this.workSearch = '';
            this.workDialog = true;
        },
        /**
         * @param {Object} info
         * 选择岗位并返回
         */
        selectJob(info) {
            if (this.forWorkExp) {
                // 工作经历模块
                this.workObj.ruleClassifyId = info.ruleClassifyId; //岗位分类id
                this.workObj.selectedJobPost = info.ruleClassifyName; //岗位分类名称
            } else if (this.type) {
                // 表单模块
                this.form.ruleClassifyId = info.ruleClassifyId; //岗位分类id
                this.form.resumesPost = info.ruleClassifyName; //岗位分类名称
            } else {
                // 求职意向模块
                this.intentionJob.ruleClassifyId = info.ruleClassifyId; //岗位分类id
                this.intentionJob.ruleClassifyName = info.ruleClassifyName; //岗位分类名称
            }

            this.workDialog = false;
            this.forWorkExp = false; // 重置标志位
        },
        /**
         * 获取岗位列表
         */
        getJobList() {
            this.$Request.get('/app/rule/getClassifyList').then(res => {
                if (res.code == 0) {
                    if (res.data) {
                        this.workTypeList = res.data;
                    }
                }
            });
        },
        //打开城市选择
        openCityDialog(type) {
            this.type = type;
            this.search = '';
            this.getCitysList();
            this.getLocation();
            this.getRmCityList();
            this.cityDialog = true;
        },
        //选择城市
        selectCity(city) {
            if (this.type) {
                this.form.city = city;
            } else {
                this.intentionJob.citys = city;
            }

            this.cityDialog = false;
        },
        /**
         * 热门城市列表
         */
        getRmCityList() {
            let data = {
                limitCount: 10
            };
            this.$Request
                .get('/app/postPush/getHotCity', { params: data })
                .then(res => {
                    if (res.code == 0) {
                        this.rmCity = res.data;
                    }
                });
        },
        /**
         * @param {Object} longitude
         * @param {Object} latitude
         * 使用经纬度获取城市
         */
        getSelectCity(longitude, latitude) {
            let data = {
                lat: latitude,
                lng: longitude
            };
            this.$Request
                .get('/app/Login/selectCity', { params: data })
                .then(res => {
                    if (res.code == 0) {
                        this.city = res.data.city ? res.data.city : '未知';
                    }
                });
        },
        //使用jsonp请求从腾讯地图获取经纬度
        getLocation() {
            let data = {
                key: 'ZBABZ-ZWECU-UQTVV-4LYDR-COK3F-5SF75', //申请的密钥
                output: 'jsonp'
            };
            let url = 'https://apis.map.qq.com/ws/location/v1/ip';
            axios
                .get(url, {
                    params: data,
                    adapter: jsonp
                })
                .then(res => {
                    this.longitude = res.data.result.location.lng;
                    this.latitude = res.data.result.location.lat;
                    this.getSelectCity(this.longitude, this.latitude);
                })
                .catch(err => {
                    console.log(err);
                });
        },
        //删除求职意向
        deleteInteJob() {
            ElMessageBox.alert('确认删除此求职意向吗？', '提示', {
                confirmButtonText: '确认',
                showCancelButton: true,
                callback: res => {
                    if (res == 'confirm') {
                        //确认
                        this.loading = true;
                        this.$Request
                            .post(
                                '/app/intention/deleteIntention',
                                { intentionId: this.intentionId },
                                { type: 'json' }
                            )
                            .then(res => {
                                if (res.code == 0) {
                                    ElMessage({
                                        message: '删除成功',
                                        type: 'success',
                                        duration: 1500,
                                        offset: this.screenHeight / 2
                                    });
                                    this.loading = false;
                                    this.gangweiEdit = false;
                                    this.getJobType();
                                } else {
                                    this.loading = false;
                                    ElMessageBox.alert(res.msg, '提示', {
                                        confirmButtonText: '确认'
                                    });
                                }
                            });
                    }
                }
            });
        },
        //修改求职意向
        editInteJob() {
            let formRef = this.$refs.formRef;
            formRef.validate(valid => {
                if (valid) {
                    // 防止重复提交
                    if (this.isWork) return;
                    this.isWork = true;
                    
                    this.loading = true;
                    
                    // 构建与app端一致的数据结构
                    let data = {
                        intentionId: this.intentionId || '',
                        ruleClassifyId: this.intentionJob.ruleClassifyId,
                        ruleClassifyName: this.intentionJob.ruleClassifyName,
                        citys: this.intentionJob.citys,
                        salaryRange: this.intentionJob.salaryRange,
                        postType: this.intentionJob.postType,
                        industry: this.intentionJob.industry,
                        createTime: "",
                        industryId: 201,
                        industryOneId: 200,
                        classifyOneId: 0,
                        classifyTwoId: 0,
                        isDefault: 1
                    };
                    this.$Request.post("/app/intention/saveUpdate", data,{type:'json'}).then((res) => {
                        this.isWork = false;
                        this.loading = false;
                        
                        if (res.code == 0) {
                            ElMessage({
                                message: '保存成功',
                                type: 'success',
                                duration: 1500,
                                offset: this.screenHeight / 2
                            });
                            
                            // 关闭编辑弹窗
                            this.gangweiEdit = false;
                            
                            // 更新求职意向列表
                            this.getJobType();
                        } 
                        // else {
                        //     ElMessage({
                        //         message: res.msg,
                        //         type: 'error',
                        //         duration: 1500,
                        //         offset: this.screenHeight / 2
                        //     });
                        // }
                    });
                } else {
                    console.log('error submit!');
                    return false;
                }
            });
        },
        //新增求职意向
        addIntentionJob() {
            //关闭之前的表单
            this.intentionId = '';
            this.intentionJob = {
                ruleClassifyId: '', //岗位id
                ruleClassifyName: '', //岗位名称
                citys: '', //工作城市
                salaryRange: '', //薪资范围
                industry: '', //行业
                postType: '', //工作性质
                minSalary: '', //最小薪资
                maxSalary: '' //最大薪资
            };
            this.hideFrom('gangweiEdit');
        },
        //查询求职意向
        getInteJob(item) {
            this.intentionId = item.intentionId;
            let data = {
                intentionId: item.intentionId
            };
            console.log(data, '1111111');
            this.$Request
                .get('/app/intention/getIntentionInfo', { params: data })
                .then(res => {
                    if (res.code == 0) {
                        this.intentionJob.ruleClassifyId =
                            res.data.ruleClassifyId; //岗位id
                        this.intentionJob.ruleClassifyName =
                            res.data.ruleClassifyName; //岗位名称
                        this.intentionJob.citys = res.data.citys; //工作城市
                        
                        // 设置薪资范围，确保与desireSalary中的选项匹配
                        // this.intentionJob.salaryRange = res.data.salaryRange; //薪资范围（数值格式）
                        this.intentionJob.minSalary = res.data.minSalary; //最小薪资
                        this.intentionJob.maxSalary = res.data.maxSalary; //最大薪资
                        this.intentionJob.industry = res.data.industry; //行业
                        this.intentionJob.postType = res.data.postType; //工作性质
                        this.intentionJob.isDefault = res.data.isDefault; //是否第一求职意向
                        //关闭之前的表单
                        this.hideFrom('gangweiEdit');
                    }
                });
        },
        /**
         * 获取城市列表
         */
        getCitysList(keyword = '') {
            const grouped = {};

            // 过滤：如果有关键字，就按城市名模糊匹配
            const filtered = keyword
                ? cityJs.filter(item => item.label.includes(keyword))
                : cityJs;

            filtered.forEach(item => {
                const letterObj = citySelect.getFirstLetter(item.label);
                const letter = letterObj.firstletter.toUpperCase();
                if (!grouped[letter]) grouped[letter] = [];
                grouped[letter].push(item.label);
            });

            const sortedLetters = Object.keys(grouped).sort();
            this.cityList = sortedLetters.map(letter => ({
                letter,
                city: grouped[letter]
            }));
        },
        // 搜索事件
        handleSearch() {
            this.getCitysList(this.search.trim());
        },
        //获取求职意向
        getJobType() {
            this.$Request.get('/app/intention/getIntentionList').then(res => {
                if (res.code == 0 && res.data.length > 0) {
                    this.jobTypeList = res.data;
                }
            });
        },
        //保存个人信息
        saveResumesInfo() {
            let formResume = this.$refs.formResume;
            formResume.validate(valid => {
                if (valid) {
                    // 额外的字段验证
                    // if (!this.form.resumesName) {
                    //     ElMessage({
                    //         message: '用户名不能为空',
                    //         type: 'warning',
                    //         duration: 1500,
                    //         offset: this.screenHeight / 2
                    //     });
                    //     return;
                    // } else if (!this.form.resumesPhone) {
                    //     ElMessage({
                    //         message: '联系电话不能为空',
                    //         type: 'warning',
                    //         duration: 1500,
                    //         offset: this.screenHeight / 2
                    //     });
                    //     return;
                    // } 
                   if (!this.form.resumesAge) {
                        ElMessage({
                            message: '年龄不能为空',
                            type: 'warning',
                            duration: 1500,
                            offset: this.screenHeight / 2
                        });
                        return;
                    } 
                    // else if (!this.form.resumesEmail) {
                    //     ElMessage({
                    //         message: '邮箱不能为空',
                    //         type: 'warning',
                    //         duration: 1500,
                    //         offset: this.screenHeight / 2
                    //     });
                    //     return;
                    // }
                    
                    // 计算年龄
                    // this.form.resumesAge = this.calculateAgeFromBirthday(this.form.birthday) || 0;
                    
                    let that = this;
                    ElMessageBox.confirm('确定保存信息', '温馨提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(() => {
                        that.loading = true;
                        // 先更新用户信息
                        that.$Request.post("/app/user/updateUser", {
                            userName: that.form.resumesName,
                            avatar: that.userEntity.avatar || '',
                            sex: that.form.resumesSex,
                            age: that.form.resumesAge,
                            phone: this.form.resumesPhone
                            // weChatNum: that.form.weChatNum || ''
                        },{type:'json'}).then(res => {
                            if (res.code === 0) {
                                // 用户信息更新成功后，更新简历信息
                                that.setResume();
                            } else {
                                that.loading = false;
                                ElMessage({
                                    message: res.msg,
                                    type: 'error',
                                    duration: 1500,
                                    offset: that.screenHeight / 2
                                });
                            }
                        });
                    }).catch(() => {
                        // 取消保存
                    });
                }
            });
        },
        // 设置简历信息
        setResume() {
            let data = {
                resumesStatus: this.form.resumesStatus,
                // resumesPhone: this.form.resumesPhone,
                // resumesAge: this.form.resumesAge,
                birthday: this.getBirthDateByAge(this.form.resumesAge),
                resumesEmail: this.form.resumesEmail,
                ifExp: this.form.resumesWorkExperience ? 1 : 0
            };
            this.$Request.post("/app/userFirst/regist", data,{type:'json'}).then((res) => {
                this.loading = false;
                if (res.code == 0) {
                    ElMessage({
                        message: '保存成功',
                        type: 'success',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                    // 更新用户信息和简历信息
                    this.getUserInfo();
                    this.getJlInfo();
                    this.userInfoEdit = false;
                    // 可以在这里添加跳转逻辑
                    setTimeout(function() {
                        // 实际开发中可以根据需要添加跳转
                    }, 1000);
                } else {
                    ElMessage({
                        message: res.msg,
                        type: 'error',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                }
            });
        },
        getBirthDateByAge(age) {
            const today = new Date()
            const birth = new Date(today.getFullYear() - age, today.getMonth(), today.getDate())
            const y = birth.getFullYear()
            const m = String(birth.getMonth() + 1).padStart(2, '0')
            const d = String(birth.getDate()).padStart(2, '0')
            return `${y}-${m}-${d}`
        },
        // 计算年龄
        // calculateAgeFromBirthday(birthday) {
        //     if (!birthday) return 0;
        //     let birthDate = new Date(birthday);
        //     let nowDate = new Date();
        //     let age = nowDate.getFullYear() - birthDate.getFullYear();
        //     if (nowDate.getMonth() < birthDate.getMonth() || (nowDate.getMonth() === birthDate.getMonth() && nowDate.getDate() < birthDate.getDate())) {
        //         age--;
        //     }
        //     return age;
        // },
        // 获取最高学历的学校和专业
        getHighestEducation() {
            if (!this.eduList || this.eduList.length === 0) {
                return { school: '', major: '', degree: '' };
            }
            
            // 学历排序优先级（从高到低）
            const degreePriority = {
                '博士': 6,
                '硕士': 5,
                '本科': 4,
                '大专': 3,
                '高中': 2,
                '初中': 1,
                '其他': 0
            };
            
            // 对学历列表进行排序
            const sortedEduList = [...this.eduList].sort((a, b) => {
                const priorityA = degreePriority[a.degree] || 0;
                const priorityB = degreePriority[b.degree] || 0;
                
                // 优先按学历等级排序
                if (priorityA !== priorityB) {
                    return priorityB - priorityA;
                }
                
                // 学历等级相同时，按结束时间排序（最新的在前）
                const endTimeA = new Date(a.endTime || 0).getTime();
                const endTimeB = new Date(b.endTime || 0).getTime();
                return endTimeB - endTimeA;
            });
            
            // 返回最高学历的信息
            const highestEdu = sortedEduList[0];
            return {
                school: highestEdu.school || '',
                major: highestEdu.profession || '',
                degree: highestEdu.degree || ''
            };
        },
        //查询简历信息
        getJlInfo() {
            this.$Request.get('/app/userFirst/getUserResumes').then(res => {
                if (res.code == 0) {
                    if (res.data) {
                        console.log(res.data);
                        // 保存完整数据
                        this.resumeInfo = res.data;
                        // 同步新结构的各个字段
                        this.eduList = res.data.eduList || []; // 学历列表
                        this.intentions = res.data.intentions || []; // 意向列表
                        this.skills = res.data.skills || []; // 技能列表
                        this.userEntity = res.data.userEntity || {}; // 用户信息
                        // 工作经验详细列表，处理skills字段将JSON字符串转换为数组
                        this.workExpList = (res.data.workExpList || []).map(workExp => {
                            if (workExp.skills && typeof workExp.skills === 'string') {
                                try {
                                    workExp.skills = JSON.parse(workExp.skills);
                                } catch (e) {
                                    workExp.skills = [];
                                }
                            } else if (!Array.isArray(workExp.skills)) {
                                workExp.skills = [];
                            }
                            return workExp;
                        });
                        this.workExpTimes = res.data.workExpTimes || 0; // 工作经历中的技能经历数量
                        this.workExps = res.data.workExps || []; // 工作经历列表

                        // 从resumeList中提取简历基本信息并同步到form中
                        if (res.data.resumeList) {
                            const resumeData = res.data.resumeList;
                            // 同步基本信息到form中
                            this.form.resumesName =
                                res.data.userEntity.userName || '';
                            this.form.resumesAge = resumeData.resumesAge || '';
                            this.form.resumesSex = resumeData.resumesSex || 1;
                            this.form.resumesPhone =
                                resumeData.resumesPhone || '';
                            this.form.resumesMarriage =
                                resumeData.resumesMarriage || '';
                            this.form.address = resumeData.address || '';
                            this.form.resumesEducation =
                                resumeData.resumesEducation || '';
                            this.form.graduationTime =
                                resumeData.graduationTime || '';
                            
                            // 获取最高学历的学校和专业
                            const highestEdu = this.getHighestEducation();
                            this.form.school = highestEdu.school;
                            this.form.major = highestEdu.major;
                            this.form.resumesEducation = highestEdu.degree;
                            this.form.resumesWorkExperience =
                                resumeData.resumesWorkExperience || '';
                            this.form.resumesEmail =
                                resumeData.resumesEmail || '';
                            this.form.resumesStatus =
                                resumeData.resumesStatus || 0;
                            this.form.resumesCompensation =
                                resumeData.resumesCompensation || '';
                            this.form.city = resumeData.city || '';
                            // 同步其他需要的字段
                            // this.form.birthday = resumeData.birthday || '';
                            // this.form.resumesAttachment =
                            //     resumeData.resumesAttachment || '';
                            // this.form.resumesImage =
                            //     resumeData.resumesImage || '';
                            // this.form.resumesImageName =
                            //     resumeData.resumesImageName || '';

                            // 更新性别选择的当前值
                            this.current = resumeData.resumesSex || 1;
                            this.resumesStatus = resumeData.resumesStatus;
                            this.resumesId = resumeData.resumesId;
                        }

                        // 从userEntity中提取用户信息
                        if (res.data.userEntity) {
                            this.nickName = res.data.userEntity.userName || '';
                            this.avatar = res.data.userEntity.avatar || '';
                            // 更新store中的头像
                            this.$store.commit(
                                'SET_AVATAR',
                                res.data.userEntity.avatar || ''
                            );
                        }
                    } else {
                        ElMessageBox.alert('暂无简历，请添加简历', '提示', {
                            confirmButtonText: '确认'
                        });
                    }
                } else {
                    ElMessageBox.alert(res.msg, '提示', {
                        confirmButtonText: '确认'
                    });
                }
            });
        },
        //获取个人信息
        getUserInfo() {
            this.$Request.get('/app/user/selectUserById').then(res => {
                if (res.code == 0) {
                    this.$store.commit('SET_AVATAR', res.data.avatar);
                    this.nickName = res.data.userName;
                    this.avatar = res.data.avatar;
                    if (res.data.userType == 1 || res.data.userType == null) {
                        this.userType = 1;
                        localStorage.setItem('userType', 1);
                    } else {
                        this.userType = 2;
                        localStorage.setItem('userType', 2);
                    }
                }
            });
        },
        /**
         * 获取投递记录、收藏记录、浏览记录
         */
        getUserData() {
            this.$Request.get('/app/user/userData').then(res => {
                if (res.code == 0) {
                    this.browseCount = res.data.browseCount;
                    this.collectionCount = res.data.collectionCount;
                    this.deliveryCount = res.data.deliveryCount;
                }
            });
        },
        //工作性质
        getPostType() {
            let data = {
                type: '工作性质'
            };
            this.$Request.get('/app/dict/list', { params: data }).then(res => {
                if (res.code == 0) {
                    res.data.map(item => {
                        item.label = item.value;
                    });
                    this.workStatus = res.data;
                }
            });
        },
        // 获取部门列表
        getDepartment() {
            this.$Request.post('/app/userFirst/getDepartment', {},{type:'json'}).then((res) => {
                if (res.code == 0) {
                    this.departments = res.data;
                    // 如果是编辑状态且有workExpId，获取工作经历详情
                    if (this.workObj.workExpId && this.workObj.workExpId != '') {
                        this.getData();
                    }
                } else {
                    ElMessage({
                        message: res.msg || '获取部门列表失败',
                        type: 'error',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                }
            });
        },
        // 获取工作经历详情
        getData() {
            this.$Request.get('/app/userFirst/getWorkExpDetailOne', {
                params: {
                    workExpId: this.workObj.workExpId
                }
            }).then((res) => {
                if (res.code == 0) {
                    const data = res.data;
                    // 更新公司信息
                    this.workObj.resumesTitle = data.workExp.companyName || '';
                    this.workObj.businessType = JSON.parse(data.workExp.type) || [];
                    
                    // 更新工作经历详情
                    if (data.workExpDetails && data.workExpDetails.length > 0) {
                        const detail = data.workExpDetails[0];
                        // 时间处理
                        this.workObj.resumesTime = [
                            new Date(detail.startTime),
                            new Date(detail.endTime)
                        ];
                        // 工作内容
                        this.workObj.resumesContent = detail.workContent || '';
                        // 部门信息
                        this.workObj.departmentId = detail.departmentId || 0;
                        this.workObj.department = detail.department || '';
                        // 岗位职级
                        this.workObj.positionLevel = detail.positionLevel || '初级';
                        // 工作业绩
                        this.workObj.workPerformance = detail.workPerformance || '';
                        // 技能处理
                        this.workObj.skills = detail.skills ? JSON.parse(detail.skills) : [];
                        // 岗位职业技能相关字段 - 修正字段映射关系
                        this.workObj.selectedJobPost = detail.position || '';
                        this.workObj.ruleClassifyId = detail.positionId || 0;
                        this.workObj.positionSkills = detail.skills ? JSON.parse(detail.skills) : [];
                        this.workObj.workExpDetailId = detail.workExpDetailId || '';
                    }
                } else {
                    ElMessage({
                        message: res.msg || '获取工作经历详情失败',
                        type: 'error',
                        duration: 1500,
                        offset: this.screenHeight / 2
                    });
                }
            });
        },
        // 处理部门选择变化
        handleDepartmentChange(value) {
            // 根据部门ID获取部门名称
            const selectedDepartment = this.departments.find(item => item.departmentId === value);
            if (selectedDepartment) {
                this.workObj.department = selectedDepartment.departmentName;
            } else {
                this.workObj.department = '';
            }
        },
        //返回
        goBack() {
            this.$router.back();
        },
        //获取最高学历
        getHighestEducation() {
            // 定义学历等级映射（从低到高）
            const educationLevels = {
                '小学': 1,
                '初中': 2,
                '高中': 3,
                '中专': 4,
                '大专': 5,
                '本科': 6,
                '硕士': 7,
                '博士': 8,
                '博士后': 9
            };

            let highestEdu = null;
            let highestLevel = -1;

            // 检查eduList是否存在且是数组
            if (Array.isArray(this.eduList)) {
                this.eduList.forEach(edu => {
                    const level = educationLevels[edu.degree] || 0;
                    if (level > highestLevel) {
                        highestLevel = level;
                        highestEdu = edu;
                    } else if (level === highestLevel) {
                        // 如果学历等级相同，选择结束时间较晚的
                        const currentEndTime = highestEdu.endTime ? new Date(highestEdu.endTime).getTime() : 0;
                        const newEndTime = edu.endTime ? new Date(edu.endTime).getTime() : 0;
                        if (newEndTime > currentEndTime) {
                            highestEdu = edu;
                        }
                    }
                });
            }

            // 返回完整的最高学历信息
            return highestEdu ? {
                school: highestEdu.school,
                major: highestEdu.profession,
                degree: highestEdu.degree
            } : {
                school: '',
                major: '',
                degree: ''
            };
        }
    }
};
</script>
<style lang="scss" scoped>
@import url('index.scss');
.workDialog {
    width: 70% !important;
}

/* 从事方向选择样式 */
.preference-grid {
    padding: 20px;
    max-height: 400px;
    overflow-y: auto;
}

.preference-group {
    margin-bottom: 20px;
}

.preference-title {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 10px;
    color: #333;
}

.preference-children {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.preference-tag {
    padding: 8px 16px;
    border: 1px solid #dcdfe6;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #fff;
    font-size: 14px;
    color: #606266;
}

.preference-tag:hover {
    border-color: #00DD9A;
    color: #00DD9A;
}

.preference-tag.active {
    background-color: #00DD9A;
    border-color: #00DD9A;
    color: #fff;
}
/* 技能标签样式 */
.info-boxsWorks-content-skills {
    display: flex;
    align-items: center;
    margin-top: 10px;
}

.info-boxsWorks-content-skills-title {
    margin-right: 10px;
    font-weight: bold;
    color: #333;
}

.info-boxsWorks-content-skills-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.info-boxsWorks-content-skill-tag {
    padding: 4px 12px;
    background-color: #f0f0f0;
    border-radius: 12px;
    font-size: 14px;
    color: #999999;
    white-space: nowrap;
}
</style>