From 1220a9ebba0e3cbf91cb9af18a95cc42e872c653 Mon Sep 17 00:00:00 2001 From: xiaowang Date: Fri, 27 Mar 2026 10:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=A0=87=E7=AD=BE=E5=BA=97=E9=93=BA=E7=BB=91=E5=AE=9A=E4=B8=8E?= =?UTF-8?q?=E4=BD=9C=E5=93=81=E4=BC=98=E6=83=A0=E5=88=B8=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/src/api/admin.ts | 1 + Frontend/src/views/admin/ProductsView.vue | 84 ++++++++++++++-- Frontend/src/views/admin/TagsView.vue | 17 +++- .../controller/AdminCouponController.java | 9 +- .../service/impl/ProductServiceImpl.java | 95 ++++++++++++++++--- .../service/impl/TagServiceImpl.java | 81 ++++++++++++++-- .../com/xiaowang/yuminailcore/vo/TagVO.java | 5 + ...2026-03-27-作品优惠券全选与标签店铺修复.md | 93 ++++++++++++++++++ .../2026-03-27_tag_shop_unique_patch.sql | 38 ++++++++ 9 files changed, 386 insertions(+), 37 deletions(-) create mode 100644 docs/changes/2026-03-27-作品优惠券全选与标签店铺修复.md create mode 100644 docs/changes/2026-03-27_tag_shop_unique_patch.sql diff --git a/Frontend/src/api/admin.ts b/Frontend/src/api/admin.ts index 2e64326f..7603fd59 100644 --- a/Frontend/src/api/admin.ts +++ b/Frontend/src/api/admin.ts @@ -270,6 +270,7 @@ export interface Tag { bgColor?: string borderColor?: string shopId?: number + shopName?: string createTime: string updateTime: string } diff --git a/Frontend/src/views/admin/ProductsView.vue b/Frontend/src/views/admin/ProductsView.vue index 6620f1fe..6ecca402 100644 --- a/Frontend/src/views/admin/ProductsView.vue +++ b/Frontend/src/views/admin/ProductsView.vue @@ -51,7 +51,7 @@ @@ -469,10 +487,18 @@ const columns = [ ] const getShopName = (shopId: number): string => { - const shop = shops.value.find(s => s.id === shopId) + const normalizedShopId = normalizeShopIdValue(shopId) + const shop = shops.value.find(s => normalizeShopIdValue(s.id) === normalizedShopId) return shop ? shop.shopName : '未知店铺' } +const normalizeShopIdValue = (value: string | number | undefined | null) => { + if (value === undefined || value === null || value === '') { + return '' + } + return String(value) +} + const getCurrentUserInfo = () => { try { const userInfoStr = localStorage.getItem('adminUserInfo') @@ -488,11 +514,13 @@ const getCurrentUserInfo = () => { return null } -const isShopOwner = () => { +const canManageAvailableCoupons = () => { const userInfo = getCurrentUserInfo() - return userInfo && userInfo.type === 2 + return Boolean(userInfo && (userInfo.type === 2 || userInfo.type === 4)) } +const isCouponSelectionDisabled = computed(() => !canManageAvailableCoupons()) + const fetchShops = async () => { loadingShops.value = true try { @@ -556,12 +584,29 @@ const fetchArtists = async (shopId?: number) => { } } -const fetchCoupons = async () => { +const syncAvailableCouponSelection = () => { + const availableCouponIdSet = new Set( + coupons.value + .map(coupon => coupon?.id) + .filter((id): id is number => id !== undefined && id !== null) + .map(id => String(id)) + ) + formState.availableCoupons = formState.availableCoupons.filter(couponId => availableCouponIdSet.has(String(couponId))) +} + +const fetchCoupons = async (shopId?: number) => { + if (!shopId) { + coupons.value = [] + formState.availableCoupons = [] + return + } + loadingCoupons.value = true try { - const response = await adminCouponApi.listAllCoupons() + const response = await adminCouponApi.listAllCoupons(shopId) const res = typeof response === 'object' && 'data' in response ? response.data : response coupons.value = (res as any[]) || [] + syncAvailableCouponSelection() } catch (error) { console.error('获取优惠券列表失败', error) message.error('获取优惠券列表失败') @@ -669,6 +714,7 @@ const showAddModal = async () => { // 如果有店铺ID,获取该店铺的美甲师列表 if (shopId) { fetchArtists(shopId) + fetchCoupons(shopId) } await restoreDraft() modalVisible.value = true @@ -721,6 +767,7 @@ const showEditModal = async (record: Product | Record) => { // 获取该店铺的美甲师列表 if (recordShopId) { await fetchArtists(recordShopId) + await fetchCoupons(recordShopId) } await restoreDraft() @@ -785,6 +832,7 @@ const showViewModal = async (record: Product | Record) => { // 获取该店铺的美甲师列表 if (recordShopId) { await fetchArtists(recordShopId) + await fetchCoupons(recordShopId) } viewModalVisible.value = true @@ -1097,11 +1145,24 @@ const handleDelete = async (record: Product | Record) => { } } +const handleSelectAllCoupons = () => { + if (isCouponSelectionDisabled.value) { + return + } + formState.availableCoupons = coupons.value + .map(coupon => coupon?.id) + .filter((id): id is number => id !== undefined && id !== null) + .map(id => String(id)) +} + +const handleClearAvailableCoupons = () => { + formState.availableCoupons = [] +} + onMounted(async () => { await loadUserPermissions() fetchShops() fetchTags() - fetchCoupons() fetchProductList() }) @@ -1110,9 +1171,12 @@ watch(() => formState.shopId, (newShopId) => { if (newShopId) { fetchTags(newShopId) fetchArtists(newShopId) + fetchCoupons(newShopId) } else { tags.value = [] artists.value = [] + coupons.value = [] + formState.availableCoupons = [] } }) @@ -1146,4 +1210,8 @@ watch(() => formState.shopId, (newShopId) => { line-height: 1.6; margin-top: 6px; } + +.coupon-actions { + margin-top: 6px; +} diff --git a/Frontend/src/views/admin/TagsView.vue b/Frontend/src/views/admin/TagsView.vue index 27dedddf..bb8c22df 100644 --- a/Frontend/src/views/admin/TagsView.vue +++ b/Frontend/src/views/admin/TagsView.vue @@ -42,7 +42,7 @@