feat: 前端页面和组件全面完善
- 优化通用组件:导航栏、页脚、图片上传、搜索 - 完善业务组件:商品卡片、秒杀卡片 - 更新用户端页面:首页、商品、秒杀、订单、购物车、个人中心 - 新增用户收藏页面 - 完善管理后台:仪表盘、商品/订单/用户/秒杀管理 - 新增管理后台:收藏管理、评价管理、系统监控页面
This commit is contained in:
106
flash-sale-frontend/src/pages/admin/favorites.vue
Normal file
106
flash-sale-frontend/src/pages/admin/favorites.vue
Normal file
@@ -0,0 +1,106 @@
|
||||
<template>
|
||||
<div class="page-shell">
|
||||
<div class="page-header">
|
||||
<div>
|
||||
<h2 class="page-title">收藏管理</h2>
|
||||
<p class="page-subtitle">查看用户收藏关系并支持后台删除</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<el-button @click="reloadData"><el-icon><Refresh /></el-icon>刷新</el-button>
|
||||
<el-button type="primary" @click="migrateItems">迁移旧订单明细</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="stats-grid">
|
||||
<div class="mini-stat blue"><div class="mini-stat__value">{{ stats.totalFavorites }}</div><div class="mini-stat__label">收藏总数</div></div>
|
||||
<div class="mini-stat green"><div class="mini-stat__value">{{ stats.favoriteUsers }}</div><div class="mini-stat__label">收藏用户数</div></div>
|
||||
<div class="mini-stat orange"><div class="mini-stat__value">{{ stats.favoriteProducts }}</div><div class="mini-stat__label">被收藏商品数</div></div>
|
||||
<div class="mini-stat purple"><div class="mini-stat__value">{{ stats.todayFavorites }}</div><div class="mini-stat__label">今日新增收藏</div></div>
|
||||
</div>
|
||||
|
||||
<div class="panel-card filter-card">
|
||||
<el-input v-model="keyword" clearable placeholder="搜索用户 / 商品" @keyup.enter="loadFavorites" />
|
||||
<el-button type="primary" @click="loadFavorites">搜索</el-button>
|
||||
</div>
|
||||
|
||||
<div class="panel-card">
|
||||
<el-table v-loading="loading" :data="favorites" stripe>
|
||||
<el-table-column prop="productName" label="商品" min-width="180" show-overflow-tooltip />
|
||||
<el-table-column prop="productCategory" label="分类" width="120" />
|
||||
<el-table-column prop="username" label="用户" width="120" />
|
||||
<el-table-column prop="createdAt" label="收藏时间" min-width="170" />
|
||||
<el-table-column label="操作" width="100">
|
||||
<template #default="{ row }"><el-button text type="danger" @click="removeFavorite(row.id)">删除</el-button></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div class="table-footer">
|
||||
<el-pagination v-model:current-page="page" v-model:page-size="size" :total="total" :page-sizes="[10,20,50]" layout="total, sizes, prev, pager, next, jumper" @current-change="loadFavorites" @size-change="loadFavorites" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { adminApi } from '@/api/modules/admin'
|
||||
import type { AdminFavoriteRow, AdminFavoriteStats } from '@/types/admin'
|
||||
|
||||
const loading = ref(false)
|
||||
const keyword = ref('')
|
||||
const page = ref(1)
|
||||
const size = ref(10)
|
||||
const total = ref(0)
|
||||
const favorites = ref<AdminFavoriteRow[]>([])
|
||||
const stats = reactive<AdminFavoriteStats>({ totalFavorites: 0, favoriteUsers: 0, favoriteProducts: 0, todayFavorites: 0 })
|
||||
|
||||
const loadStats = async () => {
|
||||
const res = await adminApi.getFavoriteStats()
|
||||
Object.assign(stats, res.data)
|
||||
}
|
||||
|
||||
const loadFavorites = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await adminApi.getFavorites({ page: page.value, size: size.value, keyword: keyword.value || undefined })
|
||||
favorites.value = res.data.favorites
|
||||
total.value = res.data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const removeFavorite = async (id: number) => {
|
||||
await ElMessageBox.confirm('确定删除该收藏记录吗?', '提示', { type: 'warning' })
|
||||
await adminApi.deleteFavorite(id)
|
||||
ElMessage.success('删除成功')
|
||||
loadStats(); loadFavorites()
|
||||
}
|
||||
|
||||
const migrateItems = async () => {
|
||||
const res = await adminApi.migrateLegacyOrderItems()
|
||||
ElMessage.success(`迁移完成:迁移 ${res.data.migrated} 条,跳过 ${res.data.skipped} 条`)
|
||||
}
|
||||
|
||||
const reloadData = async () => { await Promise.all([loadStats(), loadFavorites()]) }
|
||||
onMounted(() => { reloadData() })
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.page-shell { display:flex; flex-direction:column; gap:20px; }
|
||||
.page-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; }
|
||||
.page-title { @apply text-2xl font-bold text-slate-900; }
|
||||
.page-subtitle { @apply text-sm text-slate-500 mt-1; }
|
||||
.actions { display:flex; gap:12px; }
|
||||
.stats-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:16px; }
|
||||
.mini-stat { @apply rounded-xl text-white p-5 shadow-sm; }
|
||||
.mini-stat.blue { background:linear-gradient(135deg,#3b82f6,#2563eb); }
|
||||
.mini-stat.green { background:linear-gradient(135deg,#10b981,#059669); }
|
||||
.mini-stat.orange { background:linear-gradient(135deg,#f59e0b,#ea580c); }
|
||||
.mini-stat.purple { background:linear-gradient(135deg,#8b5cf6,#7c3aed); }
|
||||
.mini-stat__value { @apply text-3xl font-bold; }
|
||||
.mini-stat__label { @apply text-sm opacity-90 mt-2; }
|
||||
.panel-card { @apply bg-white rounded-xl shadow-sm p-5; }
|
||||
.filter-card { display:grid; grid-template-columns:1fr 100px; gap:12px; }
|
||||
.table-footer { @apply flex justify-end mt-4; }
|
||||
</style>
|
||||
Reference in New Issue
Block a user