feat: 计划模式(时间段+打卡+计时时钟) / 工作详情范围导出 / 工作与记账分类自定义(含历史迁移)

This commit is contained in:
root
2026-10-26 11:48:14 +08:00
parent a1f2a45623
commit 284f8ebd46
24 changed files with 768 additions and 81 deletions
+13 -6
View File
@@ -1,5 +1,6 @@
import { getWorkRule, listAttendanceBetween, listLogItemsBetween, listProjects, listWeeklyNotesBetween } from '../db/repo'
import { CATEGORIES, type LogItem } from '../db/schema'
import { type LogItem } from '../db/schema'
import { getLogCategories } from '../db/categories'
import { todayStr } from '../lib/date'
import { computeDay } from './attendance'
@@ -44,13 +45,15 @@ export async function buildReport(start: string, end: string, label: string): Pr
listAttendanceBetween(start, end),
listLogItemsBetween(start, end),
listProjects(true),
listWeeklyNotesBetween(start, end)
listWeeklyNotesBetween(start, end),
getLogCategories()
])
const rule = results[0]
const atts = results[1]
const items = results[2]
const projects = results[3]
const notes = results[4]
const logCats: string[] = results[5] as string[]
let attendDays = 0
let workedMin = 0
@@ -73,10 +76,14 @@ export async function buildReport(start: string, end: string, label: string): Pr
.sort((a, b) => b.count - a.count)
const total = items.length || 1
const categoryStats: CategoryStat[] = CATEGORIES
.map(c => {
const count = items.filter((i: LogItem) => i.category === c.key).length
return { key: c.key, label: c.label, count, percent: Math.round((count / total) * 100) }
const catCount2 = new Map<string, number>()
for (const it of items) catCount2.set(it.category, (catCount2.get(it.category) || 0) + 1)
const catSet2 = new Set(logCats)
for (const k of catCount2.keys()) if (!catSet2.has(k)) logCats.push(k)
const categoryStats: CategoryStat[] = logCats
.map(label => {
const count = catCount2.get(label) || 0
return { key: label, label, count, percent: Math.round((count / total) * 100) }
})
.filter(c => c.count > 0)
.sort((a, b) => b.count - a.count)