修复前端打包问题
提取基础接口为配置
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import axios, { AxiosError } from 'axios'
|
||||
import router from '../router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { ADMIN_API_BASE_URL } from '../config/api'
|
||||
|
||||
// 防重复提示标志
|
||||
let lastErrorTime = 0
|
||||
@@ -8,7 +9,7 @@ let lastErrorMessage = ''
|
||||
const ERROR_DEBOUNCE_TIME = 1000 // 1秒内不重复显示相同错误
|
||||
|
||||
const adminApi = axios.create({
|
||||
baseURL: 'http://wcy111.top:8088/admin/api',
|
||||
baseURL: ADMIN_API_BASE_URL,
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
@@ -210,6 +211,9 @@ export const adminCouponApi = {
|
||||
},
|
||||
deleteCoupon: (id: number) => {
|
||||
return adminApi.delete<boolean>(`/coupon/delete/${id}`)
|
||||
},
|
||||
distributeCoupon: (data: any) => {
|
||||
return adminApi.post<boolean>('/coupon/distribute', data)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -323,7 +327,7 @@ export interface PageResult<T> {
|
||||
}
|
||||
|
||||
export const adminUserApi = {
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: number }) => {
|
||||
listUsers: (params: { page: number; size: number; keyword?: string; type?: number; shopId?: number; status?: number }) => {
|
||||
return adminApi.get<PageResult<UserVO>>('/user/list', { params })
|
||||
},
|
||||
listAllUsers: () => {
|
||||
@@ -392,6 +396,7 @@ export interface RecentActivityVO {
|
||||
type: string
|
||||
description: string
|
||||
time: string
|
||||
color?: string
|
||||
}
|
||||
|
||||
export interface DashboardStats {
|
||||
|
||||
@@ -4,11 +4,13 @@ export interface LoginRequest {
|
||||
account: string
|
||||
password: string
|
||||
rememberMe?: boolean
|
||||
shopId?: number
|
||||
}
|
||||
|
||||
export interface PhoneLoginRequest {
|
||||
phone: string
|
||||
verificationCode: string
|
||||
shopId?: number
|
||||
}
|
||||
|
||||
export interface RegisterRequest {
|
||||
@@ -16,6 +18,8 @@ export interface RegisterRequest {
|
||||
password: string
|
||||
nickname: string
|
||||
shopId?: number
|
||||
phone?: string
|
||||
verificationCode?: string
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
|
||||
@@ -16,6 +16,7 @@ export interface Coupon {
|
||||
endTime: string
|
||||
status: number
|
||||
statusName: string
|
||||
shopId?: number
|
||||
availableTags: Tag[]
|
||||
unavailableTags: Tag[]
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import { authApi } from './auth'
|
||||
import { wishlistApi } from './wishlist'
|
||||
import router from '../router'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { API_BASE_URL } from '../config/api'
|
||||
|
||||
// 防重复提示标志
|
||||
let lastErrorTime = 0
|
||||
@@ -10,7 +11,7 @@ let lastErrorMessage = ''
|
||||
const ERROR_DEBOUNCE_TIME = 1000 // 1秒内不重复显示相同错误
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://wcy111.top:8088/api',
|
||||
baseURL: API_BASE_URL,
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
|
||||
@@ -62,23 +62,23 @@ export interface UpdateProductRequest {
|
||||
|
||||
export const productApi = {
|
||||
getAllProducts: async (): Promise<ProductVO[]> => {
|
||||
return await api.get<ProductVO[]>('/product/list/all')
|
||||
return await api.get<ProductVO[]>('/product/list/all') as unknown as ProductVO[]
|
||||
},
|
||||
|
||||
getProductById: async (id: number): Promise<ProductVO> => {
|
||||
return await api.get<ProductVO>(`/product/get/${id}`)
|
||||
return await api.get<ProductVO>(`/product/get/${id}`) as unknown as ProductVO
|
||||
},
|
||||
|
||||
getProductsByTag: async (tag: string): Promise<ProductVO[]> => {
|
||||
return await api.get<ProductVO[]>(`/product/list/tag/${tag}`)
|
||||
return await api.get<ProductVO[]>(`/product/list/tag/${tag}`) as unknown as ProductVO[]
|
||||
},
|
||||
|
||||
likeProduct: async (productId: number): Promise<boolean> => {
|
||||
return await api.post<boolean>(`/product/like/${productId}`)
|
||||
return await api.post<boolean>(`/product/like/${productId}`) as unknown as boolean
|
||||
},
|
||||
|
||||
unlikeProduct: async (productId: number): Promise<boolean> => {
|
||||
return await api.post<boolean>(`/product/unlike/${productId}`)
|
||||
return await api.post<boolean>(`/product/unlike/${productId}`) as unknown as boolean
|
||||
},
|
||||
|
||||
searchProducts: async (keyword: string): Promise<ProductVO[]> => {
|
||||
@@ -86,6 +86,6 @@ export const productApi = {
|
||||
params: {
|
||||
keyword: keyword
|
||||
}
|
||||
})
|
||||
}) as unknown as ProductVO[]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ export interface ListUsersParams {
|
||||
size: number
|
||||
keyword?: string
|
||||
shopId?: number
|
||||
status?: number
|
||||
}
|
||||
|
||||
export interface CreateUserRequest {
|
||||
|
||||
@@ -190,7 +190,7 @@ router.beforeEach((to, _from, next) => {
|
||||
const adminUserInfoStr = localStorage.getItem('adminUserInfo')
|
||||
if (adminUserInfoStr) {
|
||||
try {
|
||||
const adminUserInfo = JSON.parse(adminUserInfoStr)
|
||||
JSON.parse(adminUserInfoStr)
|
||||
// 获取用户权限
|
||||
const userPermissionsStr = localStorage.getItem('userPermissions')
|
||||
if (userPermissionsStr) {
|
||||
|
||||
@@ -506,13 +506,12 @@ const handleDeactivateAccount = async () => {
|
||||
try {
|
||||
// 在删除前先重命名账号和手机号,添加删除时间戳
|
||||
const timestamp = new Date().getTime()
|
||||
const newAccount = `${userInfo.value.account}_deleted_${timestamp}`
|
||||
const newPhone = `${userInfo.value.phone}_deleted_${timestamp}`
|
||||
|
||||
try {
|
||||
await userApi.updateUserInfo({ account: newAccount, phone: newPhone })
|
||||
await userApi.updateUserInfo({ phone: newPhone })
|
||||
} catch (renameError) {
|
||||
console.error('重命名账号和手机号失败:', renameError)
|
||||
console.error('重命名手机号失败:', renameError)
|
||||
// 重命名失败也继续删除流程
|
||||
}
|
||||
|
||||
|
||||
@@ -311,6 +311,7 @@ import { ref, reactive, onMounted } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { UserOutlined, LockOutlined, WechatOutlined, QqOutlined, InfoCircleOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { Rule } from 'ant-design-vue/es/form'
|
||||
import { authApi } from '@/api/auth'
|
||||
import { shopApi } from '@/api/shop'
|
||||
import { userApi } from '@/api/user'
|
||||
@@ -354,7 +355,7 @@ const validateConfirmPassword = async (_rule: any, value: string) => {
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const rules = {
|
||||
const rules: Record<string, Rule[]> = {
|
||||
account: [
|
||||
{ required: true, message: '请输入账号', trigger: 'blur' },
|
||||
{ min: 3, max: 50, message: '账号长度在3到50个字符', trigger: 'blur' },
|
||||
@@ -488,11 +489,12 @@ const handleAccountBlur = async () => {
|
||||
if (activeTab.value === 'login' && formData.account) {
|
||||
try {
|
||||
const res = await userApi.getUserByAccount(formData.account)
|
||||
if (res) {
|
||||
const userData = res as any
|
||||
if (userData) {
|
||||
accountStatus.value = {
|
||||
exists: true,
|
||||
nickname: res.nickname,
|
||||
hasShop: res.shopId && res.shopId > 0
|
||||
nickname: userData.nickname,
|
||||
hasShop: userData.shopId && userData.shopId > 0
|
||||
}
|
||||
} else {
|
||||
accountStatus.value = {
|
||||
@@ -513,10 +515,11 @@ const handlePhoneBlur = async () => {
|
||||
if (activeTab.value === 'login' && loginType.value === 'phone' && formData.phone) {
|
||||
try {
|
||||
const res = await userApi.getUserByAccount(formData.phone)
|
||||
if (res) {
|
||||
const userData = res as any
|
||||
if (userData) {
|
||||
phoneUserStatus.value = {
|
||||
exists: true,
|
||||
hasShop: res.shopId && res.shopId > 0
|
||||
hasShop: userData.shopId && userData.shopId > 0
|
||||
}
|
||||
} else {
|
||||
phoneUserStatus.value = {
|
||||
|
||||
@@ -265,8 +265,7 @@ import { orderApi } from '../api/order'
|
||||
import { fileApi } from '../api/index'
|
||||
import { couponApi, type UserCoupon } from '../api/coupon'
|
||||
import { userApi } from '../api/user'
|
||||
import { adminTagApi, type Tag } from '../api/admin'
|
||||
import { tagApi } from '../api/tag'
|
||||
import { tagApi, type TagVO } from '../api/tag'
|
||||
import api from '../api'
|
||||
|
||||
// 注入更新购物车数量的方法
|
||||
@@ -333,14 +332,14 @@ const loadProductImages = async (items: CartItem[]) => {
|
||||
try {
|
||||
const response = await fileApi.getSignedUrl(Number(imageId)) as any
|
||||
imageIdCache.value[imageId] = response
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
item.productImage = imageIdCache.value[imageId] || ''
|
||||
} catch (error) {
|
||||
// 静默处理404错误,不显示错误信息
|
||||
console.log('图片不存在或无法获取签名URL:', imageId)
|
||||
item.productImage = ''
|
||||
}
|
||||
} else {
|
||||
item.productImage = imageIdCache.value[imageId]
|
||||
item.productImage = imageIdCache.value[imageId] || ''
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('处理图片时出错:', error)
|
||||
@@ -520,13 +519,13 @@ const showArtistModal = ref(false)
|
||||
const selectedArtist = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number} | null>(null)
|
||||
const availableArtists = ref<{id: number, name: string, avatar?: string, signature?: string, shopName?: string, status?: number, experience?: number, skills?: string, rating?: number}[]>([])
|
||||
// 标签列表
|
||||
const tagList = ref<Tag[]>([])
|
||||
const tagList = ref<TagVO[]>([])
|
||||
|
||||
// 加载标签列表
|
||||
const loadTagList = async () => {
|
||||
try {
|
||||
// 使用前台API获取标签列表
|
||||
const tags = await tagApi.getAllTags()
|
||||
const tags = await tagApi.getAllTags() as unknown as TagVO[]
|
||||
tagList.value = tags || []
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败:', error)
|
||||
@@ -548,7 +547,7 @@ const loadAvailableArtists = async () => {
|
||||
users.map(async (user: any) => {
|
||||
try {
|
||||
// 调用前台美甲师信息API获取详细信息
|
||||
const nailArtistInfo = await api.get(`/nail-artist/get/${user.id}`)
|
||||
const nailArtistInfo = await api.get(`/nail-artist/get/${user.id}`) as any
|
||||
return {
|
||||
id: user.id,
|
||||
name: user.nickname,
|
||||
@@ -636,27 +635,27 @@ const getArtistAvatar = (artist: any) => {
|
||||
}
|
||||
// 生成基于ID的随机头像
|
||||
const colors = ['#FF6B6B', '#4ECDC4', '#45B7D1', '#96CEB4', '#FFEAA7', '#DDA0DD']
|
||||
const color = colors[artist.id % colors.length]
|
||||
const color = colors[artist.id % colors.length] || '#FF6B6B'
|
||||
return `https://api.dicebear.com/7.x/avataaars/svg?seed=${artist.id}&backgroundColor=${color.replace('#', '')}`
|
||||
}
|
||||
|
||||
// 获取随机评分
|
||||
const getRandomRating = () => {
|
||||
return (4 + Math.random()).toFixed(1)
|
||||
}
|
||||
// const _getRandomRating = () => {
|
||||
// return (4 + Math.random()).toFixed(1)
|
||||
// }
|
||||
|
||||
// 获取随机经验
|
||||
const getRandomExperience = () => {
|
||||
return Math.floor(1 + Math.random() * 5)
|
||||
}
|
||||
// const _getRandomExperience = () => {
|
||||
// return Math.floor(1 + Math.random() * 5)
|
||||
// }
|
||||
|
||||
// 获取随机技能标签
|
||||
const getRandomSkills = () => {
|
||||
const allSkills = ['手绘', '雕花', '水晶甲', '光疗甲', '渐变', '法式', '钻饰', '创意美甲']
|
||||
const skillsCount = 2 + Math.floor(Math.random() * 3)
|
||||
const shuffled = allSkills.sort(() => 0.5 - Math.random())
|
||||
return shuffled.slice(0, skillsCount)
|
||||
}
|
||||
// const _getRandomSkills = () => {
|
||||
// const allSkills = ['手绘', '雕花', '水晶甲', '光疗甲', '渐变', '法式', '钻饰', '创意美甲']
|
||||
// const skillsCount = 2 + Math.floor(Math.random() * 3)
|
||||
// const shuffled = allSkills.sort(() => 0.5 - Math.random())
|
||||
// return shuffled.slice(0, skillsCount)
|
||||
// }
|
||||
|
||||
// 获取美甲师的技能标签
|
||||
const getArtistSkills = (artist: any) => {
|
||||
@@ -666,7 +665,7 @@ const getArtistSkills = (artist: any) => {
|
||||
|
||||
const skillIds = artist.skills.split(',').filter((id: string) => id)
|
||||
return skillIds.map((id: string) => {
|
||||
const tag = tagList.value.find(t => t.id.toString() === id)
|
||||
const tag = tagList.value.find((t: any) => t.id.toString() === id)
|
||||
return tag ? tag.tagName : id
|
||||
})
|
||||
}
|
||||
|
||||
@@ -188,19 +188,20 @@ const loadBannerImages = async () => {
|
||||
const fileIdPromises: Promise<string>[] = []
|
||||
|
||||
// 从店铺获取图片
|
||||
const shops = await shopApi.getAllShops() as ShopVO[]
|
||||
const shops = await shopApi.getAllShops() as unknown as ShopVO[]
|
||||
|
||||
// 处理店铺图片 - 只使用coverImageFileId(banner图片)
|
||||
for (const shop of shops) {
|
||||
// 处理coverImageFileId(专门用于banner的图片)
|
||||
if (shop.coverImageFileId) {
|
||||
const fileIds = shop.coverImageFileId.split(',').filter(id => id.trim())
|
||||
const shopAny = shop as any
|
||||
if (shopAny.coverImageFileId) {
|
||||
const fileIds = shopAny.coverImageFileId.split(',').filter((id: string) => id.trim())
|
||||
for (const idStr of fileIds) {
|
||||
const fileId = parseInt(idStr)
|
||||
if (!isNaN(fileId)) {
|
||||
const promise = fileApi.getSignedUrl(fileId).catch(err => {
|
||||
const promise = fileApi.getSignedUrl(fileId).then((response: any) => response as string).catch(err => {
|
||||
console.error('获取店铺banner图签名失败:', err)
|
||||
return null
|
||||
return ''
|
||||
})
|
||||
fileIdPromises.push(promise)
|
||||
}
|
||||
@@ -211,8 +212,8 @@ const loadBannerImages = async () => {
|
||||
// 并行请求所有签名URL
|
||||
const results = await Promise.all(fileIdPromises)
|
||||
|
||||
// 过滤掉null值并去除反引号
|
||||
const filteredResults = results.filter((url): url is string => url !== null).map(url => url.replace(/[`]/g, '').trim())
|
||||
// 过滤掉空值并去除反引号
|
||||
const filteredResults = results.filter((url): url is string => url !== '').map(url => url.replace(/[`]/g, '').trim())
|
||||
|
||||
// 去重
|
||||
const uniqueImages = [...new Set(filteredResults)]
|
||||
@@ -328,7 +329,7 @@ const handleNotificationClick = () => {
|
||||
}
|
||||
|
||||
// 处理搜索输入
|
||||
const handleSearch = (e: any) => {
|
||||
const handleSearch = (_e: any) => {
|
||||
}
|
||||
|
||||
// 处理筛选按钮点击
|
||||
@@ -340,7 +341,7 @@ const handleBannerClick = () => {
|
||||
}
|
||||
|
||||
// 处理查看全部点击
|
||||
const handleSeeAll = (type: string) => {
|
||||
const handleSeeAll = (_type: string) => {
|
||||
router.push('/products')
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ import { useRouter } from 'vue-router'
|
||||
import { LeftOutlined, LockOutlined } from '@ant-design/icons-vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import type { Rule } from 'ant-design-vue/es/form'
|
||||
import { userApi } from '@/api/user'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -82,14 +83,14 @@ const formState = reactive({
|
||||
confirmPassword: ''
|
||||
})
|
||||
|
||||
const validateConfirmPassword = (_, value: string) => {
|
||||
const validateConfirmPassword = (_rule: any, value: string) => {
|
||||
if (value !== formState.password) {
|
||||
return Promise.reject(new Error('两次输入的密码不一致'))
|
||||
}
|
||||
return Promise.resolve()
|
||||
}
|
||||
|
||||
const formRules = {
|
||||
const formRules: Record<string, Rule[]> = {
|
||||
password: [
|
||||
{ required: true, message: '请输入新密码', trigger: 'blur' },
|
||||
{ min: 8, message: '密码长度至少8位', trigger: 'blur' },
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
</div>
|
||||
<div v-if="productImages.length > 1" class="carousel-indicators">
|
||||
<div
|
||||
v-for="(image, index) in productImages"
|
||||
v-for="(_, index) in productImages"
|
||||
:key="index"
|
||||
class="indicator"
|
||||
:class="{ active: currentImageIndex === index }"
|
||||
@@ -179,7 +179,7 @@ const checkWishlistStatus = async () => {
|
||||
|
||||
try {
|
||||
const status = await wishlistApi.checkWishlist(product.value.id)
|
||||
isFavorite.value = status as boolean
|
||||
isFavorite.value = (status as unknown as boolean)
|
||||
} catch (error) {
|
||||
console.error('检查收藏状态失败:', error)
|
||||
isFavorite.value = false
|
||||
@@ -198,7 +198,7 @@ const checkLikeStatus = async () => {
|
||||
|
||||
try {
|
||||
const status = await productLikeApi.checkLikeStatus(product.value.id)
|
||||
isLiked.value = status as boolean
|
||||
isLiked.value = (status as unknown as boolean)
|
||||
} catch (error) {
|
||||
console.error('检查点赞状态失败:', error)
|
||||
isLiked.value = false
|
||||
|
||||
@@ -68,8 +68,8 @@ const handleBackClick = () => {
|
||||
const fetchWishlist = async () => {
|
||||
try {
|
||||
const response = await wishlistApi.getWishlist()
|
||||
wishlistItems.value = response as WishlistItem[]
|
||||
await loadImageUrls(response as WishlistItem[])
|
||||
wishlistItems.value = (response as unknown as WishlistItem[])
|
||||
await loadImageUrls(response as unknown as WishlistItem[])
|
||||
} catch (error) {
|
||||
console.error('获取收藏列表失败:', error)
|
||||
ElMessage.error('获取收藏列表失败')
|
||||
|
||||
@@ -97,7 +97,8 @@ import {
|
||||
TeamOutlined
|
||||
} from '@ant-design/icons-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import { userApi, type UserVO, adminAuthApi } from '@/api/admin'
|
||||
import { userApi, type UserVO } from '@/api/admin'
|
||||
import { authApi } from '@/api/auth'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
@@ -190,8 +191,8 @@ const toggleCollapsed = () => {
|
||||
collapsed.value = !collapsed.value
|
||||
}
|
||||
|
||||
const handleMenuClick = ({ key }: { key: string }) => {
|
||||
router.push(key)
|
||||
const handleMenuClick = (info: any) => {
|
||||
router.push(info.key)
|
||||
}
|
||||
|
||||
const goToProfile = () => {
|
||||
@@ -204,7 +205,8 @@ const handleLogout = () => {
|
||||
content: '确定要退出登录吗?',
|
||||
onOk: async () => {
|
||||
try {
|
||||
await adminAuthApi.logout()
|
||||
// 尝试调用登出API
|
||||
await authApi.logout()
|
||||
} catch (error) {
|
||||
console.error('登出失败:', error)
|
||||
} finally {
|
||||
|
||||
@@ -79,7 +79,7 @@ const formRules = {
|
||||
{ pattern: /^[a-zA-Z0-9_\-@.]+$/, message: '账号只能包含数字、字母、下划线、连字符、@和点号', trigger: 'blur' }
|
||||
],
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }]
|
||||
}
|
||||
} as any
|
||||
|
||||
const handleLogin = async () => {
|
||||
try {
|
||||
|
||||
@@ -286,8 +286,8 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { adminCouponApi, adminTagApi, adminShopApi, userApi, type Shop } from '@/api/admin'
|
||||
@@ -408,7 +408,7 @@ const formRules = {
|
||||
startTime: [{ required: true, message: '请选择开始时间', trigger: 'change' }],
|
||||
endTime: [{ required: true, message: '请选择结束时间', trigger: 'change' }],
|
||||
shopId: [{ required: true, message: '请选择所属店铺', trigger: 'change' }]
|
||||
}
|
||||
} as any
|
||||
|
||||
// 发放优惠券表单状态
|
||||
const distributeFormState = reactive({
|
||||
@@ -421,7 +421,7 @@ const distributeFormState = reactive({
|
||||
const distributeFormRules = {
|
||||
userIds: [{ required: true, message: '请选择要发放的用户', trigger: 'change' }],
|
||||
quantity: [{ required: true, message: '请输入发放数量', trigger: 'blur' }]
|
||||
}
|
||||
} as any
|
||||
|
||||
const columns = [
|
||||
{ title: '优惠券编码', dataIndex: 'couponCode', key: 'couponCode' },
|
||||
@@ -456,15 +456,15 @@ const fetchCoupons = async () => {
|
||||
try {
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : undefined
|
||||
const res = await adminCouponApi.listAllCoupons(shopId)
|
||||
const res = await adminCouponApi.listAllCoupons(shopId) as unknown as Coupon[]
|
||||
// 后端返回的是数组,直接使用
|
||||
if (Array.isArray(res)) {
|
||||
couponList.value = res
|
||||
pagination.total = res.length
|
||||
} else {
|
||||
// 兼容分页数据结构
|
||||
couponList.value = res?.list || []
|
||||
pagination.total = res?.total || 0
|
||||
couponList.value = (res as any)?.list || []
|
||||
pagination.total = (res as any)?.total || 0
|
||||
}
|
||||
} catch (error) {
|
||||
message.error('获取优惠券列表失败')
|
||||
@@ -475,7 +475,7 @@ const fetchCoupons = async () => {
|
||||
|
||||
const fetchTags = async () => {
|
||||
try {
|
||||
const res = await adminTagApi.listAllTags()
|
||||
const res = await adminTagApi.listAllTags() as unknown as TagVO[]
|
||||
tagList.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败:', error)
|
||||
@@ -485,7 +485,7 @@ const fetchTags = async () => {
|
||||
const fetchShops = async () => {
|
||||
loadingShops.value = true
|
||||
try {
|
||||
const res = await adminShopApi.listAllShops()
|
||||
const res = await adminShopApi.listAllShops() as unknown as Shop[]
|
||||
shops.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error)
|
||||
@@ -526,27 +526,28 @@ const showAddModal = () => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showEditModal = (record: Coupon) => {
|
||||
if (!record) {
|
||||
const showEditModal = (record: Record<string, any>) => {
|
||||
const coupon = record as Coupon
|
||||
if (!coupon) {
|
||||
message.error('优惠券数据不存在')
|
||||
return
|
||||
}
|
||||
try {
|
||||
isEdit.value = true
|
||||
currentCoupon.value = record
|
||||
currentCoupon.value = coupon
|
||||
Object.assign(formState, {
|
||||
couponCode: record.couponCode || '',
|
||||
couponName: record.couponName || '',
|
||||
couponType: record.couponType || 1,
|
||||
discountValue: record.discountValue || 0,
|
||||
minAmount: record.minAmount || 0,
|
||||
reduceAmount: record.reduceAmount || 0,
|
||||
totalCount: record.totalCount || 0,
|
||||
startTime: record.startTime ? dayjs(record.startTime) : undefined,
|
||||
endTime: record.endTime ? dayjs(record.endTime) : undefined,
|
||||
availableTagIds: record.availableTags ? record.availableTags.map(tag => tag.id) : [],
|
||||
unavailableTagIds: record.unavailableTags ? record.unavailableTags.map(tag => tag.id) : [],
|
||||
shopId: record.shopId
|
||||
couponCode: coupon.couponCode || '',
|
||||
couponName: coupon.couponName || '',
|
||||
couponType: coupon.couponType || 1,
|
||||
discountValue: coupon.discountValue || 0,
|
||||
minAmount: coupon.minAmount || 0,
|
||||
reduceAmount: coupon.reduceAmount || 0,
|
||||
totalCount: coupon.totalCount || 0,
|
||||
startTime: coupon.startTime ? dayjs(coupon.startTime) : undefined,
|
||||
endTime: coupon.endTime ? dayjs(coupon.endTime) : undefined,
|
||||
availableTagIds: coupon.availableTags ? coupon.availableTags.map(tag => tag.id) : [],
|
||||
unavailableTagIds: coupon.unavailableTags ? coupon.unavailableTags.map(tag => tag.id) : [],
|
||||
shopId: coupon.shopId
|
||||
})
|
||||
modalVisible.value = true
|
||||
} catch (error) {
|
||||
@@ -555,25 +556,26 @@ const showEditModal = (record: Coupon) => {
|
||||
}
|
||||
}
|
||||
|
||||
const showViewModal = (record: Coupon) => {
|
||||
if (!record) {
|
||||
const showViewModal = (record: Record<string, any>) => {
|
||||
const coupon = record as Coupon
|
||||
if (!coupon) {
|
||||
message.error('优惠券数据不存在')
|
||||
return
|
||||
}
|
||||
try {
|
||||
Object.assign(viewFormState, {
|
||||
couponCode: record.couponCode || '',
|
||||
couponName: record.couponName || '',
|
||||
couponType: record.couponType || 1,
|
||||
discountValue: record.discountValue || 0,
|
||||
minAmount: record.minAmount || 0,
|
||||
reduceAmount: record.reduceAmount || 0,
|
||||
totalCount: record.totalCount || 0,
|
||||
startTime: record.startTime ? dayjs(record.startTime) : undefined,
|
||||
endTime: record.endTime ? dayjs(record.endTime) : undefined,
|
||||
availableTagIds: record.availableTags ? record.availableTags.map(tag => tag.id) : [],
|
||||
unavailableTagIds: record.unavailableTags ? record.unavailableTags.map(tag => tag.id) : [],
|
||||
shopId: record.shopId
|
||||
couponCode: coupon.couponCode || '',
|
||||
couponName: coupon.couponName || '',
|
||||
couponType: coupon.couponType || 1,
|
||||
discountValue: coupon.discountValue || 0,
|
||||
minAmount: coupon.minAmount || 0,
|
||||
reduceAmount: coupon.reduceAmount || 0,
|
||||
totalCount: coupon.totalCount || 0,
|
||||
startTime: coupon.startTime ? dayjs(coupon.startTime) : undefined,
|
||||
endTime: coupon.endTime ? dayjs(coupon.endTime) : undefined,
|
||||
availableTagIds: coupon.availableTags ? coupon.availableTags.map(tag => tag.id) : [],
|
||||
unavailableTagIds: coupon.unavailableTags ? coupon.unavailableTags.map(tag => tag.id) : [],
|
||||
shopId: coupon.shopId
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
} catch (error) {
|
||||
@@ -640,10 +642,10 @@ const handleModalOk = async () => {
|
||||
}
|
||||
|
||||
if (isEdit.value && currentCoupon.value) {
|
||||
await adminCouponApi.updateCoupon(currentCoupon.value.id, requestData, shopId)
|
||||
await adminCouponApi.updateCoupon(currentCoupon.value.id, requestData)
|
||||
message.success('更新成功')
|
||||
} else {
|
||||
await adminCouponApi.createCoupon(requestData, shopId)
|
||||
await adminCouponApi.createCoupon(requestData)
|
||||
message.success('创建成功')
|
||||
}
|
||||
|
||||
@@ -658,7 +660,7 @@ const handleModalOk = async () => {
|
||||
}
|
||||
|
||||
const handleModalCancel = () => {
|
||||
message.confirm({
|
||||
Modal.confirm({
|
||||
title: '确认关闭',
|
||||
content: '确定要关闭编辑模态框吗?未保存的更改将会丢失。',
|
||||
onOk: () => {
|
||||
@@ -668,15 +670,14 @@ const handleModalCancel = () => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleDelete = (record: Coupon) => {
|
||||
message.confirm({
|
||||
const handleDelete = (record: Record<string, any>) => {
|
||||
const coupon = record as Coupon
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定要删除优惠券 ${record.couponName} 吗?`,
|
||||
content: `确定要删除优惠券 ${coupon.couponName} 吗?`,
|
||||
onOk: async () => {
|
||||
try {
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : record.shopId
|
||||
await adminCouponApi.deleteCoupon(record.id, shopId)
|
||||
await adminCouponApi.deleteCoupon(coupon.id)
|
||||
message.success('删除成功')
|
||||
fetchCoupons()
|
||||
} catch (error) {
|
||||
@@ -695,10 +696,9 @@ const fetchUsers = async () => {
|
||||
const res = await userApi.listUsers({
|
||||
page: 1,
|
||||
size: 100,
|
||||
shopId: shopId,
|
||||
status: 1 // 只获取激活状态的用户
|
||||
shopId: shopId
|
||||
})
|
||||
userList.value = res.list || []
|
||||
userList.value = (res as any).list || []
|
||||
} catch (error) {
|
||||
console.error('获取用户列表失败:', error)
|
||||
// 如果API调用失败,使用模拟数据作为 fallback
|
||||
@@ -711,9 +711,10 @@ const fetchUsers = async () => {
|
||||
}
|
||||
|
||||
// 显示发放优惠券模态框
|
||||
const showDistributeModal = (record: Coupon) => {
|
||||
currentDistributeCoupon.value = record
|
||||
distributeFormState.couponName = record.couponName
|
||||
const showDistributeModal = (record: Record<string, any>) => {
|
||||
const coupon = record as Coupon
|
||||
currentDistributeCoupon.value = coupon
|
||||
distributeFormState.couponName = coupon.couponName
|
||||
distributeFormState.userIds = []
|
||||
distributeFormState.quantity = 1
|
||||
fetchUsers()
|
||||
@@ -728,21 +729,12 @@ const handleDistributeOk = async () => {
|
||||
|
||||
if (!currentDistributeCoupon.value) return
|
||||
|
||||
const currentUser = getCurrentUserInfo()
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : currentDistributeCoupon.value.shopId
|
||||
|
||||
if (!shopId) {
|
||||
message.error('请选择所属店铺')
|
||||
distributeLoading.value = false
|
||||
return
|
||||
}
|
||||
|
||||
// 调用发放优惠券的API
|
||||
await adminCouponApi.distributeCoupon({
|
||||
couponId: currentDistributeCoupon.value.id,
|
||||
userIds: distributeFormState.userIds,
|
||||
quantity: distributeFormState.quantity
|
||||
}, shopId)
|
||||
})
|
||||
|
||||
message.success('发放成功')
|
||||
distributeModalVisible.value = false
|
||||
|
||||
@@ -93,10 +93,11 @@ const welcomeMessage = computed(() => {
|
||||
const groupedPermissions = computed(() => {
|
||||
const groups: Record<string, PermissionVO[]> = {}
|
||||
userPermissions.value.forEach(permission => {
|
||||
if (!groups[permission.permissionGroup]) {
|
||||
groups[permission.permissionGroup] = []
|
||||
const groupName = permission.permissionGroup
|
||||
if (!groups[groupName]) {
|
||||
groups[groupName] = []
|
||||
}
|
||||
groups[permission.permissionGroup].push(permission)
|
||||
groups[groupName]!.push(permission)
|
||||
})
|
||||
return groups
|
||||
})
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { adminNailArtistApi, type NailArtistInfoVO } from '@/api/admin'
|
||||
@@ -244,7 +244,7 @@ const formRules = {
|
||||
skills: [{ required: true, message: '请选择技能标签', trigger: 'change' }],
|
||||
status: [{ required: true, message: '请选择状态', trigger: 'change' }],
|
||||
portfolio: [{ required: true, message: '请选择作品作品', trigger: 'change' }]
|
||||
}
|
||||
} as any
|
||||
|
||||
const columns = [
|
||||
{ title: '美甲师姓名', dataIndex: 'nickname', key: 'nickname' },
|
||||
@@ -267,7 +267,7 @@ const getStatusColor = (status: number) => {
|
||||
const fetchTagList = async () => {
|
||||
tagLoading.value = true
|
||||
try {
|
||||
const res = await adminTagApi.listAllTags()
|
||||
const res = await adminTagApi.listAllTags() as unknown as Tag[]
|
||||
tagList.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取标签列表失败:', error)
|
||||
@@ -286,7 +286,7 @@ const fetchProductList = async () => {
|
||||
if (currentUserInfo && currentUserInfo.type !== 4 && currentUserInfo.shopId) {
|
||||
params.shopId = currentUserInfo.shopId
|
||||
}
|
||||
const res = await adminProductApi.listProducts(params)
|
||||
const res = await adminProductApi.listProducts(params) as unknown as { list: Product[] }
|
||||
productList.value = res.list || []
|
||||
} catch (error) {
|
||||
console.error('获取作品列表失败:', error)
|
||||
@@ -298,12 +298,12 @@ const fetchProductList = async () => {
|
||||
const fetchNailArtistList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await adminNailArtistApi.listNailArtists()
|
||||
const res = await adminNailArtistApi.listNailArtists() as unknown as NailArtistInfoVO[]
|
||||
let filteredList = res || []
|
||||
|
||||
// 按搜索词过滤
|
||||
if (searchText.value) {
|
||||
filteredList = filteredList.filter(item =>
|
||||
filteredList = filteredList.filter((item: NailArtistInfoVO) =>
|
||||
item.nickname?.includes(searchText.value)
|
||||
)
|
||||
}
|
||||
@@ -328,8 +328,8 @@ const handleTableChange = (pag: any) => {
|
||||
fetchNailArtistList()
|
||||
}
|
||||
|
||||
const showEditModal = (record: NailArtistInfoVO) => {
|
||||
currentNailArtist.value = record
|
||||
const showEditModal = (record: Record<string, any>) => {
|
||||
currentNailArtist.value = record as NailArtistInfoVO
|
||||
Object.assign(formState, {
|
||||
userId: record.userId,
|
||||
identity: record.identity || '',
|
||||
@@ -343,29 +343,30 @@ const showEditModal = (record: NailArtistInfoVO) => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showViewModal = (record: NailArtistInfoVO) => {
|
||||
const showViewModal = (record: Record<string, any>) => {
|
||||
const nailArtist = record as NailArtistInfoVO
|
||||
// 构建技能标签文本
|
||||
const skillsArray = record.skills ? record.skills.split(',').filter(Boolean) : []
|
||||
const skillsArray = nailArtist.skills ? nailArtist.skills.split(',').filter(Boolean) : []
|
||||
const skillsText = skillsArray.map(skillId => {
|
||||
const tag = tagList.value.find(t => t.id.toString() === skillId)
|
||||
return tag ? tag.tagName : skillId
|
||||
}).join(', ')
|
||||
|
||||
// 构建作品文本
|
||||
const portfolioArray = record.portfolio ? record.portfolio.split(',').filter(Boolean) : []
|
||||
const portfolioArray = nailArtist.portfolio ? nailArtist.portfolio.split(',').filter(Boolean) : []
|
||||
const portfolioText = portfolioArray.map(productId => {
|
||||
const product = productList.value.find(p => p.id.toString() === productId)
|
||||
return product ? product.title : productId
|
||||
}).join(', ')
|
||||
|
||||
Object.assign(viewFormState, {
|
||||
nickname: record.nickname || '',
|
||||
shopName: record.shopName || '',
|
||||
identity: record.identity || '',
|
||||
experience: (record.experience || 0).toString(),
|
||||
nickname: nailArtist.nickname || '',
|
||||
shopName: nailArtist.shopName || '',
|
||||
identity: nailArtist.identity || '',
|
||||
experience: (nailArtist.experience || 0).toString(),
|
||||
skillsText: skillsText,
|
||||
statusText: getStatusText(record.status || 1),
|
||||
rating: (record.rating || 0).toString(),
|
||||
statusText: getStatusText(nailArtist.status || 1),
|
||||
rating: (nailArtist.rating || 0).toString(),
|
||||
portfolioText: portfolioText
|
||||
})
|
||||
viewModalVisible.value = true
|
||||
|
||||
@@ -152,7 +152,7 @@ const getStatusColor = (status: number) => {
|
||||
const loadOrders = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await orderApi.getAllOrders()
|
||||
const data = await orderApi.getAllOrders() as unknown as Order[]
|
||||
orders.value = data
|
||||
pagination.total = data.length
|
||||
} catch (error) {
|
||||
@@ -183,8 +183,8 @@ const processOrder = async (orderId: number, status: number) => {
|
||||
}
|
||||
}
|
||||
|
||||
const showOrderDetail = (order: Order) => {
|
||||
currentOrder.value = order
|
||||
const showOrderDetail = (order: Record<string, any>) => {
|
||||
currentOrder.value = order as Order
|
||||
detailModalVisible.value = true
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
<a-card :bordered="false">
|
||||
<a-tabs v-model:activeKey="activeTab">
|
||||
<a-tab-pane key="permissions" tab="权限列表">
|
||||
<template #extra>
|
||||
<div style="margin-bottom: 16px; text-align: right;">
|
||||
<a-button v-if="hasPermission('permission:create')" type="primary" @click="showAddPermissionModal">
|
||||
<template #icon>
|
||||
<PlusOutlined />
|
||||
</template>
|
||||
新增权限
|
||||
</a-button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
:columns="permissionColumns"
|
||||
@@ -176,6 +176,7 @@
|
||||
import { ref, reactive, computed, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import type { Rule } from 'ant-design-vue/es/form'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { userApi, type UserVO } from '@/api/admin'
|
||||
@@ -209,7 +210,7 @@ const permissionFormState = reactive({
|
||||
description: ''
|
||||
})
|
||||
|
||||
const permissionFormRules = {
|
||||
const permissionFormRules: Record<string, Rule[]> = {
|
||||
permissionCode: [{ required: true, message: '请输入权限编码', trigger: 'blur' }],
|
||||
permissionName: [{ required: true, message: '请输入权限名称', trigger: 'blur' }],
|
||||
permissionGroup: [{ required: true, message: '请选择权限分组', trigger: 'change' }],
|
||||
@@ -237,10 +238,11 @@ const currentLoginUser = ref<UserVO | null>(null)
|
||||
const groupedPermissions = computed(() => {
|
||||
const groups: Record<string, PermissionVO[]> = {}
|
||||
permissionList.value.forEach(p => {
|
||||
if (!groups[p.permissionGroup]) {
|
||||
groups[p.permissionGroup] = []
|
||||
const groupName = p.permissionGroup
|
||||
if (!groups[groupName]) {
|
||||
groups[groupName] = []
|
||||
}
|
||||
groups[p.permissionGroup].push(p)
|
||||
groups[groupName]!.push(p)
|
||||
})
|
||||
return groups
|
||||
})
|
||||
@@ -258,14 +260,16 @@ const getUserTypeText = (type: number) => {
|
||||
const filteredUserList = computed(() => {
|
||||
if (!currentLoginUser.value) return []
|
||||
|
||||
const currentUserId = currentLoginUser.value.id
|
||||
|
||||
// 管理员可以看到所有用户(除了普通用户和自己)
|
||||
if (currentLoginUser.value.type === 4) {
|
||||
return userList.value.filter(user => user.type !== 0 && user.id !== currentLoginUser.value!.id)
|
||||
return userList.value.filter(user => user.type !== 0 && user.id !== currentUserId)
|
||||
}
|
||||
|
||||
// 店长只能看到美甲师(除了自己)
|
||||
if (currentLoginUser.value.type === 2) {
|
||||
return userList.value.filter(user => user.type === 3 && user.id !== currentLoginUser.value!.id)
|
||||
return userList.value.filter(user => user.type === 3 && user.id !== currentUserId)
|
||||
}
|
||||
|
||||
// 其他用户类型(如美甲师)不能管理权限
|
||||
@@ -300,7 +304,7 @@ const fetchCurrentUser = async () => {
|
||||
const fetchPermissionList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await permissionApi.listAllPermissions()
|
||||
const res = await permissionApi.listAllPermissions() as unknown as PermissionVO[]
|
||||
permissionList.value = res || []
|
||||
permissionPagination.total = res?.length || 0
|
||||
} catch (error) {
|
||||
@@ -324,7 +328,7 @@ const fetchUserList = async () => {
|
||||
params.shopId = currentLoginUser.value.shopId
|
||||
}
|
||||
|
||||
const res = await userApi.listUsers(params)
|
||||
const res = await userApi.listUsers(params) as unknown as { list: UserVO[] }
|
||||
userList.value = res.list || []
|
||||
} catch (error) {
|
||||
message.error('获取用户列表失败')
|
||||
@@ -347,8 +351,8 @@ const selectUser = async (user: UserVO) => {
|
||||
selectedUser.value = user
|
||||
assignLoading.value = true
|
||||
try {
|
||||
const res = await permissionApi.getUserPermissions(user.id)
|
||||
selectedPermissions.value = res.map(p => p.id)
|
||||
const res = await permissionApi.getUserPermissions(user.id) as unknown as PermissionVO[]
|
||||
selectedPermissions.value = res.map((p: PermissionVO) => p.id)
|
||||
} catch (error) {
|
||||
message.error('获取用户权限失败')
|
||||
selectedPermissions.value = []
|
||||
@@ -380,9 +384,9 @@ const showAddPermissionModal = () => {
|
||||
permissionModalVisible.value = true
|
||||
}
|
||||
|
||||
const showEditPermissionModal = (record: PermissionVO) => {
|
||||
const showEditPermissionModal = (record: Record<string, any>) => {
|
||||
isEditPermission.value = true
|
||||
currentPermission.value = record
|
||||
currentPermission.value = record as PermissionVO
|
||||
Object.assign(permissionFormState, {
|
||||
permissionCode: record.permissionCode,
|
||||
permissionName: record.permissionName,
|
||||
@@ -419,9 +423,9 @@ const handlePermissionModalCancel = () => {
|
||||
permissionFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const handleDeletePermission = async (record: PermissionVO) => {
|
||||
const handleDeletePermission = async (record: Record<string, any>) => {
|
||||
try {
|
||||
await permissionApi.deletePermission(record.id)
|
||||
await permissionApi.deletePermission((record as PermissionVO).id)
|
||||
message.success('删除成功')
|
||||
fetchPermissionList()
|
||||
} catch (error) {
|
||||
|
||||
@@ -361,10 +361,9 @@
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, watch } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import type { FormInstance, UploadProps } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { DEFAULT_PRODUCT_IMAGE } from '@/constants'
|
||||
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, type ObjectStorageFileVO, adminTagApi, adminArtistApi, adminCouponApi } from '@/api/admin'
|
||||
import { adminProductApi, type Product, adminShopApi, type Shop, adminFileApi, adminTagApi, adminArtistApi, adminCouponApi } from '@/api/admin'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
@@ -490,7 +489,7 @@ const fetchShops = async () => {
|
||||
// 根据用户权限控制店铺列表的显示
|
||||
if (currentUser && currentUser.type !== 4 && currentUser.shopId) {
|
||||
// 如果是店长,只显示用户所属的店铺
|
||||
shops.value = res?.filter(shop => shop.id === currentUser.shopId) || []
|
||||
shops.value = res?.filter((shop: any) => shop.id === currentUser.shopId) || []
|
||||
// 默认选择用户所属的店铺,并且不可修改
|
||||
formState.shopId = currentUser.shopId
|
||||
} else {
|
||||
@@ -588,10 +587,10 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_PRODUCT_IMAGE)
|
||||
@@ -599,16 +598,23 @@ const loadImageUrls = async (products: Product[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
imageUrls.value[product.id] = urls
|
||||
if (product.id) {
|
||||
imageUrls.value[product.id] = urls
|
||||
}
|
||||
} else {
|
||||
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
if (product.id) {
|
||||
imageUrls.value[product.id] = [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getProductImages = (product: Product | Record<string, any>): string[] => {
|
||||
const productId = 'id' in product ? product.id : (product as any).id
|
||||
return imageUrls.value[productId] || [DEFAULT_PRODUCT_IMAGE]
|
||||
if (productId !== undefined) {
|
||||
return imageUrls.value[productId] || [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
return [DEFAULT_PRODUCT_IMAGE]
|
||||
}
|
||||
|
||||
const handleSearch = () => {
|
||||
@@ -650,7 +656,6 @@ const showEditModal = async (record: Product | Record<string, any>) => {
|
||||
isEdit.value = true
|
||||
currentProduct.value = record as Product
|
||||
|
||||
const recordId = 'id' in record ? record.id : (record as any).id
|
||||
const recordShopId = 'shopId' in record ? record.shopId : (record as any).shopId
|
||||
const recordTitle = 'title' in record ? record.title : (record as any).title
|
||||
const recordDescription = 'description' in record ? record.description : (record as any).description
|
||||
|
||||
@@ -341,10 +341,10 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
@@ -352,9 +352,13 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
shopImageUrls.value[shop.id] = urls
|
||||
if (shop.id !== undefined) {
|
||||
shopImageUrls.value[shop.id] = urls
|
||||
}
|
||||
} else {
|
||||
shopImageUrls.value[shop.id] = []
|
||||
if (shop.id !== undefined) {
|
||||
shopImageUrls.value[shop.id] = []
|
||||
}
|
||||
}
|
||||
|
||||
// 加载Banner图片
|
||||
@@ -367,10 +371,10 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
@@ -378,21 +382,31 @@ const loadImageUrls = async (shops: Shop[]) => {
|
||||
}
|
||||
}
|
||||
|
||||
shopBannerUrls.value[shop.id] = urls
|
||||
if (shop.id !== undefined) {
|
||||
shopBannerUrls.value[shop.id] = urls
|
||||
}
|
||||
} else {
|
||||
shopBannerUrls.value[shop.id] = []
|
||||
if (shop.id !== undefined) {
|
||||
shopBannerUrls.value[shop.id] = []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getShopImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
return shopImageUrls.value[shopId] || []
|
||||
if (shopId !== undefined) {
|
||||
return shopImageUrls.value[shopId] || []
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
const getShopBannerImages = (shop: Shop | Record<string, any>): string[] => {
|
||||
const shopId = 'id' in shop ? shop.id : (shop as any).id
|
||||
return shopBannerUrls.value[shopId] || []
|
||||
if (shopId !== undefined) {
|
||||
return shopBannerUrls.value[shopId] || []
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
const fetchShopList = async () => {
|
||||
@@ -567,7 +581,7 @@ const showEditModal = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
fileList.push({
|
||||
@@ -604,7 +618,7 @@ const showEditModal = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
fileList.push({
|
||||
@@ -652,10 +666,10 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
@@ -676,10 +690,10 @@ const showViewModal = async (record: Shop | Record<string, any>) => {
|
||||
try {
|
||||
// 检查缓存
|
||||
if (!imageIdCache.value[id]) {
|
||||
const response = await adminFileApi.getSignedUrl(Number(id)) as any
|
||||
const response = await adminFileApi.getSignedUrl(Number(id || '0')) as any
|
||||
imageIdCache.value[id] = response
|
||||
}
|
||||
urls.push(imageIdCache.value[id])
|
||||
urls.push(imageIdCache.value[id]!)
|
||||
} catch (error) {
|
||||
console.error('获取签名链接失败:', error)
|
||||
urls.push(DEFAULT_SHOP_IMAGE)
|
||||
|
||||
@@ -181,7 +181,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { message } from 'ant-design-vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { adminTagApi, adminShopApi, type Shop } from '@/api/admin'
|
||||
@@ -244,7 +244,7 @@ const formState = reactive({
|
||||
const formRules = {
|
||||
tagName: [{ required: true, message: '请输入标签名称', trigger: 'blur' }],
|
||||
shopId: [{ required: true, message: '请选择所属店铺', trigger: 'change' }]
|
||||
}
|
||||
} as any
|
||||
|
||||
const columns = [
|
||||
{ title: '标签名称', dataIndex: 'tagName', key: 'tagName' },
|
||||
@@ -264,9 +264,9 @@ const fetchTags = async () => {
|
||||
const shopId = (currentUser && currentUser.shopId) ? currentUser.shopId : undefined
|
||||
let tags
|
||||
if (shopId) {
|
||||
tags = await adminTagApi.listTagsByShopId(shopId)
|
||||
tags = await adminTagApi.listTagsByShopId(shopId) as unknown as any[]
|
||||
} else {
|
||||
tags = await adminTagApi.listAllTags()
|
||||
tags = await adminTagApi.listAllTags() as unknown as any[]
|
||||
}
|
||||
tagList.value = tags || []
|
||||
pagination.total = tagList.value.length
|
||||
@@ -281,7 +281,7 @@ const fetchTags = async () => {
|
||||
const fetchShops = async () => {
|
||||
loadingShops.value = true
|
||||
try {
|
||||
const res = await adminShopApi.listAllShops()
|
||||
const res = await adminShopApi.listAllShops() as unknown as any[]
|
||||
shops.value = res || []
|
||||
} catch (error) {
|
||||
console.error('获取店铺列表失败:', error)
|
||||
@@ -385,7 +385,7 @@ const handleModalCancel = () => {
|
||||
}
|
||||
|
||||
const handleDelete = (record: any) => {
|
||||
message.confirm({
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: `确定要删除标签 ${record.tagName} 吗?`,
|
||||
onOk: async () => {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
<template v-else-if="column.key === 'status'">
|
||||
<a-switch
|
||||
:checked="record.status === 1"
|
||||
@change="(checked) => handleStatusChange(record, checked)"
|
||||
@change="(checked: any) => handleStatusChange(record, checked === true)"
|
||||
/>
|
||||
</template>
|
||||
<template v-else-if="column.key === 'actions'">
|
||||
@@ -197,12 +197,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted, computed } from 'vue'
|
||||
import { ref, reactive, onMounted } from 'vue'
|
||||
import { message, Modal } from 'ant-design-vue'
|
||||
import type { FormInstance } from 'ant-design-vue'
|
||||
import { PlusOutlined } from '@ant-design/icons-vue'
|
||||
import { DEFAULT_AVATAR } from '@/constants'
|
||||
import { userApi, type UserVO, adminShopApi, type Shop } from '@/api/admin'
|
||||
import { userApi, adminShopApi, type Shop } from '@/api/admin'
|
||||
import type { UserVO } from '@/api/user'
|
||||
import { usePermission } from '@/utils/permission'
|
||||
|
||||
const { hasPermission, loadUserPermissions } = usePermission()
|
||||
@@ -233,7 +234,7 @@ const viewModalVisible = ref(false)
|
||||
const isEdit = ref(false)
|
||||
const isAdmin = ref(false)
|
||||
const formRef = ref<FormInstance>()
|
||||
const currentUser = ref<UserVO | null>(null)
|
||||
const currentUser = ref<UserVO | Record<string, any> | null>(null)
|
||||
const currentUserInfo = getCurrentUserInfo()
|
||||
|
||||
const viewFormState = reactive({
|
||||
@@ -270,7 +271,7 @@ const formRules = {
|
||||
password: [{ required: true, message: '请输入密码', trigger: 'blur' }],
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
type: [{ required: true, message: '请选择用户类型', trigger: 'change' }]
|
||||
}
|
||||
} as any
|
||||
|
||||
const columns = [
|
||||
{ title: '头像', key: 'avatar', width: 80 },
|
||||
@@ -313,7 +314,7 @@ const fetchShopList = async () => {
|
||||
shopList.value = []
|
||||
formState.shopId = currentUserInfo.shopId
|
||||
} else {
|
||||
const res = await adminShopApi.listAllShops()
|
||||
const res = await adminShopApi.listAllShops() as unknown as any[]
|
||||
shopList.value = res || []
|
||||
if (currentUserInfo && currentUserInfo.type !== 4 && currentUserInfo.shopId) {
|
||||
formState.shopId = currentUserInfo.shopId
|
||||
@@ -346,9 +347,9 @@ const fetchUserList = async () => {
|
||||
|
||||
const res = await userApi.listUsers(params)
|
||||
// 前端再次过滤,确保只显示级别比当前用户低的用户
|
||||
let filteredList = res.list || []
|
||||
let filteredList = (res as any).list || []
|
||||
if (currentUserInfo && currentUserInfo.type !== 4) {
|
||||
filteredList = filteredList.filter(user => {
|
||||
filteredList = filteredList.filter((user: any) => {
|
||||
if (currentUserInfo.type === 2) {
|
||||
// 店长可以看到美甲师(3)和用户(0)
|
||||
return user.type === 3 || user.type === 0
|
||||
@@ -392,13 +393,13 @@ const showAddModal = () => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showEditModal = (record: UserVO) => {
|
||||
const showEditModal = (record: UserVO | Record<string, any>) => {
|
||||
isEdit.value = true
|
||||
currentUser.value = record
|
||||
Object.assign(formState, {
|
||||
account: record.account,
|
||||
nickname: record.nickname,
|
||||
phone: record.phone,
|
||||
phone: (record as any).phone || '',
|
||||
password: '',
|
||||
type: record.type,
|
||||
shopId: record.shopId
|
||||
@@ -406,11 +407,11 @@ const showEditModal = (record: UserVO) => {
|
||||
modalVisible.value = true
|
||||
}
|
||||
|
||||
const showViewModal = (record: UserVO) => {
|
||||
const showViewModal = (record: UserVO | Record<string, any>) => {
|
||||
Object.assign(viewFormState, {
|
||||
account: record.account,
|
||||
nickname: record.nickname,
|
||||
phone: record.phone,
|
||||
phone: (record as any).phone || '',
|
||||
shopId: record.shopId,
|
||||
type: record.type,
|
||||
createTime: record.createTime
|
||||
@@ -426,7 +427,7 @@ const checkAccountExists = async (account: string) => {
|
||||
try {
|
||||
const res = await userApi.listUsers({ page: 1, size: 1000, keyword: account, status: 1 })
|
||||
// 只检查未被删除的账号(status为1表示正常,0表示删除)
|
||||
return res.list?.some(user => user.account === account)
|
||||
return (res as any).list?.some((user: any) => user.account === account)
|
||||
} catch (error) {
|
||||
console.error('检查账号是否存在失败:', error)
|
||||
return false
|
||||
@@ -467,9 +468,9 @@ const handleModalOk = async () => {
|
||||
status: 0 // 只查询已删除的用户
|
||||
})
|
||||
|
||||
if (deletedUser.list && deletedUser.list.length > 0) {
|
||||
if ((deletedUser as any).list && (deletedUser as any).list.length > 0) {
|
||||
// 找到已删除的账号,恢复它
|
||||
const user = deletedUser.list[0]
|
||||
const user = (deletedUser as any).list[0]
|
||||
await userApi.updateUserStatus(user.id, 1)
|
||||
message.success('账号已恢复')
|
||||
} else {
|
||||
@@ -500,7 +501,7 @@ const handleModalCancel = () => {
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
|
||||
const handleStatusChange = async (record: UserVO, checked: boolean) => {
|
||||
const handleStatusChange = async (record: UserVO | Record<string, any>, checked: boolean) => {
|
||||
try {
|
||||
await userApi.updateUserStatus(record.id, checked ? 1 : 0)
|
||||
message.success('状态更新成功')
|
||||
@@ -511,7 +512,7 @@ const handleStatusChange = async (record: UserVO, checked: boolean) => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleResetPassword = (record: UserVO) => {
|
||||
const handleResetPassword = (record: UserVO | Record<string, any>) => {
|
||||
Modal.confirm({
|
||||
title: '确认重置密码',
|
||||
content: `确定要将用户 ${record.nickname} 的密码重置为 888888 吗?`,
|
||||
@@ -526,7 +527,7 @@ const handleResetPassword = (record: UserVO) => {
|
||||
})
|
||||
}
|
||||
|
||||
const handleDelete = async (record: UserVO) => {
|
||||
const handleDelete = async (record: UserVO | Record<string, any>) => {
|
||||
try {
|
||||
if (record.type === 4) {
|
||||
message.warning('管理员账号无法被删除')
|
||||
|
||||
@@ -6,9 +6,9 @@ spring:
|
||||
nacos:
|
||||
discovery:
|
||||
# Nacos集群地址
|
||||
server-addr: 192.168.5.101:8848,192.168.5.102:8848,192.168.5.103:8848
|
||||
server-addr: home-nacos01:8848,home-nacos02:8848,home-nacos03:8848
|
||||
# 命名空间ID
|
||||
namespace: YumiNail
|
||||
namespace: YumiNail-dev
|
||||
# 分组名称
|
||||
group: DEFAULT_GROUP
|
||||
# 服务名称
|
||||
@@ -23,9 +23,9 @@ spring:
|
||||
password: 122503wcy....
|
||||
config:
|
||||
# Nacos配置中心集群地址
|
||||
server-addr: 192.168.5.101:8848,192.168.5.102:8848,192.168.5.103:8848
|
||||
server-addr: home-nacos01:8848,home-nacos02:8848,home-nacos03:8848
|
||||
# 配置中心命名空间
|
||||
namespace: YumiNail
|
||||
namespace: YumiNail-dev
|
||||
# 配置分组
|
||||
group: DEFAULT_GROUP
|
||||
# 配置文件名称
|
||||
|
||||
@@ -5,15 +5,15 @@ spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: 192.168.5.101:8848,192.168.5.102:8848,192.168.5.103:8848
|
||||
namespace: YumiNail
|
||||
server-addr: home-nacos01:8848,home-nacos02:8848,home-nacos03:8848
|
||||
namespace: YumiNail-dev
|
||||
group: DEFAULT_GROUP
|
||||
service: ${spring.application.name}
|
||||
username: xiaowang
|
||||
password: 122503wcy....
|
||||
config:
|
||||
server-addr: 192.168.5.101:8848,192.168.5.102:8848,192.168.5.103:8848
|
||||
namespace: YumiNail
|
||||
server-addr: home-nacos01:8848,home-nacos02:8848,home-nacos03:8848
|
||||
namespace: YumiNail-dev
|
||||
group: DEFAULT_GROUP
|
||||
name: yuminail-gateway
|
||||
file-extension: yaml
|
||||
|
||||
Reference in New Issue
Block a user