核心变更: - 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>
42 lines
1.7 KiB
TypeScript
42 lines
1.7 KiB
TypeScript
'use client';
|
|
|
|
import { memo } from 'react';
|
|
import { TestCaseStatusBadge } from './TestCaseStatusBadge';
|
|
import { getTestCaseActualHours } from '@/lib/test-case';
|
|
import { formatWorkHours } from '@/lib/work-hours';
|
|
import type { TestCase } from '@/lib/test-case';
|
|
|
|
interface Props {
|
|
testCase: TestCase;
|
|
bugCount: number;
|
|
onClick?: () => void;
|
|
}
|
|
|
|
const PRIORITY_DOT: Record<string, string> = {
|
|
P0: 'bg-red-500',
|
|
P1: 'bg-orange-400',
|
|
P2: 'bg-blue-400',
|
|
P3: 'bg-zinc-300',
|
|
};
|
|
|
|
function TestCaseRowImpl({ testCase, bugCount, onClick }: Props) {
|
|
const actualHours = getTestCaseActualHours(testCase);
|
|
return (
|
|
<div onClick={onClick} className="flex items-center gap-3 px-4 py-2.5 border-b border-[var(--line)] hover:bg-[var(--bg-subtle)] cursor-pointer transition-colors last:border-b-0">
|
|
<span className={`h-2 w-2 rounded-full shrink-0 ${PRIORITY_DOT[testCase.priority] || 'bg-zinc-300'}`} />
|
|
<span className="text-[11px] font-mono text-[var(--ink-muted)] w-14 shrink-0">{testCase.caseNo}</span>
|
|
<span className="text-[13px] text-[var(--ink)] flex-1 truncate">{testCase.title}</span>
|
|
<TestCaseStatusBadge status={testCase.status} />
|
|
{actualHours > 0 && (
|
|
<span className="text-[11px] text-[var(--ink-muted)] tabular-nums w-28 text-right shrink-0 whitespace-nowrap">{formatWorkHours(actualHours)}</span>
|
|
)}
|
|
{bugCount > 0 && (
|
|
<span className="text-[10px] text-red-500 bg-red-50 px-1.5 py-0.5 rounded shrink-0">{bugCount} Bug</span>
|
|
)}
|
|
<span className="text-[11px] text-[var(--ink-soft)] w-14 text-right truncate shrink-0">{testCase.assigneeId || '-'}</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export const TestCaseRow = memo(TestCaseRowImpl);
|