|
@@ -691,8 +691,7 @@ export default {
|
|
|
})
|
|
})
|
|
|
if (filteredChildren.length > 0) {
|
|
if (filteredChildren.length > 0) {
|
|
|
this.children = filteredChildren
|
|
this.children = filteredChildren
|
|
|
- this.selectedChild = filteredChildren[0]
|
|
|
|
|
- this.currentChildId = filteredChildren[0].id
|
|
|
|
|
|
|
+ // 不自动选孩子:默认显示家长自己,等待用户从 FamilyMemberStrip 选择
|
|
|
this.familyAvgCompletionRate = dashData.avgCompletionRate || 0
|
|
this.familyAvgCompletionRate = dashData.avgCompletionRate || 0
|
|
|
// 家长自身数据(积分 + 任务完成率)
|
|
// 家长自身数据(积分 + 任务完成率)
|
|
|
this.myPoints = dashData.parentPoints || 0
|
|
this.myPoints = dashData.parentPoints || 0
|
|
@@ -716,10 +715,7 @@ export default {
|
|
|
const parents = (data.parents || []).filter(function(p) { return p && p.id && p.id !== currentUserId }).map(function(p) { return { ...p, role: 'parent' } })
|
|
const parents = (data.parents || []).filter(function(p) { return p && p.id && p.id !== currentUserId }).map(function(p) { return { ...p, role: 'parent' } })
|
|
|
const children = (data.children || []).filter(function(c) { return c && c.id }).map(function(c) { return { ...c, role: 'child' } })
|
|
const children = (data.children || []).filter(function(c) { return c && c.id }).map(function(c) { return { ...c, role: 'child' } })
|
|
|
this.familyMembers = [].concat(parents, children)
|
|
this.familyMembers = [].concat(parents, children)
|
|
|
- if (children.length > 0) {
|
|
|
|
|
- this.selectedChild = children[0]
|
|
|
|
|
- this.currentChildId = children[0].id
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 不自动选孩子:默认显示家长自己,等待用户从 FamilyMemberStrip 选择
|
|
|
// 保存 familyId 用于后续请求
|
|
// 保存 familyId 用于后续请求
|
|
|
if (data.familyId) {
|
|
if (data.familyId) {
|
|
|
this._familyId = data.familyId
|
|
this._familyId = data.familyId
|
|
@@ -733,10 +729,7 @@ export default {
|
|
|
const childrenRes = await getChildren()
|
|
const childrenRes = await getChildren()
|
|
|
const rawChildren = childrenRes.data || []
|
|
const rawChildren = childrenRes.data || []
|
|
|
this.children = rawChildren
|
|
this.children = rawChildren
|
|
|
- if (this.children.length > 0 && !this.selectedChild) {
|
|
|
|
|
- this.selectedChild = this.children[0]
|
|
|
|
|
- this.currentChildId = this.children[0].id
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 不自动选孩子:默认显示家长自己,等待用户从 FamilyMemberStrip 选择
|
|
|
} catch (e) {
|
|
} catch (e) {
|
|
|
console.log('获取孩子列表失败', e)
|
|
console.log('获取孩子列表失败', e)
|
|
|
}
|
|
}
|
|
@@ -923,6 +916,15 @@ export default {
|
|
|
},
|
|
},
|
|
|
onFamilyMemberSelect(member) {
|
|
onFamilyMemberSelect(member) {
|
|
|
this.selectedMemberId = member.id
|
|
this.selectedMemberId = member.id
|
|
|
|
|
+ // 选中的是孩子时,设置 selectedChild 以便子组件加载孩子数据
|
|
|
|
|
+ var matched = this.children.find(function(c) { return c.id === member.id })
|
|
|
|
|
+ if (matched) {
|
|
|
|
|
+ this.selectedChild = matched
|
|
|
|
|
+ this.currentChildId = matched.id
|
|
|
|
|
+ } else {
|
|
|
|
|
+ this.selectedChild = null
|
|
|
|
|
+ this.currentChildId = ''
|
|
|
|
|
+ }
|
|
|
},
|
|
},
|
|
|
async onFamilyMemberSwitch(member) {
|
|
async onFamilyMemberSwitch(member) {
|
|
|
if (!member || !member.id) return
|
|
if (!member || !member.id) return
|