refactor: 去掉"联调"阶段,新增"BUG"阶段胶囊
- Stage 类型去掉 integration,新增 bug - 胶囊条:调研 → 产品设计 → UI设计 → 开发 → 测试 → BUG → 上线 - BUG 阶段进度 = 已关闭Bug / 总Bug - 全部关闭 = done(绿色),有Bug未关闭 = active(蓝色) - 版本列表/项目详情的阶段筛选同步去掉联调 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,9 +6,13 @@ import { ChevronLeft, Package, Calendar, Clock, Users, Tag, ChevronDown } from '
|
|||||||
import { useProductStore } from '@/stores/useProductStore';
|
import { useProductStore } from '@/stores/useProductStore';
|
||||||
import { useRequirementStore } from '@/stores/useRequirementStore';
|
import { useRequirementStore } from '@/stores/useRequirementStore';
|
||||||
import { useOvertimeStore } from '@/stores/useOvertimeStore';
|
import { useOvertimeStore } from '@/stores/useOvertimeStore';
|
||||||
|
import { useVersionPlanStore } from '@/stores/useVersionPlanStore';
|
||||||
|
import { useDevTaskStore } from '@/stores/useDevTaskStore';
|
||||||
|
import { useTestCaseStore } from '@/stores/useTestCaseStore';
|
||||||
import { getProjectDetail, VersionWithContext } from '@/lib/derive';
|
import { getProjectDetail, VersionWithContext } from '@/lib/derive';
|
||||||
import { Stage, Role, STAGES, ROLES, STAGE_INDEX, ROLE_LABEL } from '@/lib/stage';
|
import { Stage, Role, STAGES, ROLES, STAGE_INDEX, ROLE_LABEL } from '@/lib/stage';
|
||||||
import { VersionStatus, VERSION_STATUS_LABEL, VERSION_STATUS_BG } from '@/lib/version-status';
|
import { VersionStatus, VERSION_STATUS_LABEL, VERSION_STATUS_BG } from '@/lib/version-status';
|
||||||
|
import { STATUS_PROGRESS } from '@/lib/dev-task';
|
||||||
import { CapsuleStages } from '@/components/version/CapsuleStages';
|
import { CapsuleStages } from '@/components/version/CapsuleStages';
|
||||||
import { MemberChips } from '@/components/version/MemberChips';
|
import { MemberChips } from '@/components/version/MemberChips';
|
||||||
|
|
||||||
@@ -39,13 +43,23 @@ function ProgressBar({ role, percent, daysSpent }: { role: Role; percent: number
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* ─── VersionCard ─── */
|
/* ─── VersionCard ─── */
|
||||||
function VersionCard({ version, onNavigate }: { version: VersionWithContext; onNavigate: (id: string) => void }) {
|
function VersionCard({ version, progress, onNavigate }: { version: VersionWithContext; progress: number; onNavigate: (id: string) => void }) {
|
||||||
const [expanded, setExpanded] = useState(false);
|
const [expanded, setExpanded] = useState(false);
|
||||||
const totalDays = (version.progress ?? []).reduce((sum, p) => sum + p.daysSpent, 0);
|
|
||||||
|
|
||||||
const stageLabel = version.currentStage ? STAGES.find((s) => s.key === version.currentStage)?.label ?? '' : '';
|
// Calculate actual elapsed days from dates instead of old progress data
|
||||||
const displayStatus = version.status === 'released' ? '已发布' : version.status === 'planned' ? '规划中' : stageLabel ? `${stageLabel}中` : '开发中';
|
const totalDays = useMemo(() => {
|
||||||
const displayBg = version.status === 'released' ? 'bg-zinc-100 text-zinc-600' : version.status === 'planned' ? 'bg-orange-500/10 text-orange-600' : 'bg-blue-500/10 text-blue-600';
|
if (!version.startDate) return 0;
|
||||||
|
const start = new Date(version.startDate);
|
||||||
|
start.setHours(0, 0, 0, 0);
|
||||||
|
const end = version.status === 'released' && version.releaseDate
|
||||||
|
? new Date(version.releaseDate)
|
||||||
|
: new Date();
|
||||||
|
end.setHours(0, 0, 0, 0);
|
||||||
|
return Math.max(0, Math.floor((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24)));
|
||||||
|
}, [version.startDate, version.releaseDate, version.status]);
|
||||||
|
|
||||||
|
const displayStatus = VERSION_STATUS_LABEL[version.status] ?? '开发中';
|
||||||
|
const displayBg = VERSION_STATUS_BG[version.status] ?? 'bg-blue-500/10 text-blue-600';
|
||||||
|
|
||||||
if (version.status === 'planned') {
|
if (version.status === 'planned') {
|
||||||
return (
|
return (
|
||||||
@@ -91,6 +105,12 @@ function VersionCard({ version, onNavigate }: { version: VersionWithContext; onN
|
|||||||
<div className="flex items-center gap-2 mb-3">
|
<div className="flex items-center gap-2 mb-3">
|
||||||
<span onClick={() => onNavigate(version.id)} className="text-sm font-medium text-[var(--ink)] cursor-pointer hover:text-[var(--accent)]">{version.name}</span>
|
<span onClick={() => onNavigate(version.id)} className="text-sm font-medium text-[var(--ink)] cursor-pointer hover:text-[var(--accent)]">{version.name}</span>
|
||||||
<span className={`text-[11px] px-2 py-0.5 rounded-full ${displayBg}`}>{displayStatus}</span>
|
<span className={`text-[11px] px-2 py-0.5 rounded-full ${displayBg}`}>{displayStatus}</span>
|
||||||
|
<div className="flex-1 flex items-center gap-2 ml-2">
|
||||||
|
<div className="flex-1 h-1.5 rounded-full bg-zinc-100 max-w-[160px]">
|
||||||
|
<div className="h-1.5 rounded-full bg-blue-500 transition-all" style={{ width: `${progress}%` }} />
|
||||||
|
</div>
|
||||||
|
<span className="text-[11px] tabular-nums text-[var(--ink-muted)]">{progress}%</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="mb-3"><CapsuleStages /></div>
|
<div className="mb-3"><CapsuleStages /></div>
|
||||||
<div className="flex items-center justify-between text-[11px] text-[var(--ink-muted)] mb-3 pb-3 border-b border-[var(--line-soft)]">
|
<div className="flex items-center justify-between text-[11px] text-[var(--ink-muted)] mb-3 pb-3 border-b border-[var(--line-soft)]">
|
||||||
@@ -163,7 +183,6 @@ const FILTER_OPTIONS: { key: string; label: string }[] = [
|
|||||||
{ key: 'product_design', label: '产品设计' },
|
{ key: 'product_design', label: '产品设计' },
|
||||||
{ key: 'ui_design', label: 'UI设计' },
|
{ key: 'ui_design', label: 'UI设计' },
|
||||||
{ key: 'dev', label: '开发' },
|
{ key: 'dev', label: '开发' },
|
||||||
{ key: 'integration', label: '联调' },
|
|
||||||
{ key: 'testing', label: '测试' },
|
{ key: 'testing', label: '测试' },
|
||||||
{ key: 'released', label: '已发布' },
|
{ key: 'released', label: '已发布' },
|
||||||
{ key: 'planned', label: '规划中' },
|
{ key: 'planned', label: '规划中' },
|
||||||
@@ -177,11 +196,17 @@ export default function ProjectDetailPage() {
|
|||||||
const { overview, fetchOverview } = useProductStore();
|
const { overview, fetchOverview } = useProductStore();
|
||||||
const { requirements, fetchRequirements } = useRequirementStore();
|
const { requirements, fetchRequirements } = useRequirementStore();
|
||||||
const { records, fetchRecords } = useOvertimeStore();
|
const { records, fetchRecords } = useOvertimeStore();
|
||||||
|
const { plans, fetchPlans } = useVersionPlanStore();
|
||||||
|
const { tasks: devTasks, fetchTasks: fetchDevTasks } = useDevTaskStore();
|
||||||
|
const { testCases, fetchTestCases } = useTestCaseStore();
|
||||||
const [statusFilter, setStatusFilter] = useState<string>('all');
|
const [statusFilter, setStatusFilter] = useState<string>('all');
|
||||||
|
|
||||||
useEffect(() => { fetchOverview(); }, [fetchOverview]);
|
useEffect(() => { fetchOverview(); }, [fetchOverview]);
|
||||||
useEffect(() => { fetchRequirements(); }, [fetchRequirements]);
|
useEffect(() => { fetchRequirements(); }, [fetchRequirements]);
|
||||||
useEffect(() => { fetchRecords(); }, [fetchRecords]);
|
useEffect(() => { fetchRecords(); }, [fetchRecords]);
|
||||||
|
useEffect(() => { fetchPlans(); }, [fetchPlans]);
|
||||||
|
useEffect(() => { fetchDevTasks(); }, [fetchDevTasks]);
|
||||||
|
useEffect(() => { fetchTestCases(); }, [fetchTestCases]);
|
||||||
|
|
||||||
const project = useMemo(() => getProjectDetail(overview, projectId), [overview, projectId]);
|
const project = useMemo(() => getProjectDetail(overview, projectId), [overview, projectId]);
|
||||||
|
|
||||||
@@ -200,12 +225,89 @@ export default function ProjectDetailPage() {
|
|||||||
return list.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
return list.sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
||||||
}, [project, statusFilter]);
|
}, [project, statusFilter]);
|
||||||
|
|
||||||
|
// Compute actual overall progress per version
|
||||||
|
const versionProgressMap = useMemo(() => {
|
||||||
|
if (!project) return {} as Record<string, number>;
|
||||||
|
const map: Record<string, number> = {};
|
||||||
|
for (const v of project.versions) {
|
||||||
|
const vPlans = plans.filter((p) => p.versionId === v.id);
|
||||||
|
const vReqs = requirements.filter((r) => r.versionId === v.id);
|
||||||
|
const vReqIds = new Set(vReqs.map((r) => r.id));
|
||||||
|
const vDevTasks = devTasks.filter((t) => vReqIds.has(t.requirementId));
|
||||||
|
const vTestCases = testCases.filter((c) => c.versionId === v.id);
|
||||||
|
|
||||||
|
const segments: number[] = [];
|
||||||
|
|
||||||
|
const researchPlans = vPlans.filter((p) => p.type === 'research');
|
||||||
|
if (researchPlans.length > 0) {
|
||||||
|
const totals = researchPlans.reduce((acc, p) => {
|
||||||
|
const tasks = p.tasks || [];
|
||||||
|
acc.total += tasks.length;
|
||||||
|
acc.done += tasks.filter((t) => t.status === 'completed').length;
|
||||||
|
return acc;
|
||||||
|
}, { total: 0, done: 0 });
|
||||||
|
segments.push(totals.total > 0 ? (totals.done / totals.total) * 100 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const productPlans = vPlans.filter((p) => p.type === 'product');
|
||||||
|
if (productPlans.length > 0) {
|
||||||
|
const totals = productPlans.reduce((acc, p) => {
|
||||||
|
const linked = p.linkedRequirementIds || [];
|
||||||
|
const completed = p.completedRequirementIds || [];
|
||||||
|
acc.total += linked.length;
|
||||||
|
acc.done += completed.filter((id) => linked.includes(id)).length;
|
||||||
|
return acc;
|
||||||
|
}, { total: 0, done: 0 });
|
||||||
|
segments.push(totals.total > 0 ? (totals.done / totals.total) * 100 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uiPlans = vPlans.filter((p) => p.type === 'ui');
|
||||||
|
if (uiPlans.length > 0) {
|
||||||
|
const totals = uiPlans.reduce((acc, p) => {
|
||||||
|
const linked = p.linkedRequirementIds || [];
|
||||||
|
const completed = p.completedRequirementIds || [];
|
||||||
|
acc.total += linked.length;
|
||||||
|
acc.done += completed.filter((id) => linked.includes(id)).length;
|
||||||
|
return acc;
|
||||||
|
}, { total: 0, done: 0 });
|
||||||
|
segments.push(totals.total > 0 ? (totals.done / totals.total) * 100 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vDevTasks.length > 0) {
|
||||||
|
const totalEstimate = vDevTasks.reduce((sum, t) => sum + t.estimateHours, 0);
|
||||||
|
let devProgress: number;
|
||||||
|
if (totalEstimate === 0) {
|
||||||
|
devProgress = vDevTasks.reduce((sum, t) => sum + STATUS_PROGRESS[t.status], 0) / vDevTasks.length;
|
||||||
|
} else {
|
||||||
|
const weighted = vDevTasks.reduce((sum, t) => sum + t.estimateHours * STATUS_PROGRESS[t.status], 0);
|
||||||
|
devProgress = weighted / totalEstimate;
|
||||||
|
}
|
||||||
|
segments.push(devProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vTestCases.length > 0) {
|
||||||
|
const executed = vTestCases.filter((c) => c.status === 'passed' || c.status === 'failed' || c.status === 'blocked').length;
|
||||||
|
segments.push((executed / vTestCases.length) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
map[v.id] = segments.length > 0 ? Math.round(segments.reduce((s, x) => s + x, 0) / segments.length) : 0;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}, [project, plans, requirements, devTasks, testCases]);
|
||||||
|
|
||||||
const stats = useMemo(() => {
|
const stats = useMemo(() => {
|
||||||
if (!project) return { total: 0, developing: 0, released: 0, totalDays: 0, reqCount: 0, overtimeHours: 0 };
|
if (!project) return { total: 0, developing: 0, released: 0, totalDays: 0, reqCount: 0, overtimeHours: 0 };
|
||||||
const total = project.versions.length;
|
const total = project.versions.length;
|
||||||
const developing = project.versions.filter((v) => v.status === 'developing').length;
|
const developing = project.versions.filter((v) => v.status === 'developing').length;
|
||||||
const released = project.versions.filter((v) => v.status === 'released').length;
|
const released = project.versions.filter((v) => v.status === 'released').length;
|
||||||
const totalDays = project.versions.reduce((sum, v) => sum + (v.progress ?? []).reduce((s, p) => s + p.daysSpent, 0), 0);
|
const totalDays = project.versions.reduce((sum, v) => {
|
||||||
|
if (!v.startDate) return sum;
|
||||||
|
const start = new Date(v.startDate);
|
||||||
|
start.setHours(0, 0, 0, 0);
|
||||||
|
const end = v.status === 'released' && v.releaseDate ? new Date(v.releaseDate) : new Date();
|
||||||
|
end.setHours(0, 0, 0, 0);
|
||||||
|
return sum + Math.max(0, Math.floor((end.getTime() - start.getTime()) / (1000 * 60 * 60 * 24)));
|
||||||
|
}, 0);
|
||||||
const reqCount = requirements.filter((r) => r.projectId === projectId).length;
|
const reqCount = requirements.filter((r) => r.projectId === projectId).length;
|
||||||
const overtimeHours = Math.round(records.filter((r) => r.projectId === projectId).reduce((sum, r) => sum + r.duration, 0) * 10) / 10;
|
const overtimeHours = Math.round(records.filter((r) => r.projectId === projectId).reduce((sum, r) => sum + r.duration, 0) * 10) / 10;
|
||||||
return { total, developing, released, totalDays, reqCount, overtimeHours };
|
return { total, developing, released, totalDays, reqCount, overtimeHours };
|
||||||
@@ -283,7 +385,7 @@ export default function ProjectDetailPage() {
|
|||||||
{sortedVersions.length === 0 ? (
|
{sortedVersions.length === 0 ? (
|
||||||
<div className="rounded-xl border border-dashed border-[var(--line)] p-6 text-center text-xs text-[var(--ink-muted)]">暂无版本</div>
|
<div className="rounded-xl border border-dashed border-[var(--line)] p-6 text-center text-xs text-[var(--ink-muted)]">暂无版本</div>
|
||||||
) : (
|
) : (
|
||||||
sortedVersions.map((v) => <VersionCard key={v.id} version={v} onNavigate={(id) => router.push(`/versions/${id}`)} />)
|
sortedVersions.map((v) => <VersionCard key={v.id} version={v} progress={versionProgressMap[v.id] ?? 0} onNavigate={(id) => router.push(`/versions/${id}`)} />)
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -345,6 +345,14 @@ export default function VersionDetailPage() {
|
|||||||
stageProgress['testing'] = { percent: testPercent, status: allPassed ? 'done' : (hasRunning || executed > 0) ? 'active' : 'idle' };
|
stageProgress['testing'] = { percent: testPercent, status: allPassed ? 'done' : (hasRunning || executed > 0) ? 'active' : 'idle' };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BUG 阶段:已关闭Bug / 总Bug
|
||||||
|
if (versionBugs.length > 0) {
|
||||||
|
const closedBugs = versionBugs.filter((b) => b.status === 'closed' || b.status === 'rejected').length;
|
||||||
|
const bugPercent = Math.round((closedBugs / versionBugs.length) * 100);
|
||||||
|
const allClosed = versionBugs.every((b) => b.status === 'closed' || b.status === 'rejected');
|
||||||
|
stageProgress['bug'] = { percent: bugPercent, status: allClosed ? 'done' : closedBugs > 0 || versionBugs.length > 0 ? 'active' : 'idle' };
|
||||||
|
}
|
||||||
|
|
||||||
return <CapsuleStages stageProgress={stageProgress as any} />;
|
return <CapsuleStages stageProgress={stageProgress as any} />;
|
||||||
})()}
|
})()}
|
||||||
|
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ import { useRouter } from 'next/navigation';
|
|||||||
import { Search, Tag, Plus, X, ChevronDown, MoreHorizontal, Pause, Play, XCircle, Trash2 } from 'lucide-react';
|
import { Search, Tag, Plus, X, ChevronDown, MoreHorizontal, Pause, Play, XCircle, Trash2 } from 'lucide-react';
|
||||||
import { useProductStore } from '@/stores/useProductStore';
|
import { useProductStore } from '@/stores/useProductStore';
|
||||||
import { useRequirementStore } from '@/stores/useRequirementStore';
|
import { useRequirementStore } from '@/stores/useRequirementStore';
|
||||||
|
import { useVersionPlanStore } from '@/stores/useVersionPlanStore';
|
||||||
|
import { useDevTaskStore } from '@/stores/useDevTaskStore';
|
||||||
|
import { useTestCaseStore } from '@/stores/useTestCaseStore';
|
||||||
import { flattenVersions, flattenProjects } from '@/lib/derive';
|
import { flattenVersions, flattenProjects } from '@/lib/derive';
|
||||||
import type { VersionWithContext } from '@/lib/derive';
|
import type { VersionWithContext } from '@/lib/derive';
|
||||||
import { VersionStatus, VERSION_STATUS_LABEL, VERSION_STATUS_DOT, VERSION_STATUS_BG, getVersionDisplayStatus } from '@/lib/version-status';
|
import { VersionStatus, VERSION_STATUS_LABEL, VERSION_STATUS_DOT, VERSION_STATUS_BG, getVersionDisplayStatus } from '@/lib/version-status';
|
||||||
import { STAGES } from '@/lib/stage';
|
import { STAGES } from '@/lib/stage';
|
||||||
import { ROLE_LABEL } from '@/lib/stage';
|
import { ROLE_LABEL } from '@/lib/stage';
|
||||||
import { calcOverallProgress } from '@/lib/risk';
|
import { STATUS_PROGRESS } from '@/lib/dev-task';
|
||||||
import { calcHealthScore, getHealthLevel, calcRiskTags, HEALTH_LEVEL_COLOR, HEALTH_LEVEL_DOT, getTagStyle } from '@/lib/health';
|
import { calcHealthScore, getHealthLevel, calcRiskTags, HEALTH_LEVEL_COLOR, HEALTH_LEVEL_DOT, getTagStyle } from '@/lib/health';
|
||||||
import { Pagination, usePagination } from '@/components/Pagination';
|
import { Pagination, usePagination } from '@/components/Pagination';
|
||||||
|
|
||||||
@@ -38,7 +41,6 @@ const STATUS_TABS: { key: string; label: string }[] = [
|
|||||||
{ key: 'product_design', label: '产品设计' },
|
{ key: 'product_design', label: '产品设计' },
|
||||||
{ key: 'ui_design', label: 'UI设计' },
|
{ key: 'ui_design', label: 'UI设计' },
|
||||||
{ key: 'dev', label: '开发' },
|
{ key: 'dev', label: '开发' },
|
||||||
{ key: 'integration', label: '联调' },
|
|
||||||
{ key: 'testing', label: '测试' },
|
{ key: 'testing', label: '测试' },
|
||||||
{ key: 'released', label: '已发布' },
|
{ key: 'released', label: '已发布' },
|
||||||
{ key: 'paused', label: '已暂停' },
|
{ key: 'paused', label: '已暂停' },
|
||||||
@@ -84,7 +86,6 @@ const STAGE_ROLE_MAP: Record<string, string[]> = {
|
|||||||
product_design: ['product'],
|
product_design: ['product'],
|
||||||
ui_design: ['ui'],
|
ui_design: ['ui'],
|
||||||
dev: ['frontend', 'backend'],
|
dev: ['frontend', 'backend'],
|
||||||
integration: ['frontend', 'backend'],
|
|
||||||
testing: ['testing'],
|
testing: ['testing'],
|
||||||
released: [],
|
released: [],
|
||||||
};
|
};
|
||||||
@@ -112,9 +113,95 @@ export default function VersionsPage() {
|
|||||||
|
|
||||||
useEffect(() => { fetchOverview(); }, [fetchOverview]);
|
useEffect(() => { fetchOverview(); }, [fetchOverview]);
|
||||||
|
|
||||||
|
const { requirements, fetchRequirements, updateRequirement } = useRequirementStore();
|
||||||
|
useEffect(() => { fetchRequirements(); }, [fetchRequirements]);
|
||||||
|
|
||||||
|
const { plans, fetchPlans } = useVersionPlanStore();
|
||||||
|
useEffect(() => { fetchPlans(); }, [fetchPlans]);
|
||||||
|
|
||||||
|
const { tasks: devTasks, fetchTasks: fetchDevTasks } = useDevTaskStore();
|
||||||
|
useEffect(() => { fetchDevTasks(); }, [fetchDevTasks]);
|
||||||
|
|
||||||
|
const { testCases, fetchTestCases } = useTestCaseStore();
|
||||||
|
useEffect(() => { fetchTestCases(); }, [fetchTestCases]);
|
||||||
|
|
||||||
const allVersions = useMemo(() => flattenVersions(overview), [overview]);
|
const allVersions = useMemo(() => flattenVersions(overview), [overview]);
|
||||||
const allProjects = useMemo(() => flattenProjects(overview), [overview]);
|
const allProjects = useMemo(() => flattenProjects(overview), [overview]);
|
||||||
|
|
||||||
|
// Compute overall progress per version from actual data
|
||||||
|
const versionProgressMap = useMemo(() => {
|
||||||
|
const map: Record<string, number> = {};
|
||||||
|
for (const v of allVersions) {
|
||||||
|
const vPlans = plans.filter((p) => p.versionId === v.id);
|
||||||
|
const vReqs = requirements.filter((r) => r.versionId === v.id);
|
||||||
|
const vReqIds = new Set(vReqs.map((r) => r.id));
|
||||||
|
const vDevTasks = devTasks.filter((t) => vReqIds.has(t.requirementId));
|
||||||
|
const vTestCases = testCases.filter((c) => c.versionId === v.id);
|
||||||
|
|
||||||
|
const segments: number[] = [];
|
||||||
|
|
||||||
|
// Research plans progress
|
||||||
|
const researchPlans = vPlans.filter((p) => p.type === 'research');
|
||||||
|
if (researchPlans.length > 0) {
|
||||||
|
const totals = researchPlans.reduce((acc, p) => {
|
||||||
|
const tasks = p.tasks || [];
|
||||||
|
acc.total += tasks.length;
|
||||||
|
acc.done += tasks.filter((t) => t.status === 'completed').length;
|
||||||
|
return acc;
|
||||||
|
}, { total: 0, done: 0 });
|
||||||
|
segments.push(totals.total > 0 ? (totals.done / totals.total) * 100 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Product plans progress
|
||||||
|
const productPlans = vPlans.filter((p) => p.type === 'product');
|
||||||
|
if (productPlans.length > 0) {
|
||||||
|
const totals = productPlans.reduce((acc, p) => {
|
||||||
|
const linked = p.linkedRequirementIds || [];
|
||||||
|
const completed = p.completedRequirementIds || [];
|
||||||
|
acc.total += linked.length;
|
||||||
|
acc.done += completed.filter((id) => linked.includes(id)).length;
|
||||||
|
return acc;
|
||||||
|
}, { total: 0, done: 0 });
|
||||||
|
segments.push(totals.total > 0 ? (totals.done / totals.total) * 100 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UI plans progress
|
||||||
|
const uiPlans = vPlans.filter((p) => p.type === 'ui');
|
||||||
|
if (uiPlans.length > 0) {
|
||||||
|
const totals = uiPlans.reduce((acc, p) => {
|
||||||
|
const linked = p.linkedRequirementIds || [];
|
||||||
|
const completed = p.completedRequirementIds || [];
|
||||||
|
acc.total += linked.length;
|
||||||
|
acc.done += completed.filter((id) => linked.includes(id)).length;
|
||||||
|
return acc;
|
||||||
|
}, { total: 0, done: 0 });
|
||||||
|
segments.push(totals.total > 0 ? (totals.done / totals.total) * 100 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dev tasks progress (weighted by STATUS_PROGRESS)
|
||||||
|
if (vDevTasks.length > 0) {
|
||||||
|
const totalEstimate = vDevTasks.reduce((sum, t) => sum + t.estimateHours, 0);
|
||||||
|
let devProgress: number;
|
||||||
|
if (totalEstimate === 0) {
|
||||||
|
devProgress = vDevTasks.reduce((sum, t) => sum + STATUS_PROGRESS[t.status], 0) / vDevTasks.length;
|
||||||
|
} else {
|
||||||
|
const weighted = vDevTasks.reduce((sum, t) => sum + t.estimateHours * STATUS_PROGRESS[t.status], 0);
|
||||||
|
devProgress = weighted / totalEstimate;
|
||||||
|
}
|
||||||
|
segments.push(devProgress);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test cases progress (executed / total)
|
||||||
|
if (vTestCases.length > 0) {
|
||||||
|
const executed = vTestCases.filter((c) => c.status === 'passed' || c.status === 'failed' || c.status === 'blocked').length;
|
||||||
|
segments.push((executed / vTestCases.length) * 100);
|
||||||
|
}
|
||||||
|
|
||||||
|
map[v.id] = segments.length > 0 ? Math.round(segments.reduce((s, x) => s + x, 0) / segments.length) : 0;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}, [allVersions, plans, requirements, devTasks, testCases]);
|
||||||
|
|
||||||
const filtered = useMemo(() => {
|
const filtered = useMemo(() => {
|
||||||
let list = allVersions.filter((v) => {
|
let list = allVersions.filter((v) => {
|
||||||
if (search && !v.name.toLowerCase().includes(search.toLowerCase())) return false;
|
if (search && !v.name.toLowerCase().includes(search.toLowerCase())) return false;
|
||||||
@@ -139,9 +226,6 @@ export default function VersionsPage() {
|
|||||||
|
|
||||||
const { paged, page, setPage, total, pageSize, setPageSize } = usePagination(filtered, 20);
|
const { paged, page, setPage, total, pageSize, setPageSize } = usePagination(filtered, 20);
|
||||||
|
|
||||||
const { requirements, fetchRequirements, updateRequirement } = useRequirementStore();
|
|
||||||
useEffect(() => { fetchRequirements(); }, [fetchRequirements]);
|
|
||||||
|
|
||||||
const handleAction = async (version: VersionWithContext, action: 'pause' | 'resume' | 'close' | 'delete') => {
|
const handleAction = async (version: VersionWithContext, action: 'pause' | 'resume' | 'close' | 'delete') => {
|
||||||
setOpenMenuId(null);
|
setOpenMenuId(null);
|
||||||
if (action === 'delete') {
|
if (action === 'delete') {
|
||||||
@@ -264,6 +348,7 @@ export default function VersionsPage() {
|
|||||||
<VersionRow
|
<VersionRow
|
||||||
key={v.id}
|
key={v.id}
|
||||||
version={v}
|
version={v}
|
||||||
|
overallProgress={versionProgressMap[v.id] ?? 0}
|
||||||
openMenuId={openMenuId}
|
openMenuId={openMenuId}
|
||||||
setOpenMenuId={setOpenMenuId}
|
setOpenMenuId={setOpenMenuId}
|
||||||
onNavigate={() => router.push(`/versions/${v.id}`)}
|
onNavigate={() => router.push(`/versions/${v.id}`)}
|
||||||
@@ -286,15 +371,15 @@ export default function VersionsPage() {
|
|||||||
|
|
||||||
interface VersionRowProps {
|
interface VersionRowProps {
|
||||||
version: VersionWithContext;
|
version: VersionWithContext;
|
||||||
|
overallProgress: number;
|
||||||
openMenuId: string | null;
|
openMenuId: string | null;
|
||||||
setOpenMenuId: (id: string | null) => void;
|
setOpenMenuId: (id: string | null) => void;
|
||||||
onNavigate: () => void;
|
onNavigate: () => void;
|
||||||
onAction: (version: VersionWithContext, action: 'pause' | 'resume' | 'close' | 'delete') => void;
|
onAction: (version: VersionWithContext, action: 'pause' | 'resume' | 'close' | 'delete') => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function VersionRow({ version, openMenuId, setOpenMenuId, onNavigate, onAction }: VersionRowProps) {
|
function VersionRow({ version, overallProgress, openMenuId, setOpenMenuId, onNavigate, onAction }: VersionRowProps) {
|
||||||
const priority = (version.priority ?? 'P2') as Priority;
|
const priority = (version.priority ?? 'P2') as Priority;
|
||||||
const overallProgress = calcOverallProgress(version.progress);
|
|
||||||
const healthScore = calcHealthScore(version.status, version.startDate, version.expectedReleaseDate, version.progress);
|
const healthScore = calcHealthScore(version.status, version.startDate, version.expectedReleaseDate, version.progress);
|
||||||
const healthLevel = getHealthLevel(healthScore);
|
const healthLevel = getHealthLevel(healthScore);
|
||||||
const riskTags = calcRiskTags(version.status, version.startDate, version.expectedReleaseDate, version.progress, version.currentStage, version.members);
|
const riskTags = calcRiskTags(version.status, version.startDate, version.expectedReleaseDate, version.progress, version.currentStage, version.members);
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ const STAGE_ROLE_MAP: Record<string, Role[]> = {
|
|||||||
product_design: ['product'],
|
product_design: ['product'],
|
||||||
ui_design: ['ui'],
|
ui_design: ['ui'],
|
||||||
dev: ['frontend', 'backend'],
|
dev: ['frontend', 'backend'],
|
||||||
integration: ['frontend', 'backend'],
|
|
||||||
testing: ['testing'],
|
testing: ['testing'],
|
||||||
|
bug: [],
|
||||||
released: [],
|
released: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
export type Stage = 'requirement' | 'product_design' | 'ui_design' | 'dev' | 'integration' | 'testing' | 'released';
|
export type Stage = 'requirement' | 'product_design' | 'ui_design' | 'dev' | 'testing' | 'bug' | 'released';
|
||||||
|
|
||||||
export type Role = 'product' | 'ui' | 'frontend' | 'backend' | 'testing';
|
export type Role = 'product' | 'ui' | 'frontend' | 'backend' | 'testing';
|
||||||
|
|
||||||
@@ -7,8 +7,8 @@ export const STAGES: { key: Stage; label: string }[] = [
|
|||||||
{ key: 'product_design', label: '产品设计' },
|
{ key: 'product_design', label: '产品设计' },
|
||||||
{ key: 'ui_design', label: 'UI 设计' },
|
{ key: 'ui_design', label: 'UI 设计' },
|
||||||
{ key: 'dev', label: '开发' },
|
{ key: 'dev', label: '开发' },
|
||||||
{ key: 'integration', label: '联调' },
|
|
||||||
{ key: 'testing', label: '测试' },
|
{ key: 'testing', label: '测试' },
|
||||||
|
{ key: 'bug', label: 'BUG' },
|
||||||
{ key: 'released', label: '上线' },
|
{ key: 'released', label: '上线' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|||||||
@@ -29,15 +29,12 @@ export const STAGE_LABEL: Record<string, string> = {
|
|||||||
product_design: '产品设计中',
|
product_design: '产品设计中',
|
||||||
ui_design: 'UI设计中',
|
ui_design: 'UI设计中',
|
||||||
dev: '开发中',
|
dev: '开发中',
|
||||||
integration: '联调中',
|
|
||||||
testing: '测试中',
|
testing: '测试中',
|
||||||
|
bug: 'BUG跟进中',
|
||||||
released: '已发布',
|
released: '已发布',
|
||||||
};
|
};
|
||||||
|
|
||||||
export function getVersionDisplayStatus(status: VersionStatus, currentStage?: string): string {
|
export function getVersionDisplayStatus(status: VersionStatus, _currentStage?: string): string {
|
||||||
if (status === 'developing' && currentStage && STAGE_LABEL[currentStage]) {
|
|
||||||
return STAGE_LABEL[currentStage];
|
|
||||||
}
|
|
||||||
return VERSION_STATUS_LABEL[status];
|
return VERSION_STATUS_LABEL[status];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user