【建议书优化需求】投被保人姓名没有格式校验

This commit is contained in:
lyt
2023-04-27 14:50:37 +08:00
parent 7cd4c40ddf
commit 35326d0bb7
2 changed files with 17 additions and 6 deletions

View File

@@ -6,7 +6,6 @@
class="border-bottom" class="border-bottom"
@nameChange="nameChange" @nameChange="nameChange"
@on-choose="chooseCustomer" @on-choose="chooseCustomer"
v-validate="'name'"
name="投保人" name="投保人"
label="姓名" label="姓名"
@on-click="selectClick('1')" @on-click="selectClick('1')"
@@ -53,7 +52,7 @@ import FieldDatePicter from '@/components/ebiz/FieldDatePicter'
import SelectRadio from '@/components/ebiz/SelectRadio' import SelectRadio from '@/components/ebiz/SelectRadio'
import OccupationPicker from '@/components/ebiz/occipation/OccupationPicker' import OccupationPicker from '@/components/ebiz/occipation/OccupationPicker'
import CustomerPicker from '@/components/ebiz/customer/CustomerPicker' import CustomerPicker from '@/components/ebiz/customer/CustomerPicker'
import { CellGroup, Field } from 'vant' import { CellGroup, Field ,Toast } from 'vant'
import { saveProposal } from '@/api/ebiz/proposal/proposal.js' import { saveProposal } from '@/api/ebiz/proposal/proposal.js'
import getAge from '@/assets/js/utils/age.js' import getAge from '@/assets/js/utils/age.js'
import beforeDate from '@/assets/js/utils/getBeforeDate.js' import beforeDate from '@/assets/js/utils/getBeforeDate.js'
@@ -311,6 +310,10 @@ export default {
if(this.appntDTO.name == name){ if(this.appntDTO.name == name){
this.appntDTO.name = '' this.appntDTO.name = ''
} }
let ageRule = /^[a-zA-Z\.\s\u4e00-\u9fa5]{2,120}$/
if (this.appntDTO.name && ageRule.test(this.appntDTO.name)) {
return Toast.fail('姓名长度为2-120个字符之内只能输入汉字或者英文')
}
this.appntDTO.age = String(this.appntDTO.age) this.appntDTO.age = String(this.appntDTO.age)
//投保人年龄校验 //投保人年龄校验
let minAge = getAge.getAge(utils.formatDate(new Date(this.maxDate),'yyyy-MM-dd'), new Date()) let minAge = getAge.getAge(utils.formatDate(new Date(this.maxDate),'yyyy-MM-dd'), new Date())

View File

@@ -10,7 +10,6 @@
@on-choose="chooseCustomer" @on-choose="chooseCustomer"
name="被保险人" name="被保险人"
:readonly="disabled" :readonly="disabled"
v-validate="'name'"
label="姓名" label="姓名"
@on-click="selectClick('1')" @on-click="selectClick('1')"
:parentShowPicker.sync="customerShowPicker" :parentShowPicker.sync="customerShowPicker"
@@ -321,8 +320,13 @@ export default {
}, },
//点击下一步 //点击下一步
nextStep() { nextStep() {
// 建议书投保人/被保人姓名不必填, 填写姓名时展示姓名(落库),不填写姓名时展示性别+年龄,如:男30岁(不落库)
let sex = this.insured.sex == '0'?'男':'女'
let name = sex + this.insured.insuredAge+'岁'
if(this.insured.name == name){
this.insured.name = ''
}
//保存有没有社保,在保费计算用到 //保存有没有社保,在保费计算用到
//localStorage.setItem('proposalMedical', this.insured.medical == '0' ? '1' : '0') //localStorage.setItem('proposalMedical', this.insured.medical == '0' ? '1' : '0')
localStorage.proposalMedical = this.insured.medical == '0' ? '1' : '0' localStorage.proposalMedical = this.insured.medical == '0' ? '1' : '0'
this.insured.insuredAge = String(this.insured.insuredAge) this.insured.insuredAge = String(this.insured.insuredAge)
@@ -330,7 +334,11 @@ export default {
let localSex = this.insured.sex let localSex = this.insured.sex
let relation = this.localInfo.relationToAppnt let relation = this.localInfo.relationToAppnt
let resultSex = checkSex(cacheSex, localSex, relation) let resultSex = checkSex(cacheSex, localSex, relation)
let resultRelation = checkRelation(relation, this.insured.insuredAge) let resultRelation = checkRelation(relation, this.insured.insuredAge)
let ageRule = /^[a-zA-Z\.\s\u4e00-\u9fa5]{2,120}$/
if (this.insured.name && !ageRule.test(this.insured.name)) {
return Toast.fail('姓名长度为2-120个字符之内只能输入汉字或者英文')
}
if (!resultSex) { if (!resultSex) {
return Toast.fail('被保险人性别有误') return Toast.fail('被保险人性别有误')
} }
@@ -365,7 +373,7 @@ export default {
let locaInsured = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo')) let locaInsured = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo'))
let { name, sex, birthday, occupationCode, medical } = this.insured let { name, sex, birthday, occupationCode, medical } = this.insured
if ( if (
locaInsured.name == name && // locaInsured.name == name &&
locaInsured.sex == sex && locaInsured.sex == sex &&
locaInsured.birthday == birthday && locaInsured.birthday == birthday &&
locaInsured.occupationCode == occupationCode && locaInsured.occupationCode == occupationCode &&