mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-09 15:46:43 +08:00
feat(insured-person): 优化被保人信息处理逻辑
- 引入 deepClone 工具函数用于深拷贝用户信息 - 注释掉原生返回按钮相关代码逻辑 - 调整 userInfo 监听器逻辑,增加 relationToAppnt 属性监听 - 使用 some 替代 every 来判断用户信息变更 - 保存旧用户信息用于比较变更内容
This commit is contained in:
@@ -1,43 +1,44 @@
|
||||
export function deepClone(obj, hash = new WeakMap()) {
|
||||
if (window.structuredClone) return window.structuredClone(obj)
|
||||
// 处理 null 或 undefined
|
||||
if (obj === null || typeof obj !== 'object') {
|
||||
return obj;
|
||||
return obj
|
||||
}
|
||||
|
||||
// 处理循环引用
|
||||
if (hash.has(obj)) {
|
||||
return hash.get(obj);
|
||||
return hash.get(obj)
|
||||
}
|
||||
|
||||
// 处理 Date 对象
|
||||
if (obj instanceof Date) {
|
||||
return new Date(obj);
|
||||
return new Date(obj)
|
||||
}
|
||||
|
||||
// 处理 RegExp 对象
|
||||
if (obj instanceof RegExp) {
|
||||
return new RegExp(obj.source, obj.flags);
|
||||
return new RegExp(obj.source, obj.flags)
|
||||
}
|
||||
|
||||
// 处理数组
|
||||
if (Array.isArray(obj)) {
|
||||
const clonedArr = [];
|
||||
hash.set(obj, clonedArr);
|
||||
const clonedArr = []
|
||||
hash.set(obj, clonedArr)
|
||||
obj.forEach((item, index) => {
|
||||
clonedArr[index] = deepClone(item, hash);
|
||||
});
|
||||
return clonedArr;
|
||||
clonedArr[index] = deepClone(item, hash)
|
||||
})
|
||||
return clonedArr
|
||||
}
|
||||
|
||||
// 处理普通对象
|
||||
if (typeof obj === 'object') {
|
||||
const clonedObj = {};
|
||||
hash.set(obj, clonedObj);
|
||||
const clonedObj = {}
|
||||
hash.set(obj, clonedObj)
|
||||
Object.keys(obj).forEach(key => {
|
||||
clonedObj[key] = deepClone(obj[key], hash);
|
||||
});
|
||||
return clonedObj;
|
||||
clonedObj[key] = deepClone(obj[key], hash)
|
||||
})
|
||||
return clonedObj
|
||||
}
|
||||
|
||||
return obj;
|
||||
return obj
|
||||
}
|
||||
|
||||
@@ -505,6 +505,7 @@ import SearchField from './components/SearchField'
|
||||
import riskRules from '@/views/ebiz/common/risk-rules'
|
||||
import { cardSide, subBusinessType, user } from '@/views/ebiz/saleFlowProImprove/js/enum'
|
||||
import { applicant, insured } from '@/views/ebiz/saleFlowProImprove/js/state'
|
||||
import { deepClone } from '@/assets/js/utils/objectUtils'
|
||||
|
||||
export default {
|
||||
name: 'insuredInfo',
|
||||
@@ -767,14 +768,14 @@ export default {
|
||||
},
|
||||
async mounted() {
|
||||
window.cvThis = this
|
||||
setTimeout(() => {
|
||||
// eslint-disable-next-line no-undef
|
||||
EWebBridge.webCallAppInJs('webview_left_button', {
|
||||
img: this.$assetsUrl + 'images/del-close-btn@3x.png',
|
||||
intercept: '1' //是否拦截原生返回事件 1是 其他否
|
||||
})
|
||||
}, 100)
|
||||
window.appCallBack = this.appCallBack
|
||||
// setTimeout(() => {
|
||||
// // eslint-disable-next-line no-undef
|
||||
// EWebBridge.webCallAppInJs('webview_left_button', {
|
||||
// img: this.$assetsUrl + 'images/del-close-btn@3x.png',
|
||||
// intercept: '1' //是否拦截原生返回事件 1是 其他否
|
||||
// })
|
||||
// }, 100)
|
||||
// window.appCallBack = this.appCallBack
|
||||
// // document.body.style.backgroundColor = '#F5F5F5'
|
||||
//获取代理人管理机构 52贵州 45广西
|
||||
let dataReturn = await riskRules.getAgentInfoFunc(this)
|
||||
@@ -2189,12 +2190,13 @@ export default {
|
||||
userInfo: {
|
||||
deep: true,
|
||||
immediate: true,
|
||||
async handler(userInfo, oldUserInfo) {
|
||||
async handler(userInfo) {
|
||||
const oldUserInfo = this.oldUserInfo
|
||||
// 如果信息补全了, 开始计算试算信息
|
||||
if (!(await this.$validator.validate())) return
|
||||
const includesProperties = ['sex', 'birthday', 'medical']
|
||||
// if (!(await this.$validator.validate())) return
|
||||
const includesProperties = ['sex', 'birthday', 'medical', 'relationToAppnt']
|
||||
if (
|
||||
includesProperties.every(property => {
|
||||
includesProperties.some(property => {
|
||||
if (!userInfo || !oldUserInfo) return false
|
||||
if (!userInfo[property] || !oldUserInfo[property]) return false
|
||||
return userInfo[property] !== oldUserInfo[property]
|
||||
@@ -2202,6 +2204,7 @@ export default {
|
||||
) {
|
||||
this.$emit('msgUpdate')
|
||||
}
|
||||
this.oldUserInfo = deepClone(userInfo)
|
||||
}
|
||||
},
|
||||
applicant: {
|
||||
|
||||
Reference in New Issue
Block a user