<template>
  <div class="profile-page-content">
    <!-- 顶部 Tab 导航栏（固定不动） -->
    <div class="profile-page-content__tabs">
      <span
        v-for="tab in tabList"
        :key="tab.key"
        class="profile-page-content__tab-item"
        :class="{ 'profile-page-content__tab-item--active': activeTab === tab.key }"
        @click="scrollToSection(tab.key)"
      >{{ tab.label }}</span>
    </div>

    <!-- 内容滚动区域 -->
    <div ref="scrollContainerRef" class="profile-page-content__body">
    <!-- 个人信息 -->
    <div ref="infoRef" class="profile-page-content__card p10" :class="{ 'profile-page-content__card-hover': editingModule !== 'info' }">
      <template v-if="editingModule !== 'info'">
        <div class="profile-page-content__card-header  pl0 mb-20">
          <h3 class="profile-page-content__card-title"></h3>
          <button class="profile-page-content__edit-btn-inline" @click="startEdit('info')">
            <el-icon><EditPen /></el-icon><span>编辑</span>
          </button>
        </div>
        <div class="profile-page-content__info-name dflex-start aliite-e"><span class="fs28">{{ profile.name }}</span><span v-if="profile.regionCode&&profile.regionCode!='null'" class="fs13 color-6 ml10 dflex-start aliite-c pb5"><svg viewBox="0 0 16 16" fill="none" class="resume-detail__contact-icon">
                  <circle cx="8" cy="6.5" r="2.5" stroke="currentColor" stroke-width="1.2"/>
                  <path d="M8 14s-5-4-5-7.5a5 5 0 0110 0C13 10 8 14 8 14z" stroke="currentColor" stroke-width="1.2"/>
                </svg> {{ resolveRegionName(profile.regionCode) }}</span></div>
        <div class="profile-page-content__info-contacts">
          <span  v-if="profile.phone&&profile.phone!='null'" class="profile-page-content__contact-item"><svg viewBox="0 0 16 16" fill="none" class="resume-detail__contact-icon">
                  <path d="M4 2h2.5l1.5 3-1.5 1.5a8 8 0 003 3L11 8l3 1.5V12a2 2 0 01-2 2C6.5 14 2 9.5 2 4a2 2 0 012-2z" stroke="currentColor" stroke-width="1.2" stroke-linejoin="round"/>
                </svg> {{ profile.phone }}</span>
          <span  v-if="profile.email&&profile.email!='null'" class="profile-page-content__contact-item"><svg viewBox="0 0 16 16" fill="none" class="resume-detail__contact-icon">
                  <rect x="2" y="3" width="12" height="10" rx="1.5" stroke="currentColor" stroke-width="1.2"/>
                  <path d="M2 5.5l6 4 6-4" stroke="currentColor" stroke-width="1.2" stroke-linecap="round"/>
                </svg>{{ profile.email }}</span>


          <span class="profile-page-content__info-contacts" v-if="profile.wechat&&profile.wechat!='null'">
            <span class="profile-page-content__contact-item"><el-icon class="fs14 color-9"><ChatLineRound /></el-icon> {{ profile.wechat }}</span>
          </span>
          <!-- 作品集链接显示在个人信息卡片内 -->
          <span v-if="profile.portfolioUrl&&profile.portfolioUrl!='null'" class="profile-page-content__info-contacts">
            <span class="profile-page-content__contact-item dib">
              <svg xmlns="http://www.w3.org/2000/svg" class="resume-detail__contact-icon mr6" width="0.15rem" height="0.15rem" viewBox="0 0 16 16">
                <path d="M0 0h16v16H0z" fill="none" />
                <path fill="none" stroke="currentColor" d="M14.5 8A6.5 6.5 0 0 1 8 14.5M14.5 8A6.5 6.5 0 0 0 8 1.5M14.5 8c0 1.657-2.91 3-6.5 3S1.5 9.657 1.5 8m13 0c0-1.657-2.91-3-6.5-3S1.5 6.343 1.5 8M8 14.5A6.5 6.5 0 0 1 1.5 8M8 14.5c1.657 0 3-2.91 3-6.5S9.657 1.5 8 1.5m0 13c-1.657 0-3-2.91-3-6.5s1.343-6.5 3-6.5M1.5 8A6.5 6.5 0 0 1 8 1.5" />
              </svg>
              <a :href="profile.portfolioUrl?.startsWith('http') ? profile.portfolioUrl : `http://${profile.portfolioUrl}`" target="_blank" rel="noopener noreferrer" class="profile-page-content__portfolio-link">{{ profile.portfolioUrl }}</a>
            </span>
          </span>
        </div>
      </template>
      <!-- 编辑模式 -->
      <ProfileEditDrawer
        v-if="editingModule === 'info'"
        v-model="editVisible"
        module="info"
        :initial-data="editInitialData"
        @save="handleSave"
        @cancel="cancelEdit"
      />
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14 mt14"></div>

    <!-- 个人概述 -->
    <div ref="summaryRef" class="profile-page-content__card mtb16" :class="{ 'profile-page-content__card-hover': editingModule !== 'summary' }">
      <template v-if="editingModule !== 'summary'">
        <div class="profile-page-content__card-header">
          <h3 class="profile-page-content__card-title">个人概述</h3>
          <button class="profile-page-content__edit-btn-inline" @click="startEdit('summary')">
            <el-icon><EditPen /></el-icon><span>编辑</span>
          </button>
        </div>
        <div class="profile-page-content__summary-text" v-if="profile.summary">{{ profile.summary }}</div>
        <div class="profile-page-content__summary-text color-9" v-else>暂无个人概述</div>
      </template>
      <ProfileEditDrawer
        v-if="editingModule === 'summary'"
        v-model="editVisible"
        module="summary"
        :initial-data="editInitialData"
        @save="handleSave"
        @cancel="cancelEdit"
      />
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

    <!-- 教育经历 -->
    <div ref="educationRef" class="profile-page-content__card">
      <div class="profile-page-content__card-header profile-page-content__header-hover">
        <h3 class="profile-page-content__card-title">教育经历</h3>
        <button class="profile-page-content__edit-btn-inline" @click="startAdd('education')">
          <el-icon><Plus /></el-icon><span>添加</span>
        </button>
      </div>
      <!-- 新增 -->
      <ResumeExpInlineEdit v-if="addingModule === 'education'" module-type="education" @save="handleExpAdd('education', $event)" @cancel="addingModule = ''" />
      <div v-for="(edu, i) in profile.education" :key="i" class="profile-page-content__section-item"  @click.stop="startEditExp('education', i, edu)">
        <template v-if="editingExpIndex !== `education_${i}`">
          <div class="profile-page-content__item-row">
            <div class="profile-page-content__item-left">
              <div class="profile-page-content__item-title">{{ edu.school }}</div>
              <div class="profile-page-content__item-sub">{{ getDegreeText(edu.studyType, edu.degree) }} · {{ edu.major }}</div>
            </div>
            <!-- 时间（默认显示，hover时隐藏） -->
            <div class="profile-page-content__item-date profile-page-content__item-date--toggle">{{ edu.startDate }} - {{ edu.endDate }}</div>
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn">
              <el-icon><EditPen /></el-icon><span>编辑</span>
            </button>
            <!-- 删除按钮 -->
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn" @click.stop="handleExpDelete('education', i)" aria-label="删除">
              <el-icon><DeleteFilled /></el-icon><span>删除</span>
            </button>
          </div>
          <ul class="profile-page-content__item-list" v-if="edu.description?.length && edu.description[0]?.text">
            <li v-for="desc in edu.description" :key="desc.id">{{ desc.text }}</li>
          </ul>
        </template>
        <ResumeExpInlineEdit v-else module-type="education" :initial-data="edu" @save="handleExpUpdate('education', i, $event)" @cancel="editingExpIndex = ''" />
      </div>
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

    <!-- 工作经历 -->
    <div ref="workRef" class="profile-page-content__card">
      <div class="profile-page-content__card-header profile-page-content__header-hover">
        <h3 class="profile-page-content__card-title">工作经历</h3>
        <button class="profile-page-content__edit-btn-inline" @click="startAdd('work')">
          <el-icon><Plus /></el-icon><span>添加</span>
        </button>
      </div>
      <ResumeExpInlineEdit v-if="addingModule === 'work'" module-type="work" @save="handleExpAdd('work', $event)" @cancel="addingModule = ''" />
      <div v-for="(exp, i) in profile.works" :key="i" class="profile-page-content__section-item"  @click.stop="startEditExp('work', i, exp)">
        <template v-if="editingExpIndex !== `work_${i}`">
          <div class="profile-page-content__item-row">
            <div class="profile-page-content__item-left">
              <div class="profile-page-content__item-title">{{ exp.companyName }}</div>
              <div class="profile-page-content__item-sub">{{ exp.position }}</div>
            </div>
            <!-- 时间（默认显示，hover时隐藏） -->
            <div class="profile-page-content__item-period profile-page-content__item-date--toggle">{{ exp.startDate }} - {{ exp.endDate || '至今' }}</div>
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn">
              <el-icon><EditPen /></el-icon><span>编辑</span>
            </button>
            <!-- 删除按钮 -->
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn" @click.stop="handleExpDelete('work', i)" aria-label="删除">
              <el-icon><DeleteFilled /></el-icon><span>删除</span>
            </button>
          </div>
          <ul class="profile-page-content__item-list">
            <li v-for="desc in exp.description" :key="desc.id">{{ desc.text }}</li>
          </ul>
        </template>
        <ResumeExpInlineEdit v-else module-type="work" :initial-data="exp" @save="handleExpUpdate('work', i, $event)" @cancel="editingExpIndex = ''" />
      </div>
    </div>

      <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

      <!-- 实习经历 -->
    <div ref="internshipRef" class="profile-page-content__card">
      <div class="profile-page-content__card-header profile-page-content__header-hover">
        <h3 class="profile-page-content__card-title">实习经历</h3>
        <button class="profile-page-content__edit-btn-inline" @click="startAdd('internship')">
          <el-icon><Plus /></el-icon><span>添加</span>
        </button>
      </div>
      <ResumeExpInlineEdit v-if="addingModule === 'internship'" module-type="internship" @save="handleExpAdd('internship', $event)" @cancel="addingModule = ''" />
      <div v-for="(exp, i) in profile.internships" :key="i" class="profile-page-content__section-item"  @click.stop="startEditExp('internship', i, exp)">
        <template v-if="editingExpIndex !== `internship_${i}`">
          <div class="profile-page-content__item-row">
            <div class="profile-page-content__item-left">
              <div class="profile-page-content__item-title">{{ exp.companyName }}</div>
              <div class="profile-page-content__item-sub">{{ exp.position }}</div>
            </div>
            <!-- 时间（默认显示，hover时隐藏） -->
            <div class="profile-page-content__item-period profile-page-content__item-date--toggle">{{ exp.startDate }} - {{ exp.endDate }}</div>
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn">
              <el-icon><EditPen /></el-icon><span>编辑</span>
            </button>
            <!-- 删除按钮 -->
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn" @click.stop="handleExpDelete('internship', i)" aria-label="删除">
              <el-icon><DeleteFilled /></el-icon><span>删除</span>
            </button>
          </div>
          <ul class="profile-page-content__item-list">
            <li v-for="desc in exp.description" :key="desc.id">{{ desc.text }}</li>
          </ul>
        </template>
        <ResumeExpInlineEdit v-else module-type="internship" :initial-data="exp" @save="handleExpUpdate('internship', i, $event)" @cancel="editingExpIndex = ''" />
      </div>
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

    <!-- 项目经历 -->
    <div ref="projectRef" class="profile-page-content__card">
      <div class="profile-page-content__card-header profile-page-content__header-hover">
        <h3 class="profile-page-content__card-title">项目经历</h3>
        <button class="profile-page-content__edit-btn-inline" @click="startAdd('project')">
          <el-icon><Plus /></el-icon><span>添加</span>
        </button>
      </div>
      <ResumeExpInlineEdit v-if="addingModule === 'project'" module-type="project" @save="handleExpAdd('project', $event)" @cancel="addingModule = ''" />
      <div v-for="(proj, i) in profile.projects" :key="i" class="profile-page-content__section-item"  @click.stop="startEditExp('project', i, proj)">
        <template v-if="editingExpIndex !== `project_${i}`">
          <div class="profile-page-content__item-row">
            <div class="profile-page-content__item-left">
              <div class="profile-page-content__item-title">{{ proj.projectName }}</div>
              <div class="profile-page-content__item-sub" v-if="proj.role">{{ proj.role }}</div>
            </div>
            <!-- 时间（默认显示，hover时隐藏） -->
            <div class="profile-page-content__item-period profile-page-content__item-date--toggle">{{ proj.startDate }} - {{ proj.endDate }}</div>
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn">
              <el-icon><EditPen /></el-icon><span>编辑</span>
            </button>
            <!-- 删除按钮 -->
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn" @click.stop="handleExpDelete('project', i)" aria-label="删除">
              <el-icon><DeleteFilled /></el-icon><span>删除</span>
            </button>
          </div>
          <ul class="profile-page-content__item-list">
            <li v-for="desc in proj.description" :key="desc.id">{{ desc.text }}</li>
          </ul>
        </template>
        <ResumeExpInlineEdit v-else module-type="project" :initial-data="proj" @save="handleExpUpdate('project', i, $event)" @cancel="editingExpIndex = ''" />
      </div>
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

    <!-- 竞赛 -->
    <div ref="competitionRef" class="profile-page-content__card">
      <div class="profile-page-content__card-header profile-page-content__header-hover">
        <h3 class="profile-page-content__card-title">竞赛</h3>
        <button class="profile-page-content__edit-btn-inline" @click="startAdd('competition')">
          <el-icon><Plus /></el-icon><span>添加</span>
        </button>
      </div>
      <ResumeExpInlineEdit v-if="addingModule === 'competition'" module-type="competition" @save="handleExpAdd('competition', $event)" @cancel="addingModule = ''" />
      <div v-for="(comp, i) in profile.competitions" :key="i" class="profile-page-content__section-item" @click.stop="startEditExp('competition', i, comp)">
        <template v-if="editingExpIndex !== `competition_${i}`">
          <div class="profile-page-content__item-row">
            <div class="profile-page-content__item-left">
              <div class="profile-page-content__item-title">{{ comp.competitionName }} · {{ comp.award }}</div>
            </div>
            <!-- 时间（默认显示，hover时隐藏） -->
            <div class="profile-page-content__item-period profile-page-content__item-date--toggle">{{ comp.awardDate }}</div>
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn">
              <el-icon><EditPen /></el-icon><span>编辑</span>
            </button>
            <!-- 删除按钮 -->
            <button class="profile-page-content__edit-btn-inline profile-page-content__item-edit-btn" @click.stop="handleExpDelete('competition', i)" aria-label="删除">
              <el-icon><DeleteFilled /></el-icon><span>删除</span>
            </button>
          </div>
          <ul class="profile-page-content__item-list" v-if="comp.description[0]?.text">
            <li v-for="desc in comp.description" :key="desc.id">{{ desc.text }}</li>
          </ul>
        </template>
        <ResumeExpInlineEdit v-else module-type="competition" :initial-data="comp" @save="handleExpUpdate('competition', i, $event)" @cancel="editingExpIndex = ''" />
      </div>
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

    <!-- 技能 -->
    <div ref="skillsRef" class="profile-page-content__card mtb16" :class="{ 'profile-page-content__card-hover': editingModule !== 'skills' }">
      <template v-if="editingModule !== 'skills'">
        <div class="profile-page-content__card-header">
          <h3 class="profile-page-content__card-title">技能</h3>
          <button class="profile-page-content__edit-btn-inline" @click="startEdit('skills')">
            <el-icon><EditPen /></el-icon><span>编辑</span>
          </button>
        </div>
        <div class="profile-page-content__tags">
          <span v-for="(skill, i) in profile.skills" :key="i" class="profile-page-content__tag">{{ skill }}</span>
        </div>
      </template>
      <ProfileEditDrawer
        v-if="editingModule === 'skills'"
        v-model="editVisible"
        module="skills"
        :initial-data="editInitialData"
        @save="handleSave"
        @cancel="cancelEdit"
      />
    </div>

    <div class="h1 border-EDF9FA-bottom-2 mrl14"></div>

    <!-- 证书 -->
    <div ref="certificateRef" class="profile-page-content__card mtb16" :class="{ 'profile-page-content__card-hover': editingModule !== 'certificate' }">
      <template v-if="editingModule !== 'certificate'">
        <div class="profile-page-content__card-header">
          <h3 class="profile-page-content__card-title">证书</h3>
          <button class="profile-page-content__edit-btn-inline" @click="startEdit('certificate')">
            <el-icon><EditPen /></el-icon><span>编辑</span>
          </button>
        </div>
        <div class="profile-page-content__tags">
          <span v-for="(cert, i) in profile.certificates" :key="i" class="profile-page-content__tag">{{ cert }}</span>
        </div>
      </template>
      <ProfileEditDrawer
        v-if="editingModule === 'certificate'"
        v-model="editVisible"
        module="certificate"
        :initial-data="editInitialData"
        @save="handleSave"
        @cancel="cancelEdit"
      />
    </div>
    </div><!-- 内容滚动区域结束 -->
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import {EditPen, Plus, DeleteFilled, ChatLineRound} from '@element-plus/icons-vue'
import { resolveRegionName } from '@/utils/region'
import ProfileEditDrawer from '@/components/ProfileEditDrawer.vue'
import ResumeExpInlineEdit from '@/components/ResumeExpInlineEdit.vue'

