修复:全局治理雪花ID精度问题
This commit is contained in:
+70
-69
@@ -2,6 +2,7 @@ import axios, { AxiosError, type AxiosProgressEvent } from 'axios'
|
||||
import router from '../router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { ADMIN_API_BASE_URL } from '../config/api'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
let lastErrorTime = 0
|
||||
let lastErrorMessage = ''
|
||||
@@ -169,7 +170,7 @@ adminApi.interceptors.response.use(
|
||||
export interface AdminLoginRequest {
|
||||
account: string
|
||||
password: string
|
||||
shopId?: string | number
|
||||
shopId?: IdType
|
||||
}
|
||||
|
||||
export interface AdminLoginResponse {
|
||||
@@ -182,7 +183,7 @@ export interface LoginShopSelectionResponse {
|
||||
allowShoplessLogin: boolean
|
||||
message: string
|
||||
shops: Array<{
|
||||
id: number | string
|
||||
id: IdType
|
||||
shopName: string
|
||||
}>
|
||||
}
|
||||
@@ -197,7 +198,7 @@ export const adminAuthApi = {
|
||||
logout: () => {
|
||||
return adminApi.post<boolean>('/auth/logout')
|
||||
},
|
||||
switchShop: (shopId?: string | number) => {
|
||||
switchShop: (shopId?: IdType) => {
|
||||
return adminApi.post<AdminLoginResponse>('/auth/switch-shop', { shopId })
|
||||
},
|
||||
refreshToken: (refreshToken: string) => {
|
||||
@@ -206,7 +207,7 @@ export const adminAuthApi = {
|
||||
}
|
||||
|
||||
export interface ObjectStorageFileVO {
|
||||
id: number
|
||||
id: IdType
|
||||
fileName: string
|
||||
fileSize: number
|
||||
contentType: string
|
||||
@@ -264,18 +265,18 @@ export const adminFileApi = {
|
||||
cancelChunkUpload: (uploadId: string) => {
|
||||
return adminApi.delete<boolean>(`/object-storage-file/upload/${uploadId}`)
|
||||
},
|
||||
getSignedUrl: (id: number) => {
|
||||
getSignedUrl: (id: IdType) => {
|
||||
return adminApi.get<string>(`/object-storage-file/get-signed-url/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
id: number
|
||||
id: IdType
|
||||
tagName: string
|
||||
textColor?: string
|
||||
bgColor?: string
|
||||
borderColor?: string
|
||||
shopId?: number
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
@@ -285,33 +286,33 @@ export const adminTagApi = {
|
||||
listAllTags: () => {
|
||||
return adminApi.get<Tag[]>('/tag/list/all') as unknown as Promise<Tag[]>
|
||||
},
|
||||
listTagsByShopId: (shopId: number) => {
|
||||
listTagsByShopId: (shopId: IdType) => {
|
||||
return adminApi.get<Tag[]>(`/tag/list/by-shop/${shopId}`) as unknown as Promise<Tag[]>
|
||||
},
|
||||
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => {
|
||||
return adminApi.post<number>('/tag/create', data)
|
||||
createTag: (data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => {
|
||||
return adminApi.post<IdType>('/tag/create', data)
|
||||
},
|
||||
updateTag: (id: number, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: number }) => {
|
||||
updateTag: (id: IdType, data: { tagName: string; textColor?: string; bgColor?: string; borderColor?: string; shopId?: IdType }) => {
|
||||
return adminApi.put<boolean>(`/tag/update/${id}`, data)
|
||||
},
|
||||
deleteTag: (id: number) => {
|
||||
deleteTag: (id: IdType) => {
|
||||
return adminApi.delete<boolean>(`/tag/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Artist {
|
||||
id: number
|
||||
id: IdType
|
||||
nickname: string
|
||||
account: string
|
||||
avatar?: string
|
||||
shopId?: number
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
createTime: string
|
||||
updateTime: string
|
||||
}
|
||||
|
||||
export const adminArtistApi = {
|
||||
listArtists: (shopId?: number) => {
|
||||
listArtists: (shopId?: IdType) => {
|
||||
const params: any = {}
|
||||
if (shopId) {
|
||||
params.shopId = shopId
|
||||
@@ -321,7 +322,7 @@ export const adminArtistApi = {
|
||||
}
|
||||
|
||||
export interface Coupon {
|
||||
id: number
|
||||
id: IdType
|
||||
couponCode?: string
|
||||
couponName: string
|
||||
couponType: number
|
||||
@@ -336,7 +337,7 @@ export interface Coupon {
|
||||
endTime: string
|
||||
status?: number
|
||||
statusName?: string
|
||||
shopId?: number
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
couponScene?: string
|
||||
requiredVipLevel?: string
|
||||
@@ -348,17 +349,17 @@ export interface Coupon {
|
||||
}
|
||||
|
||||
export const adminCouponApi = {
|
||||
listAllCoupons: (shopId?: number) => {
|
||||
listAllCoupons: (shopId?: IdType) => {
|
||||
const params = shopId ? { shopId } : {}
|
||||
return adminApi.get<Coupon[]>('/coupon/list/all', { params }) as unknown as Promise<Coupon[]>
|
||||
},
|
||||
createCoupon: (data: any) => {
|
||||
return adminApi.post<number>('/coupon/create', data)
|
||||
return adminApi.post<IdType>('/coupon/create', data)
|
||||
},
|
||||
updateCoupon: (id: number, data: any) => {
|
||||
updateCoupon: (id: IdType, data: any) => {
|
||||
return adminApi.put<boolean>(`/coupon/update/${id}`, data)
|
||||
},
|
||||
deleteCoupon: (id: number) => {
|
||||
deleteCoupon: (id: IdType) => {
|
||||
return adminApi.delete<boolean>(`/coupon/delete/${id}`)
|
||||
},
|
||||
distributeCoupon: (data: any) => {
|
||||
@@ -367,8 +368,8 @@ export const adminCouponApi = {
|
||||
}
|
||||
|
||||
export interface Product {
|
||||
id: number
|
||||
shopId: number
|
||||
id: IdType
|
||||
shopId: IdType
|
||||
shopName?: string
|
||||
title: string
|
||||
description: string
|
||||
@@ -388,25 +389,25 @@ export interface Product {
|
||||
}
|
||||
|
||||
export const adminProductApi = {
|
||||
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: number }) => {
|
||||
listProducts: (params: { page: number; size: number; keyword?: string; shopId?: IdType }) => {
|
||||
return adminApi.get<{ list: Product[]; total: number; page: number; size: number }>('/product/list', { params })
|
||||
},
|
||||
listAllProducts: () => {
|
||||
return adminApi.get<Product[]>('/product/list/all')
|
||||
},
|
||||
createProduct: (data: any) => {
|
||||
return adminApi.post<number>('/product/create', data)
|
||||
return adminApi.post<IdType>('/product/create', data)
|
||||
},
|
||||
updateProduct: (id: number, data: any) => {
|
||||
updateProduct: (id: IdType, data: any) => {
|
||||
return adminApi.put<boolean>(`/product/update/${id}`, data)
|
||||
},
|
||||
deleteProduct: (id: number) => {
|
||||
deleteProduct: (id: IdType) => {
|
||||
return adminApi.delete<boolean>(`/product/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface Shop {
|
||||
id: number
|
||||
id: IdType
|
||||
shopName: string
|
||||
description: string
|
||||
address: string
|
||||
@@ -438,31 +439,31 @@ export interface CreateShopRequest {
|
||||
}
|
||||
|
||||
export const adminShopApi = {
|
||||
listShops: (params: { page: number; size: number; keyword?: string; shopId?: number }) => {
|
||||
listShops: (params: { page: number; size: number; keyword?: string; shopId?: IdType }) => {
|
||||
return adminApi.get<ShopListResponse>('/shops/list', { params }) as unknown as Promise<ShopListResponse>
|
||||
},
|
||||
listAllShops: () => {
|
||||
return adminApi.get<Shop[]>('/shops/list/all') as unknown as Promise<Shop[]>
|
||||
},
|
||||
createShop: (data: CreateShopRequest) => {
|
||||
return adminApi.post<number>('/shops/create', data)
|
||||
return adminApi.post<IdType>('/shops/create', data)
|
||||
},
|
||||
updateShop: (id: number, data: CreateShopRequest) => {
|
||||
updateShop: (id: IdType, data: CreateShopRequest) => {
|
||||
return adminApi.put<boolean>(`/shops/update/${id}`, data)
|
||||
},
|
||||
updateShopStatus: (id: number, status: number) => {
|
||||
updateShopStatus: (id: IdType, status: number) => {
|
||||
return adminApi.put<boolean>(`/shops/status/${id}`, { status })
|
||||
},
|
||||
deleteShop: (id: number) => {
|
||||
deleteShop: (id: IdType) => {
|
||||
return adminApi.delete<boolean>(`/shops/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserVO {
|
||||
id: number
|
||||
shopId?: number
|
||||
id: IdType
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
shopIds?: Array<number | string>
|
||||
shopIds?: IdType[]
|
||||
shopNames?: string[]
|
||||
nickname: string
|
||||
account: string
|
||||
@@ -471,7 +472,7 @@ export interface UserVO {
|
||||
signature?: string
|
||||
level?: string
|
||||
type: number
|
||||
vipId?: number
|
||||
vipId?: IdType
|
||||
createTime: string
|
||||
updateTime: string
|
||||
status?: number
|
||||
@@ -485,59 +486,59 @@ export interface PageResult<T> {
|
||||
}
|
||||
|
||||
export const adminUserApi = {
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: number; status?: number }) => {
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: IdType; status?: number }) => {
|
||||
return adminApi.get<PageResult<UserVO>>('/user/list', { params }) as unknown as Promise<PageResult<UserVO>>
|
||||
},
|
||||
listAllUsers: () => {
|
||||
return adminApi.get<UserVO[]>('/user/list/all') as unknown as Promise<UserVO[]>
|
||||
},
|
||||
createUser: (data: any) => {
|
||||
return adminApi.post<number>('/user/create', data)
|
||||
return adminApi.post<IdType>('/user/create', data)
|
||||
},
|
||||
updateUser: (id: number, data: any) => {
|
||||
updateUser: (id: IdType, data: any) => {
|
||||
return adminApi.put<boolean>(`/user/update/${id}`, data)
|
||||
},
|
||||
deleteUser: (id: number) => {
|
||||
deleteUser: (id: IdType) => {
|
||||
return adminApi.delete<boolean>(`/user/delete/${id}`)
|
||||
},
|
||||
unbindUser: (id: number) => {
|
||||
unbindUser: (id: IdType) => {
|
||||
return adminApi.put<boolean>(`/user/unbind/${id}`, {})
|
||||
},
|
||||
updateUserStatus: (id: number, status: number) => {
|
||||
updateUserStatus: (id: IdType, status: number) => {
|
||||
return adminApi.put<boolean>(`/user/status/${id}`, { status })
|
||||
},
|
||||
resetPassword: (id: number) => {
|
||||
resetPassword: (id: IdType) => {
|
||||
return adminApi.post<string>(`/user/reset-password/${id}`)
|
||||
},
|
||||
getUserInfo: () => {
|
||||
return adminApi.get<UserVO>('/user/info') as unknown as Promise<UserVO>
|
||||
},
|
||||
getUserAsset: (id: number) => {
|
||||
getUserAsset: (id: IdType) => {
|
||||
return adminApi.get<UserAssetVO>(`/user/${id}/asset`) as unknown as Promise<UserAssetVO>
|
||||
},
|
||||
getUserBalanceHistory: (id: number) => {
|
||||
getUserBalanceHistory: (id: IdType) => {
|
||||
return adminApi.get<UserBalanceHistoryItem[]>(`/user/${id}/balance/history`) as unknown as Promise<UserBalanceHistoryItem[]>
|
||||
},
|
||||
changeUserBalance: (id: number, data: AdminUserBalanceChangeRequest) => {
|
||||
changeUserBalance: (id: IdType, data: AdminUserBalanceChangeRequest) => {
|
||||
return adminApi.post<UserAssetVO>(`/user/${id}/balance/change`, data) as unknown as Promise<UserAssetVO>
|
||||
},
|
||||
overrideUserVip: (id: number, data: AdminUserVipOverrideRequest) => {
|
||||
overrideUserVip: (id: IdType, data: AdminUserVipOverrideRequest) => {
|
||||
return adminApi.post<UserAssetVO>(`/user/${id}/vip/override`, data) as unknown as Promise<UserAssetVO>
|
||||
},
|
||||
recalculateUserVip: (id: number) => {
|
||||
recalculateUserVip: (id: IdType) => {
|
||||
return adminApi.post<UserAssetVO>(`/user/${id}/vip/recalculate`) as unknown as Promise<UserAssetVO>
|
||||
}
|
||||
}
|
||||
|
||||
export interface UserAssetVO {
|
||||
userId: number
|
||||
userId: IdType
|
||||
nickname: string
|
||||
balance: number
|
||||
totalRechargeAmount: number
|
||||
lastRechargeTime?: string
|
||||
vipInfoId?: number
|
||||
vipInfoId?: IdType
|
||||
vipLevel: string
|
||||
benefitId?: number
|
||||
benefitId?: IdType
|
||||
benefitInfo?: string
|
||||
manualOverride: boolean
|
||||
vipStartTime?: string
|
||||
@@ -545,8 +546,8 @@ export interface UserAssetVO {
|
||||
}
|
||||
|
||||
export interface UserBalanceHistoryItem {
|
||||
id: number
|
||||
userId: number
|
||||
id: IdType
|
||||
userId: IdType
|
||||
userNickname?: string
|
||||
amount: number
|
||||
type?: string
|
||||
@@ -554,10 +555,10 @@ export interface UserBalanceHistoryItem {
|
||||
beforeBalance?: number
|
||||
afterBalance?: number
|
||||
changeScene?: string
|
||||
relatedOrderId?: number
|
||||
relatedOrderId?: IdType
|
||||
relatedOrderNo?: string
|
||||
externalOrderNo?: string
|
||||
operatorId?: number
|
||||
operatorId?: IdType
|
||||
remark?: string
|
||||
changeTime: string
|
||||
}
|
||||
@@ -565,7 +566,7 @@ export interface UserBalanceHistoryItem {
|
||||
export interface AdminUserBalanceChangeRequest {
|
||||
amount: number
|
||||
changeScene: string
|
||||
relatedOrderId?: number
|
||||
relatedOrderId?: IdType
|
||||
externalOrderNo?: string
|
||||
remark?: string
|
||||
}
|
||||
@@ -578,13 +579,13 @@ export interface AdminUserVipOverrideRequest {
|
||||
export const userApi = adminUserApi
|
||||
|
||||
export interface OrderVO {
|
||||
id: number
|
||||
id: IdType
|
||||
orderNo: string
|
||||
userId: number
|
||||
userId: IdType
|
||||
userNickname?: string
|
||||
shopId: number
|
||||
shopId: IdType
|
||||
shopName?: string
|
||||
artistId?: number
|
||||
artistId?: IdType
|
||||
artistName?: string
|
||||
totalAmount: number
|
||||
discountAmount: number
|
||||
@@ -597,16 +598,16 @@ export interface OrderVO {
|
||||
}
|
||||
|
||||
export const adminOrderApi = {
|
||||
listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: number }) => {
|
||||
listOrders: (params: { page: number; size: number; keyword?: string; status?: number; shopId?: IdType }) => {
|
||||
return adminApi.get<PageResult<OrderVO>>('/order/list', { params })
|
||||
},
|
||||
updateOrderStatus: (id: number, status: number) => {
|
||||
updateOrderStatus: (id: IdType, status: number) => {
|
||||
return adminApi.put<boolean>(`/order/update-status/${id}`, { status })
|
||||
}
|
||||
}
|
||||
|
||||
export interface HotProductVO {
|
||||
id: number
|
||||
id: IdType
|
||||
title: string
|
||||
price: number
|
||||
likeCount: number
|
||||
@@ -614,7 +615,7 @@ export interface HotProductVO {
|
||||
}
|
||||
|
||||
export interface RecentActivityVO {
|
||||
id: number
|
||||
id: IdType
|
||||
type: string
|
||||
title?: string
|
||||
description: string
|
||||
@@ -638,8 +639,8 @@ export const adminDashboardApi = {
|
||||
}
|
||||
|
||||
export interface NailArtistInfoVO {
|
||||
id: number | string
|
||||
userId: number | string
|
||||
id: IdType
|
||||
userId: IdType
|
||||
identity: string
|
||||
experience: number
|
||||
skills: string
|
||||
@@ -647,7 +648,7 @@ export interface NailArtistInfoVO {
|
||||
status: number
|
||||
portfolio: string
|
||||
nickname: string
|
||||
shopId: number | string
|
||||
shopId: IdType
|
||||
shopName: string
|
||||
}
|
||||
|
||||
@@ -655,7 +656,7 @@ export const adminNailArtistApi = {
|
||||
listNailArtists: () => {
|
||||
return adminApi.get<NailArtistInfoVO[]>('/nail-artist/list')
|
||||
},
|
||||
getNailArtistInfo: (userId: number) => {
|
||||
getNailArtistInfo: (userId: IdType) => {
|
||||
return adminApi.get<NailArtistInfoVO>(`/nail-artist/get/${userId}`)
|
||||
},
|
||||
saveNailArtistInfo: (data: any) => {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface SendVerificationCodeRequest {
|
||||
phone: string
|
||||
@@ -33,15 +34,15 @@ export interface LoginResponse {
|
||||
}
|
||||
|
||||
export interface UserInfo {
|
||||
id: number
|
||||
id: IdType
|
||||
account: string
|
||||
nickname: string
|
||||
avatar?: string
|
||||
signature?: string
|
||||
type?: number
|
||||
shopId?: number | string
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
shopIds?: Array<number | string>
|
||||
shopIds?: IdType[]
|
||||
shopNames?: string[]
|
||||
createTime: string
|
||||
updateTime?: string
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
interface CartItem {
|
||||
productId: number
|
||||
productId: IdType
|
||||
quantity: number
|
||||
}
|
||||
|
||||
@@ -12,12 +13,12 @@ export const cartApi = {
|
||||
},
|
||||
|
||||
// 从购物车移除作品
|
||||
removeFromCart: (productId: number) => {
|
||||
removeFromCart: (productId: IdType) => {
|
||||
return api.delete(`/cart/remove/${productId}`)
|
||||
},
|
||||
|
||||
// 批量从购物车移除作品
|
||||
batchRemoveFromCart: (cartItemIds: number[]) => {
|
||||
batchRemoveFromCart: (cartItemIds: IdType[]) => {
|
||||
return api.post('/cart/batch-remove', cartItemIds)
|
||||
},
|
||||
|
||||
|
||||
+15
-14
@@ -1,7 +1,8 @@
|
||||
import request from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface Coupon {
|
||||
id: number
|
||||
id: IdType
|
||||
couponCode: string
|
||||
couponName: string
|
||||
couponType: number
|
||||
@@ -16,7 +17,7 @@ export interface Coupon {
|
||||
endTime: string
|
||||
status: number
|
||||
statusName: string
|
||||
shopId?: number
|
||||
shopId?: IdType
|
||||
couponScene?: string
|
||||
requiredVipLevel?: string
|
||||
autoMatch?: number
|
||||
@@ -25,13 +26,13 @@ export interface Coupon {
|
||||
}
|
||||
|
||||
export interface Tag {
|
||||
id: number
|
||||
id: IdType
|
||||
tagName?: string
|
||||
}
|
||||
|
||||
export interface UserCoupon {
|
||||
id: number
|
||||
couponId: number
|
||||
id: IdType
|
||||
couponId: IdType
|
||||
couponName: string
|
||||
couponType: number
|
||||
couponTypeName: string
|
||||
@@ -62,8 +63,8 @@ export interface CreateCouponRequest {
|
||||
couponScene?: string
|
||||
requiredVipLevel?: string
|
||||
autoMatch?: number
|
||||
availableTagIds: number[]
|
||||
unavailableTagIds: number[]
|
||||
availableTagIds: IdType[]
|
||||
unavailableTagIds: IdType[]
|
||||
}
|
||||
|
||||
export interface CouponListResponse {
|
||||
@@ -84,7 +85,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 更新优惠券
|
||||
updateCoupon: (id: number, data: CreateCouponRequest) => {
|
||||
updateCoupon: (id: IdType, data: CreateCouponRequest) => {
|
||||
return request({
|
||||
url: `/coupon/update/${id}`,
|
||||
method: 'put',
|
||||
@@ -93,7 +94,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 删除优惠券
|
||||
deleteCoupon: (id: number) => {
|
||||
deleteCoupon: (id: IdType) => {
|
||||
return request({
|
||||
url: `/coupon/delete/${id}`,
|
||||
method: 'delete'
|
||||
@@ -101,7 +102,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 获取优惠券详情
|
||||
getCouponById: (id: number) => {
|
||||
getCouponById: (id: IdType) => {
|
||||
return request({
|
||||
url: `/coupon/detail/${id}`,
|
||||
method: 'get'
|
||||
@@ -109,7 +110,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 获取优惠券列表
|
||||
listCoupons: (params: { page: number; size: number; shopId?: number }) => {
|
||||
listCoupons: (params: { page: number; size: number; shopId?: IdType }) => {
|
||||
return request({
|
||||
url: '/coupon/list',
|
||||
method: 'get',
|
||||
@@ -118,7 +119,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 为用户分配优惠券
|
||||
assignCouponToUser: (userId: number, couponId: number) => {
|
||||
assignCouponToUser: (userId: IdType, couponId: IdType) => {
|
||||
return request({
|
||||
url: '/coupon/assign',
|
||||
method: 'post',
|
||||
@@ -136,7 +137,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 使用优惠券
|
||||
useCoupon: (userCouponId: number) => {
|
||||
useCoupon: (userCouponId: IdType) => {
|
||||
return request({
|
||||
url: '/coupon/use',
|
||||
method: 'post',
|
||||
@@ -145,7 +146,7 @@ export const couponApi = {
|
||||
},
|
||||
|
||||
// 获取作品可用的优惠券
|
||||
getAvailableCoupons: async (productTags: string, productPrice: number, shopId?: number): Promise<UserCoupon[]> => {
|
||||
getAvailableCoupons: async (productTags: string, productPrice: number, shopId?: IdType): Promise<UserCoupon[]> => {
|
||||
return await request({
|
||||
url: '/coupon/available',
|
||||
method: 'get',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { AxiosProgressEvent } from 'axios'
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface ChunkUploadInitRequest {
|
||||
fileName: string
|
||||
@@ -53,7 +54,7 @@ export const fileApi = {
|
||||
return api.delete<boolean>(`/user/upload-avatar/${uploadId}`)
|
||||
},
|
||||
|
||||
getSignedUrl: (fileId: number, expiryTimeInMinutes?: number) => {
|
||||
getSignedUrl: (fileId: IdType, expiryTimeInMinutes?: number) => {
|
||||
return api.get<string>(`/file/get-signed-url/${fileId}`, {
|
||||
params: { expiryTimeInMinutes }
|
||||
})
|
||||
|
||||
@@ -5,6 +5,7 @@ import { wishlistApi } from './wishlist'
|
||||
import router from '../router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { API_BASE_URL } from '../config/api'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
// 防重复提示标志
|
||||
let lastErrorTime = 0
|
||||
@@ -223,7 +224,7 @@ api.interceptors.response.use(
|
||||
)
|
||||
|
||||
export const fileApi = {
|
||||
getSignedUrl: (fileId: number, expiryTimeInMinutes?: number) => {
|
||||
getSignedUrl: (fileId: IdType, expiryTimeInMinutes?: number) => {
|
||||
return api.get<string>(`/file/get-signed-url/${fileId}`, {
|
||||
params: { expiryTimeInMinutes }
|
||||
})
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
interface OrderItem {
|
||||
productId: number
|
||||
productId: IdType
|
||||
quantity: number
|
||||
artistId?: number
|
||||
artistId?: IdType
|
||||
appointmentTime?: string
|
||||
}
|
||||
|
||||
interface CreateOrderRequest {
|
||||
couponId?: number
|
||||
couponId?: IdType
|
||||
couponSourceType?: string
|
||||
items: OrderItem[]
|
||||
}
|
||||
@@ -25,12 +26,12 @@ export const orderApi = {
|
||||
},
|
||||
|
||||
// 获取订单详情
|
||||
getOrderDetail: (orderId: number) => {
|
||||
getOrderDetail: (orderId: IdType) => {
|
||||
return api.get(`/order/detail/${orderId}`)
|
||||
},
|
||||
|
||||
// 取消订单
|
||||
cancelOrder: (orderId: number) => {
|
||||
cancelOrder: (orderId: IdType) => {
|
||||
return api.put(`/order/cancel/${orderId}`)
|
||||
},
|
||||
|
||||
@@ -40,7 +41,7 @@ export const orderApi = {
|
||||
},
|
||||
|
||||
// 后台处理订单
|
||||
processOrder: (orderId: number, status: number) => {
|
||||
processOrder: (orderId: IdType, status: number) => {
|
||||
return api.put(`/order/admin/process/${orderId}`, {}, {
|
||||
params: { status }
|
||||
})
|
||||
@@ -51,7 +52,7 @@ export const orderApi = {
|
||||
return api.get('/order/artist/list')
|
||||
},
|
||||
|
||||
completeArtistOrder: (orderId: number) => {
|
||||
completeArtistOrder: (orderId: IdType) => {
|
||||
return api.put(`/order/artist/complete/${orderId}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { adminApi } from './admin'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface PermissionVO {
|
||||
id: number
|
||||
id: IdType
|
||||
permissionCode: string
|
||||
permissionName: string
|
||||
permissionGroup: string
|
||||
@@ -25,15 +26,15 @@ export interface UpdatePermissionRequest {
|
||||
}
|
||||
|
||||
export const permissionApi = {
|
||||
getUserPermissions: (userId?: number) => {
|
||||
getUserPermissions: (userId?: IdType) => {
|
||||
if (userId) {
|
||||
return adminApi.get<PermissionVO[]>(`/permission/user/${userId}`)
|
||||
}
|
||||
return adminApi.get<PermissionVO[]>('/permission/user/current')
|
||||
},
|
||||
|
||||
getAssignablePermissionIds: (userId: number) => {
|
||||
return adminApi.get<number[]>(`/permission/assignable/${userId}`)
|
||||
getAssignablePermissionIds: (userId: IdType) => {
|
||||
return adminApi.get<IdType[]>(`/permission/assignable/${userId}`)
|
||||
},
|
||||
|
||||
listAllPermissions: () => {
|
||||
@@ -44,15 +45,15 @@ export const permissionApi = {
|
||||
return adminApi.post('/permission/create', data)
|
||||
},
|
||||
|
||||
updatePermission: (id: number, data: UpdatePermissionRequest) => {
|
||||
updatePermission: (id: IdType, data: UpdatePermissionRequest) => {
|
||||
return adminApi.put(`/permission/update/${id}`, data)
|
||||
},
|
||||
|
||||
deletePermission: (id: number) => {
|
||||
deletePermission: (id: IdType) => {
|
||||
return adminApi.delete(`/permission/delete/${id}`)
|
||||
},
|
||||
|
||||
assignUserPermissions: (userId: number, permissionIds: number[]) => {
|
||||
assignUserPermissions: (userId: IdType, permissionIds: IdType[]) => {
|
||||
return adminApi.post(`/permission/assign/${userId}`, { permissionIds })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface ProductVO {
|
||||
id: number
|
||||
shopId: number | null
|
||||
id: IdType
|
||||
shopId: IdType | null
|
||||
shopName?: string
|
||||
name: string
|
||||
title?: string
|
||||
@@ -29,7 +30,7 @@ export interface ProductVO {
|
||||
}
|
||||
|
||||
export interface TagInfo {
|
||||
id: number
|
||||
id: IdType
|
||||
tagName: string
|
||||
textColor?: string
|
||||
bgColor?: string
|
||||
@@ -50,7 +51,7 @@ export interface CreateProductRequest {
|
||||
estimatedTime: number
|
||||
category: string
|
||||
status: number
|
||||
shopId: number | null
|
||||
shopId: IdType | null
|
||||
}
|
||||
|
||||
export interface UpdateProductRequest {
|
||||
@@ -61,7 +62,7 @@ export interface UpdateProductRequest {
|
||||
estimatedTime?: number
|
||||
category?: string
|
||||
status?: number
|
||||
shopId?: number | null
|
||||
shopId?: IdType | null
|
||||
}
|
||||
|
||||
export const productApi = {
|
||||
@@ -69,7 +70,7 @@ export const productApi = {
|
||||
return await api.get<ProductVO[]>('/product/list/all') as unknown as ProductVO[]
|
||||
},
|
||||
|
||||
getProductById: async (id: number): Promise<ProductVO> => {
|
||||
getProductById: async (id: IdType): Promise<ProductVO> => {
|
||||
return await api.get<ProductVO>(`/product/get/${id}`) as unknown as ProductVO
|
||||
},
|
||||
|
||||
@@ -77,11 +78,11 @@ export const productApi = {
|
||||
return await api.get<ProductVO[]>(`/product/list/tag/${tag}`) as unknown as ProductVO[]
|
||||
},
|
||||
|
||||
likeProduct: async (productId: number): Promise<boolean> => {
|
||||
likeProduct: async (productId: IdType): Promise<boolean> => {
|
||||
return await api.post<boolean>(`/product/like/${productId}`) as unknown as boolean
|
||||
},
|
||||
|
||||
unlikeProduct: async (productId: number): Promise<boolean> => {
|
||||
unlikeProduct: async (productId: IdType): Promise<boolean> => {
|
||||
return await api.post<boolean>(`/product/unlike/${productId}`) as unknown as boolean
|
||||
},
|
||||
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export const productLikeApi = {
|
||||
/**
|
||||
* 点赞作品
|
||||
* @param productId 作品ID
|
||||
*/
|
||||
likeProduct: (productId: number) => {
|
||||
likeProduct: (productId: IdType) => {
|
||||
return api.post<boolean>(`/product-like/like/${productId}`)
|
||||
},
|
||||
|
||||
@@ -13,7 +14,7 @@ export const productLikeApi = {
|
||||
* 取消点赞作品
|
||||
* @param productId 作品ID
|
||||
*/
|
||||
unlikeProduct: (productId: number) => {
|
||||
unlikeProduct: (productId: IdType) => {
|
||||
return api.post<boolean>(`/product-like/unlike/${productId}`)
|
||||
},
|
||||
|
||||
@@ -21,7 +22,7 @@ export const productLikeApi = {
|
||||
* 检查用户是否已点赞作品
|
||||
* @param productId 作品ID
|
||||
*/
|
||||
checkLikeStatus: (productId: number) => {
|
||||
checkLikeStatus: (productId: IdType) => {
|
||||
return api.get<boolean>(`/product-like/check/${productId}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface ShopVO {
|
||||
id: number
|
||||
id: IdType
|
||||
shopName: string
|
||||
description: string
|
||||
address: string
|
||||
@@ -60,7 +61,7 @@ export const shopApi = {
|
||||
return await api.get<ShopSimpleVO[]>('/shop/list/simple') as unknown as ShopSimpleVO[]
|
||||
},
|
||||
|
||||
getShopById: async (id: number): Promise<ShopVO> => {
|
||||
getShopById: async (id: IdType): Promise<ShopVO> => {
|
||||
return await api.get<ShopVO>(`/shop/get/${id}`) as unknown as ShopVO
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface TagVO {
|
||||
id: number
|
||||
id: IdType
|
||||
tagName: string
|
||||
textColor: string
|
||||
bgColor: string
|
||||
@@ -22,7 +23,7 @@ export const tagApi = {
|
||||
return api.get<TagVO[]>('/tag/list/all')
|
||||
},
|
||||
|
||||
getTagById: (id: number) => {
|
||||
getTagById: (id: IdType) => {
|
||||
return api.get<TagVO>(`/tag/get/${id}`)
|
||||
},
|
||||
|
||||
@@ -30,11 +31,11 @@ export const tagApi = {
|
||||
return api.post<TagVO>('/tag/add', data)
|
||||
},
|
||||
|
||||
updateTag: (id: number, data: TagDTO) => {
|
||||
updateTag: (id: IdType, data: TagDTO) => {
|
||||
return api.put<TagVO>(`/tag/update/${id}`, data)
|
||||
},
|
||||
|
||||
deleteTag: (id: number) => {
|
||||
deleteTag: (id: IdType) => {
|
||||
return api.delete(`/tag/delete/${id}`)
|
||||
}
|
||||
}
|
||||
|
||||
+11
-10
@@ -1,11 +1,12 @@
|
||||
import api from './index'
|
||||
import type { UserInfo } from './auth'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface UserVO extends UserInfo {
|
||||
id: number
|
||||
shopId?: number
|
||||
id: IdType
|
||||
shopId?: IdType
|
||||
shopName?: string
|
||||
shopIds?: Array<number | string>
|
||||
shopIds?: IdType[]
|
||||
shopNames?: string[]
|
||||
nickname: string
|
||||
account: string
|
||||
@@ -13,7 +14,7 @@ export interface UserVO extends UserInfo {
|
||||
signature?: string
|
||||
level?: string
|
||||
type: number
|
||||
vipId?: number
|
||||
vipId?: IdType
|
||||
createTime: string
|
||||
updateTime: string
|
||||
status: number
|
||||
@@ -30,7 +31,7 @@ export interface ListUsersParams {
|
||||
page: number
|
||||
size: number
|
||||
keyword?: string
|
||||
shopId?: number
|
||||
shopId?: IdType
|
||||
status?: number
|
||||
}
|
||||
|
||||
@@ -40,8 +41,8 @@ export interface CreateUserRequest {
|
||||
phone: string
|
||||
password: string
|
||||
type: number
|
||||
shopId?: number
|
||||
shopIds?: Array<number | string>
|
||||
shopId?: IdType
|
||||
shopIds?: IdType[]
|
||||
}
|
||||
|
||||
export interface UpdateUserRequest {
|
||||
@@ -49,8 +50,8 @@ export interface UpdateUserRequest {
|
||||
nickname?: string
|
||||
phone?: string
|
||||
type?: number
|
||||
shopId?: number
|
||||
shopIds?: Array<number | string>
|
||||
shopId?: IdType
|
||||
shopIds?: IdType[]
|
||||
}
|
||||
|
||||
export interface UpdatePasswordRequest {
|
||||
@@ -78,7 +79,7 @@ export interface LoginShopSelectionResponse {
|
||||
allowShoplessLogin: boolean
|
||||
message: string
|
||||
shops: Array<{
|
||||
id: number | string
|
||||
id: IdType
|
||||
shopName: string
|
||||
}>
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import api from './index'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
export interface WishlistItem {
|
||||
id: number
|
||||
userId: number
|
||||
productId: number
|
||||
id: IdType
|
||||
userId: IdType
|
||||
productId: IdType
|
||||
product: {
|
||||
id: number
|
||||
shopId: number | null
|
||||
id: IdType
|
||||
shopId: IdType | null
|
||||
shopName?: string
|
||||
title: string
|
||||
description: string
|
||||
@@ -27,15 +28,15 @@ export interface WishlistItem {
|
||||
}
|
||||
|
||||
export const wishlistApi = {
|
||||
addToWishlist: async (productId: number): Promise<boolean> => {
|
||||
addToWishlist: async (productId: IdType): Promise<boolean> => {
|
||||
return await api.post<boolean>('/wishlist/add', { productId }) as unknown as boolean
|
||||
},
|
||||
|
||||
removeFromWishlist: async (productId: number): Promise<boolean> => {
|
||||
removeFromWishlist: async (productId: IdType): Promise<boolean> => {
|
||||
return await api.post<boolean>('/wishlist/remove', { productId }) as unknown as boolean
|
||||
},
|
||||
|
||||
checkWishlist: async (productId: number): Promise<boolean> => {
|
||||
checkWishlist: async (productId: IdType): Promise<boolean> => {
|
||||
return await api.get<boolean>(`/wishlist/check?productId=${productId}`) as unknown as boolean
|
||||
},
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
export type IdType = string | number
|
||||
|
||||
export const isEmptyId = (value: unknown): value is undefined | null | '' => {
|
||||
return value === undefined || value === null || `${value}`.trim() === ''
|
||||
}
|
||||
|
||||
export const toIdString = (value: IdType) => String(value)
|
||||
|
||||
export const toOptionalIdString = (value: unknown) => {
|
||||
if (isEmptyId(value)) {
|
||||
return undefined
|
||||
}
|
||||
return String(value).trim()
|
||||
}
|
||||
|
||||
export const sameId = (left: unknown, right: unknown) => {
|
||||
const leftId = toOptionalIdString(left)
|
||||
const rightId = toOptionalIdString(right)
|
||||
return leftId !== undefined && leftId === rightId
|
||||
}
|
||||
@@ -49,6 +49,7 @@ import { LeftOutlined } from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { fileApi } from '../api/index'
|
||||
import { orderApi } from '../api/order'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
const orders = ref<any[]>([])
|
||||
@@ -69,7 +70,7 @@ const loadOrders = async () => {
|
||||
if (!match?.[1]) continue
|
||||
const imageId = match[1]
|
||||
try {
|
||||
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(Number(imageId)) as any
|
||||
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
} catch {
|
||||
item.productImage = ''
|
||||
@@ -81,7 +82,7 @@ const loadOrders = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const completeOrder = (orderId: number) => {
|
||||
const completeOrder = (orderId: IdType) => {
|
||||
Modal.confirm({
|
||||
title: '确认完成服务',
|
||||
content: '确定要完成这个订单吗?',
|
||||
|
||||
@@ -403,6 +403,7 @@ import {
|
||||
type LoginAccountCheckResponse,
|
||||
type LoginShopSelectionResponse
|
||||
} from '@/api/user'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
|
||||
@@ -411,7 +412,7 @@ const loginType = ref<'password' | 'phone'>('password')
|
||||
const loading = ref(false)
|
||||
const loadingShops = ref(false)
|
||||
const shops = ref<any[]>([])
|
||||
const loginShops = ref<Array<{ id: number | string; shopName: string }>>([])
|
||||
const loginShops = ref<Array<{ id: IdType; shopName: string }>>([])
|
||||
const countdown = ref(0)
|
||||
const loginAccountStatus = ref<LoginAccountCheckResponse | null>(null)
|
||||
const registerAccountStatus = ref<AvailabilityCheckResponse | null>(null)
|
||||
|
||||
@@ -143,7 +143,7 @@
|
||||
:key="artist.id"
|
||||
type="button"
|
||||
class="artist-option"
|
||||
:class="{ active: draftArtistId === artist.id }"
|
||||
:class="{ active: sameId(draftArtistId, artist.id) }"
|
||||
@click="draftArtistId = artist.id"
|
||||
>
|
||||
<img v-if="artist.avatar" :src="artist.avatar" :alt="artist.name" />
|
||||
@@ -183,6 +183,8 @@ import { couponApi, type UserCoupon } from '../api/coupon'
|
||||
import { fileApi } from '../api/index'
|
||||
import { orderApi } from '../api/order'
|
||||
import { shopApi } from '../api/shop'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId, toOptionalIdString } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
@@ -190,15 +192,15 @@ const updateCartCount = inject<() => Promise<void>>('updateCartCount', async ()
|
||||
const NO_COUPON_KEY = 'NONE'
|
||||
|
||||
interface ArtistOption {
|
||||
id: number
|
||||
id: IdType
|
||||
name: string
|
||||
avatar?: string
|
||||
}
|
||||
|
||||
interface CartItem {
|
||||
id: number
|
||||
productId: number
|
||||
shopId?: number
|
||||
id: IdType
|
||||
productId: IdType
|
||||
shopId?: IdType
|
||||
productTitle: string
|
||||
productImage: string
|
||||
originalProductImage?: string
|
||||
@@ -214,19 +216,19 @@ interface CartItem {
|
||||
availableArtists?: ArtistOption[]
|
||||
appointmentTime?: string
|
||||
selected: boolean
|
||||
artistId?: number
|
||||
artistId?: IdType
|
||||
artist?: ArtistOption
|
||||
}
|
||||
|
||||
interface CheckoutIssue {
|
||||
key: string
|
||||
message: string
|
||||
itemId?: number
|
||||
itemId?: IdType
|
||||
}
|
||||
|
||||
const cartItems = ref<CartItem[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const itemRefs = ref<Record<number, HTMLElement>>({})
|
||||
const itemRefs = ref<Record<string, HTMLElement>>({})
|
||||
const availableCoupons = ref<UserCoupon[]>([])
|
||||
const selectedCoupon = ref<UserCoupon | null>(null)
|
||||
const couponSelectionKey = ref(NO_COUPON_KEY)
|
||||
@@ -235,7 +237,7 @@ const showCouponModal = ref(false)
|
||||
const showBookingModal = ref(false)
|
||||
const currentItem = ref<CartItem | null>(null)
|
||||
const availableArtists = ref<ArtistOption[]>([])
|
||||
const draftArtistId = ref<number>()
|
||||
const draftArtistId = ref<IdType>()
|
||||
const draftAppointmentTime = ref('')
|
||||
const currentShopHours = ref('')
|
||||
const editing = ref(false)
|
||||
@@ -269,16 +271,20 @@ const getDayBoundary = (date: Date) => {
|
||||
|
||||
const getCouponKey = (coupon: UserCoupon) => `${coupon.sourceType || 'USER_COUPON'}:${coupon.id}`
|
||||
|
||||
const setItemRef = (itemId: number, element: unknown) => {
|
||||
const setItemRef = (itemId: IdType, element: unknown) => {
|
||||
const refKey = toOptionalIdString(itemId)
|
||||
if (!refKey) {
|
||||
return
|
||||
}
|
||||
if (element && (element as any).$el) {
|
||||
itemRefs.value[itemId] = (element as any).$el as HTMLElement
|
||||
itemRefs.value[refKey] = (element as any).$el as HTMLElement
|
||||
return
|
||||
}
|
||||
if (element instanceof HTMLElement) {
|
||||
itemRefs.value[itemId] = element
|
||||
itemRefs.value[refKey] = element
|
||||
return
|
||||
}
|
||||
delete itemRefs.value[itemId]
|
||||
delete itemRefs.value[refKey]
|
||||
}
|
||||
|
||||
const formatCouponDisplay = (coupon: UserCoupon) => {
|
||||
@@ -332,11 +338,21 @@ const checkoutIssues = computed<CheckoutIssue[]>(() => {
|
||||
issues.push({ key: 'expired', message: `“${firstExpiredTime.productTitle}”的预约时间已过期,请重新选择`, itemId: firstExpiredTime.id })
|
||||
}
|
||||
|
||||
if (new Set(items.map(item => item.shopId).filter(Boolean)).size > 1) {
|
||||
const selectedShopIds = new Set(
|
||||
items
|
||||
.map(item => toOptionalIdString(item.shopId))
|
||||
.filter((shopId): shopId is string => Boolean(shopId))
|
||||
)
|
||||
if (selectedShopIds.size > 1) {
|
||||
issues.push({ key: 'shop', message: '跨店铺项目请分开结算', itemId: items[0]?.id })
|
||||
}
|
||||
|
||||
if (new Set(items.map(item => item.artistId).filter(Boolean)).size > 1) {
|
||||
const selectedArtistIds = new Set(
|
||||
items
|
||||
.map(item => toOptionalIdString(item.artistId))
|
||||
.filter((artistId): artistId is string => Boolean(artistId))
|
||||
)
|
||||
if (selectedArtistIds.size > 1) {
|
||||
issues.push({ key: 'artist-mix', message: '不同美甲师的项目请分开结算', itemId: items[0]?.id })
|
||||
}
|
||||
|
||||
@@ -344,10 +360,11 @@ const checkoutIssues = computed<CheckoutIssue[]>(() => {
|
||||
})
|
||||
|
||||
const scrollToIssue = (issue?: CheckoutIssue) => {
|
||||
if (!issue?.itemId) {
|
||||
const itemId = toOptionalIdString(issue?.itemId)
|
||||
if (!itemId) {
|
||||
return
|
||||
}
|
||||
const target = itemRefs.value[issue.itemId]
|
||||
const target = itemRefs.value[itemId]
|
||||
if (target) {
|
||||
target.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
||||
}
|
||||
@@ -381,7 +398,7 @@ const loadProductImages = async () => {
|
||||
const imageId = match[1]
|
||||
try {
|
||||
if (!imageIdCache.value[imageId]) {
|
||||
imageIdCache.value[imageId] = await fileApi.getSignedUrl(Number(imageId)) as any
|
||||
imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
|
||||
}
|
||||
item.productImage = imageIdCache.value[imageId] || ''
|
||||
} catch {
|
||||
@@ -464,7 +481,7 @@ const changeQuantity = async (item: CartItem, delta: number) => {
|
||||
const removeItem = async (item: CartItem) => {
|
||||
try {
|
||||
await cartApi.removeFromCart(item.productId)
|
||||
cartItems.value = cartItems.value.filter(current => current.id !== item.id)
|
||||
cartItems.value = cartItems.value.filter(current => !sameId(current.id, item.id))
|
||||
await Promise.all([loadAvailableCoupons(), updateCartCount()])
|
||||
message.success('作品已删除')
|
||||
} catch {
|
||||
@@ -505,18 +522,18 @@ const loadArtists = async (item: CartItem) => {
|
||||
? item.availableArtists
|
||||
.filter(artist => artist && artist.id !== undefined && artist.id !== null)
|
||||
.map(artist => ({
|
||||
id: Number(artist.id),
|
||||
id: artist.id,
|
||||
name: artist.name,
|
||||
avatar: artist.avatar
|
||||
}))
|
||||
: []
|
||||
|
||||
if (draftArtistId.value && !availableArtists.value.some(artist => artist.id === draftArtistId.value)) {
|
||||
if (draftArtistId.value && !availableArtists.value.some(artist => sameId(artist.id, draftArtistId.value))) {
|
||||
draftArtistId.value = undefined
|
||||
}
|
||||
}
|
||||
|
||||
const loadShopHours = async (shopId?: number) => {
|
||||
const loadShopHours = async (shopId?: IdType) => {
|
||||
currentShopHours.value = ''
|
||||
if (!shopId) return
|
||||
try {
|
||||
@@ -571,7 +588,7 @@ const confirmBooking = () => {
|
||||
if (!draftAppointmentTime.value) return message.warning('请选择预约时间')
|
||||
if (isPastAppointment(draftAppointmentTime.value)) return message.warning('预约时间至少需要晚于当前 5 分钟')
|
||||
currentItem.value.artistId = draftArtistId.value
|
||||
currentItem.value.artist = availableArtists.value.find(artist => artist.id === draftArtistId.value)
|
||||
currentItem.value.artist = availableArtists.value.find(artist => sameId(artist.id, draftArtistId.value))
|
||||
currentItem.value.appointmentTime = draftAppointmentTime.value
|
||||
closeBookingModal()
|
||||
}
|
||||
|
||||
@@ -138,17 +138,18 @@ import { productApi, type ProductVO } from '../api/product'
|
||||
import { shopApi, type ShopVO } from '../api/shop'
|
||||
import { fileApi } from '../api/file'
|
||||
import { DEFAULT_AVATAR, DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
interface BannerImage {
|
||||
id: string
|
||||
shopId: number
|
||||
shopId: IdType
|
||||
shopName: string
|
||||
businessHours?: string
|
||||
url: string
|
||||
}
|
||||
|
||||
interface ProductCardItem {
|
||||
id: number
|
||||
id: IdType
|
||||
name: string
|
||||
price: string
|
||||
meta: string
|
||||
@@ -187,7 +188,7 @@ const getProductCoverUrl = async (product: ProductVO): Promise<string> => {
|
||||
}
|
||||
if (!productImageCache.value[firstImageId]) {
|
||||
try {
|
||||
productImageCache.value[firstImageId] = await fileApi.getSignedUrl(Number(firstImageId)) as unknown as string
|
||||
productImageCache.value[firstImageId] = await fileApi.getSignedUrl(firstImageId) as unknown as string
|
||||
} catch (error) {
|
||||
console.error('获取首页作品封面失败:', error)
|
||||
productImageCache.value[firstImageId] = DEFAULT_PRODUCT_IMAGE
|
||||
@@ -250,11 +251,11 @@ const loadBannerImages = async () => {
|
||||
.filter(Boolean)
|
||||
for (const id of coverIds) {
|
||||
try {
|
||||
const url = await fileApi.getSignedUrl(Number(id)) as unknown as string
|
||||
const url = await fileApi.getSignedUrl(id) as unknown as string
|
||||
if (url) {
|
||||
banners.push({
|
||||
id: `${shop.id}-${id}`,
|
||||
shopId: Number(shop.id),
|
||||
shopId: shop.id,
|
||||
shopName: shop.shopName,
|
||||
businessHours: shop.businessHours,
|
||||
url
|
||||
@@ -339,7 +340,7 @@ const handleProductClick = (item: ProductCardItem) => {
|
||||
router.push(`/product/${item.id}`)
|
||||
}
|
||||
|
||||
const openShopById = (shopId: number) => {
|
||||
const openShopById = (shopId: IdType) => {
|
||||
router.push(`/shop/${shopId}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ import { LeftOutlined } from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { fileApi } from '../api/index'
|
||||
import { orderApi } from '../api/order'
|
||||
import type { IdType } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
const orders = ref<any[]>([])
|
||||
@@ -68,7 +69,7 @@ const loadOrders = async () => {
|
||||
if (!match?.[1]) continue
|
||||
const imageId = match[1]
|
||||
try {
|
||||
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(Number(imageId)) as any
|
||||
if (!imageIdCache.value[imageId]) imageIdCache.value[imageId] = await fileApi.getSignedUrl(imageId) as any
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
} catch {
|
||||
item.productImage = ''
|
||||
@@ -80,7 +81,7 @@ const loadOrders = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const cancelOrder = (orderId: number) => {
|
||||
const cancelOrder = (orderId: IdType) => {
|
||||
Modal.confirm({
|
||||
title: '确认取消订单',
|
||||
content: '确定要取消这个订单吗?',
|
||||
|
||||
@@ -148,6 +148,8 @@ import { productLikeApi } from '@/api/productLike'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { wishlistApi } from '@/api/wishlist'
|
||||
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { toOptionalIdString } from '@/utils/id'
|
||||
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
@@ -169,8 +171,8 @@ const artistCount = computed(() => {
|
||||
const rawValue = product.value.bookableArtists || ''
|
||||
return rawValue
|
||||
.split(',')
|
||||
.map(id => Number(id.trim()))
|
||||
.filter(id => Number.isFinite(id) && id > 0).length
|
||||
.map(id => id.trim())
|
||||
.filter(Boolean).length
|
||||
})
|
||||
const artistCountText = computed(() => {
|
||||
if (artistCount.value > 0) {
|
||||
@@ -264,7 +266,7 @@ const loadProductImages = async () => {
|
||||
for (const id of fileIds) {
|
||||
try {
|
||||
if (!imageIdCache.value[id]) {
|
||||
imageIdCache.value[id] = await fileApi.getSignedUrl(Number(id)) as unknown as string
|
||||
imageIdCache.value[id] = await fileApi.getSignedUrl(id) as unknown as string
|
||||
}
|
||||
if (imageIdCache.value[id]) {
|
||||
urls.push(imageIdCache.value[id])
|
||||
@@ -277,13 +279,13 @@ const loadProductImages = async () => {
|
||||
productImages.value = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
|
||||
const loadShopInfo = async (shopId?: number | null) => {
|
||||
const loadShopInfo = async (shopId?: IdType | null) => {
|
||||
if (!shopId) {
|
||||
shopInfo.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const response = await shopApi.getShopById(Number(shopId))
|
||||
const response = await shopApi.getShopById(shopId)
|
||||
shopInfo.value = response || null
|
||||
} catch (error) {
|
||||
console.error('获取门店信息失败:', error)
|
||||
@@ -333,7 +335,10 @@ const resolveLoadError = (error: any) => {
|
||||
const fetchProductDetail = async () => {
|
||||
loadError.value = ''
|
||||
try {
|
||||
const productId = Number(route.params.id)
|
||||
const productId = toOptionalIdString(route.params.id)
|
||||
if (!productId) {
|
||||
throw new Error('作品ID不存在')
|
||||
}
|
||||
const response = await productApi.getProductById(productId)
|
||||
if (!response?.id) {
|
||||
throw new Error('未找到对应作品')
|
||||
|
||||
@@ -143,7 +143,7 @@ const loading = ref(false)
|
||||
const showSearch = ref(false)
|
||||
const searchKeyword = ref('')
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const imageUrls = ref<Record<number, string[]>>({})
|
||||
const imageUrls = ref<Record<string, string[]>>({})
|
||||
|
||||
const isLoggedIn = computed(() => Boolean(localStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')))
|
||||
const activeBannerText = computed(() => {
|
||||
@@ -170,7 +170,7 @@ const ensureLoginForAction = (actionText: string) => {
|
||||
const loadImageUrls = async (productList: ProductVO[]) => {
|
||||
for (const product of productList) {
|
||||
if (!product.imageFileIds) {
|
||||
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
imageUrls.value[String(product.id)] = [DEFAULT_PRODUCT_IMAGE]
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ const loadImageUrls = async (productList: ProductVO[]) => {
|
||||
for (const id of ids) {
|
||||
try {
|
||||
if (!imageIdCache.value[id]) {
|
||||
imageIdCache.value[id] = await fileApi.getSignedUrl(Number(id)) as unknown as string
|
||||
imageIdCache.value[id] = await fileApi.getSignedUrl(id) as unknown as string
|
||||
}
|
||||
if (imageIdCache.value[id]) {
|
||||
urls.push(imageIdCache.value[id])
|
||||
@@ -190,11 +190,11 @@ const loadImageUrls = async (productList: ProductVO[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
imageUrls.value[product.id] = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
|
||||
imageUrls.value[String(product.id)] = urls.length ? urls : [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
}
|
||||
|
||||
const getProductImages = (product: ProductVO): string[] => imageUrls.value[product.id] || [DEFAULT_PRODUCT_IMAGE]
|
||||
const getProductImages = (product: ProductVO): string[] => imageUrls.value[String(product.id)] || [DEFAULT_PRODUCT_IMAGE]
|
||||
|
||||
const fetchTags = async () => {
|
||||
try {
|
||||
|
||||
@@ -70,12 +70,13 @@ import { LeftOutlined, ShopOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { shopApi, type ShopVO } from '@/api/shop'
|
||||
import { fileApi } from '@/api/file'
|
||||
import { toOptionalIdString } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
|
||||
const shopInfo = ref<ShopVO>({
|
||||
id: 0,
|
||||
id: '',
|
||||
shopName: '',
|
||||
description: '',
|
||||
address: '',
|
||||
@@ -124,13 +125,13 @@ const loadShopImages = async () => {
|
||||
if (imageFileIds) {
|
||||
const fileIds = imageFileIds.split(',').filter(id => id.trim())
|
||||
const fileIdPromises = fileIds.map(idStr => {
|
||||
const fileId = parseInt(idStr)
|
||||
if (!isNaN(fileId)) {
|
||||
return fileApi.getSignedUrl(fileId).catch(() => {
|
||||
return null
|
||||
})
|
||||
const fileId = idStr.trim()
|
||||
if (!fileId) {
|
||||
return null
|
||||
}
|
||||
return null
|
||||
return fileApi.getSignedUrl(fileId).catch(() => {
|
||||
return null
|
||||
})
|
||||
})
|
||||
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
@@ -149,14 +150,14 @@ const loadShopImages = async () => {
|
||||
const fetchShopDetail = async () => {
|
||||
try {
|
||||
// 从路由参数或本地存储获取店铺ID
|
||||
const shopId = route.params.id || localStorage.getItem('userShopId')
|
||||
const shopId = toOptionalIdString(route.params.id || localStorage.getItem('userShopId'))
|
||||
if (!shopId) {
|
||||
message.error('店铺ID不存在')
|
||||
router.back()
|
||||
return
|
||||
}
|
||||
|
||||
const response = await shopApi.getShopById(Number(shopId)) as any
|
||||
const response = await shopApi.getShopById(shopId) as any
|
||||
shopInfo.value = response || {}
|
||||
|
||||
// 加载店铺图片
|
||||
|
||||
@@ -53,13 +53,15 @@ import { ElMessage } from 'element-plus'
|
||||
import { wishlistApi, type WishlistItem } from '@/api/wishlist'
|
||||
import { cartApi } from '@/api/cart'
|
||||
import { fileApi } from '@/api/file'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
|
||||
const router = useRouter()
|
||||
const updateCartCount = inject<() => Promise<void>>('updateCartCount', async () => {})
|
||||
|
||||
const wishlistItems = ref<WishlistItem[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const imageUrls = ref<Record<number, string[]>>({})
|
||||
const imageUrls = ref<Record<string, string[]>>({})
|
||||
const DEFAULT_PRODUCT_IMAGE = 'data:image/svg+xml;base64,PHN2ZyB3aW0dPSJodHRwOi8vd3d3Lm9yZy8yMDAwL3N2ZyI+Pjwvc3ZnPg=='
|
||||
|
||||
const handleBackClick = () => {
|
||||
@@ -87,7 +89,7 @@ const loadImageUrls = async (items: WishlistItem[]) => {
|
||||
if (id) {
|
||||
try {
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await fileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await fileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
if (imageIdCache.value[id]) {
|
||||
@@ -100,18 +102,18 @@ const loadImageUrls = async (items: WishlistItem[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
imageUrls.value[item.product.id] = urls
|
||||
imageUrls.value[String(item.product.id)] = urls
|
||||
} else {
|
||||
imageUrls.value[item.product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
imageUrls.value[String(item.product.id)] = [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getProductImages = (product: any): string[] => {
|
||||
return imageUrls.value[product.id] || [DEFAULT_PRODUCT_IMAGE]
|
||||
return imageUrls.value[String(product.id)] || [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
|
||||
const handleAddToCart = async (productId: number) => {
|
||||
const handleAddToCart = async (productId: IdType) => {
|
||||
try {
|
||||
await cartApi.addToCart({ productId, quantity: 1 })
|
||||
await updateCartCount()
|
||||
@@ -122,10 +124,10 @@ const handleAddToCart = async (productId: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleRemoveItem = async (productId: number) => {
|
||||
const handleRemoveItem = async (productId: IdType) => {
|
||||
try {
|
||||
await wishlistApi.removeFromWishlist(productId)
|
||||
wishlistItems.value = wishlistItems.value.filter(item => item.productId !== productId)
|
||||
wishlistItems.value = wishlistItems.value.filter(item => !sameId(item.productId, productId))
|
||||
ElMessage.success('已从收藏中移除')
|
||||
} catch (error) {
|
||||
console.error('移除收藏失败:', error)
|
||||
@@ -137,7 +139,7 @@ const handleBrowseProducts = () => {
|
||||
router.push('/products')
|
||||
}
|
||||
|
||||
const handleProductClick = (productId: number) => {
|
||||
const handleProductClick = (productId: IdType) => {
|
||||
router.push(`/product/${productId}`)
|
||||
}
|
||||
|
||||
|
||||
@@ -84,13 +84,14 @@ import type { FormInstance } from 'ant-design-vue'
|
||||
import { UserOutlined, LockOutlined } from '@ant-design/icons-vue'
|
||||
import { adminAuthApi, type LoginShopSelectionResponse } from '@/api/admin'
|
||||
import { ACCOUNT_REGEX, ACCOUNT_RULE_MESSAGE, sanitizeAccountInput } from '@/utils/account'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const router = useRouter()
|
||||
const formRef = ref<FormInstance>()
|
||||
const loading = ref(false)
|
||||
const shopLoading = ref(false)
|
||||
const shops = ref<Array<{ id: number | string; shopName: string }>>([])
|
||||
const shops = ref<Array<{ id: IdType; shopName: string }>>([])
|
||||
const allowShoplessLogin = ref(false)
|
||||
const loginShopMessage = ref('')
|
||||
const { loadUserPermissions } = usePermission()
|
||||
@@ -109,8 +110,8 @@ const handleAccountInput = () => {
|
||||
}
|
||||
}
|
||||
|
||||
const getShopIdValue = (shop: { id: number | string; shopName: string }) => String(shop.id ?? '')
|
||||
const getShopLabel = (shop: { id: number | string; shopName: string }) => String(shop.shopName || `店铺 ${shop.id}`)
|
||||
const getShopIdValue = (shop: { id: IdType; shopName: string }) => String(shop.id ?? '')
|
||||
const getShopLabel = (shop: { id: IdType; shopName: string }) => String(shop.shopName || `店铺 ${shop.id}`)
|
||||
|
||||
const shopOptions = computed(() =>
|
||||
shops.value.map(shop => ({
|
||||
|
||||
@@ -68,6 +68,8 @@ import { computed, onMounted, ref } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { orderApi } from '../../api/order'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
|
||||
const orders = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
@@ -133,13 +135,13 @@ const loadOrders = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const process = async (orderId: number, status: number) => {
|
||||
const process = async (orderId: IdType, status: number) => {
|
||||
try {
|
||||
await orderApi.processOrder(orderId, status)
|
||||
message.success('操作成功')
|
||||
await loadOrders()
|
||||
if (currentOrder.value?.id === orderId) {
|
||||
currentOrder.value = orders.value.find(order => order.id === orderId) || null
|
||||
if (sameId(currentOrder.value?.id, orderId)) {
|
||||
currentOrder.value = orders.value.find(order => sameId(order.id, orderId)) || null
|
||||
}
|
||||
} catch {
|
||||
message.error('操作失败')
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
>
|
||||
<template #renderItem="{ item }">
|
||||
<a-list-item
|
||||
:class="{ selected: selectedUser?.id === item.id }"
|
||||
:class="{ selected: sameId(selectedUser?.id, item.id) }"
|
||||
style="cursor: pointer;"
|
||||
@click="selectUser(item)"
|
||||
>
|
||||
@@ -220,6 +220,8 @@ import { userApi, type UserVO } from '@/api/admin'
|
||||
import { permissionApi, type PermissionVO } from '@/api/permission'
|
||||
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
|
||||
@@ -304,14 +306,14 @@ const userSearchText = ref('')
|
||||
const userList = ref<UserVO[]>([])
|
||||
const selectedUser = ref<UserVO | null>(null)
|
||||
const assignLoading = ref(false)
|
||||
const selectedPermissions = ref<number[]>([])
|
||||
const assignablePermissionIds = ref<number[]>([])
|
||||
const selectedPermissions = ref<IdType[]>([])
|
||||
const assignablePermissionIds = ref<IdType[]>([])
|
||||
const activeCollapseKeys = ref<string[]>(['作品管理', '店铺管理', '用户管理', '权限管理'])
|
||||
const currentLoginUser = ref<UserVO | null>(null)
|
||||
|
||||
const assignablePermissionIdSet = computed(() => new Set(assignablePermissionIds.value))
|
||||
const assignablePermissionIdSet = computed(() => new Set(assignablePermissionIds.value.map(id => String(id))))
|
||||
const disabledPermissionCount = computed(() =>
|
||||
permissionList.value.filter(permission => !assignablePermissionIdSet.value.has(permission.id)).length
|
||||
permissionList.value.filter(permission => !assignablePermissionIdSet.value.has(String(permission.id))).length
|
||||
)
|
||||
|
||||
const groupedPermissions = computed(() => {
|
||||
@@ -343,12 +345,12 @@ const filteredUserList = computed(() => {
|
||||
|
||||
// 管理员可以看到所有用户(除了普通用户和自己)
|
||||
if (currentLoginUser.value.type === 4) {
|
||||
return userList.value.filter(user => user.type !== 0 && user.id !== currentUserId)
|
||||
return userList.value.filter(user => user.type !== 0 && !sameId(user.id, currentUserId))
|
||||
}
|
||||
|
||||
// 店长只能看到美甲师(除了自己)
|
||||
if (currentLoginUser.value.type === 2) {
|
||||
return userList.value.filter(user => user.type === 3 && user.id !== currentUserId)
|
||||
return userList.value.filter(user => user.type === 3 && !sameId(user.id, currentUserId))
|
||||
}
|
||||
|
||||
// 其他用户类型(如美甲师)不能管理权限
|
||||
@@ -359,7 +361,7 @@ const isPermissionDisabled = (permission: PermissionVO) => {
|
||||
if (!selectedUser.value) {
|
||||
return true
|
||||
}
|
||||
return !assignablePermissionIdSet.value.has(permission.id)
|
||||
return !assignablePermissionIdSet.value.has(String(permission.id))
|
||||
}
|
||||
|
||||
const resolveRequestErrorMessage = (error: any, fallback: string) => {
|
||||
@@ -443,12 +445,12 @@ const selectUser = async (user: UserVO) => {
|
||||
try {
|
||||
const [assignedPermissions, allowedIds] = await Promise.all([
|
||||
permissionApi.getUserPermissions(user.id) as unknown as Promise<PermissionVO[]>,
|
||||
permissionApi.getAssignablePermissionIds(user.id) as unknown as Promise<number[]>
|
||||
permissionApi.getAssignablePermissionIds(user.id) as unknown as Promise<IdType[]>
|
||||
])
|
||||
assignablePermissionIds.value = allowedIds || []
|
||||
const allowedIdSet = new Set(assignablePermissionIds.value)
|
||||
const allowedIdSet = new Set(assignablePermissionIds.value.map(id => String(id)))
|
||||
const assignedIds = (assignedPermissions || []).map((p: PermissionVO) => p.id)
|
||||
selectedPermissions.value = assignedIds.filter(id => allowedIdSet.has(id))
|
||||
selectedPermissions.value = assignedIds.filter(id => allowedIdSet.has(String(id)))
|
||||
const trimmedCount = assignedIds.length - selectedPermissions.value.length
|
||||
if (trimmedCount > 0) {
|
||||
message.warning(`已自动排除 ${trimmedCount} 项超出当前角色允许范围的权限`)
|
||||
|
||||
@@ -410,6 +410,8 @@ import { createChunkUploadTask, type ChunkUploadTask } from '@/utils/chunk-uploa
|
||||
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
import { MAX_IMAGE_UPLOAD_SIZE, compressImageIfNeeded, formatFileSize } from '@/utils/image-upload'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
const loading = ref(false)
|
||||
@@ -432,7 +434,7 @@ const previewVisible = ref(false)
|
||||
const previewImage = ref('')
|
||||
const imageFileList = ref<any[]>([])
|
||||
const uploadedFileIds = ref<string[]>([])
|
||||
const imageUrls = ref<Record<number, string[]>>({})
|
||||
const imageUrls = ref<Record<string, string[]>>({})
|
||||
const viewImageUrls = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const isAdmin = ref(false)
|
||||
@@ -498,7 +500,7 @@ const columns = [
|
||||
{ title: '操作', key: 'actions', width: 150, fixed: 'right' as const }
|
||||
]
|
||||
|
||||
const getShopName = (shopId: number): string => {
|
||||
const getShopName = (shopId: IdType): string => {
|
||||
const normalizedShopId = normalizeShopIdValue(shopId)
|
||||
const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId)
|
||||
return shop ? shop.shopName : '未知店铺'
|
||||
@@ -549,7 +551,7 @@ const fetchShops = async () => {
|
||||
// 根据用户权限控制店铺列表的显示
|
||||
if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
|
||||
// 如果是店长,只显示用户所属的店铺
|
||||
shops.value = res?.filter((shop: any) => shop.id === currentUser.shopId) || []
|
||||
shops.value = res?.filter((shop: any) => sameId(shop.id, currentUser.shopId)) || []
|
||||
// 默认选择用户所属的店铺,并且不可修改
|
||||
formState.shopId = currentUser.shopId
|
||||
} else {
|
||||
@@ -565,7 +567,7 @@ const fetchShops = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchTags = async (shopId?: number) => {
|
||||
const fetchTags = async (shopId?: IdType) => {
|
||||
loadingTags.value = true
|
||||
try {
|
||||
let response
|
||||
@@ -583,7 +585,7 @@ const fetchTags = async (shopId?: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const fetchArtists = async (shopId?: number) => {
|
||||
const fetchArtists = async (shopId?: IdType) => {
|
||||
loadingArtists.value = true
|
||||
try {
|
||||
const response = await adminArtistApi.listArtists(shopId) as any
|
||||
@@ -600,13 +602,13 @@ const syncAvailableCouponSelection = () => {
|
||||
const availableCouponIdSet = new Set(
|
||||
coupons.value
|
||||
.map(coupon => coupon?.id)
|
||||
.filter((id): id is number => id !== undefined && id !== null)
|
||||
.filter((id): id is IdType => id !== undefined && id !== null)
|
||||
.map(id => String(id))
|
||||
)
|
||||
formState.availableCoupons = formState.availableCoupons.filter(couponId => availableCouponIdSet.has(String(couponId)))
|
||||
}
|
||||
|
||||
const fetchCoupons = async (shopId?: number) => {
|
||||
const fetchCoupons = async (shopId?: IdType) => {
|
||||
if (!shopId) {
|
||||
coupons.value = []
|
||||
formState.availableCoupons = []
|
||||
@@ -664,7 +666,7 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
const response = await adminFileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
@@ -676,11 +678,11 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
}
|
||||
|
||||
if (product.id) {
|
||||
imageUrls.value[product.id] = urls
|
||||
imageUrls.value[String(product.id)] = urls
|
||||
}
|
||||
} else {
|
||||
if (product.id) {
|
||||
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
imageUrls.value[String(product.id)] = [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -689,7 +691,7 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
const getProductImages = (product: Product | Record<string, any>): string[] => {
|
||||
const productId = 'id' in product ? product.id : (product as any).id
|
||||
if (productId !== undefined) {
|
||||
return imageUrls.value[productId] || [DEFAULT_PRODUCT_IMAGE]
|
||||
return imageUrls.value[String(productId)] || [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
return [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
@@ -827,7 +829,7 @@ const showViewModal = async (record: Product | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as unknown as string
|
||||
const response = await adminFileApi.getSignedUrl(id) as unknown as string
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
@@ -881,7 +883,7 @@ const buildImageFileListByIds = async (ids: string[]) => {
|
||||
for (const [index, id] of ids.entries()) {
|
||||
try {
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(id) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
fileList.push({
|
||||
@@ -1062,7 +1064,7 @@ const handlePreview = async (file: any) => {
|
||||
}
|
||||
|
||||
if (!imageIdCache.value[fileId]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(fileId)) as any
|
||||
const response = await adminFileApi.getSignedUrl(fileId) as any
|
||||
imageIdCache.value[fileId] = response
|
||||
}
|
||||
|
||||
@@ -1163,7 +1165,7 @@ const handleSelectAllCoupons = () => {
|
||||
}
|
||||
formState.availableCoupons = coupons.value
|
||||
.map(coupon => coupon?.id)
|
||||
.filter((id): id is number => id !== undefined && id !== null)
|
||||
.filter((id): id is IdType => id !== undefined && id !== null)
|
||||
.map(id => String(id))
|
||||
}
|
||||
|
||||
|
||||
@@ -326,8 +326,8 @@ const bannerPreviewImage = ref('')
|
||||
const imageFileList = ref<any[]>([])
|
||||
const uploadedFileIds = ref<string[]>([])
|
||||
const imageIdCache = ref<Record<string, string>>({})
|
||||
const shopImageUrls = ref<Record<number, string[]>>({})
|
||||
const shopBannerUrls = ref<Record<number, string[]>>({})
|
||||
const shopImageUrls = ref<Record<string, string[]>>({})
|
||||
const shopBannerUrls = ref<Record<string, string[]>>({})
|
||||
const viewImageUrls = ref<string[]>([])
|
||||
const viewBannerUrls = ref<string[]>([])
|
||||
const previewVisible = ref(false)
|
||||
@@ -426,7 +426,7 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
const response = await adminFileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
@@ -438,11 +438,11 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
}
|
||||
|
||||
if (shop.id !== undefined) {
|
||||
shopImageUrls.value[shop.id] = urls
|
||||
shopImageUrls.value[String(shop.id)] = urls
|
||||
}
|
||||
} else {
|
||||
if (shop.id !== undefined) {
|
||||
shopImageUrls.value[shop.id] = []
|
||||
shopImageUrls.value[String(shop.id)] = []
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
const response = await adminFileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
@@ -468,11 +468,11 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
}
|
||||
|
||||
if (shop.id !== undefined) {
|
||||
shopBannerUrls.value[shop.id] = urls
|
||||
shopBannerUrls.value[String(shop.id)] = urls
|
||||
}
|
||||
} else {
|
||||
if (shop.id !== undefined) {
|
||||
shopBannerUrls.value[shop.id] = []
|
||||
shopBannerUrls.value[String(shop.id)] = []
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -481,7 +481,7 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
const getShopImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
if (shopId !== undefined) {
|
||||
return shopImageUrls.value[shopId] || []
|
||||
return shopImageUrls.value[String(shopId)] || []
|
||||
}
|
||||
return []
|
||||
}
|
||||
@@ -489,7 +489,7 @@ const getShopImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
if (shopId !== undefined) {
|
||||
return shopBannerUrls.value[shopId] || []
|
||||
return shopBannerUrls.value[String(shopId)] || []
|
||||
}
|
||||
return []
|
||||
}
|
||||
@@ -600,7 +600,7 @@ const handleBannerPreview = async (file: any) => {
|
||||
}
|
||||
|
||||
if (!imageIdCache.value[fileId]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(fileId)) as any
|
||||
const response = await adminFileApi.getSignedUrl(fileId) as any
|
||||
imageIdCache.value[fileId] = response
|
||||
}
|
||||
bannerPreviewImage.value = imageIdCache.value[fileId] || ''
|
||||
@@ -680,7 +680,7 @@ const handlePreview = async (file: any) => {
|
||||
}
|
||||
|
||||
if (!imageIdCache.value[fileId]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(fileId)) as any
|
||||
const response = await adminFileApi.getSignedUrl(fileId) as any
|
||||
imageIdCache.value[fileId] = response
|
||||
}
|
||||
previewImage.value = imageIdCache.value[fileId] || ''
|
||||
@@ -805,7 +805,7 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
const response = await adminFileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
@@ -829,7 +829,7 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
const response = await adminFileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
@@ -879,7 +879,7 @@ const buildShopUploadFileList = async (ids: string[], fileNamePrefix: string) =>
|
||||
for (const [index, id] of ids.entries()) {
|
||||
try {
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
const response = await adminFileApi.getSignedUrl(id.trim()) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
fileList.push({
|
||||
|
||||
@@ -192,6 +192,7 @@ import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import DraftActions from '@/components/DraftActions.vue'
|
||||
import { adminTagApi, adminShopApi, type Shop } from '@/api/admin'
|
||||
import { buildDraftStorageKey, clearDraftRecord, loadDraftRecord, saveDraftRecord } from '@/utils/form-draft'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
@@ -340,7 +341,7 @@ const normalizeShopIdValue = (value: string | number | undefined | null) => {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
const getShopName = (shopId: number | string | undefined) => {
|
||||
const getShopName = (shopId: IdType | undefined) => {
|
||||
const normalizedShopId = normalizeShopIdValue(shopId)
|
||||
const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId)
|
||||
return shop ? shop.shopName : '未知店铺'
|
||||
|
||||
@@ -403,6 +403,8 @@ import {
|
||||
type UserBalanceHistoryItem,
|
||||
type UserVO
|
||||
} from '@/api/admin'
|
||||
import type { IdType } from '@/utils/id'
|
||||
import { sameId } from '@/utils/id'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, hasAnyPermission, loadUserPermissions } = usePermission()
|
||||
@@ -939,7 +941,7 @@ const showViewModal = (record: any) => {
|
||||
viewModalVisible.value = true
|
||||
}
|
||||
|
||||
const loadUserAssetData = async (userId: number) => {
|
||||
const loadUserAssetData = async (userId: IdType) => {
|
||||
const [asset, history] = await Promise.all([
|
||||
adminUserApi.getUserAsset(userId),
|
||||
adminUserApi.getUserBalanceHistory(userId)
|
||||
@@ -1080,7 +1082,7 @@ const handleDelete = async (record: any) => {
|
||||
await fetchUserList()
|
||||
return
|
||||
}
|
||||
userList.value = userList.value.filter(user => user.id !== record.id)
|
||||
userList.value = userList.value.filter(user => !sameId(user.id, record.id))
|
||||
pagination.total = Math.max(0, Number(pagination.total || 0) - 1)
|
||||
message.success('已删除用户账号')
|
||||
await fetchUserList()
|
||||
@@ -1102,7 +1104,7 @@ const handleUnbind = async (record: any) => {
|
||||
await fetchUserList()
|
||||
return
|
||||
}
|
||||
userList.value = userList.value.filter(user => user.id !== record.id)
|
||||
userList.value = userList.value.filter(user => !sameId(user.id, record.id))
|
||||
pagination.total = Math.max(0, Number(pagination.total || 0) - 1)
|
||||
if (currentUserType.value === 2 && record.type === 3) {
|
||||
message.success('已解绑当前店铺下的美甲师,并已同步降级为普通用户')
|
||||
@@ -1123,7 +1125,7 @@ const refreshAssetPanel = async () => {
|
||||
assetLoading.value = true
|
||||
try {
|
||||
await loadUserAssetData(assetTargetUser.value.id)
|
||||
const matchedUser = userList.value.find(user => user.id === assetTargetUser.value?.id)
|
||||
const matchedUser = userList.value.find(user => sameId(user.id, assetTargetUser.value?.id))
|
||||
if (matchedUser && assetData.value) {
|
||||
matchedUser.level = assetData.value.vipLevel
|
||||
matchedUser.vipId = assetData.value.vipInfoId
|
||||
|
||||
Reference in New Issue
Block a user