feat(dev-task): 开发任务模块 V1 完整实现
- 核心库:dev-task.ts(类型+状态机+进度计算)、task-worklog.ts(工时)、task-category.ts(字典)、work-item.ts(聚合契约) - Store:useDevTaskStore(CRUD+状态流转)、useTaskWorklogStore(工时记录)、useTaskCategoryStore(字典管理) - UI组件:DevTaskTab、DevTaskCreateModal、DevTaskDetailDrawer、DevTaskRow、WorklogPanel、StatusBadge、CategoryChip - 集成:版本详情页"开发任务"Tab、"与我相关"工作台开发任务分组、任务类型管理页 - 设计文档:spec + 实施计划 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
33
apps/web/lib/task-worklog.ts
Normal file
33
apps/web/lib/task-worklog.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
export interface TaskWorklog {
|
||||
id: string;
|
||||
taskId: string;
|
||||
userId: string;
|
||||
date: string;
|
||||
hours: number;
|
||||
workContent: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export function calcActualHours(worklogs: TaskWorklog[], taskId: string): number {
|
||||
return worklogs
|
||||
.filter((w) => w.taskId === taskId)
|
||||
.reduce((sum, w) => sum + w.hours, 0);
|
||||
}
|
||||
|
||||
export function getTaskWorklogs(worklogs: TaskWorklog[], taskId: string): TaskWorklog[] {
|
||||
return worklogs
|
||||
.filter((w) => w.taskId === taskId)
|
||||
.sort((a, b) => b.date.localeCompare(a.date));
|
||||
}
|
||||
|
||||
export function getUserDailyWorklogs(worklogs: TaskWorklog[], userId: string, date: string): TaskWorklog[] {
|
||||
return worklogs.filter((w) => w.userId === userId && w.date === date);
|
||||
}
|
||||
|
||||
export function getUserDailySummary(worklogs: TaskWorklog[], userId: string, date: string): { total: number; items: { taskId: string; hours: number; workContent: string }[] } {
|
||||
const items = getUserDailyWorklogs(worklogs, userId, date);
|
||||
return {
|
||||
total: items.reduce((sum, w) => sum + w.hours, 0),
|
||||
items: items.map((w) => ({ taskId: w.taskId, hours: w.hours, workContent: w.workContent })),
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user