hookehuyr

refactor(plan): 移除年龄与出生年月日的联动逻辑

- 删除 CriticalIllnessTemplate、LifeInsuranceTemplate 中的 watch 联动代码
- 删除所有模板 validate() 中的"以生日为准计算年龄"逻辑
- 年龄和出生年月日现在是独立的二选一字段
- 保留原始代码注释,便于将来恢复

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
......@@ -3,6 +3,18 @@
记录项目开发过程中的重要变更和完成任务。
## 2026-02-28
### 20:42:20 - refactor(plan): 移除年龄与出生年月日的联动逻辑
**影响文件**:
- `src/components/plan/PlanTemplates/CriticalIllnessTemplate.vue`
- `src/components/plan/PlanTemplates/LifeInsuranceTemplate.vue`
**变更摘要**:
- 移除年龄与出生年月日的联动逻辑
---
### 20:30:15 - feat(husky): 使用 prepare-commit-msg + amend 实现 CHANGELOG 自动更新
**影响文件**:
......
......@@ -249,32 +249,30 @@ watch(
{ deep: true }
)
/**
* 年龄与出生年月日自动计算逻辑
* - 填年龄 → 推算生日(默认当年1月1日)
* - 填生日 → 计算年龄
*/
watch(
() => form.age,
(newAge) => {
if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) {
const currentYear = new Date().getFullYear()
const birthYear = currentYear - parseInt(newAge)
form.birthday = `${birthYear}-01-01`
}
}
)
watch(
() => form.birthday,
(newBirthday) => {
if (!isEmptyValue(newBirthday)) {
const birthYear = new Date(newBirthday).getFullYear()
const currentYear = new Date().getFullYear()
form.age = currentYear - birthYear
}
}
)
// 年龄与出生年月日已取消联动,客户要求二者独立填写
// 如需恢复联动,可参考以下代码:
//
// watch(
// () => form.age,
// (newAge) => {
// if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) {
// const currentYear = new Date().getFullYear()
// const birthYear = currentYear - parseInt(newAge)
// form.birthday = `${birthYear}-01-01`
// }
// }
// )
//
// watch(
// () => form.birthday,
// (newBirthday) => {
// if (!isEmptyValue(newBirthday)) {
// const birthYear = new Date(newBirthday).getFullYear()
// const currentYear = new Date().getFullYear()
// form.age = currentYear - birthYear
// }
// }
// )
/**
* 百分比输入清洗,避免非法字符
......@@ -349,13 +347,6 @@ const validate = () => {
return false
}
// 如果都填写了,以生日为准,重新计算年龄
if (hasAge && hasBirthday) {
const birthYear = new Date(form.birthday).getFullYear()
const currentYear = new Date().getFullYear()
form.age = currentYear - birthYear
}
for (const field of fields) {
if (!isFieldVisible(field.key)) {
continue
......
......@@ -251,34 +251,32 @@ watch(
{ deep: true }
)
/**
* 年龄与出生年月日自动计算逻辑
* - 填年龄 → 推算生日(默认当年1月1日)
* - 填生日 → 计算年龄
*/
watch(
() => form.age,
(newAge) => {
if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) {
// 填了年龄,推算生日(默认当年1月1日)
const currentYear = new Date().getFullYear()
const birthYear = currentYear - parseInt(newAge)
form.birthday = `${birthYear}-01-01`
}
}
)
watch(
() => form.birthday,
(newBirthday) => {
if (!isEmptyValue(newBirthday)) {
// 填了生日,计算年龄
const birthYear = new Date(newBirthday).getFullYear()
const currentYear = new Date().getFullYear()
form.age = currentYear - birthYear
}
}
)
// 年龄与出生年月日已取消联动,客户要求二者独立填写
// 如需恢复联动,可参考以下代码:
//
// watch(
// () => form.age,
// (newAge) => {
// if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) {
// // 填了年龄,推算生日(默认当年1月1日)
// const currentYear = new Date().getFullYear()
// const birthYear = currentYear - parseInt(newAge)
// form.birthday = `${birthYear}-01-01`
// }
// }
// )
//
// watch(
// () => form.birthday,
// (newBirthday) => {
// if (!isEmptyValue(newBirthday)) {
// // 填了生日,计算年龄
// const birthYear = new Date(newBirthday).getFullYear()
// const currentYear = new Date().getFullYear()
// form.age = currentYear - birthYear
// }
// }
// )
/**
* 百分比输入清洗,避免非法字符
......@@ -353,14 +351,6 @@ const validate = () => {
return false
}
// 如果都填写了,以生日为准,重新计算年龄
if (hasAge && hasBirthday) {
// 使用生日重新计算年龄
const birthYear = new Date(form.birthday).getFullYear()
const currentYear = new Date().getFullYear()
form.age = String(currentYear - birthYear)
}
for (const field of fields) {
if (!isFieldVisible(field.key)) {
continue
......
......@@ -926,13 +926,6 @@ const validate = () => {
return false
}
// 如果都填写了,以生日为准,重新计算年龄
if (hasAge && hasBirthday) {
const birthYear = new Date(form.birthday).getFullYear()
const currentYear = new Date().getFullYear()
form.age = currentYear - birthYear
}
// 2. 校验基础字段和 withdrawal_fields 中可见的必填字段
for (const field of fields) {
if (!isFieldVisible(field.key)) {
......