0.3.0.5
This commit is contained in:
@@ -116,8 +116,16 @@ export default function MemberProfilePage() {
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
if (member.gender === 'MALE') {
|
||||
params.set('fatherId', member.id)
|
||||
// 如果父亲有配偶,设置配偶为母亲
|
||||
if (member.spouseIds && member.spouseIds.length > 0) {
|
||||
params.set('motherId', member.spouseIds[0])
|
||||
}
|
||||
} else {
|
||||
params.set('motherId', member.id)
|
||||
// 如果母亲有配偶,设置配偶为父亲
|
||||
if (member.spouseIds && member.spouseIds.length > 0) {
|
||||
params.set('fatherId', member.spouseIds[0])
|
||||
}
|
||||
}
|
||||
params.set('generation', (member.generation + 1).toString())
|
||||
router.push(`/members/new?${params.toString()}`)
|
||||
@@ -130,6 +138,15 @@ export default function MemberProfilePage() {
|
||||
params.set('generation', member.generation.toString())
|
||||
// 配偶性别与当前成员相反
|
||||
params.set('gender', member.gender === 'MALE' ? 'FEMALE' : 'MALE')
|
||||
|
||||
// 如果当前成员有子女,将他们也作为新配偶的子女
|
||||
if (member.childrenIds && member.childrenIds.length > 0) {
|
||||
// 传递所有子女ID
|
||||
member.childrenIds.forEach(id => {
|
||||
params.append('childrenIds', id)
|
||||
})
|
||||
}
|
||||
|
||||
router.push(`/members/new?${params.toString()}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -42,19 +42,29 @@ export default function NewMemberPage() {
|
||||
// 处理父母信息
|
||||
if (fatherId) {
|
||||
data.fatherId = fatherId
|
||||
// 如果有父亲,尝试获取母亲(父亲的配偶)
|
||||
const father = getMember(fatherId)
|
||||
if (father?.spouseIds && father.spouseIds.length > 0) {
|
||||
data.motherId = father.spouseIds[0]
|
||||
}
|
||||
}
|
||||
|
||||
if (motherId) {
|
||||
data.motherId = motherId
|
||||
// 如果有母亲,尝试获取父亲(母亲的配偶)
|
||||
}
|
||||
|
||||
// 如果只有父亲没有母亲,尝试自动获取母亲(父亲的配偶)
|
||||
if (fatherId && !motherId) {
|
||||
const father = getMember(fatherId)
|
||||
console.log('Looking for mother (father\'s spouse):', { fatherId, father, spouseIds: father?.spouseIds })
|
||||
if (father?.spouseIds && father.spouseIds.length > 0) {
|
||||
data.motherId = father.spouseIds[0]
|
||||
console.log('Found mother:', data.motherId)
|
||||
}
|
||||
}
|
||||
|
||||
// 如果只有母亲没有父亲,尝试自动获取父亲(母亲的配偶)
|
||||
if (motherId && !fatherId) {
|
||||
const mother = getMember(motherId)
|
||||
console.log('Looking for father (mother\'s spouse):', { motherId, mother, spouseIds: mother?.spouseIds })
|
||||
if (mother?.spouseIds && mother.spouseIds.length > 0) {
|
||||
data.fatherId = mother.spouseIds[0]
|
||||
console.log('Found father:', data.fatherId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,8 +73,12 @@ export default function NewMemberPage() {
|
||||
data.spouseIds = [spouseId]
|
||||
}
|
||||
|
||||
// 处理子女信息(添加父母时使用)
|
||||
if (childId) {
|
||||
// 处理子女信息
|
||||
const childrenIds = searchParams.getAll('childrenIds')
|
||||
|
||||
if (childrenIds.length > 0) {
|
||||
data.childrenIds = childrenIds
|
||||
} else if (childId) {
|
||||
data.childrenIds = [childId]
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user