Files
ftb-project-management/apps/web/lib/work-item.ts
Script Generator 1f5bed0c79 feat: 开发任务时间字段重构 + 双口径耗时 + 搜索 + 性能优化
核心变更:
- DevTask 字段重构:startDate/dueDate/estimateHours/actualHours 替换为 expectedStartAt/expectedEndAt/actualStartAt/actualEndAt(含时分),预计/实际工时按工作时段(9:00-12:00 + 13:00-18:00)派生计算
- 状态机自动化:到点自动切开发中、未到可手动开干、超期需填延后原因
- 新建 lib/work-hours.ts:calcWorkHours(工作时段过滤)、formatWorkHours(X h(Y 天))、calcTwoMetrics(日历/人力双口径)
- 新建 lib/dev-task-transitions.ts:状态切换守卫
- 三个 Tab 顶部统计:开发任务(预/日历/人力)、测试用例 / Bug(日历 / 人力);版本概览总人天投入改双行(日历总耗时 / 人力总投入)
- 三个 Tab 加搜索框:300ms debounce + 标题/编号模糊匹配
- 性能优化:requirementIds/categories/requirements/testCases 转 Map/Set 索引、Row 组件 React.memo
- 全局耗时显示统一带天数换算:8h(1天)、11h(1.4天)

新增文件: SearchInput.tsx, useDebouncedValue.ts, work-hours.ts, dev-task-transitions.ts, 设计文档

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-06-16 17:44:59 +08:00

50 lines
1.3 KiB
TypeScript

import type { DevTask } from './dev-task';
import type { VersionPlan } from './version-plan';
import type { Priority } from './derive';
export type WorkItemEntityType = 'plan' | 'devTask' | 'testCase' | 'bug';
export interface WorkItem {
entityType: WorkItemEntityType;
entityId: string;
title: string;
status: string;
isBlocked?: boolean;
assigneeId: string;
reviewerId?: string;
versionId: string;
versionName?: string;
priority?: Priority;
dueDate?: string;
categoryLabel?: string;
}
export function planToWorkItem(plan: VersionPlan): WorkItem {
return {
entityType: 'plan',
entityId: plan.id,
title: plan.title,
status: plan.status,
assigneeId: plan.owner,
versionId: plan.versionId,
dueDate: plan.endTime.slice(0, 10),
categoryLabel: plan.type === 'research' ? '调研' : plan.type === 'product' ? '产品方案' : 'UI设计',
};
}
export function devTaskToWorkItem(task: DevTask, versionId: string, categoryLabel?: string): WorkItem {
return {
entityType: 'devTask',
entityId: task.id,
title: task.title,
status: task.status,
isBlocked: task.isBlocked,
assigneeId: task.assigneeId,
reviewerId: task.reviewerId,
versionId,
priority: task.priority,
dueDate: task.expectedEndAt,
categoryLabel,
};
}