Files
Neo-ZQYY/docs/prd/Neo_Specs/review-audit/P8-NS1-14.md
Neo 6f8f12314f feat: 累积功能变更 — 聊天集成、租户管理、小程序更新、ETL 增强、迁移脚本
包含多个会话的累积代码变更:
- backend: AI 聊天服务、触发器调度、认证增强、WebSocket、调度器最小间隔
- admin-web: ETL 状态页、任务管理、调度配置、登录优化
- miniprogram: 看板页面、聊天集成、UI 组件、导航更新
- etl: DWS 新任务(finance_area_daily/board_cache)、连接器增强
- tenant-admin: 项目初始化
- db: 19 个迁移脚本(etl_feiqiu 11 + zqyy_app 8)
- packages/shared: 枚举和工具函数更新
- tools: 数据库工具、报表生成、健康检查
- docs: PRD/架构/部署/合约文档更新

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 00:03:48 +08:00

97 lines
3.5 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.
# P8→NS1/RNS1 缺失项 #14财务看板数字的格式化规范
## 简要结论
- 状态:✅ 已解决
- 风险等级:🟡 低
- 千分位、小数位、货币符号的格式化规范已在设计文档中定义工具函数已实现TS + WXS 双版本),财务看板已使用
## 详细审查
### 审查范围
- `docs/miniprogram-dev/design-system/DISPLAY-STANDARDS.md`
- `apps/miniprogram/miniprogram/utils/money.ts`
- `apps/miniprogram/miniprogram/utils/format.wxs`
- `apps/miniprogram/miniprogram/pages/board-finance/board-finance.ts`
- `apps/miniprogram/miniprogram/pages/board-coach/board-coach.ts`
### 发现
#### 1. 设计规范文档已完善
`DISPLAY-STANDARDS.md` 第 1 章"金额展示规范"明确定义了:
- 正常金额:`¥N,NNN`(千分位逗号,无小数)
- 负数金额:`-¥N,NNN`(负号在 ¥ 前)
- 零值:`¥0`
- 空值:`--`
- 大额金额:不简写,保留完整数字
- 禁止事项:禁止 `¥-368``¥0.00``¥12万``toLocaleString()`
#### 2. TS 工具函数已实现(`utils/money.ts`
- `formatMoney(value)` — 金额格式化,千分位 + ¥ 前缀
- `formatCount(value, unit)` — 计数格式化,千分位 + 单位
- `formatNumber(value)` — 纯数字千分位
- `formatPercent(value)` — 百分比,保留 1 位小数
- `formatTrendValue(value)` — 同比/环比差值,+¥/-¥ 前缀
- `toProgressWidth(value)` — 进度条宽度,截断至 [0, 100]
#### 3. WXS 工具函数已实现(`utils/format.wxs`
- `money(value)` — 金额格式化WXS 版,用于 WXML 模板)
- `count(value, unit)` — 计数格式化
- `percent(value)` — 百分比
- `hours(value)` — 课时格式化
- `trendValue(value)` — 同比/环比差值
- `safe(val)` — 空值兜底
#### 4. 看板页面已使用格式化函数
- `board-finance.ts`:导入并使用 `formatMoney` 格式化赠送卡矩阵数据
- `board-coach.ts`:导入并使用 `formatMoney``formatCount``formatHours` 格式化助教数据
- `board-finance.wxml`:未引入 `format.wxs`(财务看板数据在 TS 层预格式化后传入模板)
- `board-customer.wxml`:引入 `format.wxs`,使用 `fmt.safe()` 兜底
### 证据
DISPLAY-STANDARDS.md 金额规范:
```markdown
| 场景 | 格式 | 示例 |
|---|---|---|
| 正常金额 | `¥N,NNN`(千分位逗号,无小数) | `¥12,680` |
| 负数金额 | `-¥N,NNN`(负号在 ¥ 前) | `-¥368` |
| 零值 | `¥0` | `¥0` |
| 空值 / undefined | `--` | `--` |
```
money.ts 核心函数:
```typescript
export function formatMoney(value: number | null | undefined): string {
if (value === null || value === undefined) return '--'
if (value === 0) return '¥0'
const abs = Math.round(Math.abs(value))
const formatted = abs.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
return value < 0 ? `${formatted}` : `¥${formatted}`
}
```
format.wxs 金额函数WXS 版,逻辑一致):
```javascript
function money(value) {
if (value === undefined || value === null) return '--'
if (value === 0) return '¥0'
// ... 千分位处理
return (value < 0 ? '-¥' : '¥') + result
}
```
board-finance.ts 使用示例:
```typescript
import { formatMoney } from '../../utils/money'
// ...
wine: formatMoney(row.liquor?.value),
table: formatMoney(row.tableFee?.value),
```
### 建议
无。格式化规范已完整覆盖:
- 设计文档DISPLAY-STANDARDS.md定义了规则
- TS 工具函数money.ts供 JS 层使用
- WXS 工具函数format.wxs供 WXML 模板使用
- 看板页面已实际调用格式化函数