mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-10 02:16:44 +08:00
feat(insurance): 优化投保人与被保人信息同步逻辑
- 引入applicant和insured状态管理模块 - 新增applicantData和insuredData计算属性 - 重构syncApplicant方法实现数据同步 - 修复婚姻状况字段绑定问题 - 调整被保人信息初始化逻辑 - 完善字段默认值处理逻辑 - 清理无效代码片段
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
<script>
|
||||
import { orderDetail } from '@/api/ebiz/common/common'
|
||||
import { createTaskContainer } from '@/views/ebiz/saleFlowProImprove/js/task'
|
||||
import { applicant, insured } from '@/views/ebiz/saleFlowProImprove/js/state'
|
||||
|
||||
export default {
|
||||
name: 'InsuranceApplicationFlow',
|
||||
@@ -32,6 +33,8 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
applicantData: () => applicant,
|
||||
insuredData: () => insured,
|
||||
mainRisk() {
|
||||
if (!this.risks.length) return ''
|
||||
const mainRisk = this.risks.find(risk => risk.isMainRisk === '0')
|
||||
@@ -52,19 +55,7 @@ export default {
|
||||
component: 'InsuredInfo',
|
||||
events: {
|
||||
/** 当投被人是同人的时候,同步被保人信息 */
|
||||
syncApplicant: applicant => {
|
||||
const [insuredRef] = this.$refs['InsuredRef']
|
||||
const insured = insuredRef.userInfo
|
||||
|
||||
this.$nextTick(() => {
|
||||
if (Number(insured.relationToAppnt) === 1) {
|
||||
for (const key in insured) {
|
||||
if (['relationToAppnt', 'email', 'taxResidentId'].includes(key)) continue
|
||||
insured[key] = applicant[key]
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
syncApplicant: this.syncApplicant
|
||||
}
|
||||
},
|
||||
{ title: '被保险人信息', name: 'Insured', component: 'InsuredPersonInfo', events: { msgUpdate: this.handleInsuredMsgUpdate } },
|
||||
@@ -248,6 +239,17 @@ export default {
|
||||
async handleCalculatePremiumClick() {
|
||||
const [ref] = this.$refs['CalculatePremiumRef']
|
||||
ref.nextStep('orderTrial')
|
||||
},
|
||||
syncApplicant() {
|
||||
if (Number(this.insuredData.relationToAppnt) === 1) {
|
||||
for (const key in this.insuredData) {
|
||||
// 同步两者相同属性的数据
|
||||
if (!this.insuredData.hasOwnProperty(key) || !this.applicant.hasOwnProperty(key)) continue
|
||||
if (['relationToAppnt', 'email', 'taxResidentId', 'appntId'].includes(key)) continue
|
||||
// eslint-disable-next-line vue/no-side-effects-in-computed-properties
|
||||
this.insuredData[key] = this.applicant[key]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
||||
@@ -103,7 +103,7 @@
|
||||
/>
|
||||
<van-field
|
||||
v-validate="'required'"
|
||||
:value="userInfo.marriageStatus"
|
||||
:value="marriageStatus"
|
||||
label="婚姻状况"
|
||||
name="婚姻状况"
|
||||
placeholder="请选择"
|
||||
@@ -630,7 +630,7 @@ export default {
|
||||
this.$nextTick(() => {
|
||||
this.isAppnt = true
|
||||
//获取投保人信息
|
||||
let insuredInfo = res.orderDTO.appntDTO
|
||||
let insuredInfo = res.orderDTO.insuredDTOs[0]
|
||||
for (let key in insuredInfo) {
|
||||
this.userInfo[key] = insuredInfo[key]
|
||||
}
|
||||
@@ -670,6 +670,7 @@ export default {
|
||||
} else if (Array.isArray(res.orderDTO.insuredDTOs) && res.orderDTO.insuredDTOs[0]) {
|
||||
let insuredPersonInfo = res.orderDTO.insuredDTOs[0]
|
||||
|
||||
// 被忽略的默认值选项
|
||||
const ignoreKeys = this.$route.query.source === 'productDetail' ? ['isNewPeopleFlag', 'marriage'] : []
|
||||
|
||||
for (let key in insuredPersonInfo) {
|
||||
@@ -682,6 +683,7 @@ export default {
|
||||
}
|
||||
this.userInfo[key] = insuredPersonInfo[key]
|
||||
}
|
||||
|
||||
//是否长期
|
||||
this.userInfo.effectiveDateType = String(insuredPersonInfo.effectiveDateType) !== 'false'
|
||||
//设为联系地址
|
||||
@@ -1073,7 +1075,6 @@ export default {
|
||||
}*/ else if (this.pickerType == '9') {
|
||||
this.userInfo.salarySource = value.id
|
||||
} else if (this.pickerType === '10') {
|
||||
this.userInfo
|
||||
} else if (this.pickerType === '11') {
|
||||
this.userInfo.npType = value.id
|
||||
}
|
||||
@@ -2104,6 +2105,11 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
marriageStatus() {
|
||||
if (this.userInfo.marriageStatus) return this.userInfo.marriageStatus
|
||||
|
||||
return DataDictionary.marriage.find(item => item.id === Number(this.userInfo.marriage)).text || ''
|
||||
},
|
||||
isReadonly() {
|
||||
return this.isAppnt
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user