diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 2385f3d..b75b201 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -550,15 +550,31 @@ const navGroups = computed(() => { })); }); -/* ===== profile:读 store.userInfo(真实展示;保存占位) ===== */ -const profileForm = reactive({ mobile: "", email: "" }); -/** userInfo 派生展示(手机/邮箱编辑值初始同源;工号暂以登录账号展示——接口未提供独立工号字段) */ +/* ===== profile:读 store.userInfo(真实展示;手机/邮箱编辑值初始同源;工号暂以登录账号展示——接口未提供独立工号字段) ===== */ +/** 所属部门=组路径(BoaUser.groups 是「挂载组→…→根」近→远链):取学校组(type=2)到链首的区段反向 join("/"), + * 如「云海小学/校长室」;链上无学校组(区域/学段直属)时回退挂载组名;链空再回退 dept.name(dept 是 BoaGroup 对象, + * 直接展示会成 [object Object]——本 helper 即该 bug 的修复口径,他处如需展示部门也复用此口径)。 */ +function deptPathOf(u: any): string { + if (typeof u.deptName === "string" && u.deptName.trim()) return u.deptName.trim(); + const groups: any[] = Array.isArray(u.groups) ? u.groups : []; + if (groups.length === 0) { + const dn = u.dept && typeof u.dept.name === "string" ? u.dept.name.trim() : ""; + return dn || "-"; + } + const schoolIdx = groups.findIndex(g => !!g && g.type === 2); + const seg = schoolIdx >= 0 ? groups.slice(0, schoolIdx + 1) : groups.slice(0, 1); + const names = seg + .map(g => (g && typeof g.name === "string" ? g.name.trim() : "")) + .filter(Boolean) + .reverse(); + return names.length > 0 ? names.join("/") : "-"; +} const profileView = computed(() => { const u: any = store.userInfo || {}; return { name: u.name || "-", account: u.account || "-", - deptName: u.deptName || u.dept || "-", + deptName: deptPathOf(u), phone: u.phone || "", email: u.email || "", };