Files
ebiz-h5/src/views/ebiz/sale/AddBeneficiaryInfo.vue

1376 lines
53 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<div class="add-beneficiary-container pb50 redRadioCheckbox">
<!-- 基本信息 -->
<van-cell-group>
<van-field
v-model="relationToAppnt"
required
readonly
label="是被保险人的"
name="是被保险人的"
right-icon="arrow"
placeholder="请选择"
v-validate="'required'"
@click="toSelect('7')"
/>
<div class="relative border-bt fs14 p10 flex align-center">
<van-checkbox v-model="userInfo.asAppntAddress" @change="asAppntAddress" :disabled="Insured">同投保人</van-checkbox>
</div>
<customer-picker
@on-choose="chooseCustomer"
v-validate="'required|salename'"
name="姓名"
label="姓名"
required
v-model="userInfo.name"
:parentShowPicker.sync="customerShowPicker"
@nameChange="nameChange"
@on-click="selectClick('1')"
:readonly="isInsured && nameLimit"
></customer-picker>
<van-field
:value="userInfo.idType | idToText('idType')"
v-validate="'required'"
readonly
required
label="证件类型"
name="证件类型"
right-icon="arrow"
placeholder="请选择"
@click="toSelect('2')"
/>
<van-field
v-model="userInfo.idNo"
label="证件号码"
name="证件号码"
required
placeholder="请输入"
maxlength="18"
clearable
:readonly="isInsured && idNoLimit"
v-validate="'required'"
@blur="getRelatedData(userInfo.idNo)"
></van-field>
<FieldDatePicter
v-validate="'required'"
label="出生日期"
name="出生日期"
required
:value.sync="userInfo.birthday"
type="date"
:flag="true"
@confirm="onDateConfirm($event, '2')"
ref="birthday"
:readonly="isInsured && birthdayLimit"
></FieldDatePicter>
<FieldDatePicter
v-validate="'required'"
label="证件起始日期"
name="证件起始日期"
required
:value.sync="userInfo.certificateValidate"
type="date"
:defaultDate="new Date()"
@confirm="onDateConfirm($event, '0')"
ref="certificateValidate"
:flag="true"
:readonly="isInsured"
></FieldDatePicter>
<FieldDatePicter
:v-validate="{ required: certiexpiredateRequired }"
label="证件截止日期"
name="证件截止日期"
:required="isRequired"
:defaultDate="new Date()"
:value.sync="userInfo.certiexpiredate"
type="date"
@confirm="onDateConfirm($event, '1')"
ref="certiexpiredate"
:flag="certiexpiredateShow"
:readonly="isInsured || idLimit"
></FieldDatePicter>
<div class="border-bt relative fs14 p10 flex align-center">
<van-checkbox v-model="userInfo.effectiveDateType" class="fr" :disabled="effectiveDateTypeAble" @change="effectiveDataTypeChange">长期</van-checkbox>
</div>
<select-radio
:radios="sexRadio"
required
label="性别"
:value.sync="userInfo.sex"
:disabled="isInsured && sexLimit"
v-validate="'required'"
name="性别"
></select-radio>
<van-field
:value="userInfo.marriageStatus"
readonly
required
label="婚姻状况"
name="婚姻状况"
v-validate="'required'"
right-icon="arrow"
placeholder="请选择"
@click="setMarriageStatus('10')"
/>
<van-field
:value="userInfo.nativeplace | idToText('nativeplace')"
readonly
label="国籍"
name="国籍"
required
v-validate="'required'"
right-icon="arrow"
placeholder="请选择"
@click="toSelect('1')"
/>
<van-field
v-model="areaStr"
label="联系地址"
placeholder="请选择"
required
@click="isAreaListShow = true"
readonly
right-icon="arrow"
v-validate="'required|contactAdderss'"
data-vv-name="联系地址"
/>
<van-field v-model="userInfo.village" label="" name="详细地址" placeholder="请输入详细地址" v-validate="'required'" clearable maxlength="30" />
<div class="pl10 pt10 pb10 pr10 address fs14">
<van-checkbox v-model="withRootUser.value">同投保人地址</van-checkbox>
</div>
<van-field
v-model="userInfo.yearSalary"
label="平均年收入(万元)"
name="平均年收入"
required
placeholder="请输入,单位万元"
v-validate="'required|onlyNumber'"
data-vv-name="平均年收入"
clearable
maxlength="5"
/>
<van-field
v-model="userInfo.mobile"
clearable
label="联系电话"
name="联系电话"
required
placeholder="请输入"
v-validate="'required|mobile'"
maxlength="11"
:readonly="isInsured && mobileLimit"
/>
<!-- <van-field
v-model="areaName"
readonly
label="联系地址"
name="联系地址"
required
right-icon="arrow"
placeholder="请选择"
v-validate="'required'"
@click="chooseArea"
/> -->
<!-- <div class="relative border-bt fs14 p10 flex align-center">
<van-checkbox v-model="userInfo.asAppntAddress" @change="asAppntAddress" :disabled="isInsured">同投保人</van-checkbox>
</div> -->
<!-- <van-field v-model="userInfo.email" required label="电子邮箱" name="电子邮箱" placeholder="请输入" v-validate="'required|email'" clearable :readonly="isInsured" /> -->
<occupation-picker
:value.sync="userInfo.occupationCode"
:chooseName.sync="userInfo.occupationName"
:lifeGrade.sync="userInfo.lifeGrade"
:healthGrade.sync="userInfo.healthGrade"
clearable
label="职业类别"
name="职业类别"
required
v-validate="'required'"
placeholder="请选择"
:parentShowPicker.sync="occupationShowPicker"
@on-click="selectClick('2')"
@on-choose="chooseOccupation"
/>
<van-field
v-model="userInfo.bnfOrder"
required
readonly
label="受益顺序"
name="受益顺序"
placeholder="请输入"
v-validate="'required|onlyNumber'"
maxlength="1"
/>
<van-field
v-model="userInfo.bnfLot"
label="受益比例(%)"
name="受益比例"
placeholder="指定多个受益人受益比例和须为100%"
required
v-validate="'required|onlyNumber'"
maxlength="3"
clearable
/>
</van-cell-group>
<!-- 工作信息 -->
<!-- <van-cell-group>
</van-cell-group>-->
<!-- 家庭信息 -->
<!-- <van-cell-group>
</van-cell-group>-->
<van-button type="danger" class="bottom-btn" @click="nextStep" v-no-more-click="1000">添加</van-button>
<!-- 字段选择 -->
<van-popup v-model="popupShow" position="bottom">
<van-picker show-toolbar :columns="columns" @confirm="onConfirm" @cancel="popupShow = false" />
</van-popup>
<!-- 地区选择 -->
<van-popup position="bottom" v-model="isAreaListShow">
<van-area title="省市区" :visible-item-count="4" :area-list="areaList" @confirm="setBankArea" @cancel="isAreaListShow = false" />
</van-popup>
<van-popup v-model="isMarriageStatusShow" position="bottom">
<van-picker show-toolbar :columns="columns" @confirm="onMarriageConfirm" @cancel="isMarriageStatusShow = false" />
</van-popup>
</div>
</template>
<script>
import { Field, CellGroup, Checkbox, Popup, Picker, Area } from 'vant'
import SelectRadio from '@/components/ebiz/SelectRadio'
import FieldDatePicter from '@/components/ebiz/FieldDatePicter'
import OccupationPicker from '@/components/ebiz/occipation/OccupationPicker'
import DataDictionary from '@/assets/js/utils/data-dictionary'
import areaList from '@/assets/js/utils/areaForSale'
import countCredentialValidity from '@/assets/js/utils/countCredentialValidity'
import filter from '@/filters/index'
import utilsAge from '@/assets/js/utils/age'
import IdentityCardScan from '@/components/ebiz/sale/IdentityCardScan'
import CustomerPicker from '@/components/ebiz/customer/CustomerPicker'
import idNoCheck from '@/assets/js/utils/idNoCheck'
import { idToData } from './js/verification'
import { selectComp } from './js/methods'
import getAreaName from '@/assets/js/utils/getAreaNameForSale'
import { getOrderDetail, checkAppointBnf } from '@/api/ebiz/sale/sale'
let relationToInsured = [
{ id: 2, text: '配偶' },
{ id: 3, text: '父母' },
{ id: 4, text: '子女' }
]
export default {
name: 'insuredInfo',
components: {
[SelectRadio.name]: SelectRadio,
[FieldDatePicter.name]: FieldDatePicter,
[OccupationPicker.name]: OccupationPicker,
[Field.name]: Field,
[CellGroup.name]: CellGroup,
[Checkbox.name]: Checkbox,
[Popup.name]: Popup,
[Picker.name]: Picker,
[Area.name]: Area,
[IdentityCardScan.name]: IdentityCardScan,
[CustomerPicker.name]: CustomerPicker
},
data() {
return {
withRootUser: {
load: false, //防止重复请求
value: false,
},
nameLimit: false,
idNoLimit: false,
birthdayLimit: false,
sexLimit: false,
mobileLimit: false,
isAreaListShow: false,
province: '',
city: '',
county: '',
areaStr: '',
isMarriageStatusShow: false,
effectiveDateTypeAble: true, //长期按钮是否禁用
isScan: false, //是否显示证件扫描组件
sexRadio: [
{
label: '男',
value: '0'
},
{
label: '女',
value: '1'
}
],
currentPopupIndex: '',
relationToAppnt: '',
popupShow: false,
areaShow: false,
pickerType: undefined,
columns: [],
valueKey: 'text',
nativeplace: '',
idType: '居民身份证',
degree: '',
socialSecurity: '',
taxIdentity: '',
areaValue: '110101',
certiexpiredateRequired: true, //证件截止日期是否需要校验
certiexpiredateShow: true, //证件截止日期是否可以选择
marriage: '',
isRequired: '', //长期前是否有*
userInfo: {
mobile: '',
yearSalary: '',
marriage: '',
averageAnnualIncome: '',
marriageStatus: '',
province: '',
city: '',
area: '',
village: '',
name: '',
sex: '0',
nativeplace: '1', //国家地区
birthday: '',
idType: '1', //证件类型
idNo: '', //证件号码
certiexpiredate: '', //证件到期时间
effectiveDateType: false, //是否长期
asAppntAddress: false, //同投保人
occupationCode: '',
occupationName: '',
workcompany: '', //工作单位
fIncome: '',
bnfOrder: '1', //受益顺序
bnfLot: '', //受益比例
bnfFlag: '',
relationToInsured: '', //和被保险人的关系
lifeGrade: '',
healthGrade: '',
bnfType: '0' //身故受益人
},
areaList,
occupationShowPicker: false,
customerShowPicker: false, //客户列表展示
isInsured: false, //是投保人本人,
Insured: false, //投保人本人按钮是否置灰
idLimit: false, //证件起止日期是否只读
saleInsuredPersonInfo: JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo')) //被保人信息
}
},
mounted() {
window.appCallBack = this.appCallBack
if (localStorage.applicant == '1' || this.saleInsuredPersonInfo.relationToAppnt == '1' || this.saleInsuredPersonInfo.relationToAppnt == '5') {
this.Insured = true
} else {
this.Insured = false
}
},
methods: {
setCustomerMarriage(marriageCode) {
for (let status of DataDictionary.marriage) {
if (status.id == marriageCode) {
this.userInfo.marriageStatus = status.text
// this.userInfo.marriage = status.id
}
}
},
setBankArea(areaInfo) {
let province = areaInfo[0]
let city = areaInfo[1]
let county = areaInfo[2]
switch (county.code) {
case '500129':
county.code = '500229'
break
case '500130':
county.code = '500230'
break
case '500131':
county.code = '500231'
break
case '500133':
county.code = '500233'
break
case '500135':
county.code = '500235'
break
case '500136':
county.code = '500236'
break
case '500137':
county.code = '500237'
break
case '500138':
county.code = '500238'
break
case '500140':
county.code = '500240'
break
case '500141':
county.code = '500241'
break
case '500142':
county.code = '500242'
break
case '500143':
county.code = '500243'
break
}
console.log(areaInfo[2])
this.userInfo.province = province.code
this.userInfo.city = city.code
this.userInfo.area = county.code
this.isAreaListShow = false
this.areaStr = `${province.name}-${city.name}-${county.name}`
},
onMarriageConfirm(value) {
this.userInfo.marriageStatus = value.text
for (let status of DataDictionary.marriage) {
if (status.text === value.text) {
this.userInfo.marriage = status.id
}
}
this.isMarriageStatusShow = false
},
setMarriageStatus() {
this.isMarriageStatusShow = true
this.columns = DataDictionary.marriage
},
//监听名字变化
nameChange(name) {
this.userInfo.name = name
},
selectClick(index) {
// 同被保险人不允许编辑
if (this.isInsured) {
return
}
// this.currentPopupIndex = index
// let title = ''
// if (index == 1) {
// ;[this.customerShowPicker, title] = [true, '客户列表']
// } else if (index == 2) {
// ;[this.occupationShowPicker, title] = [true, '职业类别']
// }
// setTimeout(() => {
// this.$jump({
// flag: 'navigation',
// extra: {
// title,
// hiddenLeft: '1'
// }
// })
// this.closeBtn()
// }, 400)
// let that = this
selectComp(this, index, '3')
},
appCallBack() {
this.$jump({
flag: 'goBack',
extra: {
refresh: '1', //是否返回后刷新01
index: '-1'
}
})
this.$jump({
flag: 'navigation',
extra: {
title: '指定受益人信息',
hiddenRight: '1'
}
})
if (this.currentPopupIndex == 1) {
this.customerShowPicker = false
} else if (this.currentPopupIndex == 2) {
this.occupationShowPicker = false
}
},
chooseOccupation() {
this.$jump({
flag: 'navigation',
extra: {
title: '指定受益人信息',
hiddenRight: '1'
}
})
this.occupationShowPicker = false
},
//弹框选择
toSelect(pickerType, valueKey) {
//同被保险人不允许编辑
if (this.isInsured) {
return
}
//pickerType 1、国家地区 2、证件类型 3、文化程度 4、有无社保 5、税收居民身份 6、婚姻状况
;[this.popupShow, this.pickerType] = [true, pickerType]
if (valueKey) this.valueKey = valueKey
if (pickerType == '1') {
this.columns = DataDictionary.nativeplace
} else if (pickerType == '2') {
this.columns = DataDictionary.idType
} else if (pickerType == '3') {
this.columns = DataDictionary.degree
} else if (pickerType == '4') {
this.columns = [
{ id: 0, text: '有' },
{ id: 1, text: '无' }
]
} else if (pickerType == '5') {
this.columns = DataDictionary.taxIdentity
} else if (pickerType == '6') {
this.columns = DataDictionary.marriage
} else if (pickerType == '7') {
this.columns = relationToInsured
}
},
//确认选择字段
onConfirm(value) {
this.popupShow = false
if (this.pickerType == '1') {
;[this.userInfo.nativeplace, this.nativeplace] = [value.id, value.text]
} else if (this.pickerType == '2') {
this.idLimit = false
this.userInfo.idNo = this.userInfo.certiexpiredate = this.userInfo.birthday = ''
this.userInfo.sex = '0'
this.effectiveDateTypeAble = false
console.log(value.id)
//身份证以外的证件类型可以使用长期
if (value.id == '1') {
console.log('123')
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
this.effectiveDateTypeAble = age <= 45
}else if (value.id == '2') {
//证件类型户口本时,证件截止日期和是否长期不可选择
this.idLimit = true
this.effectiveDateTypeAble = true
this.userInfo.effectiveDateType = false
}
// else if (value.id == 2 || value.id == 3) {
// this.effectiveDateTypeAble = true
// }
else {
this.effectiveDateTypeAble = false
}
;[this.userInfo.idType, this.idType] = [value.id, value.text]
} else if (this.pickerType == '3') {
;[this.userInfo.degree, this.degree] = [value.id, value.text]
} else if (this.pickerType == '4') {
;[this.userInfo.socialSecurity, this.socialSecurity] = [value.id, value.text]
} else if (this.pickerType == '5') {
;[this.userInfo.taxIdentity, this.taxIdentity] = [value.id, value.text]
} else if (this.pickerType == '6') {
;[this.userInfo.marriage, this.marriage] = [value.id, value.text]
} else if (this.pickerType == '7') {
// //如果受益人是被保险人本人
// if (value.id == 1) {
// //获取投保人数据
// getOrderDetail({ orderNo: localStorage.orderNo }).then(res => {
// if (res.result == 0) {
// this.isInsured = true
// //获取被保险人信息
// let insuredInfo = res.orderDTO.insuredDTOs[0]
// for (let key in this.userInfo) {
// this.userInfo[key] = insuredInfo[key]
// }
// console.log(this.userInfo)
// // setTimeout(() => {
// // this.userInfo.city = insuredInfo.homeCity //家庭市
// // this.userInfo.area = insuredInfo.homeArea //家庭区
// // this.userInfo.province = insuredInfo.homeProvince //家庭省
// // this.areaName = getAreaName([{ code: insuredInfo.homeProvince }, { code: insuredInfo.homeCity }, { code: insuredInfo.homeArea }]) //家庭地址
// // this.userInfo.village = insuredInfo.homeAddress //家庭详细地址
// // }, 0)
// //受益人类型
// this.userInfo.bnfType = '0'
// //是否长期
// this.userInfo.effectiveDateType = insuredInfo.effectiveDateType == 'false' ? false : true
// //受益顺序
// this.userInfo.bnfOrder = '1'
// //长期判断
// if (this.userInfo.idType == '1') {
// // 计算年龄
// let age = utilsAge.getAge(this.userInfo.birthday, new Date())
// // 长期按钮是否禁用
// this.effectiveDateTypeAble = age <= 45
// }
// } else {
// this.$toast(res.resultMessage)
// }
// ;[this.userInfo.relationToInsured, this.relationToAppnt] = [value.id, value.text]
// // console.log(this.userInfo)
// })
// // console.log(JSON.parse(localStorage.saleInsuredPersonInfo))
// // this.userInfo = JSON.parse(localStorage.saleInsuredPersonInfo)
// // this.userInfo.bnfOrder = '1'
// } else {
this.isInsured = false
// for (var key in this.userInfo) {
// if (!['nativeplace', 'sex', 'idType', 'bnfOrder', 'bnfType'].includes(key)) {
// this.userInfo[key] = ''
// }
// }
// this.areaName = ''
;[this.userInfo.relationToInsured, this.relationToAppnt] = [value.id, value.text]
}
// ;[this.userInfo.relationToInsured, this.relationToAppnt] = [value.id, value.text]
// }
},
//证件起始截止日期
onDateConfirm(val, type) {
switch (type) {
case '0':
{
//证件起始日期
//如果录入日期早于出生日期或晚于当前日期
if (Date.parse(val) > Date.parse(new Date()) || Date.parse(val) < Date.parse(this.userInfo.birthday)) {
this.userInfo.certificateValidate = ''
this.$refs.certificateValidate.date = ''
return this.$toast('证件起始日期填写错误')
}
// 计算年龄
// 长期按钮是否禁用
if (this.userInfo.idType == '1') {
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
this.effectiveDateTypeAble = age <= 45
if(this.userInfo.birthday){
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,val)
}
}
}
break
case '1':
{
//证件截止日期
//如果已经勾选了长期
// if (this.userInfo.effectiveDateType) {
// //清空数据并返回
// this.userInfo.certiexpiredate = ''
// this.$refs.certiexpiredate.date = ''
// return
// }
this.userInfo.effectiveDateType = false
//如果录入日期早于当前日期
if (Date.parse(val) < Date.parse(new Date())) {
this.userInfo.certiexpiredate = ''
this.$refs.certiexpiredate.date = ''
return this.$toast('亲,请您核实受益人身份证件有效期~')
}
//身份证证件类型的判断
if (this.userInfo.idType == '1') {
//获取年龄
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
if(this.userInfo.birthday){
this.userInfo.certificateValidate = countCredentialValidity.getStartDate(age,val)
}
}
}
break
case '2':
{
//出生日期
//如果录入日期晚于当前日期
if (Date.parse(val) > Date.parse(new Date())) {
this.userInfo.birthday = ''
this.$refs.birthday.date = ''
return this.$toast('出生日期不晚于当日')
}
//长期判断
if (this.userInfo.idType == '1') {
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
this.effectiveDateTypeAble = age <= 45
}
//出生证有效期
if (this.userInfo.idType == '3') {
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(val) > Date.parse('1973-01-01')) {
this.userInfo.birthday = ''
this.$refs.birthday.date = ''
return this.$toast('出生证有效期或出生日期有误')
}
}
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
if (this.userInfo.certificateValidate && !this.userInfo.certiexpiredate) {
this.userInfo.certiexpiredate = countCredentialValidity.getEndDate(age,this.userInfo.certificateValidate)
}
if (this.userInfo.certiexpiredate && !this.userInfo.certificateValidate) {
this.userInfo.certificateValidate = countCredentialValidity.getEndDate(age,this.userInfo.certiexpiredate)
}
}
break
}
},
//选择客户
chooseCustomer(data) {
this.customerShowPicker = false
this.$jump({
flag: 'navigation',
extra: {
title: '指定受益人信息',
hiddenRight: '1'
}
})
this.userInfo.name = data.customerName //用户名
if (data.dacustomerSex == null) {
this.userInfo.sex = null
} else {
this.userInfo.sex = String(data.customerSex) //性别
}
this.userInfo.nativeplace = data.country //国家地区
this.userInfo.birthday = data.birthday //出生日期
this.userInfo.idType = data.customerIdType //证件类型
// 证件截止日期证件截止日期应为第16周岁的生日日期
if(this.userInfo.idType == '2'){
//证件类型如果是户口本时,证件有效止期不可编辑
this.idLimit = true
this.effectiveDateTypeAble = false
this.userInfo.effectiveDateType = false
}
//受益人证件类型如果是户口本时证件截止日期证件截止日期应为第16周岁的生日日期。
if(this.userInfo.idType == '2' && idToData(this.userInfo.idNo).age <16){
// 获取出生日期年份16
let year = Number(this.userInfo.birthday.substr(0,4)) + 16
if(this.userInfo.birthday.substr(5,5) == '02-29'){
// 获取某年某月一共多少天
let date = new Date(year, 2, 1)
let dayEnd = new Date(date.getTime() - 864e5).getDate()
this.userInfo.certiexpiredate = year +'-02-'+ dayEnd
}else{
this.userInfo.certiexpiredate = year +'-'+ this.userInfo.birthday.substr(5,5)
}
}
this.userInfo.idNo = data.customerIdNumber //证件号码
this.setCustomerMarriage(data.marryStatus)
this.userInfo.village = data.homeAddress
this.userInfo.mobile = data.customerPhone
if (data.homeProvince && data.homeCity && data.homeArea) {
this.areaStr = getAreaName([{ code: data.homeProvince }, { code: data.homeCity }, { code: data.homeArea }])
}
if (data.idEffectEndDate == '9999-12-31') {
this.userInfo.effectiveDateType = true //是否长期
} else {
this.userInfo.certiexpiredate = data.idEffectEndDate //证件截止日期
}
this.userInfo.occupationCode = data.occupationCode
this.userInfo.occupationCode = data.occupationCode //职业类别编码
this.userInfo.occupationName = data.occupationName //职业类别名称
this.userInfo.lifeGrade = data.lifeGrade //寿险等级
this.userInfo.healthGrade = data.healthGrade //健康等级
this.userInfo.province = data.homeProvince //家庭省
this.userInfo.city = data.homeCity //家庭市
this.userInfo.area = data.homeArea //家庭区
//计算年龄
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
// 长期按钮是否禁用
this.effectiveDateTypeAble = age <= 45
//数据是否从客户列表拉取
this.fromCustomer = true
this.getRelatedData(this.userInfo.idNo, '1')
},
async nextStep() {
// 计算年龄
let age = utilsAge.getAge(this.userInfo.birthday, new Date())
let relationToAppnt = this.saleInsuredPersonInfo.relationToAppnt
let insuredDetail = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredInfo'))
// let insuredDetail = JSON.parse(localStorage.insuredDetail)
// let relationToAppnt = localStorage.relationToAppnt
// //被保人不是已婚
// if (this.insuredMarriage != '1') {
// return this.$toast('与投保人关系不正确')
// }
// let insuredSex = JSON.parse(localStorage.saleInsuredPersonInfo).sex
// let appntSex = JSON.parse(localStorage.saleInsuredInfo).sex
// //投被保险人性别相同
// if (insuredSex == appntSex) {
// return this.$toast('性别输入有误')
// }
for (let status of DataDictionary.marriage) {
if (status.text === this.userInfo.marriageStatus) {
this.userInfo.marriage = status.id
}
}
console.log(insuredDetail)
// 页面跳转
let valid = await this.$validator.validate()
// .then(valid => {
if (true === valid) {
// 受益人是被保险人的配偶
if (this.userInfo.relationToInsured == '2') {
// 受益人与投保人都是被保险人的配偶时
if (this.userInfo.relationToInsured == '2' && relationToAppnt == '2') {
if (this.userInfo.name != insuredDetail.name || this.userInfo.sex != insuredDetail.sex || this.userInfo.idNo != insuredDetail.idNo) {
return this.$toast('受益人数据不合法,请重新输入')
}
}
//与被保人关系是配偶
let insuredInfo = this.saleInsuredPersonInfo
//如果投保人不是已婚
// if (insuredInfo.marriage != '1') {
// return this.$toast('亲,受益人与被保险人关系为配偶,被保险人婚姻状况必须为已婚哦~')
// }
//如果被保险人与投保人性别相同
if (insuredInfo.sex == this.userInfo.sex) {
return this.$toast('额,受益人与被保险人关系为配偶,性别不能相同哦~')
}
//如果性别男小于22岁 或者 性别女小于20岁
// if ((this.userInfo.sex == '0' && age < 22) || (this.userInfo.sex == '1' && age < 20)) {
// return this.$toast('年龄与婚姻状况不符')
// }
}
// 受益人是被保险人的父母,被保险人是投保人的子女时
if (this.userInfo.relationToInsured == '3' && relationToAppnt == '4') {
if (this.userInfo.sex == insuredDetail.sex) {
if (this.userInfo.name != insuredDetail.name || this.userInfo.idNo != insuredDetail.idNo) {
return this.$toast('受益人数据不合法,请重新输入')
}
}
}
let insuredInfo = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo'))
// 受益人与被保险人关系为父母时,受益人年龄必须大于被保险人年龄
if (this.userInfo.relationToInsured == '3') {
if (age < insuredInfo.age) {
await this.$dialog.confirm({
title: '提示',
message: '亲,请确认受益人与被保险人关系哦',
confirmButtonText: '继续填写',
cancelButtonText: '返回修改'
})
}
}
// 受益人与被保险人关系为子女时,受益人年龄必须小于被保险人年龄
if (this.userInfo.relationToInsured == '4') {
if (age > insuredInfo.age) {
await this.$dialog.confirm({
title: '提示',
message: '亲,请确认受益人与被保险人关系哦',
confirmButtonText: '继续填写',
cancelButtonText: '返回修改'
})
}
}
//如果证件类型是身份证
if (this.userInfo.idType == '1') {
if (this.userInfo.nativeplace != '1') {
return this.$toast('证件类型”为“身份证,国籍必须为中国哦')
}
//校验性别是否与身份证号码位相符
if (this.userInfo.idNo.length == '15') {
//15位身份证第15位是性别位, 奇男偶女
let sexSign = this.userInfo.idNo.substr(14, 1)
if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) {
return this.$toast('性别录入与身份证不符')
}
//15位身份证第7-12位是生日位, 年月日
let birthSign = this.userInfo.idNo.substr(6, 6)
if (
this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) ||
this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) ||
this.userInfo.birthday.substr(8, 2) != birthSign.substr(4, 2)
) {
return this.$toast('生日录入与身份证不符')
}
} else if (this.userInfo.idNo.length == '18') {
//18位身份证第17位是性别位, 奇男偶女
let sexSign = this.userInfo.idNo.substr(16, 1)
if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) {
return this.$toast('性别录入与身份证不符')
}
//18位身份证第7-14位是生日位, 年月日
let birthSign = this.userInfo.idNo.substr(6, 8)
if (
this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) ||
this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) ||
this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2)
) {
return this.$toast('生日录入与身份证不符')
}
}
// 证件号码规则校验
if (!idNoCheck.isIdno(this.userInfo.idNo)) {
console.log('证件号码校验有误')
return this.$toast('您填写的证件号码有误')
}
//证件有效期不能为空
if (this.userInfo.effectiveDateType == false && !this.userInfo.certiexpiredate) {
return this.$toast('证件有效期不能为空')
}
//年龄在小于周岁不含46周岁证件有效期不能为长期
if (age < 46 && this.userInfo.effectiveDateType == true) {
return this.$toast('证件有效期错误年龄小于46周岁的公民身份证有效期不能为长期')
}
//证件止期
let val = this.userInfo.certiexpiredate
if (Date.parse(val) < Date.parse(new Date())) {
this.userInfo.certiexpiredate = ''
this.$refs.certiexpiredate.date = ''
return this.$toast('您的证件已过期')
}
//年龄在16周岁以下
if (age < 16) {
if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 5) {
return this.$toast('16周岁以下的证件有效期为5年')
}
//年龄在16-21周岁之间
}else if (age >= 16 && age <= 21) {
if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 10 && new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 5) {
return this.$toast('16周岁~21周岁的证件有效期为10年或5年')
}
//年龄在22-25周岁之间
}else if (age >= 22 && age <= 25) {
if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 10) {
return this.$toast('22周岁~25周岁的证件有效期为10年')
}
//年龄在26-35周岁之间
}else if (age >= 26 && age <= 35) {
if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 20 && new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 10) {
return this.$toast('26周岁~35周岁的证件有效期为20年或10年')
}
//年龄在36-45周岁之间
} else if (age >= 36 && age <= 45) {
if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 20) {
return this.$toast('36周岁~45周岁的证件有效期为20年')
}
//年龄在46-65周岁之间
} else if (age >= 46 && age <= 65) {
if (new Date(val).getFullYear() - new Date(this.userInfo.certificateValidate).getFullYear() != 20 && this.userInfo.effectiveDateType == false) {
return this.$toast('46周岁~65周岁的证件有效期为20年或长期')
}
//年龄在65周岁以上
} else if (age > 65) {
if (this.userInfo.effectiveDateType == false) {
return this.$toast('65周岁以上的证件有效期为长期')
}
}
//证件类型是户口本
} else if (this.userInfo.idType == '2') {
if (age >= 16) {
return this.$toast('客户年龄在16周岁以上不能使用户口本作为有效证件')
}
if (this.userInfo.nativeplace != '1') {
return this.$toast('证件类型”为“身份证,国籍必须为中国哦')
}
//校验性别是否与身份证号码位相符
if (this.userInfo.idNo.length == '15') {
//15位身份证第15位是性别位, 奇男偶女
let sexSign = this.userInfo.idNo.substr(14, 1)
if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) {
return this.$toast('性别录入与身份证不符')
}
//15位身份证第7-12位是生日位, 年月日
let birthSign = this.userInfo.idNo.substr(6, 6)
if (
this.userInfo.birthday.substr(2, 2) != birthSign.substr(0, 2) ||
this.userInfo.birthday.substr(5, 2) != birthSign.substr(2, 2) ||
this.userInfo.birthday.substr(8, 2) != birthSign.substr(4, 2)
) {
return this.$toast('生日录入与身份证不符')
}
} else if (this.userInfo.idNo.length == '18') {
//18位身份证第17位是性别位, 奇男偶女
let sexSign = this.userInfo.idNo.substr(16, 1)
if ((parseInt(sexSign) % 2 == 0 && this.userInfo.sex != 1) || (parseInt(sexSign) % 2 != 0 && this.userInfo.sex != 0)) {
return this.$toast('性别录入与身份证不符')
}
//18位身份证第7-14位是生日位, 年月日
let birthSign = this.userInfo.idNo.substr(6, 8)
if (
this.userInfo.birthday.substr(0, 4) != birthSign.substr(0, 4) ||
this.userInfo.birthday.substr(5, 2) != birthSign.substr(4, 2) ||
this.userInfo.birthday.substr(8, 2) != birthSign.substr(6, 2)
) {
return this.$toast('生日录入与身份证不符')
}
}
// 证件号码规则校验
if (!idNoCheck.isIdno(this.userInfo.idNo)) {
console.log('证件号码校验有误')
return this.$toast('您填写的证件号码有误')
}
//证件类型是出生证明
} else if (this.userInfo.idType == '3') {
if (age >= 2) {
return this.$toast('客户年龄在2周岁及以上不能使用出生证作为有效证件')
}
// 证件号码规则校验
if (!idNoCheck.isCardNoBirth(this.userInfo.idNo)) {
console.log('证件号码校验有误')
return this.$toast('您填写的证件号码有误')
}
//证件类型是护照
} else if (this.userInfo.idType == '4') {
if (this.userInfo.nativeplace == '1') {
return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~')
}
} else if (this.userInfo.idType == '5') {
console.log(this.userInfo.nativeplace, 'nativeplace')
if (this.userInfo.nativeplace != '2' && this.userInfo.nativeplace != '3') {
return this.$toast('“证件类型”为“港澳居民来往内地通行证”,“国籍”请选择“中国香港”或“中国澳门”哦~')
}
} else if (this.userInfo.idType == '6') {
if (this.userInfo.nativeplace != '4') {
return this.$toast('“证件类型”为“台湾居民来往大陆通行证”,“国籍”请选择“中国台湾”~')
}
} else if (this.userInfo.idType == '9') {
if (this.userInfo.nativeplace != '2' && this.userInfo.nativeplace != '3' && this.userInfo.nativeplace != '4') {
return this.$toast('“证件类型”为“港澳台居民居住证”,“国籍”请选择“中国香港”、“中国澳门”或“中国台湾”~')
}
}
// 通过国籍判断 证件是否符合要求
// 如果是国籍选择中国大陆
if (Number(this.userInfo.nativeplace) <= 4) {
// “身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”
let obj = {
'1': true,
'5': true,
'6': true,
'9': true
}
let idType = this.userInfo.idType
// 通过年龄 判断证件是否符合要求
// 小于2岁
if (age < 2) {
// “出生证”,"户口本"
obj['2'] = true
obj['3'] = true
if (obj[idType] === undefined) {
return this.$toast(
'亲国籍为中国且未满2周岁儿童证件类型必须“身份证”或“户口本”或“出生证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”'
)
}
} else if (age < 16) {
// 小于16岁
// “户口本”
obj['2'] = true
if (obj[idType] === undefined) {
return this.$toast(
'亲国籍为中国且大于2周岁小于16周岁的未成年人证件类型必须为“身份证”或“户口本”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”'
)
}
} else {
// 大于16岁
if (obj[idType] === undefined) {
return this.$toast('亲,国籍为中国,证件类型必须为“身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”')
}
}
} else {
// 非大陆人员按外籍人员
let obj = {
'4': true,
'8': true
}
let idType = this.userInfo.idType
if (obj[idType] === undefined) {
return this.$toast('亲,国籍为外籍,证件类型必须为护照或外国人永久居留身份证投保')
}
}
let beneficiaries = []
if (localStorage.beneficiaryInfo) {
// 从 localStorage 取出数据
beneficiaries = JSON.parse(localStorage.beneficiaryInfo)
// 收益份额不超过 100%
let ratio = 0
beneficiaries.forEach(item => {
ratio += parseInt(item.bnfLot)
})
ratio += parseInt(this.userInfo.bnfLot)
console.log(ratio)
if (ratio > 100) {
return this.$toast('受益份额有误,请重新输入~')
}
if (this.userInfo.idNo != '') {
// 受益人不能重复添加 (证件号码为基准)
let isDbAdd = beneficiaries.some(item => {
return item.idNo == this.userInfo.idNo
})
console.log(isDbAdd)
if (isDbAdd) {
return this.$toast('受益人不支持重复添加')
}
}
} else {
if (this.userInfo.bnfLot > 100) {
return this.$toast('受益份额不能超过100~')
}
}
let thisbnfDTOs = []
thisbnfDTOs.push(this.userInfo)
let params = {
orderType: 'BNF_ORDER',
orderDTO: {
productDTO: null,
orderInfoDTO: {
bnfFlag: this.bnfFlag,
orderNo: this.$route.query.orderNo
},
appntDTO: {},
insuredDTOs: [
{
insuredId: JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo')).insuredId,
bnfDTOs: thisbnfDTOs
}
],
paymentDTO: {},
orderAccountDTO: {},
channelDTO: null,
orderExpandDTO: null,
thirdOrderDTO: null
}
}
checkAppointBnf(params).then(res=>{
if(res.result == '0'){
beneficiaries.push(this.userInfo)
// 保存 新增的受益人信息 以及页面跳转字段
localStorage.beneficiaryInfo = JSON.stringify(beneficiaries)
localStorage.fromAddBeneficiaryInfo = true
if (this.userInfo.asAppntAddress == true) {
localStorage.applicant = '1'
}
this.$jump({
flag: 'h5',
extra: {
url: location.origin + '/#/sale/beneficiary?orderNo=' + this.$route.query.orderNo,
needRefresh: '1'
},
routerInfo: {
path: '/sale/beneficiary?orderNo=' + this.$route.query.orderNo
}
})
} else {
this.$toast(res.resultMessage)
}
})
} else {
this.$toast(this.$validator.errors.all()[0])
}
},
// 证件扫描
goScan() {
this.isScan = true
},
//勾选投保人
asAppntAddress(val) {
if (val) {
if (this.saleInsuredPersonInfo.relationToAppnt == '2') {
;[this.userInfo.relationToInsured, this.relationToAppnt] = ['2', '配偶']
} else if (this.saleInsuredPersonInfo.relationToAppnt == '4') {
;[this.userInfo.relationToInsured, this.relationToAppnt] = ['3', '父母']
} else if (this.saleInsuredPersonInfo.relationToAppnt == '3') {
;[this.userInfo.relationToInsured, this.relationToAppnt] = ['4', '子女']
}
this.isInsured = true
let params = {
orderNo: this.$route.query.orderNo
}
getOrderDetail(params).then(res=>{
if(res.result == 0){
let insuredDetail = res.orderDTO.appntDTO
this.userInfo.name = insuredDetail.name //姓名
this.nameLimit = Boolean(insuredDetail.name)
this.userInfo.sex = insuredDetail.sex //性别
this.sexLimit = Boolean(insuredDetail.sex)
this.userInfo.nativeplace = insuredDetail.nativeplace //国家地区
this.userInfo.birthday = insuredDetail.birthday //出生日期
this.birthdayLimit = Boolean(insuredDetail.birthday)
this.userInfo.idType = insuredDetail.idType //证件类型
this.userInfo.idNo = insuredDetail.idNo //证件号码
this.idNoLimit = Boolean(insuredDetail.idNo)
this.userInfo.certificateValidate = insuredDetail.certificateValidate //证件起始日期
this.userInfo.certiexpiredate = insuredDetail.certiexpiredate == '9999-12-31' ? '' : insuredDetail.certiexpiredate //证件截止日期
this.userInfo.effectiveDateType = insuredDetail.certiexpiredate == '9999-12-31' //是否长期
this.userInfo.mobile = insuredDetail.mobile
this.mobileLimit = Boolean(insuredDetail.mobile)
this.userInfo.marriage =insuredDetail.marriage
if(this.userInfo.marriage == 1){
this.userInfo.marriageStatus = '已婚'
}
else if(this.userInfo.marriage == 2){
this.userInfo.marriageStatus = '未婚'
}
else if(this.userInfo.marriage == 3){
this.userInfo.marriageStatus = '离异'
}
else if(this.userInfo.marriage == 4){
this.userInfo.marriageStatus = '丧偶'
}
let age = utilsAge.getAge(insuredDetail.birthday, new Date())
this.effectiveDateTypeAble = age <= 45
if (age > 45) {
this.userInfo.effectiveDateType = true
}
this.idLimit = true
this.userInfo.occupationCode = insuredDetail.occupationCode //职业类别编码
this.userInfo.occupationName = insuredDetail.occupationName //职业类别名称
this.areaStr = getAreaName([
{ code: insuredDetail.homeProvince },
{ code: insuredDetail.homeCity },
{ code: insuredDetail.homeArea },
])
this.userInfo.province = insuredDetail.homeProvince
this.userInfo.city = insuredDetail.homeCity
this.userInfo.area = insuredDetail.homeArea
this.userInfo.village = insuredDetail.homeAddress
this.userInfo.yearSalary = insuredDetail.averageAnnualIncome
this.userInfo.averageAnnualIncome = insuredDetail.averageAnnualIncome
}
})
} else {
this.isInsured = false
this.userInfo.relationToInsured = ''
this.relationToAppnt = ''
this.userInfo.name = '' //姓名
this.userInfo.sex = '0' //性别
this.userInfo.nativeplace = '1' //国家地区
this.userInfo.birthday = '' //出生日期
this.userInfo.idType = '1' //证件类型
this.userInfo.idNo = '' //证件号码
this.userInfo.certificateValidate = '' //证件起始日期
this.userInfo.certiexpiredate = '' //证件截止日期
this.effectiveDateTypeAble = true
this.userInfo.effectiveDateType = false
this.idLimit = false
this.userInfo.occupationCode = '' //职业类别编码
this.userInfo.occupationName = '' //职业类别名称
}
},
//长期状态改变时
effectiveDataTypeChange(val) {
//勾选长期状态时,证件截止日期置空
if (val) {
this.userInfo.certiexpiredate = ''
this.certiexpiredateRequired = false
} else {
this.certiexpiredateRequired = true
}
},
//获取身份证扫描信息
getIdentityInfo(data) {
console.log(data)
if (data.name && data.name != '待识别') {
this.userInfo.certiexpiredate = data.endDate
this.userInfo.name = data.name
this.userInfo.idNo = data.idNo
}
this.isScan = false
},
//时间戳格式处理
timeStampFormat(timeStamp) {
let date = new Date(timeStamp)
let year = date.getFullYear()
let month = date.getMonth() + 1
month = month.toString().padStart(2, '0')
let day = Number(date.getDate()) + 1
day = day.toString().padStart(2, '0')
return `${year}-${month}-${day}`
},
getRelatedData(val, from) {
if (this.userInfo.idType != '1' && this.userInfo.idType != '2') {
return
}
//如果证件校验不通过,恢复默认值
if (idToData(val).text) {
;[this.userInfo.idNo, this.userInfo.sex, this.userInfo.birthday, this.effectiveDateTypeAble] = ['', '0', '', false]
return this.$toast(idToData(val).text)
}
this.userInfo.effectiveDateType = false
this.effectiveDateTypeAble = idToData(val).age <= 45
this.userInfo.birthday = idToData(val).birthday
//受益人证件类型如果是户口本时证件截止日期证件截止日期应为第16周岁的生日日期。
if(this.userInfo.idType == '2' && idToData(this.userInfo.idNo).age <16){
// 获取出生日期年份16
let year = Number(this.userInfo.birthday.substr(0,4)) + 16
if(this.userInfo.birthday.substr(5,5) == '02-29'){
// 获取某年某月一共多少天
let date = new Date(year, 2, 1)
let dayEnd = new Date(date.getTime() - 864e5).getDate()
this.userInfo.certiexpiredate = year +'-02-'+ dayEnd
}else{
this.userInfo.certiexpiredate = year +'-'+ this.userInfo.birthday.substr(5,5)
}
}
this.userInfo.sex = idToData(val).sex
if (idToData(val).age > 45) {
if (from) {
this.userInfo.effectiveDateType = true
}
this.effectiveDateTypeAble = false
}
//如果选择户口本
if (this.userInfo.idType == '2') {
let exipreDate = Date.parse(this.userInfo.birthday) + Date.parse('1985-12-31')
this.userInfo.certificateValidate = this.userInfo.birthday
this.userInfo.certiexpiredate = this.timeStampFormat(exipreDate)
this.idLimit = true
//如果选择出生证明
}
}
},
filters: {
idToText: filter.idToText
},
watch: {
async 'withRootUser.value'(n) {
const orderNo = this.$route.query.orderNo
if (n && orderNo) {
const rs = await getOrderDetail({ orderNo: orderNo});
this.areaStr = getAreaName([
{ code: rs.orderDTO.appntDTO.homeProvince },
{ code: rs.orderDTO.appntDTO.homeCity },
{ code: rs.orderDTO.appntDTO.homeArea },
])
this.userInfo.province = rs.orderDTO.appntDTO.homeProvince
this.userInfo.city = rs.orderDTO.appntDTO.homeCity
this.userInfo.area = rs.orderDTO.appntDTO.homeArea
this.userInfo.village = rs.orderDTO.appntDTO.homeAddress
} else {
this.homeName = this.userInfo.homeAddress = ''
}
}
},
beforeRouteLeave(to, from, next) {
document.body.style.backgroundColor = ''
next()
}
}
</script>
<style lang="scss" scoped>
.add-beneficiary-container {
.title {
font-weight: 600;
border-bottom: 1px solid #dadada;
}
/deep/.van-checkbox {
margin-left: auto;
}
.address {
display: flex;
flex-direction: row-reverse;
}
}
</style>