406 lines
10 KiB
Vue
406 lines
10 KiB
Vue
<template>
|
|
<div class="admin-manage">
|
|
<section class="admin-page-intro admin-manage__intro">
|
|
<span class="admin-page-intro__eyebrow">经营</span>
|
|
<h1 class="admin-page-intro__title">{{ currentShopName }}</h1>
|
|
<div class="admin-page-intro__meta">
|
|
<span class="admin-page-chip">{{ roleLabel }}</span>
|
|
<span class="admin-page-chip">可见模块 {{ visibleModules.length }}</span>
|
|
<span v-if="isBootstrapAdmin" class="admin-page-chip">平台总览</span>
|
|
</div>
|
|
</section>
|
|
|
|
<div class="module-grid">
|
|
<button
|
|
v-for="module in visibleModules"
|
|
:key="module.key"
|
|
class="module-card"
|
|
:class="{ 'is-disabled': !module.allowed }"
|
|
type="button"
|
|
@click="openModule(module)"
|
|
>
|
|
<div class="module-card__icon">
|
|
<component :is="module.icon" />
|
|
</div>
|
|
<div class="module-card__body">
|
|
<div class="module-card__head">
|
|
<div class="module-card__title">{{ module.title }}</div>
|
|
<span class="module-card__badge">
|
|
{{ module.readonly ? '仅查看' : (module.allowed ? '进入' : '受限') }}
|
|
</span>
|
|
</div>
|
|
<div class="module-card__subtitle">{{ module.description }}</div>
|
|
<div v-if="!module.allowed && module.disabledReason" class="module-card__hint">
|
|
{{ module.disabledReason }}
|
|
</div>
|
|
</div>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
/**
|
|
* ManageView page script.
|
|
* Call guide: the template binds the reactive state below, and the methods are triggered by button clicks, lifecycle hooks, or router events.
|
|
*/
|
|
import { computed, onMounted } from 'vue'
|
|
import { useRouter } from 'vue-router'
|
|
import {
|
|
DashboardOutlined,
|
|
FileProtectOutlined,
|
|
GiftOutlined,
|
|
HomeOutlined,
|
|
MessageOutlined,
|
|
SafetyCertificateOutlined,
|
|
ShopOutlined,
|
|
SettingOutlined,
|
|
TagOutlined,
|
|
TeamOutlined,
|
|
UserOutlined
|
|
} from '@ant-design/icons-vue'
|
|
import { message } from 'ant-design-vue'
|
|
import { usePermission } from '@/utils/permission'
|
|
import {
|
|
getAdminCurrentShopName,
|
|
getAdminRoleLabel,
|
|
isBootstrapAdminUser,
|
|
loadCachedAdminUserInfo
|
|
} from './admin-helpers'
|
|
|
|
/**
|
|
* Purpose: router supports ManageView.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.
|
|
*/
|
|
const router = useRouter()
|
|
const { hasPermission, loadUserPermissions } = usePermission()
|
|
|
|
/** userInfo is a reactive state variable used by the template and event handlers. */
|
|
const userInfo = computed(() => loadCachedAdminUserInfo())
|
|
/** currentShopName is a reactive state variable used by the template and event handlers. */
|
|
const currentShopName = computed(() => getAdminCurrentShopName(userInfo.value))
|
|
/** roleLabel is a reactive state variable used by the template and event handlers. */
|
|
const roleLabel = computed(() => getAdminRoleLabel(userInfo.value?.type))
|
|
/** isBootstrapAdmin is a reactive state variable used by the template and event handlers. */
|
|
const isBootstrapAdmin = computed(() => isBootstrapAdminUser(userInfo.value))
|
|
|
|
/** visibleModules is a reactive state variable used by the template and event handlers. */
|
|
const visibleModules = computed(() => {
|
|
const definitions = [
|
|
{
|
|
key: 'dashboard',
|
|
title: '仪表盘',
|
|
description: '查看经营概览、近期动态和重点提醒。',
|
|
path: '/admin/dashboard',
|
|
icon: DashboardOutlined,
|
|
permissionCode: 'dashboard:view'
|
|
},
|
|
{
|
|
key: 'users',
|
|
title: '用户管理',
|
|
description: '处理账号、资产、VIP 和店铺关系。',
|
|
path: '/admin/users',
|
|
icon: UserOutlined,
|
|
permissionCode: 'user:view',
|
|
requireShopContext: true,
|
|
allowPlatformOverviewManage: true
|
|
},
|
|
{
|
|
key: 'products',
|
|
title: '作品管理',
|
|
description: '维护作品、标签、可预约员工和优惠券。',
|
|
path: '/admin/products',
|
|
icon: ShopOutlined,
|
|
permissionCode: 'product:view',
|
|
requireShopContext: true
|
|
},
|
|
{
|
|
key: 'coupons',
|
|
title: '优惠券',
|
|
description: '管理券模板、场景和批量发放入口。',
|
|
path: '/admin/coupons',
|
|
icon: GiftOutlined,
|
|
permissionCode: 'coupon:view',
|
|
requireShopContext: true
|
|
},
|
|
{
|
|
key: 'tags',
|
|
title: '标签管理',
|
|
description: '维护作品标签及颜色风格。',
|
|
path: '/admin/tags',
|
|
icon: TagOutlined,
|
|
permissionCode: 'tag:view',
|
|
requireShopContext: true
|
|
},
|
|
{
|
|
key: 'artists',
|
|
title: '员工',
|
|
description: '查看员工状态、技能与排班关系。',
|
|
path: '/admin/nail-artists',
|
|
icon: TeamOutlined,
|
|
permissionCode: 'nail_artist:view',
|
|
requireShopContext: true
|
|
},
|
|
{
|
|
key: 'shops',
|
|
title: '店铺管理',
|
|
description: '创建门店、调整营业信息与图片素材。',
|
|
path: '/admin/shops',
|
|
icon: HomeOutlined,
|
|
permissionCode: 'shop:view'
|
|
},
|
|
{
|
|
key: 'permissions',
|
|
title: '权限管理',
|
|
description: '查看权限列表并给后台账号分配权限。',
|
|
path: '/admin/permissions',
|
|
icon: SafetyCertificateOutlined,
|
|
permissionCode: 'permission:view'
|
|
},
|
|
{
|
|
key: 'messages',
|
|
title: '消息发布',
|
|
description: '发布站内消息,可面向全平台或指定范围。',
|
|
path: '/admin/messages',
|
|
icon: MessageOutlined,
|
|
permissionCode: 'message:view'
|
|
},
|
|
{
|
|
key: 'announcements',
|
|
title: '公告管理',
|
|
description: '维护首页滚动公告,支持平台和门店范围。',
|
|
path: '/admin/announcements',
|
|
icon: MessageOutlined,
|
|
permissionCode: 'announcement:view'
|
|
},
|
|
{
|
|
key: 'vip-plans',
|
|
title: 'VIP充值配置',
|
|
description: '维护充值档位和 VIP 等级来源。',
|
|
path: '/admin/vip-recharge-plans',
|
|
icon: GiftOutlined,
|
|
permissionCode: 'user:vip:manage',
|
|
requireShopContext: true
|
|
},
|
|
{
|
|
key: 'parameters',
|
|
title: '参数管理',
|
|
description: '维护地图 Key、短信 MessageHub 等系统参数。',
|
|
path: '/admin/messagehub-push-configs',
|
|
icon: SettingOutlined,
|
|
permissionCode: 'messagehub:config:manage'
|
|
},
|
|
{
|
|
key: 'agreements',
|
|
title: '协议管理',
|
|
description: '维护用户协议和隐私政策版本。',
|
|
path: '/admin/legal-agreements',
|
|
icon: FileProtectOutlined,
|
|
permissionCode: 'legal_agreement:manage'
|
|
}
|
|
]
|
|
|
|
return definitions
|
|
.filter(module => !module.permissionCode || hasPermission(module.permissionCode))
|
|
.map(module => {
|
|
if (module.requireShopContext && isBootstrapAdmin.value && !module.allowPlatformOverviewManage) {
|
|
return {
|
|
...module,
|
|
allowed: true,
|
|
readonly: true,
|
|
disabledReason: '平台总览模式下该模块仅可查看,编辑操作已关闭。'
|
|
}
|
|
}
|
|
return {
|
|
...module,
|
|
allowed: true,
|
|
readonly: false,
|
|
disabledReason: ''
|
|
}
|
|
})
|
|
})
|
|
|
|
/** openModule is a local helper used by this page script. */
|
|
const openModule = (module: any) => {
|
|
if (!module.allowed) {
|
|
message.warning(module.disabledReason || '当前无法进入该模块')
|
|
return
|
|
}
|
|
router.push(module.path)
|
|
}
|
|
|
|
onMounted(() => {
|
|
void loadUserPermissions()
|
|
})
|
|
</script>
|
|
|
|
<style scoped>
|
|
.admin-manage {
|
|
display: grid;
|
|
gap: 18px;
|
|
}
|
|
|
|
.module-grid {
|
|
display: grid;
|
|
gap: 14px;
|
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
|
}
|
|
|
|
.module-card {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 14px;
|
|
padding: 18px;
|
|
border: 1px solid var(--admin-mobile-border);
|
|
border-radius: 24px;
|
|
background: var(--admin-mobile-card);
|
|
text-align: left;
|
|
box-shadow: 0 12px 30px rgba(144, 103, 84, 0.08);
|
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
|
}
|
|
|
|
.module-card:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 18px 36px rgba(144, 103, 84, 0.12);
|
|
}
|
|
|
|
.module-card.is-disabled {
|
|
opacity: 0.78;
|
|
}
|
|
|
|
.module-card__icon {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
width: 52px;
|
|
height: 52px;
|
|
border-radius: 18px;
|
|
background: var(--admin-mobile-accent-soft);
|
|
color: var(--theme-primary);
|
|
flex-shrink: 0;
|
|
font-size: 20px;
|
|
}
|
|
|
|
.module-card__body {
|
|
flex: 1;
|
|
min-width: 0;
|
|
}
|
|
|
|
.module-card__head {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
gap: 10px;
|
|
}
|
|
|
|
.module-card__title {
|
|
font-size: 17px;
|
|
font-weight: 700;
|
|
color: var(--admin-mobile-ink);
|
|
}
|
|
|
|
.module-card__badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
min-height: 28px;
|
|
padding: 0 10px;
|
|
border-radius: 999px;
|
|
background: var(--theme-primary-soft);
|
|
color: var(--theme-primary);
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
}
|
|
|
|
.module-card__subtitle {
|
|
margin-top: 8px;
|
|
line-height: 1.6;
|
|
color: var(--text-secondary);
|
|
}
|
|
|
|
.module-card__hint {
|
|
margin-top: 10px;
|
|
padding: 10px 12px;
|
|
border-radius: 14px;
|
|
background: var(--theme-primary-soft);
|
|
color: var(--text-secondary);
|
|
line-height: 1.55;
|
|
}
|
|
|
|
@media (max-width: 960px) {
|
|
.admin-manage {
|
|
gap: 12px;
|
|
}
|
|
|
|
.admin-manage__intro {
|
|
display: none;
|
|
}
|
|
|
|
.module-grid {
|
|
grid-template-columns: 1fr;
|
|
gap: 10px;
|
|
}
|
|
|
|
.module-card {
|
|
gap: 12px;
|
|
padding: 14px 16px;
|
|
border-radius: 18px;
|
|
box-shadow: 0 8px 20px rgba(144, 103, 84, 0.07);
|
|
}
|
|
|
|
.module-card:hover {
|
|
transform: none;
|
|
box-shadow: 0 8px 20px rgba(144, 103, 84, 0.07);
|
|
}
|
|
|
|
.module-card__icon {
|
|
width: 44px;
|
|
height: 44px;
|
|
border-radius: 14px;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.module-card__head {
|
|
align-items: flex-start;
|
|
}
|
|
|
|
.module-card__title {
|
|
font-size: 16px;
|
|
line-height: 1.25;
|
|
}
|
|
|
|
.module-card__badge {
|
|
min-height: 24px;
|
|
padding: 0 8px;
|
|
font-size: 11px;
|
|
}
|
|
|
|
.module-card__subtitle {
|
|
margin-top: 5px;
|
|
font-size: 13px;
|
|
line-height: 1.45;
|
|
}
|
|
|
|
.module-card__hint {
|
|
margin-top: 8px;
|
|
padding: 8px 10px;
|
|
border-radius: 12px;
|
|
font-size: 13px;
|
|
}
|
|
}
|
|
|
|
@media (max-width: 420px) {
|
|
.module-card {
|
|
padding: 12px 14px;
|
|
}
|
|
|
|
.module-card__icon {
|
|
width: 40px;
|
|
height: 40px;
|
|
}
|
|
|
|
.module-card__head {
|
|
gap: 8px;
|
|
}
|
|
}
|
|
</style>
|