mirror of
http://112.124.100.131/GFRS/ebiz-h5.git
synced 2025-12-24 12:32:53 +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()) {
|
export function deepClone(obj, hash = new WeakMap()) {
|
||||||
|
if (window.structuredClone) return window.structuredClone(obj)
|
||||||
// 处理 null 或 undefined
|
// 处理 null 或 undefined
|
||||||
if (obj === null || typeof obj !== 'object') {
|
if (obj === null || typeof obj !== 'object') {
|
||||||
return obj;
|
return obj
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理循环引用
|
// 处理循环引用
|
||||||
if (hash.has(obj)) {
|
if (hash.has(obj)) {
|
||||||
return hash.get(obj);
|
return hash.get(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理 Date 对象
|
// 处理 Date 对象
|
||||||
if (obj instanceof Date) {
|
if (obj instanceof Date) {
|
||||||
return new Date(obj);
|
return new Date(obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理 RegExp 对象
|
// 处理 RegExp 对象
|
||||||
if (obj instanceof RegExp) {
|
if (obj instanceof RegExp) {
|
||||||
return new RegExp(obj.source, obj.flags);
|
return new RegExp(obj.source, obj.flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理数组
|
// 处理数组
|
||||||
if (Array.isArray(obj)) {
|
if (Array.isArray(obj)) {
|
||||||
const clonedArr = [];
|
const clonedArr = []
|
||||||
hash.set(obj, clonedArr);
|
hash.set(obj, clonedArr)
|
||||||
obj.forEach((item, index) => {
|
obj.forEach((item, index) => {
|
||||||
clonedArr[index] = deepClone(item, hash);
|
clonedArr[index] = deepClone(item, hash)
|
||||||
});
|
})
|
||||||
return clonedArr;
|
return clonedArr
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理普通对象
|
// 处理普通对象
|
||||||
if (typeof obj === 'object') {
|
if (typeof obj === 'object') {
|
||||||
const clonedObj = {};
|
const clonedObj = {}
|
||||||
hash.set(obj, clonedObj);
|
hash.set(obj, clonedObj)
|
||||||
Object.keys(obj).forEach(key => {
|
Object.keys(obj).forEach(key => {
|
||||||
clonedObj[key] = deepClone(obj[key], hash);
|
clonedObj[key] = deepClone(obj[key], hash)
|
||||||
});
|
})
|
||||||
return clonedObj;
|
return clonedObj
|
||||||
}
|
}
|
||||||
|
|
||||||
return obj;
|
return obj
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -505,6 +505,7 @@ import SearchField from './components/SearchField'
|
|||||||
import riskRules from '@/views/ebiz/common/risk-rules'
|
import riskRules from '@/views/ebiz/common/risk-rules'
|
||||||
import { cardSide, subBusinessType, user } from '@/views/ebiz/saleFlowProImprove/js/enum'
|
import { cardSide, subBusinessType, user } from '@/views/ebiz/saleFlowProImprove/js/enum'
|
||||||
import { applicant, insured } from '@/views/ebiz/saleFlowProImprove/js/state'
|
import { applicant, insured } from '@/views/ebiz/saleFlowProImprove/js/state'
|
||||||
|
import { deepClone } from '@/assets/js/utils/objectUtils'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'insuredInfo',
|
name: 'insuredInfo',
|
||||||
@@ -767,14 +768,14 @@ export default {
|
|||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
window.cvThis = this
|
window.cvThis = this
|
||||||
setTimeout(() => {
|
// setTimeout(() => {
|
||||||
// eslint-disable-next-line no-undef
|
// // eslint-disable-next-line no-undef
|
||||||
EWebBridge.webCallAppInJs('webview_left_button', {
|
// EWebBridge.webCallAppInJs('webview_left_button', {
|
||||||
img: this.$assetsUrl + 'images/del-close-btn@3x.png',
|
// img: this.$assetsUrl + 'images/del-close-btn@3x.png',
|
||||||
intercept: '1' //是否拦截原生返回事件 1是 其他否
|
// intercept: '1' //是否拦截原生返回事件 1是 其他否
|
||||||
})
|
// })
|
||||||
}, 100)
|
// }, 100)
|
||||||
window.appCallBack = this.appCallBack
|
// window.appCallBack = this.appCallBack
|
||||||
// // document.body.style.backgroundColor = '#F5F5F5'
|
// // document.body.style.backgroundColor = '#F5F5F5'
|
||||||
//获取代理人管理机构 52贵州 45广西
|
//获取代理人管理机构 52贵州 45广西
|
||||||
let dataReturn = await riskRules.getAgentInfoFunc(this)
|
let dataReturn = await riskRules.getAgentInfoFunc(this)
|
||||||
@@ -2189,12 +2190,13 @@ export default {
|
|||||||
userInfo: {
|
userInfo: {
|
||||||
deep: true,
|
deep: true,
|
||||||
immediate: true,
|
immediate: true,
|
||||||
async handler(userInfo, oldUserInfo) {
|
async handler(userInfo) {
|
||||||
|
const oldUserInfo = this.oldUserInfo
|
||||||
// 如果信息补全了, 开始计算试算信息
|
// 如果信息补全了, 开始计算试算信息
|
||||||
if (!(await this.$validator.validate())) return
|
// if (!(await this.$validator.validate())) return
|
||||||
const includesProperties = ['sex', 'birthday', 'medical']
|
const includesProperties = ['sex', 'birthday', 'medical', 'relationToAppnt']
|
||||||
if (
|
if (
|
||||||
includesProperties.every(property => {
|
includesProperties.some(property => {
|
||||||
if (!userInfo || !oldUserInfo) return false
|
if (!userInfo || !oldUserInfo) return false
|
||||||
if (!userInfo[property] || !oldUserInfo[property]) return false
|
if (!userInfo[property] || !oldUserInfo[property]) return false
|
||||||
return userInfo[property] !== oldUserInfo[property]
|
return userInfo[property] !== oldUserInfo[property]
|
||||||
@@ -2202,6 +2204,7 @@ export default {
|
|||||||
) {
|
) {
|
||||||
this.$emit('msgUpdate')
|
this.$emit('msgUpdate')
|
||||||
}
|
}
|
||||||
|
this.oldUserInfo = deepClone(userInfo)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
applicant: {
|
applicant: {
|
||||||
|
|||||||
Reference in New Issue
Block a user