/** Tab 导航列表 */
const tabList = [
  { key: 'info', label: '个人信息' },
  { key: 'summary', label: '个人概述' },
  { key: 'education', label: '教育经历' },
  { key: 'work', label: '工作经历' },
  { key: 'internship', label: '实习经历' },
  { key: 'project', label: '项目经历' },
  { key: 'skills', label: '技能' },
  { key: 'competition', label: '竞赛' },
  { key: 'certificate', label: '证书' },
]

/** 当前激活的 tab */
const activeTab = ref('info')

/** 各模块的 DOM 引用 */
const scrollContainerRef = ref<HTMLElement | null>(null)
const infoRef = ref<HTMLElement | null>(null)
const summaryRef = ref<HTMLElement | null>(null)
const educationRef = ref<HTMLElement | null>(null)
const workRef = ref<HTMLElement | null>(null)
const internshipRef = ref<HTMLElement | null>(null)
const projectRef = ref<HTMLElement | null>(null)
const skillsRef = ref<HTMLElement | null>(null)
const competitionRef = ref<HTMLElement | null>(null)
const certificateRef = ref<HTMLElement | null>(null)

/** 模块 key 与 ref 的映射 */
const sectionRefMap: Record<string, typeof infoRef> = {
  info: infoRef,
  summary: summaryRef,
  education: educationRef,
  work: workRef,
  internship: internshipRef,
  project: projectRef,
  skills: skillsRef,
  competition: competitionRef,
  certificate: certificateRef,
}

