hookehuyr

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

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

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
...@@ -3,6 +3,18 @@ ...@@ -3,6 +3,18 @@
3 记录项目开发过程中的重要变更和完成任务。 3 记录项目开发过程中的重要变更和完成任务。
4 4
5 ## 2026-02-28 5 ## 2026-02-28
6 +### 20:42:20 - refactor(plan): 移除年龄与出生年月日的联动逻辑
7 +
8 +**影响文件**:
9 +- `src/components/plan/PlanTemplates/CriticalIllnessTemplate.vue`
10 +- `src/components/plan/PlanTemplates/LifeInsuranceTemplate.vue`
11 +
12 +**变更摘要**:
13 +- 移除年龄与出生年月日的联动逻辑
14 +
15 +---
16 +
17 +
6 ### 20:30:15 - feat(husky): 使用 prepare-commit-msg + amend 实现 CHANGELOG 自动更新 18 ### 20:30:15 - feat(husky): 使用 prepare-commit-msg + amend 实现 CHANGELOG 自动更新
7 19
8 **影响文件**: 20 **影响文件**:
......
...@@ -249,32 +249,30 @@ watch( ...@@ -249,32 +249,30 @@ watch(
249 { deep: true } 249 { deep: true }
250 ) 250 )
251 251
252 -/** 252 +// 年龄与出生年月日已取消联动,客户要求二者独立填写
253 - * 年龄与出生年月日自动计算逻辑 253 +// 如需恢复联动,可参考以下代码:
254 - * - 填年龄 → 推算生日(默认当年1月1日) 254 +//
255 - * - 填生日 → 计算年龄 255 +// watch(
256 - */ 256 +// () => form.age,
257 -watch( 257 +// (newAge) => {
258 - () => form.age, 258 +// if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) {
259 - (newAge) => { 259 +// const currentYear = new Date().getFullYear()
260 - if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) { 260 +// const birthYear = currentYear - parseInt(newAge)
261 - const currentYear = new Date().getFullYear() 261 +// form.birthday = `${birthYear}-01-01`
262 - const birthYear = currentYear - parseInt(newAge) 262 +// }
263 - form.birthday = `${birthYear}-01-01` 263 +// }
264 - } 264 +// )
265 - } 265 +//
266 -) 266 +// watch(
267 - 267 +// () => form.birthday,
268 -watch( 268 +// (newBirthday) => {
269 - () => form.birthday, 269 +// if (!isEmptyValue(newBirthday)) {
270 - (newBirthday) => { 270 +// const birthYear = new Date(newBirthday).getFullYear()
271 - if (!isEmptyValue(newBirthday)) { 271 +// const currentYear = new Date().getFullYear()
272 - const birthYear = new Date(newBirthday).getFullYear() 272 +// form.age = currentYear - birthYear
273 - const currentYear = new Date().getFullYear() 273 +// }
274 - form.age = currentYear - birthYear 274 +// }
275 - } 275 +// )
276 - }
277 -)
278 276
279 /** 277 /**
280 * 百分比输入清洗,避免非法字符 278 * 百分比输入清洗,避免非法字符
...@@ -349,13 +347,6 @@ const validate = () => { ...@@ -349,13 +347,6 @@ const validate = () => {
349 return false 347 return false
350 } 348 }
351 349
352 - // 如果都填写了,以生日为准,重新计算年龄
353 - if (hasAge && hasBirthday) {
354 - const birthYear = new Date(form.birthday).getFullYear()
355 - const currentYear = new Date().getFullYear()
356 - form.age = currentYear - birthYear
357 - }
358 -
359 for (const field of fields) { 350 for (const field of fields) {
360 if (!isFieldVisible(field.key)) { 351 if (!isFieldVisible(field.key)) {
361 continue 352 continue
......
...@@ -251,34 +251,32 @@ watch( ...@@ -251,34 +251,32 @@ watch(
251 { deep: true } 251 { deep: true }
252 ) 252 )
253 253
254 -/** 254 +// 年龄与出生年月日已取消联动,客户要求二者独立填写
255 - * 年龄与出生年月日自动计算逻辑 255 +// 如需恢复联动,可参考以下代码:
256 - * - 填年龄 → 推算生日(默认当年1月1日) 256 +//
257 - * - 填生日 → 计算年龄 257 +// watch(
258 - */ 258 +// () => form.age,
259 -watch( 259 +// (newAge) => {
260 - () => form.age, 260 +// if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) {
261 - (newAge) => { 261 +// // 填了年龄,推算生日(默认当年1月1日)
262 - if (!isEmptyValue(newAge) && isEmptyValue(form.birthday)) { 262 +// const currentYear = new Date().getFullYear()
263 - // 填了年龄,推算生日(默认当年1月1日) 263 +// const birthYear = currentYear - parseInt(newAge)
264 - const currentYear = new Date().getFullYear() 264 +// form.birthday = `${birthYear}-01-01`
265 - const birthYear = currentYear - parseInt(newAge) 265 +// }
266 - form.birthday = `${birthYear}-01-01` 266 +// }
267 - } 267 +// )
268 - } 268 +//
269 -) 269 +// watch(
270 - 270 +// () => form.birthday,
271 -watch( 271 +// (newBirthday) => {
272 - () => form.birthday, 272 +// if (!isEmptyValue(newBirthday)) {
273 - (newBirthday) => { 273 +// // 填了生日,计算年龄
274 - if (!isEmptyValue(newBirthday)) { 274 +// const birthYear = new Date(newBirthday).getFullYear()
275 - // 填了生日,计算年龄 275 +// const currentYear = new Date().getFullYear()
276 - const birthYear = new Date(newBirthday).getFullYear() 276 +// form.age = currentYear - birthYear
277 - const currentYear = new Date().getFullYear() 277 +// }
278 - form.age = currentYear - birthYear 278 +// }
279 - } 279 +// )
280 - }
281 -)
282 280
283 /** 281 /**
284 * 百分比输入清洗,避免非法字符 282 * 百分比输入清洗,避免非法字符
...@@ -353,14 +351,6 @@ const validate = () => { ...@@ -353,14 +351,6 @@ const validate = () => {
353 return false 351 return false
354 } 352 }
355 353
356 - // 如果都填写了,以生日为准,重新计算年龄
357 - if (hasAge && hasBirthday) {
358 - // 使用生日重新计算年龄
359 - const birthYear = new Date(form.birthday).getFullYear()
360 - const currentYear = new Date().getFullYear()
361 - form.age = String(currentYear - birthYear)
362 - }
363 -
364 for (const field of fields) { 354 for (const field of fields) {
365 if (!isFieldVisible(field.key)) { 355 if (!isFieldVisible(field.key)) {
366 continue 356 continue
......
...@@ -926,13 +926,6 @@ const validate = () => { ...@@ -926,13 +926,6 @@ const validate = () => {
926 return false 926 return false
927 } 927 }
928 928
929 - // 如果都填写了,以生日为准,重新计算年龄
930 - if (hasAge && hasBirthday) {
931 - const birthYear = new Date(form.birthday).getFullYear()
932 - const currentYear = new Date().getFullYear()
933 - form.age = currentYear - birthYear
934 - }
935 -
936 // 2. 校验基础字段和 withdrawal_fields 中可见的必填字段 929 // 2. 校验基础字段和 withdrawal_fields 中可见的必填字段
937 for (const field of fields) { 930 for (const field of fields) {
938 if (!isFieldVisible(field.key)) { 931 if (!isFieldVisible(field.key)) {
......