Files
ebiz-h5/src/views/ebiz/common/CalculatePremium.vue

2554 lines
108 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="calculate-premium-container pb50 pt10 redRadioCheckbox">
<div class="bg-white ph10 pt10">
<div class="flex justify-content-s align-items-c border-bottom pb10">
<span class="mr10">{{ saleInsuredPersonInfo.name }}</span>
<span class="mr10">{{ saleInsuredPersonInfo.sex == 0 ? '男' : '女' }}</span>
<span class="mr10">{{ saleInsuredPersonInfo.age }}</span>
<span class="mr10 flex1 van-ellipsis">{{ saleInsuredPersonInfo.occupationName }}</span>
</div>
</div>
<div v-for="(item, index) in chooseProducts" :key="index" class="ph10 bg-white">
<div class="flex justify-content-s align-items-c border-bottom pv10">
<van-tag type="primary" v-if="item.isMainRisk == 0" class="mr5 green" plain>主险</van-tag>
<van-tag type="primary" v-else class="mr5 green" plain>附加险</van-tag>
<span class="ml5 center fs13 flex1">{{ item.riskName }}</span>
<van-tag type="primary" v-if="item.isMainRisk == 0 && item.hasAddtionRisk && isEnterAddtionRisk" plain @click="selectAddtionRisk" class="green mr8"
></van-tag
>
<van-icon name="search" size="20" v-if="item.documentDTOS && item.documentDTOS.length > 0" @click="seeDocument(index)" class="green mr5" />
<van-icon name="delete" size="22" @click="deleteRisk(index)" class="green" />
</div>
<!-- 险种条件-->
<div v-if="(item.isRemit == 1 && isTrial == '1') || (item.isRemit == 1 && isTrial != '1' && item.isMainRisk == 1)">
<!-- <div v-if="item.isRemit == 1 && isTrial == '1'"> -->
<div v-for="(riskFactor, riskFactorIndex) in item.calFactorLst" :key="riskFactorIndex">
<!--riskFactor.type 1输入框和步进器 0 下拉选 -->
<div class="flex justify-content-s pv10 border-bottom" v-if="riskFactor.type == 1 && item.productCode != 'GFRS_A0011'">
<div class="flex align-items-c">
<span v-if="riskFactor.suffix" class="fs14">{{ riskFactor.name + '(' + riskFactor.suffix + ')' }}</span>
<span v-else class="fs14">{{ riskFactor.name }} &nbsp;&nbsp; &nbsp;&nbsp;</span>
<!-- {{ riskFactorIndex }} -->
<!-- {{defalutAmt}} -->
<van-stepper
v-model="item.calFactorLst[riskFactorIndex].displayAmount"
:min="riskFactor.minAmt || riskFactor.minPrem"
:max="riskFactor.maxAmt || riskFactor.maxPrem"
:show-plus="false"
:show-minus="false"
class="ml30"
@change="
stepperChange(
item.calFactorLst[riskFactorIndex].displayAmount,
index,
riskFactorIndex,
riskFactor.minAmt || riskFactor.minPrem,
riskFactor.maxAmt || riskFactor.maxPrem,
riskFactor
)
"
input-width="100"
:integer="false"
/>
</div>
</div>
<!-- GFRS_A0011-附加两全 属于非豁免险 但附加两全保额=主险年交保费+其他不带豁免责任的长期期交附加险年交保费 此处保额单独展示 -->
<div v-else-if="item.productCode == 'GFRS_A0011' && riskFactor.type == 1 && riskFactor.code == 'amt'" class="flex justify-content-s pv10 border-bottom">
<van-field v-model="riskFactor.defaultValue" readonly :label="riskFactor.name + '(' + riskFactor.suffix + ')'" />
</div>
<!-- //主险的交费期间联动国富人寿附加两全(GFRS_A0011)保险的交费期间 -->
<div
class="flex justify-content-s pv10 border-bottom"
v-if="riskFactor.type == 0 && item.productCode != 'GFRS_A0011'"
:class="{ hidden: riskFactor.code == 'payEndYear' && item.isHidden }"
>
<van-field
v-model="riskFactor.showContent"
readonly
:label="riskFactor.name"
right-icon="arrow"
placeholder="请选择"
@click="toSelect(index, riskFactorIndex, riskFactor.columns)"
/>
</div>
<div
class="flex justify-content-s pv10 border-bottom"
v-else-if="riskFactor.type == 0 && item.productCode == 'GFRS_A0011'"
:class="{ hidden: riskFactor.code == 'payEndYear' && item.isHidden }"
>
<van-field
v-if="riskFactor.code != 'payEndYear'"
v-model="riskFactor.showContent"
readonly
:label="riskFactor.name"
right-icon="arrow"
placeholder="请选择"
@click="toSelect(index, riskFactorIndex, riskFactor.columns)"
/>
<van-field v-if="riskFactor.code == 'payEndYear'" v-model="riskFactor.showContent" readonly :label="riskFactor.name" />
</div>
<div class="border-bottom renewalWrappser fs14" v-if="riskFactor.type == 4 && !renewalShow(mainRiskCode)">
<span>{{ riskFactor.name }}</span>
<van-radio-group class="renewal" v-model="renewal" direction="horizontal">
<van-radio class="radio" name="-1"></van-radio>
<van-radio class="radio" name="-2"></van-radio>
</van-radio-group>
</div>
<!-- 桂企产品GFRS_M0024/GFRS_M0040不显示责任保费及万元只显示责任名称及勾选框 -->
<div class="border-bottom" v-if="riskFactor.type == 3">
<div class="pv12 border-bd">{{ riskFactor.name }}</div>
<div class="duty">
<div class="flex justify-content-s border-bd pv10 align-items-c" v-for="(dutyItem, dutyItemIndex) in riskFactor.rules" :key="dutyItemIndex">
<span
v-if="
!(
item.productCode == 'GFRS_M0024' ||
item.productCode == 'GFRS_M0040' ||
item.productCode == 'GFRS_M0044' ||
item.productCode == 'GFRS_M0046' ||
item.productCode == 'GFRS_M0051'
)
"
class="fs14 w100"
>{{ dutyItem.dutyName }}({{ dutyItem.suffix }})</span
>
<span v-else class="fs14 w100">{{ dutyItem.dutyName }}</span>
<div class="flex relative">
<van-stepper
v-if="
!(
item.productCode == 'GFRS_M0024' ||
item.productCode == 'GFRS_M0040' ||
item.productCode == 'GFRS_M0044' ||
item.productCode == 'GFRS_M0046' ||
item.productCode == 'GFRS_M0051'
)
"
v-model="dutyItem.defaultDutyAmt"
:min="dutyItem.minDutyAmt"
:max="dutyItem.maxDutyAmt"
:show-plus="false"
:show-minus="false"
class="ml10 mr10"
@focus="focusStep"
@blur="blurStep(dutyItem, index)"
@change="
dutyStepperChange(
item.calFactorLst[riskFactorIndex].rules[dutyItemIndex].defaultDutyAmt,
index,
riskFactorIndex,
dutyItemIndex,
dutyItem.necess,
dutyItem.minDutyAmt,
dutyItem.maxDutyAmt
)
"
input-width="200"
:integer="false"
/>
<van-checkbox
v-model="dutyItem.necess"
:disabled="dutyItem.defaultValue == '0'"
shape="square"
@change="changeChecked(index, riskFactorIndex, dutyItemIndex, dutyItem)"
></van-checkbox>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 为富娃娃两全保险(万能型)专写 外加鑫享年年-->
<div v-if="item.isRemit == 1 && isTrial != '1' && item.isMainRisk == 0">
<div v-for="(riskFactor, riskFactorIndex) in item.calFactorLst" :key="riskFactorIndex">
<div class="flex justify-content-s pv10 border-bottom" v-if="riskFactor.type == 1">
<div class="flex align-items-c">
<span v-if="item.productTrialYearDTOS[payEndYearColumnsIndex].suffix" class="fs14">
{{ riskFactor.name + '(' + item.productTrialYearDTOS[payEndYearColumnsIndex]['suffix'] + ')' }}
</span>
<span v-else class="fs14">{{ riskFactor.name }} &nbsp;&nbsp; &nbsp;&nbsp;</span>
<van-stepper
v-model="item.productTrialYearDTOS[payEndYearColumnsIndex].displayAmount"
:min="item.productTrialYearDTOS[payEndYearColumnsIndex].minAmt || item.productTrialYearDTOS[payEndYearColumnsIndex].minPrem"
:max="item.productTrialYearDTOS[payEndYearColumnsIndex].maxAmt || item.productTrialYearDTOS[payEndYearColumnsIndex].maxPrem"
:show-plus="false"
:show-minus="false"
class="ml30"
@change="
stepperChange(
item.productTrialYearDTOS[payEndYearColumnsIndex].displayAmount,
index,
riskFactorIndex,
item.productTrialYearDTOS[payEndYearColumnsIndex].minAmt || item.productTrialYearDTOS[payEndYearColumnsIndex].minPrem,
item.productTrialYearDTOS[payEndYearColumnsIndex].maxAmt || item.productTrialYearDTOS[payEndYearColumnsIndex].maxPrem,
item.productTrialYearDTOS[payEndYearColumnsIndex]
)
"
input-width="100"
:integer="false"
/>
</div>
</div>
<div
class="flex justify-content-s pv10 border-bottom"
v-if="riskFactor.type == 0"
:class="{ hidden: riskFactor.code == 'payEndYear' && item.isHidden }"
>
<van-field
v-model="riskFactor.showContent"
readonly
:label="riskFactor.name"
right-icon="arrow"
placeholder="请选择"
@click="toSelect(index, riskFactorIndex, riskFactor.columns)"
/>
</div>
<div class="border-bottom" v-if="riskFactor.type == 3">
<div class="pv12 border-bd">{{ riskFactor.name }}</div>
<div class="duty">
<div class="flex justify-content-s border-bd pv10 align-items-c" v-for="(dutyItem, dutyItemIndex) in riskFactor.rules" :key="dutyItemIndex">
<span class="fs14 w100">{{ dutyItem.dutyName }}({{ dutyItem.suffix }})</span>
<div class="flex relative">
<van-stepper
v-model="dutyItem.defaultDutyAmt"
:min="dutyItem.minDutyAmt"
:max="dutyItem.maxDutyAmt"
:show-plus="false"
:show-minus="false"
class="ml10 mr10"
@focus="focusStep"
@blur="blurStep(dutyItem, index)"
@change="
dutyStepperChange(
item.calFactorLst[riskFactorIndex].rules[dutyItemIndex].defaultDutyAmt,
index,
riskFactorIndex,
dutyItemIndex,
dutyItem.necess,
dutyItem.minDutyAmt,
dutyItem.maxDutyAmt
)
"
input-width="200"
:integer="false"
/>
<van-checkbox
v-model="dutyItem.necess"
:disabled="dutyItem.defaultValue == '0'"
shape="square"
@change="changeChecked(index, riskFactorIndex, dutyItemIndex, dutyItem)"
></van-checkbox>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 豁免险条件 -->
<div v-if="item.isRemit == 0">
<div v-for="(riskFactor, riskFactorIndex) in item.calFactorLst" :key="riskFactorIndex" class="border-bottom">
<div class="flex justify-content-s pv10">
<div class="flex">
<van-field v-if="riskFactor.type == 0" v-model="riskFactor.showContent" readonly :label="riskFactor.name" />
<van-field v-if="riskFactor.type == 1" v-model="riskFactor.defaultValue" readonly :label="riskFactor.name + '(' + riskFactor.suffix + ')'" />
</div>
</div>
<div v-if="riskFactor.type == 3">
<div class="pv12 border-bd">{{ riskFactor.name }}</div>
<div class="duty">
<div class="flex justify-content-s border-bd pv10 align-items-c" v-for="(dutyItem, dutyItemIndex) in riskFactor.rules" :key="dutyItemIndex">
<span class="fs14 w100">{{ dutyItem.dutyName }}({{ dutyItem.suffix }})</span>
<div class="flex relative">
<van-stepper
v-model="dutyItem.defaultDutyAmt"
:min="dutyItem.minDutyAmt"
:max="dutyItem.maxDutyAmt"
:show-plus="false"
:show-minus="false"
class="ml10 mr10"
:disabled="dutyItem.changeWithMainRisk === true ? 'disabled' : ''"
@focus="focusStep"
@blur="blurStep(dutyItem, index)"
@change="
dutyStepperChange(
item.calFactorLst[riskFactorIndex].rules[dutyItemIndex].defaultDutyAmt,
index,
riskFactorIndex,
dutyItemIndex,
dutyItem.necess,
dutyItem.minDutyAmt,
dutyItem.maxDutyAmt
)
"
input-width="200"
:integer="false"
/>
<van-checkbox
v-model="dutyItem.necess"
:disabled="dutyItem.isDisabled || dutyItem.defaultValue == '0'"
shape="square"
@change="changeChecked(index, riskFactorIndex, dutyItemIndex, dutyItem)"
></van-checkbox>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- 只有万能险且只有建议书才展示 -->
<van-field class="pv10" v-if="item.hasPredictTransferPrem === '0'" v-model="item.predictTransferPrem" label="预计转入保费" placeholder="请输入" />
<div class="flex justify-content-s pv10 border-bottom" v-if="item.isMainRisk == 0 && isRelated && isFrom != 'proposal'">
<van-field
v-model="policyNo"
clearable
label="关联保单"
name="关联保单号"
maxlength="380"
type="textarea"
autosize
placeholder="请录入保单号或者投保单号,如果关联多个保单,请用\隔开"
/>
</div>
<div class="flex justify-content-s pv10 border-bottom prem">
<!-- trialType 0-保额算保费1-保费算保额 -->
<!-- isTrial是否需存在特殊配置(规则) 0-是 1-否-->
<span
style="font-weight: bold"
v-if="(trialList.length > 0 && trialList[index].trialType == 0) || (trialList.length > 0 && trialList[index].trialType == 2)"
>
首期保费(元):
</span>
<span style="font-weight: bold" v-else>保额(元):</span>
<span class="fee red" v-if="trialList && trialList.length > 0">{{ trialList[index].showPrem | moneyFormat }}</span>
</div>
</div>
<div class="flex justify-content-fs pv10 ph15 bg-white border-bottom prem align-items-c" v-if="cvalidateFlag && cvalidateStr != '2021-12-31'">
<span>指定保单生效日</span>
<van-radio-group v-model="activeRadio" class="pl20">
<van-radio name="1" icon-size="1rem"></van-radio>
</van-radio-group>
<span class="pl5">{{ cvalidateStr }}</span>
</div>
<div class="bottom-btn bg-white">
<van-button type="danger" size="large" @click="nextStep" :disabled="nextStepFlag" v-no-more-click="1000">完成</van-button>
</div>
<van-action-sheet v-model="show" cancel-text="取消" :actions="policyInfo" @select="openDocument" />
<!-- 字段选择 -->
<van-popup v-model="popupShow" position="bottom"><van-picker show-toolbar :columns="columns" @confirm="onConfirm" @cancel="onCancel" /></van-popup>
</div>
</template>
<script>
import { Tag, Icon, Dialog, ActionSheet, Popup, Picker, Stepper, Field, Checkbox, RadioGroup, Radio } from 'vant'
import { trial } from '@/api/ebiz/common/common'
import { saveOrUpdateOrderInfo, getOrderDetail } from '@/api/ebiz/sale/sale'
import { saveProposal } from '@/api/ebiz/proposal/proposal.js'
//险种GFRS_M0016的责任的验证规则
//默认 最低基本保险金额min 10000 整数倍要求mutiple 1000
const dutyRules = {
410800: {
min: 50000,
msg: '意外基本保险金额最低为50000元超过最低基本保险金额为1000元整数倍'
},
410805: {
msg: '轨道列车意外基本保险金额最低为10000元超过最低基本保险金额为1000元整数倍并且小于等于意外基本保险金额的5倍'
},
410801: {
msg: '客运汽车意外基本保险金额最低为10000元超过最低基本保险金额为1000元整数倍并且小于等于意外基本保险金额的5倍'
},
410802: {
msg: '客运轮船意外基本保险金额最低为10000元超过最低基本保险金额为1000元整数倍并且小于等于意外基本保险金额的5倍'
},
410803: {
msg: '客运民航班机意外基本保险金额最低为10000元超过最低基本保险金额为1000元整数倍并且小于等于意外基本保险金额的10倍'
},
410804: {
msg: '自驾车意外基本保险金额最低为10000元超过最低基本保险金额为1000元整数倍并且小于等于意外基本保险金额的5倍'
},
410806: {
min: 2000,
msg: '意外伤害医疗基本保险金额最低为2000元超过最低基本保险金额为1000元整数倍并且小于等于意外基本保险金额的1/5倍'
},
410807: {
min: 10,
mutiple: 10,
msg: '意外住院津贴日额最低基本保险金额为10元/天超过最低基本保险金额为10元/天整数倍最高不得超过200元/天'
}
}
const dutyGFRS_A0004Rules = {
320205: {
mainRisk: 'GFRS_M0005',
msg: '住院医疗提示金额只能是0.5、1、1.5、2',
msg_1: '附加到国富人寿国富民惠医疗保险2020版最高基本保额不超过1万元。',
msg_2: '住院医疗提示金额只能是0.5、1'
},
320206: {
msg: '住院津贴提示:投保可选责任时,可选责任最低投保 50 元,且应为 10 元的整数倍'
},
320207: {
msg: '恶性肿瘤提示:投保可选责任时,可选责任最低投保 50 元,且应为 10 元的整数倍'
}
}
const dutyGFRS_A0008Rules = {
320404: {
mainRisk: 'GFRS_M0005',
otmainRisk: 'GFRS_M0031',
mainRisk2: 'GFRS_M0042',
otmainRisk2: 'GFRS_M0043',
msg: '住院医疗提示金额只能是0.5、1、1.5、2',
msg_1: '附加到国富人寿国富民惠医疗保险2020版最高基本保额不超过1万元。',
msg_2: '住院医疗提示金额只能是0.5、1'
},
320405: {
msg: '住院津贴提示:投保可选责任时,可选责任最低投保 50 元,且应为 10 元的整数倍'
},
320406: {
msg: '恶性肿瘤提示:投保可选责任时,可选责任最低投保 50 元,且应为 10 元的整数倍'
}
}
const DUTY_DEFAULT_MUTIPLE = 1000
const DUTY_DEFAULT_MIN = 10000
export default {
name: 'calculatePremium',
components: {
[Tag.name]: Tag,
[Icon.name]: Icon,
[ActionSheet.name]: ActionSheet,
[Popup.name]: Popup,
[Picker.name]: Picker,
[Stepper.name]: Stepper,
[Field.name]: Field,
[Checkbox.name]: Checkbox,
[Dialog.name]: Dialog,
[Radio.name]: Radio,
[RadioGroup.name]: RadioGroup
},
data() {
return {
isEnterAddtionRisk: true, //附加险list
activeRadio: '1',
// activeType: localStorage.getItem('active_type'), 现在从订单详情接口取值了
activeType: '',
cvalidateFlag: false,
cvalidateStr: '', //活动生效日
chooseProducts: [],
productIndex: '',
calFactorIndex: '',
premiumData: [], //试算
saleInsuredInfo: {},
saleInsuredPersonInfo: {}, //投保人信息
trialList: [],
popupShow: false,
columns: [],
pickerType: '',
show: false,
policyInfo: [],
currentIndex: '', //当前操作产品
trialInfos: [],
influenceAddRiskCodes: [],
influences: [],
nextStepFlag: false,
isRelated: localStorage.isRelated === '0', //关联保单号
policyNo: '',
// 份数
mult: '',
isFrom: '',
// 默认钱数
defalutAmt: '',
//是否需存在特殊配置 0-是 1-否
isTrial: localStorage.isTrial,
//缴费期间对应index索引
payEndYearColumnsIndex: 0,
// 后台配置的校验规则
ruleExpression: {},
mainRiskCode: '',
renewal: '-1',
richChildrenFlag: false,
isCrossChannel: '0' //是否交叉渠道 1-是 0-否
}
},
mounted() {
this.init()
Array.prototype.min = function () {
var min = this[0]
var len = this.length
for (var i = 1; i < len; i++) {
if (this[i] < min) {
min = this[i]
}
}
return min
}
},
methods: {
renewalShow(productCode) {
let codes = ['GFRS_M0016', 'GFRS_M0005', 'GFRS_M0018']
return codes.find((item) => {
return productCode === item
})
},
//初始化数据
async init() {
// 获取是否从建议书过来的
let that = this
this.isFrom = window.localStorage.isFrom
//获取投保人信息
if (this.$CacheUtils.getLocItem('saleInsuredInfo')) {
this.saleInsuredInfo = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredInfo'))
}
//获取被保险人信息
if (this.$CacheUtils.getLocItem('saleInsuredPersonInfo')) {
this.saleInsuredPersonInfo = JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo'))
}
// this.cvalidateFlag = (this.activeType == 'KMH'||this.activeType == 'SQY') && this.isFrom != 'proposal'
// this.cvalidateStr = this.cvalidateFlag?this.activeType == 'KMH'?'2021-01-01':this.activeType == 'SQY'?'2021-06-01':'':''
//GFRS-2552【需求】关于金掌桂投保流程增设指定生效日按钮的申请
const orderNo = this.$CacheUtils.getLocItem('orderNo')
let detailPromise = this.isFrom === 'proposal' ? localStorage.proposalMedical : await getOrderDetail({ orderNo })
if (this.isFrom != 'proposal') {
//活动生效日期
this.cvalidateStr = detailPromise.orderDTO.orderInfoDTO.cvaliDate
this.activeType = detailPromise.orderDTO.orderInfoDTO.activeType
}
this.cvalidateFlag = this.activeType && this.isFrom != 'proposal'
//构建提交数据、渲染险种
this.chooseProducts = JSON.parse(localStorage.chooseProducts)
this.chooseProducts.forEach((item, index) => {
if (item.isCrossChannel == '1') {
this.isCrossChannel = item.isCrossChannel
}
if (item.mainRiskCode == 'GFRS_M0006') {
item.isHidden = true
}
if (item.mainRiskCode != 'GFRS_M0008') {
item.calFactorLst.map((i) => {
// this.defalutAmt = i.displayAmount || 1
if (i.code == 'inputPrem') {
this.mult = Math.ceil(Number(i.displayAmount) / Number(i.defaultValue))
}
})
}
if (item.mainRiskCode == 'GFRS_M0046') {
if (this.saleInsuredPersonInfo.relationToAppnt == 1) {
this.isEnterAddtionRiskListFunc()
}
}
let payEndYearVal
//初始化时交费期间为一次性交清时,在就是中介渠道, 附加险GFRS_A0007GFRS_A0009GFRS_A0010去掉后附加险list就为空--隐藏icon
item.calFactorLst.map((i) => {
if (i.code == 'payEndYear') {
if (i.payEndYear == '1000' && i.payEndYearFlag == 'Y') {
this.isEnterAddtionRiskListFunc()
}
//初始化时取交费期间的值
payEndYearVal = i.showContent
}
})
if (index == 0) {
if (item.productTrialYearDTOS) {
//初始化时取交费期间的值值再去对应productTrialYearDTOS中的第几条规则
item.productTrialYearDTOS.forEach((item, index) => {
if (payEndYearVal == item.yearWay + '年交') {
that.payEndYearColumnsIndex = index
}
})
}
}
// if (item.productCode == 'GFRS_A0003') {
// //该附加险的责任保额=主险的保费
// item.calFactorLst.map(v => {
// if (v.code == 'dutyGroup' && v.rules.length > 0) {
// v.rules.map(y => {
// if (y.defaultDutyAmt === null) {
// y.defaultDutyAmt = (JSON.parse(localStorage.trialList)[0].prem / 10000).toFixed(6)
// }
// y.moneyUnit = 10000
// y.changeWithMainRisk = true //责任险保额=主险保费,不允许用户手动更改
// })
// }
// })
// }
//保存主险险种编号
if (item.isMainRisk == 0) {
this.mainRiskCode = item.mainRiskCode
}
})
if (this.mainRiskCode == 'GFRS_M0005') {
this.chooseProducts.map((item) => {
if (item.productCode == 'GFRS_A0004') {
item.calFactorLst.map((item2) => {
if (item2.code == 'dutyGroup') {
item2.rules.map((item3) => {
if (item3.duty == '320205') {
item3.maxDutyAmt = '1'
}
})
}
})
}
})
}
if (this.mainRiskCode == 'GFRS_M0031' || this.mainRiskCode == 'GFRS_M0005' || this.mainRiskCode == 'GFRS_M0042' || this.mainRiskCode == 'GFRS_M0043') {
this.chooseProducts.map((item) => {
if (item.productCode == 'GFRS_A0008') {
item.calFactorLst.map((item2) => {
if (item2.code == 'dutyGroup') {
item2.rules.map((item3) => {
if (item3.duty == '320404') {
item3.maxDutyAmt = '1'
}
})
}
})
}
})
}
//GFRS_M0016需要展示免赔额和赔付比例并需要根据是否有社保调整数值
// let mainRiskCode = chooseProducts[0].mainRiskCode
// eslint-disable-next-line no-unused-vars
this.dogetLimitAndGetRate().then((res) => {
if (this.chooseProducts[0].influences && this.chooseProducts[0].influences.length > 0) {
this.influences = this.chooseProducts[0].influences
this.chooseProducts[0].influences.forEach((item) => {
this.influenceAddRiskCodes.push(item.productCode)
})
}
this.mainRiskInfluenceAddRisk()
//初始化数据试算
this.getTrial()
})
console.log(this.trialList, '')
// 判断是否 含有 后台配置js验证函数
if (localStorage.ruleExpression) {
let ruleExpression = JSON.parse(localStorage.ruleExpression)
this.ruleExpression = ruleExpression
let productCodes = Object.keys(ruleExpression)
productCodes.forEach((itemKey) => {
let rules = ruleExpression[itemKey]
rules.eventList = []
rules.forEach((item) => {
let config = ''
config = JSON.parse(item.ruleExpression)
// let errorMsg = item.errorMsg;
// config = {
// eventName: 'GFRS_M0020_payEndYear_insuYear',
// eventType: 'onConfirm',
// funBody: [
// 'let ageMap = {',
// ' "10Y":{"30Y": 55,"70A": 55,"88A": 55},',
// ' "20Y":{ "30Y": 55, "70A": 50, "88A": 55 }, ',
// ' "30Y":{ "30Y": 45, "70A": 40, "88A": 45 },',
// '};',
// 'let payEndYear = "";',
// 'let insuYear = "";',
// 'let age = this.saleInsuredPersonInfo.age;',
// 'let parObj = {};',
// 'par.map(item => {',
// ' parObj[item.code] = item;',
// '});',
// 'if(ParKey == "payEndYear"){',
// ' payEndYear = Par.value + Par.flag;',
// ' lintAgeObj = ageMap[payEndYear];',
// ' let flag = true, num = parObj.insuYear.columns.length;',
// ' parObj.insuYear.columns.forEach(item => {',
// ' let lintAge = lintAgeObj[ item.value + item.flag ];',
// ' if( age > lintAge ){',
// ' item.disabled = true;',
// ' num = num - 1 ;',
// ' }else{',
// ' if(flag){',
// ' parObj.insuYear.insuYear = item.value;',
// ' parObj.insuYear.insuYearFlag = item.flag;',
// ' parObj.insuYear.showContent = item.text;',
// ' flag = false;',
// ' };',
// ' item.disabled = false;',
// ' };',
// ' });',
// ' if(!num){',
// ' this.errorMsg.push("被保险人年龄不符合当前所选交费期间");',
// ' payEndYear = parObj.payEndYear.payEndYear + parObj.payEndYear.payEndYearFlag;',
// ' lintAgeObj = ageMap[payEndYear];',
// ' parObj.insuYear.columns.forEach(item => {',
// ' let lintAge = lintAgeObj[ item.value + item.flag ];',
// ' if( age > lintAge ){',
// ' item.disabled = true;',
// ' }else{',
// ' item.disabled = false;',
// ' };',
// ' });',
// ' return false;',
// ' };',
// ' return true;',
// '}'],
// funPar: ['par','ParKey','Par'],
// }
// config = {
// eventName: 'GFRS_A0003_noMainCode',
// eventType: 'init',
// initBody: [
// 'for(let item of that.chooseProducts){',
// ' if(item.productCode == "GFRS_A0003"){',
// ' for(let itemC of item.calFactorLst){',
// ' if(itemC.code == "dutyGroup"){',
// ' for(let itemR of itemC.rules){',
// ' that.$emit("GFRS_A0003_noMainCode", itemR, that.mainRiskCode)',
// ' }',
// ' }',
// ' }',
// ' }',
// ' }',
// ],
// funBody: [
// 'let noMainCode = {',
// ' "GFRS_M0004" : true,',
// ' "GFRS_M0011" : true',
// '};',
// 'let noduty = {',
// ' "310101" : true',
// '};',
// 'if(noMainCode[mainRiskCode] && noduty[dutyItem.duty]){',
// ' dutyItem.necess = false;',
// ' dutyItem.isDisabled = true;',
// '}',
// ],
// funPar:['dutyItem', 'mainRiskCode'],
// }
this.$on(config.eventName, new Function(...config.funPar, config.funBody.join('')))
if (config.eventType == 'init') {
let initFn = new Function('that', config.initBody.join(''))
initFn(this)
}
if (config.otherRisk) {
for (let item of config.otherRisk) {
if (!ruleExpression[item] || !ruleExpression[item].eventList) {
ruleExpression[item] = {
eventList: [config.eventName]
}
} else {
ruleExpression[item].eventList.push(config.eventName)
}
}
}
rules.eventList.push(config.eventName)
})
})
}
},
//特殊处理 GFRS_M0016 GFRS_A0004 GFRS_A0005 赔付比例处理
async dogetLimitAndGetRate() {
const orderNo = this.$CacheUtils.getLocItem('orderNo')
let detailPromise = this.isFrom === 'proposal' ? localStorage.proposalMedical : await getOrderDetail({ orderNo })
this.chooseProducts.map((item) => {
if (
!(item.mainRiskCode === 'GFRS_M0016' || item.productCode === 'GFRS_A0004' || item.productCode === 'GFRS_A0008' || item.productCode === 'GFRS_A0005')
) {
//其他产品删掉两个字段
let calFactorLst = item.calFactorLst
for (let i = calFactorLst.length - 1; i >= 0; i--) {
let item = calFactorLst[i]
if (item.code === 'getLimit' || item.code === 'getRate') {
calFactorLst.splice(i, 1)
}
}
return
}
if (item.mainRiskCode === 'GFRS_M0016' || item.productCode === 'GFRS_A0004' || item.productCode === 'GFRS_A0008' || item.productCode === 'GFRS_A0005') {
let isMedical = null
if (this.isFrom === 'proposal') {
isMedical = detailPromise == '1'
} else {
isMedical = detailPromise.orderDTO.insuredDTOs[0].medical == '0'
}
// 赔付比例和免赔额
item.calFactorLst.map((i) => {
if (i.code === 'getLimit') {
let tempColumns = i.columns.filter((itemC) => {
return itemC.medical == Math.abs(isMedical - 1).toString()
})
if (tempColumns.length !== 0) {
i.columns = tempColumns
}
i.getLimit = i.columns[0].value
i.showContent = i.columns[0].text
}
//赔付比例
if (i.code === 'getRate') {
let tempColumns = i.columns.filter((itemC) => {
return itemC.medical == Math.abs(isMedical - 1).toString()
})
if (tempColumns.length !== 0) {
i.columns = tempColumns
}
i.getRate = i.columns[0].value
i.showContent = i.columns[0].text
}
})
this.$forceUpdate()
} else if (item.productCode === 'GFRS_A0005') {
// GFRS_A0005 未处理
}
})
},
// 责任保额份数变化
dutyStepperChange(value, productIndex, calFactorIndex, dutyItemIndex, isChecked, min, max) {
//这个险种使用其他验证方式
if (this.chooseProducts[productIndex].productCode === 'GFRS_M0016') return
// 004险种其他验证方式
if (this.chooseProducts[productIndex].productCode === 'GFRS_A0004') return
// 008险种其他验证方式
if (this.chooseProducts[productIndex].productCode === 'GFRS_A0008') return
if (
this.chooseProducts[productIndex].productCode === 'GFRS_A0003' ||
this.chooseProducts[productIndex].productCode === 'GFRS_A0009' ||
this.chooseProducts[productIndex].productCode === 'GFRS_A0010'
) {
setTimeout(() => {
this.getTrial()
}, 500);
return
}
let currentEle = this.chooseProducts[productIndex].calFactorLst[calFactorIndex].rules[dutyItemIndex]
let showHint = this.chooseProducts[productIndex].hint
if (value < min || value > max) {
this.$toast(showHint)
} else {
if ((Number(value) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
Dialog.alert({
message: showHint
}).then(() => {
currentEle.defaultDutyAmt = currentEle.minDutyAmt
})
// this.$toast(showHint)
} else {
// this.mainRiskInfluenceAddRisk()
// currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
// this.getTrial()
if (isChecked) {
;[this.productIndex, this.calFactorIndex] = [productIndex, calFactorIndex]
let currentEle = this.chooseProducts[productIndex].calFactorLst[calFactorIndex].rules
currentEle.forEach((item) => {
item.amt = Number(item.minDutyAmt) * Number(item.moneyUnit)
})
this.mainRiskInfluenceAddRisk()
this.getTrial()
} else {
;[this.productIndex, this.calFactorIndex] = [productIndex, calFactorIndex]
let currentEle = this.chooseProducts[productIndex].calFactorLst[calFactorIndex].rules
currentEle.forEach((item) => {
item.amt = Number(item.minDutyAmt) * Number(item.moneyUnit)
})
}
}
}
},
//弹框选择
toSelect(index, index1, columns) {
this.columns = []
;[this.popupShow, this.productIndex, this.calFactorIndex] = [true, index, index1]
let currentFactor = this.chooseProducts[this.productIndex].calFactorLst
let currentEle = currentFactor[this.calFactorIndex]
let sex = this.saleInsuredPersonInfo.sex //0男 1女
//性别男女,养老保险金领取年龄不一致
if (currentEle.code == 'pensionAge') {
columns.forEach((item) => {
if(item.sex == sex){
this.columns.push(item)
}
})
}else{
this.columns = columns
}
},
//取消picker
onCancel() {
this.columns = []
this.popupShow = false
},
//确认选择字段
onConfirm(value) {
this.columns = []
this.popupShow = false
// let productCode = this.chooseProducts[this.productIndex].productCode
let currentFactor = this.chooseProducts[this.productIndex].calFactorLst
let currentEle = currentFactor[this.calFactorIndex]
// let sex = this.saleInsuredPersonInfo.sex //0男 1女
//特殊设置:如果需要填写的保费/保额校验规则跟缴费期间挂钩当改变缴费期间时将输入框的值恢复默认值1
if (currentEle.code == 'payEndYear' && this.isTrial == '0') {
currentEle['columns'].forEach((item, index) => {
if (item.value == value.value) {
this.payEndYearColumnsIndex = index
}
})
this.defalutAmt = 1
}
//中介渠道交费期间为一次性交清时附加险GFRS_A0007GFRS_A0009GFRS_A0010去掉后附加险list就为空--隐藏icon
if (currentEle.code == 'payEndYear' && value.value == '1000') {
this.isEnterAddtionRiskListFunc()
//交费期间为一次性交清时清空豁免险GFRS_A0007GFRS_A0009GFRS_A0010并更新localStorage
this.isClearAddtionRiskListFunc()
} else if (this.chooseProducts[this.productIndex].mainRiskCode == 'GFRS_M0046') {
if (this.saleInsuredPersonInfo.relationToAppnt == 1) {
this.isEnterAddtionRiskListFunc()
}
} else {
this.isEnterAddtionRisk = true
}
if (currentEle.showContent != value.text) {
//通用规则校验
if (this.payExceedInsured(currentEle, currentFactor, value.value)) {
this.popupShow = false
return false
}
if (currentEle.code == 'payEndYear' && this.ageInfluencePayEndYear(value.value, currentEle)) {
this.popupShow = false
return false
}
if (currentEle.code == 'insuYear' && this.ageInfluenceInsuYear(value.value, currentEle)) {
this.popupShow = false
return false
}
// if(this.ruleExpression[productCode]){
// this.errorMsg = []
// this.ruleExpression[productCode].eventList.forEach(item => {
// this.$emit(item,currentFactor,currentEle.code,value);
// })
// if(this.errorMsg.length > 0){
// this.$toast(this.errorMsg[0]);
// this.popupShow = false
// return false
// }
// }
let productCode = this.chooseProducts[this.productIndex].productCode
if (this.ruleExpression[productCode]) {
this.errorMsg = []
let currentFactor = this.chooseProducts[this.productIndex].calFactorLst
let currentEle = currentFactor[this.calFactorIndex]
this.ruleExpression[productCode].eventList.forEach((item) => {
this.$emit(item, currentFactor, currentEle.code, value)
})
if (this.errorMsg.length > 0) {
this.$toast(this.errorMsg[0])
this.errorMsg = []
this.popupShow = false
return false
}
}
// 后台配置 的 js函数 验证
// if(hasR){
// if(currentEle.code == 'payEndYear' || currentEle.code == 'insuYear'){
// this.payEndYear(currentEle.code,value.value,this.tmpInsuYear.insuYear + this.tmpInsuYear.insuYearFlag)
// }
// }
currentEle.showContent = value.text
let name = currentEle.code
currentEle[name] = value.value
if (currentEle.hasFlag) {
currentEle[name + 'Flag'] = value.flag
}
// this.hiddenPayEndYear(currentEle)
//特殊规则:设置豁免险
this.getTrial()
}
},
//交费期间为一次性交清时清空豁免险GFRS_A0007GFRS_A0009GFRS_A0010并更新localStorage
isClearAddtionRiskListFunc() {
let chooseProductsNew = []
this.chooseProducts.forEach((item01) => {
if (item01.productCode != 'GFRS_A0007' && item01.productCode != 'GFRS_A0009'&& item01.productCode != 'GFRS_A0010') {
chooseProductsNew.push(item01)
}
})
if (chooseProductsNew.length != this.chooseProducts.length) {
this.chooseProducts = chooseProductsNew
}
localStorage.chooseProducts = JSON.stringify(chooseProductsNew)
},
// 交通责任险复选框变化
changeChecked(productIndex, calFactorIndex, dutyItemIndex, dutyItem) {
let isChecked = this.chooseProducts[productIndex].calFactorLst[calFactorIndex].rules.some((item) => {
return item.necess == true
})
if (!isChecked) {
this.chooseProducts[productIndex].calFactorLst[calFactorIndex].rules[dutyItemIndex]['necess'] =
!this.chooseProducts[productIndex].calFactorLst[calFactorIndex].rules[dutyItemIndex]['necess']
return false
}
this.valiAndSend(dutyItem, productIndex)
},
valiAndSend(dutyItem, productIndex) {
//验证责任
let validateRiskCode = this.chooseProducts[productIndex].productCode
let showHint = this.chooseProducts[productIndex].hint
let inputValue = dutyItem.defaultDutyAmt,
duty = dutyItem.duty
if (validateRiskCode === 'GFRS_M0016' && !this.valiDuty(inputValue, duty)) {
//验证不通过
return
} else if (validateRiskCode === 'GFRS_A0004' && !this.valiA0004Duty(inputValue, showHint, dutyItem)) {
//验证不通过 险种为GFRS_A0004 责任编码为320205
return
} else if (validateRiskCode === 'GFRS_A0008' && !this.valiA0008Duty(inputValue, showHint, dutyItem)) {
//验证不通过 险种为GFRS_A0008 责任编码为320404
return
} else {
this.mainRiskInfluenceAddRisk()
this.getTrial()
}
},
// 计步器聚焦
focusStep() {
this.nextStepFlag = true
},
blurStep(dutyItem, productIndex) {
this.nextStepFlag = false
//失去焦点时做验证
if (dutyItem.necess) {
//勾选时才做验证
this.valiAndSend(dutyItem, productIndex)
}
},
//险种GFRS_M0016的责任的验证规则
valiDuty(value, duty) {
if (this.mainRiskCode === 'GFRS_M0016') {
value *= 10000
const rule = dutyRules[duty]
const mutiple = rule.mutiple || DUTY_DEFAULT_MUTIPLE
const min = rule.min || DUTY_DEFAULT_MIN
if (!value || value < min || value % mutiple !== 0) {
this.$toast(rule.msg)
this.nextStepFlag = true
return false
} else {
this.nextStepFlag = false
return true
}
}
},
//险种 GFRS_A0004 险种验证规则
valiA0004Duty(value, showHint, currentEle) {
/* if (!(currentEle.necess == true)) {
this.nextStepFlag = false
return true
}*/
// 验证其他 最小50 其他为50 10 倍数
if (currentEle.duty == '320206' || currentEle.duty == '320207') {
let numberValue = Number(value) * 10000
if (numberValue % 10 != 0 || numberValue < 50) {
this.$toast(dutyGFRS_A0004Rules[currentEle.duty].msg)
this.nextStepFlag = true
return false
}
}
// 保额只能为5000 10000 15000 200000
if (currentEle.duty == '320205') {
if (this.mainRiskCode === dutyGFRS_A0004Rules[currentEle.duty]['mainRisk']) {
if (!(value == '0.5' || value == '1')) {
this.$toast(dutyGFRS_A0004Rules[currentEle.duty].msg_2)
this.nextStepFlag = true
return false
} else if (value - 0 > 1) {
this.$toast(dutyGFRS_A0004Rules[currentEle.duty].msg_1)
this.nextStepFlag = true
return false
}
} else {
if (!(value == '0.5' || value == '1' || value == '1.5' || value == '2')) {
this.$toast(dutyGFRS_A0004Rules[currentEle.duty].msg)
this.nextStepFlag = true
return false
}
}
this.nextStepFlag = false
return true
}
this.nextStepFlag = false
return true
},
//险种 GFRS_A0008 险种验证规则
valiA0008Duty(value, showHint, currentEle) {
/* if (!(currentEle.necess == true)) {
this.nextStepFlag = false
return true
}*/
// 验证其他 最小50 其他为50 10 倍数
if (currentEle.duty == '320405' || currentEle.duty == '320406') {
let numberValue = Number(value) * 10000
if (numberValue % 10 != 0 || numberValue < 50) {
this.$toast(dutyGFRS_A0008Rules[currentEle.duty].msg)
this.nextStepFlag = true
return false
}
}
// 保额只能为5000 10000 15000 200000
if (currentEle.duty == '320404') {
if (
this.mainRiskCode === dutyGFRS_A0008Rules[currentEle.duty]['mainRisk'] ||
this.mainRiskCode === dutyGFRS_A0008Rules[currentEle.duty]['otmainRisk'] ||
this.mainRiskCode === dutyGFRS_A0008Rules[currentEle.duty]['mainRisk2'] ||
this.mainRiskCode === dutyGFRS_A0008Rules[currentEle.duty]['otmainRisk2']
) {
if (!(value == '0.5' || value == '1')) {
this.$toast(dutyGFRS_A0008Rules[currentEle.duty].msg_2)
this.nextStepFlag = true
return false
} else if (value - 0 > 1) {
this.$toast(dutyGFRS_A0008Rules[currentEle.duty].msg_1)
this.nextStepFlag = true
return false
}
} else {
if (!(value == '0.5' || value == '1' || value == '1.5' || value == '2')) {
this.$toast(dutyGFRS_A0008Rules[currentEle.duty].msg)
this.nextStepFlag = true
return false
}
}
this.nextStepFlag = false
return true
}
this.nextStepFlag = false
return true
},
/********start 通用规则、特殊规则处理 start******/
//通用规则1交费方式为一次交情无交费期限
// hiddenPayEndYear(currentEle) {
// if (currentEle.code == 'payIntv') {
// if (this.chooseProducts[0].productCode === 'GFRS_M0015' && this.chooseProducts[this.productIndex].productCode === 'GFRS_A0006') {
// return
// }
// this.chooseProducts[this.productIndex]['isHidden'] = currentEle.payIntv == '0' ? true : false
// }
// },
//通用规则2交费期限不能超过保险期间
payExceedInsured(currentEle, currentFactor, currentVale) {
let payEndYearVal, insuYearVal
if (currentEle.code == 'payEndYear') {
payEndYearVal = Number(currentVale)
insuYearVal = this.getPayEndYearOrInsuYear('insuYear', currentFactor)
}
if (currentEle.code == 'insuYear') {
insuYearVal = Number(currentVale)
payEndYearVal = this.getPayEndYearOrInsuYear('payEndYear', currentFactor)
}
//交费期限为一次性交清时val为1000直接跳过此规则
if (payEndYearVal != 1000) {
if (payEndYearVal > insuYearVal) {
this.$toast('交费期间不能超过保险期间')
return true
} else {
return false
}
} else {
return false
}
},
//中介渠道交费期间为一次性交清时附加险GFRS_A0007GFRS_A0009GFRS_A0010去掉后附加险list就为空--隐藏icon
isEnterAddtionRiskListFunc() {
let addtionRiskLst = JSON.parse(localStorage.addtionRiskLst)
if (addtionRiskLst) {
let list = []
addtionRiskLst.forEach((item, index) => {
if (item.productCode != 'GFRS_A0007' && item.productCode != 'GFRS_A0009' && item.productCode != 'GFRS_A0010') {
list.push(item)
}
})
if (list.length) {
this.isEnterAddtionRisk = true
} else {
this.isEnterAddtionRisk = false
}
}
},
getPayEndYearOrInsuYear(flag, currentFactor) {
let returnVal
currentFactor.forEach((item) => {
if (item.code == flag) {
returnVal = item[flag]
}
})
return Number(returnVal)
},
//特殊规则1、交费期间跟年龄的关系
ageInfluencePayEndYear(value, currentEle) {
let age = Number(this.saleInsuredPersonInfo.age)
for (let i = 0; i < currentEle.rules.length; i++) {
if (currentEle.rules[i].payEndYear == value && age > currentEle.rules[i].maxAge) {
this.$toast('被保险人年龄不适合该交费期间!')
return true
}
if (
currentEle.rules[i].payEndYear == value &&
currentEle.rules[i].payEndYearFlag == 'A' &&
(age < currentEle.rules[i].minAge || age > currentEle.rules[i].maxAge)
) {
this.$toast('被保险人年龄不适合该交费期间!')
return true
}
}
return false
},
//年龄对保险期间的影响
ageInfluenceInsuYear(value, currentEle) {
let age = Number(this.saleInsuredPersonInfo.age)
for (let i = 0; i < currentEle.rules.length; i++) {
if (currentEle.rules[i].insuYear == value && age > currentEle.rules[i].maxAge) {
this.$toast('被保险人年龄不适合该保险期间!')
return true
}
}
return false
},
//特殊规则2、主险对附加险的影响,主要是保额之间的影响 mainAddRelation0-小于1-大于2-等于3-小于等于,4-大于等于
mainRiskInfluenceAddRisk() {
if (this.productIndex == 0) {
this.chooseProducts.forEach((item, index) => {
if (this.influenceAddRiskCodes.includes(item.productCode)) {
let influences = this.getInfluencesItem(item.productCode)
let mainAddRelation = influences.amtInfluence[0].mainAddRelation
let amtTimes = influences.amtInfluence[0].amtTimes
let mainRiskAmt = this.getMainRiskAmt()
if (mainAddRelation == 3 && (amtTimes == 1 || amtTimes == 5)) {
this.setInputAddtionRiskMaxAmt(mainRiskAmt * amtTimes, index)
} else if (mainAddRelation == 3 && amtTimes == 0.2) {
this.setAddtionRiskMaxAmt(mainRiskAmt * amtTimes, index)
}
}
})
}
},
setAddtionRiskMaxAmt(mainRiskAmt, index) {
this.chooseProducts[index].calFactorLst.forEach((item) => {
if (item.code == 'amt' || item.code == 'planCode') {
let columnsValArr = []
item.columns.forEach((option) => {
columnsValArr.push(Number(option.amt))
if (Number(option.amt) > mainRiskAmt * 10000) {
option.disabled = true
} else {
option.disabled = false
}
})
//主险减,附加险变化,取最小
let currentAmt = this.getAmtByPlanCode(item.columns, item.planCode)
if (mainRiskAmt * 10000 < currentAmt) {
let minVal = columnsValArr.min()
item.columns.forEach((option) => {
if (option.amt == minVal) {
item.showContent = option.text
item.planCode = option.value
item.amt = option.amt
}
})
}
}
})
},
getAmtByPlanCode(columns, planCode) {
let amt = ''
columns.forEach((item) => {
if (item.value == planCode) {
amt = item.amt
}
})
return amt
},
setInputAddtionRiskMaxAmt(mainRiskAmt, index) {
this.chooseProducts[index].calFactorLst.forEach((item) => {
if (item.type == 1) {
item.maxAmt = Math.min(mainRiskAmt, item.oldMaxAmt)
//减保额份数
if (item.maxAmt < item.defaultValue) {
item.defaultValue = item.maxAmt
}
}
})
},
getMainRiskAmt() {
let mainRiskAmt
this.chooseProducts[0].calFactorLst.forEach((item) => {
if (item.type == 1) {
mainRiskAmt = item.defaultValue
}
})
return mainRiskAmt
},
getInfluencesItem(productCode) {
let currentInfluences
this.chooseProducts[0].influences.forEach((item) => {
if (item.productCode == productCode) {
currentInfluences = item
}
})
return currentInfluences
},
trialBeforeRule() {
let that = this
console.log('走试算前规则')
// 针对于国富人寿附加两全保险附加险(GFRS_A0011),缴费期间期间要等于主险的缴费期间
let mainRiskInfo = this.getMainRiskInfo()
this.chooseProducts.forEach((item) => {
if (item.productCode == 'GFRS_A0011') {
item.calFactorLst.map((item2) => {
if (item2.code == 'payEndYear') {
item2.hasFlag = '1'
item2.payEndYearFlag = 'Y'
item2.payEndYear = Number(mainRiskInfo.payEndYear.payEndYear)
item2.showContent = item2.payEndYear + '年交'
}else if (item2.code == 'amt') {
// GFRS_A0011-附加两全 属于非豁免险 但附加两全保额=主险年交保费+其他不带豁免责任的长期期交附加险年交保费
let trialList = JSON.parse(localStorage.trialList)
item2.amt = trialList[0].prem
item2.defaultValue = trialList[0].prem
item2.moneyUnit = 1
item2.suffix = '元'
}
})
}
})
if(this.chooseProducts[0].productCode == 'GFRS_M0035' || this.chooseProducts[0].productCode == 'GFRS_M0044' || this.chooseProducts[0].productCode == 'GFRS_M0040'){
if (this.trialList.length) {
let showPrem //计算后的保费
//(被保险人)国富人寿附加豁免保险费重大疾病保险(B款GFRS_A0010
//(投保人)国富人寿附加豁免保险费重大疾病保险(B款 GFRS_A0009
//国富人寿附加两全保险条款 GFRS_A0011
//只有在搭配附加两全时才能搭配被保险人附加豁免重疾B;
//获取两全险的保费
let showPrem001
this.trialList.forEach((item, index) => {
if (item.productCode == 'GFRS_A0011') {
showPrem001 = item.showPrem //获取两全险的保费
}
})
this.chooseProducts.forEach((item, index) => {
if (item.productCode == 'GFRS_A0010' || item.productCode == 'GFRS_A0009') {
//(投保人)国富人寿附加豁免保险费重大疾病保险(B款
// 投被不同人:投保人豁免险单独搭配主险时,投保人豁免险,豁免主险保费,当投保人豁免险加两全(有长险附加险时),豁免主险保费加两全保费
if (item.productCode == 'GFRS_A0009') {
if (this.saleInsuredPersonInfo.relationToAppnt != 1) {
//不同人
if (showPrem001) {
//加两全时
showPrem = Number(showPrem001) + Number(that.trialList[0].showPrem)
} else {
showPrem = Number(that.trialList[0].showPrem)
}
}
item.calFactorLst.map((item2) => {
if (item2.code == 'dutyGroup') {
item2.rules.map((item3) => {
item3.defaultDutyAmt = (showPrem / 10000).toFixed(6)
})
}
})
} else if (item.productCode == 'GFRS_A0010') {
//(被保险人)国富人寿附加豁免保险费重大疾病保险(B款GFRS_A0010
//投被同人,不同人:被保人豁免险搭配两全(有长险附加险时)时,可选责任为必选,豁免两全保费
if (showPrem001) {
showPrem = Number(showPrem001)
}else{
showPrem = Number(that.trialList[0].showPrem)
}
item.calFactorLst.map((item2) => {
if (item2.code == 'dutyGroup') {
item2.rules.map((item3) => {
item3.defaultDutyAmt = (showPrem / 10000).toFixed(6)
item3.defaultValue = '0'
item3.necess = true
})
}
})
}
}
})
}
}
},
//特殊规则3、设置豁免险
setRemitRisk() {
//1、一次性交清和交费期间单位为A时删除豁免险
let mainRiskInfo = this.getMainRiskInfo()
let mainRiskPayIntv = mainRiskInfo.payIntv.payIntv
let mainRiskPayEndYearFlag = mainRiskInfo.payEndYear.payEndYearFlag
if (mainRiskPayIntv == 0 || mainRiskPayEndYearFlag == 'A') {
//删除已选或互斥险种
for (let i = 0; i < this.chooseProducts.length; i++) {
if (this.chooseProducts[i].isRemit == 0) {
this.chooseProducts.splice(i, 1)
i--
}
}
}
//2、豁免险跟主险联动豁免险缴费期间和保险期间同主险的缴费期间
let remitIndex = this.getRemitIndex()
//if (!remitIndex) return
for (let itemRemitIndex of remitIndex) {
this.chooseProducts[itemRemitIndex].calFactorLst.forEach((item) => {
if (item.code == 'payIntv') {
for (let key in mainRiskInfo.payIntv) {
item[key] = mainRiskInfo.payIntv[key]
}
}
if (item.code == 'payEndYear') {
item.hasFlag = '1'
item.payEndYearFlag = 'Y'
item.payEndYear = Number(mainRiskInfo.payEndYear.payEndYear)
item.showContent = item.payEndYear + '年交'
}
if (item.code == 'insuYear') {
item.hasFlag = '1'
item.insuYearFlag = 'Y'
item.insuYear = Number(mainRiskInfo.payEndYear.payEndYear)
item.showContent = item.insuYear + '年'
}
if (item.code == 'amt') {
let trialList = JSON.parse(localStorage.trialList)
item.amt = trialList[0].prem
item.defaultValue = trialList[0].prem
item.moneyUnit = 1
item.suffix = '元'
}
if (this.chooseProducts[itemRemitIndex].productCode == 'GFRS_A0003' || this.chooseProducts[itemRemitIndex].productCode == 'GFRS_A0009'|| this.chooseProducts[itemRemitIndex].productCode == 'GFRS_A0010') {
//此附加险的缴费期间=主险缴费期间;保险期间=主险保险期间
if (item.code == 'insuYear') {
item.hasFlag = '1'
item.insuYearFlag = mainRiskInfo.insuYear.insuYearFlag
item.insuYear = Number(mainRiskInfo.insuYear.insuYear)
item.showContent = mainRiskInfo.insuYear.showContent
}
if (item.code == 'dutyGroup') {
item.rules.forEach((v) => {
try {
if (mainRiskInfo.inputPrem.displayAmount && mainRiskInfo.inputPrem.moneyUnit) {
v.amt = mainRiskInfo.inputPrem.displayAmount * mainRiskInfo.inputPrem.moneyUnit
} else {
// 解决这个问题--建议书添加 附加豁免保险费重大疾病保险 不展示险种保费
// inputPrem 这个里面的规则删除导致的
let payEndYearVal
this.chooseProducts.map((item) => {
item.calFactorLst.map((i) => {
if (i.code == 'payEndYear') {
payEndYearVal = i.showContent
}
})
})
this.chooseProducts[0].productTrialYearDTOS.forEach((item, index) => {
//因交费方式为一次性交清时,不会有豁免险,所以这里不判断一次性交清的情况
if (payEndYearVal == item.yearWay + '年交') {
v.amt = item.displayAmount * item.moneyUnit
}
})
}
} catch (e) {
let trialList = JSON.parse(localStorage.trialList)
v.amt = trialList[0].prem
// v.amt = mainRiskInfo.inputAmt.displayAmount * mainRiskInfo.inputAmt.moneyUnit
}
v.defaultDutyAmt = (Number(v.amt) / v.moneyUnit).toFixed(6)
// v.moneyUnit = 10000
// v.suffix = '万元'
})
}
}
//之所以catch是因为有些参数值不存在导致报错豁免险除国富人寿附加投保人豁免保险费定期寿险B款保险条款 GFRS_A0007试算拼参数时amt保额都重置为null
if (this.chooseProducts[itemRemitIndex].productCode == 'GFRS_A0001' || this.chooseProducts[itemRemitIndex].productCode == 'GFRS_A0007') {
try {
if (mainRiskInfo.inputPrem.displayAmount && mainRiskInfo.inputPrem.moneyUnit) {
item.amt = mainRiskInfo.inputPrem.displayAmount * mainRiskInfo.inputPrem.moneyUnit
item.defaultValue = mainRiskInfo.inputPrem.displayAmount * mainRiskInfo.inputPrem.moneyUnit
} else {
// 解决这个问题--建议书添加 附加豁免保险费重大疾病保险 不展示险种保费
// inputPrem 这个里面的规则删除导致的
let payEndYearVal01
this.chooseProducts.map((item01) => {
item01.calFactorLst.map((i) => {
if (i.code == 'payEndYear') {
payEndYearVal01 = i.showContent
}
})
})
this.chooseProducts[0].productTrialYearDTOS.forEach((v, index) => {
//因交费方式为一次性交清时,不会有豁免险,所以这里不判断一次性交清的情况
if (payEndYearVal01 == v.yearWay + '年交') {
item.amt = v.displayAmount * v.moneyUnit
item.defaultValue = v.displayAmount * v.moneyUnit
}
})
}
} catch (e) {
let trialList = JSON.parse(localStorage.trialList)
item.defaultValue = trialList[0].prem
item.amt = trialList[0].prem
}
item.defaultDutyAmt = (Number(item.amt) / item.moneyUnit).toFixed(6)
// 国富人寿附加投保人豁免保险费定期寿险B款保险条款 GFRS_A0007
// 保额----豁免主险+附加两全的保费
// 国富人寿附加两全保险条款 GFRS_A0011
//重新再调一次试算因保额为文本框没有change事件所以保额变化后少一次调用试算所以特此手动重新调用一次
let trialList = JSON.parse(localStorage.trialList)
let showPrem
trialList.forEach((item, index) => {
if (item.productCode == 'GFRS_A0011') {
showPrem = item.showPrem //获取两全险的保费
}
})
if (this.chooseProducts[itemRemitIndex].productCode == 'GFRS_A0007' && showPrem) {
item.amt = trialList[0].prem + showPrem
item.defaultValue = trialList[0].prem + showPrem
}
}
})
}
let product = this.chooseProducts.find((item) => {
return item.productCode === 'GFRS_A0006'
})
if (product && this.richChildrenFlag) {
product.calFactorLst[0].showContent = '月交'
product.calFactorLst[2].showContent = '月交'
product.calFactorLst[0].columns[0].text = '月交'
product.calFactorLst[2].columns[0].text = '月交'
let remitProduct = this.trialList.find((item) => {
return item.productCode === 'GFRS_A0006'
})
if (remitProduct) {
remitProduct.showPrem = '从万能账户中扣除'
remitProduct.prem = 0
remitProduct.payIntv = 1
}
}
if(this.chooseProducts[0].productCode == 'GFRS_M0053'){
if (this.trialList.length) {
this.chooseProducts.forEach((item, index) => {
// 国富人寿富桂金生养老年金保险,投保,被保险第二个责任默认不勾选,不可选
if (item.productCode == 'GFRS_A0010' || item.productCode == 'GFRS_A0009') {
item.calFactorLst.map((item2) => {
if (item2.code == 'dutyGroup') {
item2.rules.map((item3) => {
item3.defaultValue = '0'
})
}
})
}
})
}
}
this.trialBeforeRule()
},
//获取当前产品编码下的索引值
getProductCodeIndex(productCode) {
let remitIndex = ''
this.chooseProducts.forEach((item, index) => {
if (item.productCode == productCode) {
remitIndex = index
}
})
return remitIndex
},
//获取当前产品编码下的整条数据
getProductCodeItem(productCode) {
let remitItem = {}
this.chooseProducts.forEach((item, index) => {
if (item.productCode == productCode) {
remitItem = item
}
})
return remitItem
},
getRemitIndex() {
let remitIndex = []
this.chooseProducts.forEach((item, index) => {
if (item.isRemit == 0) {
remitIndex.push(index)
}
})
return remitIndex
},
getMainRiskInfo() {
let mainRiskInfo = {}
this.chooseProducts[0].calFactorLst.forEach((item) => {
mainRiskInfo[item.code] = item
})
return mainRiskInfo
},
/********end 通用规则、特殊规则处理 end******/
//查看文档列表
seeDocument(index) {
this.show = true
this.policyInfo = this.chooseProducts[index].documentDTOS
},
//打开文档
openDocument(item) {
let pdfUrl = encodeURIComponent(item.url)
this.$jump({
flag: 'h5',
extra: {
title: item.name,
// url: 'http://47.96.143.111/pdfjs/web/viewer.html?file=' + item.url //测试代码
url: location.origin + '/pdfjs/web/viewer.html?file=' + pdfUrl
}
})
// localStorage.documentInfo = JSON.stringify({ documentUrl: item.url, documentType: item.type })
// this.$jump({
// flag: 'h5',
// extra: {
// url: location.origin + '/#/product/productDocument'
// },
// routerInfo: {
// path: `/product/productDocument`
// }
// })
},
//删除所选产品
deleteRisk(index) {
Dialog.confirm({
title: '提示',
message: '确认删除该险种?',
cancelButtonColor: '#E9332E',
confirmButtonColor: '#FFFFFF',
className: 'dialog-delete'
})
.then(() => {
let currentGFRS_A0011
if (this.chooseProducts[index].isMainRisk == 0) {
this.chooseProducts = []
localStorage.chooseProducts = JSON.stringify(this.chooseProducts)
this.$jump({
flag: 'goBack',
extra: {
refresh: '1',
index: '-2'
},
routerInfo: {
type: 2,
index: -2,
path: '/common/selectedProduct'
}
})
localStorage.trialList = ''
}else{
currentGFRS_A0011 = this.chooseProducts[index].productCode == 'GFRS_A0011'?true:false //当前删除的是否是两全
this.chooseProducts.splice(index, 1)
}
if (
this.chooseProducts[0].mainRiskCode == 'GFRS_M0051' ||
this.chooseProducts[0].mainRiskCode == 'GFRS_M0044' ||
this.chooseProducts[0].mainRiskCode == 'GFRS_M0035' ||
this.chooseProducts[0].mainRiskCode == 'GFRS_M0038' ||
this.chooseProducts[0].mainRiskCode == 'GFRS_M0040'
) {
if (currentGFRS_A0011 && JSON.stringify(this.chooseProducts).includes('GFRS_A0010')) {
this.chooseProducts.forEach((item, index01) => {
if(item.productCode == 'GFRS_A0010'){
this.chooseProducts.splice(index01, 1)
}
})
// Dialog.alert({
// title: '提示',
// message: '当前未投保其他长险附加险,将删除该险种重新选择附加险!'
// }).then(() => {
// })
}
// let risks = this.chooseProducts
// let longRisks = []
// //拿到长险附加险数组
// for (let i = 1; i < risks.length; i++) {
// for (let j = 0; j < risks[i].calFactorLst.length; j++) {
// if (risks[i].calFactorLst[j].code === 'insuYear') {
// if (
// ((risks[i].calFactorLst[j].insuYearFlag == 'Y' && risks[i].calFactorLst[j].insuYear > 1) || risks[i].calFactorLst[j].insuYearFlag == 'A') &&
// risks[i].productCode != 'GFRS_A0010'
// ) {
// longRisks.push(risks[i].productCode)
// }
// }
// }
// }
// if (
// (this.chooseProducts.length == 2 && this.chooseProducts[1].productCode == 'GFRS_A0010') ||
// (this.chooseProducts.length == 3 &&
// JSON.stringify(this.chooseProducts).includes('GFRS_A0010') &&
// JSON.stringify(this.chooseProducts).includes('GFRS_A0009')) ||
// (longRisks.length <= 0 && this.chooseProducts.length > 1)
// ) {
// Dialog.alert({
// title: '提示',
// message: '当前未投保其他长险附加险,将删除该险种重新选择附加险!'
// }).then(() => {
// this.chooseProducts.splice(1, 1)
// localStorage.chooseProducts = JSON.stringify(this.chooseProducts)
// this.getTrial()
// })
// // this.$toast('当前未投保其他长险附加险,请删除该险种重新选择附加险!')
// // this.nextStepFlag = true
// }
}
localStorage.chooseProducts = JSON.stringify(this.chooseProducts)
this.getTrial()
})
.catch(() => {})
},
//试算
async getTrial() {
let that = this
this.nextStepFlag = true
this.$toast.clear()
this.$toast.loading({
message: '正在试算...',
forbidClick: true
})
await this.setRemitRisk()
let params = await this.getParams()
// 开门红产品试算增加标识,活动产品试算增加标识
if (this.activeType && this.isFrom != 'proposal') {
for (let product of params.trialInfos) {
product.isKmh = '1'
//GFRS-2552【需求】关于金掌桂投保流程增设指定生效日按钮的申请
product.cvaliDate = that.cvalidateStr
}
}
//国富人寿富桂金生养老年金保险
let age = this.saleInsuredPersonInfo.age
let sex = this.saleInsuredPersonInfo.sex //0男 1女
let trialFlag = true
params.trialInfos.forEach((item) => {
if (item.productCode == 'GFRS_A0011') {
if (item.insuYear == '60' && item.payEndYear == '30' && age > 30) {
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间或保险期间!')
trialFlag = false
} else if (item.insuYear == '70' && item.payEndYear == '30' && age > 40) {
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间或保险期间!')
trialFlag = false
} else if (
(item.insuYear == '80' && item.payEndYear == '15' && age > 55) ||
(item.insuYear == '80' && item.payEndYear == '19' && age > 50) ||
(item.insuYear == '80' && item.payEndYear == '20' && age > 50) ||
(item.insuYear == '80' && item.payEndYear == '30' && age > 40)
) {
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间或保险期间!')
trialFlag = false
}
}else if (item.productCode == 'GFRS_M0053') {
//国富人寿富桂金生养老年金保险
if(sex == '0'){
if(
(item.pensionAge == '60' && item.payEndYear == '30' && age > 30) ||
(item.pensionAge == '60' && item.payEndYear == '20' && age > 40) ||
(item.pensionAge == '60' && item.payEndYear == '15' && age > 45) ||
(item.pensionAge == '60' && item.payEndYear == '10' && age > 50)
) {
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间!')
trialFlag = false
}else if(
(item.pensionAge == '65' && item.payEndYear == '30' && age > 35) ||
(item.pensionAge == '65' && item.payEndYear == '20' && age > 40) ||
(item.pensionAge == '65' && item.payEndYear == '15' && age > 45) ||
(item.pensionAge == '65' && item.payEndYear == '10' && age > 50)
){
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间!')
trialFlag = false
}else if(
(item.pensionAge == '70' && item.payEndYear == '30' && age > 40) ||
(item.pensionAge == '70' && item.payEndYear == '20' && age > 50) ||
(item.pensionAge == '70' && item.payEndYear == '15' && age > 55)
){
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间!')
trialFlag = false
}
}else{ //女
if(
(item.pensionAge == '55' && item.payEndYear == '30' && age > 25) ||
(item.pensionAge == '55' && item.payEndYear == '20' && age > 35) ||
(item.pensionAge == '55' && item.payEndYear == '15' && age > 40) ||
(item.pensionAge == '55' && item.payEndYear == '10' && age > 45)
) {
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间!')
trialFlag = false
}else if(
(item.pensionAge == '60' && item.payEndYear == '30' && age > 30) ||
(item.pensionAge == '60' && item.payEndYear == '20' && age > 40) ||
(item.pensionAge == '60' && item.payEndYear == '15' && age > 45) ||
(item.pensionAge == '60' && item.payEndYear == '10' && age > 50)
){
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间!')
trialFlag = false
}else if(
(item.pensionAge == '65' && item.payEndYear == '30' && age > 35) ||
(item.pensionAge == '65' && item.payEndYear == '20' && age > 45) ||
(item.pensionAge == '65' && item.payEndYear == '15' && age > 50) ||
(item.pensionAge == '65' && item.payEndYear == '10' && age > 55)
){
this.nextStepFlag = true
this.$toast('被保险人年龄不适合该交费期间!')
trialFlag = false
}
}
}
})
if (!trialFlag) {
return
}
let resultData = await trial(params)
//试算成功,信息返显
if (resultData.result == 0) {
if (resultData.flag === '1') {
this.richChildrenFlag = true
}
this.trialList = resultData.trialList
localStorage.trialList = JSON.stringify(resultData.trialList)
//设置豁免险保额
this.setRemitRisk()
this.nextStepFlag = false
} else {
this.nextStepFlag = true
this.$toast(resultData.resultMessage)
}
localStorage.chooseProducts = JSON.stringify(this.chooseProducts)
},
//获取试算参数
getParams() {
let params = {
trialInfos: []
}
this.chooseProducts.forEach((item) => {
let trialInfo = {}
item.calFactorLst.forEach((factor) => {
if (factor.type == 0) {
if (factor.hasFlag == '1') {
trialInfo[factor.code] = factor[factor.code]
trialInfo[factor.code + 'Flag'] = factor[factor.code + 'Flag']
// trialInfo[factor.payEndYear] = factor[factor.payEndYear]
} else {
trialInfo[factor.code] = factor[factor.code]
}
} else if (factor.type == 1) {
if (factor.code == 'inputPrem') {
trialInfo['prem'] =
this.isTrial == '0'
? Number(item.productTrialYearDTOS[this.payEndYearColumnsIndex].displayAmount) *
Number(item.productTrialYearDTOS[this.payEndYearColumnsIndex].moneyUnit)
: Number(factor.displayAmount) * Number(factor.moneyUnit)
} else {
if (item.isRemit == 0) {
if (item.productCode == 'GFRS_A0007') {
if (factor.code == 'amt') {
trialInfo['amt'] = factor.amt
}
} else {
trialInfo['amt'] = null
}
} else {
if(item.productCode == 'GFRS_A0011'){
// 设置附加两全保额为空 后台试算
// GFRS_A0011-附加两全 属于非豁免险 但附加两全保额=主险年交保费+其他不带豁免责任的长期期交附加险年交保费
trialInfo['amt'] = null
}else {
trialInfo['amt'] = Number(factor.displayAmount) * Number(factor.moneyUnit)
}
}
}
} else if (factor.type == 2) {
trialInfo.jobLevel = this.saleInsuredPersonInfo[factor.code]
} else if (factor.type == 3) {
let result = []
factor.rules.forEach((dutyItem) => {
if (dutyItem.necess) {
// trialInfo['amt'] = this.trialList[index].amt
result.push({
amt: (Number(dutyItem.defaultDutyAmt) * Number(dutyItem.moneyUnit)).toFixed(2),
dutyCode: dutyItem.duty,
dutyName: dutyItem.dutyName
})
}
})
trialInfo.duty = result
}
})
//针对八桂D产品 计算被保人重疾B附加险保额 ==其他长险附加险的保额
/*if ( this.chooseProducts[0].mainRiskCode == 'GFRS_M0051'||this.chooseProducts[0].mainRiskCode == 'GFRS_M0044'){
if(item.productCode == 'GFRS_A0010'){
let risks = JSON.parse(localStorage.chooseProducts);
let longRisks=[];
//拿到长险附加险数组
for (let i = 1; i < risks.length; i++) {
for(let j = 0; j < risks[i].calFactorLst.length; j++){
if (risks[i].calFactorLst[j].code === 'insuYear') {
if ((risks[i].calFactorLst[j].insuYearFlag == 'Y' && risks[i].calFactorLst[j].insuYear > 1) || risks[i].calFactorLst[j].insuYearFlag == 'A') {
longRisks.push(risks[i].productCode);
}
}
}
}
let toTrial = 0
let trials = JSON.parse(localStorage.trialList)
trials.forEach(tr=>{
if(tr.isMainRisk=='1'&&tr.productCode!='GFRS_A0010'&&longRisks.includes(tr.productCode)){
toTrial+=Number(tr.prem);
}
})
trialInfo.duty.forEach(d=>{
d.amt=toTrial;
})
}
}*/
//通用规则1交费方式为一次交情无交费期限
if (trialInfo['payIntv'] == '0') {
trialInfo['payEndYear'] = '1000'
trialInfo['payEndYearFlag'] = 'Y'
// 福宝宝和万能险传A
if (
item.mainRiskCode != 'GFRS_M0006' &&
item.mainRiskCode != 'GFRS_M0017' &&
item.mainRiskCode != 'GFRS_M0003' &&
item.mainRiskCode != 'GFRS_M0013'
) {
trialInfo['insuYearFlag'] = 'Y'
}
//
if (item.mainRiskCode == 'GFRS_M0036') {
trialInfo['insuYearFlag'] = 'A'
}
}
//责任险参数构建
// if (trialInfo.duty) {
// trialInfo.duty = [{ dutyCode: trialInfo.duty }]
// }
//获取投被保生日、性别
let birthday, sex, occupationCode, occupationName
if (item.isRemit == '0' && item.remitType == '0') {
;[birthday, sex, occupationCode, occupationName] = [
this.saleInsuredInfo.birthday,
this.saleInsuredInfo.sex,
this.saleInsuredInfo.occupationCode,
this.saleInsuredInfo.occupationName
]
} else {
;[birthday, sex, occupationCode, occupationName] = [
this.saleInsuredPersonInfo.birthday,
this.saleInsuredPersonInfo.sex,
this.saleInsuredPersonInfo.occupationCode,
this.saleInsuredPersonInfo.occupationName
]
}
trialInfo = Object.assign(trialInfo, {
birthday,
sex,
occupationCode,
occupationName,
platformType: 'app',
productCode: item.productCode,
medical: JSON.parse(this.$CacheUtils.getLocItem('saleInsuredPersonInfo')).medical,
isCrossChannel: this.isCrossChannel
})
params.trialInfos.push(trialInfo)
})
this.trialInfos = params.trialInfos
return params
},
//选择附加险
selectAddtionRisk() {
//存储附加险列表
let addRiskCodes = []
this.chooseProducts.forEach((item) => {
if (item.isMainRisk == 1) {
addRiskCodes.push(item.productCode)
}
})
if (localStorage.oldAddRiskCodes && JSON.parse(localStorage.oldAddRiskCodes)) {
addRiskCodes = addRiskCodes.concat(JSON.parse(localStorage.oldAddRiskCodes))
}
//930折中方案豁免险挂订单
addRiskCodes = addRiskCodes.filter((riskCode) => {
return riskCode != 'DCRS_A0001'
})
localStorage.addRiskCodes = JSON.stringify(addRiskCodes)
this.$jump({
flag: 'h5',
extra: {
url: location.origin + '/#/common/addRiskList'
},
routerInfo: {
path: '/common/addRiskList'
}
})
},
//保额份数变化
stepperChange(defalutValue, productIndex, calFactorIndex, min, max, riskFactor) {
let currentEle =
localStorage.isTrial !== '1' && this.chooseProducts[productIndex].isMainRisk == '0'
? this.chooseProducts[productIndex].productTrialYearDTOS[calFactorIndex]
: this.chooseProducts[productIndex].calFactorLst[calFactorIndex]
//改动原因:孝心保产品有对年龄的特殊要求
//添加判断,是否是孝心保产品
let showHint = this.chooseProducts[productIndex].hint
let productCode = localStorage.trialList == '' ? '' : JSON.parse(localStorage.trialList)[0].productCode
if (productCode == 'GFRS_M0014') {
//被保险人年龄如果在50-65区间
if (this.saleInsuredPersonInfo.age >= 50 && this.saleInsuredPersonInfo.age <= 65) {
//使用rules规则里的第二条控制保额份数
if (Number(defalutValue) < Number(riskFactor.rules[1].minPrem) || Number(defalutValue) > Number(riskFactor.rules[1].maxPrem)) {
this.$toast(showHint)
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast(showHint)
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
//被保险人年龄如果在66-75之间
} else if (this.saleInsuredPersonInfo.age >= 66 && this.saleInsuredPersonInfo.age <= 75) {
//使用rules规则里的第一条控制保额份数
if (Number(defalutValue) < Number(riskFactor.rules[0].minPrem) || Number(defalutValue) > Number(riskFactor.rules[0].maxPrem)) {
this.$toast(showHint)
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast(showHint)
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
}
//isTrial为0 ---暂时为富娃娃两全保险(万能型)专配 输入保费校验
} else if (productCode == 'GFRS_M0035' || productCode == 'GFRS_M0044') {
console.log('defalutValue==', defalutValue)
console.log("currentEle['amt']==", currentEle['amt'])
console.log('riskFactor.rules', riskFactor.rules)
console.log('this.saleInsuredPersonInfo.age ', this.saleInsuredPersonInfo.age)
//被保险人年龄如果在50-65区间
if (this.saleInsuredPersonInfo.age >= 56 && this.saleInsuredPersonInfo.age <= 60) {
//使用rules规则里的第二条控制保额份数
// 年龄在56周岁及以上被保险人投保本险种时最低基本保险金额为10000元。超过最低基本保险金额为10000元整数倍。
if (Number(defalutValue) < Number(riskFactor.rules[1].minPrem) || Number(defalutValue) > Number(riskFactor.rules[1].maxPrem)) {
this.$toast('56周岁-60周岁最低基本保险金额为'+ riskFactor.rules[1].minPrem +'万元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast('56周岁-60周岁最低基本保险金额为'+ riskFactor.rules[1].minPrem +'万元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
//年龄在0-55周岁被保险人投保本险种时最低基本保险金额为50000元超过最低基本保险金额为10000元整数倍。
} else if (this.saleInsuredPersonInfo.age >= 0 && this.saleInsuredPersonInfo.age <= 55) {
//使用rules规则里的第一条控制保额份数
if (Number(defalutValue) < Number(riskFactor.rules[0].minPrem) || Number(defalutValue) > Number(riskFactor.rules[0].maxPrem)) {
this.$toast('0周岁-55周岁最低基本保险金额为'+ riskFactor.rules[0].minPrem +'万元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast('0周岁-55周岁最低基本保险金额为'+ riskFactor.rules[0].minPrem +'万元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
}
//isTrial为0 ---暂时为富娃娃两全保险(万能型)专配 输入保费校验
} else if (productCode == 'GFRS_M0040') {
// 惠企保保额限制
//被保险人年龄如果在41-60区间
if (this.saleInsuredPersonInfo.age >= 41) {
//使用rules规则里的第二条控制保额份数
if (Number(defalutValue) < Number(riskFactor.rules[1].minPrem) || Number(defalutValue) > Number(riskFactor.rules[1].maxPrem)) {
this.$toast('年龄在41周岁至60周岁被保险人投保本险种时最低基本保险金额为50000元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast('年龄在41周岁至60周岁被保险人投保本险种时最低基本保险金额为50000元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
} else if (this.saleInsuredPersonInfo.age >= 0 && this.saleInsuredPersonInfo.age <= 40) {
//使用rules规则里的第一条控制保额份数
if (Number(defalutValue) < Number(riskFactor.rules[0].minPrem) || Number(defalutValue) > Number(riskFactor.rules[0].maxPrem)) {
this.$toast('年龄在0-40周岁被保险人投保本险种时最低基本保险金额为100000元超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast('年龄在0-40周岁被保险人投保本险种时最低基本保险金额为100000元超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
}
//isTrial为0 ---暂时为富娃娃两全保险(万能型)专配 输入保费校验
} else if (productCode == 'GFRS_M0046') {
//被保险人年龄如果在50-65区间
if (this.saleInsuredPersonInfo.age >= 51 && this.saleInsuredPersonInfo.age <= 60) {
//使用rules规则里的第二条控制保额份数
// 年龄在51周岁及以上被保险人投保本险种时最低基本保险金额为10000元。超过最低基本保险金额为10000元整数倍。
if (Number(defalutValue) < Number(riskFactor.rules[1].minPrem) || Number(defalutValue) > Number(riskFactor.rules[1].maxPrem)) {
this.$toast('51周岁-60周岁最低基本保险金额为10000元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast('51周岁-60周岁最低基本保险金额为10000元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
//年龄在0-50周岁被保险人投保本险种时最低基本保险金额为50000元超过最低基本保险金额为10000元整数倍。
} else if (this.saleInsuredPersonInfo.age >= 0 && this.saleInsuredPersonInfo.age <= 50) {
//使用rules规则里的第一条控制保额份数
if (Number(defalutValue) < Number(riskFactor.rules[0].minPrem) || Number(defalutValue) > Number(riskFactor.rules[0].maxPrem)) {
this.$toast('0周岁-50周岁最低基本保险金额为50000元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
this.$toast('0周岁-50周岁最低基本保险金额为50000元。超过最低基本保险金额为10000元整数倍。')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
}
//国富人寿富桂金生养老年金保险
} else if (productCode == 'GFRS_M0053') {
if (Number(defalutValue) < Number(min)) {
this.$toast(`交费期间为${riskFactor.yearWay}年交时,最低保费为${Number(min) * Number(riskFactor.moneyUnit)}元`)
this.nextStepFlag = true
}else{
this.nextStepFlag = false
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(riskFactor.moneyUnit)
this.getTrial()
}
} else if (this.isTrial === '0' && this.chooseProducts[productIndex].isMainRisk == '0') {
if (Number(defalutValue) < Number(min)) {
this.$toast(`交费期间为${riskFactor.yearWay}年交时,最低保费为${Number(min) * Number(riskFactor.moneyUnit)}元`)
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// this.defalutAmt = currentEle.rules[productIndex].displayAmount
this.$toast(`超过最低保费部分金额需为1000元整数倍`)
this.nextStepFlag = true
} else {
this.nextStepFlag = false
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(riskFactor.moneyUnit)
this.getTrial()
}
}
//其他产品按照原先的逻辑判断
} else if (this.isTrial === '0' && this.chooseProducts[productIndex].isMainRisk == '1') {
if (Number(defalutValue) < Number(min) || Number(defalutValue) > Number(max)) {
this.$toast('投保本险种最低基本保险金额为10000元超过最低基本保险金额为1000元整数倍')
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// defalutValue = currentEle.rules[productIndex].displayAmount
this.$toast('投保本险种最低基本保险金额为10000元超过最低基本保险金额为1000元整数倍')
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
} else {
if (Number(defalutValue) < Number(min) || Number(defalutValue) > Number(max)) {
this.$toast(showHint)
this.nextStepFlag = true
} else {
if ((Number(defalutValue) * 10000) % (Number(currentEle.limit) * 10000) != 0) {
// defalutValue = currentEle.rules[productIndex].displayAmount
this.$toast(showHint)
this.nextStepFlag = true
} else {
this.mainRiskInfluenceAddRisk()
currentEle['amt'] = Number(defalutValue) * Number(currentEle.moneyUnit)
this.getTrial()
}
}
}
// let currentEle = this.chooseProducts[this.productIndex].calFactorLst[this.calFactorIndex]
// defalutValue = value
console.log('进来几次')
this.mult = Math.ceil(Number(defalutValue) / Number(riskFactor.defaultValue))
},
//下一步
async nextStep() {
//GFRS_M0016需要验证责任
if (this.mainRiskCode === 'GFRS_M0016') {
let calFactorLst = this.chooseProducts[0].calFactorLst
for (let i = 0; i < calFactorLst.length; i++) {
if (calFactorLst[i].code === 'dutyGroup') {
let duties = calFactorLst[i].rules
for (let j = 0; j < duties.length; j++) {
let item = duties[j]
if (!this.valiDuty(item.defaultDutyAmt, item.duty)) {
return
}
}
}
}
}
//GFRS_A0004需要验证责任
for (let m = 0; m < this.chooseProducts.length; m++) {
if (this.chooseProducts[m].productCode == 'GFRS_A0004' || this.chooseProducts[m].productCode == 'GFRS_A0008') {
let showHint = this.chooseProducts[m].hint
let calFactorLst = this.chooseProducts[m].calFactorLst
for (let i = 0; i < calFactorLst.length; i++) {
if (calFactorLst[i].code === 'dutyGroup') {
let duties = calFactorLst[i].rules
for (let j = 0; j < duties.length; j++) {
let item = duties[j]
if (!this.valiA0004Duty(item.defaultDutyAmt, showHint, item)) {
return
}
}
}
}
}
}
// 验证格式
if (this.isRelated && this.isFrom != 'proposal' && this.policyNo) {
let vl = /^[0-9\\]+$/.test(this.policyNo)
if (!vl) {
return this.$toast('关联保单的格式不正确')
}
}
//组装险种提交数据
let [mainRiskCode, riskDTOLst] = ['', []]
let rollInResult = '' //校验预计转入保费结果
this.chooseProducts.forEach((item, index) => {
console.log(item)
if (localStorage.trialList != '') {
if (item.isMainRisk == 0) {
mainRiskCode = item.productCode
}
// this.trialInfos.map(trial=>{
// trial.duty.map(dutylist=> {
// dutylist.dutyname
// })
// })
let riskItem = {
isMainRisk: item.isMainRisk,
riskName: item.riskName,
riskType: item.riskType,
riskCode: item.productCode,
mainRiskCode: mainRiskCode,
prem: this.trialList[index] && this.trialList[index].prem,
standPrem: this.trialList[index] && this.trialList[index].standPrem,
predictTransferPrem: item.predictTransferPrem,
thirdInsuraceNo: this.policyNo
// mult: this.mult
}
if (item.hasPredictTransferPrem && item.hasPredictTransferPrem === '0') {
//增加万能险 预计转入保费校验
rollInResult = this.rollInCheck(item.predictTransferPrem)
} else {
rollInResult = true
}
//责任险保存参数构建
if (this.trialList[index].duty) {
riskItem['dutyLst'] = this.trialList[index].duty
//930折中方案责任险分档
riskItem['amt'] = this.trialList[index].amt
} else {
//国富人寿桂企保重大疾病保险产品专写
if (
this.trialList[index].productCode == 'GFRS_M0024' ||
this.trialList[index].productCode == 'GFRS_M0040' ||
this.trialList[index].productCode == 'GFRS_M0044' ||
this.trialList[index].productCode == 'GFRS_M0046'||
this.trialList[index].productCode == 'GFRS_M0051'
) {
riskItem['dutyLst'] = this.trialInfos[index].duty
}
}
//保费算保额
if (this.trialList[index].trialType == '1' || this.trialList[index].trialType == '2') {
riskItem['amt'] = this.trialList[index].amt
}
//万能型产品保费赋值给保额
//增加判断是否是从建议书跳转过来了的
if (localStorage.isFrom != 'proposal') {
if (
this.trialList[index].productCode == 'GFRS_M0003' ||
this.trialList[index].productCode == 'GFRS_M0015' ||
this.trialList[index].productCode == 'GFRS_M0017'
) {
riskItem['amt'] = this.trialList[index].prem
}
}
//豁免险保额处理
if (item.isRemit == '0') {
this.trialInfos[index].amt = this.trialList[0].prem
}
if (item.productCode == 'GFRS_A0001') {
this.trialInfos[index].amt = this.trialList[0].standPrem
}
if (item.productCode == 'GFRS_A0003' || item.productCode == 'GFRS_A0007') {
// bug--鑫享年年+附加豁免投保人定寿B+附加豁免投保人重疾B投保单号8186270000016187
// ①豁免重疾B的保额应该等于主险的保费该单的豁免重疾B的保额等于主险的保额不正确。
this.trialInfos[index].amt = this.trialList[index].amt
}
// GFRS_A0009,GFRS_A0010 这两款时,责任保额不相加
if(item.productCode == 'GFRS_A0009' || item.productCode == 'GFRS_A0010'){
this.trialInfos[index].amt = this.trialList[index].duty[0].amt
}
// GFRS_A0011-附加两全 属于非豁免险 但附加两全保额=主险年交保费+其他不带豁免责任的长期期交附加险年交保费
if (item.productCode == 'GFRS_A0011') {
this.trialInfos[index].amt = this.trialList[0].prem
}
if (!this.renewalShow(this.mainRiskCode)) {
for (let prop of item.calFactorLst) {
if (prop.type === '4') {
this.trialInfos[index].isRenewal = this.renewal
}
}
}
// console.log(riskItem)
riskItem = Object.assign(riskItem, this.trialInfos[index])
riskDTOLst.push(riskItem)
}
})
if (!rollInResult) {
return
}
//国富人寿桂企保重大疾病保险产品专写
this.trialInfos.map((v, i) => {
if (v.productCode == 'GFRS_M0024' || v.productCode == 'GFRS_M0040' || v.productCode == 'GFRS_M0044'
|| v.productCode == 'GFRS_M0046'|| v.productCode == 'GFRS_M0051') {
delete riskDTOLst[i].duty
}
})
//建议书需要添加全部投保人信息电投只需要投保人ID
let insuredDTOItem = Object.assign(this.saleInsuredPersonInfo, { riskDTOLst: riskDTOLst })
let params = {
orderType: 'RISK_ORDER',
orderDTO: {
orderInfoDTO: {
orderNo: this.$CacheUtils.getLocItem('orderNo'),
productChannel:this.isCrossChannel
},
// appntDTO: {},
insuredDTOs: [insuredDTOItem]
}
}
// 富娃娃&一年定寿交费方式,交费区间固定为月交
if (this.richChildrenFlag) {
let product = params.orderDTO.insuredDTOs[0].riskDTOLst.find(item => {
return item.productCode === 'GFRS_M0015'
})
if (product) {
let trialProduct = params.orderDTO.insuredDTOs[0].riskDTOLst.find(item => {
return item.productCode === 'GFRS_A0006'
})
if (trialProduct) {
trialProduct.prem = 0
trialProduct.payIntv = 1
trialProduct.insuYearFlag = 'M'
trialProduct.payEndYear = 1
}
}
}
let resultData
if (localStorage.isFrom == 'proposal') {
// 从建议书进入, 豁免险保费空值特殊处理
let prdCodes = ['GFRS_A0001', 'GFRS_A0007']
params.orderDTO.insuredDTOs[0].riskDTOLst.forEach(item => {
if (prdCodes.includes(item.productCode)) {
this.trialList.forEach(element => {
if (item.productCode == element.productCode) {
item.amt = element.amt
}
})
}
})
resultData = await saveProposal(params)
} else {
resultData = await saveOrUpdateOrderInfo(params)
}
if (resultData.result == 0) {
//电投
if (localStorage.isFrom == 'sale') {
if (resultData.deleteFlag == '0') {
localStorage.salePageFlag = '3';
}
this.$jump({
flag: 'goBack',
extra: {
refresh: '1',
index: '-2'
},
routerInfo: {
type: 2,
index: -2,
path: '/common/selectedProduct'
}
})
}else if (localStorage.isFrom == 'proposal'){
let proposalOrderNo = this.$CacheUtils.getLocItem('orderNo') || ''
let url = `/common/selectedProduct?proposalOrderNo=${proposalOrderNo}`
if (resultData.content.id) {
this.saleInsuredPersonInfo.insuredId = resultData.content.id;
this.$CacheUtils.setLocItem('saleInsuredPersonInfo', JSON.stringify(this.saleInsuredPersonInfo))
}
this.$jump({
flag: 'goBack',
extra: {
refresh: '1',
index: '-2'
},
routerInfo: {
type: 2,
index: -2,
path: url
}
})
}
} else {
this.$toast(resultData.resultMessage)
}
},
rollInCheck(value) {
let regExp = /^[1-9]+[0-9]*$/
let result = regExp.test(value)
if (result) {
return true
} else {
this.$toast.fail('请输入正确的预计转入保费')
return false
}
}
},
watch: {
// chooseProducts: {
// deep: true,
// handler: function(newVal) {
// this.chooseProducts = newVal
// }
// }
}
}
</script>
<style lang="scss" scoped>
.renewalWrappser {
display: flex;
justify-content: space-between;
align-items: center;
}
/deep/ .van-radio {
margin: 0 0.5em;
}
.renewal {
display: flex;
justify-content: flex-end;
padding: 1em;
}
/deep/ .van-radio__label {
line-height: normal;
}
.calculate-premium-container {
.border-bottom {
border-bottom: 1px solid #dadada;
}
.van-cell {
padding: 0px;
}
.prem:last-child {
border: none;
}
/deep/.van-action-sheet__name {
font-size: 12px;
}
.checkbox-click {
position: absolute;
right: 0;
top: 0;
width: 7.46667vw;
height: 7.46667vw;
}
}
</style>