/** 点击 tab 滚动到对应模块 */
function scrollToSection(key: string) {
  activeTab.value = key
  const targetRef = sectionRefMap[key]
  const container = scrollContainerRef.value
  if (targetRef?.value && container) {
    const offsetTop = targetRef.value.offsetTop - container.offsetTop
    container.scrollTo({ top: offsetTop, behavior: 'smooth' })
  }
}

/** 个人资料数据结构 */
interface ProfileData {
  name: string
  phone: string
  email: string
  idNumber: string
  regionCode: string
  portfolioUrl: string
  wechat?: string
  summary?: string
  education: Array<{ school: string; major: string; studyType: string | number; degree: string | number; startDate: string; endDate: string; description: Array<{ id: string; text: string }> }>
  works: Array<{ companyName: string; position: string; startDate: string; endDate: string; description: Array<{ id: string; text: string }> }>
  internships: Array<{ companyName: string; position: string; startDate: string; endDate: string; description: Array<{ id: string; text: string }> }>
  projects: Array<{ projectName: string; companyName: string; role: string; startDate: string; endDate: string; description: Array<{ id: string; text: string }> }>
  skills: string[]
  competitions: Array<{ competitionName: string; award: string; awardDate: string; description: Array<{ id: string; text: string }> }>
  certificates: string[]
}

