财务折线:概览卡画净资产趋势(配服务端 /timeline)laoyang/FamilyBook#24
用户原话(2026-10-28):「鸿蒙端对齐网页端」。财务概览卡原来「折线图占位 (第二轮接图表能力后填)」,现在: 1) FbLedgerPoint 类型 + parseLedgerTimeline(读 /timeline 的 items) 2) loadEntries 里顺带拉 timeline(单独缓存键 ledger_timeline_<id>) 3) timelinePath():时序点 → 绝对坐标折线 path(Path 组件画,Y 轴按 min..max 归一,不是从 0 起 —— 金额平稳时不贴底);<2 点时给占位文案。 编译 BUILD SUCCESSFUL;守卫 _fb_arkts_guard.js 1324/0;服务端冒烟 _i24_timeline_api.py 8/0 + 反证命中。
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
import {
|
||||
FbAccount, FbAnniversaryItem, FbBookItem, FbBookNoteItem, FbCalEvent, FbHomeData, FbKinChip,
|
||||
FbMark,
|
||||
FbLedgerBook, FbLedgerDetail, FbLedgerEntry, FbNoteItem, FbNoteBlock, FbNotificationItem, FbResourceItem,
|
||||
FbLedgerBook, FbLedgerDetail, FbLedgerEntry, FbLedgerPoint, FbNoteItem, FbNoteBlock, FbNotificationItem, FbResourceItem,
|
||||
FbTaskItem, FbTripItem, FbWeather, FbStat, FbMemoryItem, FbRecentDay,
|
||||
FbTaskAttach, FbTaskComment, FbTaskDetail, FbTaskKid, FbTaskMeta, FbCatOpt, FbBoardOpt,
|
||||
} from '../model/Types';
|
||||
@@ -230,6 +230,10 @@ interface RawLedgerSummary {
|
||||
asset?: number; debt?: number; net?: number; count?: number;
|
||||
}
|
||||
|
||||
interface RawLedgerPoint {
|
||||
date?: string; net?: number; asset?: number; debt?: number;
|
||||
}
|
||||
|
||||
interface RawResource {
|
||||
id?: number; title?: string; content?: string; owner_id?: number;
|
||||
owner_name?: string | null; avatar?: string | null; avatar_color?: string | null;
|
||||
@@ -515,6 +519,26 @@ export function parseLedgerEntries(json: string): FbLedgerDetail {
|
||||
return d;
|
||||
}
|
||||
|
||||
/** 财务折线时序 → FbLedgerPoint[](工单 #24;`GET /api/v1/ledger/<id>/timeline`) */
|
||||
export function parseLedgerTimeline(json: string): FbLedgerPoint[] {
|
||||
const root: Record<string, Object> | null = asObject(json);
|
||||
if (root === null) {
|
||||
return [];
|
||||
}
|
||||
const rows: RawLedgerPoint[] = (root['items'] !== undefined && root['items'] !== null)
|
||||
? arr<RawLedgerPoint>(root['items'] as RawLedgerPoint[]) : [];
|
||||
const out: FbLedgerPoint[] = [];
|
||||
for (const r of rows) {
|
||||
out.push({
|
||||
date: s(r.date),
|
||||
netCent: n(r.net),
|
||||
assetCent: n(r.asset),
|
||||
debtCent: n(r.debt),
|
||||
});
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/** id 数组的容错转换(服务端可能给 null) */
|
||||
function idList(v: number[] | null | undefined): number[] {
|
||||
const xs: number[] = arr<number>(v);
|
||||
|
||||
Reference in New Issue
Block a user