2025-12-26 17:13:57 +08:00
|
|
|
|
<template>
|
2025-12-27 21:15:26 +08:00
|
|
|
|
<div class="page-container-flex">
|
2025-12-26 17:13:57 +08:00
|
|
|
|
<!-- 顶部导航栏 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-nav-bar
|
|
|
|
|
|
placeholder
|
|
|
|
|
|
>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<template #title>
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="nav-date-picker"
|
|
|
|
|
|
@click="showMonthPicker = true"
|
|
|
|
|
|
>
|
|
|
|
|
|
<span>{{ currentYear }}年{{ currentMonth }}月</span>
|
|
|
|
|
|
<van-icon name="arrow-down" />
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
<template #right>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-icon
|
|
|
|
|
|
name="chat-o"
|
|
|
|
|
|
size="20"
|
|
|
|
|
|
@click="goToAnalysis"
|
|
|
|
|
|
/>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</van-nav-bar>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 下拉刷新 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-pull-refresh
|
|
|
|
|
|
v-model="refreshing"
|
|
|
|
|
|
@refresh="onRefresh"
|
|
|
|
|
|
>
|
2026-01-11 16:33:55 +08:00
|
|
|
|
<!-- 初始加载中 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-loading
|
|
|
|
|
|
v-if="loading && firstLoading"
|
|
|
|
|
|
vertical
|
|
|
|
|
|
style="padding: 100px 0"
|
|
|
|
|
|
>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
加载统计数据中...
|
|
|
|
|
|
</van-loading>
|
|
|
|
|
|
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<!-- 统计内容(可滚动部分) -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
|
|
|
|
|
v-if="!firstLoading"
|
2026-01-16 15:56:53 +08:00
|
|
|
|
class="statistics-content"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div>
|
|
|
|
|
|
<!-- 趋势统计 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="common-card"
|
|
|
|
|
|
style="padding-bottom: 5px; margin-top: 12px;"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
|
<h3 class="card-title">
|
|
|
|
|
|
收支趋势
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
</div>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div
|
|
|
|
|
|
class="trend-chart"
|
|
|
|
|
|
style="height: 240px; padding: 10px 0"
|
|
|
|
|
|
>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
2026-01-16 15:56:53 +08:00
|
|
|
|
ref="chartRef"
|
|
|
|
|
|
style="width: 100%; height: 100%"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 分类统计 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="common-card"
|
|
|
|
|
|
style="padding-bottom: 10px;"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
|
<h3 class="card-title">
|
|
|
|
|
|
支出分类
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
<van-tag
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
size="medium"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
{{ expenseCategoriesView.length }}类
|
|
|
|
|
|
</van-tag>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 环形图区域 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="expenseCategoriesView.length > 0"
|
|
|
|
|
|
class="chart-container"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="ring-chart">
|
|
|
|
|
|
<div
|
|
|
|
|
|
ref="pieChartRef"
|
|
|
|
|
|
style="width: 100%; height: 100%"
|
|
|
|
|
|
/>
|
2026-01-11 16:33:55 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!-- 分类列表 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="category-list"
|
|
|
|
|
|
>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
2026-01-16 15:56:53 +08:00
|
|
|
|
v-for="category in expenseCategoriesSimpView"
|
|
|
|
|
|
:key="category.classify"
|
|
|
|
|
|
class="category-item clickable"
|
|
|
|
|
|
@click="goToCategoryBills(category.classify, 0)"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div class="category-info">
|
|
|
|
|
|
<div
|
|
|
|
|
|
class="category-color"
|
|
|
|
|
|
:style="{ backgroundColor: category.color }"
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div class="category-name-with-count">
|
|
|
|
|
|
<span class="category-name">{{ category.classify || '未分类' }}</span>
|
|
|
|
|
|
<span class="category-count">{{ category.count }}笔</span>
|
|
|
|
|
|
</div>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div class="category-stats">
|
|
|
|
|
|
<div class="category-amount">
|
|
|
|
|
|
¥{{ formatMoney(category.amount) }}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="category-percent">
|
|
|
|
|
|
{{ category.percent }}%
|
|
|
|
|
|
</div>
|
2026-01-11 16:33:55 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<van-icon
|
|
|
|
|
|
name="arrow"
|
|
|
|
|
|
class="category-arrow"
|
|
|
|
|
|
/>
|
2026-01-11 16:33:55 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<!-- 展开/收起按钮 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
2026-01-16 15:56:53 +08:00
|
|
|
|
v-if="expenseCategoriesView.length > 1"
|
|
|
|
|
|
class="expand-toggle"
|
|
|
|
|
|
@click="showAllExpense = !showAllExpense"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<van-icon :name="showAllExpense ? 'arrow-up' : 'arrow-down'" />
|
2026-01-11 16:33:55 +08:00
|
|
|
|
</div>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<van-empty
|
|
|
|
|
|
v-if="!expenseCategoriesView || !expenseCategoriesView.length"
|
|
|
|
|
|
description="本月暂无支出记录"
|
|
|
|
|
|
image="search"
|
|
|
|
|
|
/>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<!-- 收支和不计收支并列显示 -->
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-if="incomeCategoriesView.length > 0 || noneCategoriesView.length > 0"
|
|
|
|
|
|
class="side-by-side-cards"
|
|
|
|
|
|
>
|
|
|
|
|
|
<!-- 收入分类统计 -->
|
2026-01-16 12:08:11 +08:00
|
|
|
|
<div
|
2026-01-16 15:56:53 +08:00
|
|
|
|
v-if="incomeCategoriesView.length > 0"
|
|
|
|
|
|
class="common-card half-card"
|
2026-01-16 12:08:11 +08:00
|
|
|
|
>
|
2026-01-15 22:10:57 +08:00
|
|
|
|
<div class="card-header">
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<h3 class="card-title">
|
2026-01-16 15:56:53 +08:00
|
|
|
|
收入
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</h3>
|
|
|
|
|
|
<van-tag
|
2026-01-16 15:56:53 +08:00
|
|
|
|
type="success"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
size="medium"
|
|
|
|
|
|
>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
{{ incomeCategoriesView.length }}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</van-tag>
|
2026-01-15 22:10:57 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
|
|
|
|
|
|
<div class="category-list">
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
2026-01-16 15:56:53 +08:00
|
|
|
|
v-for="category in incomeCategoriesView"
|
2026-01-16 12:08:11 +08:00
|
|
|
|
:key="category.classify"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
class="category-item clickable"
|
2026-01-16 15:56:53 +08:00
|
|
|
|
@click="goToCategoryBills(category.classify, 1)"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
>
|
|
|
|
|
|
<div class="category-info">
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div class="category-color income-color" />
|
|
|
|
|
|
<span class="category-name text-ellipsis">{{ category.classify || '未分类' }}</span>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div class="category-amount income-text">
|
|
|
|
|
|
¥{{ formatMoney(category.amount) }}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</div>
|
2026-01-16 12:08:11 +08:00
|
|
|
|
</div>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 不计收支分类统计 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<div
|
2026-01-16 15:56:53 +08:00
|
|
|
|
v-if="noneCategoriesView.length > 0"
|
|
|
|
|
|
class="common-card half-card"
|
2026-01-16 11:15:44 +08:00
|
|
|
|
>
|
2026-01-15 22:10:57 +08:00
|
|
|
|
<div class="card-header">
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<h3 class="card-title">
|
2026-01-16 15:56:53 +08:00
|
|
|
|
不计收支
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</h3>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<van-tag
|
|
|
|
|
|
type="warning"
|
|
|
|
|
|
size="medium"
|
|
|
|
|
|
>
|
|
|
|
|
|
{{ noneCategoriesView.length }}
|
|
|
|
|
|
</van-tag>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div class="category-list">
|
|
|
|
|
|
<div
|
|
|
|
|
|
v-for="category in noneCategoriesView"
|
|
|
|
|
|
:key="category.classify"
|
|
|
|
|
|
class="category-item clickable"
|
|
|
|
|
|
@click="goToCategoryBills(category.classify, 2)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<div class="category-info">
|
|
|
|
|
|
<div class="category-color none-color" />
|
|
|
|
|
|
<span class="category-name text-ellipsis">{{ category.classify || '未分类' }}</span>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<div class="category-amount none-text">
|
|
|
|
|
|
¥{{ formatMoney(category.amount) }}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
</div>
|
2026-01-15 22:10:57 +08:00
|
|
|
|
</div>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
2026-01-11 16:33:55 +08:00
|
|
|
|
</div>
|
2026-01-16 15:56:53 +08:00
|
|
|
|
<!-- 底部安全距离 -->
|
|
|
|
|
|
<div style="height: calc(50px + env(safe-area-inset-bottom, 0px))" />
|
|
|
|
|
|
</div>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</van-pull-refresh>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- 月份选择器 -->
|
2026-01-16 11:15:44 +08:00
|
|
|
|
<van-popup
|
|
|
|
|
|
v-model:show="showMonthPicker"
|
|
|
|
|
|
position="bottom"
|
|
|
|
|
|
round
|
|
|
|
|
|
teleport="body"
|
|
|
|
|
|
>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
<van-date-picker
|
|
|
|
|
|
v-model="selectedDate"
|
|
|
|
|
|
title="选择月份"
|
|
|
|
|
|
:min-date="minDate"
|
|
|
|
|
|
:max-date="maxDate"
|
|
|
|
|
|
:columns-type="['year', 'month']"
|
|
|
|
|
|
@confirm="onMonthConfirm"
|
|
|
|
|
|
@cancel="showMonthPicker = false"
|
|
|
|
|
|
/>
|
|
|
|
|
|
</van-popup>
|
2025-12-26 17:56:08 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 分类账单列表弹出层 -->
|
2025-12-30 17:02:30 +08:00
|
|
|
|
<PopupContainer
|
|
|
|
|
|
v-model="billListVisible"
|
|
|
|
|
|
:title="selectedCategoryTitle"
|
|
|
|
|
|
:subtitle="categoryBillsTotal ? `共 ${categoryBillsTotal} 笔交易` : ''"
|
2026-01-11 11:21:13 +08:00
|
|
|
|
height="75%"
|
2025-12-26 17:56:08 +08:00
|
|
|
|
>
|
2025-12-30 17:02:30 +08:00
|
|
|
|
<template #header-actions>
|
|
|
|
|
|
<SmartClassifyButton
|
|
|
|
|
|
v-if="isUnclassified"
|
2026-01-07 14:33:30 +08:00
|
|
|
|
ref="smartClassifyButtonRef"
|
2025-12-30 17:02:30 +08:00
|
|
|
|
:transactions="categoryBills"
|
2026-01-07 14:33:30 +08:00
|
|
|
|
:on-before-classify="beforeSmartClassify"
|
2025-12-30 17:02:30 +08:00
|
|
|
|
@save="onSmartClassifySave"
|
2025-12-30 18:49:46 +08:00
|
|
|
|
@notify-doned-transaction-id="handleNotifiedTransactionId"
|
2025-12-30 17:02:30 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</template>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-30 17:02:30 +08:00
|
|
|
|
<TransactionList
|
2026-01-10 12:22:37 +08:00
|
|
|
|
ref="transactionListRef"
|
2025-12-30 17:02:30 +08:00
|
|
|
|
:transactions="categoryBills"
|
|
|
|
|
|
:loading="billListLoading"
|
|
|
|
|
|
:finished="billListFinished"
|
2025-12-31 11:49:25 +08:00
|
|
|
|
:show-delete="true"
|
2025-12-30 17:02:30 +08:00
|
|
|
|
@load="loadCategoryBills"
|
|
|
|
|
|
@click="viewBillDetail"
|
2026-01-01 11:58:21 +08:00
|
|
|
|
@delete="handleCategoryBillsDelete"
|
2025-12-30 17:02:30 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</PopupContainer>
|
2025-12-26 17:56:08 +08:00
|
|
|
|
|
|
|
|
|
|
<!-- 交易详情编辑组件 -->
|
|
|
|
|
|
<TransactionDetail
|
|
|
|
|
|
v-model:show="detailVisible"
|
|
|
|
|
|
:transaction="currentTransaction"
|
|
|
|
|
|
@save="onBillSave"
|
|
|
|
|
|
/>
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
import { ref, computed, onMounted, onActivated, nextTick, watch } from 'vue'
|
2026-01-01 11:58:21 +08:00
|
|
|
|
import { onBeforeUnmount } from 'vue'
|
2025-12-26 17:13:57 +08:00
|
|
|
|
import { showToast } from 'vant'
|
|
|
|
|
|
import { useRouter } from 'vue-router'
|
2026-01-15 22:10:57 +08:00
|
|
|
|
import { getMonthlyStatistics, getCategoryStatistics, getDailyStatistics } from '@/api/statistics'
|
|
|
|
|
|
import * as echarts from 'echarts'
|
2025-12-26 17:56:08 +08:00
|
|
|
|
import { getTransactionList, getTransactionDetail } from '@/api/transactionRecord'
|
|
|
|
|
|
import TransactionList from '@/components/TransactionList.vue'
|
|
|
|
|
|
import TransactionDetail from '@/components/TransactionDetail.vue'
|
2025-12-29 21:17:18 +08:00
|
|
|
|
import SmartClassifyButton from '@/components/SmartClassifyButton.vue'
|
2025-12-30 17:02:30 +08:00
|
|
|
|
import PopupContainer from '@/components/PopupContainer.vue'
|
2026-01-16 15:56:53 +08:00
|
|
|
|
import { getCssVar } from '@/utils/theme'
|
2025-12-26 17:13:57 +08:00
|
|
|
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
|
|
|
|
|
|
|
|
// 响应式数据
|
|
|
|
|
|
const loading = ref(true)
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const firstLoading = ref(true)
|
2025-12-26 17:13:57 +08:00
|
|
|
|
const refreshing = ref(false)
|
|
|
|
|
|
const showMonthPicker = ref(false)
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const showAllExpense = ref(false)
|
2025-12-26 17:13:57 +08:00
|
|
|
|
const currentYear = ref(new Date().getFullYear())
|
|
|
|
|
|
const currentMonth = ref(new Date().getMonth() + 1)
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const selectedDate = ref([
|
|
|
|
|
|
new Date().getFullYear().toString(),
|
|
|
|
|
|
(new Date().getMonth() + 1).toString().padStart(2, '0')
|
|
|
|
|
|
])
|
2025-12-26 17:13:57 +08:00
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
const billListVisible = ref(false)
|
|
|
|
|
|
const billListLoading = ref(false)
|
|
|
|
|
|
const billListFinished = ref(false)
|
|
|
|
|
|
const categoryBills = ref([])
|
2025-12-27 22:05:50 +08:00
|
|
|
|
const categoryBillsTotal = ref(0)
|
2025-12-26 17:56:08 +08:00
|
|
|
|
const selectedCategoryTitle = ref('')
|
|
|
|
|
|
const selectedClassify = ref('')
|
|
|
|
|
|
const selectedType = ref(null)
|
2025-12-27 22:05:50 +08:00
|
|
|
|
const billPageIndex = ref(1)
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const billPageSize = 20
|
2025-12-26 17:56:08 +08:00
|
|
|
|
|
|
|
|
|
|
// 详情编辑相关
|
|
|
|
|
|
const detailVisible = ref(false)
|
|
|
|
|
|
const currentTransaction = ref(null)
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
// 月度数据
|
|
|
|
|
|
const monthlyData = ref({
|
|
|
|
|
|
totalExpense: 0,
|
|
|
|
|
|
totalIncome: 0,
|
|
|
|
|
|
balance: 0,
|
|
|
|
|
|
expenseCount: 0,
|
|
|
|
|
|
incomeCount: 0,
|
2026-01-16 15:56:53 +08:00
|
|
|
|
totalCount: 0
|
2025-12-26 17:13:57 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// 分类数据
|
|
|
|
|
|
const expenseCategories = ref([])
|
|
|
|
|
|
const incomeCategories = ref([])
|
2025-12-27 22:34:19 +08:00
|
|
|
|
const noneCategories = ref([])
|
2025-12-26 17:13:57 +08:00
|
|
|
|
|
2026-01-12 14:46:11 +08:00
|
|
|
|
const expenseCategoriesSimpView = computed(() => {
|
|
|
|
|
|
const list = expenseCategoriesView.value
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-16 12:08:11 +08:00
|
|
|
|
if (showAllExpense.value) {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
return list
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 12:08:11 +08:00
|
|
|
|
// 只展示未分类
|
|
|
|
|
|
const unclassified = list.filter((c) => c.classify === '未分类' || !c.classify)
|
|
|
|
|
|
if (unclassified.length > 0) {
|
|
|
|
|
|
return [...unclassified]
|
|
|
|
|
|
}
|
|
|
|
|
|
return []
|
2026-01-04 18:24:39 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-12 14:46:11 +08:00
|
|
|
|
const expenseCategoriesView = computed(() => {
|
|
|
|
|
|
const list = [...expenseCategories.value]
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const unclassifiedIndex = list.findIndex((c) => !c.classify)
|
2026-01-12 14:46:11 +08:00
|
|
|
|
if (unclassifiedIndex !== -1) {
|
|
|
|
|
|
const [unclassified] = list.splice(unclassifiedIndex, 1)
|
|
|
|
|
|
list.unshift(unclassified)
|
|
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-12 14:46:11 +08:00
|
|
|
|
return list
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-04 18:24:39 +08:00
|
|
|
|
const incomeCategoriesView = computed(() => {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const list = [...incomeCategories.value]
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const unclassifiedIndex = list.findIndex((c) => !c.classify)
|
2026-01-04 18:24:39 +08:00
|
|
|
|
if (unclassifiedIndex !== -1) {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const [unclassified] = list.splice(unclassifiedIndex, 1)
|
|
|
|
|
|
list.unshift(unclassified)
|
2026-01-04 18:24:39 +08:00
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-16 12:08:11 +08:00
|
|
|
|
return list
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-04 18:24:39 +08:00
|
|
|
|
const noneCategoriesView = computed(() => {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const list = [...noneCategories.value]
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const unclassifiedIndex = list.findIndex((c) => !c.classify)
|
2026-01-04 18:24:39 +08:00
|
|
|
|
if (unclassifiedIndex !== -1) {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const [unclassified] = list.splice(unclassifiedIndex, 1)
|
|
|
|
|
|
list.unshift(unclassified)
|
2026-01-04 18:24:39 +08:00
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-16 12:08:11 +08:00
|
|
|
|
return list
|
2026-01-04 18:24:39 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
// 趋势数据
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const dailyData = ref([])
|
|
|
|
|
|
const chartRef = ref(null)
|
|
|
|
|
|
const pieChartRef = ref(null)
|
|
|
|
|
|
let chartInstance = null
|
|
|
|
|
|
let pieChartInstance = null
|
2025-12-26 17:13:57 +08:00
|
|
|
|
|
|
|
|
|
|
// 日期范围
|
|
|
|
|
|
const minDate = new Date(2020, 0, 1)
|
|
|
|
|
|
const maxDate = new Date()
|
|
|
|
|
|
|
|
|
|
|
|
// 颜色配置
|
2026-01-16 15:56:53 +08:00
|
|
|
|
const getChartColors = () => [
|
|
|
|
|
|
getCssVar('--chart-color-1'),
|
|
|
|
|
|
getCssVar('--chart-color-2'),
|
|
|
|
|
|
getCssVar('--chart-color-3'),
|
|
|
|
|
|
getCssVar('--chart-color-4'),
|
|
|
|
|
|
getCssVar('--chart-color-5'),
|
|
|
|
|
|
getCssVar('--chart-color-6'),
|
|
|
|
|
|
getCssVar('--chart-color-7'),
|
|
|
|
|
|
getCssVar('--chart-color-8'),
|
|
|
|
|
|
getCssVar('--chart-color-9'),
|
|
|
|
|
|
getCssVar('--chart-color-10'),
|
|
|
|
|
|
getCssVar('--chart-color-11'),
|
|
|
|
|
|
getCssVar('--chart-color-12'),
|
|
|
|
|
|
getCssVar('--chart-color-13'),
|
|
|
|
|
|
getCssVar('--chart-color-14'),
|
|
|
|
|
|
getCssVar('--chart-color-15')
|
2025-12-26 17:13:57 +08:00
|
|
|
|
]
|
|
|
|
|
|
|
2025-12-29 21:17:18 +08:00
|
|
|
|
// 是否为未分类账单
|
|
|
|
|
|
const isUnclassified = computed(() => {
|
|
|
|
|
|
return selectedClassify.value === '未分类' || selectedClassify.value === ''
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
// 格式化金额
|
|
|
|
|
|
const formatMoney = (value) => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
if (!value && value !== 0) {
|
|
|
|
|
|
return '0'
|
|
|
|
|
|
}
|
|
|
|
|
|
return Number(value)
|
|
|
|
|
|
.toFixed(0)
|
|
|
|
|
|
.replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 15:56:53 +08:00
|
|
|
|
// 下拉刷新
|
|
|
|
|
|
const onRefresh = async () => {
|
|
|
|
|
|
await fetchStatistics(false)
|
|
|
|
|
|
refreshing.value = false
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 确认月份选择
|
|
|
|
|
|
const onMonthConfirm = ({ selectedValues }) => {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const newYear = parseInt(selectedValues[0])
|
|
|
|
|
|
const newMonth = parseInt(selectedValues[1])
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-11 16:33:55 +08:00
|
|
|
|
currentYear.value = newYear
|
|
|
|
|
|
currentMonth.value = newMonth
|
2025-12-26 17:13:57 +08:00
|
|
|
|
showMonthPicker.value = false
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-11 16:33:55 +08:00
|
|
|
|
// 重置展开状态
|
|
|
|
|
|
showAllExpense.value = false
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
fetchStatistics()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取统计数据
|
2026-01-11 16:33:55 +08:00
|
|
|
|
const fetchStatistics = async (showLoading = true) => {
|
|
|
|
|
|
if (showLoading && firstLoading.value) {
|
|
|
|
|
|
loading.value = true
|
|
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
try {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
await Promise.all([fetchMonthlyData(), fetchCategoryData(), fetchDailyData()])
|
2025-12-26 17:13:57 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取统计数据失败:', error)
|
|
|
|
|
|
showToast('获取统计数据失败')
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false
|
2026-01-11 16:33:55 +08:00
|
|
|
|
firstLoading.value = false
|
2026-01-15 22:10:57 +08:00
|
|
|
|
// DOM 更新后渲染图表
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
renderChart(dailyData.value)
|
|
|
|
|
|
renderPieChart()
|
|
|
|
|
|
})
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取月度数据
|
|
|
|
|
|
const fetchMonthlyData = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await getMonthlyStatistics({
|
|
|
|
|
|
year: currentYear.value,
|
|
|
|
|
|
month: currentMonth.value
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (response.success && response.data) {
|
|
|
|
|
|
monthlyData.value = response.data
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取月度数据失败:', error)
|
|
|
|
|
|
showToast('获取月度数据失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取分类数据
|
|
|
|
|
|
const fetchCategoryData = async () => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// 获取支出分类
|
|
|
|
|
|
const expenseResponse = await getCategoryStatistics({
|
|
|
|
|
|
year: currentYear.value,
|
|
|
|
|
|
month: currentMonth.value,
|
|
|
|
|
|
type: 0 // 支出
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (expenseResponse.success && expenseResponse.data) {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
const currentColors = getChartColors()
|
2025-12-26 17:13:57 +08:00
|
|
|
|
expenseCategories.value = expenseResponse.data.map((item, index) => ({
|
|
|
|
|
|
classify: item.classify,
|
|
|
|
|
|
amount: item.amount,
|
2025-12-26 17:56:08 +08:00
|
|
|
|
count: item.count,
|
2025-12-26 17:13:57 +08:00
|
|
|
|
percent: item.percent,
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: currentColors[index % currentColors.length]
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 获取收入分类
|
|
|
|
|
|
const incomeResponse = await getCategoryStatistics({
|
|
|
|
|
|
year: currentYear.value,
|
|
|
|
|
|
month: currentMonth.value,
|
|
|
|
|
|
type: 1 // 收入
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (incomeResponse.success && incomeResponse.data) {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
incomeCategories.value = incomeResponse.data.map((item) => ({
|
2025-12-26 17:13:57 +08:00
|
|
|
|
classify: item.classify,
|
|
|
|
|
|
amount: item.amount,
|
2025-12-26 17:56:08 +08:00
|
|
|
|
count: item.count,
|
2025-12-26 17:13:57 +08:00
|
|
|
|
percent: item.percent
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
2025-12-27 22:34:19 +08:00
|
|
|
|
|
|
|
|
|
|
// 获取不计收支分类
|
|
|
|
|
|
const noneResponse = await getCategoryStatistics({
|
|
|
|
|
|
year: currentYear.value,
|
|
|
|
|
|
month: currentMonth.value,
|
|
|
|
|
|
type: 2 // 不计收支
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
if (noneResponse.success && noneResponse.data) {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
noneCategories.value = noneResponse.data.map((item) => ({
|
2025-12-27 22:34:19 +08:00
|
|
|
|
classify: item.classify,
|
|
|
|
|
|
amount: item.amount,
|
|
|
|
|
|
count: item.count,
|
|
|
|
|
|
percent: item.percent
|
|
|
|
|
|
}))
|
|
|
|
|
|
}
|
2025-12-26 17:13:57 +08:00
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取分类数据失败:', error)
|
|
|
|
|
|
showToast('获取分类数据失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
// 获取每日统计数据并渲染图表
|
|
|
|
|
|
const fetchDailyData = async () => {
|
2025-12-26 17:13:57 +08:00
|
|
|
|
try {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const response = await getDailyStatistics({
|
|
|
|
|
|
year: currentYear.value,
|
|
|
|
|
|
month: currentMonth.value
|
2025-12-26 17:13:57 +08:00
|
|
|
|
})
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
if (response.success && response.data) {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
dailyData.value = response.data
|
|
|
|
|
|
// 如果不是首次加载(即DOM已存在),直接渲染
|
|
|
|
|
|
if (!firstLoading.value) {
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
renderChart(response.data)
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
console.error('获取每日统计数据失败:', error)
|
|
|
|
|
|
showToast('获取每日统计数据失败')
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const renderChart = (data) => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
if (!chartRef.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 尝试获取DOM上的现有实例
|
|
|
|
|
|
const existingInstance = echarts.getInstanceByDom(chartRef.value)
|
|
|
|
|
|
|
|
|
|
|
|
// 如果当前保存的实例与DOM不一致,或者DOM上已经有实例但我们没保存引用
|
|
|
|
|
|
if (chartInstance && chartInstance !== existingInstance) {
|
|
|
|
|
|
// 这种情况很少见,但为了保险,销毁旧的引用
|
|
|
|
|
|
if (!chartInstance.isDisposed()) {
|
|
|
|
|
|
chartInstance.dispose()
|
|
|
|
|
|
}
|
|
|
|
|
|
chartInstance = null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果DOM变了(transition导致的),旧的chartInstance绑定的DOM已经不在了
|
|
|
|
|
|
// 这时 chartInstance.getDom() !== chartRef.value
|
|
|
|
|
|
if (chartInstance && chartInstance.getDom() !== chartRef.value) {
|
|
|
|
|
|
chartInstance.dispose()
|
|
|
|
|
|
chartInstance = null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 如果DOM上已经有实例(可能由其他途径创建),复用它
|
|
|
|
|
|
if (!chartInstance && existingInstance) {
|
|
|
|
|
|
chartInstance = existingInstance
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
if (!chartInstance) {
|
|
|
|
|
|
chartInstance = echarts.init(chartRef.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 补全当月所有日期
|
|
|
|
|
|
const now = new Date()
|
|
|
|
|
|
let daysInMonth
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
if (currentYear.value === now.getFullYear() && currentMonth.value === now.getMonth() + 1) {
|
|
|
|
|
|
// 如果是当前月,只显示到今天
|
|
|
|
|
|
daysInMonth = now.getDate()
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 如果是过去月,显示整月
|
|
|
|
|
|
daysInMonth = new Date(currentYear.value, currentMonth.value, 0).getDate()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const fullData = []
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
// 创建日期映射
|
|
|
|
|
|
const dataMap = new Map()
|
2026-01-16 11:15:44 +08:00
|
|
|
|
data.forEach((item) => {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const day = new Date(item.date).getDate()
|
|
|
|
|
|
dataMap.set(day, item)
|
|
|
|
|
|
})
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
for (let i = 1; i <= daysInMonth; i++) {
|
|
|
|
|
|
const item = dataMap.get(i)
|
|
|
|
|
|
if (item) {
|
|
|
|
|
|
fullData.push(item)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
fullData.push({
|
|
|
|
|
|
date: `${currentYear.value}-${String(currentMonth.value).padStart(2, '0')}-${String(i).padStart(2, '0')}`,
|
|
|
|
|
|
count: 0,
|
|
|
|
|
|
expense: 0,
|
|
|
|
|
|
income: 0,
|
|
|
|
|
|
balance: 0
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
|
|
|
|
|
const dates = fullData.map((item) => {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const date = new Date(item.date)
|
|
|
|
|
|
return `${date.getDate()}日`
|
|
|
|
|
|
})
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
// Calculate cumulative values
|
|
|
|
|
|
let accumulatedExpense = 0
|
|
|
|
|
|
let accumulatedIncome = 0
|
|
|
|
|
|
let accumulatedBalance = 0
|
|
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const expenses = fullData.map((item) => {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
accumulatedExpense += item.expense
|
|
|
|
|
|
return accumulatedExpense
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const incomes = fullData.map((item) => {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
accumulatedIncome += item.income
|
|
|
|
|
|
return accumulatedIncome
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const balances = fullData.map((item) => {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
accumulatedBalance += item.balance
|
|
|
|
|
|
return accumulatedBalance
|
|
|
|
|
|
})
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const option = {
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'axis',
|
|
|
|
|
|
formatter: function (params) {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
let result = params[0].name + '<br/>'
|
|
|
|
|
|
params.forEach((param) => {
|
|
|
|
|
|
result += param.marker + param.seriesName + ': ' + formatMoney(param.value) + '<br/>'
|
|
|
|
|
|
})
|
|
|
|
|
|
return result
|
2026-01-15 22:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
legend: {
|
|
|
|
|
|
data: ['支出', '收入', '存款'],
|
|
|
|
|
|
bottom: 0,
|
|
|
|
|
|
textStyle: {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--chart-text-muted') // 适配深色模式
|
2026-01-15 22:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
grid: {
|
|
|
|
|
|
left: '3%',
|
|
|
|
|
|
right: '4%',
|
2026-01-16 11:15:44 +08:00
|
|
|
|
bottom: '15%',
|
|
|
|
|
|
top: '5%',
|
2026-01-15 22:10:57 +08:00
|
|
|
|
containLabel: true
|
|
|
|
|
|
},
|
|
|
|
|
|
xAxis: {
|
|
|
|
|
|
type: 'category',
|
|
|
|
|
|
boundaryGap: false,
|
|
|
|
|
|
data: dates,
|
|
|
|
|
|
axisLabel: {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--chart-text-muted') // 适配深色模式
|
2026-01-15 22:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
yAxis: {
|
|
|
|
|
|
type: 'value',
|
2026-01-16 11:15:44 +08:00
|
|
|
|
splitNumber: 5,
|
2026-01-15 22:10:57 +08:00
|
|
|
|
axisLabel: {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--chart-text-muted'), // 适配深色模式
|
2026-01-15 22:10:57 +08:00
|
|
|
|
formatter: (value) => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
return value / 1000 + 'k'
|
2026-01-15 22:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
splitLine: {
|
|
|
|
|
|
lineStyle: {
|
|
|
|
|
|
type: 'dashed',
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--van-border-color') // 深色分割线
|
2026-01-15 22:10:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
series: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '支出',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: expenses,
|
2026-01-16 15:56:53 +08:00
|
|
|
|
itemStyle: { color: getCssVar('--chart-color-1') },
|
2026-01-15 22:10:57 +08:00
|
|
|
|
showSymbol: false,
|
|
|
|
|
|
smooth: true,
|
|
|
|
|
|
lineStyle: { width: 2 }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '收入',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: incomes,
|
2026-01-16 15:56:53 +08:00
|
|
|
|
itemStyle: { color: getCssVar('--chart-color-2') },
|
2026-01-15 22:10:57 +08:00
|
|
|
|
showSymbol: false,
|
|
|
|
|
|
smooth: true,
|
|
|
|
|
|
lineStyle: { width: 2 }
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '存款',
|
|
|
|
|
|
type: 'line',
|
|
|
|
|
|
data: balances,
|
2026-01-16 15:56:53 +08:00
|
|
|
|
itemStyle: { color: getCssVar('--chart-color-13') },
|
2026-01-15 22:10:57 +08:00
|
|
|
|
showSymbol: false,
|
|
|
|
|
|
smooth: true,
|
|
|
|
|
|
lineStyle: { width: 2 }
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
chartInstance.setOption(option)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const renderPieChart = () => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
if (!pieChartRef.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
if (expenseCategoriesView.value.length === 0) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 尝试获取DOM上的现有实例
|
|
|
|
|
|
const existingInstance = echarts.getInstanceByDom(pieChartRef.value)
|
|
|
|
|
|
|
|
|
|
|
|
if (pieChartInstance && pieChartInstance !== existingInstance) {
|
|
|
|
|
|
if (!pieChartInstance.isDisposed()) {
|
|
|
|
|
|
pieChartInstance.dispose()
|
|
|
|
|
|
}
|
|
|
|
|
|
pieChartInstance = null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (pieChartInstance && pieChartInstance.getDom() !== pieChartRef.value) {
|
|
|
|
|
|
pieChartInstance.dispose()
|
|
|
|
|
|
pieChartInstance = null
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!pieChartInstance && existingInstance) {
|
|
|
|
|
|
pieChartInstance = existingInstance
|
|
|
|
|
|
}
|
2026-01-15 22:10:57 +08:00
|
|
|
|
|
|
|
|
|
|
if (!pieChartInstance) {
|
|
|
|
|
|
pieChartInstance = echarts.init(pieChartRef.value)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 使用 Top N + Other 的数据逻辑,确保图表不会太拥挤
|
|
|
|
|
|
const list = [...expenseCategoriesView.value]
|
|
|
|
|
|
let chartData = []
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
// 按照金额排序
|
|
|
|
|
|
list.sort((a, b) => b.amount - a.amount)
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-16 15:56:53 +08:00
|
|
|
|
const MAX_SLICES = 8 // 最大显示扇区数,其余合并为"其他"
|
|
|
|
|
|
const currentColors = getChartColors()
|
|
|
|
|
|
|
|
|
|
|
|
if (list.length > MAX_SLICES) {
|
|
|
|
|
|
const topList = list.slice(0, MAX_SLICES - 1)
|
|
|
|
|
|
const otherList = list.slice(MAX_SLICES - 1)
|
|
|
|
|
|
const otherAmount = otherList.reduce((sum, item) => sum + item.amount, 0)
|
|
|
|
|
|
|
|
|
|
|
|
chartData = topList.map((item, index) => ({
|
|
|
|
|
|
value: item.amount,
|
|
|
|
|
|
name: item.classify || '未分类',
|
|
|
|
|
|
itemStyle: { color: currentColors[index % currentColors.length] }
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
|
|
|
|
chartData.push({
|
|
|
|
|
|
value: otherAmount,
|
|
|
|
|
|
name: '其他',
|
|
|
|
|
|
itemStyle: { color: getCssVar('--van-gray-6') } // 使用灰色表示其他
|
|
|
|
|
|
})
|
|
|
|
|
|
} else {
|
2026-01-15 22:10:57 +08:00
|
|
|
|
chartData = list.map((item, index) => ({
|
|
|
|
|
|
value: item.amount,
|
|
|
|
|
|
name: item.classify || '未分类',
|
2026-01-16 15:56:53 +08:00
|
|
|
|
itemStyle: { color: currentColors[index % currentColors.length] }
|
2026-01-15 22:10:57 +08:00
|
|
|
|
}))
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const option = {
|
|
|
|
|
|
title: {
|
|
|
|
|
|
text: '¥' + formatMoney(monthlyData.value.totalExpense),
|
|
|
|
|
|
subtext: '总支出',
|
|
|
|
|
|
left: 'center',
|
|
|
|
|
|
top: 'center',
|
|
|
|
|
|
textStyle: {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--chart-text-muted'), // 适配深色模式
|
2026-01-15 22:10:57 +08:00
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
fontWeight: 'bold'
|
|
|
|
|
|
},
|
|
|
|
|
|
subtextStyle: {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--chart-text-muted'),
|
2026-01-15 22:10:57 +08:00
|
|
|
|
fontSize: 13
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'item',
|
|
|
|
|
|
formatter: '{b}: {c} ({d}%)'
|
|
|
|
|
|
},
|
|
|
|
|
|
series: [
|
|
|
|
|
|
{
|
|
|
|
|
|
name: '支出分类',
|
|
|
|
|
|
type: 'pie',
|
|
|
|
|
|
radius: ['50%', '80%'],
|
|
|
|
|
|
avoidLabelOverlap: true,
|
|
|
|
|
|
minAngle: 5, // 最小扇区角度,防止扇区太小看不见
|
|
|
|
|
|
itemStyle: {
|
|
|
|
|
|
borderRadius: 5,
|
2026-01-16 15:56:53 +08:00
|
|
|
|
borderColor: getCssVar('--van-background-2'),
|
2026-01-15 22:10:57 +08:00
|
|
|
|
borderWidth: 2
|
|
|
|
|
|
},
|
|
|
|
|
|
label: {
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
position: 'outside',
|
|
|
|
|
|
formatter: '{b}',
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--van-text-color-2') // 适配深色模式
|
|
|
|
|
|
},
|
|
|
|
|
|
labelLayout: {
|
|
|
|
|
|
hideOverlap: true // 隐藏重叠标签
|
2026-01-15 22:10:57 +08:00
|
|
|
|
},
|
|
|
|
|
|
labelLine: {
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
lineStyle: {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: getCssVar('--van-text-color-3')
|
|
|
|
|
|
},
|
|
|
|
|
|
smooth: 0.2,
|
|
|
|
|
|
length: 10,
|
|
|
|
|
|
length2: 20
|
2026-01-15 22:10:57 +08:00
|
|
|
|
},
|
|
|
|
|
|
data: chartData
|
|
|
|
|
|
}
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pieChartInstance.setOption(option)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
// 跳转到智能分析页面
|
|
|
|
|
|
const goToAnalysis = () => {
|
|
|
|
|
|
router.push('/bill-analysis')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
// 打开分类账单列表
|
|
|
|
|
|
const goToCategoryBills = (classify, type) => {
|
2025-12-27 22:45:23 +08:00
|
|
|
|
selectedClassify.value = classify || '未分类' // TODO 如果是未分类的 添加智能分类按钮
|
2025-12-26 17:56:08 +08:00
|
|
|
|
selectedType.value = type
|
|
|
|
|
|
selectedCategoryTitle.value = `${classify || '未分类'} - ${type === 0 ? '支出' : '收入'}`
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
// 重置分页状态
|
|
|
|
|
|
categoryBills.value = []
|
2025-12-27 22:05:50 +08:00
|
|
|
|
categoryBillsTotal.value = 0
|
|
|
|
|
|
billPageIndex.value = 1
|
2025-12-26 17:56:08 +08:00
|
|
|
|
billListFinished.value = false
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
billListVisible.value = true
|
2025-12-27 22:05:50 +08:00
|
|
|
|
// 打开弹窗后加载数据
|
|
|
|
|
|
loadCategoryBills()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-29 21:17:18 +08:00
|
|
|
|
const smartClassifyButtonRef = ref(null)
|
2026-01-10 12:22:37 +08:00
|
|
|
|
const transactionListRef = ref(null)
|
2025-12-26 17:56:08 +08:00
|
|
|
|
// 加载分类账单数据
|
2025-12-29 21:17:18 +08:00
|
|
|
|
const loadCategoryBills = async (customIndex = null, customSize = null) => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
if (billListLoading.value || billListFinished.value) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
billListLoading.value = true
|
|
|
|
|
|
try {
|
|
|
|
|
|
const params = {
|
2025-12-29 21:17:18 +08:00
|
|
|
|
pageIndex: customIndex || billPageIndex.value,
|
|
|
|
|
|
pageSize: customSize || billPageSize,
|
2025-12-26 17:56:08 +08:00
|
|
|
|
type: selectedType.value,
|
|
|
|
|
|
year: currentYear.value,
|
2025-12-27 22:05:50 +08:00
|
|
|
|
month: currentMonth.value,
|
|
|
|
|
|
sortByAmount: true
|
2025-12-26 17:56:08 +08:00
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-27 22:05:50 +08:00
|
|
|
|
// 仅当选择了分类时才添加classify参数
|
|
|
|
|
|
if (selectedClassify.value !== null) {
|
|
|
|
|
|
params.classify = selectedClassify.value
|
2025-12-26 17:56:08 +08:00
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
const response = await getTransactionList(params)
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
if (response.success) {
|
|
|
|
|
|
const newList = response.data || []
|
|
|
|
|
|
categoryBills.value = [...categoryBills.value, ...newList]
|
2025-12-27 22:05:50 +08:00
|
|
|
|
categoryBillsTotal.value = response.total
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-27 22:05:50 +08:00
|
|
|
|
if (newList.length === 0 || newList.length < billPageSize) {
|
2025-12-26 17:56:08 +08:00
|
|
|
|
billListFinished.value = true
|
2025-12-27 22:05:50 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
billListFinished.value = false
|
|
|
|
|
|
billPageIndex.value++
|
2025-12-26 17:56:08 +08:00
|
|
|
|
}
|
2025-12-29 21:17:18 +08:00
|
|
|
|
|
2025-12-30 18:49:46 +08:00
|
|
|
|
smartClassifyButtonRef.value?.reset()
|
2025-12-26 17:56:08 +08:00
|
|
|
|
} else {
|
|
|
|
|
|
showToast(response.message || '加载账单失败')
|
|
|
|
|
|
billListFinished.value = true
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('加载分类账单失败:', error)
|
|
|
|
|
|
showToast('加载账单失败')
|
|
|
|
|
|
billListFinished.value = true
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
billListLoading.value = false
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 查看账单详情
|
|
|
|
|
|
const viewBillDetail = async (transaction) => {
|
|
|
|
|
|
try {
|
|
|
|
|
|
const response = await getTransactionDetail(transaction.id)
|
|
|
|
|
|
if (response.success) {
|
|
|
|
|
|
currentTransaction.value = response.data
|
|
|
|
|
|
detailVisible.value = true
|
|
|
|
|
|
} else {
|
|
|
|
|
|
showToast(response.message || '获取详情失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error('获取详情出错:', error)
|
|
|
|
|
|
showToast('获取详情失败')
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-01 11:58:21 +08:00
|
|
|
|
const handleCategoryBillsDelete = (deletedId) => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
categoryBills.value = categoryBills.value.filter((t) => t.id !== deletedId)
|
2026-01-01 11:58:21 +08:00
|
|
|
|
categoryBillsTotal.value--
|
|
|
|
|
|
|
|
|
|
|
|
// 被删除后刷新统计数据和账单列表
|
|
|
|
|
|
fetchStatistics()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
// 账单保存后的回调
|
2026-01-10 12:22:37 +08:00
|
|
|
|
const onBillSave = async (updatedTransaction) => {
|
2025-12-26 17:56:08 +08:00
|
|
|
|
// 刷新统计数据
|
|
|
|
|
|
await fetchStatistics()
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-10 12:22:37 +08:00
|
|
|
|
// 只刷新列表中指定的账单项
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const item = categoryBills.value.find((t) => t.id === updatedTransaction.id)
|
|
|
|
|
|
if (!item) {
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-01-10 12:22:37 +08:00
|
|
|
|
|
|
|
|
|
|
// 如果分类发生了变化
|
2026-01-16 11:15:44 +08:00
|
|
|
|
if (item.classify !== updatedTransaction.classify) {
|
2026-01-10 12:22:37 +08:00
|
|
|
|
// 从列表中移除该项
|
2026-01-16 11:15:44 +08:00
|
|
|
|
categoryBills.value = categoryBills.value.filter((t) => t.id !== updatedTransaction.id)
|
2026-01-10 12:22:37 +08:00
|
|
|
|
categoryBillsTotal.value--
|
|
|
|
|
|
// 通知智能分类按钮组件移除指定项
|
|
|
|
|
|
smartClassifyButtonRef.value?.removeClassifiedTransaction(updatedTransaction.id)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Object.assign(item, updatedTransaction)
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
showToast('保存成功')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-29 21:17:18 +08:00
|
|
|
|
const beforeSmartClassify = async () => {
|
|
|
|
|
|
showToast({
|
|
|
|
|
|
message: '加载完整账单列表,请稍候...',
|
|
|
|
|
|
duration: 0,
|
|
|
|
|
|
forbidClick: true
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
await loadCategoryBills(1, categoryBillsTotal.value || 1000)
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 智能分类保存后的回调
|
|
|
|
|
|
const onSmartClassifySave = async () => {
|
|
|
|
|
|
// 关闭账单列表弹窗
|
|
|
|
|
|
billListVisible.value = false
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-29 21:17:18 +08:00
|
|
|
|
// 刷新统计数据
|
|
|
|
|
|
await fetchStatistics()
|
2026-01-16 11:15:44 +08:00
|
|
|
|
try {
|
|
|
|
|
|
window.dispatchEvent(
|
|
|
|
|
|
new CustomEvent('transactions-changed', {
|
|
|
|
|
|
detail: { reason: selectedClassify.value, type: selectedType.value }
|
|
|
|
|
|
})
|
|
|
|
|
|
)
|
|
|
|
|
|
} catch (e) {
|
2026-01-03 11:26:50 +08:00
|
|
|
|
console.error('触发 transactions-changed 事件失败:', e)
|
|
|
|
|
|
}
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2025-12-29 21:17:18 +08:00
|
|
|
|
showToast('智能分类已保存')
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-30 18:49:46 +08:00
|
|
|
|
const handleNotifiedTransactionId = async (transactionId) => {
|
2026-01-16 15:56:53 +08:00
|
|
|
|
console.info('收到已处理交易ID通知:', transactionId)
|
2025-12-30 18:49:46 +08:00
|
|
|
|
// 滚动到指定的交易项
|
2026-01-16 11:15:44 +08:00
|
|
|
|
const index = categoryBills.value.findIndex((item) => String(item.id) === String(transactionId))
|
2025-12-30 18:49:46 +08:00
|
|
|
|
if (index !== -1) {
|
|
|
|
|
|
// 等待 DOM 更新
|
|
|
|
|
|
await nextTick()
|
2026-01-16 11:15:44 +08:00
|
|
|
|
|
2026-01-10 12:22:37 +08:00
|
|
|
|
// 允许一丁点延迟让浏览器响应渲染
|
2026-01-16 11:15:44 +08:00
|
|
|
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
|
|
|
|
|
2026-01-10 12:22:37 +08:00
|
|
|
|
const listElement = transactionListRef.value?.$el
|
2025-12-30 18:49:46 +08:00
|
|
|
|
if (listElement) {
|
|
|
|
|
|
const items = listElement.querySelectorAll('.transaction-item')
|
|
|
|
|
|
const itemElement = items[index]
|
|
|
|
|
|
if (itemElement) {
|
|
|
|
|
|
itemElement.scrollIntoView({ behavior: 'smooth', block: 'center' })
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
// 初始化
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
fetchStatistics()
|
2026-01-15 22:10:57 +08:00
|
|
|
|
window.addEventListener('resize', handleResize)
|
2025-12-26 17:13:57 +08:00
|
|
|
|
})
|
2025-12-26 17:56:08 +08:00
|
|
|
|
|
2026-01-15 22:10:57 +08:00
|
|
|
|
const handleResize = () => {
|
|
|
|
|
|
chartInstance && chartInstance.resize()
|
|
|
|
|
|
pieChartInstance && pieChartInstance.resize()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
// 监听DOM引用变化,确保在月份切换DOM重建后重新渲染图表
|
|
|
|
|
|
watch(chartRef, (newVal) => {
|
|
|
|
|
|
// 无论有没有数据,只要DOM变了,就尝试渲染
|
|
|
|
|
|
// 如果没有数据,renderChart 内部也应该处理(或者我们可以传空数据)
|
|
|
|
|
|
if (newVal) {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
// 传入当前 dailyData,即使是空的,renderChart 应该能处理
|
|
|
|
|
|
renderChart(dailyData.value || [])
|
|
|
|
|
|
chartInstance && chartInstance.resize()
|
|
|
|
|
|
}, 50)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
watch(pieChartRef, (newVal) => {
|
|
|
|
|
|
if (newVal) {
|
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|
renderPieChart()
|
|
|
|
|
|
pieChartInstance && pieChartInstance.resize()
|
|
|
|
|
|
}, 50)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
// 页面激活时刷新数据(从其他页面返回时)
|
|
|
|
|
|
onActivated(() => {
|
|
|
|
|
|
fetchStatistics()
|
|
|
|
|
|
})
|
2026-01-01 11:58:21 +08:00
|
|
|
|
|
|
|
|
|
|
// 全局监听交易删除事件,确保统计数据一致
|
2026-01-03 11:26:50 +08:00
|
|
|
|
const onGlobalTransactionDeleted = () => {
|
2026-01-01 11:58:21 +08:00
|
|
|
|
// e.detail contains transaction id
|
|
|
|
|
|
fetchStatistics()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
window.addEventListener &&
|
|
|
|
|
|
window.addEventListener('transaction-deleted', onGlobalTransactionDeleted)
|
2026-01-01 11:58:21 +08:00
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
window.removeEventListener &&
|
|
|
|
|
|
window.removeEventListener('transaction-deleted', onGlobalTransactionDeleted)
|
2026-01-15 22:10:57 +08:00
|
|
|
|
window.removeEventListener('resize', handleResize)
|
|
|
|
|
|
chartInstance && chartInstance.dispose()
|
|
|
|
|
|
pieChartInstance && pieChartInstance.dispose()
|
2026-01-01 11:58:21 +08:00
|
|
|
|
})
|
|
|
|
|
|
|
2026-01-03 11:26:50 +08:00
|
|
|
|
const onGlobalTransactionsChanged = () => {
|
2026-01-01 11:58:21 +08:00
|
|
|
|
fetchStatistics()
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 11:15:44 +08:00
|
|
|
|
window.addEventListener &&
|
|
|
|
|
|
window.addEventListener('transactions-changed', onGlobalTransactionsChanged)
|
2026-01-01 11:58:21 +08:00
|
|
|
|
|
|
|
|
|
|
onBeforeUnmount(() => {
|
2026-01-16 11:15:44 +08:00
|
|
|
|
window.removeEventListener &&
|
|
|
|
|
|
window.removeEventListener('transactions-changed', onGlobalTransactionsChanged)
|
2026-01-01 11:58:21 +08:00
|
|
|
|
})
|
2025-12-26 17:13:57 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
2026-01-16 11:15:44 +08:00
|
|
|
|
.page-container-flex {
|
2026-01-11 16:50:18 +08:00
|
|
|
|
background: transparent !important;
|
2026-01-11 16:44:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-27 21:15:26 +08:00
|
|
|
|
.statistics-content {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
padding: 0;
|
|
|
|
|
|
overflow-x: hidden; /* 防止滑动动画出现横向滚动条 */
|
2025-12-27 20:57:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-27 21:15:26 +08:00
|
|
|
|
:deep(.van-pull-refresh) {
|
2025-12-27 20:57:15 +08:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
|
-webkit-overflow-scrolling: touch;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 15:56:53 +08:00
|
|
|
|
/* 导航栏日期选择器 */
|
|
|
|
|
|
.nav-date-picker {
|
2026-01-11 16:33:55 +08:00
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
2026-01-16 15:56:53 +08:00
|
|
|
|
gap: 4px;
|
2025-12-27 22:05:50 +08:00
|
|
|
|
cursor: pointer;
|
2026-01-16 15:56:53 +08:00
|
|
|
|
color: var(--van-text-color);
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 环形图 */
|
|
|
|
|
|
.chart-container {
|
2026-01-16 17:52:40 +08:00
|
|
|
|
padding: 0;
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ring-chart {
|
|
|
|
|
|
position: relative;
|
2026-01-15 22:10:57 +08:00
|
|
|
|
width: 100%;
|
2025-12-26 17:13:57 +08:00
|
|
|
|
height: 200px;
|
|
|
|
|
|
margin: 0 auto;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ring-svg {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
transform: scale(1);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ring-segment {
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.ring-center {
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 50%;
|
|
|
|
|
|
left: 50%;
|
|
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
|
|
text-align: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.center-value {
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
font-weight: 700;
|
|
|
|
|
|
color: var(--van-text-color);
|
|
|
|
|
|
margin-bottom: 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.center-label {
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
color: var(--van-text-color-2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 分类列表 */
|
|
|
|
|
|
.category-list {
|
2025-12-26 17:29:17 +08:00
|
|
|
|
padding: 0;
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
padding: 12px 0;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
border-bottom: 1px solid var(--van-border-color);
|
2025-12-26 17:56:08 +08:00
|
|
|
|
transition: background-color 0.2s;
|
|
|
|
|
|
gap: 12px;
|
2025-12-26 17:29:17 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
.category-item:last-child {
|
|
|
|
|
|
border-bottom: none;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
.category-item.clickable {
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-item.clickable:active {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background-color: var(--van-background);
|
2025-12-26 17:56:08 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
.category-info {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 12px;
|
2025-12-26 17:56:08 +08:00
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-name-with-count {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-color {
|
|
|
|
|
|
width: 12px;
|
|
|
|
|
|
height: 12px;
|
|
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-name {
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: var(--van-text-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:56:08 +08:00
|
|
|
|
.category-count {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: var(--van-text-color-3);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
.category-stats {
|
|
|
|
|
|
display: flex;
|
2025-12-26 17:56:08 +08:00
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
flex-shrink: 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-arrow {
|
|
|
|
|
|
margin-left: 8px;
|
|
|
|
|
|
color: var(--van-text-color-3);
|
|
|
|
|
|
font-size: 16px;
|
|
|
|
|
|
flex-shrink: 0;
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-16 12:08:11 +08:00
|
|
|
|
.expand-toggle {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
2026-01-16 17:52:40 +08:00
|
|
|
|
padding-top: 0;
|
2026-01-16 12:08:11 +08:00
|
|
|
|
color: var(--van-text-color-3);
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.expand-toggle:active {
|
|
|
|
|
|
opacity: 0.7;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
.category-amount {
|
|
|
|
|
|
font-size: 15px;
|
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
color: var(--van-text-color);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.category-percent {
|
|
|
|
|
|
font-size: 12px;
|
|
|
|
|
|
color: var(--van-text-color-3);
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background: var(--van-background);
|
2025-12-26 17:13:57 +08:00
|
|
|
|
padding: 2px 8px;
|
|
|
|
|
|
border-radius: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.income-color {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background-color: var(--van-success-color);
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.income-text {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-success-color);
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-27 22:34:19 +08:00
|
|
|
|
/* 不计收支颜色 */
|
|
|
|
|
|
.none-color {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background-color: var(--van-gray-6);
|
2025-12-27 22:34:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.none-text {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
color: var(--van-gray-6);
|
2025-12-27 22:34:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 17:13:57 +08:00
|
|
|
|
.expense-color {
|
2026-01-13 17:00:44 +08:00
|
|
|
|
background-color: var(--van-danger-color);
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 趋势图 */
|
|
|
|
|
|
.trend-chart {
|
|
|
|
|
|
padding: 20px 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.trend-bars {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
|
align-items: flex-end;
|
|
|
|
|
|
height: 180px;
|
|
|
|
|
|
margin-bottom: 16px;
|
|
|
|
|
|
padding: 0 4px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.trend-bar-group {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 8px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.bar-container {
|
|
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 150px;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: flex-end;
|
|
|
|
|
|
gap: 4px;
|
|
|
|
|
|
padding: 0 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.bar {
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
max-width: 20px;
|
|
|
|
|
|
min-height: 4px;
|
|
|
|
|
|
border-radius: 4px 4px 0 0;
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: flex-start;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.expense-bar {
|
|
|
|
|
|
background: linear-gradient(180deg, #ff6b6b 0%, #ff8787 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.income-bar {
|
|
|
|
|
|
background: linear-gradient(180deg, #51cf66 0%, #69db7c 100%);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.bar-value {
|
|
|
|
|
|
font-size: 10px;
|
|
|
|
|
|
color: var(--van-text-color-2);
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
margin-top: -18px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.bar-label {
|
|
|
|
|
|
font-size: 11px;
|
|
|
|
|
|
color: var(--van-text-color-3);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.trend-legend {
|
|
|
|
|
|
display: flex;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
justify-content: space-center;
|
2025-12-26 17:13:57 +08:00
|
|
|
|
gap: 24px;
|
|
|
|
|
|
padding-top: 12px;
|
2026-01-13 17:00:44 +08:00
|
|
|
|
border-top: 1px solid var(--van-border-color);
|
2025-12-26 17:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.legend-item {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
gap: 6px;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
color: var(--van-text-color-2);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.legend-color {
|
|
|
|
|
|
width: 12px;
|
|
|
|
|
|
height: 12px;
|
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-26 18:03:52 +08:00
|
|
|
|
/* 设置页面容器背景色 */
|
|
|
|
|
|
:deep(.van-nav-bar) {
|
|
|
|
|
|
background: transparent !important;
|
|
|
|
|
|
}
|
2026-01-16 12:27:00 +08:00
|
|
|
|
|
|
|
|
|
|
/* 并列显示卡片 */
|
|
|
|
|
|
.side-by-side-cards {
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
gap: 12px;
|
|
|
|
|
|
margin: 0 12px 16px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.side-by-side-cards .common-card {
|
|
|
|
|
|
margin: 0;
|
|
|
|
|
|
flex: 1;
|
|
|
|
|
|
min-width: 0; /* 允许内部元素缩小 */
|
|
|
|
|
|
padding: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.side-by-side-cards .card-header {
|
|
|
|
|
|
margin-bottom: 12px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
.text-ellipsis {
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
|
font-size: 13px;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-01-13 19:11:37 +08:00
|
|
|
|
</style>
|