const props = defineProps<{
  profile: ProfileData
}>()

const emit = defineEmits<{
  /** 模块编辑保存事件 */
  (e: 'edit', section: string): void
  /** 内联保存事件（模块名+数据） */
  (e: 'save', section: string, data: Record<string, any>): void
  /** 单条经历更新事件 */
  (e: 'expUpdate', moduleType: string, index: number, data: Record<string, any>): void
  /** 新增经历事件 */
  (e: 'expAdd', moduleType: string, data: Record<string, any>): void
  /** 删除经历事件 */
  (e: 'expDelete', moduleType: string, index: number): void
}>()

/** 当前编辑的模块（info/skills/certificate） */
const editingModule = ref('')

/** 编辑可见状态 */
const editVisible = ref(false)

/** 编辑初始数据 */
const editInitialData = ref<Record<string, any>>({})

/** 当前编辑的经历索引 key（格式：moduleType_index） */
const editingExpIndex = ref('')

/** 当前添加经历的模块 */
const addingModule = ref('')

/** 获取学历文本 — 兼容数字和中文字符串 */
function getDegreeText(studyType: string | number, degree: string | number): string {
  // studyType 可能是 0/1 数字 或 "全日制"/"非全日制" 字符串
  const studyTypeMap: Record<number, string> = { 0: '全日制', 1: '非全日制' }
  const studyTypeText = typeof studyType === 'number' ? (studyTypeMap[studyType] || '') : (studyType || '')
  // degree 可能是 1/2/3/4 数字 或 "大专"/"本科"/"硕士"/"博士" 字符串
  const degreeMap: Record<number, string> = { 1: '大专', 2: '本科', 3: '硕士', 4: '博士' }
  const degreeText = typeof degree === 'number' ? (degreeMap[degree] || '') : (degree || '')
  return `${studyTypeText}${degreeText}`
}

