2026-01-07 17:33:50 +08:00
|
|
|
|
<template>
|
2026-01-09 15:42:59 +08:00
|
|
|
|
<div v-if="stats && (stats.month || stats.year)" class="summary-card common-card">
|
2026-01-07 17:33:50 +08:00
|
|
|
|
<template v-for="(config, key) in periodConfigs" :key="key">
|
|
|
|
|
|
<div class="summary-item">
|
|
|
|
|
|
<div class="label">{{ config.label }}{{ title }}率</div>
|
2026-01-09 15:42:59 +08:00
|
|
|
|
<div class="value" :class="getValueClass(stats[key]?.rate || '0.0')">
|
|
|
|
|
|
{{ 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>
|
2026-01-07 17:33:50 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="config.showDivider" class="divider"></div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
stats: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
},
|
|
|
|
|
|
title: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
},
|
|
|
|
|
|
getValueClass: {
|
|
|
|
|
|
type: Function,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
const periodConfigs = {
|
|
|
|
|
|
month: { label: '本月', showDivider: true },
|
|
|
|
|
|
year: { label: '年度', showDivider: false }
|
|
|
|
|
|
}
|
2026-01-09 15:42:59 +08:00
|
|
|
|
|
|
|
|
|
|
const formatMoney = (val) => {
|
|
|
|
|
|
return parseFloat(val || 0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
|
|
|
|
|
}
|
2026-01-07 17:33:50 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.summary-card {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-around;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
padding: 12px 16px;
|
|
|
|
|
|
margin-top: 12px;
|
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .label {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: #969799;
|
|
|
|
|
|
margin-bottom: 6px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .value {
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: bold;
|
|
|
|
|
|
color: #323233;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item :deep(.value.expense) {
|
|
|
|
|
|
color: #ee0a24;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item :deep(.value.income) {
|
|
|
|
|
|
color: #07c160;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item :deep(.value.warning) {
|
|
|
|
|
|
color: #ff976a;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.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;
|
|
|
|
|
|
color: #c8c9cc;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 3px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .amount {
|
|
|
|
|
|
color: #646566;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.summary-item .separator {
|
2026-01-07 17:33:50 +08:00
|
|
|
|
color: #c8c9cc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.divider {
|
|
|
|
|
|
width: 1px;
|
|
|
|
|
|
height: 24px;
|
|
|
|
|
|
background-color: #ebedf0;
|
|
|
|
|
|
margin: 0 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@media (prefers-color-scheme: dark) {
|
|
|
|
|
|
.summary-item .value {
|
|
|
|
|
|
color: #f5f5f5;
|
|
|
|
|
|
}
|
2026-01-09 15:42:59 +08:00
|
|
|
|
.summary-item .amount {
|
|
|
|
|
|
color: #c8c9cc;
|
|
|
|
|
|
}
|
2026-01-07 17:33:50 +08:00
|
|
|
|
.divider {
|
|
|
|
|
|
background-color: #2c2c2c;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|