核心变更: - 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>
134 lines
3.6 KiB
TypeScript
134 lines
3.6 KiB
TypeScript
import type { VersionPlan } from './version-plan';
|
|
import type { DevTask } from './dev-task';
|
|
import type { TestCase } from './test-case';
|
|
import type { Bug } from './bug';
|
|
|
|
export type WorkItemType = 'plan_research' | 'plan_product' | 'plan_ui' | 'devTask' | 'testCase' | 'bug';
|
|
|
|
export interface WorkItem {
|
|
id: string;
|
|
type: WorkItemType;
|
|
title: string;
|
|
status: string;
|
|
completed: boolean;
|
|
productName: string;
|
|
projectName: string;
|
|
versionName: string;
|
|
versionId: string;
|
|
priority?: string;
|
|
extra?: Record<string, any>;
|
|
raw: VersionPlan | DevTask | TestCase | Bug;
|
|
}
|
|
|
|
interface VersionContext {
|
|
id: string;
|
|
name: string;
|
|
productName: string;
|
|
projectName: string;
|
|
}
|
|
|
|
export function aggregateWorkItems(
|
|
userName: string,
|
|
plans: VersionPlan[],
|
|
devTasks: DevTask[],
|
|
testCases: TestCase[],
|
|
bugs: Bug[],
|
|
versionMap: Map<string, VersionContext>,
|
|
requirementVersionMap: Map<string, string>,
|
|
): WorkItem[] {
|
|
const items: WorkItem[] = [];
|
|
|
|
// Plans: owner === userName
|
|
plans.filter((p) => p.owner === userName).forEach((p) => {
|
|
const ver = versionMap.get(p.versionId);
|
|
items.push({
|
|
id: p.id,
|
|
type: p.type === 'research' ? 'plan_research' : p.type === 'product' ? 'plan_product' : 'plan_ui',
|
|
title: p.title,
|
|
status: p.status,
|
|
completed: p.status === 'completed',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId: p.versionId,
|
|
extra: { startTime: p.startTime, endTime: p.endTime },
|
|
raw: p,
|
|
});
|
|
});
|
|
|
|
// DevTasks: assigneeId === userName
|
|
devTasks.filter((t) => t.assigneeId === userName).forEach((t) => {
|
|
const versionId = requirementVersionMap.get(t.requirementId) ?? '';
|
|
const ver = versionMap.get(versionId);
|
|
items.push({
|
|
id: t.id,
|
|
type: 'devTask',
|
|
title: t.title,
|
|
status: t.status,
|
|
completed: t.status === 'submitted',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId,
|
|
priority: t.priority,
|
|
extra: {
|
|
taskNo: t.taskNo,
|
|
expectedStartAt: t.expectedStartAt,
|
|
expectedEndAt: t.expectedEndAt,
|
|
actualStartAt: t.actualStartAt,
|
|
actualEndAt: t.actualEndAt,
|
|
},
|
|
raw: t,
|
|
});
|
|
});
|
|
|
|
// TestCases: assigneeId === userName
|
|
testCases.filter((c) => c.assigneeId === userName).forEach((c) => {
|
|
const ver = versionMap.get(c.versionId);
|
|
items.push({
|
|
id: c.id,
|
|
type: 'testCase',
|
|
title: c.title,
|
|
status: c.status,
|
|
completed: c.status === 'passed',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId: c.versionId,
|
|
priority: c.priority,
|
|
extra: { caseNo: c.caseNo },
|
|
raw: c,
|
|
});
|
|
});
|
|
|
|
// Bugs: assigneeId === userName
|
|
bugs.filter((b) => b.assigneeId === userName).forEach((b) => {
|
|
const ver = versionMap.get(b.versionId);
|
|
items.push({
|
|
id: b.id,
|
|
type: 'bug',
|
|
title: b.title,
|
|
status: b.status,
|
|
completed: b.status === 'closed' || b.status === 'rejected',
|
|
productName: ver?.productName ?? '-',
|
|
projectName: ver?.projectName ?? '-',
|
|
versionName: ver?.name ?? '-',
|
|
versionId: b.versionId,
|
|
priority: b.priority,
|
|
extra: { bugNo: b.bugNo, severity: b.severity },
|
|
raw: b,
|
|
});
|
|
});
|
|
|
|
return items;
|
|
}
|
|
|
|
export const WORK_ITEM_TYPE_LABEL: Record<WorkItemType, string> = {
|
|
plan_research: '调研',
|
|
plan_product: '产品方案',
|
|
plan_ui: 'UI设计',
|
|
devTask: '开发任务',
|
|
testCase: '测试用例',
|
|
bug: 'Bug',
|
|
};
|