fix user profile update

This commit is contained in:
Timi
2026-08-07 18:20:29 +08:00
parent 82e717e3c6
commit 16fa5fdd36
10 changed files with 386 additions and 73 deletions
+24 -18
View File
@@ -2,32 +2,37 @@
<div class="management-tab">
<t-cell-group class="user-card" theme="card">
<t-cell
class="cell"
:title="currentUserName"
v-if="currentUser"
class="info"
arrow
hover
@click="go('/management/profile')"
>
<template #description>
<telephone-link v-if="currentUser?.phoneNo" :value="currentUser.phoneNo" />
<span v-else v-text="currentUserDesc" />
<div v-if="currentUser?.phoneNo" v-text="currentUser.phoneNo" />
</template>
<template #title>
<div class="header">
<div class="name" v-text="currentUser.name" />
<gender-icon :value="currentUser.gender" />
</div>
</template>
<template #leftIcon>
<t-image
class="avatar"
:src="currentUserAvatar"
:alt="currentUserName"
:alt="currentUser.name"
fit="cover"
/>
</template>
</t-cell>
<t-cell
v-if="canSelectStore"
v-if="canViewStore"
class="cell"
title="当前门店"
:note="currentStoreStore.currentStoreName"
arrow
hover
:arrow="canSelectStore"
:hover="canSelectStore"
@click="openStorePicker"
>
<template #leftIcon>
@@ -99,13 +104,10 @@ const currentStoreStore = useCurrentStoreStore();
const currentUser = computed(() => userStore.loginUser.user);
const currentUserName = computed(() => currentUser.value?.nick || currentUser.value?.name || "未登录用户");
const currentUserDesc = computed(() => currentUser.value?.phoneNo || currentUser.value?.email || "暂无联系方式");
const currentUserAvatar = computed(() => buildUserAvatar(currentUser.value));
const canSelectStore = computed(() => userStore.hasPermissions(permissionCodes.store.read));
const canSelectStore = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const canLoadLoginStore = computed(() => userStore.hasRoles([gaoRoleCodes.storeManager, gaoRoleCodes.employee], "or"));
const canViewStore = computed(() => canSelectStore.value || canLoadLoginStore.value);
const canManagePermission = computed(() => (
userStore.hasRoles(coreRoleCodes.admin) || userStore.hasRoles(coreRoleCodes.userRoleAdmin)
) && userStore.hasPermissions([
@@ -132,6 +134,10 @@ const storePickerColumns = computed(() => [
]);
function openStorePicker(): void {
if (!canSelectStore.value) {
return;
}
if (!currentStoreStore.storeList.length) {
Toast.warning("暂无可选门店");
return;
@@ -160,7 +166,7 @@ const menuGroupList = computed<MenuGroup[]>(() => [
icon: "shop",
path: "/management/stores",
title: "门店管理",
visible: userStore.hasPermissions(permissionCodes.store.read)
visible: canSelectStore.value && userStore.hasPermissions(permissionCodes.store.read)
},
{
icon: "usergroup",
@@ -226,7 +232,7 @@ const menuGroupList = computed<MenuGroup[]>(() => [
]);
function buildUserAvatar(user?: UserAvatarSource): string {
return UserAPI.getAvatarURL(user) || buildFallbackAvatar(currentUserName.value, "#0f766e");
return UserAPI.getAvatarURL(user) || buildFallbackAvatar(currentUser.value?.name, "#0f766e");
}
async function go(path: string): Promise<void> {
@@ -251,7 +257,7 @@ onMounted(async () => {
.user-card {
.cell {
.info {
padding: 10px;
.avatar {
@@ -260,9 +266,10 @@ onMounted(async () => {
border-radius: .875rem;
}
.title {
.header {
gap: .5rem;
display: flex;
align-items: center;
}
}
}
@@ -299,4 +306,3 @@ onMounted(async () => {
}
}
</style>