This commit is contained in:
freedakgmail
2025-11-23 17:10:10 +08:00
parent d7bb86375d
commit 9cdd751a56
25 changed files with 900 additions and 309 deletions
+36
View File
@@ -88,6 +88,32 @@ export default function MemberProfilePage() {
router.push(`/members/new?${params.toString()}`)
}
const handleQuickAddFather = () => {
// 跳转到新增成员页面,并预填父亲信息
const params = new URLSearchParams()
params.set('childId', member.id)
params.set('generation', (member.generation - 1).toString())
params.set('gender', 'MALE')
// 如果已有母亲,将母亲设置为配偶
if (member.motherId) {
params.set('spouseId', member.motherId)
}
router.push(`/members/new?${params.toString()}`)
}
const handleQuickAddMother = () => {
// 跳转到新增成员页面,并预填母亲信息
const params = new URLSearchParams()
params.set('childId', member.id)
params.set('generation', (member.generation - 1).toString())
params.set('gender', 'FEMALE')
// 如果已有父亲,将父亲设置为配偶
if (member.fatherId) {
params.set('spouseId', member.fatherId)
}
router.push(`/members/new?${params.toString()}`)
}
if (isEditing) {
return (
<div className="min-h-screen flex flex-col bg-background">
@@ -168,6 +194,16 @@ export default function MemberProfilePage() {
</div>
<div className="flex gap-2 flex-wrap">
{!member.fatherId && (
<Button variant="outline" onClick={handleQuickAddFather} className="gap-2">
<UserPlus className="h-4 w-4" />
</Button>
)}
{!member.motherId && (
<Button variant="outline" onClick={handleQuickAddMother} className="gap-2">
<UserPlus className="h-4 w-4" />
</Button>
)}
<Button variant="default" onClick={handleQuickAddChild} className="gap-2">
<UserPlus className="h-4 w-4" />
</Button>
+7 -1
View File
@@ -21,10 +21,11 @@ export default function NewMemberPage() {
const fatherId = searchParams.get('fatherId')
const motherId = searchParams.get('motherId')
const spouseId = searchParams.get('spouseId')
const childId = searchParams.get('childId')
const generation = searchParams.get('generation')
const gender = searchParams.get('gender')
if (!fatherId && !motherId && !spouseId && !generation && !gender) return undefined
if (!fatherId && !motherId && !spouseId && !childId && !generation && !gender) return undefined
const data: Partial<FamilyMember> = {}
@@ -52,6 +53,11 @@ export default function NewMemberPage() {
data.spouseIds = [spouseId]
}
// 处理子女信息(添加父母时使用)
if (childId) {
data.childrenIds = [childId]
}
// 处理世代
if (generation) {
data.generation = parseInt(generation)
+11 -11
View File
@@ -373,7 +373,7 @@ export default function MembersPage() {
? 'bg-pink-50/50 dark:bg-pink-950/20 border-pink-200/50 dark:border-pink-800/30'
: 'bg-blue-50/50 dark:bg-blue-950/20 border-blue-200/50 dark:border-blue-800/30'
}`}>
<CardContent className="p-3 flex items-center gap-3">
<CardContent className="p-3 flex items-center gap-5">
<div className="relative flex-shrink-0">
<AvatarDisplay
imageId={member.avatarImageId}
@@ -390,38 +390,38 @@ export default function MembersPage() {
<div className="absolute -bottom-1 -right-1 w-4 h-4 rounded-full bg-green-500 border-2 border-white" title="在世" />
)}
</div>
<div className="flex-1 min-w-0 pl-1">
<div className="flex-1 min-w-0 flex flex-col justify-center">
<div className="flex items-baseline justify-between gap-1.5">
<h3 className="text-base font-bold font-serif truncate">
<h3 className="text-lg font-bold font-serif truncate">
{member.fullName}
{member.courtesyName && (
<span className="text-[11px] font-normal text-muted-foreground ml-1">
<span className="text-xs font-normal text-muted-foreground ml-1">
{member.courtesyName}
</span>
)}
</h3>
</div>
{isFounder ? (
<p className="text-[11px] text-amber-700 font-medium mt-0.5 truncate">
<p className="text-xs text-amber-700 font-medium mt-0.5 truncate">
</p>
) : isSpouse && spouseName ? (
<p className="text-[11px] text-purple-700 mt-0.5 truncate">
<p className="text-xs text-purple-700 mt-0.5 truncate">
{spouseName}
</p>
) : (
<p className="text-[11px] text-muted-foreground mt-0.5 truncate">
<p className="text-xs text-muted-foreground mt-0.5 truncate">
{member.generationName ? `字辈: ${member.generationName}` : "未录入字辈"}
</p>
)}
{/* 籍贯和生卒年并排 */}
<div className="flex items-start justify-between gap-2 mt-0.5">
<p className="text-[11px] text-muted-foreground truncate flex-1">{member.ancestralHome || "籍贯未知"}</p>
<p className="text-xs text-muted-foreground truncate flex-1">{member.ancestralHome || "籍贯未知"}</p>
{/* 生卒年和年龄 */}
{(member.birthDate || member.deathDate) && (
<div className="text-[10px] text-muted-foreground text-right space-y-0.5 flex-shrink-0">
<div className="text-xs text-muted-foreground text-right space-y-0.5 flex-shrink-0">
<div>
{member.birthDate && new Date(member.birthDate).getFullYear()}
{member.deathDate && ` - ${new Date(member.deathDate).getFullYear()}`}
@@ -433,7 +433,7 @@ export default function MembersPage() {
const deathYear = member.deathDate ? new Date(member.deathDate).getFullYear() : new Date().getFullYear()
const age = deathYear - birthYear
return (
<div className="text-[9px] text-muted-foreground">
<div className="text-[10px] text-muted-foreground">
{member.deathDate ? `享年${age}` : `${age}`}
</div>
)
@@ -447,7 +447,7 @@ export default function MembersPage() {
{member.tags.map((tag) => (
<span
key={tag}
className="text-[9px] bg-primary/10 text-primary px-1 py-0.5 rounded border border-primary/20"
className="text-xs bg-primary/10 text-primary px-2 py-0.5 rounded border border-primary/20"
>
{tag}
</span>