web-base-admin/src/views/dashboard/dashboard.vue

477 lines
18 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<div v-show="visible" class="summary-dashboard">
<topBar
v-if="topList.length > 0 && userInfo.userType != 9"
:top-list="topList"
:moren="defaultTabItem"
:wait-approval-num="waitApprovalNum"
:receive-approval-num="receiveApprovalNum"
/>
<div class="dashboard-cards">
<!-- 会员数据卡片 -->
<div class="dashboard-card-group">
<div class="dashboard-card-title">会员数据</div>
<div class="dashboard-card-list">
<div class="dashboard-card">
<div class="dashboard-card-label">会员总数</div>
<div class="dashboard-card-value">{{ memberSummary.memberTotal || 0 }}</div>
</div>
<div class="dashboard-card">
<div class="dashboard-card-label">今日新增会员</div>
<div class="dashboard-card-value">{{ memberSummary.memberToday || 0 }}</div>
</div>
<div class="dashboard-card">
<div class="dashboard-card-label">昨日新增会员</div>
<div class="dashboard-card-value">{{ memberSummary.memberYesterday || 0 }}</div>
</div>
<div class="dashboard-card">
<div class="dashboard-card-label">当月新增会员</div>
<div class="dashboard-card-value">{{ memberSummary.memberMonth || 0 }}</div>
</div>
</div>
</div>
<!-- 业绩数据卡片 -->
<div class="dashboard-card-group dashboard-card-group--today">
<div class="dashboard-card-title dashboard-card-title--today">今日业绩</div>
<div class="dashboard-card-list dashboard-card-list--performance">
<div class="dashboard-card dashboard-card--performance dashboard-card--today">
<div class="dashboard-card-label">首购金额</div>
<div class="dashboard-card-value dashboard-card-value--today">{{ dailyPerformance.today && dailyPerformance.today.firstAmount || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--today">
<div class="dashboard-card-label">首购业绩</div>
<div class="dashboard-card-value dashboard-card-value--today">{{ dailyPerformance.today && dailyPerformance.today.firstAchieve || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--today">
<div class="dashboard-card-label">复购金额</div>
<div class="dashboard-card-value dashboard-card-value--today">{{ dailyPerformance.today && dailyPerformance.today.repAmount || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--today">
<div class="dashboard-card-label">复购业绩</div>
<div class="dashboard-card-value dashboard-card-value--today">{{ dailyPerformance.today && dailyPerformance.today.repAchieve || '0.00' }}</div>
</div>
<div class="dashboard-total-row">
<div class="dashboard-card dashboard-card--performance dashboard-card--today dashboard-card--total-amount">
<div class="dashboard-card-label">总金额</div>
<div class="dashboard-card-value dashboard-card-value--today">{{ getSum(dailyPerformance.today && dailyPerformance.today.firstAmount, dailyPerformance.today && dailyPerformance.today.repAmount) }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--today dashboard-card--total-achievement">
<div class="dashboard-card-label">总业绩</div>
<div class="dashboard-card-value dashboard-card-value--today">{{ getSum(dailyPerformance.today && dailyPerformance.today.firstAchieve, dailyPerformance.today && dailyPerformance.today.repAchieve) }}</div>
</div>
</div>
</div>
</div>
<div class="dashboard-card-group dashboard-card-group--yesterday">
<div class="dashboard-card-title dashboard-card-title--yesterday">昨日业绩</div>
<div class="dashboard-card-list dashboard-card-list--performance">
<div class="dashboard-card dashboard-card--performance dashboard-card--yesterday">
<div class="dashboard-card-label">首购金额</div>
<div class="dashboard-card-value">{{ dailyPerformance.yesterday && dailyPerformance.yesterday.firstAmount || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--yesterday">
<div class="dashboard-card-label">首购业绩</div>
<div class="dashboard-card-value">{{ dailyPerformance.yesterday && dailyPerformance.yesterday.firstAchieve || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--yesterday">
<div class="dashboard-card-label">复购金额</div>
<div class="dashboard-card-value">{{ dailyPerformance.yesterday && dailyPerformance.yesterday.repAmount || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--yesterday">
<div class="dashboard-card-label">复购业绩</div>
<div class="dashboard-card-value">{{ dailyPerformance.yesterday && dailyPerformance.yesterday.repAchieve || '0.00' }}</div>
</div>
<div class="dashboard-total-row">
<div class="dashboard-card dashboard-card--performance dashboard-card--yesterday dashboard-card--total-amount">
<div class="dashboard-card-label">总金额</div>
<div class="dashboard-card-value">{{ getSum(dailyPerformance.yesterday && dailyPerformance.yesterday.firstAmount, dailyPerformance.yesterday && dailyPerformance.yesterday.repAmount) }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--yesterday dashboard-card--total-achievement">
<div class="dashboard-card-label">总业绩</div>
<div class="dashboard-card-value">{{ getSum(dailyPerformance.yesterday && dailyPerformance.yesterday.firstAchieve, dailyPerformance.yesterday && dailyPerformance.yesterday.repAchieve) }}</div>
</div>
</div>
</div>
</div>
<div class="dashboard-card-group dashboard-card-group--month">
<div class="dashboard-card-title dashboard-card-title--month">本月业绩</div>
<div class="dashboard-card-list dashboard-card-list--performance">
<div class="dashboard-card dashboard-card--performance dashboard-card--month">
<div class="dashboard-card-label">首购金额</div>
<div class="dashboard-card-value">{{ monthlyPerformance.firstAmount || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--month">
<div class="dashboard-card-label">首购业绩</div>
<div class="dashboard-card-value">{{ monthlyPerformance.firstAchieve || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--month">
<div class="dashboard-card-label">复购金额</div>
<div class="dashboard-card-value">{{ monthlyPerformance.repAmount || '0.00' }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--month">
<div class="dashboard-card-label">复购业绩</div>
<div class="dashboard-card-value">{{ monthlyPerformance.repAchieve || '0.00' }}</div>
</div>
<div class="dashboard-total-row">
<div class="dashboard-card dashboard-card--performance dashboard-card--month dashboard-card--total-amount">
<div class="dashboard-card-label">总金额</div>
<div class="dashboard-card-value">{{ getSum(monthlyPerformance.firstAmount, monthlyPerformance.repAmount) }}</div>
</div>
<div class="dashboard-card dashboard-card--performance dashboard-card--month dashboard-card--total-achievement">
<div class="dashboard-card-label">总业绩</div>
<div class="dashboard-card-value">{{ getSum(monthlyPerformance.firstAchieve, monthlyPerformance.repAchieve) }}</div>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import topBarMixin from './mixins/top-bar-mixin'
import topBar from '@/components/topBar'
import { getMemberSummary, getDailyPerformance, getMonthlyPerformance } from '@/api/dashboard'
export default {
name: 'SummaryDashboard',
components: {
topBar
},
mixins: [topBarMixin],
data() {
return {
memberSummary: {},
dailyPerformance: {},
monthlyPerformance: {},
defaultTabItem: 'summaryDashboard',
userInfo: {},
visible: false
}
},
mounted() {
this.getRoles().then(() => {
this.visible = true
this.getMemberSummary()
this.getDailyPerformance()
this.getMonthlyPerformance()
this.getApprovalStatus()
this.userInfo = JSON.parse(localStorage.getItem('userInfo'))
})
},
methods: {
getMemberSummary() {
// {
// "msg": "操作成功",
// "code": 200,
// "data": {
// "memberTotal": 145,
// "memberToday": 0,
// "memberYesterday": 0,
// "memberMonth": 18
// }
// }
getMemberSummary().then(res => {
this.memberSummary = res.data
})
},
getDailyPerformance() {
// {
// "msg": "操作成功",
// "code": 200,
// "data": {
// "today": {
// "firstAchieve": "0.00",
// "firstAmount": "0.00",
// "repAchieve": "0.00",
// "repAmount": "0.00"
// },
// "yesterday": {
// "firstAchieve": "0.00",
// "firstAmount": "0.00",
// "repAchieve": "1.29",
// "repAmount": "5.40"
// }
// }
// }
getDailyPerformance().then(res => {
this.dailyPerformance = res.data
})
},
// {
// "msg": "操作成功",
// "code": 200,
// "data": {
// "firstAchieve": "55.63",
// "firstAmount": "199.80",
// "repAchieve": "1.83",
// "repAmount": "10.61"
// }
// }
getMonthlyPerformance() {
getMonthlyPerformance().then(res => {
this.monthlyPerformance = res.data
})
},
getSum(a, b) {
// 字符串转数字后相加,保留两位小数
const numA = parseFloat(a) || 0
const numB = parseFloat(b) || 0
return (numA + numB).toFixed(2)
}
}
}
</script>
<style lang="scss" scoped>
.summary-dashboard {
padding: 20px;
background: #f9f9f9;
font-size: 14px;
}
.dashboard-cards {
margin-top: 16px;
display: flex;
flex-direction: column;
gap: 24px;
}
.dashboard-card-group {
background: #fff;
border-radius: 12px;
box-shadow: 0 2px 12px 0 rgba(0,0,0,0.06);
padding: 24px 32px 16px 32px;
}
/* 基础分组标题样式 */
.dashboard-card-title {
font-size: 18px;
font-weight: 600;
margin-bottom: 20px; /* 统一标题下边距 */
color: #333333; /* 默认标题颜色 */
}
/* 统一业绩分组标题样式 - 继承基础并扩展 */
.dashboard-card-group--today .dashboard-card-title,
.dashboard-card-group--yesterday .dashboard-card-title,
.dashboard-card-group--month .dashboard-card-title {
font-size: 18px;
font-weight: 600;
margin-bottom: 20px;
padding-left: 12px;
position: relative;
}
/* 业绩分组标题左侧装饰线 */
.dashboard-card-group--today .dashboard-card-title::before,
.dashboard-card-group--yesterday .dashboard-card-title::before,
.dashboard-card-group--month .dashboard-card-title::before {
content: '';
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
width: 4px;
height: 18px; /* 调整装饰线高度 */
border-radius: 2px;
}
.dashboard-card-group--today .dashboard-card-title {
color: #357ae8;
/* font-size, font-weight, margin-bottom will be inherited from .dashboard-card-title */
}
.dashboard-card-group--today .dashboard-card-title::before {
background-color: #357ae8;
}
.dashboard-card-group--yesterday .dashboard-card-title {
color: #f59e0b; /* 昨日标题颜色 - 暖黄色 */
/* font-size, font-weight, margin-bottom will be inherited */
}
.dashboard-card-group--yesterday .dashboard-card-title::before {
background-color: #f59e0b;
}
.dashboard-card-group--month .dashboard-card-title {
color: #10b981; /* 本月标题颜色 - 绿色 */
/* font-size, font-weight, margin-bottom will be inherited */
}
.dashboard-card-group--month .dashboard-card-title::before {
background-color: #10b981;
transition: all 0.3s ease;
}
.dashboard-card-list {
display: flex;
flex-wrap: wrap;
gap: 24px;
}
.dashboard-card {
flex: 1 1 180px;
min-width: 180px;
background: linear-gradient(135deg, #f6d365 0%, #fda085 100%);
border-radius: 10px;
box-shadow: 0 1px 6px 0 rgba(253,160,133,0.12);
padding: 18px 16px;
display: flex;
flex-direction: column;
align-items: flex-start;
transition: all 0.3s ease;
}
.dashboard-card:hover {
transform: translateY(-3px);
box-shadow: 0 4px 12px 0 rgba(253,160,133,0.2);
/* 会员卡片样式不变 */
}
.dashboard-card-label {
font-size: 14px;
color: #666;
margin-bottom: 8px;
}
.dashboard-card-value {
font-size: 28px;
font-weight: bold;
color: #222;
}
/* 业绩卡片专属基础样式 */
.dashboard-card--performance {
background: #ffffff;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 20px;
flex: 1 1 200px;
min-width: 180px;
display: flex;
flex-direction: column;
justify-content: space-between;
box-shadow: 0 2px 4px rgba(0,0,0,0.04); /* 更精致的阴影 */
transition: all 0.3s ease-in-out;
position: relative; /* 用于内部绝对定位元素(如有) */
}
.dashboard-card--performance:hover {
transform: translateY(-5px);
box-shadow: 0 8px 16px rgba(0,0,0,0.07);
}
.dashboard-card--performance .dashboard-card-label {
font-size: 14px; /* 标签字号略微增大以保持清晰 */
color: #4b5563; /* 标签颜色调整,更柔和 */
margin-bottom: 12px;
}
.dashboard-card--performance .dashboard-card-value {
font-size: 24px; /* 基础数值字号 */
font-weight: 700; /* 加粗数值 */
color: #111827; /* 深色数值,对比度高 */
display: flex;
align-items: baseline;
justify-content: flex-start;
line-height: 1.2; /* 改善行高 */
}
.dashboard-card--performance .dashboard-card-value::after {
/* content: '¥'; */ /* 去掉人民币符号 */
font-size: 13px; /* 货币符号大小 */
font-weight: 500;
color: #374151; /* 货币符号颜色 */
margin-left: 4px;
}
/* 今日业绩卡片特殊样式 */
.dashboard-card--today.dashboard-card--performance {
background: linear-gradient(135deg, #a7d7f9 0%, #7fb2eb 100%); /* 更明显的蓝天到海洋蓝渐变 */
border-left: 5px solid #357ae8; /* 标题蓝色 */
border-color: transparent; /* 其他边框透明,突出左边框 */
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-top-left-radius: 0; /* 配合左边框 */
border-bottom-left-radius: 0; /* 配合左边框 */
}
.dashboard-card--today.dashboard-card--performance .dashboard-card-label {
color: #2c5282; /* 深蓝标签,配合主色 */
font-weight: 500;
}
.dashboard-card--today.dashboard-card--performance .dashboard-card-value {
color: #1e3a8a; /* 更深的蓝,突出数值 */
font-size: 28px; /* 今日数值更大 */
}
/* 昨日业绩卡片 */
.dashboard-card--yesterday.dashboard-card--performance {
background: linear-gradient(135deg, #fde68a 0%, #f5c767 100%); /* 更明显的阳光黄到橘黄渐变 */
border-left: 5px solid #f59e0b; /* 标题黄色 */
border-color: transparent;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.dashboard-card--yesterday.dashboard-card--performance .dashboard-card-label {
color: #b45309; /* 深黄/橙色标签 */
}
.dashboard-card--yesterday.dashboard-card--performance .dashboard-card-value {
color: #78350f; /* 深橙/棕色数值 */
}
/* 本月业绩卡片 */
.dashboard-card--month.dashboard-card--performance {
background: linear-gradient(135deg, #a7f3d0 0%, #79d7b5 100%); /* 更明显的薄荷绿到青绿渐变 */
border-left: 5px solid #10b981; /* 标题绿色 */
border-color: transparent;
border-top-right-radius: 8px;
border-bottom-right-radius: 8px;
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
.dashboard-card--month.dashboard-card--performance .dashboard-card-label {
color: #047857; /* 深绿色标签 */
}
.dashboard-card--month.dashboard-card--performance .dashboard-card-value {
color: #065f46; /* 更深的绿色数值 */
}
/* 总计行特定样式 */
.dashboard-total-row {
display: flex;
gap: 24px; /* 与 .dashboard-card-list 的 gap 保持一致或按需调整 */
width: 100%; /* 占据整行宽度 */
}
.dashboard-total-row .dashboard-card--performance {
flex: 1 1 0; /* 让两个卡片均分空间 */
/* 覆盖一些基础卡片样式,如果需要更紧凑 */
min-width: 0; /* 允许卡片收缩 */
}
/* 特定对齐调整:确保总金额与金额对齐,总业绩与业绩对齐 */
/* 由于业绩卡片内部已经是 flex-start主要依赖卡片宽度和内部padding */
/* 如果需要更精确的对齐,可能需要对 .dashboard-card-value 和 .dashboard-card-label 进行微调 */
.dashboard-card--total-amount .dashboard-card-value,
.dashboard-card--total-achievement .dashboard-card-value {
/* 如果希望文本部分左对齐以模拟效果,可以尝试 */
/* justify-content: flex-start; */
/* padding-left: 你可能需要根据实际视觉效果计算一个值 */
}
@media (max-width: 900px) {
.dashboard-card-list {
gap: 16px;
}
.dashboard-card, .dashboard-card--performance {
min-width: unset;
width: 100%;
}
.dashboard-card--performance .dashboard-card-value {
font-size: 22px;
}
.dashboard-card--today.dashboard-card--performance .dashboard-card-value {
font-size: 26px;
}
}
</style>