From 28b789eb861e7d39565c89650a0339bbd2bdfe2a Mon Sep 17 00:00:00 2001 From: Timi Date: Fri, 7 Aug 2026 16:02:29 +0800 Subject: [PATCH] update user detail --- src/api/ManagedUserAPI.ts | 26 +++- src/api/StoreAPI.ts | 5 + src/pages/management/ManagementProfile.vue | 15 +- src/pages/management/UserDetail.vue | 50 +++--- src/pages/management/UserEdit.vue | 104 ++++++++++++- src/pages/management/UserList.vue | 168 +++++++++++++-------- src/pages/management/UserRoleAssign.vue | 100 +++++++++--- src/pages/tabs/ManagementTab.vue | 26 ++-- src/store/currentStoreStore.ts | 39 ++++- src/store/permissionSettingsStore.ts | 6 +- src/utils/avatar.ts | 18 +++ src/utils/permission.ts | 6 + src/utils/store.ts | 5 +- 13 files changed, 421 insertions(+), 147 deletions(-) create mode 100644 src/utils/avatar.ts diff --git a/src/api/ManagedUserAPI.ts b/src/api/ManagedUserAPI.ts index 441bfef..9445c92 100644 --- a/src/api/ManagedUserAPI.ts +++ b/src/api/ManagedUserAPI.ts @@ -4,7 +4,26 @@ import { withCurrentStoreId, withCurrentStorePage } from "@/utils/store"; const BASE_URI = "/gao/user"; -async function list(page: Page): Promise> { +type ListOptions = { + allStores?: boolean; + storeId?: string; +}; + +async function list(page: Page, options?: ListOptions): Promise> { + if (options?.allStores) { + return await axios.post(`${BASE_URI}/list`, page); + } + + if (options?.storeId) { + return await axios.post(`${BASE_URI}/list`, { + ...page, + equalsExample: { + ...(page.equalsExample || {}), + storeId: options.storeId + } + }); + } + return await axios.post(`${BASE_URI}/list`, withCurrentStorePage(page)); } @@ -22,6 +41,10 @@ async function update(user: ManagedUser): Promise { return await axios.post(`${BASE_URI}/update`, withCurrentStoreId(user)); } +async function transferStore(user: ManagedUser): Promise { + return await axios.post(`${BASE_URI}/transfer/store`, user); +} + async function remove(id: string): Promise { return await axios.post(`${BASE_URI}/delete`, undefined, { params: { id } @@ -37,6 +60,7 @@ export default { detail, create, update, + transferStore, remove, roleList }; diff --git a/src/api/StoreAPI.ts b/src/api/StoreAPI.ts index ef80e84..d1470a6 100644 --- a/src/api/StoreAPI.ts +++ b/src/api/StoreAPI.ts @@ -14,6 +14,10 @@ async function detail(id: string): Promise { }); } +async function loginStore(): Promise { + return await axios.post(`${STORE_BASE_URI}/user`); +} + async function create(store: Store): Promise { return await axios.post(`${STORE_BASE_URI}/create`, store); } @@ -75,6 +79,7 @@ async function removeBusinessDay(id: string): Promise { export default { list, detail, + loginStore, create, update, sort, diff --git a/src/pages/management/ManagementProfile.vue b/src/pages/management/ManagementProfile.vue index 458a424..6f44eef 100644 --- a/src/pages/management/ManagementProfile.vue +++ b/src/pages/management/ManagementProfile.vue @@ -52,6 +52,7 @@ import { DialogPlugin, Toast } from "tdesign-mobile-vue"; import { AttachmentAPI, UserAPI, useUserStore } from "timi-web"; import PhotoField from "@/components/PhotoField.vue"; +import { buildFallbackAvatar } from "@/utils/avatar"; import { compressUploadImage } from "@/utils/imageCompression"; type UserAvatarSource = NonNullable[0]> & { @@ -223,21 +224,9 @@ function textToSex(text: string): number { return 0; } -function buildFallbackAvatar(name: string): string { - const text = encodeURIComponent((name.trim() || "用户").slice(0, 2)); - return [ - "data:image/svg+xml;charset=UTF-8,", - "%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E", - "%3Crect width='120' height='120' rx='24' fill='%230f766e'/%3E", - "%3Ctext x='50%25' y='54%25' fill='white' font-size='36' font-family='Arial,sans-serif' text-anchor='middle' dominant-baseline='middle'%3E", - text, - "%3C/text%3E%3C/svg%3E" - ].join(""); -} - function buildUserAvatar(user?: UserAvatarSource): string { const name = user?.nick || user?.name || "用户"; - return UserAPI.getAvatarURL(user) || buildFallbackAvatar(name); + return UserAPI.getAvatarURL(user) || buildFallbackAvatar(name, "#0f766e"); } onMounted(() => { diff --git a/src/pages/management/UserDetail.vue b/src/pages/management/UserDetail.vue index 6a5c2ab..4a98420 100644 --- a/src/pages/management/UserDetail.vue +++ b/src/pages/management/UserDetail.vue @@ -1,28 +1,34 @@