From 41f4dade918dc8de3382e5c4592fbec5c8712718 Mon Sep 17 00:00:00 2001 From: chenxing Date: Fri, 2 Oct 2026 08:42:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(settings):=20=E4=B8=AA=E4=BA=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E3=80=8C=E6=89=80=E5=B1=9E=E9=83=A8=E9=97=A8=E3=80=8D?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=BB=84=E8=B7=AF=E5=BE=84=E2=80=94=E2=80=94?= =?UTF-8?q?BoaUser.dept=20=E6=98=AF=E5=AF=B9=E8=B1=A1=E7=9B=B4=E6=98=BE?= =?UTF-8?q?=E6=88=90=20[object=20Object]=EF=BC=8C=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8F=96=20groups=20=E9=93=BE=E5=AD=A6=E6=A0=A1=E7=BB=84(type?= =?UTF-8?q?=3D2)=E2=86=92=E6=8C=82=E8=BD=BD=E7=BB=84=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E5=8F=8D=E5=90=91=20join('/')=EF=BC=88=E5=A6=82=E3=80=8C?= =?UTF-8?q?=E4=BA=91=E6=B5=B7=E5=B0=8F=E5=AD=A6/=E6=A0=A1=E9=95=BF?= =?UTF-8?q?=E5=AE=A4=E3=80=8D=EF=BC=89=EF=BC=8C=E6=97=A0=E5=AD=A6=E6=A0=A1?= =?UTF-8?q?=E7=BB=84=E5=9B=9E=E9=80=80=E6=8C=82=E8=BD=BD=E7=BB=84=E5=90=8D?= =?UTF-8?q?=E3=80=81=E9=93=BE=E7=A9=BA=E5=9B=9E=E9=80=80=20dept.name?= =?UTF-8?q?=E3=80=81=E5=85=9C=E5=BA=95=20'-'=EF=BC=88=E4=BB=BB=E5=8A=A1C?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/Settings.vue | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) 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 || "", };