摩卡级联操作,地区选择操作

This commit is contained in:
2026-08-05 10:58:35 +08:00
parent e8c306946f
commit d5b273ebc0
6 changed files with 770 additions and 41 deletions
+35 -3
View File
@@ -8,7 +8,7 @@ import { useState, useEffect, useRef, useCallback } from "react"
import { getCookieValue } from "~utils/cookie"
import { get as storageGet, set as storageSet, remove as storageRemove } from "~utils/storage"
import { getCustomizeResume } from "~api/aiApi"
import { getMemberStatus } from "~api/dataApi"
import { getMemberStatus, preloadRegionTree } from "~api/dataApi"
import { handleAutoFillCommon } from "~handlers/handleAutoFillCommon"
import { handleAutoFillBeisen } from "~handlers/handleAutoFillBeisen"
import { handleAutoFillMoka } from "~handlers/handleAutoFillMoka"
@@ -305,6 +305,9 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps)
return
}
// 预加载省市区行政区划数据(供摩卡级联选择器使用)
preloadRegionTree()
// 查询会员状态
getMemberStatus().then((memberData) => {
console.log("[OfferPie] 会员状态:", memberData)
@@ -666,6 +669,35 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps)
}
}
/**
* 过滤日期/时间字段值中的年龄后缀,如 "1997-05 (29岁)" → "1997-05"
* 匹配中英文括号包裹的"数字+岁/years old"格式
*/
const stripAgeSuffix = (label: string, value: string): string => {
if (!value) return value
const dateKeywords = ["日期", "时间", "年月", "生日", "出生", "date", "birth", "年龄"]
const isDateField = dateKeywords.some((k) => label.toLowerCase().includes(k.toLowerCase()))
if (!isDateField) return value
// 去掉中英文括号包裹的年龄信息:(29岁)(29岁)(29 years old) 等
return value.replace(/\s*[(\uff08]\s*\d+\s*(岁|years?\s*old)\s*[)\uff09]/gi, "").trim()
}
/**
* 地区类字段空格转斜杠:如 "山西 大同市" → "山西/大同市"
* 适用于:籍贯、户口、所在地、出生地、工作地等地区相关字段
* @param label - 字段标签名(用于判断是否为地区字段)
* @param value - 字段当前值
* @returns 处理后的值(非地区字段原样返回)
*/
const formatRegionValue = (label: string, value: string): string => {
if (!value) return value
const regionKeywords = ["籍贯", "户口", "所在地", "出生地", "工作地", "居住地", "家庭地址", "户籍", "地区", "城市", "省市", "location", "birthplace", "hometown", "residence"]
const isRegionField = regionKeywords.some((k) => label.toLowerCase().includes(k.toLowerCase()))
if (!isRegionField) return value
// 将空格替换为 /(如 "山西 大同市" → "山西/大同市"
return value.replace(/\s+/g, "/")
}
// 提取非简历格式字段(B2阶段字段)
const nonResumeData = extractNonResumeFields(titleStats)
@@ -692,7 +724,7 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps)
for (const nf of newFields) {
const of_ = oldFields.find((f: any) => f.label === nf.label)
if (of_) {
if (nf.value) of_.value = nf.value
if (nf.value) of_.value = formatRegionValue(nf.label || "", stripAgeSuffix(nf.label || "", nf.value))
} else {
oldFields.push(nf)
}
@@ -706,7 +738,7 @@ export function SidebarPanel({ sourceUrl, jobInfo, onClose }: SidebarPanelProps)
for (const nf of newFields) {
const of_ = oldFields.find((f: any) => f.label === nf.label)
if (of_) {
if (nf.value) of_.value = nf.value
if (nf.value) of_.value = formatRegionValue(nf.label || "", stripAgeSuffix(nf.label || "", nf.value))
} else {
oldFields.push(nf)
}