Files
backmanagerweb/src/components/home.vue

316 lines
7.9 KiB
Vue
Raw Normal View History

<template>
2026-06-30 23:10:56 +08:00
<div class="workspace-container">
2026-06-15 23:20:21 +08:00
<!-- 顶部视频横幅 -->
<div class="video-banner">
2026-06-28 00:36:03 +08:00
<video src="/首页顶图.mp4" autoplay muted loop class="bg-video"></video>
2026-06-15 23:20:21 +08:00
<div class="video-overlay">
2026-06-30 23:10:56 +08:00
<div class="welcome-text">
<h2 class="banner-title">欢迎回来{{ userInfo?.name || '用户' }}</h2>
<p class="welcome-sub">{{ userInfo?.departmentDesc }} · {{ roleName }}</p>
<p class="welcome-date">{{ currentDate }}</p>
</div>
2026-06-15 23:20:21 +08:00
</div>
</div>
2026-06-30 23:10:56 +08:00
<!-- 功能卡片网格 -->
<div class="card-grid">
<div
v-for="card in visibleCards"
:key="card.route"
class="function-card"
:style="{ borderTopColor: themeColor, '--hover-bg': themeBg }"
@click="navigateTo(card.route)"
>
<div class="card-icon" :style="{ background: themeBg, color: themeColor }">
<el-icon :size="28"><component :is="card.icon" /></el-icon>
2026-06-15 23:20:21 +08:00
</div>
2026-06-30 23:10:56 +08:00
<div class="card-content">
<h3 class="card-title">{{ card.title }}</h3>
<p class="card-desc">{{ card.description }}</p>
</div>
<div class="card-arrow">
<el-icon :style="{ color: themeColor }"><ArrowRight /></el-icon>
</div>
</div>
</div>
2026-06-30 23:10:56 +08:00
<!-- 快捷信息 -->
<div class="info-section">
<el-row :gutter="20">
<el-col :span="12">
<el-card shadow="hover" class="info-card">
<template #header>
<div class="info-card-header">
<span>我的信息</span>
</div>
</template>
<div class="info-item">
<span class="info-label">用户名</span>
<span>{{ userInfo?.username }}</span>
</div>
<div class="info-item">
<span class="info-label">部门</span>
<span>{{ userInfo?.departmentDesc }}</span>
</div>
<div class="info-item">
<span class="info-label">角色</span>
<span>{{ roleName }}</span>
</div>
</el-card>
</el-col>
<el-col :span="12">
<el-card shadow="hover" class="info-card">
<template #header>
<div class="info-card-header">
<span>快速操作</span>
</div>
</template>
<div class="quick-actions">
<el-button
v-for="card in visibleCards.slice(0, 3)"
:key="card.route"
:style="{ borderColor: themeColor, color: themeColor }"
@click="navigateTo(card.route)"
plain
>
{{ card.title }}
</el-button>
</div>
</el-card>
</el-col>
</el-row>
</div>
</div>
</template>
<script setup>
2026-06-30 23:10:56 +08:00
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import { getUserInfo, hasPermission, getRoleLevel, isManager } from '../store/user'
const router = useRouter()
const userInfo = computed(() => getUserInfo())
const roleLevel = computed(() => getRoleLevel())
// 主题色
const themeColor = computed(() => roleLevel.value <= 3 ? '#E60012' : '#FF8C69')
const themeBg = computed(() => roleLevel.value <= 3 ? '#FEF0F0' : '#FFF5F0')
const bannerBg = computed(() => roleLevel.value <= 3
? 'linear-gradient(135deg, #FEF0F0 0%, #FFF5F5 100%)'
: 'linear-gradient(135deg, #FFF5F0 0%, #FFFAF5 100%)')
// 角色名称
const roleName = computed(() => {
const level = roleLevel.value
if (level === 1) return '总经理'
if (level === 2) return '部门经理'
if (level === 3) return '部门副经理'
return '一般专员'
})
// 当前日期
const currentDate = computed(() => {
const d = new Date()
const days = ['日', '一', '二', '三', '四', '五', '六']
return `${d.getFullYear()}${d.getMonth() + 1}${d.getDate()}日 星期${days[d.getDay()]}`
})
// 功能卡片定义
const allCards = [
{ title: '客户管理', description: '管理加盟商信息、联系方式、地址等', icon: 'Avatar', route: '/panel/customer', permission: ['customer', 'read'] },
{ title: '合同管理', description: '管理加盟合同和采购合同', icon: 'Document', route: '/panel/contract', permission: ['contract', 'read'] },
{ title: '售后管理', description: '处理客户反馈和售后服务', icon: 'Service', route: '/panel/service', permission: ['after_sale', 'read'] },
{ title: '产品管理', description: '管理茶饮原料、包装物料、设备', icon: 'Goods', route: '/panel/products', permission: ['product', 'read'] },
{ title: '供应商管理', description: '管理供应商信息和合作关系', icon: 'Box', route: '/panel/supplier', permission: ['supplier', 'read'] },
{ title: '员工管理', description: '管理员工信息、部门、职务', icon: 'User', route: '/panel/employee', permission: ['employee', 'read'] },
{ title: '用户管理', description: '管理系统用户账号和权限', icon: 'UserFilled', route: '/panel/user', permission: ['user', 'manage'] },
]
// 根据权限过滤可见卡片
const visibleCards = computed(() => {
return allCards.filter(card => hasPermission(card.permission[0], card.permission[1]))
})
// 导航
const navigateTo = (route) => {
router.push(route)
}
</script>
<style scoped>
2026-06-30 23:10:56 +08:00
.workspace-container {
max-width: 1200px;
margin: 0 auto;
}
2026-06-15 23:20:21 +08:00
/* ========== 视频横幅 ========== */
.video-banner {
position: relative;
width: calc(100% + 40px);
2026-06-30 23:10:56 +08:00
margin: -20px -20px 20px -20px;
height: 260px;
2026-06-15 23:20:21 +08:00
overflow: hidden;
2026-06-30 23:10:56 +08:00
border-radius: 0 0 12px 12px;
}
2026-06-15 23:20:21 +08:00
.bg-video {
width: 100%;
height: 100%;
object-fit: cover;
}
2026-06-15 23:20:21 +08:00
.video-overlay {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
background: linear-gradient(
to bottom,
rgba(230, 0, 18, 0.3) 0%,
2026-06-30 23:10:56 +08:00
rgba(0, 0, 0, 0.5) 100%
2026-06-15 23:20:21 +08:00
);
display: flex;
align-items: center;
justify-content: center;
}
2026-06-30 23:10:56 +08:00
.welcome-text {
text-align: center;
}
2026-06-15 23:20:21 +08:00
.banner-title {
color: #fff;
2026-06-30 23:10:56 +08:00
font-size: 28px;
2026-06-15 23:20:21 +08:00
font-weight: 600;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
2026-06-30 23:10:56 +08:00
margin: 0 0 8px 0;
2026-06-15 23:20:21 +08:00
}
2026-06-30 23:10:56 +08:00
.welcome-sub {
margin: 0 0 4px 0;
color: rgba(255,255,255,0.9);
font-size: 16px;
2026-06-15 23:20:21 +08:00
}
2026-06-30 23:10:56 +08:00
.welcome-date {
margin: 0;
color: rgba(255,255,255,0.7);
font-size: 14px;
}
/* ========== 功能卡片网格 ========== */
.card-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
2026-06-15 23:20:21 +08:00
gap: 20px;
2026-06-30 23:10:56 +08:00
margin-bottom: 30px;
2026-06-15 23:20:21 +08:00
}
2026-06-30 23:10:56 +08:00
.function-card {
background: #fff;
border-radius: 12px;
padding: 24px;
border-top: 3px solid #E60012;
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.04);
display: flex;
align-items: center;
gap: 16px;
cursor: pointer;
transition: all 0.3s ease;
}
2026-06-30 23:10:56 +08:00
.function-card:hover {
transform: translateY(-2px);
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
background: var(--hover-bg, #FEF0F0);
}
2026-06-30 23:10:56 +08:00
.card-icon {
width: 56px;
height: 56px;
border-radius: 12px;
display: flex;
align-items: center;
2026-06-30 23:10:56 +08:00
justify-content: center;
flex-shrink: 0;
}
2026-06-30 23:10:56 +08:00
.card-content {
flex: 1;
min-width: 0;
}
.card-title {
margin: 0 0 4px 0;
font-size: 16px;
font-weight: 600;
color: #303133;
}
.card-desc {
margin: 0;
font-size: 13px;
color: #909399;
overflow: hidden;
2026-06-30 23:10:56 +08:00
text-overflow: ellipsis;
white-space: nowrap;
2026-06-15 23:20:21 +08:00
}
2026-06-30 23:10:56 +08:00
.card-arrow {
flex-shrink: 0;
opacity: 0;
transition: opacity 0.3s;
}
2026-06-30 23:10:56 +08:00
.function-card:hover .card-arrow {
opacity: 1;
}
2026-06-30 23:10:56 +08:00
/* ========== 信息区域 ========== */
.info-section {
margin-bottom: 20px;
}
2026-06-30 23:10:56 +08:00
.info-card {
height: 100%;
}
2026-06-30 23:10:56 +08:00
.info-card-header {
font-weight: 600;
}
2026-06-30 23:10:56 +08:00
.info-item {
display: flex;
2026-06-30 23:10:56 +08:00
justify-content: space-between;
padding: 8px 0;
2026-06-15 23:20:21 +08:00
border-bottom: 1px dashed #eee;
2026-06-30 23:10:56 +08:00
font-size: 14px;
}
2026-06-30 23:10:56 +08:00
.info-item:last-child {
2026-06-15 23:20:21 +08:00
border-bottom: none;
}
2026-06-15 23:20:21 +08:00
.info-label {
2026-06-30 23:10:56 +08:00
color: #909399;
}
2026-06-30 23:10:56 +08:00
.quick-actions {
display: flex;
flex-wrap: wrap;
gap: 10px;
}
2026-06-30 23:10:56 +08:00
/* ========== 响应式 ========== */
@media (max-width: 768px) {
.card-grid {
grid-template-columns: 1fr;
}
2026-06-30 23:10:56 +08:00
.welcome-banner {
padding: 20px;
}
}
</style>