hookehuyr

fix(plan): 修复计划书表单字段映射并统一术语

- 修复 smoking_status 字段映射(之前错误映射为 smoker)
- 删除未使用的 formatAmounts 函数
- 将所有"客户姓名"统一改为"申请人"
- 更新表单标签、占位符和错误提示

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
......@@ -35,8 +35,8 @@
* @example
* <PlanFieldName
* v-model="form.customer_name"
* label="客户姓名"
* placeholder="请输入客户姓名"
* label="申请人"
* placeholder="请输入申请人"
* :required="true"
* />
*/
......
......@@ -228,30 +228,6 @@ const close = async () => {
}
/**
* 格式化金额数据(分 → 元)
* @description 将金额从"分"转换为"元"(带2位小数),便于调试和查看
* @param {Object} data - 表单数据
* @returns {Object} 格式化后的表单数据
* @example
* formatAmounts({ coverage: 10000 }) // 返回 { coverage: '100.00' }
*/
const formatAmounts = (data) => {
const formatted = { ...data }
// 金额字段列表(单位:分)
const amountFields = ['coverage', 'premium', 'amount', 'total_amount']
for (const field of amountFields) {
if (formatted[field] !== null && formatted[field] !== undefined) {
// 分 → 元,保留2位小数
formatted[field] = (formatted[field] / 100).toFixed(2)
}
}
return formatted
}
/**
* 提交表单
* @description 将表单数据和产品信息提交到后端 API
*
......@@ -284,17 +260,17 @@ const submit = async () => {
try {
// 字段名映射:将表单字段名映射为 API 期望的字段名
// 根据 API 文档 (docs/api-specs/plan/add.md) 定义
const fieldMapping = {
customer_name: 'customer_name', // 客户姓名(已直接使用)
customer_name: 'customer_name', // 申请人(已直接使用)
gender: 'customer_gender', // 性别 → customer_gender
age: 'customer_age', // 年龄 → customer_age
birthday: 'customer_birthday', // 出生年月日 → customer_birthday
smoker: 'smoker', // 是否吸烟(保持不变)
smoker: 'smoking_status', // 是否吸烟 → smoking_status
coverage: 'annual_premium', // 保额/年缴保费 → annual_premium
payment_period: 'payment_years', // 缴费年期 → payment_years
withdrawal_enabled: 'allow_reduce_amount', // 是否容许减少名义金额
withdrawal_mode: 'withdrawal_option', // 提取选项
specified_amount_type: null, // 提取方式(后端可能不需要)
withdrawal_start_age: 'withdrawal_start_age', // 提取开始年龄
withdrawal_period: 'withdrawal_period', // 提取期
currency_type: 'currency_type' // 币种类型
......
<template>
<div v-if="config">
<!-- 客户姓名 -->
<!-- 申请人 -->
<PlanFieldName
v-model="form.customer_name"
label="客户姓名"
placeholder="请输入客户姓名"
label="申请人"
placeholder="请输入申请人"
:required="true"
class="mb-5"
/>
......@@ -239,7 +239,7 @@ const onBirthdayChange = (birthday) => {
*/
const validate = () => {
if (!form.customer_name || !form.customer_name.trim()) {
Taro.showToast({ title: '请输入客户姓名', icon: 'none' })
Taro.showToast({ title: '请输入申请人', icon: 'none' })
return false
}
if (!form.gender) {
......
<template>
<div v-if="config">
<!-- 客户姓名 -->
<!-- 申请人 -->
<PlanFieldName
v-model="form.customer_name"
label="客户姓名"
placeholder="请输入客户姓名"
label="申请人"
placeholder="请输入申请人"
:required="true"
class="mb-5"
/>
......@@ -242,7 +242,7 @@ const onBirthdayChange = (birthday) => {
*/
const validate = () => {
if (!form.customer_name || !form.customer_name.trim()) {
Taro.showToast({ title: '请输入客户姓名', icon: 'none' })
Taro.showToast({ title: '请输入申请人', icon: 'none' })
return false
}
if (!form.gender) {
......
<template>
<div v-if="config">
<!-- 客户姓名 -->
<!-- 申请人 -->
<PlanFieldName
v-model="form.customer_name"
label="客户姓名"
placeholder="请输入客户姓名"
label="申请人"
placeholder="请输入申请人"
:required="true"
class="mb-5"
/>
......@@ -468,7 +468,7 @@ watch(
const validate = () => {
// 基础字段校验
if (!form.customer_name || !form.customer_name.trim()) {
Taro.showToast({ title: '请输入客户姓名', icon: 'none' })
Taro.showToast({ title: '请输入申请人', icon: 'none' })
return false
}
if (!form.gender) {
......
......@@ -11,7 +11,7 @@
<view class="px-[24rpx] py-[16rpx] bg-white">
<SearchBar
v-model="searchValue"
placeholder="搜索计划书名称、客户姓名..."
placeholder="搜索计划书名称、申请人..."
:show-clear="true"
variant="rounded"
@search="onSearch"
......