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