2026-01-07 17:33:50 +08:00
|
|
|
|
<template>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
<div class="summary-container">
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<transition
|
|
|
|
|
|
:name="transitionName"
|
|
|
|
|
|
mode="out-in"
|
|
|
|
|
|
>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-if="stats && (stats.month || stats.year)"
|
|
|
|
|
|
:key="dateKey"
|
|
|
|
|
|
class="summary-card common-card"
|
|
|
|
|
|
>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
<!-- 左切换按钮 -->
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="nav-arrow left"
|
|
|
|
|
|
@click.stop="changeMonth(-1)"
|
|
|
|
|
|
>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
<van-icon name="arrow-left" />
|
2026-01-09 15:42:59 +08:00
|
|
|
|
</div>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="summary-content">
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<template
|
|
|
|
|
|
v-for="(config, key) in periodConfigs"
|
|
|
|
|
|
:key="key"
|
|
|
|
|
|
>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
<div class="summary-item">
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<div class="label">
|
|
|
|
|
|
{{ config.label }}{{ title }}率
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="value"
|
|
|
|
|
|
:class="getValueClass(stats[key]?.rate || '0.0')"
|
|
|
|
|
|
>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
{{ stats[key]?.rate || '0.0' }}<span class="unit">%</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="sub-info">
|
|
|
|
|
|
<span class="amount">¥{{ formatMoney(stats[key]?.current || 0) }}</span>
|
|
|
|
|
|
<span class="separator">/</span>
|
|
|
|
|
|
<span class="amount">¥{{ formatMoney(stats[key]?.limit || 0) }}</span>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-if="config.showDivider"
|
|
|
|
|
|
class="divider"
|
|
|
|
|
|
/>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 右切换按钮 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="nav-arrow right"
|
2026-01-11 12:41:52 +08:00
|
|
|
|
:class="{ disabled: isCurrentMonth }"
|
|
|
|
|
|
@click.stop="!isCurrentMonth && changeMonth(1)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<van-icon name="arrow" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 非本月时显示的日期标识 -->
|
2026-01-27 15:29:25 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-if="!isCurrentMonth"
|
|
|
|
|
|
class="date-tag"
|
|
|
|
|
|
>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
{{ props.date.getFullYear() }}年{{ props.date.getMonth() + 1 }}月
|
2026-01-07 17:33:50 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
</transition>
|
2026-01-07 17:33:50 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
import { computed, ref } from 'vue'
|
|
|
|
|
|
|
2026-01-07 17:33:50 +08:00
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
stats: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
},
|
|
|
|
|
|
title: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
},
|
|
|
|
|
|
getValueClass: {
|
|
|
|
|
|
type: Function,
|
|
|
|
|
|
required: true
|
2026-01-11 12:41:52 +08:00
|
|
|
|
},
|
|
|
|
|
|
date: {
|
|
|
|
|
|
type: Date,
|
|
|
|
|
|
default: () => new Date()
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-11 12:41:52 +08:00
|
|
|
|
const emit = defineEmits(['update:date'])
|
|
|
|
|
|
|
|
|
|
|
|
const transitionName = ref('slide-right')
|
|
|
|
|
|
const dateKey = computed(() => props.date.getFullYear() + '-' + props.date.getMonth())
|
|
|
|
|
|
|
|
|
|
|
|
const isCurrentMonth = computed(() => {
|
|
|
|
|
|
const now = new Date()
|
2026-01-16 11:15:44 +08:00
|
|
|
|
return props.date.getFullYear() === now.getFullYear() && props.date.getMonth() === now.getMonth()
|
2026-01-11 12:41:52 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const periodConfigs = computed(() => ({
|
2026-01-16 11:15:44 +08:00
|
|
|
|
month: {
|
|
|
|
|
|
label: isCurrentMonth.value ? '本月' : `${props.date.getMonth() + 1}月`,
|
|
|
|
|
|
showDivider: true
|
2026-01-11 12:41:52 +08:00
|
|
|
|
},
|
2026-01-16 11:15:44 +08:00
|
|
|
|
year: {
|
|
|
|
|
|
label: isCurrentMonth.value ? '年度' : `${props.date.getFullYear()}年`,
|
|
|
|
|
|
showDivider: false
|
2026-01-11 12:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
const changeMonth = (delta) => {
|
|
|
|
|
|
transitionName.value = delta > 0 ? 'slide-left' : 'slide-right'
|
|
|
|
|
|
const newDate = new Date(props.date)
|
|
|
|
|
|
newDate.setMonth(newDate.getMonth() + delta)
|
|
|
|
|
|
emit('update:date', newDate)
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
2026-01-09 15:42:59 +08:00
|
|
|
|
|
|
|
|
|
|
const formatMoney = (val) => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
return parseFloat(val || 0).toLocaleString(undefined, {
|
|
|
|
|
|
minimumFractionDigits: 0,
|
|
|
|
|
|
maximumFractionDigits: 0
|
|
|
|
|
|
})
|
2026-01-09 15:42:59 +08:00
|
|
|
|
}
|
2026-01-07 17:33:50 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-01-11 12:41:52 +08:00
|
|
|
|
.summary-container {
|
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-07 17:33:50 +08:00
|
|
|
|
.summary-card {
|
2026-01-11 12:41:52 +08:00
|
|
|
|
position: relative;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 16px 36px;
|
|
|
|
|
|
margin: 0 12px 8px;
|
|
|
|
|
|
min-height: 80px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-content {
|
|
|
|
|
|
flex: 1;
|
2026-01-07 17:33:50 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
text-align: center;
|
2026-01-11 12:41:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-arrow {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
bottom: 0;
|
|
|
|
|
|
width: 40px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
font-size: 18px;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-gray-5);
|
2026-01-11 12:41:52 +08:00
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
transition: all 0.2s;
|
|
|
|
|
|
z-index: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-arrow:active {
|
|
|
|
|
|
color: var(--van-primary-color);
|
|
|
|
|
|
background-color: rgba(0, 0, 0, 0.02);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-14 15:59:18 +08:00
|
|
|
|
.nav-arrow.disabled {
|
|
|
|
|
|
color: #c8c9cc;
|
|
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
opacity: 0.35;
|
|
|
|
|
|
pointer-events: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-arrow.disabled:active {
|
|
|
|
|
|
background-color: transparent;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-11 12:41:52 +08:00
|
|
|
|
.nav-arrow.left {
|
|
|
|
|
|
left: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-arrow.right {
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.nav-arrow.disabled {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-gray-3);
|
2026-01-11 12:41:52 +08:00
|
|
|
|
cursor: not-allowed;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.date-tag {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
color: var(--van-primary-color);
|
|
|
|
|
|
background-color: var(--van-primary-color-light);
|
|
|
|
|
|
padding: 1px 8px;
|
|
|
|
|
|
border-radius: 0 0 8px 8px;
|
|
|
|
|
|
font-weight: 500;
|
|
|
|
|
|
opacity: 0.8;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 动画效果 */
|
|
|
|
|
|
.slide-left-enter-active,
|
|
|
|
|
|
.slide-left-leave-active,
|
|
|
|
|
|
.slide-right-enter-active,
|
|
|
|
|
|
.slide-right-leave-active {
|
|
|
|
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slide-left-enter-from {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
transform: translateX(30px);
|
|
|
|
|
|
}
|
|
|
|
|
|
.slide-left-leave-to {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
transform: translateX(-30px);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.slide-right-enter-from {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
transform: translateX(-30px);
|
|
|
|
|
|
}
|
|
|
|
|
|
.slide-right-leave-to {
|
|
|
|
|
|
opacity: 0;
|
|
|
|
|
|
transform: translateX(30px);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .label {
|
|
|
|
|
|
font-size: 12px;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-2);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
margin-bottom: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .value {
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: bold;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item :deep(.value.expense) {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-danger-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item :deep(.value.income) {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-success-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item :deep(.value.warning) {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-warning-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .unit {
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
margin-left: 1px;
|
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-09 15:42:59 +08:00
|
|
|
|
.summary-item .sub-info {
|
|
|
|
|
|
font-size: 12px;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-3);
|
2026-01-09 15:42:59 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 3px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .amount {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-2);
|
2026-01-09 15:42:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .separator {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-3);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.divider {
|
|
|
|
|
|
width: 1px;
|
|
|
|
|
|
height: 24px;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background-color: var(--van-border-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
margin: 0 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-13 17:00:44 +08:00
|
|
|
|
/* @media (prefers-color-scheme: dark) {
|
2026-01-11 12:41:52 +08:00
|
|
|
|
.nav-arrow:active {
|
|
|
|
|
|
background-color: rgba(255, 255, 255, 0.05);
|
|
|
|
|
|
}
|
|
|
|
|
|
.nav-arrow.disabled {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color);
|
2026-01-11 12:41:52 +08:00
|
|
|
|
}
|
2026-01-07 17:33:50 +08:00
|
|
|
|
.summary-item .value {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
2026-01-09 15:42:59 +08:00
|
|
|
|
.summary-item .amount {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-text-color-3);
|
2026-01-09 15:42:59 +08:00
|
|
|
|
}
|
2026-01-07 17:33:50 +08:00
|
|
|
|
.divider {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background-color: var(--van-border-color);
|
2026-01-07 17:33:50 +08:00
|
|
|
|
}
|
2026-01-13 17:00:44 +08:00
|
|
|
|
} */
|
2026-01-07 17:33:50 +08:00
|
|
|
|
</style>
|