refactor(product): 优化保费计算组件逻辑

- 移除未使用的组件引用 FieldDatePicter 和 SelectRadio
- 删除冗余的 registerMainTask 调用
- 清理调试代码 window.cps 赋值
- 统一使用严格相等运算符 === 替代 ==
- 简化 forEach 循环中的索引参数
- 修复作用域变量 that 的使用,统一为 this
- 注释掉无用的 proposalOrderNo 相关代码
- 优化产品编码判断逻辑,提高可读性
This commit is contained in:
hz
2025-11-28 16:46:54 +08:00
parent 9d110db205
commit 52766cbfc1

View File

@@ -515,8 +515,6 @@ export default {
[Dialog.name]: Dialog,
[Radio.name]: Radio,
[RadioGroup.name]: RadioGroup,
FieldDatePicter: FieldDatePicter,
SelectRadio: SelectRadio,
InsuredMessageInfo: () => import('./CalculatePremiumInsuredMessageInfo.vue'),
DestoryablePopup: () => import('@/components/common/DestroyablePopup.vue')
},
@@ -633,20 +631,6 @@ export default {
// 当组件挂载之后开始创建订单
this.isFrom = window.localStorage.isFrom
if (this.isFrom === 'proposal') {
setTimeout(() => {
/* global EWebBridge */
EWebBridge.webCallAppInJs('webview_right_button', {
btns: [
{
img: this.$assetsUrl + 'images/del-close.png',
route: { flag: '', extra: {} }
}
]
})
}, 500)
}
// window.appCallBack = this.appCallBack
getAgentInfo({}).then(res => {
this.branchType = res.branchType
// branchType N1、1代表个险渠道 和 N5、5 代表中介渠道N代表内勤
@@ -664,7 +648,7 @@ export default {
})
// this.initPersonInfo()
this.init()
this.registerMainTask()
Array.prototype.min = function() {
var min = this[0]
var len = this.length
@@ -675,7 +659,6 @@ export default {
}
return min
}
this.registerMainTask()
},
methods: {
registerMainTask() {
@@ -1026,7 +1009,6 @@ export default {
this.chooseProducts = (window.structuredClone ? structuredClone : deepClone)(productsData)
window.cps = this.chooseProducts
this.processProducts()
//GFRS_M0016需要展示免赔额和赔付比例并需要根据是否有社保调整数值
// let mainRiskCode = chooseProducts[0].mainRiskCode
@@ -1536,14 +1518,14 @@ export default {
//勾选时才做验证
this.valiAndSend(dutyItem, productIndex)
}
if (productCode == 'GFRS_M0077') {
if (productCode === 'GFRS_M0077') {
this.chooseProducts.forEach(item => {
if (item.mainRiskCode == 'GFRS_M0077') {
if (item.mainRiskCode === 'GFRS_M0077') {
item.calFactorLst.map(i => {
if (i.code == 'dutyGroup') {
if (i.code === 'dutyGroup') {
if (i.rules && i.rules.length != 0) {
i.rules.forEach(ii => {
if (ii.duty == '311507' && ii.necess) {
if (ii.duty === '311507' && ii.necess) {
ii.defaultDutyAmt = dutyItem.defaultDutyAmt
}
})
@@ -1711,16 +1693,16 @@ export default {
let addtionRiskLst = JSON.parse(localStorage.addtionRiskLst)
if (addtionRiskLst) {
let list = []
addtionRiskLst.forEach((item, index) => {
addtionRiskLst.forEach(item => {
if (
item.productCode != 'GFRS_A0007' &&
item.productCode != 'GFRS_A0009' &&
item.productCode != 'GFRS_A0010' &&
item.productCode != 'GFRS_A0012' &&
item.productCode != 'GFRS_A0013' &&
item.productCode != 'GFRS_A0014' &&
item.productCode != 'GFRS_A0015' &&
item.productCode != 'GFRS_A0016'
item.productCode !== 'GFRS_A0007' &&
item.productCode !== 'GFRS_A0009' &&
item.productCode !== 'GFRS_A0010' &&
item.productCode !== 'GFRS_A0012' &&
item.productCode !== 'GFRS_A0013' &&
item.productCode !== 'GFRS_A0014' &&
item.productCode !== 'GFRS_A0015' &&
item.productCode !== 'GFRS_A0016'
) {
list.push(item)
}
@@ -1897,12 +1879,12 @@ export default {
//只有在搭配附加两全时才能搭配被保险人附加豁免重疾B;
//获取两全险的保费
let showPrem001
this.trialList.forEach((item, index) => {
this.trialList.forEach(item => {
if (item.productCode == 'GFRS_A0011') {
showPrem001 = item.showPrem //获取两全险的保费
}
})
this.chooseProducts.forEach((item, index) => {
this.chooseProducts.forEach(item => {
if (
item.productCode === 'GFRS_A0010' ||
item.productCode === 'GFRS_A0009' ||
@@ -2050,7 +2032,7 @@ export default {
}
})
})
this.chooseProducts[0].productTrialYearDTOS.forEach((item, index) => {
this.chooseProducts[0].productTrialYearDTOS.forEach(item => {
//因交费方式为一次性交清时,不会有豁免险,所以这里不判断一次性交清的情况
if (payEndYearVal == Number(item.yearWay) - 1 + '年交') {
v.amt = item.displayAmount * item.moneyUnit
@@ -2085,7 +2067,7 @@ export default {
}
})
})
this.chooseProducts[0].productTrialYearDTOS.forEach((v, index) => {
this.chooseProducts[0].productTrialYearDTOS.forEach(v => {
//因交费方式为一次性交清时,不会有豁免险,所以这里不判断一次性交清的情况
if (payEndYearVal01 == v.yearWay + '年交') {
item.amt = v.displayAmount * v.moneyUnit
@@ -2106,7 +2088,7 @@ export default {
//重新再调一次试算因保额为文本框没有change事件所以保额变化后少一次调用试算所以特此手动重新调用一次
let trialList = JSON.parse(localStorage.trialList)
let showPrem
trialList.forEach((item, index) => {
trialList.forEach(item => {
if (item.productCode === 'GFRS_A0011') {
showPrem = item.showPrem //获取两全险的保费
}
@@ -2167,7 +2149,7 @@ export default {
//获取当前产品编码下的整条数据
getProductCodeItem(productCode) {
let remitItem = {}
this.chooseProducts.forEach((item, index) => {
this.chooseProducts.forEach(item => {
if (item.productCode == productCode) {
remitItem = item
}
@@ -3310,8 +3292,7 @@ export default {
if (!this.renewalShow(this.mainRiskCode)) {
for (let prop of item.calFactorLst) {
if (prop.type === '4') {
this.保费试算
trialInfos[index].isRenewal = this.renewal
this.trialInfos[index].isRenewal = this.renewal
}
}
}
@@ -3428,7 +3409,7 @@ export default {
// }
// })
} else if (localStorage.isFrom === 'proposal') {
let proposalOrderNo = this.$CacheUtils.getLocItem('proposalNo') || ''
// let proposalOrderNo = this.$CacheUtils.getLocItem('proposalNo') || ''
if (resultData.content.id) {
this.saleInsuredPersonInfo.insuredId = resultData.content.id
this.$CacheUtils.setLocItem('saleInsuredPersonInfo', JSON.stringify(this.saleInsuredPersonInfo))
@@ -3473,14 +3454,14 @@ export default {
saveOrUpdateTrialRecordInfo(data).then(res => {
if (res.result == '0') {
//被保人产品列表界面 点击编辑按钮进入产品试算界面 点击完成 页面跳转不正确
let proposalOrderNo = ''
if (this.$route.query.proposalOrderNo) {
proposalOrderNo = this.$route.query.proposalOrderNo
} else {
proposalOrderNo = this.$route.query.orderNo
}
let url = `/common/selectedProduct?proposalOrderNo=${proposalOrderNo}`
if (localStorage.isFrom == 'orderTrial' && localStorage.isFrom == 'sale') {
// let proposalOrderNo = ''
// if (this.$route.query.proposalOrderNo) {
// proposalOrderNo = this.$route.query.proposalOrderNo
// } else {
// proposalOrderNo = this.$route.query.orderNo
// }
// let url = `/common/selectedProduct?proposalOrderNo=${proposalOrderNo}`
if (localStorage.isFrom === 'orderTrial' && localStorage.isFrom === 'sale') {
this.$toast.clear()
this.trialResultsShow = true
this.verifyResultList = res.content.data.verifyResultList
@@ -3632,7 +3613,7 @@ export default {
//初始化时取交费期间的值值再去对应productTrialYearDTOS中的第几条规则
item.productTrialYearDTOS.forEach((item, index) => {
if (payEndYearVal == item.yearWay + '年交') {
that.payEndYearColumnsIndex = index
this.payEndYearColumnsIndex = index
}
})
}