fix(settings): 个人信息「所属部门」显示组路径——BoaUser.dept 是对象直显成 [object Object],改为取 groups 链学校组(type=2)→挂载组区段反向 join('/')(如「云海小学/校长室」),无学校组回退挂载组名、链空回退 dept.name、兜底 '-'(任务C)
This commit is contained in:
+20
-4
@@ -550,15 +550,31 @@ const navGroups = computed(() => {
|
|||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
/* ===== profile:读 store.userInfo(真实展示;保存占位) ===== */
|
/* ===== profile:读 store.userInfo(真实展示;手机/邮箱编辑值初始同源;工号暂以登录账号展示——接口未提供独立工号字段) ===== */
|
||||||
const profileForm = reactive({ mobile: "", email: "" });
|
/** 所属部门=组路径(BoaUser.groups 是「挂载组→…→根」近→远链):取学校组(type=2)到链首的区段反向 join("/"),
|
||||||
/** userInfo 派生展示(手机/邮箱编辑值初始同源;工号暂以登录账号展示——接口未提供独立工号字段) */
|
* 如「云海小学/校长室」;链上无学校组(区域/学段直属)时回退挂载组名;链空再回退 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 profileView = computed(() => {
|
||||||
const u: any = store.userInfo || {};
|
const u: any = store.userInfo || {};
|
||||||
return {
|
return {
|
||||||
name: u.name || "-",
|
name: u.name || "-",
|
||||||
account: u.account || "-",
|
account: u.account || "-",
|
||||||
deptName: u.deptName || u.dept || "-",
|
deptName: deptPathOf(u),
|
||||||
phone: u.phone || "",
|
phone: u.phone || "",
|
||||||
email: u.email || "",
|
email: u.email || "",
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user