Files
gamegroup2/docs/plans/2026-04-18-phase3-features-design.md
T
congsh c5413644f9 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>
2026-04-18 19:42:04 +08:00

147 lines
4.4 KiB
Markdown
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.
# Game Group V2 — 三期功能设计
## 功能总览
| 优先级 | 功能 | 说明 |
|--------|------|------|
| P0 | 账目管理 | 群组费用流水记录,纯记录不分摊 |
| P0 | 资产管理 | 群组公共资产清单,自由标记持有人 |
---
## P0: 账目管理
### 定位
群组内费用流水记录。成员记录每笔收入/支出(聚餐、游戏充值、设备采购等),纯记录,不做分摊和结算。
### 数据模型
**`ledgers` Collection:**
| 字段 | 类型 | 说明 |
|------|------|------|
| group | relation → groups | 所属群组 |
| creator | relation → users | 记录人 |
| type | select: `income` / `expense` | 收入/支出 |
| amount | number | 金额 |
| category | select: `gaming` / `food` / `equipment` / `transport` / `other` | 分类 |
| description | text | 描述 |
| relatedMembers | relation → users (multiple) | 相关成员 |
| occurredAt | date | 发生时间 |
### 业务规则
- 所有群成员可记录和查看
- 只有记录人可编辑/删除
- 收入用绿色,支出用红色,直观区分
### 前端页面
路由:`/group/:groupId/ledger`
```
components/ledger/
├── LedgerList.vue # 账目列表(收入/支出分色显示)
├── LedgerCard.vue # 单条账目卡片
├── CreateLedgerDialog.vue # 新建账目弹窗
└── LedgerSummary.vue # 汇总面板(总收入/总支出/余额)
```
### API 层 (`api/ledgers.ts`)
- `createLedger(groupId, data)` — 新建记录
- `listLedgers(groupId, filter?)` — 列表(支持按月筛选)
- `updateLedger(ledgerId, data)` — 更新(仅记录人)
- `deleteLedger(ledgerId)` — 删除(仅记录人)
- `getLedgerSummary(groupId)` — 汇总统计
---
## P0: 资产管理
### 定位
群组公共资产清单。登记游戏账号、主机、手柄等物品,任何成员可自由标记当前持有人。空持有人表示资产在库。
### 数据模型
**`assets` Collection:**
| 字段 | 类型 | 说明 |
|------|------|------|
| group | relation → groups | 所属群组 |
| creator | relation → users | 登记人 |
| name | text | 资产名称 |
| type | select: `game_account` / `console` / `equipment` / `accessory` / `other` | 类型 |
| description | text, 可选 | 描述备注 |
| currentHolder | relation → users, 可选 | 当前持有人(空=在库) |
| image | file, 可选 | 资产照片 |
### 业务规则
- 所有群成员可登记和查看
- 任何成员可更新持有人(标记自己拿走/放回)
- 只有登记人可编辑/删除资产信息
### 前端页面
路由:`/group/:groupId/assets`
```
components/asset/
├── AssetList.vue # 资产列表(卡片网格)
├── AssetCard.vue # 资产卡片(显示持有人头像)
├── CreateAssetDialog.vue # 登记资产弹窗
└── TransferAssetDialog.vue # 转移持有人弹窗(选择成员)
```
### API 层 (`api/assets.ts`)
- `createAsset(groupId, data)` — 登记资产
- `listAssets(groupId)` — 资产列表
- `updateAsset(assetId, data)` — 更新信息
- `deleteAsset(assetId)` — 删除
- `transferAsset(assetId, userId?)` — 更新持有人(null=放回在库)
---
## 导航入口
GroupView 群组操作菜单中添加:
- "账目"按钮 → 跳转 `/group/:groupId/ledger`
- "资产"按钮 → 跳转 `/group/:groupId/assets`
---
## 实现文件变更总览
### 新增文件
| 文件 | 说明 |
|------|------|
| `frontend/src/api/ledgers.ts` | 账目 API |
| `frontend/src/api/assets.ts` | 资产 API |
| `frontend/src/components/ledger/*.vue` | 账目组件 (4 个) |
| `frontend/src/components/asset/*.vue` | 资产组件 (4 个) |
| `frontend/src/views/LedgerView.vue` | 账目页面 |
| `frontend/src/views/AssetView.vue` | 资产页面 |
| `backend/pb_migrations/xxxx_create_ledgers.js` | 账目表迁移 |
| `backend/pb_migrations/xxxx_create_assets.js` | 资产表迁移 |
### 修改文件
| 文件 | 变更 |
|------|------|
| `frontend/src/types/index.ts` | 新增 Ledger、Asset 类型定义 |
| `frontend/src/router/index.ts` | 新增 ledger、asset 路由 |
| `frontend/src/views/GroupView.vue` | 添加账目/资产入口按钮 |
### 建议实现顺序
1. 数据库迁移(ledgers → assets
2. 类型定义 (types/index.ts)
3. API 层 (ledgers.ts → assets.ts)
4. 账目页面(组件 + 路由 + 导航入口)
5. 资产页面(组件 + 路由 + 导航入口)