Files
ebiz-h5/src/views/ebiz/common/risk-rules.js
liu.xiaofeng@ebiz-digits.com dbc1891bf3 内勤账号做建议书改动
2023-10-23 10:19:19 +08:00

217 lines
7.7 KiB
JavaScript
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.
import { productCheck } from '@/api/ebiz/common/common'
import { getCompany } from '@/api/ebiz/sale/sale'
import { getAgentInfo } from '@/api/ebiz/my/my.js'
import utilsAge from '@/assets/js/utils/age'
import CacheUtils from '@/assets/js/utils/cacheUtils'
import DataDictionary from '@/assets/js/utils/data-dictionary'
export default {
//投、被保险人关系险种的限制
relationLimit(resultData, relationToAppnt, vm) {
var flag = '1'
let tips
DataDictionary.hqbRelationToAppnt.forEach(item => {
if (flag == '1') {
if (item.id == relationToAppnt) {
flag = '0'
}
}
})
if (flag == '1') {
tips = '惠企保产品被保险人与投保人的关系必须为本人、配偶、子女!'
vm.$toast(tips)
return true
}
return false
},
//投、被保险人关系险种的限制
relationCommonLimit(resultData, relationToAppnt, vm) {
var flag = '1'
let tips
DataDictionary.tdylRelationToAppnt.forEach(item => {
if (flag == '1') {
if (item.id == relationToAppnt) {
flag = '0'
}
}
})
if (flag == '1') {
tips = '该产品被保险人与投保人的关系必须为本人、配偶、子女、父母!'
vm.$toast(tips)
return true
}
return false
},
//投、被保险人年龄对险种的限制
ageLimit(resultData, vm, isApplicant,riskProductCode) {
let age, tips
if (isApplicant) {
age = this.getSaleInsuredInfo().age
tips = '投保人年龄不适合此款险种,请选择其他险种!'
} else {
if(riskProductCode == 'GFRS_M0061'){
age = this.getSaleInsuredPersonInfo().birthday?utilsAge.getAge29(this.getSaleInsuredPersonInfo().birthday, new Date()):this.getSaleInsuredPersonInfo().insuredAge
}else{
age = this.getSaleInsuredPersonInfo().birthday?utilsAge.getAgeByValue(this.getSaleInsuredPersonInfo().birthday, new Date()):this.getSaleInsuredPersonInfo().insuredAge
}
tips = '被保险人年龄不适合此款险种,请选择其他险种!'
}
let minAge = resultData.productTrialInfoDTO.ageRange && resultData.productTrialInfoDTO.ageRange.minAge
let maxAge = resultData.productTrialInfoDTO.ageRange && resultData.productTrialInfoDTO.ageRange.maxAge
;[age, minAge, maxAge] = [Number(age), Number(minAge), Number(maxAge)]
if (age > maxAge || age < minAge) {
vm.$toast(tips)
return true
}
return false
},
//社保对附加险的影响 0 无影响 1无社保 2有社保
medicalLimit(resultData, vm) {
let currentMedical = this.getSaleInsuredPersonInfo().medical == 0 ? 2 : 1
let socialInsurance = resultData.productInsuredDTO.socialInsurance
if (socialInsurance == 0) return false
if (currentMedical != socialInsurance) {
vm.$toast('被保险人社保情况不适合此款险种,请选择其他险种!')
return true
}
return false
},
//健康等级对附加险的影响
healthGradeLimit(resultData, vm) {
let cuttentHealthGrade = this.getSaleInsuredPersonInfo().healthGrade
let healthGrade = resultData.productInsuredDTO.healthGrade
if (healthGrade == 0) return false
if (Number(cuttentHealthGrade) > Number(healthGrade)) {
vm.$toast('健康职业等级不适合此款险种,请选择其他险种!')
return true
}
return false
},
//寿险等级对附加险的影响 标识
lifeGradeLimit(resultData, vm) {
let cuttentLifeGrade
if (resultData.productTrialInfoDTO.isRemit === '0' && resultData.productTrialInfoDTO.remitType === '0')
cuttentLifeGrade = this.getSaleInsuredInfo().lifeGrade
else cuttentLifeGrade = this.getSaleInsuredPersonInfo().lifeGrade
let lifeGrade = resultData.productInsuredDTO.lifeGrade
if (lifeGrade == 0) return false
if (Number(cuttentLifeGrade) > Number(lifeGrade)) {
vm.$toast('寿险职业等级不适合此款险种,请选择其他险种!')
return true
}
return false
},
//寿险等级对附加险的影响 标识--卡单
lifeGradeLimitCard(resultData, vm ,cuttentLifeGrade) {
let lifeGrade = resultData.productInsuredDTO.lifeGrade
if (lifeGrade == 0) return false
if (Number(cuttentLifeGrade) > Number(lifeGrade)) {
vm.$toast('寿险职业等级不适合此款险种,请选择其他险种!')
return true
}
return false
},
// 福宝宝产品寿险等级对主险影响
lifeGradeLimitForBaby(resultData, vm) {
let cuttentLifeGrade = this.getSaleInsuredInfo().lifeGrade
let lifeGrade = resultData.productInsuredDTO.lifeGrade
if (lifeGrade == 0) return false
if (Number(cuttentLifeGrade) > Number(lifeGrade)) {
vm.$toast('投保人寿险职业等级不适合此款险种,请选择其他险种!')
return true
}
return false
},
//获取被保险人信息
getSaleInsuredPersonInfo() {
return CacheUtils.getLocItem('saleInsuredPersonInfo') && JSON.parse(CacheUtils.getLocItem('saleInsuredPersonInfo'))
},
//获取投保人信息
getSaleInsuredInfo() {
return CacheUtils.getLocItem('saleInsuredInfo') && JSON.parse(CacheUtils.getLocItem('saleInsuredInfo'))
},
//获取产品售卖权限列表
getProductSellPermissionList(val, that, isCrossChannel) {
let resultData = {
flag:true,
resultMessage:''
}
const data = { productCodes: [val] ,isCrossChannel: isCrossChannel}
if (Object.prototype.toString.call(val) === '[object Array]') data.productCodes = [...val]
return new Promise((resolve, reject) => {
productCheck(data).then(
res => {
if (res.result == '0') {
if (JSON.stringify(res.content) == '{}') {
resultData.flag = false
} else {
//0-有权限 1-没权限
resultData.flag = res.content[val] === '1' ? true : false
}
resultData.resultMessage = res.resultMessage
} else {
that.$toast(res.resultMessage)
}
resolve(resultData)
},
error => {
reject(true)
}
)
})
},
//校验投保人工作单位是否有权限投保该产品
//isAsync 是否协同工作单位 0否 1是
checkCompany(val, workcompany,isAsync, that) {
let flag = true
let columns = []
return new Promise((resolve, reject) => {
getCompany({ productCodes: [val] }).then(
res => {
if (res.result == 0) {
columns = res.content
if (columns.length == 0) {
flag = false
} else {
//是否为协同单位为是并且协同单位可查,才可选主险为嘉和保,桂企保,瑞利年金
flag = !(columns.includes(workcompany) && isAsync == 1)
}
} else {
that.$toast(res.resultMessage)
}
resolve(flag)
},
error => {
reject(true)
}
)
})
},
//查看代理人信息
getAgentInfoFunc(that) {
let flag = {}
return new Promise((resolve, reject) => {
getAgentInfo({}).then(
res => {
if (res.result == 0) {
flag.manageComCode = res.manageComCode ? res.manageComCode.substring(2, 4) : ''
flag.jobNo = res.jobNo
// branchType N1、1代表个险渠道 和 N5、5 代表中介渠道N代表内勤
if (res.branchType == 'N1' || res.branchType == '1') {
flag.branchTypeVal = 'G'
} else if (res.branchType == 'N5' || res.branchType == '5') {
flag.branchTypeVal = 'Z'
}
} else {
that.$toast(res.resultMessage)
}
resolve(flag)
},
error => {
reject(true)
}
)
})
}
}