feat(miniprogram): board-finance isCurrentMonthFilter 接入业务时钟 (W1-T1 / P0-3)

Wave 1 Day 2 看板沙箱接入。

调研修正:
- xcx_board.py + board_service.py 服务层已接入 runtime_context (L264/L712)
- board-customer.ts / board-coach.ts 0 处使用 new Date(),无需改
- 唯一遗漏: board-finance.ts isCurrentMonthFilter 用 new Date().getDate()
  沙箱回放历史日期会判错"本月前 5 天预估"提示

修复:
- import getBusinessClock from utils/runtime-clock
- isCurrentMonthFilter 接收可选 businessDate 参数;空值降级 new Date()
- data 加 businessDate: ''
- onShow 拉业务时钟 + 修正 isCurrentMonth
- onTimeChange 用 this.data.businessDate

参考: docs/audit/changes/2026-05-04__wave1_t1_board_sandbox_clock.md
This commit is contained in:
Neo
2026-05-04 07:42:51 +08:00
parent 509cf43284
commit 9eb495686f
2 changed files with 179 additions and 3 deletions

View File

@@ -12,9 +12,23 @@
import { checkPageAccess, getVisibleBoardTabs } from '../../utils/auth-guard'
import { getRandomAiColor } from '../../utils/ai-color'
import { fetchBoardFinance, fetchAICache } from '../../services/api'
import { getBusinessClock } from '../../utils/runtime-clock'
function isCurrentMonthFilter(selectedTime: string): boolean {
return selectedTime === 'month' && new Date().getDate() <= 5
/**
* 判断当前选择的时间筛选是否为"本月前 5 天"(用于显示"(预估)"提示)。
*
* Wave 1 W1-T1 沙箱接入(2026-05-04):
* - 优先使用业务时钟 businessDate(YYYY-MM-DD),沙箱模式下回放虚拟日期
* - businessDate 为空时降级到本地 new Date()(初次进入页面、业务时钟未就绪)
* - 后端 board_service 已通过 runtime_context 自处理时间窗口,本函数仅控制 UI 提示
*/
function isCurrentMonthFilter(selectedTime: string, businessDate?: string): boolean {
if (selectedTime !== 'month') return false
if (businessDate) {
const day = parseInt(businessDate.slice(8, 10), 10)
return !Number.isNaN(day) && day <= 5
}
return new Date().getDate() <= 5
}
// 2026-04-22 小程序轻量 Markdown 内联解析:支持 **加粗** / *倾斜* / _倾斜_ / ***加粗倾斜***
@@ -106,6 +120,8 @@ Page({
compareEnabled: false,
isCurrentMonth: true,
// Wave 1 W1-T1 沙箱接入:业务时钟(YYYY-MM-DD),沙箱模式下回放虚拟日期。空字符串表示尚未拉取,降级用本地 new Date()
businessDate: '',
// 2026-04-22 改版:拆成 title/body 两段title 在 wxml 渲染为 ai-insight-dim灰色标题body 为正文
aiInsights: [] as Array<{ title: string; body: string }>,
// 2026-04-22 seq11/12 置顶:从 aiInsights 派生,供"本期总结"卡片渲染
@@ -231,6 +247,16 @@ Page({
})
const tabBar = this.getTabBar?.()
if (tabBar) tabBar.setData({ active: 'board' })
// Wave 1 W1-T1:刷新业务时钟,沙箱模式下回放虚拟日期 → 修正"本月前 5 天预估"提示
getBusinessClock().then((clock) => {
const businessDate = clock.business_date || ''
this.setData({
businessDate,
isCurrentMonth: isCurrentMonthFilter(this.data.selectedTime, businessDate),
})
}).catch(() => {
// 降级:保留默认 isCurrentMonth(本地时钟)
})
this._loadData()
})
},
@@ -656,7 +682,7 @@ Page({
onTimeChange(e: WechatMiniprogram.CustomEvent<{ value: string }>) {
const value = e.detail.value
const option = this.data.timeOptions.find(o => o.value === value)
this.setData({ selectedTime: value, selectedTimeText: option?.text || '本月', isCurrentMonth: isCurrentMonthFilter(value) })
this.setData({ selectedTime: value, selectedTimeText: option?.text || '本月', isCurrentMonth: isCurrentMonthFilter(value, this.data.businessDate) })
this._loadData()
},