Files
ebiz-h5/src/views/ebiz/common/CalculatePremium.vue
tian.guangyuan e7a27da4e8 Merge branch 'feature/GFRS-834【0402】国富人寿国富栋梁定期寿险' into release/0421
# Conflicts:
#	src/views/ebiz/sale/SignatureConfirmation.vue
2020-04-21 19:54:22 +08:00

1589 lines
62 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" 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">
<div class="flex justify-content-s pv10 border-bottom" v-if="riskFactor.type == 1">
<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>
<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 == 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.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="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">
<span
style="font-weight:bold"
v-if="(trialList.length > 0 && trialList[index].trialType == 0) || (trialList.length > 0 && trialList[index].trialType == 2) || isTrial === '0'"
>首期保费</span
>
<span style="font-weight:bold" v-else>保额</span>
<span class="fee red" v-if="trialList && trialList.length > 0">{{ trialList[index].showPrem.toFixed(2) | moneyFormat }}</span>
</div>
</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 } from 'vant'
import { trial } from '@/api/ebiz/common/common'
import { saveOrUpdateOrderInfo, getOrderDetail } from '@/api/ebiz/sale/sale'
import { saveProposal, getDemo } 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 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
},
data() {
return {
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: {}
}
},
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: {
//初始化数据
init() {
// 获取是否从建议书过来的
this.isFrom = localStorage.isFrom
//获取投保人信息
if (localStorage.saleInsuredInfo) {
this.saleInsuredInfo = JSON.parse(localStorage.saleInsuredInfo)
}
//获取被保险人信息
if (localStorage.saleInsuredPersonInfo) {
this.saleInsuredPersonInfo = JSON.parse(localStorage.saleInsuredPersonInfo)
}
//构建提交数据、渲染险种
let chooseProducts = (this.chooseProducts = JSON.parse(localStorage.chooseProducts))
this.chooseProducts.map(item => {
if (item.mainRiskCode == 'GFRS_M0006') {
item.isHidden = true
}
if (item.mainRiskCode != 'GFRS_M0008') {
item.calFactorLst.map(i => {
// this.defalutAmt = i.displayAmount || 1
this.mult = Math.ceil(Number(i.displayAmount) / Number(i.defaultValue))
})
}
// 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 => {
console.log(item3)
if (item3.duty == '320205') {
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()
})
// 判断是否 含有 后台配置js验证函数
if(localStorage.ruleExpression){
let ruleExpression = JSON.parse(localStorage.ruleExpression);
this.ruleExpression = ruleExpression
let productCodes = Object.keys(ruleExpression)
productCodes.forEach(itemKey => {
// console.log(ruleExpression[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'],
// }
// console.log("config",config);
this.$on(config.eventName, new Function( ...config.funPar, config.funBody.join('')));
rules.eventList.push(config.eventName)
})
})
}
},
//特殊处理 GFRS_M0016 GFRS_A0004 GFRS_A0005 赔付比例处理
async dogetLimitAndGetRate() {
const orderNo = localStorage.getItem('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_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_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
if (this.chooseProducts[productIndex].productCode === 'GFRS_A0003') {
this.getTrial()
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)
})
}
}
}
},
// blur(value) {
// console.log('哈哈哈',value)
// },
//弹框选择
toSelect(index, index1, columns) {
;[this.popupShow, this.productIndex, this.calFactorIndex] = [true, index, index1]
this.columns = columns
},
//取消picker
onCancel() {
this.columns = []
this.popupShow = false
},
//确认选择字段
onConfirm(value) {
this.columns = []
// let productCode = this.chooseProducts[this.productIndex].productCode
let currentFactor = this.chooseProducts[this.productIndex].calFactorLst
let currentEle = currentFactor[this.calFactorIndex]
console.log('value', value)
console.log('currentFactor', currentFactor)
console.log('currentEle', currentEle)
//特殊设置:如果需要填写的保费/保额校验规则跟缴费期间挂钩当改变缴费期间时将输入框的值恢复默认值1
if (currentEle.code == 'payEndYear' && this.isTrial == '0') {
currentEle['columns'].forEach((item, index) => {
if (item.value == value.value) {
this.payEndYearColumnsIndex = index
}
})
this.defalutAmt = 1
}
console.log('payEndYearColumnsIndex == ', this.payEndYearColumnsIndex)
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
}
// console.log("productCode ==>" , productCode)
// 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()
}
this.popupShow = false
},
// 交通责任险复选框变化
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 {
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
},
/********start 通用规则、特殊规则处理 start******/
//通用规则1交费方式为一次交情无交费期限
hiddenPayEndYear(currentEle) {
if (currentEle.code == 'payIntv') {
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)
}
if (payEndYearVal > insuYearVal) {
this.$toast('交费期间不能超过保险期间')
return true
} else {
return 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
}
}
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
},
//特殊规则3、设置豁免险
setRemitRisk() {
//1、一次性交清和交费期间单位为A时删除豁免险
let mainRiskInfo = this.getMainRiskInfo()
console.log(mainRiskInfo)
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
this.chooseProducts[remitIndex].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[remitIndex].productCode == 'GFRS_A0003') {
//此附加险的缴费期间=主险缴费期间;保险期间=主险保险期间
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') {
let trialList = JSON.parse(localStorage.trialList)
item.rules.forEach(v => {
v.amt = trialList[0].prem
v.defaultDutyAmt = (Number(trialList[0].prem) / 10000).toFixed(6)
v.moneyUnit = 10000
v.suffix = '万元'
})
}
}
})
},
getRemitIndex() {
let remitIndex
this.chooseProducts.forEach((item, index) => {
if (item.isRemit == 0) {
remitIndex = 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(() => {
if (this.chooseProducts[index].isMainRisk == 0) {
this.chooseProducts = []
this.$jump({
flag: 'goBack',
extra: {
refresh: '1',
index: '-2'
},
routerInfo: {
type: 2,
index: -2,
path: '/common/selectedProduct'
}
})
localStorage.trialList = ''
} else {
this.chooseProducts.splice(index, 1)
}
localStorage.chooseProducts = JSON.stringify(this.chooseProducts)
this.getTrial()
})
.catch(() => {})
},
//试算
async getTrial() {
this.setRemitRisk()
let params = this.getParams()
let resultData = await trial(params)
//试算成功,信息返显
if (resultData.result == 0) {
this.trialList = resultData.trialList
console.log(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, index) => {
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) {
trialInfo['amt'] = Number(factor.displayAmount) * Number(factor.moneyUnit)
} 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
}
})
console.log('trialInfo == ', trialInfo)
//通用规则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 (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(localStorage.getItem('saleInsuredPersonInfo')).medical
})
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) {
console.log(defalutValue, productIndex, calFactorIndex, min, max)
console.log(this.saleInsuredPersonInfo.age)
console.log(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 (this.isTrial === '0' && this.chooseProducts[productIndex].isMainRisk == '0') {
if (Number(defalutValue) < Number(min)) {
console.log('校验 == ', Number(defalutValue), Number(min), Number(min) * Number(riskFactor.moneyUnit))
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') {
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) => {
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
}
//保费算保额
console.log('this.trialList', this.trialList[index].trialType)
// debugger
if (this.trialList[index].trialType == '1' || this.trialList[index].trialType == '2') {
// console.log('11111111111111111')
// console.log(this.trialList[index].amt)
riskItem['amt'] = this.trialList[index].amt
}
// console.log(riskItem)
//万能型产品保费赋值给保额
//增加判断是否是从建议书跳转过来了的
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') {
// console.log('33333333')
this.trialInfos[index].amt = this.trialList[0].prem
}
// console.log(riskItem)
console.log(this.trialInfos[index])
riskItem = Object.assign(riskItem, this.trialInfos[index])
// console.log(riskItem)
riskDTOLst.push(riskItem)
}
})
if (!rollInResult) {
return
}
// console.log('riskDTOLst', riskDTOLst)
//建议书需要添加全部投保人信息电投只需要投保人ID
let insuredDTOItem = Object.assign(this.saleInsuredPersonInfo, { riskDTOLst: riskDTOLst })
let params = {
orderType: 'RISK_ORDER',
orderDTO: {
orderInfoDTO: {
orderNo: localStorage.orderNo
},
// appntDTO: {},
insuredDTOs: [insuredDTOItem]
}
}
let resultData
if (localStorage.isFrom == 'proposal') {
resultData = await saveProposal(params)
} else {
resultData = await saveOrUpdateOrderInfo(params)
}
if (resultData.result == 0) {
//电投
if (localStorage.isFrom == 'sale' && resultData.deleteFlag == '0') {
localStorage.salePageFlag = '3'
}
//建议书
if (localStorage.isFrom == 'proposal' && resultData.content.id) {
this.saleInsuredPersonInfo.insuredId = resultData.content.id
localStorage.saleInsuredPersonInfo = JSON.stringify(this.saleInsuredPersonInfo)
}
this.$jump({
flag: 'goBack',
extra: {
refresh: '1',
index: '-2'
},
routerInfo: {
type: 2,
index: -2,
path: '/common/selectedProduct'
}
})
} 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) {
// // console.log('xin', newVal)
// this.chooseProducts = newVal
// }
// }
}
}
</script>
<style lang="scss" scoped>
.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>