功能:更新消息中心和 YumiNail 模块

This commit is contained in:
xiaowang
2026-05-13 12:43:01 +08:00
parent 6b9eba5aca
commit 2074addc40
284 changed files with 21031 additions and 4533 deletions
@@ -0,0 +1,326 @@
<template>
<div class="orders">
<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>
<p class="admin-page-intro__subtitle">
手机端不再默认展示横向大表格,而是把筛选、状态和处理按钮压到单列卡片里。
</p>
<div class="admin-page-intro__meta">
<span class="admin-page-chip">订单 {{ filteredOrders.length }}</span>
<span class="admin-page-chip">{{ canProcessOrders ? '可处理订单' : '查看模式' }}</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"
class="admin-toolbar__grow"
placeholder="搜索订单号、用户 ID 或优惠券"
@search="noop"
/>
<a-select
v-model:value="statusFilter"
:options="statusOptions"
:style="isMobile ? { width: '100%' } : { width: '160px' }"
/>
</div>
</template>
<a-table v-if="!isMobile" :columns="columns" :data-source="filteredOrders" :loading="loading" row-key="id">
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'status'">
<a-tag :color="statusColor(record.status)">{{ record.statusText }}</a-tag>
</template>
<template v-else-if="column.key === 'totalAmount'">
¥{{ record.totalAmount.toFixed(2) }}
</template>
<template v-else-if="column.key === 'actualAmount'">
¥{{ record.actualAmount.toFixed(2) }}
</template>
<template v-else-if="column.key === 'actions'">
<a-space>
<a-button type="link" size="small" @click="currentOrder = record">查看</a-button>
<a-button
v-if="record.status === 1 && canProcessOrders"
type="primary"
size="small"
@click="process(record.id, 2)"
>
确认完成
</a-button>
<a-button
v-if="record.status === 1 && canProcessOrders && !isArtist"
danger
size="small"
@click="process(record.id, 3)"
>
取消订单
</a-button>
</a-space>
</template>
</template>
</a-table>
<AdminMobileCardList v-else :items="filteredOrders" 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.orderNo }}</div>
<div class="admin-mobile-card__subtitle">
用户 {{ item.userId }} · {{ item.createTime }}
</div>
</div>
<a-tag :color="statusColor(item.status)">{{ item.statusText }}</a-tag>
</div>
<div class="admin-mobile-card__rows">
<div class="admin-mobile-card__row">
<span>总金额</span>
<strong>¥{{ item.totalAmount.toFixed(2) }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>实付金额</span>
<strong>¥{{ item.actualAmount.toFixed(2) }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>优惠券</span>
<strong>{{ item.couponName || '无' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>预约项目</span>
<strong>{{ item.items?.length || 0 }} 个</strong>
</div>
</div>
<div class="admin-mobile-card__actions">
<a-button size="small" @click="currentOrder = item">查看详情</a-button>
<a-button
v-if="item.status === 1 && canProcessOrders"
size="small"
type="primary"
@click="process(item.id, 2)"
>
完成
</a-button>
<a-button
v-if="item.status === 1 && canProcessOrders && !isArtist"
size="small"
danger
@click="process(item.id, 3)"
>
取消
</a-button>
</div>
</article>
</template>
</AdminMobileCardList>
</a-card>
<AdminResponsiveModal
v-model:open="detailVisible"
title="订单详情"
:desktop-width="860"
@cancel="currentOrder = null"
>
<template v-if="currentOrder">
<a-descriptions :column="isMobile ? 1 : 2" bordered size="small">
<a-descriptions-item label="订单编号">{{ currentOrder.orderNo }}</a-descriptions-item>
<a-descriptions-item label="用户ID">{{ currentOrder.userId }}</a-descriptions-item>
<a-descriptions-item label="订单总额">¥{{ currentOrder.totalAmount.toFixed(2) }}</a-descriptions-item>
<a-descriptions-item label="实付金额">¥{{ currentOrder.actualAmount.toFixed(2) }}</a-descriptions-item>
<a-descriptions-item label="优惠券">{{ currentOrder.couponName || '无' }}</a-descriptions-item>
<a-descriptions-item label="订单状态">{{ currentOrder.statusText }}</a-descriptions-item>
<a-descriptions-item label="创建时间" :span="isMobile ? 1 : 2">{{ currentOrder.createTime }}</a-descriptions-item>
</a-descriptions>
<a-divider>订单项目</a-divider>
<a-table
v-if="!isMobile"
:columns="itemColumns"
:data-source="currentOrder.items"
row-key="id"
:pagination="false"
>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'price'">¥{{ record.price.toFixed(2) }}</template>
<template v-else-if="column.key === 'totalPrice'">¥{{ (record.price * record.quantity).toFixed(2) }}</template>
</template>
</a-table>
<div v-else class="detail-items">
<article v-for="item in currentOrder.items" :key="item.id" class="admin-mobile-card">
<div class="admin-mobile-card__title">{{ item.productTitle }}</div>
<div class="admin-mobile-card__subtitle">{{ item.artistName || '未指定美甲师' }}</div>
<div class="admin-mobile-card__rows">
<div class="admin-mobile-card__row">
<span>预约时间</span>
<strong>{{ item.appointmentTime || '--' }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>单价</span>
<strong>¥{{ item.price.toFixed(2) }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>数量</span>
<strong>{{ item.quantity }}</strong>
</div>
<div class="admin-mobile-card__row">
<span>小计</span>
<strong>¥{{ (item.price * item.quantity).toFixed(2) }}</strong>
</div>
</div>
</article>
</div>
</template>
</AdminResponsiveModal>
</div>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { message } from 'ant-design-vue'
import { orderApi } from '../../api/order'
import { usePermission } from '@/utils/permission'
import type { IdType } from '@/utils/id'
import { sameId } from '@/utils/id'
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 orders = ref<any[]>([])
const loading = ref(false)
const currentOrder = ref<any | null>(null)
const currentUserType = ref<number | null>(null)
const keyword = ref('')
const statusFilter = ref<'all' | string>('all')
const { hasPermission, loadUserPermissions } = usePermission()
const detailVisible = computed({
get: () => !!currentOrder.value,
set: value => { if (!value) currentOrder.value = null }
})
const canProcessOrders = computed(() => hasPermission('order:process'))
const isArtist = computed(() => currentUserType.value === 3)
const statusOptions = [
{ label: '全部状态', value: 'all' },
{ label: '待处理', value: '1' },
{ label: '已完成', value: '2' },
{ label: '已取消', value: '3' }
]
const filteredOrders = computed(() => {
const keywordValue = keyword.value.trim().toLowerCase()
return orders.value.filter(order => {
const matchStatus = statusFilter.value === 'all' || String(order.status) === String(statusFilter.value)
if (!matchStatus) {
return false
}
if (!keywordValue) {
return true
}
const haystack = [
order.orderNo,
order.userId,
order.couponName,
...(order.items || []).map((item: any) => `${item.productTitle || ''} ${item.artistName || ''}`)
].join(' ').toLowerCase()
return haystack.includes(keywordValue)
})
})
const columns = [
{ title: '订单编号', dataIndex: 'orderNo', key: 'orderNo' },
{ title: '用户ID', dataIndex: 'userId', key: 'userId', width: 100 },
{ title: '订单总额', key: 'totalAmount', width: 120 },
{ title: '实付金额', key: 'actualAmount', width: 120 },
{ title: '优惠券', dataIndex: 'couponName', key: 'couponName', width: 140 },
{ title: '状态', key: 'status', width: 100 },
{ title: '创建时间', dataIndex: 'createTime', key: 'createTime', width: 180 },
{ title: '操作', key: 'actions', width: 180 }
]
const itemColumns = [
{ title: '商品ID', dataIndex: 'productId', key: 'productId', width: 100 },
{ title: '商品名称', dataIndex: 'productTitle', key: 'productTitle' },
{ title: '美甲师', dataIndex: 'artistName', key: 'artistName', width: 120 },
{ title: '预约时间', dataIndex: 'appointmentTime', key: 'appointmentTime', width: 180 },
{ title: '单价', key: 'price', width: 100 },
{ title: '数量', dataIndex: 'quantity', key: 'quantity', width: 80 },
{ title: '总价', key: 'totalPrice', width: 100 }
]
const statusColor = (status: number) => {
if (status === 1) return 'orange'
if (status === 2) return 'green'
if (status === 3) return 'red'
return 'default'
}
const resolveCurrentUserType = () => {
const cached = localStorage.getItem('adminUserInfo') || sessionStorage.getItem('adminUserInfo')
if (!cached) {
currentUserType.value = null
return
}
try {
currentUserType.value = JSON.parse(cached)?.type ?? null
} catch {
currentUserType.value = null
}
}
const loadOrders = async () => {
loading.value = true
try {
orders.value = await orderApi.getAllOrders() as unknown as any[]
} catch {
message.error('获取订单列表失败')
} finally {
loading.value = false
}
}
const process = async (orderId: IdType, status: number) => {
try {
await runWithGlobalLoading(async () => {
await orderApi.processOrder(orderId, status)
await loadOrders()
})
message.success('操作成功')
if (sameId(currentOrder.value?.id, orderId)) {
currentOrder.value = orders.value.find(order => sameId(order.id, orderId)) || null
}
} catch {
message.error('操作失败')
}
}
const noop = () => {}
onMounted(async () => {
resolveCurrentUserType()
await loadUserPermissions()
await loadOrders()
})
</script>
<style scoped>
.orders {
padding: 0;
}
.detail-items {
display: grid;
gap: 12px;
}
</style>