refactor(plan): 移除年龄字段映射
- 从 PlanFormContainer.vue 的 fieldMapping 中移除 age → customer_age 映射 - 提交计划书时不再包含 customer_age 参数 - 保留 withdrawal_start_age 字段用于提取计划 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Showing
4 changed files
with
35 additions
and
218 deletions
| ... | @@ -227,12 +227,7 @@ const close = async () => { | ... | @@ -227,12 +227,7 @@ const close = async () => { |
| 227 | console.log('[PlanFormContainer] 弹窗已关闭,表单已重置') | 227 | console.log('[PlanFormContainer] 弹窗已关闭,表单已重置') |
| 228 | } | 228 | } |
| 229 | 229 | ||
| 230 | -/** | 230 | +// 提交表单 - 将表单数据和产品信息提交到后端 API |
| 231 | - * 提交表单 | ||
| 232 | - * @description 将表单数据和产品信息提交到后端 API | ||
| 233 | - * | ||
| 234 | - * @returns {Promise<boolean>} 是否提交成功 | ||
| 235 | - */ | ||
| 236 | const submit = async () => { | 231 | const submit = async () => { |
| 237 | if (!props.product) { | 232 | if (!props.product) { |
| 238 | console.error('[PlanFormContainer] 无法提交: 产品数据为空') | 233 | console.error('[PlanFormContainer] 无法提交: 产品数据为空') |
| ... | @@ -264,7 +259,6 @@ const submit = async () => { | ... | @@ -264,7 +259,6 @@ const submit = async () => { |
| 264 | const fieldMapping = { | 259 | const fieldMapping = { |
| 265 | customer_name: 'customer_name', // 申请人(已直接使用) | 260 | customer_name: 'customer_name', // 申请人(已直接使用) |
| 266 | gender: 'customer_gender', // 性别 → customer_gender | 261 | gender: 'customer_gender', // 性别 → customer_gender |
| 267 | - age: 'customer_age', // 年龄 → customer_age | ||
| 268 | birthday: 'customer_birthday', // 出生年月日 → customer_birthday | 262 | birthday: 'customer_birthday', // 出生年月日 → customer_birthday |
| 269 | smoker: 'smoking_status', // 是否吸烟 → smoking_status | 263 | smoker: 'smoking_status', // 是否吸烟 → smoking_status |
| 270 | coverage: 'annual_premium', // 保额/年缴保费 → annual_premium | 264 | coverage: 'annual_premium', // 保额/年缴保费 → annual_premium | ... | ... |
| ... | @@ -18,23 +18,12 @@ | ... | @@ -18,23 +18,12 @@ |
| 18 | class="mb-5" | 18 | class="mb-5" |
| 19 | /> | 19 | /> |
| 20 | 20 | ||
| 21 | - <!-- 年龄(主字段,选择后自动计算出生年月日) --> | 21 | + <!-- 出生年月日 --> |
| 22 | - <PlanFieldAgePicker | ||
| 23 | - v-model="form.age" | ||
| 24 | - label="年龄" | ||
| 25 | - placeholder="请选择年龄" | ||
| 26 | - :required="true" | ||
| 27 | - @change="onAgeChange" | ||
| 28 | - class="mb-5" | ||
| 29 | - /> | ||
| 30 | - | ||
| 31 | - <!-- 出生年月日(根据年龄自动计算,可手动调整) --> | ||
| 32 | <PlanFieldDatePicker | 22 | <PlanFieldDatePicker |
| 33 | v-model="form.birthday" | 23 | v-model="form.birthday" |
| 34 | label="出生年月日" | 24 | label="出生年月日" |
| 35 | placeholder="请选择年月日" | 25 | placeholder="请选择年月日" |
| 36 | :required="true" | 26 | :required="true" |
| 37 | - @change="onBirthdayChange" | ||
| 38 | class="mb-5" | 27 | class="mb-5" |
| 39 | /> | 28 | /> |
| 40 | 29 | ||
| ... | @@ -70,18 +59,17 @@ | ... | @@ -70,18 +59,17 @@ |
| 70 | 59 | ||
| 71 | <!-- 配置缺失提示 --> | 60 | <!-- 配置缺失提示 --> |
| 72 | <div v-else class="text-center text-gray-500 py-10"> | 61 | <div v-else class="text-center text-gray-500 py-10"> |
| 73 | - <p>⚠️ 模版配置未找到</p> | 62 | + <p>⚠️ 模板配置未找到</p> |
| 74 | <p class="text-sm mt-2">请检查产品配置或联系开发人员</p> | 63 | <p class="text-sm mt-2">请检查产品配置或联系开发人员</p> |
| 75 | </div> | 64 | </div> |
| 76 | </template> | 65 | </template> |
| 77 | 66 | ||
| 78 | <script setup> | 67 | <script setup> |
| 79 | /** | 68 | /** |
| 80 | - * 重疾保险计划书模版 | 69 | + * 重疾保险计划书模板 |
| 81 | * | 70 | * |
| 82 | * @description MPC/MBC PRO/MBC2 等重疾保险产品的计划书录入表单 | 71 | * @description MPC/MBC PRO/MBC2 等重疾保险产品的计划书录入表单 |
| 83 | - * - 支持出生日期自动计算年龄 | 72 | + * - 表单字段:性别、出生年月日、是否吸烟、保额、缴费年期 |
| 84 | - * - 表单字段:性别、年龄、出生年月日、是否吸烟、保额、缴费年期 | ||
| 85 | * @author Claude Code | 73 | * @author Claude Code |
| 86 | * @example | 74 | * @example |
| 87 | * <CriticalIllnessTemplate | 75 | * <CriticalIllnessTemplate |
| ... | @@ -92,7 +80,6 @@ | ... | @@ -92,7 +80,6 @@ |
| 92 | import { reactive, watch } from 'vue' | 80 | import { reactive, watch } from 'vue' |
| 93 | import Taro from '@tarojs/taro' | 81 | import Taro from '@tarojs/taro' |
| 94 | import PlanFieldName from '../PlanFields/NameInput.vue' | 82 | import PlanFieldName from '../PlanFields/NameInput.vue' |
| 95 | -import PlanFieldAgePicker from '../PlanFields/AgePickerGlobal.vue' | ||
| 96 | import PlanFieldAmount from '../PlanFields/AmountKeyboard.vue' | 83 | import PlanFieldAmount from '../PlanFields/AmountKeyboard.vue' |
| 97 | import PlanFieldDatePicker from '../PlanFields/DatePickerGlobal.vue' | 84 | import PlanFieldDatePicker from '../PlanFields/DatePickerGlobal.vue' |
| 98 | import PlanFieldRadio from '../PlanFields/RadioGroup.vue' | 85 | import PlanFieldRadio from '../PlanFields/RadioGroup.vue' |
| ... | @@ -112,7 +99,7 @@ const props = defineProps({ | ... | @@ -112,7 +99,7 @@ const props = defineProps({ |
| 112 | }, | 99 | }, |
| 113 | 100 | ||
| 114 | /** | 101 | /** |
| 115 | - * 模版配置 | 102 | + * 模板配置 |
| 116 | * @type {Object} | 103 | * @type {Object} |
| 117 | * @property {string} currency - 币种代码 | 104 | * @property {string} currency - 币种代码 |
| 118 | * @property {Array<string>} payment_periods - 缴费年期选项 | 105 | * @property {Array<string>} payment_periods - 缴费年期选项 |
| ... | @@ -163,8 +150,8 @@ watch( | ... | @@ -163,8 +150,8 @@ watch( |
| 163 | 150 | ||
| 164 | // 判断是否是重置(从有数据变为空对象) | 151 | // 判断是否是重置(从有数据变为空对象) |
| 165 | const isReset = previousModelValue && | 152 | const isReset = previousModelValue && |
| 166 | - Object.keys(previousModelValue).length > 0 && | 153 | + Object.keys(previousModelValue).length > 0 && |
| 167 | - Object.keys(newVal).length === 0 | 154 | + Object.keys(newVal).length === 0 |
| 168 | 155 | ||
| 169 | if (isReset) { | 156 | if (isReset) { |
| 170 | // 父组件重置了:清空表单 | 157 | // 父组件重置了:清空表单 |
| ... | @@ -172,6 +159,7 @@ watch( | ... | @@ -172,6 +159,7 @@ watch( |
| 172 | previousModelValue = newVal | 159 | previousModelValue = newVal |
| 173 | } else { | 160 | } else { |
| 174 | // 正常更新:合并新字段,不删除已有字段 | 161 | // 正常更新:合并新字段,不删除已有字段 |
| 162 | + // 这很重要!因为用户可能刚填写了某些字段,其他字段还没更新 | ||
| 175 | Object.keys(newVal).forEach(key => { | 163 | Object.keys(newVal).forEach(key => { |
| 176 | form[key] = newVal[key] | 164 | form[key] = newVal[key] |
| 177 | }) | 165 | }) |
| ... | @@ -191,49 +179,6 @@ watch( | ... | @@ -191,49 +179,6 @@ watch( |
| 191 | ) | 179 | ) |
| 192 | 180 | ||
| 193 | /** | 181 | /** |
| 194 | - * 年龄变化时自动计算出生年月日 | ||
| 195 | - * @param {number} age - 年龄 | ||
| 196 | - * | ||
| 197 | - * @description 用户选择年龄后,自动计算并填充出生日期字段 | ||
| 198 | - * 计算公式:当前年份 - 年龄 = 出生年份(默认1月1日) | ||
| 199 | - */ | ||
| 200 | -const onAgeChange = (age) => { | ||
| 201 | - if (age !== undefined && age !== null && age !== '') { | ||
| 202 | - const currentYear = new Date().getFullYear() | ||
| 203 | - const birthYear = currentYear - age | ||
| 204 | - | ||
| 205 | - // 格式化为 YYYY-MM-DD,默认使用1月1日 | ||
| 206 | - const month = String(1).padStart(2, '0') | ||
| 207 | - const day = String(1).padStart(2, '0') | ||
| 208 | - form.birthday = `${birthYear}-${month}-${day}` | ||
| 209 | - } | ||
| 210 | -} | ||
| 211 | - | ||
| 212 | -/** | ||
| 213 | - * 出生日期变化时自动计算年龄 | ||
| 214 | - * @param {string} birthday - 出生日期(格式:YYYY-MM-DD) | ||
| 215 | - * | ||
| 216 | - * @description 用户选择出生日期后,自动计算并填充年龄字段 | ||
| 217 | - * 计算公式:当前年份 - 出生年份 | ||
| 218 | - */ | ||
| 219 | -const onBirthdayChange = (birthday) => { | ||
| 220 | - if (birthday) { | ||
| 221 | - // 兼容 iOS 的日期格式 (YYYY/MM/DD) | ||
| 222 | - const dateStr = birthday.replace(/-/g, '/') | ||
| 223 | - const birthDate = new Date(dateStr) | ||
| 224 | - | ||
| 225 | - if (!Number.isNaN(birthDate.getTime())) { | ||
| 226 | - const birthYear = birthDate.getFullYear() | ||
| 227 | - const currentYear = new Date().getFullYear() | ||
| 228 | - const calculatedAge = currentYear - birthYear | ||
| 229 | - | ||
| 230 | - // 自动填充年龄字段(确保非负) | ||
| 231 | - form.age = Math.max(0, calculatedAge) | ||
| 232 | - } | ||
| 233 | - } | ||
| 234 | -} | ||
| 235 | - | ||
| 236 | -/** | ||
| 237 | * 表单校验 | 182 | * 表单校验 |
| 238 | * @returns {boolean} 是否通过校验 | 183 | * @returns {boolean} 是否通过校验 |
| 239 | */ | 184 | */ |
| ... | @@ -250,10 +195,6 @@ const validate = () => { | ... | @@ -250,10 +195,6 @@ const validate = () => { |
| 250 | Taro.showToast({ title: '请选择出生年月日', icon: 'none' }) | 195 | Taro.showToast({ title: '请选择出生年月日', icon: 'none' }) |
| 251 | return false | 196 | return false |
| 252 | } | 197 | } |
| 253 | - if (form.age === undefined || form.age === '') { | ||
| 254 | - Taro.showToast({ title: '请填写年龄', icon: 'none' }) | ||
| 255 | - return false | ||
| 256 | - } | ||
| 257 | if (!form.smoker) { | 198 | if (!form.smoker) { |
| 258 | Taro.showToast({ title: '请选择是否吸烟', icon: 'none' }) | 199 | Taro.showToast({ title: '请选择是否吸烟', icon: 'none' }) |
| 259 | return false | 200 | return false |
| ... | @@ -286,5 +227,5 @@ defineExpose({ | ... | @@ -286,5 +227,5 @@ defineExpose({ |
| 286 | </script> | 227 | </script> |
| 287 | 228 | ||
| 288 | <style lang="less" scoped> | 229 | <style lang="less" scoped> |
| 289 | -/* 模版样式 */ | 230 | +/* 模板样式 */ |
| 290 | </style> | 231 | </style> | ... | ... |
| ... | @@ -18,23 +18,12 @@ | ... | @@ -18,23 +18,12 @@ |
| 18 | class="mb-5" | 18 | class="mb-5" |
| 19 | /> | 19 | /> |
| 20 | 20 | ||
| 21 | - <!-- 年龄(主字段,选择后自动计算出生年月日) --> | 21 | + <!-- 出生年月日 --> |
| 22 | - <PlanFieldAgePicker | ||
| 23 | - v-model="form.age" | ||
| 24 | - label="年龄" | ||
| 25 | - placeholder="请选择年龄" | ||
| 26 | - :required="true" | ||
| 27 | - @change="onAgeChange" | ||
| 28 | - class="mb-5" | ||
| 29 | - /> | ||
| 30 | - | ||
| 31 | - <!-- 出生年月日(根据年龄自动计算,可手动调整) --> | ||
| 32 | <PlanFieldDatePicker | 22 | <PlanFieldDatePicker |
| 33 | v-model="form.birthday" | 23 | v-model="form.birthday" |
| 34 | label="出生年月日" | 24 | label="出生年月日" |
| 35 | placeholder="请选择年月日" | 25 | placeholder="请选择年月日" |
| 36 | :required="true" | 26 | :required="true" |
| 37 | - @change="onBirthdayChange" | ||
| 38 | class="mb-5" | 27 | class="mb-5" |
| 39 | /> | 28 | /> |
| 40 | 29 | ||
| ... | @@ -47,11 +36,11 @@ | ... | @@ -47,11 +36,11 @@ |
| 47 | class="mb-5" | 36 | class="mb-5" |
| 48 | /> | 37 | /> |
| 49 | 38 | ||
| 50 | - <!-- 保额(年缴保费) --> | 39 | + <!-- 保额 --> |
| 51 | <PlanFieldAmount | 40 | <PlanFieldAmount |
| 52 | v-model="form.coverage" | 41 | v-model="form.coverage" |
| 53 | - label="年缴保费" | 42 | + label="保额" |
| 54 | - placeholder="请输入年缴保费" | 43 | + placeholder="请输入保额" |
| 55 | :currency="config.currency" | 44 | :currency="config.currency" |
| 56 | :required="true" | 45 | :required="true" |
| 57 | class="mb-5" | 46 | class="mb-5" |
| ... | @@ -70,18 +59,17 @@ | ... | @@ -70,18 +59,17 @@ |
| 70 | 59 | ||
| 71 | <!-- 配置缺失提示 --> | 60 | <!-- 配置缺失提示 --> |
| 72 | <div v-else class="text-center text-gray-500 py-10"> | 61 | <div v-else class="text-center text-gray-500 py-10"> |
| 73 | - <p>⚠️ 模版配置未找到</p> | 62 | + <p>⚠️ 模板配置未找到</p> |
| 74 | <p class="text-sm mt-2">请检查产品配置或联系开发人员</p> | 63 | <p class="text-sm mt-2">请检查产品配置或联系开发人员</p> |
| 75 | </div> | 64 | </div> |
| 76 | </template> | 65 | </template> |
| 77 | 66 | ||
| 78 | <script setup> | 67 | <script setup> |
| 79 | /** | 68 | /** |
| 80 | - * 人寿保险计划书模版 | 69 | + * 人寿保险计划书模板 |
| 81 | * | 70 | * |
| 82 | * @description WIOP3E/WIOP3 等人寿保险产品的计划书录入表单 | 71 | * @description WIOP3E/WIOP3 等人寿保险产品的计划书录入表单 |
| 83 | - * - 支持出生日期自动计算年龄 | 72 | + * - 表单字段:性别、出生年月日、是否吸烟、保额、缴费年期 |
| 84 | - * - 表单字段:性别、年龄、出生年月日、是否吸烟、保额、缴费年期 | ||
| 85 | * @author Claude Code | 73 | * @author Claude Code |
| 86 | * @example | 74 | * @example |
| 87 | * <LifeInsuranceTemplate | 75 | * <LifeInsuranceTemplate |
| ... | @@ -92,7 +80,6 @@ | ... | @@ -92,7 +80,6 @@ |
| 92 | import { reactive, watch, toRefs } from 'vue' | 80 | import { reactive, watch, toRefs } from 'vue' |
| 93 | import Taro from '@tarojs/taro' | 81 | import Taro from '@tarojs/taro' |
| 94 | import PlanFieldName from '../PlanFields/NameInput.vue' | 82 | import PlanFieldName from '../PlanFields/NameInput.vue' |
| 95 | -import PlanFieldAgePicker from '../PlanFields/AgePickerGlobal.vue' | ||
| 96 | import PlanFieldAmount from '../PlanFields/AmountKeyboard.vue' | 83 | import PlanFieldAmount from '../PlanFields/AmountKeyboard.vue' |
| 97 | import PlanFieldDatePicker from '../PlanFields/DatePickerGlobal.vue' | 84 | import PlanFieldDatePicker from '../PlanFields/DatePickerGlobal.vue' |
| 98 | import PlanFieldRadio from '../PlanFields/RadioGroup.vue' | 85 | import PlanFieldRadio from '../PlanFields/RadioGroup.vue' |
| ... | @@ -112,7 +99,7 @@ const props = defineProps({ | ... | @@ -112,7 +99,7 @@ const props = defineProps({ |
| 112 | }, | 99 | }, |
| 113 | 100 | ||
| 114 | /** | 101 | /** |
| 115 | - * 模版配置 | 102 | + * 模板配置 |
| 116 | * @type {Object} | 103 | * @type {Object} |
| 117 | * @property {string} currency - 币种代码 | 104 | * @property {string} currency - 币种代码 |
| 118 | * @property {Array<string>} payment_periods - 缴费年期选项 | 105 | * @property {Array<string>} payment_periods - 缴费年期选项 |
| ... | @@ -165,8 +152,8 @@ watch( | ... | @@ -165,8 +152,8 @@ watch( |
| 165 | 152 | ||
| 166 | // 判断是否是重置(从有数据变为空对象) | 153 | // 判断是否是重置(从有数据变为空对象) |
| 167 | const isReset = previousModelValue && | 154 | const isReset = previousModelValue && |
| 168 | - Object.keys(previousModelValue).length > 0 && | 155 | + Object.keys(previousModelValue).length > 0 && |
| 169 | - Object.keys(newVal).length === 0 | 156 | + Object.keys(newVal).length === 0 |
| 170 | 157 | ||
| 171 | if (isReset) { | 158 | if (isReset) { |
| 172 | // 父组件重置了:清空表单 | 159 | // 父组件重置了:清空表单 |
| ... | @@ -194,49 +181,6 @@ watch( | ... | @@ -194,49 +181,6 @@ watch( |
| 194 | ) | 181 | ) |
| 195 | 182 | ||
| 196 | /** | 183 | /** |
| 197 | - * 年龄变化时自动计算出生年月日 | ||
| 198 | - * @param {number} age - 年龄 | ||
| 199 | - * | ||
| 200 | - * @description 用户选择年龄后,自动计算并填充出生日期字段 | ||
| 201 | - * 计算公式:当前年份 - 年龄 = 出生年份(默认1月1日) | ||
| 202 | - */ | ||
| 203 | -const onAgeChange = (age) => { | ||
| 204 | - if (age !== undefined && age !== null && age !== '') { | ||
| 205 | - const currentYear = new Date().getFullYear() | ||
| 206 | - const birthYear = currentYear - age | ||
| 207 | - | ||
| 208 | - // 格式化为 YYYY-MM-DD,默认使用1月1日 | ||
| 209 | - const month = String(1).padStart(2, '0') | ||
| 210 | - const day = String(1).padStart(2, '0') | ||
| 211 | - form.birthday = `${birthYear}-${month}-${day}` | ||
| 212 | - } | ||
| 213 | -} | ||
| 214 | - | ||
| 215 | -/** | ||
| 216 | - * 出生日期变化时自动计算年龄 | ||
| 217 | - * @param {string} birthday - 出生日期(格式:YYYY-MM-DD) | ||
| 218 | - * | ||
| 219 | - * @description 用户选择出生日期后,自动计算并填充年龄字段 | ||
| 220 | - * 计算公式:当前年份 - 出生年份 | ||
| 221 | - */ | ||
| 222 | -const onBirthdayChange = (birthday) => { | ||
| 223 | - if (birthday) { | ||
| 224 | - // 兼容 iOS 的日期格式 (YYYY/MM/DD) | ||
| 225 | - const dateStr = birthday.replace(/-/g, '/') | ||
| 226 | - const birthDate = new Date(dateStr) | ||
| 227 | - | ||
| 228 | - if (!Number.isNaN(birthDate.getTime())) { | ||
| 229 | - const birthYear = birthDate.getFullYear() | ||
| 230 | - const currentYear = new Date().getFullYear() | ||
| 231 | - const calculatedAge = currentYear - birthYear | ||
| 232 | - | ||
| 233 | - // 自动填充年龄字段(确保非负) | ||
| 234 | - form.age = Math.max(0, calculatedAge) | ||
| 235 | - } | ||
| 236 | - } | ||
| 237 | -} | ||
| 238 | - | ||
| 239 | -/** | ||
| 240 | * 表单校验 | 184 | * 表单校验 |
| 241 | * @returns {boolean} 是否通过校验 | 185 | * @returns {boolean} 是否通过校验 |
| 242 | */ | 186 | */ |
| ... | @@ -253,10 +197,6 @@ const validate = () => { | ... | @@ -253,10 +197,6 @@ const validate = () => { |
| 253 | Taro.showToast({ title: '请选择出生年月日', icon: 'none' }) | 197 | Taro.showToast({ title: '请选择出生年月日', icon: 'none' }) |
| 254 | return false | 198 | return false |
| 255 | } | 199 | } |
| 256 | - if (form.age === undefined || form.age === '') { | ||
| 257 | - Taro.showToast({ title: '请填写年龄', icon: 'none' }) | ||
| 258 | - return false | ||
| 259 | - } | ||
| 260 | if (!form.smoker) { | 200 | if (!form.smoker) { |
| 261 | Taro.showToast({ title: '请选择是否吸烟', icon: 'none' }) | 201 | Taro.showToast({ title: '请选择是否吸烟', icon: 'none' }) |
| 262 | return false | 202 | return false |
| ... | @@ -288,6 +228,6 @@ defineExpose({ | ... | @@ -288,6 +228,6 @@ defineExpose({ |
| 288 | }) | 228 | }) |
| 289 | </script> | 229 | </script> |
| 290 | 230 | ||
| 291 | -<style lang="less"> | 231 | +<style lang="less" scoped> |
| 292 | -/* 模版样式 */ | 232 | +/* 模板样式 */ |
| 293 | </style> | 233 | </style> | ... | ... |
| ... | @@ -18,23 +18,12 @@ | ... | @@ -18,23 +18,12 @@ |
| 18 | class="mb-5" | 18 | class="mb-5" |
| 19 | /> | 19 | /> |
| 20 | 20 | ||
| 21 | - <!-- 年龄(主字段,选择后自动计算出生年月日) --> | 21 | + <!-- 出生日期 --> |
| 22 | - <PlanFieldAgePicker | ||
| 23 | - v-model="form.age" | ||
| 24 | - label="年龄" | ||
| 25 | - placeholder="请选择年龄" | ||
| 26 | - :required="true" | ||
| 27 | - @change="onAgeChange" | ||
| 28 | - class="mb-5" | ||
| 29 | - /> | ||
| 30 | - | ||
| 31 | - <!-- 出生年月日(根据年龄自动计算,可手动调整) --> | ||
| 32 | <PlanFieldDatePicker | 22 | <PlanFieldDatePicker |
| 33 | v-model="form.birthday" | 23 | v-model="form.birthday" |
| 34 | label="出生年月日" | 24 | label="出生年月日" |
| 35 | placeholder="请选择年月日" | 25 | placeholder="请选择年月日" |
| 36 | :required="true" | 26 | :required="true" |
| 37 | - @change="onBirthdayChange" | ||
| 38 | class="mb-5" | 27 | class="mb-5" |
| 39 | /> | 28 | /> |
| 40 | 29 | ||
| ... | @@ -72,10 +61,10 @@ | ... | @@ -72,10 +61,10 @@ |
| 72 | 61 | ||
| 73 | <!-- 提取计划配置 --> | 62 | <!-- 提取计划配置 --> |
| 74 | <div v-if="config.withdrawal_plan?.enabled" class="withdrawal-plan-section"> | 63 | <div v-if="config.withdrawal_plan?.enabled" class="withdrawal-plan-section"> |
| 75 | - <!-- 第一层:是否希望生成一份容许减少名义金额的提取说明? --> | 64 | + <!-- 第一层:是否希望生成一份允许减少名义金额的提取说明? --> |
| 76 | <PlanFieldRadio | 65 | <PlanFieldRadio |
| 77 | v-model="form.withdrawal_enabled" | 66 | v-model="form.withdrawal_enabled" |
| 78 | - label="是否希望生成一份容许减少名义金额的提取说明?" | 67 | + label="是否希望生成一份允许减少名义金额的提取说明?" |
| 79 | :options="['是', '否']" | 68 | :options="['是', '否']" |
| 80 | :required="true" | 69 | :required="true" |
| 81 | class="mb-5" | 70 | class="mb-5" |
| ... | @@ -83,7 +72,7 @@ | ... | @@ -83,7 +72,7 @@ |
| 83 | 72 | ||
| 84 | <!-- 仅当选择"是"时才显示以下内容 --> | 73 | <!-- 仅当选择"是"时才显示以下内容 --> |
| 85 | <template v-if="form.withdrawal_enabled === '是'"> | 74 | <template v-if="form.withdrawal_enabled === '是'"> |
| 86 | - <h3 class="text-base font-semibold text-gray-900 mb-4">款项提取(容许减少名义金额)</h3> | 75 | + <h3 class="text-base font-semibold text-gray-900 mb-4">款项提取(允许减少名义金额)</h3> |
| 87 | 76 | ||
| 88 | <!-- 提取选项:指定提取金额 / 最高固定提取金额 --> | 77 | <!-- 提取选项:指定提取金额 / 最高固定提取金额 --> |
| 89 | <PlanFieldRadio | 78 | <PlanFieldRadio |
| ... | @@ -192,19 +181,17 @@ | ... | @@ -192,19 +181,17 @@ |
| 192 | 181 | ||
| 193 | <!-- 配置缺失提示 --> | 182 | <!-- 配置缺失提示 --> |
| 194 | <div v-else class="text-center text-gray-500 py-10"> | 183 | <div v-else class="text-center text-gray-500 py-10"> |
| 195 | - <p>⚠️ 模版配置未找到</p> | 184 | + <p>⚠️ 模板配置未找到</p> |
| 196 | <p class="text-sm mt-2">请检查产品配置或联系开发人员</p> | 185 | <p class="text-sm mt-2">请检查产品配置或联系开发人员</p> |
| 197 | </div> | 186 | </div> |
| 198 | </template> | 187 | </template> |
| 199 | 188 | ||
| 200 | <script setup> | 189 | <script setup> |
| 201 | /** | 190 | /** |
| 202 | - * 储蓄型保险计划书模版 | 191 | + * 储蓄型保险计划书模板 |
| 203 | * | 192 | * |
| 204 | * @description GS/GC/FA/LV2 等储蓄型保险产品的计划书录入表单 | 193 | * @description GS/GC/FA/LV2 等储蓄型保险产品的计划书录入表单 |
| 205 | - * - 支持出生日期自动计算年龄 | 194 | + * - 表单字段:性别、出生年月日、是否吸烟、保额、缴费年期 |
| 206 | - * - 支持提取计划配置(多种提取模式和方式) | ||
| 207 | - * - 表单字段:性别、年龄、出生年月日、是否吸烟、保额、缴费年期 | ||
| 208 | * - 提取计划:指定提取金额(按年岁/按保单年度)、最高固定提取金额 | 195 | * - 提取计划:指定提取金额(按年岁/按保单年度)、最高固定提取金额 |
| 209 | * - 小程序端币种固定(使用配置中的默认币种) | 196 | * - 小程序端币种固定(使用配置中的默认币种) |
| 210 | * @author Claude Code | 197 | * @author Claude Code |
| ... | @@ -237,7 +224,7 @@ const props = defineProps({ | ... | @@ -237,7 +224,7 @@ const props = defineProps({ |
| 237 | }, | 224 | }, |
| 238 | 225 | ||
| 239 | /** | 226 | /** |
| 240 | - * 模版配置 | 227 | + * 模板配置 |
| 241 | * @type {Object} | 228 | * @type {Object} |
| 242 | * @property {string} currency - 币种代码 | 229 | * @property {string} currency - 币种代码 |
| 243 | * @property {Array<string>} payment_periods - 缴费年期选项 | 230 | * @property {Array<string>} payment_periods - 缴费年期选项 |
| ... | @@ -275,7 +262,9 @@ const emit = defineEmits([ | ... | @@ -275,7 +262,9 @@ const emit = defineEmits([ |
| 275 | * ⚠️ 重要:处理父组件重置表单的情况 | 262 | * ⚠️ 重要:处理父组件重置表单的情况 |
| 276 | * 问题:reactive() 只在初始化时赋值,父组件重置时子组件不会自动更新 | 263 | * 问题:reactive() 只在初始化时赋值,父组件重置时子组件不会自动更新 |
| 277 | * | 264 | * |
| 278 | - * 解决方案:使用 watch 监听,但只在引用变化时才清空并复制 | 265 | + * 解决方案:使用 watch 监听,但只在重置时(空对象)才清空 |
| 266 | + * - 判断重置的标准:从有数据变为空对象 | ||
| 267 | + * - 用户输入时的更新:只合并新字段,不删除已有字段 | ||
| 279 | */ | 268 | */ |
| 280 | const form = reactive({}) | 269 | const form = reactive({}) |
| 281 | 270 | ||
| ... | @@ -310,8 +299,8 @@ watch( | ... | @@ -310,8 +299,8 @@ watch( |
| 310 | 299 | ||
| 311 | // 判断是否是重置(从有数据变为空对象) | 300 | // 判断是否是重置(从有数据变为空对象) |
| 312 | const isReset = previousModelValue && | 301 | const isReset = previousModelValue && |
| 313 | - Object.keys(previousModelValue).length > 0 && | 302 | + Object.keys(previousModelValue).length > 0 && |
| 314 | - Object.keys(newVal).length === 0 | 303 | + Object.keys(newVal).length === 0 |
| 315 | 304 | ||
| 316 | if (isReset) { | 305 | if (isReset) { |
| 317 | // 父组件重置了:清空表单 | 306 | // 父组件重置了:清空表单 |
| ... | @@ -367,49 +356,6 @@ const withdrawalPeriods = computed(() => { | ... | @@ -367,49 +356,6 @@ const withdrawalPeriods = computed(() => { |
| 367 | }) | 356 | }) |
| 368 | 357 | ||
| 369 | /** | 358 | /** |
| 370 | - * 年龄变化时自动计算出生年月日 | ||
| 371 | - * @param {number} age - 年龄 | ||
| 372 | - * | ||
| 373 | - * @description 用户选择年龄后,自动计算并填充出生日期字段 | ||
| 374 | - * 计算公式:当前年份 - 年龄 = 出生年份(默认1月1日) | ||
| 375 | - */ | ||
| 376 | -const onAgeChange = (age) => { | ||
| 377 | - if (age !== undefined && age !== null && age !== '') { | ||
| 378 | - const currentYear = new Date().getFullYear() | ||
| 379 | - const birthYear = currentYear - age | ||
| 380 | - | ||
| 381 | - // 格式化为 YYYY-MM-DD,默认使用1月1日 | ||
| 382 | - const month = String(1).padStart(2, '0') | ||
| 383 | - const day = String(1).padStart(2, '0') | ||
| 384 | - form.birthday = `${birthYear}-${month}-${day}` | ||
| 385 | - } | ||
| 386 | -} | ||
| 387 | - | ||
| 388 | -/** | ||
| 389 | - * 出生日期变化时自动计算年龄 | ||
| 390 | - * @param {string} birthday - 出生日期(格式:YYYY-MM-DD) | ||
| 391 | - * | ||
| 392 | - * @description 用户选择出生日期后,自动计算并填充年龄字段 | ||
| 393 | - * 计算公式:当前年份 - 出生年份 | ||
| 394 | - */ | ||
| 395 | -const onBirthdayChange = (birthday) => { | ||
| 396 | - if (birthday) { | ||
| 397 | - // 兼容 iOS 的日期格式 (YYYY/MM/DD) | ||
| 398 | - const dateStr = birthday.replace(/-/g, '/') | ||
| 399 | - const birthDate = new Date(dateStr) | ||
| 400 | - | ||
| 401 | - if (!Number.isNaN(birthDate.getTime())) { | ||
| 402 | - const birthYear = birthDate.getFullYear() | ||
| 403 | - const currentYear = new Date().getFullYear() | ||
| 404 | - const calculatedAge = currentYear - birthYear | ||
| 405 | - | ||
| 406 | - // 自动填充年龄字段(确保非负) | ||
| 407 | - form.age = Math.max(0, calculatedAge) | ||
| 408 | - } | ||
| 409 | - } | ||
| 410 | -} | ||
| 411 | - | ||
| 412 | -/** | ||
| 413 | * 提取模式变化时的处理 | 359 | * 提取模式变化时的处理 |
| 414 | * @param {string} mode - 新的提取模式 | 360 | * @param {string} mode - 新的提取模式 |
| 415 | * | 361 | * |
| ... | @@ -479,10 +425,6 @@ const validate = () => { | ... | @@ -479,10 +425,6 @@ const validate = () => { |
| 479 | Taro.showToast({ title: '请选择出生年月日', icon: 'none' }) | 425 | Taro.showToast({ title: '请选择出生年月日', icon: 'none' }) |
| 480 | return false | 426 | return false |
| 481 | } | 427 | } |
| 482 | - if (form.age === undefined || form.age === '') { | ||
| 483 | - Taro.showToast({ title: '请填写年龄', icon: 'none' }) | ||
| 484 | - return false | ||
| 485 | - } | ||
| 486 | if (!form.smoker) { | 428 | if (!form.smoker) { |
| 487 | Taro.showToast({ title: '请选择是否吸烟', icon: 'none' }) | 429 | Taro.showToast({ title: '请选择是否吸烟', icon: 'none' }) |
| 488 | return false | 430 | return false | ... | ... |
-
Please register or login to post a comment