فهرست منبع

fix(@six/smart-pharmacy): 智慧药事系统第一版显示机构名称

cmj 1 ماه پیش
والد
کامیت
c28f089614
2فایلهای تغییر یافته به همراه22 افزوده شده و 7 حذف شده
  1. 9 7
      apps/smart-pharmacy/src/api/method/access.ts
  2. 13 0
      apps/smart-pharmacy/src/layouts/basic.vue

+ 9 - 7
apps/smart-pharmacy/src/api/method/access.ts

@@ -51,17 +51,19 @@ export function getUserInfoMethod(token?: string) {
       cacheFor: 0,
       headers: { Authorization: token },
       transform(data, headers) {
+        const user = data?.user ?? data;
+        const userId = user?.userId ?? user?.userid;
         return {
-          avatar: data?.headImage,
-          realName: '',
-          roles: data?.roles?.map(fromRole) ?? [],
-          userId: data?.userid,
-          username: data?.username,
-          // user
+          avatar: user?.avatar ?? user?.headImage ?? '',
+          realName: user?.nickName ?? '',
+          roles: (user?.roles ?? data?.roles)?.map(fromRole) ?? [],
+          userId: userId === undefined || userId === null ? '' : String(userId),
+          username: user?.userName ?? user?.username ?? '',
+          deptName: user?.dept?.deptName ?? '',
           token: token ?? headers.get('authorization') ?? '',
           homePath: '',
           desc: '',
-        } satisfies UserInfo;
+        } satisfies UserInfo & { deptName?: string };
       },
     },
   );

+ 13 - 0
apps/smart-pharmacy/src/layouts/basic.vue

@@ -32,6 +32,10 @@ const text = computed(() => {
   );
 });
 
+const deptName = computed(() => {
+  return (userStore.userInfo as { deptName?: string } | null)?.deptName ?? '';
+});
+
 async function handleLogout() {
   await authStore.logout(false);
 }
@@ -55,6 +59,15 @@ watch(
 
 <template>
   <BasicLayout @clear-preferences-and-logout="handleLogout">
+    <template #header-right-69>
+      <span
+        v-if="deptName"
+        class="text-foreground mr-2 max-w-[200px] truncate text-sm"
+        :title="deptName"
+      >
+        {{ deptName }}
+      </span>
+    </template>
     <template #user-dropdown>
       <UserDropdown
         :avatar