feat: phase 3 - ledger and asset management

Add group expense tracking (ledger) and public asset inventory (asset) features.
Ledger supports income/expense recording with monthly summary. Asset tracks
group equipment with free-form holder transfer. Both are independent pages
accessible from GroupView navigation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
congsh
2026-04-18 19:42:04 +08:00
parent 625d0baf7d
commit c5413644f9
21 changed files with 4407 additions and 1 deletions
+110
View File
@@ -0,0 +1,110 @@
<!-- src/views/AssetView.vue -->
<script setup lang="ts">
import { onMounted, onUnmounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { useGroupStore } from '@/stores/group'
import { useAssetStore } from '@/stores/asset'
import AssetList from '@/components/asset/AssetList.vue'
import { ArrowLeft } from '@element-plus/icons-vue'
const route = useRoute()
const groupStore = useGroupStore()
const assetStore = useAssetStore()
const groupId = route.params.groupId as string
const group = computed(() => groupStore.currentGroup)
onMounted(async () => {
await groupStore.setCurrentGroup(groupId)
await assetStore.loadAssets(groupId)
await assetStore.startSubscription(groupId)
})
onUnmounted(() => {
assetStore.stopSubscription()
})
</script>
<template>
<div class="asset-view">
<!-- 页面头部 -->
<section class="page-header">
<router-link :to="`/group/${groupId}`" class="back-link">
<el-icon><ArrowLeft /></el-icon> 返回群组
</router-link>
<div class="header-content">
<h1 class="page-title">资产管理</h1>
<span class="group-badge">{{ group?.name }}</span>
</div>
</section>
<!-- 资产列表 -->
<AssetList />
</div>
</template>
<style scoped>
.asset-view {
width: 100%;
display: flex;
flex-direction: column;
gap: 20px;
}
.page-header {
padding: 20px 24px;
background: var(--gg-bg-card);
border: 1px solid var(--gg-border);
border-radius: var(--gg-radius-lg);
position: relative;
overflow: hidden;
}
.page-header::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: var(--gg-gradient);
}
.back-link {
display: inline-flex;
align-items: center;
gap: 4px;
color: var(--gg-text-muted);
text-decoration: none;
font-size: 13px;
font-weight: 500;
transition: color 0.2s;
margin-bottom: 12px;
}
.back-link:hover {
color: var(--gg-primary);
}
.header-content {
display: flex;
align-items: center;
gap: 12px;
}
.page-title {
font-size: 22px;
font-weight: 700;
margin: 0;
color: var(--gg-text);
}
.group-badge {
font-size: 13px;
padding: 4px 12px;
border-radius: 20px;
background: rgba(5, 150, 105, 0.15);
color: var(--gg-primary-light);
font-weight: 500;
}
</style>
+24 -1
View File
@@ -13,7 +13,7 @@ import PollList from '@/components/poll/PollList.vue'
import PollDetail from '@/components/poll/PollDetail.vue'
import MemoryGrid from '@/components/memory/MemoryGrid.vue'
import GroupStatsPanel from '@/components/stats/GroupStatsPanel.vue'
import { Promotion, Opportunity, UserFilled } from '@element-plus/icons-vue'
import { Promotion, Opportunity, UserFilled, Wallet, Box } from '@element-plus/icons-vue'
import { DataLine, PictureFilled, TrendCharts } from '@element-plus/icons-vue'
const route = useRoute()
@@ -154,6 +154,14 @@ async function checkExpiredPolls() {
<span class="meta-label">容量:</span>
<span class="meta-value">{{ members.length }} / {{ group?.maxMembers || '-' }}</span>
</span>
<span class="meta-divider">|</span>
<router-link :to="`/group/${groupId}/ledger`" class="meta-link">
<el-icon><Wallet /></el-icon> 账目
</router-link>
<span class="meta-divider">|</span>
<router-link :to="`/group/${groupId}/assets`" class="meta-link">
<el-icon><Box /></el-icon> 资产
</router-link>
</div>
</section>
@@ -331,6 +339,21 @@ async function checkExpiredPolls() {
color: var(--gg-border);
}
.meta-link {
display: inline-flex;
align-items: center;
gap: 4px;
color: var(--gg-primary);
text-decoration: none;
font-size: 13px;
font-weight: 500;
transition: color 0.2s;
}
.meta-link:hover {
color: var(--gg-primary-light);
}
/* ── 主体双栏 ── */
.body-grid {
display: grid;
+105
View File
@@ -0,0 +1,105 @@
<!-- src/views/LedgerView.vue -->
<script setup lang="ts">
import { onMounted, computed } from 'vue'
import { useRoute } from 'vue-router'
import { useGroupStore } from '@/stores/group'
import { useLedgerStore } from '@/stores/ledger'
import LedgerList from '@/components/ledger/LedgerList.vue'
import { ArrowLeft } from '@element-plus/icons-vue'
const route = useRoute()
const groupStore = useGroupStore()
const ledgerStore = useLedgerStore()
const groupId = route.params.groupId as string
const group = computed(() => groupStore.currentGroup)
onMounted(async () => {
await groupStore.setCurrentGroup(groupId)
await ledgerStore.loadLedgers(groupId)
})
</script>
<template>
<div class="ledger-view">
<!-- 页面头部 -->
<section class="page-header">
<router-link :to="`/group/${groupId}`" class="back-link">
<el-icon><ArrowLeft /></el-icon> 返回群组
</router-link>
<div class="header-content">
<h1 class="page-title">账目管理</h1>
<span class="group-badge">{{ group?.name }}</span>
</div>
</section>
<!-- 账目列表 -->
<LedgerList />
</div>
</template>
<style scoped>
.ledger-view {
width: 100%;
display: flex;
flex-direction: column;
gap: 20px;
}
.page-header {
padding: 20px 24px;
background: var(--gg-bg-card);
border: 1px solid var(--gg-border);
border-radius: var(--gg-radius-lg);
position: relative;
overflow: hidden;
}
.page-header::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 3px;
background: var(--gg-gradient);
}
.back-link {
display: inline-flex;
align-items: center;
gap: 4px;
color: var(--gg-text-muted);
text-decoration: none;
font-size: 13px;
font-weight: 500;
transition: color 0.2s;
margin-bottom: 12px;
}
.back-link:hover {
color: var(--gg-primary);
}
.header-content {
display: flex;
align-items: center;
gap: 12px;
}
.page-title {
font-size: 22px;
font-weight: 700;
margin: 0;
color: var(--gg-text);
}
.group-badge {
font-size: 13px;
padding: 4px 12px;
border-radius: 20px;
background: rgba(5, 150, 105, 0.15);
color: var(--gg-primary-light);
font-weight: 500;
}
</style>