feat(版本): 优化概览与只读状态
关键改动: - 增加需求排序和版本只读状态规则及测试 - 完善版本概览阶段耗时、项目页和工作台展示 - 优化小宝预警请求节流、建议状态和风险过滤 Co-Authored-By: Codex GPT-5 <codex@openai.com>
This commit is contained in:
@@ -43,6 +43,7 @@ interface Props {
|
||||
onUpdate: (id: string, data: Partial<VersionPlan>) => void;
|
||||
onComplete: (id: string, result: PlanResultPayload) => { ok: boolean; message?: string } | void;
|
||||
onDelete: (id: string) => void;
|
||||
readOnly?: boolean;
|
||||
}
|
||||
|
||||
const TYPE_LABEL = { research: '调研', product: '产品方案', ui: 'UI设计' };
|
||||
@@ -71,7 +72,7 @@ function getFailureLabels(types?: ProductPlanReviewFailureType[]): string[] {
|
||||
.filter(Boolean) as string[];
|
||||
}
|
||||
|
||||
export function PlanTab({ plans, versionId, version, versionDeadline, currentUserName, planType, versionMembers, linkedRequirements, allRequirements, onCreate, onUpdate, onComplete, onDelete }: Props) {
|
||||
export function PlanTab({ plans, versionId, version, versionDeadline, currentUserName, planType, versionMembers, linkedRequirements, allRequirements, onCreate, onUpdate, onComplete, onDelete, readOnly = false }: Props) {
|
||||
const [showCreateModal, setShowCreateModal] = useState(false);
|
||||
const [editingPlan, setEditingPlan] = useState<VersionPlan | null>(null);
|
||||
const [completingPlan, setCompletingPlan] = useState<VersionPlan | null>(null);
|
||||
@@ -321,10 +322,11 @@ export function PlanTab({ plans, versionId, version, versionDeadline, currentUse
|
||||
onEditPlan={setEditingPlan}
|
||||
onOpenComplete={setCompletingPlan}
|
||||
onCreatePlan={() => setShowCreateModal(true)}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
)}
|
||||
|
||||
{(showCreateModal || editingPlan) && (
|
||||
{(showCreateModal || editingPlan) && !readOnly && (
|
||||
<PlanFormModal
|
||||
initial={editingPlan}
|
||||
planType={planType}
|
||||
@@ -343,7 +345,7 @@ export function PlanTab({ plans, versionId, version, versionDeadline, currentUse
|
||||
/>
|
||||
)}
|
||||
|
||||
{completingPlan && (
|
||||
{completingPlan && !readOnly && (
|
||||
<CompleteModal
|
||||
plan={completingPlan}
|
||||
onClose={() => setCompletingPlan(null)}
|
||||
@@ -402,6 +404,7 @@ function ProductUiPlanWorkspace({
|
||||
onEditPlan,
|
||||
onOpenComplete,
|
||||
onCreatePlan,
|
||||
readOnly,
|
||||
}: {
|
||||
typePlans: VersionPlan[];
|
||||
planType: VersionPlan['type'];
|
||||
@@ -421,6 +424,7 @@ function ProductUiPlanWorkspace({
|
||||
onEditPlan: (plan: VersionPlan) => void;
|
||||
onOpenComplete: (plan: VersionPlan) => void;
|
||||
onCreatePlan: () => void;
|
||||
readOnly: boolean;
|
||||
}) {
|
||||
const [selectedPlanId, setSelectedPlanId] = useState<string | null>(typePlans[0]?.id ?? null);
|
||||
const selectedPlan = typePlans.find((plan) => plan.id === selectedPlanId) ?? typePlans[0];
|
||||
@@ -428,23 +432,26 @@ function ProductUiPlanWorkspace({
|
||||
const allLogs = useMemo(() => getPlanLogsForPlans(typePlans), [typePlans]);
|
||||
|
||||
useEffect(() => {
|
||||
if (readOnly) return;
|
||||
typePlans.forEach((plan) => {
|
||||
const { autoStarted } = getPlanRuntime(plan);
|
||||
if (autoStarted && !plan.actualStartAt) {
|
||||
onUpdate(plan.id, { status: 'in_progress' });
|
||||
}
|
||||
});
|
||||
}, [typePlans, onUpdate]);
|
||||
}, [typePlans, onUpdate, readOnly]);
|
||||
|
||||
return (
|
||||
<div className="flex h-full min-h-0">
|
||||
<aside className="flex h-full w-72 shrink-0 flex-col border-r border-[var(--line)] bg-[var(--bg-card)]">
|
||||
<div className="flex h-14 shrink-0 items-center justify-between gap-2 border-b border-[var(--line)] px-4">
|
||||
<div className="text-[14px] font-semibold text-[var(--ink)]">任务计划</div>
|
||||
<button onClick={onCreatePlan} className="flex h-7 items-center gap-1.5 rounded-md bg-[var(--accent)] px-2.5 text-[11px] font-medium text-white shadow-[var(--shadow-sm)] hover:bg-[var(--accent-hover)] transition-colors">
|
||||
<Plus className="h-3.5 w-3.5" strokeWidth={2} />
|
||||
新建
|
||||
</button>
|
||||
{!readOnly && (
|
||||
<button onClick={onCreatePlan} className="flex h-7 items-center gap-1.5 rounded-md bg-[var(--accent)] px-2.5 text-[11px] font-medium text-white shadow-[var(--shadow-sm)] hover:bg-[var(--accent-hover)] transition-colors">
|
||||
<Plus className="h-3.5 w-3.5" strokeWidth={2} />
|
||||
新建
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
<div className="shrink-0 space-y-2 border-b border-[var(--line)] p-3">
|
||||
<div className={`grid gap-2 ${versionDeadline ? 'grid-cols-2' : 'grid-cols-1'}`}>
|
||||
@@ -530,6 +537,7 @@ function ProductUiPlanWorkspace({
|
||||
onDelete={onDelete}
|
||||
onEditPlan={onEditPlan}
|
||||
onOpenComplete={onOpenComplete}
|
||||
readOnly={readOnly}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-full items-center justify-center text-[13px] text-[var(--ink-muted)]">
|
||||
@@ -563,6 +571,7 @@ function ProductUiPlanDetail({
|
||||
onDelete,
|
||||
onEditPlan,
|
||||
onOpenComplete,
|
||||
readOnly,
|
||||
}: {
|
||||
plan: VersionPlan;
|
||||
planType: VersionPlan['type'];
|
||||
@@ -579,12 +588,13 @@ function ProductUiPlanDetail({
|
||||
onDelete: (id: string) => void;
|
||||
onEditPlan: (plan: VersionPlan) => void;
|
||||
onOpenComplete: (plan: VersionPlan) => void;
|
||||
readOnly: boolean;
|
||||
}) {
|
||||
const now = new Date().toISOString();
|
||||
const { autoStarted, effectiveStatus, effectiveStartAt } = getPlanRuntime(plan);
|
||||
const durText = getPlanDurationText(plan, effectiveStatus, effectiveStartAt, now);
|
||||
const completionState = getPlanCompletionState(plan);
|
||||
const canEditCoverage = canEditPlanRequirementCoverage(plan);
|
||||
const canEditCoverage = !readOnly && canEditPlanRequirementCoverage(plan);
|
||||
const requirementOptions = mergeSelectedRequirementOptions(linkedRequirements ?? [], allRequirements ?? [], plan.linkedRequirementIds ?? []);
|
||||
const selectedRequirements = (plan.linkedRequirementIds ?? [])
|
||||
.map((rid) => requirementOptions.find((requirement) => requirement.id === rid))
|
||||
@@ -612,26 +622,28 @@ function ProductUiPlanDetail({
|
||||
</div>
|
||||
<div className="mt-1 text-[11px] text-[var(--ink-muted)]">{TYPE_LABEL[plan.type]}</div>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
{plan.status === 'pending' && !autoStarted && (
|
||||
<button onClick={() => onUpdate(plan.id, { status: 'in_progress' })} className="flex h-7 items-center gap-1 rounded-md border border-blue-200 px-2 text-[11px] font-medium text-blue-600 hover:bg-blue-50" title="提前开始">
|
||||
<Play className="h-3 w-3" />开始
|
||||
</button>
|
||||
)}
|
||||
{plan.status !== 'completed' && (
|
||||
<>
|
||||
<button onClick={() => onSetTransferPlanId(plan.id)} className="flex h-7 w-7 items-center justify-center rounded-md text-blue-500 hover:bg-blue-50" title="转交">
|
||||
<ArrowRightLeft className="h-3.5 w-3.5" />
|
||||
{!readOnly && (
|
||||
<div className="flex shrink-0 items-center gap-1">
|
||||
{plan.status === 'pending' && !autoStarted && (
|
||||
<button onClick={() => onUpdate(plan.id, { status: 'in_progress' })} className="flex h-7 items-center gap-1 rounded-md border border-blue-200 px-2 text-[11px] font-medium text-blue-600 hover:bg-blue-50" title="提前开始">
|
||||
<Play className="h-3 w-3" />开始
|
||||
</button>
|
||||
<button onClick={() => onEditPlan(plan)} className="flex h-7 w-7 items-center justify-center rounded-md text-[var(--ink-muted)] hover:bg-[var(--bg-subtle)]" title="编辑">
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button onClick={() => onDelete(plan.id)} className="flex h-7 w-7 items-center justify-center rounded-md text-red-500 hover:bg-red-50" title="删除">
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{plan.status !== 'completed' && (
|
||||
<>
|
||||
<button onClick={() => onSetTransferPlanId(plan.id)} className="flex h-7 w-7 items-center justify-center rounded-md text-blue-500 hover:bg-blue-50" title="转交">
|
||||
<ArrowRightLeft className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button onClick={() => onEditPlan(plan)} className="flex h-7 w-7 items-center justify-center rounded-md text-[var(--ink-muted)] hover:bg-[var(--bg-subtle)]" title="编辑">
|
||||
<Pencil className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
<button onClick={() => onDelete(plan.id)} className="flex h-7 w-7 items-center justify-center rounded-md text-red-500 hover:bg-red-50" title="删除">
|
||||
<Trash2 className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<dl className="mt-4 grid grid-cols-1 gap-3 text-[12px] sm:grid-cols-2 xl:grid-cols-4">
|
||||
@@ -676,7 +688,7 @@ function ProductUiPlanDetail({
|
||||
<a href={plan.resultUrl} target="_blank" rel="noopener noreferrer" className="flex min-w-0 items-center gap-1 text-[12px] text-[var(--accent)] hover:underline">
|
||||
<span className="truncate">{plan.resultTitle || plan.resultFileName || '查看成果'}</span><ExternalLink className="h-3 w-3 shrink-0" />
|
||||
</a>
|
||||
{planType === 'product' && version && (
|
||||
{planType === 'product' && version && !readOnly && (
|
||||
<AiDecomposeButton plan={plan} version={version} />
|
||||
)}
|
||||
</div>
|
||||
@@ -720,7 +732,7 @@ function ProductUiPlanDetail({
|
||||
<p className="mt-3 text-[11px] text-[var(--ink-muted)]">还不能提交成果:{completionState.missingReasons.join('、')}</p>
|
||||
)}
|
||||
|
||||
{transferPlanId === plan.id && (
|
||||
{transferPlanId === plan.id && !readOnly && (
|
||||
<div className="mt-3 flex items-center gap-2 border-t border-[var(--line)] pt-3">
|
||||
<span className="text-[11px] text-[var(--ink-muted)]">转交给:</span>
|
||||
<FilterSelect
|
||||
@@ -735,7 +747,7 @@ function ProductUiPlanDetail({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{plan.status !== 'completed' && completionState.canSubmitResult && (
|
||||
{plan.status !== 'completed' && completionState.canSubmitResult && !readOnly && (
|
||||
<div className="mt-3 flex items-center justify-between rounded-lg border border-green-200 bg-green-50 px-3 py-2">
|
||||
<span className="text-[12px] text-green-700">已满足{getSubmitActionLabel(plan)}条件</span>
|
||||
<button onClick={() => onOpenComplete(plan)} className="text-[11px] font-medium text-green-700 underline hover:text-green-900">{getSubmitActionLabel(plan)}</button>
|
||||
|
||||
Reference in New Issue
Block a user