/** 打开模块编辑（个人信息/技能/证书） */
function startEdit(module: string) {
  editingModule.value = module
  editVisible.value = true
  editingExpIndex.value = ''
  addingModule.value = ''
  if (module === 'info') {
    editInitialData.value = {
      name: props.profile.name || '',
      email: props.profile.email || '',
      phone: props.profile.phone || '',
      location: props.profile.regionCode || '',
      wechat: props.profile.wechat || '',
      portfolioUrl: props.profile.portfolioUrl || '',
    }
  } else if (module === 'skills') {
    editInitialData.value = { skills: [...(props.profile.skills || [])] }
  } else if (module === 'certificate') {
    editInitialData.value = { certificates: [...(props.profile.certificates || [])] }
  } else if (module === 'summary') {
    editInitialData.value = { summary: props.profile.summary || '' }
  }
}

/** 取消编辑 */
function cancelEdit() {
  editingModule.value = ''
  editVisible.value = false
}

/** 保存编辑（个人信息/技能/证书） */
function handleSave(data: Record<string, any>) {
  emit('save', editingModule.value, data)
  editingModule.value = ''
  editVisible.value = false
}

/** 开始添加经历 */
function startAdd(moduleType: string) {
  addingModule.value = moduleType
  editingExpIndex.value = ''
  editingModule.value = ''
}

/** 开始编辑单条经历 */
function startEditExp(_moduleType: string, index: number, _record: any) {
  editingExpIndex.value = `${_moduleType}_${index}`
  addingModule.value = ''
  editingModule.value = ''
}

/** 保存经历更新 */
function handleExpUpdate(moduleType: string, index: number, data: Record<string, any>) {
  emit('expUpdate', moduleType, index, data)
  editingExpIndex.value = ''
}

/** 保存新增经历 */
function handleExpAdd(moduleType: string, data: Record<string, any>) {
  emit('expAdd', moduleType, data)
  addingModule.value = ''
}

/** 删除单条经历（直接触发，不弹确认框，由父组件处理确认） */
function handleExpDelete(moduleType: string, index: number) {
  emit('expDelete', moduleType, index)
}
</script>

<style scoped lang="scss">
@use '../assets/styles/components/profile-page-content';
</style>
