功能:新增下一阶段运营能力和生产部署

This commit is contained in:
xiaowang
2026-05-24 18:09:11 +08:00
parent 8116abc9b5
commit 1d077d4089
157 changed files with 9206 additions and 74 deletions
+206 -1
View File
@@ -966,6 +966,199 @@ export interface PageResult<T> {
size: number
}
export interface ArtistScheduleVO {
id: IdType
shopId?: IdType
artistId: IdType
workDate: string
startTime: string
endTime: string
slotMinutes?: number
capacity?: number
status?: number
remark?: string
createTime?: string
}
export interface ArtistScheduleRequest {
shopId?: IdType
artistId?: IdType
workDate?: string
startTime?: string
endTime?: string
slotMinutes?: number
capacity?: number
status?: number
remark?: string
}
export interface ArtistScheduleQuery {
artistId?: IdType
startDate?: string
endDate?: string
}
export interface PaymentOrderVO {
id: IdType
payNo?: string
orderId: IdType
orderNo?: string
userId?: IdType
shopId?: IdType
channel?: string
status?: string
payAmount?: number
paidAmount?: number
payTime?: string
expireTime?: string
remark?: string
}
export interface AfterSaleVO {
id: IdType
afterSaleNo?: string
orderId: IdType
orderItemId?: IdType
userId?: IdType
shopId?: IdType
type?: string
reason?: string
refundAmount?: number
status?: string
auditUserId?: IdType
auditReason?: string
auditTime?: string
refundOrderId?: IdType
createTime?: string
}
export interface AfterSaleAuditRequest {
auditReason?: string
}
export interface AfterSaleQuery {
status?: string
page: number
size: number
}
export interface InventoryItemVO {
id: IdType
shopId?: IdType
category?: string
itemName: string
unit?: string
stockQuantity?: number
warningThreshold?: number
warning?: boolean
status?: number
}
export interface InventoryItemRequest {
shopId?: IdType
category?: string
itemName?: string
unit?: string
stockQuantity?: number
warningThreshold?: number
status?: number
}
export interface InventoryAdjustRequest {
changeType?: string
changeQuantity?: number
remark?: string
}
export interface CampaignVO {
id: IdType
shopId?: IdType
title: string
description?: string
scene?: string
productIds?: string
couponIds?: string
status?: number
startTime?: string
endTime?: string
sortOrder?: number
}
export interface CampaignRequest {
shopId?: IdType
title?: string
description?: string
scene?: string
productIds?: string
couponIds?: string
status?: number
startTime?: string
endTime?: string
sortOrder?: number
}
export interface OperationsAnalyticsVO {
viewCount?: number
favoriteCount?: number
cartCount?: number
orderCount?: number
paidOrderCount?: number
completedOrderCount?: number
reviewCount?: number
rebookCount?: number
totalAmount?: number
}
export const adminArtistScheduleApi = {
listSchedules: (params: ArtistScheduleQuery = {}) => {
return adminApi.get<ArtistScheduleVO[]>('/artist-schedule/list', { params }) as unknown as Promise<ArtistScheduleVO[]>
},
saveSchedule: (data: ArtistScheduleRequest) => {
return adminApi.post<ArtistScheduleVO>('/artist-schedule/save', data) as unknown as Promise<ArtistScheduleVO>
}
}
export const adminPaymentApi = {
manualConfirmOrder: (orderId: IdType, remark?: string) => {
return adminApi.post<PaymentOrderVO>(`/payment/order/${orderId}/manual-confirm`, undefined, {
params: { remark }
}) as unknown as Promise<PaymentOrderVO>
}
}
export const adminAfterSaleApi = {
listAfterSales: (params: AfterSaleQuery) => {
return adminApi.get<PageResult<AfterSaleVO>>('/after-sale/list', { params }) as unknown as Promise<PageResult<AfterSaleVO>>
},
approveAfterSale: (id: IdType, data?: AfterSaleAuditRequest) => {
return adminApi.put<AfterSaleVO>(`/after-sale/${id}/approve`, data || {}) as unknown as Promise<AfterSaleVO>
},
rejectAfterSale: (id: IdType, data?: AfterSaleAuditRequest) => {
return adminApi.put<AfterSaleVO>(`/after-sale/${id}/reject`, data || {}) as unknown as Promise<AfterSaleVO>
}
}
export const adminInventoryApi = {
listItems: (params: { page: number; size: number }) => {
return adminApi.get<PageResult<InventoryItemVO>>('/inventory/list', { params }) as unknown as Promise<PageResult<InventoryItemVO>>
},
saveItem: (data: InventoryItemRequest) => {
return adminApi.post<InventoryItemVO>('/inventory/save', data) as unknown as Promise<InventoryItemVO>
},
adjustStock: (id: IdType, data: InventoryAdjustRequest) => {
return adminApi.post<InventoryItemVO>(`/inventory/${id}/adjust`, data) as unknown as Promise<InventoryItemVO>
}
}
export const adminCampaignApi = {
listCampaigns: (params: { status?: number; page: number; size: number }) => {
return adminApi.get<PageResult<CampaignVO>>('/campaign/list', { params }) as unknown as Promise<PageResult<CampaignVO>>
},
saveCampaign: (data: CampaignRequest) => {
return adminApi.post<CampaignVO>('/campaign/save', data) as unknown as Promise<CampaignVO>
}
}
/**
* adminUserApi groups all API calls for this page domain.
* Call guide: pass the typed payload or identifier into the method below, and use the returned Promise in the page script.
@@ -1199,6 +1392,12 @@ export interface OrderVO {
actualAmount?: number
discountAmount: number
payAmount: number
paidAmount?: number
paymentStatus?: string
paymentMethod?: string
paymentOrderNo?: string
payTime?: string
refundStatus?: string
couponName?: string
customerName?: string
customerPhone?: string
@@ -1242,6 +1441,9 @@ export const adminOrderApi = {
*/
updateOrderStatus: (id: IdType, status: number) => {
return adminApi.put<boolean>(`/order/update-status/${id}`, {}, { params: { status } })
},
manualConfirmPayment: (id: IdType, remark?: string) => {
return adminPaymentApi.manualConfirmOrder(id, remark)
}
}
@@ -1304,6 +1506,9 @@ export const adminDashboardApi = {
*/
getStats: () => {
return adminApi.get<DashboardStats>('/dashboard/stats')
},
getAnalytics: () => {
return adminApi.get<OperationsAnalyticsVO>('/dashboard/analytics') as unknown as Promise<OperationsAnalyticsVO>
}
}
@@ -1340,7 +1545,7 @@ export const adminNailArtistApi = {
* Call guide: supply the parameters below, await the returned Promise, and handle loading / error UI in the caller.
*/
listNailArtists: () => {
return adminApi.get<NailArtistInfoVO[]>('/nail-artist/list')
return adminApi.get<NailArtistInfoVO[]>('/nail-artist/list') as unknown as Promise<NailArtistInfoVO[]>
},
/**
* `getNailArtistInfo` API call. Use this method from the page script to invoke the backend endpoint tied to this feature.
@@ -19,6 +19,7 @@ export const WEB_API_AUTH_FREE_PATHS = [
'/nail-artist/',
'/shop/get/',
'/shop/trust-profile/',
'/shop/list',
'/shop/list/public',
'/shop/list/simple',
'/tag/list/all',
+79
View File
@@ -61,6 +61,85 @@ export interface CheckoutPreview {
summaryText?: string
}
export interface PaymentOrderVO {
id: IdType
payNo?: string
orderId: IdType
orderNo?: string
userId?: IdType
shopId?: IdType
channel?: string
status?: string
payAmount?: number
paidAmount?: number
payTime?: string
expireTime?: string
remark?: string
}
export interface AfterSaleApplyRequest {
orderId: IdType
orderItemId?: IdType
type: string
reason: string
refundAmount?: number
}
export interface AfterSaleVO {
id: IdType
afterSaleNo?: string
orderId: IdType
orderItemId?: IdType
userId?: IdType
shopId?: IdType
type?: string
reason?: string
refundAmount?: number
status?: string
auditReason?: string
auditTime?: string
createTime?: string
}
export interface PageResult<T> {
list: T[]
total: number
page: number
size: number
}
export interface GrowthSummaryVO {
userId?: IdType
growthValue?: number
levelName?: string
appointmentCount?: number
reviewCount?: number
}
export const paymentApi = {
prepareOrderPayment: async (orderId: IdType): Promise<PaymentOrderVO> => {
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/prepare`) as unknown as PaymentOrderVO
},
mockSuccess: async (orderId: IdType): Promise<PaymentOrderVO> => {
return await api.post<PaymentOrderVO>(`/payment/order/${orderId}/mock-success`) as unknown as PaymentOrderVO
}
}
export const afterSaleApi = {
apply: async (data: AfterSaleApplyRequest): Promise<AfterSaleVO> => {
return await api.post<AfterSaleVO>('/after-sale/apply', data) as unknown as AfterSaleVO
},
listMy: async (params: { page: number; size: number }): Promise<PageResult<AfterSaleVO>> => {
return await api.get<PageResult<AfterSaleVO>>('/after-sale/my', { params }) as unknown as PageResult<AfterSaleVO>
}
}
export const growthApi = {
getSummary: async (): Promise<GrowthSummaryVO> => {
return await api.get<GrowthSummaryVO>('/growth/summary') as unknown as GrowthSummaryVO
}
}
/**
* Purpose: ArtistCalendarAppointment supports order.ts by holding or executing the artist calendar appointment page or API role.
* Usage: import, call, read, or update this interface from the owning page/module while preserving the surrounding loading and permission flow.
-1
View File
@@ -34,7 +34,6 @@ declare module 'vue' {
AEmpty: typeof import('ant-design-vue/es')['Empty']
AForm: typeof import('ant-design-vue/es')['Form']
AFormItem: typeof import('ant-design-vue/es')['FormItem']
AGrid: typeof import('ant-design-vue/es')['Grid']
AImage: typeof import('ant-design-vue/es')['Image']
AInput: typeof import('ant-design-vue/es')['Input']
AInputNumber: typeof import('ant-design-vue/es')['InputNumber']
+24
View File
@@ -187,6 +187,30 @@ const router = createRouter({
component: () => import('../views/admin/OrdersView.vue'),
meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'order:view' }
},
{
path: 'schedules',
name: 'admin-schedules',
component: () => import('../views/admin/SchedulesView.vue'),
meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'schedule:view' }
},
{
path: 'after-sales',
name: 'admin-after-sales',
component: () => import('../views/admin/AfterSalesView.vue'),
meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'after_sale:view' }
},
{
path: 'inventory',
name: 'admin-inventory',
component: () => import('../views/admin/InventoryView.vue'),
meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'inventory:view' }
},
{
path: 'campaigns',
name: 'admin-campaigns',
component: () => import('../views/admin/CampaignsView.vue'),
meta: { requiresAuth: true, isAdmin: true, hideNav: true, permissionCode: 'campaign:view' }
},
{
path: 'manage',
name: 'admin-manage',
+178 -3
View File
@@ -9,6 +9,22 @@
</header>
<main class="content">
<section class="growth-panel">
<div>
<strong>{{ growthSummary.levelName || '成长会员' }}</strong>
<span>成长值 {{ growthSummary.growthValue ?? 0 }} · 预约 {{ growthSummary.appointmentCount ?? 0 }} 次 · 评价 {{ growthSummary.reviewCount ?? 0 }} 次</span>
</div>
<a-button size="small" @click="loadGrowthSummary">刷新</a-button>
</section>
<section v-if="myAfterSales.length" class="after-sale-panel">
<div class="after-sale-panel__title">我的售后</div>
<div v-for="item in myAfterSales.slice(0, 3)" :key="item.id" class="after-sale-row">
<span>{{ item.afterSaleNo || `售后 ${item.id}` }}</span>
<strong>{{ afterSaleStatusText(item.status) }}</strong>
</div>
</section>
<section v-if="orders.length" class="filter-panel">
<a-input v-model:value="filters.keyword" allow-clear placeholder="搜索订单号、作品、美甲师" />
<div class="filter-row">
@@ -102,6 +118,9 @@
<div class="footer">
<span>总计:¥{{ order.actualAmount.toFixed(2) }}</span>
<div class="footer-actions">
<a-button v-if="canPreparePayment(order)" size="small" @click="preparePayment(order)">准备支付</a-button>
<a-button v-if="canMockPay(order)" size="small" type="primary" @click="mockPay(order)">模拟支付</a-button>
<a-button v-if="canApplyAfterSale(order)" size="small" @click="openAfterSaleModal(order)">申请售后</a-button>
<a-button v-if="hasRebookableItems(order)" size="small" type="primary" @click="rebookOrder(order)">复刻同款</a-button>
<a-button v-if="order.status === 1" size="small" danger @click="cancelOrder(order.id)">取消订单</a-button>
</div>
@@ -152,6 +171,39 @@
</a-form-item>
</a-form>
</a-modal>
<a-modal
v-model:open="afterSaleModalOpen"
title="申请售后"
:confirm-loading="afterSaleSubmitting"
@ok="submitAfterSale"
@cancel="closeAfterSaleModal"
>
<a-form layout="vertical">
<a-form-item label="订单">
<a-input :value="activeAfterSaleOrder?.orderNo || ''" disabled />
</a-form-item>
<a-form-item label="订单项">
<a-select v-model:value="afterSaleForm.orderItemId" allow-clear placeholder="可选,默认整单">
<a-select-option v-for="item in activeAfterSaleOrder?.items || []" :key="item.id" :value="item.id">
{{ item.productTitle }}
</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="类型" required>
<a-select v-model:value="afterSaleForm.type">
<a-select-option value="REFUND">退款</a-select-option>
<a-select-option value="AFTER_SALE">售后</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="退款金额">
<a-input-number v-model:value="afterSaleForm.refundAmount" :min="0" :step="0.01" style="width: 100%" />
</a-form-item>
<a-form-item label="原因" required>
<a-textarea v-model:value="afterSaleForm.reason" :rows="4" :maxlength="300" placeholder="请说明申请原因" />
</a-form-item>
</a-form>
</a-modal>
</div>
</template>
@@ -166,8 +218,8 @@ import { LeftOutlined } from '@ant-design/icons-vue'
import { message, Modal } from 'ant-design-vue'
import { fileApi } from '../api/index'
import { cartApi } from '../api/cart'
import { orderApi } from '../api/order'
import type { OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
import { afterSaleApi, growthApi, orderApi, paymentApi } from '../api/order'
import type { AfterSaleVO, GrowthSummaryVO, OrderArtistChangeRequestVO, OrderArtistReviewVO } from '../api/order'
import { userApi } from '@/api/user'
import type { IdType } from '@/utils/id'
import { runWithGlobalLoading } from '@/utils/action-loading'
@@ -186,6 +238,8 @@ const updateCartCount = inject<() => Promise<void>>('updateCartCount', async ()
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const orders = ref<any[]>([])
const myAfterSales = ref<AfterSaleVO[]>([])
const growthSummary = ref<GrowthSummaryVO>({})
/**
* Purpose: imageIdCache supports OrderView.vue by holding or executing the image id cache page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -228,6 +282,9 @@ const activeReview = ref<OrderArtistReviewVO | null>(null)
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const rejectModalOpen = ref(false)
const afterSaleModalOpen = ref(false)
const afterSaleSubmitting = ref(false)
const activeAfterSaleOrder = ref<any | null>(null)
/**
* Purpose: changeProcessing supports OrderView.vue by holding or executing the change processing page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -265,6 +322,13 @@ const rejectForm = reactive({
rejectReason: ''
})
const afterSaleForm = reactive({
orderItemId: undefined as IdType | undefined,
type: 'REFUND',
reason: '',
refundAmount: undefined as number | undefined
})
/** filteredOrders is a reactive state variable used by the template and event handlers. */
const filteredOrders = computed(() => {
const keyword = filters.keyword.trim().toLowerCase()
@@ -305,6 +369,18 @@ const statusClass = (status: number) => {
return 'cancelled'
}
const isOrderPaid = (order: any) => String(order.paymentStatus || '').toUpperCase() === 'PAID'
const canPreparePayment = (order: any) => Number(order.status) === 1 && !isOrderPaid(order)
const canMockPay = (order: any) => Number(order.status) === 1 && String(order.paymentStatus || '').toUpperCase() === 'PAYING'
const canApplyAfterSale = (order: any) => Number(order.status) === 2 || isOrderPaid(order)
const afterSaleStatusText = (status?: string) => {
if (status === 'PENDING') return '待处理'
if (status === 'APPROVED') return '已通过'
if (status === 'REJECTED') return '已驳回'
return status || '-'
}
/**
* Purpose: sameId supports OrderView.vue by holding or executing the same id page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -474,6 +550,95 @@ const resetFilters = () => {
filters.maxAmount = undefined
}
const loadGrowthSummary = async () => {
try {
growthSummary.value = await growthApi.getSummary()
} catch (error) {
console.error('加载成长摘要失败:', error)
growthSummary.value = {}
}
}
const loadMyAfterSales = async () => {
try {
const result = await afterSaleApi.listMy({ page: 1, size: 20 })
myAfterSales.value = result.list || []
} catch (error) {
console.error('加载售后列表失败:', error)
myAfterSales.value = []
}
}
const preparePayment = async (order: any) => {
try {
await runWithGlobalLoading(async () => {
await paymentApi.prepareOrderPayment(order.id)
await loadOrders()
})
message.success('支付单已准备,可继续模拟支付')
} catch (error: any) {
message.error(error?.message || '准备支付失败')
}
}
const mockPay = async (order: any) => {
try {
await runWithGlobalLoading(async () => {
await paymentApi.mockSuccess(order.id)
await loadOrders()
})
message.success('模拟支付成功')
} catch (error: any) {
message.error(error?.message || '模拟支付失败')
}
}
const openAfterSaleModal = (order: any) => {
activeAfterSaleOrder.value = order
const firstItem = (order.items || [])[0]
afterSaleForm.orderItemId = firstItem?.id
afterSaleForm.type = 'REFUND'
afterSaleForm.reason = ''
afterSaleForm.refundAmount = Number(order.actualAmount || order.totalAmount || 0)
afterSaleModalOpen.value = true
}
const closeAfterSaleModal = () => {
afterSaleModalOpen.value = false
activeAfterSaleOrder.value = null
afterSaleForm.orderItemId = undefined
afterSaleForm.type = 'REFUND'
afterSaleForm.reason = ''
afterSaleForm.refundAmount = undefined
}
const submitAfterSale = async () => {
if (!activeAfterSaleOrder.value) return
if (!afterSaleForm.reason.trim()) {
message.warning('请填写售后原因')
return
}
afterSaleSubmitting.value = true
try {
await runWithGlobalLoading(async () => {
await afterSaleApi.apply({
orderId: activeAfterSaleOrder.value.id,
orderItemId: afterSaleForm.orderItemId,
type: afterSaleForm.type,
reason: afterSaleForm.reason.trim(),
refundAmount: afterSaleForm.refundAmount
})
await loadMyAfterSales()
})
message.success('售后申请已提交')
closeAfterSaleModal()
} catch (error: any) {
message.error(error?.message || '提交售后失败')
} finally {
afterSaleSubmitting.value = false
}
}
const normalizeRebookQuantity = (quantity: unknown) => {
const value = Number(quantity)
return Number.isFinite(value) && value > 0 ? Math.max(1, Math.floor(value)) : 1
@@ -803,7 +968,10 @@ const cancelOrder = (orderId: IdType) => {
})
}
onMounted(loadOrders)
onMounted(async () => {
await Promise.all([loadGrowthSummary(), loadMyAfterSales()])
await loadOrders()
})
</script>
<style scoped>
@@ -812,6 +980,13 @@ onMounted(loadOrders)
.header h1 { margin: 0; font-size: 18px; color: var(--text-primary); }
.placeholder { width: 40px; height: 40px; }
.content { padding: 15px; }
.growth-panel, .after-sale-panel { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; padding: 12px; border: 1px solid var(--theme-border); border-radius: 14px; background: var(--theme-card-bg); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
.growth-panel div { display: grid; gap: 4px; min-width: 0; }
.growth-panel strong, .after-sale-panel__title { color: var(--text-primary); font-weight: 700; }
.growth-panel span { color: var(--text-secondary); font-size: 13px; }
.after-sale-panel { display: grid; }
.after-sale-row { display: flex; justify-content: space-between; gap: 8px; color: var(--text-secondary); font-size: 13px; }
.after-sale-row strong { color: var(--theme-primary); }
.filter-panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 12px; border-radius: 14px; background: var(--theme-card-bg); border: 1px solid var(--theme-border); box-shadow: 0 14px 34px rgba(122, 67, 88, 0.08); }
.filter-row { display: flex; gap: 8px; align-items: center; }
.filter-select, .filter-date, .filter-number { flex: 1; min-width: 0; }
@@ -140,6 +140,7 @@
import { computed, inject, onMounted, ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import {
CalendarOutlined,
HeartFilled,
HeartOutlined,
LeftOutlined,
@@ -218,6 +218,7 @@ import {
DownOutlined,
GiftOutlined,
HomeOutlined,
CalendarOutlined,
IdcardOutlined,
LogoutOutlined,
MessageOutlined,
@@ -228,6 +229,7 @@ import {
SafetyCertificateOutlined,
ShopOutlined,
ShoppingOutlined,
ToolOutlined,
TagOutlined,
TeamOutlined,
UserOutlined
@@ -307,6 +309,10 @@ const menuItems: AdminMenuItem[] = [
{ key: '/admin/permissions', icon: SafetyCertificateOutlined, label: '权限管理', permissionCode: 'permission:view' },
{ key: '/admin/tags', icon: TagOutlined, label: '标签管理', permissionCode: 'tag:view' },
{ key: '/admin/orders', icon: ShoppingOutlined, label: '订单管理', permissionCode: 'order:view' },
{ key: '/admin/schedules', icon: CalendarOutlined, label: '排班管理', permissionCode: 'schedule:view' },
{ key: '/admin/after-sales', icon: MessageOutlined, label: '售后处理', permissionCode: 'after_sale:view' },
{ key: '/admin/inventory', icon: ToolOutlined, label: '库存管理', permissionCode: 'inventory:view' },
{ key: '/admin/campaigns', icon: GiftOutlined, label: '活动管理', permissionCode: 'campaign:view' },
{ key: '/admin/nail-artists', icon: TeamOutlined, label: '美甲师管理', permissionCode: 'nail_artist:view' }
,
{ key: '/admin/messages', icon: MessageOutlined, label: '消息发布', permissionCode: 'message:view' },
@@ -385,7 +391,11 @@ const activeMobileTab = computed(() => {
route.path.startsWith('/admin/shops') ||
route.path.startsWith('/admin/permissions') ||
route.path.startsWith('/admin/tags') ||
route.path.startsWith('/admin/nail-artists')
route.path.startsWith('/admin/nail-artists') ||
route.path.startsWith('/admin/schedules') ||
route.path.startsWith('/admin/after-sales') ||
route.path.startsWith('/admin/inventory') ||
route.path.startsWith('/admin/campaigns')
) {
return 'manage'
}
@@ -0,0 +1,286 @@
<template>
<div class="after-sales">
<a-page-header v-if="!isMobile" title="售后处理" sub-title="处理客户退款与售后申请" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">售后</span>
<h1 class="admin-page-intro__title">售后处理</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">申请 {{ pagination.total }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">售后列表</template>
<template #extra>
<div class="admin-toolbar" :class="{ 'admin-toolbar--stacked': isMobile }">
<a-select
v-model:value="statusFilter"
:options="statusOptions"
:style="isMobile ? { width: '100%' } : { width: '160px' }"
@change="reload"
/>
</div>
</template>
<a-table
v-if="!isMobile"
:columns="columns"
:data-source="visibleAfterSales"
:loading="loading"
:pagination="pagination"
row-key="id"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<a-tag :color="statusColor(record.status)">{{ statusText(record.status) }}</a-tag>
</template>
<template v-else-if="column.key === 'amount'">¥{{ money(record.refundAmount) }}</template>
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button type="link" size="small" @click="currentAfterSale = record as AfterSaleVO">查看</a-button>
<a-button v-if="record.status === 'PENDING'" type="primary" size="small" @click="openAudit(record as AfterSaleVO, 'approve')">通过</a-button>
<a-button v-if="record.status === 'PENDING'" danger size="small" @click="openAudit(record as AfterSaleVO, 'reject')">驳回</a-button>
</a-space>
</template>
</template>
</a-table>
<AdminMobileCardList v-else :items="visibleAfterSales" empty-description="暂无售后申请">
<template #item="{ item }">
<article class="admin-mobile-card">
<div class="admin-mobile-card__head">
<div class="admin-mobile-card__body">
<div class="admin-mobile-card__title">{{ item.afterSaleNo || `售后 ${item.id}` }}</div>
<div class="admin-mobile-card__subtitle">订单 {{ item.orderId }} · {{ item.createTime || '-' }}</div>
</div>
<a-tag :color="statusColor(item.status)">{{ statusText(item.status) }}</a-tag>
</div>
<div class="admin-mobile-card__rows">
<div class="admin-mobile-card__row">
<span>类型</span>
<strong>{{ typeText(item.type) }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>退款金额</span>
<strong>¥{{ money(item.refundAmount) }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>原因</span>
<strong>{{ item.reason || '-' }}</strong>
</div>
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="currentAfterSale = item">查看</a-button>
<a-button v-if="item.status === 'PENDING'" type="primary" size="small" @click="openAudit(item, 'approve')">通过</a-button>
<a-button v-if="item.status === 'PENDING'" danger size="small" @click="openAudit(item, 'reject')">驳回</a-button>
</div>
</article>
</template>
</AdminMobileCardList>
</a-card>
<AdminResponsiveModal
v-model:open="detailOpen"
title="售后详情"
:desktop-width="760"
:footer="null"
@cancel="currentAfterSale = null"
>
<a-descriptions v-if="currentAfterSale" bordered :column="1" size="small">
<a-descriptions-item label="售后单号">{{ currentAfterSale.afterSaleNo || '-' }}</a-descriptions-item>
<a-descriptions-item label="订单ID">{{ currentAfterSale.orderId }}</a-descriptions-item>
<a-descriptions-item label="订单项ID">{{ currentAfterSale.orderItemId || '-' }}</a-descriptions-item>
<a-descriptions-item label="用户ID">{{ currentAfterSale.userId || '-' }}</a-descriptions-item>
<a-descriptions-item label="类型">{{ typeText(currentAfterSale.type) }}</a-descriptions-item>
<a-descriptions-item label="退款金额">¥{{ money(currentAfterSale.refundAmount) }}</a-descriptions-item>
<a-descriptions-item label="状态">{{ statusText(currentAfterSale.status) }}</a-descriptions-item>
<a-descriptions-item label="申请原因">{{ currentAfterSale.reason || '-' }}</a-descriptions-item>
<a-descriptions-item label="审核原因">{{ currentAfterSale.auditReason || '-' }}</a-descriptions-item>
<a-descriptions-item label="申请时间">{{ currentAfterSale.createTime || '-' }}</a-descriptions-item>
</a-descriptions>
</AdminResponsiveModal>
<AdminResponsiveModal
v-model:open="auditOpen"
:title="auditAction === 'approve' ? '通过售后' : '驳回售后'"
:desktop-width="620"
:confirm-loading="auditing"
@ok="submitAudit"
@cancel="closeAudit"
>
<a-form layout="vertical">
<a-alert
v-if="auditTarget"
class="audit-alert"
type="info"
show-icon
:message="`${auditTarget.afterSaleNo || auditTarget.id} · 退款 ¥${money(auditTarget.refundAmount)}`"
:description="auditTarget.reason || '暂无申请原因'"
/>
<a-form-item label="处理备注">
<a-textarea v-model:value="auditReason" :rows="4" :maxlength="300" placeholder="填写给客户和门店留痕的处理说明" />
</a-form-item>
</a-form>
</AdminResponsiveModal>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { useRoute } from 'vue-router'
import { message } from 'ant-design-vue'
import { adminAfterSaleApi, type AfterSaleVO } from '@/api/admin'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { useAdminViewport } from '@/composables/useAdminViewport'
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { isMobile } = useAdminViewport()
const route = useRoute()
const loading = ref(false)
const auditing = ref(false)
const statusFilter = ref('all')
const afterSales = ref<AfterSaleVO[]>([])
const currentAfterSale = ref<AfterSaleVO | null>(null)
const auditOpen = ref(false)
const auditTarget = ref<AfterSaleVO | null>(null)
const auditAction = ref<'approve' | 'reject'>('approve')
const auditReason = ref('')
const pagination = reactive({
current: 1,
pageSize: 10,
total: 0,
showSizeChanger: true,
showTotal: (total: number) => `共 ${total} 条`
})
const detailOpen = computed({
get: () => !!currentAfterSale.value,
set: value => { if (!value) currentAfterSale.value = null }
})
const visibleAfterSales = computed(() => {
const orderId = route.query.orderId
if (!orderId) {
return afterSales.value
}
return afterSales.value.filter(item => String(item.orderId) === String(orderId))
})
const statusOptions = [
{ label: '全部状态', value: 'all' },
{ label: '待处理', value: 'PENDING' },
{ label: '已通过', value: 'APPROVED' },
{ label: '已驳回', value: 'REJECTED' }
]
const columns = [
{ title: '售后单号', dataIndex: 'afterSaleNo', key: 'afterSaleNo' },
{ title: '订单ID', dataIndex: 'orderId', key: 'orderId', width: 110 },
{ title: '用户ID', dataIndex: 'userId', key: 'userId', width: 110 },
{ title: '类型', dataIndex: 'type', key: 'type', width: 110 },
{ title: '退款金额', key: 'amount', width: 120 },
{ title: '状态', key: 'status', width: 110 },
{ title: '申请时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
{ title: '操作', key: 'actions', width: 190 }
]
const money = (value?: number) => Number(value || 0).toFixed(2)
const typeText = (type?: string) => {
if (type === 'REFUND') return '退款'
if (type === 'AFTER_SALE') return '售后'
return type || '-'
}
const statusText = (status?: string) => {
if (status === 'PENDING') return '待处理'
if (status === 'APPROVED') return '已通过'
if (status === 'REJECTED') return '已驳回'
return status || '-'
}
const statusColor = (status?: string) => {
if (status === 'PENDING') return 'orange'
if (status === 'APPROVED') return 'green'
if (status === 'REJECTED') return 'red'
return 'default'
}
const loadAfterSales = async () => {
loading.value = true
try {
const result = await adminAfterSaleApi.listAfterSales({
status: statusFilter.value === 'all' ? undefined : statusFilter.value,
page: pagination.current,
size: pagination.pageSize
})
afterSales.value = result.list || []
pagination.total = result.total || 0
} catch (error) {
console.error('加载售后失败:', error)
message.error('加载售后失败')
} finally {
loading.value = false
}
}
const reload = () => {
pagination.current = 1
void loadAfterSales()
}
const handleTableChange = (pag: any) => {
pagination.current = pag.current || 1
pagination.pageSize = pag.pageSize || pagination.pageSize
void loadAfterSales()
}
const openAudit = (record: AfterSaleVO, action: 'approve' | 'reject') => {
auditTarget.value = record
auditAction.value = action
auditReason.value = ''
auditOpen.value = true
}
const closeAudit = () => {
auditOpen.value = false
auditTarget.value = null
auditReason.value = ''
}
const submitAudit = async () => {
if (!auditTarget.value) return
auditing.value = true
try {
await runWithGlobalLoading(async () => {
const payload = { auditReason: auditReason.value.trim() || undefined }
if (auditAction.value === 'approve') {
await adminAfterSaleApi.approveAfterSale(auditTarget.value!.id, payload)
} else {
await adminAfterSaleApi.rejectAfterSale(auditTarget.value!.id, payload)
}
await loadAfterSales()
})
message.success('售后已处理')
closeAudit()
} catch (error: any) {
console.error('处理售后失败:', error)
message.error(error?.message || '处理售后失败')
} finally {
auditing.value = false
}
}
onMounted(loadAfterSales)
</script>
<style scoped>
.after-sales {
padding: 0;
}
.audit-alert {
margin-bottom: 16px;
}
</style>
@@ -0,0 +1,299 @@
<template>
<div class="campaigns">
<a-page-header v-if="!isMobile" title="活动管理" sub-title="维护营销活动、推荐位和关联资源" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">活动</span>
<h1 class="admin-page-intro__title">活动管理</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">活动 {{ pagination.total }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">活动列表</template>
<template #extra>
<div class="admin-toolbar" :class="{ 'admin-toolbar--stacked': isMobile }">
<a-select
v-model:value="statusFilter"
:options="statusOptions"
:style="isMobile ? { width: '100%' } : { width: '160px' }"
@change="reload"
/>
<a-button type="primary" @click="openCreateModal">
<template #icon>
<PlusOutlined />
</template>
新增活动
</a-button>
</div>
</template>
<a-table
v-if="!isMobile"
:columns="columns"
:data-source="campaigns"
:loading="loading"
:pagination="pagination"
row-key="id"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<a-tag :color="record.status === 0 ? 'red' : 'green'">{{ campaignStatusText(record.status) }}</a-tag>
</template>
<template v-else-if="column.key === 'time'">
{{ record.startTime || '-' }} 至 {{ record.endTime || '-' }}
</template>
<template v-else-if="column.key === 'actions'">
<a-button type="link" size="small" @click="openEditModal(record as CampaignVO)">编辑</a-button>
</template>
</template>
</a-table>
<AdminMobileCardList v-else :items="campaigns" empty-description="暂无活动数据">
<template #item="{ item }">
<article class="admin-mobile-card">
<div class="admin-mobile-card__head">
<div class="admin-mobile-card__body">
<div class="admin-mobile-card__title">{{ item.title }}</div>
<div class="admin-mobile-card__subtitle">{{ item.scene || 'GENERAL' }} · 排序 {{ item.sortOrder ?? 0 }}</div>
</div>
<a-tag :color="item.status === 0 ? 'red' : 'green'">{{ campaignStatusText(item.status) }}</a-tag>
</div>
<div class="admin-mobile-card__rows">
<div class="admin-mobile-card__row">
<span>时间</span>
<strong>{{ item.startTime || '-' }} 至 {{ item.endTime || '-' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>作品ID</span>
<strong>{{ item.productIds || '-' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>优惠券ID</span>
<strong>{{ item.couponIds || '-' }}</strong>
</div>
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="openEditModal(item)">编辑</a-button>
</div>
</article>
</template>
</AdminMobileCardList>
</a-card>
<AdminResponsiveModal
v-model:open="modalOpen"
:title="editingCampaign ? '编辑活动' : '新增活动'"
:desktop-width="760"
:confirm-loading="saving"
@ok="saveCampaign"
@cancel="closeModal"
>
<a-form ref="formRef" :model="formState" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
<a-form-item label="活动标题" name="title">
<a-input v-model:value="formState.title" placeholder="请输入活动标题" />
</a-form-item>
<a-form-item label="活动场景">
<a-input v-model:value="formState.scene" placeholder="HOME / DETAIL / POPUP" />
</a-form-item>
<a-form-item label="活动说明">
<a-textarea v-model:value="formState.description" :rows="3" :maxlength="500" />
</a-form-item>
<a-form-item label="关联作品ID">
<a-input v-model:value="formState.productIds" placeholder="多个 ID 用英文逗号分隔" />
</a-form-item>
<a-form-item label="关联券ID">
<a-input v-model:value="formState.couponIds" placeholder="多个 ID 用英文逗号分隔" />
</a-form-item>
<a-form-item label="开始时间">
<a-date-picker
v-model:value="formState.startTime"
show-time
value-format="YYYY-MM-DDTHH:mm:ss"
format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
/>
</a-form-item>
<a-form-item label="结束时间">
<a-date-picker
v-model:value="formState.endTime"
show-time
value-format="YYYY-MM-DDTHH:mm:ss"
format="YYYY-MM-DD HH:mm:ss"
style="width: 100%"
/>
</a-form-item>
<a-form-item label="排序">
<a-input-number v-model:value="formState.sortOrder" :min="0" style="width: 100%" />
</a-form-item>
<a-form-item label="状态">
<a-select v-model:value="formState.status">
<a-select-option :value="1">启用</a-select-option>
<a-select-option :value="0">停用</a-select-option>
</a-select>
</a-form-item>
</a-form>
</AdminResponsiveModal>
</div>
</template>
<script setup lang="ts">
import { onMounted, reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
import { adminCampaignApi, type CampaignRequest, type CampaignVO } from '@/api/admin'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { useAdminViewport } from '@/composables/useAdminViewport'
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { isMobile } = useAdminViewport()
const loading = ref(false)
const saving = ref(false)
const statusFilter = ref<'all' | number>('all')
const campaigns = ref<CampaignVO[]>([])
const modalOpen = ref(false)
const editingCampaign = ref<CampaignVO | null>(null)
const formRef = ref<FormInstance>()
const pagination = reactive({
current: 1,
pageSize: 10,
total: 0,
showSizeChanger: true,
showTotal: (total: number) => `共 ${total} 条`
})
const formState = reactive<CampaignRequest>({
title: '',
description: '',
scene: 'HOME',
productIds: '',
couponIds: '',
status: 1,
startTime: undefined,
endTime: undefined,
sortOrder: 0
})
const rules = {
title: [{ required: true, message: '请输入活动标题', trigger: 'blur' }]
} as any
const statusOptions = [
{ label: '全部状态', value: 'all' },
{ label: '启用', value: 1 },
{ label: '停用', value: 0 }
]
const columns = [
{ title: '标题', dataIndex: 'title', key: 'title' },
{ title: '场景', dataIndex: 'scene', key: 'scene', width: 120 },
{ title: '活动时间', key: 'time', width: 280 },
{ title: '排序', dataIndex: 'sortOrder', key: 'sortOrder', width: 90 },
{ title: '状态', key: 'status', width: 100 },
{ title: '操作', key: 'actions', width: 90 }
]
const campaignStatusText = (status?: number) => status === 0 ? '停用' : '启用'
const resetForm = () => {
Object.assign(formState, {
title: '',
description: '',
scene: 'HOME',
productIds: '',
couponIds: '',
status: 1,
startTime: undefined,
endTime: undefined,
sortOrder: 0
})
}
const loadCampaigns = async () => {
loading.value = true
try {
const result = await adminCampaignApi.listCampaigns({
status: statusFilter.value === 'all' ? undefined : Number(statusFilter.value),
page: pagination.current,
size: pagination.pageSize
})
campaigns.value = result.list || []
pagination.total = result.total || 0
} catch (error) {
console.error('加载活动失败:', error)
message.error('加载活动失败')
} finally {
loading.value = false
}
}
const reload = () => {
pagination.current = 1
void loadCampaigns()
}
const handleTableChange = (pag: any) => {
pagination.current = pag.current || 1
pagination.pageSize = pag.pageSize || pagination.pageSize
void loadCampaigns()
}
const openCreateModal = () => {
editingCampaign.value = null
resetForm()
modalOpen.value = true
}
const openEditModal = (record: CampaignVO) => {
editingCampaign.value = record
Object.assign(formState, {
title: record.title || '',
description: record.description || '',
scene: record.scene || 'HOME',
productIds: record.productIds || '',
couponIds: record.couponIds || '',
status: record.status ?? 1,
startTime: record.startTime,
endTime: record.endTime,
sortOrder: record.sortOrder ?? 0
})
modalOpen.value = true
}
const closeModal = () => {
modalOpen.value = false
formRef.value?.resetFields()
}
const saveCampaign = async () => {
try {
await formRef.value?.validate()
saving.value = true
await runWithGlobalLoading(async () => {
await adminCampaignApi.saveCampaign({ ...formState })
await loadCampaigns()
})
message.success('活动已保存')
closeModal()
} catch (error: any) {
if (error?.errorFields) return
console.error('保存活动失败:', error)
message.error(error?.message || '保存活动失败')
} finally {
saving.value = false
}
}
onMounted(loadCampaigns)
</script>
<style scoped>
.campaigns {
padding: 0;
}
</style>
@@ -20,11 +20,22 @@
<a-row :gutter="[16, 16]" class="stat-cards">
<a-col v-for="item in primaryStats" :key="item.key" :xs="24" :sm="12" :xl="6">
<a-card class="metric-card">
<a-statistic :title="item.title" :value="item.value" :precision="item.precision || 0" :loading="loading">
<a-statistic :title="item.title" :value="item.value" :precision="0" :loading="loading">
<template #prefix>
<component :is="item.icon" />
</template>
</a-statistic>
</a-card>
</a-col>
</a-row>
<a-row :gutter="[16, 16]" class="stat-cards">
<a-col v-for="item in analyticsStats" :key="item.key" :xs="24" :sm="12" :xl="6">
<a-card class="metric-card">
<a-statistic :title="item.title" :value="item.value" :precision="0" :loading="loading">
<template #prefix>
<component :is="item.icon" />
</template>
<template v-if="item.suffix" #suffix>{{ item.suffix }}</template>
</a-statistic>
</a-card>
</a-col>
@@ -99,15 +110,20 @@
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { computed, onMounted, reactive, ref, type Component } from 'vue'
import { useRouter } from 'vue-router'
import { message } from 'ant-design-vue'
import {
CheckCircleOutlined,
EyeOutlined,
GiftOutlined,
HeartOutlined,
HomeOutlined,
MessageOutlined,
ShopOutlined,
ShoppingCartOutlined,
ShoppingOutlined,
StarOutlined,
TeamOutlined,
UserOutlined
} from '@ant-design/icons-vue'
@@ -115,9 +131,18 @@ import {
* Purpose: DashboardStats supports DashboardView.vue by holding or executing the dashboard stats page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
*/
import { adminDashboardApi, type DashboardStats } from '@/api/admin'
import { adminDashboardApi, type DashboardStats, type OperationsAnalyticsVO } from '@/api/admin'
import { useAdminViewport } from '@/composables/useAdminViewport'
type StatCard = {
key: string
title: string
value: number
precision?: number
suffix?: string
icon: Component
}
/**
* Purpose: router supports DashboardView.vue by holding or executing the router page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -153,6 +178,18 @@ const stats = reactive<DashboardStats>({
recentActivities: []
})
const analytics = reactive<OperationsAnalyticsVO>({
viewCount: 0,
favoriteCount: 0,
cartCount: 0,
orderCount: 0,
paidOrderCount: 0,
completedOrderCount: 0,
reviewCount: 0,
rebookCount: 0,
totalAmount: 0
})
/**
* Purpose: getCurrentUserInfo supports DashboardView.vue by holding or executing the get current user info page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -203,13 +240,24 @@ const numberText = (value?: number) => String(Number(value || 0))
* Purpose: primaryStats supports DashboardView.vue by holding or executing the primary stats page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const primaryStats = computed(() => [
const primaryStats = computed<StatCard[]>(() => [
{ key: 'amount', title: '订单总额', value: money(stats.totalOrderAmount), precision: 2, suffix: '元', icon: ShoppingOutlined },
{ key: 'todayAmount', title: '今日订单额', value: money(stats.todayOrderAmount), precision: 2, suffix: '元', icon: ShoppingOutlined },
{ key: 'customers', title: '客户数量', value: stats.totalCustomers || stats.totalUsers || 0, icon: UserOutlined },
{ key: 'artists', title: '美甲师数量', value: stats.totalArtists || 0, icon: TeamOutlined }
])
const analyticsStats = computed<StatCard[]>(() => [
{ key: 'views', title: '浏览量', value: Number(analytics.viewCount || 0), icon: EyeOutlined },
{ key: 'favorites', title: '收藏量', value: Number(analytics.favoriteCount || 0), icon: HeartOutlined },
{ key: 'carts', title: '加购量', value: Number(analytics.cartCount || 0), icon: ShoppingCartOutlined },
{ key: 'orders', title: '下单量', value: Number(analytics.orderCount || 0), icon: ShoppingOutlined },
{ key: 'paid', title: '支付订单', value: Number(analytics.paidOrderCount || 0), icon: CheckCircleOutlined },
{ key: 'completed', title: '完成订单', value: Number(analytics.completedOrderCount || 0), icon: CheckCircleOutlined },
{ key: 'reviews', title: '评价数', value: Number(analytics.reviewCount || 0), icon: StarOutlined },
{ key: 'rebooks', title: '复购数', value: Number(analytics.rebookCount || 0), icon: ShoppingOutlined }
])
/**
* Purpose: overviewItems supports DashboardView.vue by holding or executing the overview items page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -266,6 +314,12 @@ const fetchStats = async () => {
try {
const data = await adminDashboardApi.getStats()
Object.assign(stats, data)
try {
const analyticsData = await adminDashboardApi.getAnalytics()
Object.assign(analytics, analyticsData)
} catch (analyticsError) {
console.error('获取经营分析数据失败:', analyticsError)
}
} catch (error) {
console.error('获取统计数据失败:', error)
message.error('获取统计数据失败')
@@ -66,8 +66,8 @@
<template #title>
快捷操作
</template>
<a-grid :columns="3" :colGap="16" :rowGap="16">
<a-grid-item v-for="item in quickActions" :key="item.key">
<a-row :gutter="[16, 16]">
<a-col v-for="item in quickActions" :key="item.key" :span="8">
<a-card hoverable @click="navigateTo(item.path, item.permissionCode)">
<template #cover>
<div class="action-icon">
@@ -78,8 +78,8 @@
{{ item.title }}
</template>
</a-card>
</a-grid-item>
</a-grid>
</a-col>
</a-row>
</a-card>
</template>
@@ -0,0 +1,343 @@
<template>
<div class="inventory">
<a-page-header v-if="!isMobile" title="库存管理" sub-title="维护门店耗材库存和预警阈值" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">库存</span>
<h1 class="admin-page-intro__title">库存管理</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">物料 {{ pagination.total }}</span>
<span class="admin-page-chip">预警 {{ warningCount }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">库存列表</template>
<template #extra>
<div class="admin-toolbar" :class="{ 'admin-toolbar--stacked': isMobile }">
<a-input-search
v-model:value="keyword"
placeholder="搜索物料或分类"
:style="isMobile ? { width: '100%' } : { width: '220px' }"
/>
<a-button type="primary" @click="openCreateModal">
<template #icon>
<PlusOutlined />
</template>
新增物料
</a-button>
</div>
</template>
<a-alert
v-if="warningCount"
class="inventory-alert"
type="warning"
show-icon
:message="`当前有 ${warningCount} 个物料低于预警阈值`"
/>
<a-table
v-if="!isMobile"
:columns="columns"
:data-source="filteredItems"
:loading="loading"
:pagination="pagination"
row-key="id"
@change="handleTableChange"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'stock'">
<a-tag :color="record.warning ? 'red' : 'green'">{{ numberText(record.stockQuantity) }} {{ record.unit || '' }}</a-tag>
</template>
<template v-else-if="column.key === 'warning'">{{ numberText(record.warningThreshold) }} {{ record.unit || '' }}</template>
<template v-else-if="column.key === 'status'">
<a-tag :color="record.status === 0 ? 'red' : 'green'">{{ record.status === 0 ? '停用' : '启用' }}</a-tag>
</template>
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button type="link" size="small" @click="openAdjustModal(record as InventoryItemVO, 'IN')">入库</a-button>
<a-button type="link" size="small" @click="openAdjustModal(record as InventoryItemVO, 'OUT')">出库</a-button>
</a-space>
</template>
</template>
</a-table>
<AdminMobileCardList v-else :items="filteredItems" empty-description="暂无库存物料">
<template #item="{ item }">
<article class="admin-mobile-card">
<div class="admin-mobile-card__head">
<div class="admin-mobile-card__body">
<div class="admin-mobile-card__title">{{ item.itemName }}</div>
<div class="admin-mobile-card__subtitle">{{ item.category || '未分类' }}</div>
</div>
<a-tag :color="item.warning ? 'red' : 'green'">{{ item.warning ? '预警' : '正常' }}</a-tag>
</div>
<div class="admin-mobile-card__rows">
<div class="admin-mobile-card__row">
<span>库存</span>
<strong>{{ numberText(item.stockQuantity) }} {{ item.unit || '' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>预警阈值</span>
<strong>{{ numberText(item.warningThreshold) }} {{ item.unit || '' }}</strong>
</div>
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="openAdjustModal(item, 'IN')">入库</a-button>
<a-button size="small" @click="openAdjustModal(item, 'OUT')">出库</a-button>
</div>
</article>
</template>
</AdminMobileCardList>
</a-card>
<AdminResponsiveModal
v-model:open="itemModalOpen"
title="新增物料"
:desktop-width="680"
:confirm-loading="savingItem"
@ok="saveItem"
@cancel="closeItemModal"
>
<a-form ref="itemFormRef" :model="itemForm" :rules="itemRules" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
<a-form-item label="物料名称" name="itemName">
<a-input v-model:value="itemForm.itemName" placeholder="例如:底胶" />
</a-form-item>
<a-form-item label="分类">
<a-input v-model:value="itemForm.category" placeholder="例如:胶类/工具/耗材" />
</a-form-item>
<a-form-item label="单位">
<a-input v-model:value="itemForm.unit" placeholder="瓶、盒、个" />
</a-form-item>
<a-form-item label="初始库存">
<a-input-number v-model:value="itemForm.stockQuantity" :min="0" :step="1" style="width: 100%" />
</a-form-item>
<a-form-item label="预警阈值">
<a-input-number v-model:value="itemForm.warningThreshold" :min="0" :step="1" style="width: 100%" />
</a-form-item>
<a-form-item label="状态">
<a-select v-model:value="itemForm.status">
<a-select-option :value="1">启用</a-select-option>
<a-select-option :value="0">停用</a-select-option>
</a-select>
</a-form-item>
</a-form>
</AdminResponsiveModal>
<AdminResponsiveModal
v-model:open="adjustModalOpen"
:title="adjustForm.changeType === 'OUT' ? '出库调整' : '入库调整'"
:desktop-width="600"
:confirm-loading="adjusting"
@ok="submitAdjust"
@cancel="closeAdjustModal"
>
<a-form ref="adjustFormRef" :model="adjustForm" :rules="adjustRules" layout="vertical">
<a-alert
v-if="adjustTarget"
class="inventory-alert"
type="info"
show-icon
:message="adjustTarget.itemName"
:description="`当前库存:${numberText(adjustTarget.stockQuantity)} ${adjustTarget.unit || ''}`"
/>
<a-form-item label="调整数量" name="changeQuantity">
<a-input-number v-model:value="adjustForm.changeQuantity" :step="1" style="width: 100%" />
</a-form-item>
<a-form-item label="备注">
<a-textarea v-model:value="adjustForm.remark" :rows="3" :maxlength="200" />
</a-form-item>
</a-form>
</AdminResponsiveModal>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
import { adminInventoryApi, type InventoryItemVO } from '@/api/admin'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { useAdminViewport } from '@/composables/useAdminViewport'
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { isMobile } = useAdminViewport()
const loading = ref(false)
const savingItem = ref(false)
const adjusting = ref(false)
const keyword = ref('')
const items = ref<InventoryItemVO[]>([])
const itemModalOpen = ref(false)
const adjustModalOpen = ref(false)
const adjustTarget = ref<InventoryItemVO | null>(null)
const itemFormRef = ref<FormInstance>()
const adjustFormRef = ref<FormInstance>()
const pagination = reactive({
current: 1,
pageSize: 10,
total: 0,
showSizeChanger: true,
showTotal: (total: number) => `共 ${total} 条`
})
const itemForm = reactive({
itemName: '',
category: '',
unit: '',
stockQuantity: 0,
warningThreshold: 0,
status: 1
})
const adjustForm = reactive({
changeType: 'IN' as 'IN' | 'OUT',
changeQuantity: 1,
remark: ''
})
const itemRules = {
itemName: [{ required: true, message: '请输入物料名称', trigger: 'blur' }]
} as any
const adjustRules = {
changeQuantity: [{ required: true, message: '请输入调整数量', trigger: 'blur' }]
} as any
const columns = [
{ title: '物料名称', dataIndex: 'itemName', key: 'itemName' },
{ title: '分类', dataIndex: 'category', key: 'category', width: 140 },
{ title: '库存', key: 'stock', width: 140 },
{ title: '预警阈值', key: 'warning', width: 140 },
{ title: '状态', key: 'status', width: 100 },
{ title: '操作', key: 'actions', width: 130 }
]
const warningCount = computed(() => items.value.filter(item => item.warning).length)
const filteredItems = computed(() => {
const value = keyword.value.trim().toLowerCase()
if (!value) return items.value
return items.value.filter(item => [item.itemName, item.category, item.unit].join(' ').toLowerCase().includes(value))
})
const numberText = (value?: number) => Number(value || 0).toFixed(2).replace(/\.00$/, '')
const resetItemForm = () => {
Object.assign(itemForm, {
itemName: '',
category: '',
unit: '',
stockQuantity: 0,
warningThreshold: 0,
status: 1
})
}
const loadItems = async () => {
loading.value = true
try {
const result = await adminInventoryApi.listItems({
page: pagination.current,
size: pagination.pageSize
})
items.value = result.list || []
pagination.total = result.total || 0
} catch (error) {
console.error('加载库存失败:', error)
message.error('加载库存失败')
} finally {
loading.value = false
}
}
const handleTableChange = (pag: any) => {
pagination.current = pag.current || 1
pagination.pageSize = pag.pageSize || pagination.pageSize
void loadItems()
}
const openCreateModal = () => {
resetItemForm()
itemModalOpen.value = true
}
const closeItemModal = () => {
itemModalOpen.value = false
itemFormRef.value?.resetFields()
}
const saveItem = async () => {
try {
await itemFormRef.value?.validate()
savingItem.value = true
await runWithGlobalLoading(async () => {
await adminInventoryApi.saveItem({ ...itemForm })
await loadItems()
})
message.success('物料已保存')
closeItemModal()
} catch (error: any) {
if (error?.errorFields) return
console.error('保存物料失败:', error)
message.error(error?.message || '保存物料失败')
} finally {
savingItem.value = false
}
}
const openAdjustModal = (record: InventoryItemVO, changeType: 'IN' | 'OUT') => {
adjustTarget.value = record
adjustForm.changeType = changeType
adjustForm.changeQuantity = changeType === 'OUT' ? -1 : 1
adjustForm.remark = ''
adjustModalOpen.value = true
}
const closeAdjustModal = () => {
adjustModalOpen.value = false
adjustTarget.value = null
adjustFormRef.value?.resetFields()
}
const submitAdjust = async () => {
if (!adjustTarget.value) return
const quantity = Number(adjustForm.changeQuantity || 0)
if (quantity === 0) {
message.warning('调整数量不能为 0')
return
}
adjusting.value = true
try {
await runWithGlobalLoading(async () => {
await adminInventoryApi.adjustStock(adjustTarget.value!.id, {
changeType: adjustForm.changeType,
changeQuantity: quantity,
remark: adjustForm.remark.trim() || undefined
})
await loadItems()
})
message.success('库存已调整')
closeAdjustModal()
} catch (error: any) {
console.error('库存调整失败:', error)
message.error(error?.message || '库存调整失败')
} finally {
adjusting.value = false
}
}
onMounted(loadItems)
</script>
<style scoped>
.inventory {
padding: 0;
}
.inventory-alert {
margin-bottom: 16px;
}
</style>
@@ -76,6 +76,22 @@
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button type="link" size="small" @click="currentOrder = record">查看</a-button>
<a-button
v-if="canManagePayments && record.paymentStatus !== 'PAID'"
type="link"
size="small"
@click="openManualPay(record)"
>
手动确认支付
</a-button>
<a-button
v-if="canViewAfterSales"
type="link"
size="small"
@click="openAfterSales(record)"
>
售后
</a-button>
<a-button
v-if="record.status === 1 && canProcessOrders"
type="primary"
@@ -129,6 +145,20 @@
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="currentOrder = item">查看详情</a-button>
<a-button
v-if="canManagePayments && item.paymentStatus !== 'PAID'"
size="small"
@click="openManualPay(item)"
>
确认支付
</a-button>
<a-button
v-if="canViewAfterSales"
size="small"
@click="openAfterSales(item)"
>
售后
</a-button>
<a-button
v-if="item.status === 1 && canProcessOrders"
size="small"
@@ -209,6 +239,29 @@
</div>
</template>
</AdminResponsiveModal>
<AdminResponsiveModal
v-model:open="manualPayOpen"
title="手动确认支付"
:desktop-width="560"
:confirm-loading="manualPayLoading"
@ok="submitManualPay"
@cancel="closeManualPay"
>
<a-form layout="vertical">
<a-alert
v-if="manualPayOrder"
class="order-action-alert"
type="warning"
show-icon
:message="manualPayOrder.orderNo"
:description="`将把订单标记为已支付,实付金额 ¥${moneyText(manualPayOrder.actualAmount || manualPayOrder.totalAmount)}`"
/>
<a-form-item label="确认备注">
<a-textarea v-model:value="manualPayRemark" :rows="3" :maxlength="200" placeholder="例如:线下现金已核验" />
</a-form-item>
</a-form>
</AdminResponsiveModal>
</div>
</template>
@@ -219,6 +272,7 @@
*/
import { computed, onMounted, ref } from 'vue'
import { message } from 'ant-design-vue'
import { useRouter } from 'vue-router'
/**
* Purpose: Shop supports OrdersView.vue by holding or executing the shop page or API role.
* Usage: import, call, read, or update this type from the owning page/module while preserving the surrounding loading and permission flow.
@@ -233,6 +287,7 @@ import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { isMobile } = useAdminViewport()
const router = useRouter()
/**
* Purpose: orders supports OrdersView.vue by holding or executing the orders page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -250,6 +305,10 @@ const shopLoading = ref(false)
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
*/
const currentOrder = ref<any | null>(null)
const manualPayOpen = ref(false)
const manualPayLoading = ref(false)
const manualPayOrder = ref<any | null>(null)
const manualPayRemark = ref('')
/**
* Purpose: currentUserType supports OrdersView.vue by holding or executing the current user type page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -324,6 +383,8 @@ const detailVisible = computed({
})
/** canProcessOrders is a reactive state variable used by the template and event handlers. */
const canProcessOrders = computed(() => hasPermission('order:process'))
const canManagePayments = computed(() => hasPermission('payment:manage'))
const canViewAfterSales = computed(() => hasPermission('after_sale:view'))
/** isArtist is a reactive state variable used by the template and event handlers. */
const isArtist = computed(() => currentUserType.value === 3)
/**
@@ -445,6 +506,8 @@ const statusColor = (status: number) => {
return 'default'
}
const moneyText = (value?: number) => Number(value || 0).toFixed(2)
/**
* Purpose: normalizeUserType supports OrdersView.vue by holding or executing the normalize user type page or API role.
* Usage: import, call, read, or update this const from the owning page/module while preserving the surrounding loading and permission flow.
@@ -530,6 +593,43 @@ const process = async (orderId: IdType, status: number) => {
}
}
const openManualPay = (order: any) => {
manualPayOrder.value = order
manualPayRemark.value = ''
manualPayOpen.value = true
}
const closeManualPay = () => {
manualPayOpen.value = false
manualPayOrder.value = null
manualPayRemark.value = ''
}
const submitManualPay = async () => {
if (!manualPayOrder.value) return
manualPayLoading.value = true
try {
await runWithGlobalLoading(async () => {
await adminOrderApi.manualConfirmPayment(manualPayOrder.value.id, manualPayRemark.value.trim() || undefined)
await loadOrders()
})
message.success('支付已确认')
closeManualPay()
} catch (error: any) {
console.error('手动确认支付失败:', error)
message.error(error?.message || '手动确认支付失败')
} finally {
manualPayLoading.value = false
}
}
const openAfterSales = (order: any) => {
router.push({
path: '/admin/after-sales',
query: { orderId: String(order.id) }
})
}
/** noop is a local helper used by this page script. */
const noop = () => {}
@@ -557,4 +657,8 @@ onMounted(async () => {
gap: 10px;
margin-bottom: 16px;
}
.order-action-alert {
margin-bottom: 16px;
}
</style>
@@ -1013,7 +1013,7 @@ const fetchProductList = async () => {
}
const nextProducts = response?.list || []
productList.value = nextProducts
pagination.total = response?.total || 0
pagination.total = Number(response?.total || 0)
const nextImageUrls = await loadImageUrls(nextProducts, requestToken)
if (nextImageUrls && isLatestRequestToken('products', requestToken)) {
@@ -0,0 +1,293 @@
<template>
<div class="schedules">
<a-page-header v-if="!isMobile" title="排班管理" sub-title="维护美甲师班次、容量和可约状态" />
<section v-else class="admin-page-intro">
<span class="admin-page-intro__eyebrow">排班</span>
<h1 class="admin-page-intro__title">排班管理</h1>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">班次 {{ schedules.length }}</span>
</div>
</section>
<a-card :bordered="false">
<template #title v-if="isMobile">班次列表</template>
<template #extra>
<div class="admin-toolbar" :class="{ 'admin-toolbar--stacked': isMobile }">
<a-select
v-model:value="filters.artistId"
allow-clear
placeholder="选择美甲师"
:options="artistOptions"
:style="isMobile ? { width: '100%' } : { width: '180px' }"
@change="loadSchedules"
/>
<a-range-picker
v-model:value="filters.dateRange"
value-format="YYYY-MM-DD"
:style="isMobile ? { width: '100%' } : { width: '240px' }"
@change="loadSchedules"
/>
<a-button type="primary" @click="openCreateModal">
<template #icon>
<PlusOutlined />
</template>
新增排班
</a-button>
</div>
</template>
<a-table v-if="!isMobile" :columns="columns" :data-source="schedules" :loading="loading" row-key="id">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'artist'">{{ artistName(record.artistId) }}</template>
<template v-else-if="column.key === 'time'">{{ record.startTime }} - {{ record.endTime }}</template>
<template v-else-if="column.key === 'capacity'">{{ record.capacity ?? '-' }} / {{ record.slotMinutes ?? '-' }} 分钟</template>
<template v-else-if="column.key === 'status'">
<a-tag :color="record.status === 0 ? 'red' : 'green'">{{ scheduleStatusText(record.status) }}</a-tag>
</template>
<template v-else-if="column.key === 'actions'">
<a-button type="link" size="small" @click="openEditModal(record as ArtistScheduleVO)">编辑</a-button>
</template>
</template>
</a-table>
<AdminMobileCardList v-else :items="schedules" empty-description="暂无排班数据">
<template #item="{ item }">
<article class="admin-mobile-card">
<div class="admin-mobile-card__head">
<div class="admin-mobile-card__body">
<div class="admin-mobile-card__title">{{ artistName(item.artistId) }}</div>
<div class="admin-mobile-card__subtitle">{{ item.workDate }} {{ item.startTime }} - {{ item.endTime }}</div>
</div>
<a-tag :color="item.status === 0 ? 'red' : 'green'">{{ scheduleStatusText(item.status) }}</a-tag>
</div>
<div class="admin-mobile-card__rows">
<div class="admin-mobile-card__row">
<span>容量</span>
<strong>{{ item.capacity ?? '-' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>间隔</span>
<strong>{{ item.slotMinutes ?? '-' }} 分钟</strong>
</div>
<div class="admin-mobile-card__row">
<span>备注</span>
<strong>{{ item.remark || '-' }}</strong>
</div>
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="openEditModal(item)">编辑</a-button>
</div>
</article>
</template>
</AdminMobileCardList>
</a-card>
<AdminResponsiveModal
v-model:open="modalOpen"
:title="editingSchedule ? '编辑排班' : '新增排班'"
:desktop-width="720"
:confirm-loading="saving"
@ok="saveSchedule"
@cancel="closeModal"
>
<a-form ref="formRef" :model="formState" :rules="rules" :label-col="{ span: 6 }" :wrapper-col="{ span: 16 }">
<a-form-item label="美甲师" name="artistId">
<a-select v-model:value="formState.artistId" placeholder="选择美甲师" :options="artistOptions" />
</a-form-item>
<a-form-item label="工作日期" name="workDate">
<a-date-picker v-model:value="formState.workDate" value-format="YYYY-MM-DD" style="width: 100%" />
</a-form-item>
<a-form-item label="开始时间" name="startTime">
<a-input v-model:value="formState.startTime" placeholder="09:00:00" />
</a-form-item>
<a-form-item label="结束时间" name="endTime">
<a-input v-model:value="formState.endTime" placeholder="18:00:00" />
</a-form-item>
<a-form-item label="预约间隔">
<a-input-number v-model:value="formState.slotMinutes" :min="5" :step="5" style="width: 100%" />
</a-form-item>
<a-form-item label="容量">
<a-input-number v-model:value="formState.capacity" :min="1" style="width: 100%" />
</a-form-item>
<a-form-item label="状态">
<a-select v-model:value="formState.status">
<a-select-option :value="1">可预约</a-select-option>
<a-select-option :value="0">停用</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="备注">
<a-textarea v-model:value="formState.remark" :rows="3" :maxlength="200" />
</a-form-item>
</a-form>
</AdminResponsiveModal>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, reactive, ref } from 'vue'
import { message } from 'ant-design-vue'
import type { FormInstance } from 'ant-design-vue'
import { PlusOutlined } from '@ant-design/icons-vue'
import {
adminArtistScheduleApi,
adminNailArtistApi,
type ArtistScheduleRequest,
type ArtistScheduleVO,
type NailArtistInfoVO
} from '@/api/admin'
import { runWithGlobalLoading } from '@/utils/action-loading'
import { useAdminViewport } from '@/composables/useAdminViewport'
import AdminMobileCardList from '@/components/admin/AdminMobileCardList.vue'
import AdminResponsiveModal from '@/components/admin/AdminResponsiveModal.vue'
const { isMobile } = useAdminViewport()
const loading = ref(false)
const saving = ref(false)
const modalOpen = ref(false)
const schedules = ref<ArtistScheduleVO[]>([])
const artists = ref<NailArtistInfoVO[]>([])
const editingSchedule = ref<ArtistScheduleVO | null>(null)
const formRef = ref<FormInstance>()
const filters = reactive({
artistId: undefined as string | undefined,
dateRange: undefined as [string, string] | undefined
})
const formState = reactive<ArtistScheduleRequest>({
artistId: undefined,
workDate: '',
startTime: '09:00:00',
endTime: '18:00:00',
slotMinutes: 30,
capacity: 1,
status: 1,
remark: ''
})
const rules = {
artistId: [{ required: true, message: '请选择美甲师', trigger: 'change' }],
workDate: [{ required: true, message: '请选择工作日期', trigger: 'change' }],
startTime: [{ required: true, message: '请选择开始时间', trigger: 'change' }],
endTime: [{ required: true, message: '请选择结束时间', trigger: 'change' }]
} as any
const columns = [
{ title: '美甲师', key: 'artist', width: 160 },
{ title: '工作日期', dataIndex: 'workDate', key: 'workDate', width: 140 },
{ title: '工作时段', key: 'time', width: 180 },
{ title: '容量 / 间隔', key: 'capacity', width: 140 },
{ title: '状态', key: 'status', width: 100 },
{ title: '备注', dataIndex: 'remark', key: 'remark' },
{ title: '操作', key: 'actions', width: 90 }
]
const artistOptions = computed(() => artists.value.map(artist => ({
label: artist.nickname || artist.identity || `美甲师 ${artist.userId}`,
value: String(artist.userId || artist.id)
})))
const artistName = (artistId?: unknown) => {
const artist = artists.value.find(item => String(item.userId || item.id) === String(artistId))
return artist?.nickname || artist?.identity || (artistId ? `美甲师 ${artistId}` : '-')
}
const scheduleStatusText = (status?: number) => status === 0 ? '停用' : '可预约'
const resetForm = () => {
Object.assign(formState, {
artistId: undefined,
workDate: '',
startTime: '09:00:00',
endTime: '18:00:00',
slotMinutes: 30,
capacity: 1,
status: 1,
remark: ''
})
}
const loadArtists = async () => {
try {
artists.value = await adminNailArtistApi.listNailArtists() as unknown as NailArtistInfoVO[]
} catch (error) {
console.error('加载美甲师失败:', error)
artists.value = []
}
}
const loadSchedules = async () => {
loading.value = true
try {
schedules.value = await adminArtistScheduleApi.listSchedules({
artistId: filters.artistId,
startDate: filters.dateRange?.[0],
endDate: filters.dateRange?.[1]
})
} catch (error) {
console.error('加载排班失败:', error)
message.error('加载排班失败')
} finally {
loading.value = false
}
}
const openCreateModal = () => {
editingSchedule.value = null
resetForm()
modalOpen.value = true
}
const openEditModal = (record: ArtistScheduleVO) => {
editingSchedule.value = record
Object.assign(formState, {
artistId: String(record.artistId),
workDate: record.workDate,
startTime: record.startTime,
endTime: record.endTime,
slotMinutes: record.slotMinutes ?? 30,
capacity: record.capacity ?? 1,
status: record.status ?? 1,
remark: record.remark || ''
})
modalOpen.value = true
}
const closeModal = () => {
modalOpen.value = false
formRef.value?.resetFields()
}
const saveSchedule = async () => {
try {
await formRef.value?.validate()
saving.value = true
await runWithGlobalLoading(async () => {
await adminArtistScheduleApi.saveSchedule({ ...formState })
await loadSchedules()
})
message.success('排班已保存')
closeModal()
} catch (error: any) {
if (error?.errorFields) {
return
}
console.error('保存排班失败:', error)
message.error(error?.message || '保存排班失败')
} finally {
saving.value = false
}
}
onMounted(async () => {
await loadArtists()
await loadSchedules()
})
</script>
<style scoped>
.schedules {
padding: 0;
}
</style>