'use client'; import { useState } from 'react'; import { CheckCircle2, CircleAlert, Send } from 'lucide-react'; import type { Demand } from '@/lib/demand'; import { currentProposal, reviewStage, type ReviewProposal } from '@/lib/demand-review'; import { pendingChange } from '@/lib/workflow'; import { AttachmentList } from './attachments'; import type { SaveInput } from './form'; const date = (value: string) => new Date(value).toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai', hour12: false }); function ProposalContent({ proposal }: { proposal: ReviewProposal }) { return <>
实施范围与功能说明

{proposal.scope}

范围外事项

{proposal.outOfScope}

{(proposal.businessAttachments?.length??0)>0&&
此方案评审时的附件
}

由 {proposal.developer.displayName}({proposal.developer.username})提交 · {date(proposal.submittedAt)}

{proposal.decision &&

{proposal.decision.actor.displayName}({proposal.decision.actor.username})于 {date(proposal.decision.time)} {proposal.decision.result === 'confirmed' ? '确认同意实施' : '退回修改'}{proposal.decision.comment ? `:${proposal.decision.comment}` : ''}

} {proposal.invalidated &&

此版本已失效:{proposal.invalidated.reason}({date(proposal.invalidated.time)})

} ; } export function DemandReviewPanel({ d, onAction, busy, onDirtyChange }: { d: Demand; onAction: (body: SaveInput) => Promise; busy: boolean; onDirtyChange: (dirty: boolean) => void }) { const proposal = currentProposal(d); const stage = reviewStage(d); const business = d.access?.business ?? true; const ready = d.status === '待评审' && d.reviewReady; const canPropose = ready && d.access?.developer && ['待开发提出方案', '待开发修改方案'].includes(stage); const canDecide = ready && business && proposal && !proposal.invalidated && !proposal.decision; const canReopen = ready && business && proposal && !proposal.invalidated && proposal.decision?.result === 'confirmed'; const [scope, setScope] = useState(proposal?.scope ?? d.fields.scope); const [outOfScope, setOutOfScope] = useState(proposal?.outOfScope ?? d.fields.outOfScope); const [comment, setComment] = useState(''); const [confirm, setConfirm] = useState(false); const [takeoverConfirmed, setTakeoverConfirmed] = useState(false); const [error, setError] = useState(''); function dirty() { onDirtyChange(true); setError(''); } async function act(action: string) { setError(''); if (action === 'propose-solution' && (!scope.trim() || !outOfScope.trim())) { setError('请填写实施范围与功能说明、范围外事项;无范围外事项请填“无”。'); return; } if (action === 'confirm-solution' && !confirm) { setError('请勾选确认同意按当前方案实施。'); return; } if (action === 'return-solution' && !comment.trim()) { setError('请填写具体的修改意见。'); return; } if (action === 'take-over-development' && !takeoverConfirmed) { setError('请确认接手后的评审和排期安排。'); return; } try { await onAction({ action, id: d.id, revision: d.revision, scope, outOfScope, proposalVersion: proposal?.version, confirm: action === 'take-over-development' ? takeoverConfirmed : confirm, comment }); } catch { /* The parent preserves input and displays the API error. */ } } return

需求评审

{stage}

开发责任人提出实施范围与功能说明、范围外事项,业务方核对后确认。每次提交保留独立方案版本。

{error &&
{error}
} {!d.reviewReady &&

请先补齐业务材料并提交评审,开发负责人默认由系统管理员担任,无需填写。

}
开发负责人

{d.review ? `${d.review.developer.displayName}(${d.review.developer.username})` : '系统管理员'}

开发负责人默认由系统管理员担任,无需填写。业务确认由需求登记账号操作;开发负责人负责方案、排期、开发提测、发布与归档。

{d.access?.canTakeOverDevelopment &&

原开发账号已停用或不可用,你可以使用当前管理员账号接手。接手后回到待评审,重新确认方案和排期,再提测验收;历史记录保留。

{pendingChange(d) ?

请先由业务方在“需求变更”中处理或撤回待确认变更,再接手开发职责。

: <> }
}
{(d.attachments?.length??0)>0&&

当前参考附件

} {proposal ?

方案 v{proposal.version}

: (d.fields.scope || d.fields.outOfScope) ?

原有方案内容

历史内容已保留,尚无本次评审确认记录。开发责任人可据此提交正式方案。

实施范围与功能说明

{d.fields.scope || '待补充'}

范围外事项

{d.fields.outOfScope || '待补充'}

: d.review && !canPropose ?

等待 {d.review.developer.displayName} 提交方案,提交后业务方可在此确认或退回修改。

: null} {canPropose &&

{proposal ? '修改并提交新版本' : '填写评审方案'}