Files
ebiz-h5/src/views/ebiz/sale/AddBeneficiaryInfo.vue
yang.huaxiang c65ec217f7 Merge branch 'feature/GFRS-1991【待确定】APP检测结果优化-整理' into dev
# Conflicts:
#	src/assets/js/business-common.js
#	src/config/index.js
#	src/views/ebiz/sale/AccountInformation.vue
#	src/views/ebiz/sale/AddBeneficiaryInfo.vue
#	src/views/ebiz/sale/InsuredPerson.vue
2020-10-27 13:17:52 +08:00

1149 lines
44 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
:value.sync="userInfo.name"
:parentShowPicker.sync="customerShowPicker"
@nameChange="nameChange"
@on-click="selectClick('1')"
:readonly="isInsured"
></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"
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"
></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 || idLimit"
></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"></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'"
data-vv-name="联系地址"
/>
<van-field v-model="userInfo.street" label="" name="详细地址" placeholder="请输入详细地址" v-validate="'required'" clearable maxlength="30" />
<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"
/> -->
<!-- <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.jobCode"
: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/area'
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'
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 {
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: {
yearSalary: '',
maritalStatus: '',
averageAnnualIncome: '',
marriageStatus: '',
provinceCode: '',
cityCode: '',
countyCode: '',
jobCode: '',
street: '',
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: {
setBankArea(areaInfo) {
let province = areaInfo[0]
let city = areaInfo[1]
let county = areaInfo[2]
this.userInfo.provinceCode = province.code
this.userInfo.cityCode = city.code
this.userInfo.countyCode = county.code
this.isAreaListShow = false
this.areaStr = `${province.name}-${city.name}-${county.name}`
},
onMarriageConfirm(value) {
this.userInfo.marriageStatus = value.text
if (value.text === '已婚') {
this.userInfo.marriage = '1'
} else {
this.userInfo.marriage = '2'
}
this.isMarriageStatusShow = false
},
setMarriageStatus() {
this.isMarriageStatusShow = true
this.columns = [
{ id: 1, text: '已婚' },
{ id: 2, text: '单身' }
]
},
//监听名字变化
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 || 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(this.$CacheUtils.getLocItem('saleInsuredPersonInfo')))
// // this.userInfo = JSON.parse(this.$CacheUtils.getLocItem('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
// }
// }
// 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('亲,请您核实受益人身份证件有效期~')
}
}
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('出生证有效期或出生日期有误')
}
}
}
break
}
},
//选择客户
chooseCustomer(data) {
// let { name, sex, birthDay, phone } = data
// this.userInfo.applicantPhone = phone
// this.userInfo.applicantBirth = birthDay
// this.userInfo.applicantSex = sex
// this.userInfo.name = name
// console.log(this)
// let age = this.$utils.jsGetAge(birthDay)
// if (age != undefined) {
// this.userInfo.applicantAge = age
// }
console.log(data)
this.customerShowPicker = false
this.$jump({
flag: 'navigation',
extra: {
title: '指定受益人信息',
hiddenRight: '1'
}
})
this.userInfo.name = data.customerName //用户名
if (data.dacustomerSex == null) {
this.userInfo.sex = ''
} else {
this.userInfo.sex = String(data.customerSex) //性别
}
this.userInfo.nativeplace = data.country //国家地区
this.userInfo.birthday = data.birthday //出生日期
this.userInfo.idType = data.customerIdType //证件类型
this.userInfo.idNo = data.customerIdNumber //证件号码
if (data.idEffectEndDate == '9999-01-01') {
this.userInfo.effectiveDateType = true //是否长期
} else {
this.userInfo.certiexpiredate = data.idEffectEndDate //证件截止日期
}
this.userInfo.jobCode = data.occupationCode
this.userInfo.occupationCode = data.occupationCode //职业类别编码
this.userInfo.occupationName = data.occupationName //职业类别名称
this.userInfo.lifeGrade = data.lifeGrade //寿险等级
this.userInfo.healthGrade = data.healthGrade //健康等级
// this.userInfo.mobile = data.customerPhone //移动电话
// this.userInfo.email = data.email //电子邮箱
// this.userInfo.province = data.homeProvince //家庭省
// this.userInfo.city = data.homeCity //家庭市
// this.userInfo.area = data.homeArea //家庭区
// this.userInfo.village = data.homeAddress //家庭详细地址
// if (data.homeProvince.length) {
// this.areaName = getAreaName([{ code: data.homeProvince }, { code: data.homeCity }, { code: 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(this.$CacheUtils.getLocItem('saleInsuredPersonInfo')).sex
// let appntSex = JSON.parse(localStorage.saleInsuredInfo).sex
// //投被保险人性别相同
// if (insuredSex == appntSex) {
// return this.$toast('性别输入有误')
// }
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周岁的公民身份证有效期不能为长期')
}
//年龄在0-15周岁之间
if (age <= 15) {
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1975-01-01')) {
this.userInfo.certiexpiredate = ''
this.$refs.certiexpiredate.date = ''
// this.effectiveDateTypeAble = true
return this.$toast('证件有效期错误未满16周岁的公民身份证有效期应小于等于5年')
}
//年龄在 16-25 周岁之间
} else if (age >= 16 && age <= 25) {
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1980-01-01')) {
this.userInfo.certiexpiredate = ''
this.$refs.certiexpiredate.date = ''
// this.effectiveDateTypeAble = true
return this.$toast('证件有效期错误16周岁~25周岁的公民身份证有效期应小于等于10年')
}
//年龄在 26-45 周岁之间
} else if (age >= 26 && age <= 45) {
if (Date.parse(this.userInfo.certiexpiredate) - Date.parse(new Date()) > Date.parse('1990-01-01')) {
this.userInfo.certiexpiredate = ''
this.$refs.certiexpiredate.date = ''
// this.effectiveDateTypeAble = true
return this.$toast('证件有效期错误26周岁~45周岁的公民身份证有效期应小于等于20年')
}
}
//证件类型是户口本
} else if (this.userInfo.idType == '2') {
if (age > 16) {
return this.$toast('客户年龄在16周岁以上不能使用户口本作为有效证件')
}
// else if (this.userInfo.idNo.length != 18) {
// return this.$toast('户口本的证件号码长度应等于18位')
// }
//证件类型是出生证明
} else if (this.userInfo.idType == '3') {
if (age >= 2) {
return this.$toast('客户年龄在2周岁及以上不能使用出生证作为有效证件')
}
// else if (this.userInfo.idNo.length < 3) {
// return this.$toast('出生证须大于等于3个字符')
// }
//证件类型是护照
} else if (this.userInfo.idType == '4') {
if (this.userInfo.nativeplace == '1') {
return this.$toast('“证件类型”为“外国人护照”,“国籍”不能选择为“中国”哦~')
}
}
// else if (this.userInfo.idType == '4' && this.userInfo.idNo.length < 3) {
// return this.$toast('护照须大于等于3个字符')
// //证件是港澳居民通行证
// } else if (this.userInfo.idType == '5') {
// if (this.userInfo.idNo.length != 9) {
// return this.$toast('证件类型为港澳居民通行证的证件号码须为9位')
// } else if (!/^(H|M)[0-9]{8}$/.test(this.userInfo.idNo)) {
// return this.$toast('证件类型为港澳居民通行证的,证件号码首位字母为"H"/"M",证件号码第2位至第9位为阿拉伯数字')
// }
// //证件是台湾居民通行证
// } else if (this.userInfo.idType == '6' && this.userInfo.idNo.length != 8) {
// return this.$toast('证件类型为台湾居民通行证的证件号码须为8位数字')
// }
// 通过国籍判断 证件是否符合要求
// 如果是国籍选择中国大陆
if (this.userInfo.nativeplace == '1') {
// “身份证”或“台湾居民来往大陆通行证”或“港澳居民来往内地通行证”
let obj = {
'1': true,
'5': true,
'6': 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~')
}
}
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',
needRefresh: '1'
},
routerInfo: {
path: '/sale/beneficiary'
}
})
} else {
this.$toast(this.$validator.errors.all()[0])
}
},
// 证件扫描
goScan() {
this.isScan = true
},
// //联系地址同投保人
// async asAppntAddress(val) {
// //选中时
// if (val) {
// let res = await getOrderDetail({ orderNo: localStorage.orderNo })
// // console.log(res)
// if (res.result == 0) {
// //省市区
// ;[this.userInfo.province, this.userInfo.city, this.userInfo.area] = [
// res.orderDTO.appntDTO.province,
// res.orderDTO.appntDTO.city,
// res.orderDTO.appntDTO.area
// ]
// //同投保人联系地址
// this.areaName = getAreaName([{ code: this.userInfo.province }, { code: this.userInfo.city }, { code: this.userInfo.area }])
// //详细地址
// this.userInfo.village = res.orderDTO.appntDTO.village
// } else {
// this.$toast(res.resultMessage)
// }
// } else {
// // 清空地址
// this.areaName = ''
// this.userInfo.village = ''
// this.userInfo.province = this.userInfo.city = this.userInfo.area = ''
// }
// },
//勾选投保人
asAppntAddress(val) {
console.log(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 insuredDetail = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredInfo'))
this.userInfo.name = insuredDetail.name //姓名
this.userInfo.sex = insuredDetail.sex //性别
this.userInfo.nativeplace = insuredDetail.nativeplace //国家地区
this.userInfo.birthday = insuredDetail.birthday //出生日期
this.userInfo.idType = insuredDetail.idType //证件类型
this.userInfo.idNo = insuredDetail.idNo //证件号码
this.userInfo.certificateValidate = insuredDetail.certificateValidate //证件起始日期
this.userInfo.certiexpiredate = insuredDetail.certiexpiredate == '9999-01-01' ? '' : insuredDetail.certiexpiredate //证件截止日期
this.userInfo.effectiveDateType = insuredDetail.certiexpiredate == '9999-01-01' //是否长期
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 //职业类别名称
} 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 = date.getDate()
day = day.toString().padStart(2, '0')
return `${year}-${month}-${day}`
},
getRelatedData(val, from) {
if (this.userInfo.idType != '1') {
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.effectiveDateTypeAble = idToData(val).age < 45
// this.userInfo.birthday = idToData(val).birthday
// this.userInfo.sex = idToData(val).sex
// if (!['1', '2', '3', 1, 2, 3].includes(this.userInfo.idType)) {
// 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
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
// //如果选择出生证明
// } else if (this.userInfo.idType == '3') {
// let exipreDate = Date.parse(this.userInfo.birthday) + Date.parse('1972-12-31')
// this.userInfo.certificateValidate = this.userInfo.birthday
// this.userInfo.certiexpiredate = this.timeStampFormat(exipreDate)
// this.idLimit = true
// } else {
// this.idLimit = false
// }
}
},
filters: {
idToText: filter.idToText
},
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;
}
}
</style>