refactor(release-ui): 发布页改成三块 + 一个折叠抽屉,删掉全部步骤脚手架

用户反馈「界面还是没优化,步骤太多」。上一轮只把动作合成了一键发布,但页面上仍铺着
7 步流程条、步骤编号、引导卡、分区页签和统计卡——用户看到的是"还有很多步要做"。

- 默认视图只剩三块:生产状态条 → 待发布(主操作,每行「发布到生产」+ 批量)→ 发布记录
  (查看结果/重排/回滚)。
- 待审核仅在有待审条目时出现(对内已自动批准,happy path 上通常不出现);已驳回收进折叠。
- 发布计划、下架选择、冻结清单、批次清单全部收进「<details>更多」,仍是完整能力,只是不再挡路。
- 删除 7 步流程条、步骤编号标题、引导卡、分区页签、四格统计卡。
- 保留全部安全信号:门禁/快照状态条、执行阶段与批次进度、审核策略说明、删除二次确认、
  固定确认语句弹窗、"锁定清单 ≠ 上线"。
- 测试:新增"步骤脚手架不得出现"回归断言(7 步流程条/步骤编号/引导卡/页签 class 一律不得渲染);
  183 条前端测试 + tsc 全过。

自测(面板实测):待发布里点「发布到生产」→ 输 publish-to-production → 确认 →
批次 rb-7088588bac30a109cfaae357d4095ffe(sealed) + 执行 rx-bceb1ca9c1ecdd088e541bad2ebe9d7f
(completed 1/1,项级 verified、production_revision=rv-934f2a64724611e0f50cccadf9a30f87);
再在页面上回滚 → rx-2618de118a7efabea34cdb8fdb384c20(rolled_back 1/1、项级 absent)。
This commit is contained in:
姚章浩
2026-10-10 16:05:51 +08:00
parent f8faed0b21
commit eca7fee5a8
2 changed files with 124 additions and 164 deletions
+12 -19
View File
@@ -353,41 +353,34 @@ describe('ReleaseManagement', () => {
releasePlan={releasePlan}
selectedDeleteIDs={['tp-delete']} onToggleDelete={vi.fn()}
/>)
for (const text of ['来源与目录 → 测试知识库 → 生产知识库','自动发布计划','新增 1','更新 0','删除 1','未变化 11284','B.pdf','C.pdf','D.pdf','将从生产检索中移除','我确认所选删除项会停止生产检索','已选择删除:1(待确认)','已选 1 项(删除待确认)','为什么按钮不能点:请确认所选删除项会停止生产检索;至少 1 项动作通过确认;请填写批次名称','至少 1 项动作通过确认','来源当前不可用,保留生产知识','正在执行自动回滚','批次 1 / 1','每批最多 50 项','Snapshot #20260906-090000Z','审核要发布的知识', '需人工确认', '批准', '驳回', '创建并锁定清单', '锁定清单(不会上线)', 'Synthetic batch', '删除生产知识', '已从生产检索中移除', '已恢复生产知识', '仍可检查调整', 'Release Worker保持关闭', '锁定清单 ≠ 上线', '生产确认、发布验证与回滚', '生产操作权限:已阻断', '生产请求门禁已开启', '快照恢复验证未通过', '生产发布已阻断']) {
for (const text of ['来源与目录 → 测试知识库 → 生产知识库','发布计划','新增 1','更新 0','删除 1','未变化 11284','B.pdf','C.pdf','D.pdf','将从生产检索中移除','我确认所选删除项会停止生产检索','待发布(0 + 下架 1)','已选 1 项(删除待确认)','为什么按钮不能点:请确认所选删除项会停止生产检索;至少 1 项动作通过确认;请填写批次名称','至少 1 项动作通过确认','来源当前不可用,保留生产知识','正在执行自动回滚','批次 1 / 1','每批最多 50 项','Snapshot #20260906-090000Z','待你审核', '需人工确认', '批准', '驳回', '创建并锁定清单', '锁定清单(不会上线)', 'Synthetic batch', '删除生产知识', '已从生产检索中移除', '已恢复生产知识', '仍可检查调整', 'Release Worker 默认关闭', '锁定清单 ≠ 上线', '生产确认、发布验证与回滚', '生产操作权限:已阻断', '生产请求门禁已开启', '快照恢复验证未通过', '生产发布已阻断']) {
expect(html).toContain(text)
}
// 需求(2026-10-10):发布界面要简单——不再显示步骤脚手架/流程编号/引导卡。
for (const text of [
'从检查到发布,只走这 7 步',
'1. 查看来源变化',
'2. 确认测试结果',
'3. 审核发布内容',
'4. 创建并锁定发布清单',
'4. 创建并锁定发布清单',
'5. 生产负责人确认',
'6. 发布并验证',
'7. 必要时回滚',
'当前在第 3 步,共 7 步',
'现在要做:审核 1 项知识',
'还有 1 项等待审核;已批准文件可先创建批次',
'完成本步的 3 件事',
'只审核本次准备发布的文件',
'勾选要发布的已批准知识',
'填写批次名称后创建(创建即冻结并锁定清单)',
'现在先做:逐条选择“批准”或“驳回”(操作自动记在当前登录人名下)',
'完成后进入:第 4 步,创建并锁定发布清单',
'为什么按钮不能点:请确认所选删除项会停止生产检索',
'当前在第',
'共 7 步',
'现在要做:',
'完成本步的',
'完成后进入:第',
'如何决定批准或驳回',
'可以批准:基础测试通过,你已确认搜索结果相关,而且发布范围正确',
'应该驳回:内容错误、过期、敏感、搜索结果不相关,或者你无法确认',
'创建批次还需要',
'确认所选发布动作',
'查看审核与发布说明',
'至少 1 项动作通过确认',
'填写批次名称',
'普通业务操作,不会影响生产',
'生产危险操作',
'module-tabs',
'release-journey',
'release-guidance',
'guidance-step',
]) {
expect(html).toContain(text)
expect(html).not.toContain(text)
}
expect(html).not.toContain('>授权生产发布</button>')
expect(html).not.toContain('knowledge_id')
+112 -145
View File
@@ -924,184 +924,151 @@ export function ReleaseManagement(props: ReleaseManagementProps) {
setSelectedIDs((current) => current.includes(publicationID) ? current.filter((id) => id !== publicationID) : [...current, publicationID])
}
// 待发布 = 已批准且门禁通过,可以直接发。待审核 = 尚未决定(对内通常已由系统自动批准,所以多为空)。
const publishReady = props.reviewPage.items.filter((item) => item.review_state === 'approved' && item.gate_status === 'ready')
const pendingItems = props.reviewPage.items.filter((item) => item.review_state === 'pending')
const rejectedItems = props.reviewPage.items.filter((item) => item.review_state === 'rejected')
const publishableSelected = selectedIDs.filter((id) => publishReady.some((item) => item.publication_id === id))
const selectedDeleteIDs = props.selectedDeleteIDs.filter(() => deleteConfirmed)
const publishSelectedIDs = [...publishableSelected, ...selectedDeleteIDs]
const startPublish = (ids: string[], label: string, deleteIDs: string[] = []) => props.onStartReleaseAction?.('publish_now', 'publish-now', label, ids, deleteIDs)
// 计划表筛选与分页(默认视图里这块在「更多」里,保留筛选与分页以免一次渲染上百行)。
const planFiltered = props.releasePlan.items.filter((item) => {
if (planOnlyReleasable && !item.can_release) return false
if (planActionFilter === 'blocked' ? item.can_release : planActionFilter ? item.action !== planActionFilter : false) return false
if (planScopeFilter && item.target_scope !== planScopeFilter) return false
return true
})
const actionLabel = (item: ReleasePlanItem) => item.action === 'add' ? '新增' : item.action === 'update' ? '更新' : item.action === 'delete' ? '删除' : '等待测试'
const planPageCount = Math.max(1, Math.ceil(planFiltered.length / planPageSize))
const planSafePage = Math.min(planPage, planPageCount - 1)
const planPageItems = planFiltered.slice(planSafePage * planPageSize, planSafePage * planPageSize + planPageSize)
return <main className="page-shell release-page">
<header className="hero compact">
<div>
<h1>发布管理</h1>
<p className="subtitle">测试知识库与生产知识库的同步。生产发布仍由独立门禁、备份和负责人确认保护。</p>
<p className="subtitle">挑一条知识点“发布到生产”,输入确认语句即可。生产发布仍由门禁、备份快照与负责人确认保护。</p>
</div>
<div className="release-actions"><button type="button" onClick={() => { props.onReviewRefresh(); props.onBatchRefresh(); props.onExecutionRefresh() }} disabled={props.reviewLoading || props.batchLoading || props.executionLoading}>刷新当前页面</button></div>
<div className="release-actions"><button type="button" onClick={() => { props.onReviewRefresh(); props.onBatchRefresh(); props.onExecutionRefresh() }} disabled={props.reviewLoading || props.batchLoading || props.executionLoading}>刷新</button></div>
</header>
<nav className="module-tabs" aria-label="发布管理分区"><a className="active" href="#release-plan">发布计划</a><a href="#batch-actions">发布清单</a><a href="#release-execution">执行进度与历史</a></nav>
<section className="release-snapshot-callout"><span aria-hidden="true">ⓘ</span><div><strong>{props.releaseCapabilities.production_backup_restore_verified ? '发布前将创建可恢复快照' : '生产发布当前不可执行'}</strong><small>{props.releaseCapabilities.production_backup_restore_verified ? '发布失败时系统会按已验证的快照执行回滚。' : '尚未通过生产备份恢复验证,当前只能审核和锁定发布清单。'}</small></div></section>
<details className="release-help"><summary>查看审核与发布说明</summary>
<section className="release-journey" aria-label="发布流程">
<div className="journey-heading"><div><span>操作顺序</span><h2>从检查到发布,只走这 7 步</h2></div><p>蓝色是当前步骤;绿色表示已完成;红色步骤会修改生产环境。</p></div>
<ol className="journey-steps">
{releaseFlowSteps.map((item, index) => {
const number = index + 1
const state = number < guidance.step ? 'done' : number === guidance.step ? 'current' : 'upcoming'
const danger = number >= 6
return <li key={item.title} className={`journey-step ${state}${danger ? ' danger' : ''}`} aria-current={state === 'current' ? 'step' : undefined}>
<span className="step-number">{number < guidance.step ? '✓' : number}</span>
<strong>{item.title}</strong>
<small>{item.kind}</small>
</li>
})}
</ol>
</section>
<section className="current-guidance" aria-label="当前阶段">
<div className="guidance-step">当前在第 {guidance.step} 步,共 7 步</div>
<div className="guidance-copy">
<h2>{guidance.title}</h2>
<strong>{guidance.reason}</strong>
{guidance.step === 3 ? <div className="current-checklist"><b>完成本步的 3 件事</b><ol><li>只审核本次准备发布的文件</li><li>勾选要发布的已批准知识</li><li>填写批次名称后创建(创建即冻结并锁定清单)</li></ol></div> : null}
<p>{`现在先做:${guidance.action}`}</p>
<p>{`完成后进入:${guidance.after}`}</p>
<span>{guidance.impact}</span>
</div>
<a className="primary-link" href={guidance.href}>{guidance.step === 3 ? '滚动到审核列表' : guidance.button}</a>
</section>
</details>
<section className="safety-strip" id="production-status">
<div><strong>{productionStatus}</strong><span>{props.releaseCapabilities.production_release_requests_enabled && !props.releaseCapabilities.production_backup_restore_verified ? '生产发布已阻断:先完成生产快照并通过恢复验证。' : '锁定清单只表示内容不再变化,不会自动上线;普通业务操作不会改动生产知识。'}</span></div>
<span className="safe-badge">修改生产内容:关闭</span>
<details className="technical-status"><summary>查看技术状态</summary><p>生产请求门禁{props.releaseCapabilities.production_release_requests_enabled ? '已开启' : '关闭'};快照恢复验证{props.releaseCapabilities.production_backup_restore_verified ? '已通过' : '未通过'};Release Worker保持关闭。</p></details>
</section>
<section className="panel release-plan-panel" id="release-plan">
<div className="panel-heading"><div><h2>自动发布计划</h2><p>来源与目录 → 测试知识库 → 生产知识库。来源标注是最终 Truth Source。</p></div><span className="safe-badge">按知识级别同步</span></div>
<div className="release-plan-summary"><span>{`新增 ${props.releasePlan.summary.add}`}</span><span>{`更新 ${props.releasePlan.summary.update}`}</span><span>{`删除 ${props.releasePlan.summary.delete}`}</span><span>{`阻断 ${props.releasePlan.summary.blocked}`}</span><span>{`未变化 ${props.releasePlan.summary.unchanged}`}</span></div>
{(() => {
const filtered = props.releasePlan.items.filter((item) => {
if (planActionFilter === 'blocked' ? item.can_release : planActionFilter ? item.action !== planActionFilter : false) return false
if (planScopeFilter && item.target_scope !== planScopeFilter) return false
if (planOnlyReleasable && !item.can_release) return false
return true
})
const pageCount = Math.max(1, Math.ceil(filtered.length / planPageSize))
const safePage = Math.min(planPage, pageCount - 1)
const pageItems = filtered.slice(safePage * planPageSize, safePage * planPageSize + planPageSize)
const actionLabel = (item: ReleasePlanItem) => item.action === 'add' ? '新增' : item.action === 'update' ? '更新' : item.action === 'delete' ? '删除' : '等待测试'
return <>
<div className="release-plan-filters" role="search">
<label>动作<select value={planActionFilter} onChange={(event) => { setPlanActionFilter(event.target.value as typeof planActionFilter); setPlanPage(0) }}><option value="">全部</option><option value="add">新增</option><option value="update">更新</option><option value="delete">删除</option><option value="blocked">仅阻断</option></select></label>
<label>目标<select value={planScopeFilter} onChange={(event) => { setPlanScopeFilter(event.target.value as typeof planScopeFilter); setPlanPage(0) }}><option value="">全部</option><option value="internal">对内</option><option value="external">对外</option></select></label>
<label className="filter-check"><input type="checkbox" checked={planOnlyReleasable} onChange={(event) => { setPlanOnlyReleasable(event.target.checked); setPlanPage(0) }} />仅可发布</label>
<span className="filter-count">{`筛选 ${filtered.length} / 全部 ${props.releasePlan.items.length}`}</span>
</div>
{pageItems.length ? <div className="table-wrap"><table className="release-plan-table"><thead><tr><th>选择</th><th>知识</th><th>目标</th><th>计划动作</th><th>测试状态</th><th>生产状态</th><th>能否发布</th></tr></thead><tbody>{pageItems.map((item, index) => <tr key={`${item.publication_id}-${item.title}-${item.target_scope}-${index}`} className={item.action === 'delete' && item.can_release ? 'plan-delete' : item.can_release ? '' : 'plan-blocked'}><td>{item.action === 'delete' && item.can_release ? <input type="checkbox" aria-label={`选择删除${item.title}`} checked={props.selectedDeleteIDs.includes(item.publication_id)} onChange={() => { props.onToggleDelete(item.publication_id); setDeleteConfirmed(false) }} /> : '—'}</td><td><strong>{item.title}</strong></td><td>{item.target_scope === 'internal' ? '对内知识库' : '对外知识库'}</td><td>{actionLabel(item)}</td><td>{item.test_state === 'ready' ? '已通过' : item.test_state === 'not_required' ? '无需测试' : '未就绪'}</td><td>{item.production_state === 'present' ? '已存在' : '不存在'}</td><td>{item.can_release ? item.action === 'delete' ? '将从生产检索中移除' : '可加入发布批次' : item.blocker === 'source_unavailable' ? '来源当前不可用,保留生产知识' : '测试未就绪,当前阻断'}</td></tr>)}</tbody></table></div> : filtered.length ? <div className="empty-state">当前筛选没有发布变更。</div> : <div className="empty-state">来源、测试与生产状态一致,当前没有发布变更。</div>}
{pageCount > 1 ? <div className="release-plan-pager"><button type="button" className="secondary-action" disabled={safePage === 0} onClick={() => setPlanPage(safePage - 1)}>上一页</button><span>{`第 ${safePage + 1} / ${pageCount} 页 · 每页 ${planPageSize} 条`}</span><button type="button" className="secondary-action" disabled={safePage >= pageCount - 1} onClick={() => setPlanPage(safePage + 1)}>下一页</button></div> : null}
</>
})()}
{(() => {
const manifestShort = changeSet ? `${changeSet.manifest_sha256.slice(0, 8)}…${changeSet.manifest_sha256.slice(-6)}` : ''
const frozenActionLabel = (action: string) => action === 'add' ? '新增' : action === 'update' ? '更新' : action === 'delete' ? '删除' : action === 'blocked' ? '阻断' : '不变'
return <div className="release-changeset-panel">
<div className="release-changeset-heading"><div><h3>冻结发布计划集(R1)</h3><p>生成即固化:来源刷新不会改变已确认清单;正式批次只能引用已确认版本。</p></div>
{changeSet ? <span className={`status status-${changeSet.state === 'confirmed' ? 'completed' : 'pending'}`}>v{changeSet.number} · {changeSet.state === 'confirmed' ? '已确认' : changeSet.state === 'consumed' ? '已消费' : changeSet.state === 'cancelled' ? '已取消' : '待确认'}</span> : <span className="status status-pending">尚未生成</span>}
</div>
{changeSet ? <div className="release-changeset-meta">
<span>{`清单 ${changeSet.items.length} 项(新增${changeSet.add_count}·更新${changeSet.update_count}·删除${changeSet.delete_count}·阻断${changeSet.blocked_count})`}</span>
<span title={changeSet.manifest_sha256}>{`摘要 ${manifestShort}`}</span>
<span>{`绑定快照 ${changeSet.source_snapshot_ids.length} 个`}</span>
<span>{`生成人 ${changeSet.created_by} · ${new Date(changeSet.created_at).toLocaleString('zh-CN', { hour12: false })}`}</span>
{changeSet.confirmed_by ? <span>{`确认人 ${changeSet.confirmed_by} · ${changeSet.confirmed_at ? new Date(changeSet.confirmed_at).toLocaleString('zh-CN', { hour12: false }) : ''}`}</span> : null}
</div> : null}
{changeSet && changeSet.state === 'planned' ? <details className="release-changeset-items"><summary>查看冻结清单({changeSet.items.length}项)</summary><ul>{changeSet.items.map((item) => <li key={item.seq}>{`${item.seq}. ${item.title} · ${item.target_scope === 'internal' ? '对内' : '对外'} · ${frozenActionLabel(item.action)}${item.can_release ? '' : '(阻断:' + (item.blocker === 'source_unavailable' ? '来源不可用' : '测试未就绪') + ')'}`}</li>)}</ul></details> : null}
{changeSetError ? <p className="form-error">{changeSetError}</p> : null}
<div className="release-changeset-actions">
{changeSet ? <small className="safe-badge">建批时自动冻结当前计划(同摘要复用同一版本 v{changeSet.number}),无需手动确认冻结</small> : <small>建批时会自动冻结当前发布计划</small>}
</div>
</div>
})()}
{props.selectedDeleteIDs.length > 0 ? <label className="delete-confirmation"><input type="checkbox" aria-label="确认删除生产知识" checked={deleteConfirmed} onChange={(event) => setDeleteConfirmed(event.target.checked)} /><span><strong>我确认所选删除项会停止生产检索</strong><small>发布前会创建可恢复快照;失败会自动回滚。</small></span></label> : null}
</section>
<section className="summary-grid" aria-label="审核概览">
<SummaryCard label="审核候选" value={props.reviewPage.total} tone="blue" />
<SummaryCard label="测试可用" value={ready} tone="green" />
<SummaryCard label="待审核" value={pending} tone="amber" />
<SummaryCard label={props.selectedDeleteIDs.length > 0 && !deleteConfirmed ? `已选择删除:${props.selectedDeleteIDs.length}(待确认)` : '已选入批次'} value={selectedCount} tone="cyan" />
<div><strong>{productionStatus}</strong><span>{props.releaseCapabilities.production_backup_restore_verified ? '发布前会创建可恢复快照;失败自动按快照回滚。' : '生产发布已阻断:先完成生产快照并通过恢复验证。'}</span></div>
<span className="safe-badge">{props.releaseCapabilities.production_release_requests_enabled ? '修改生产内容:待确认' : '修改生产内容:关闭'}</span>
<details className="technical-status"><summary>查看技术状态</summary><p>{`生产请求门禁${props.releaseCapabilities.production_release_requests_enabled ? '已开启' : '已关闭'};快照恢复验证${props.releaseCapabilities.production_backup_restore_verified ? '已通过' : '未通过'}。`}</p></details>
</section>
{props.releaseActionError ? <div className="error-banner" role="alert">{props.releaseActionError}</div> : null}
{props.releaseActionMessage ? <p className="success-message" role="status">{props.releaseActionMessage}</p> : null}
<section className="panel review-panel" id="review-actions">
<div className="panel-heading release-toolbar">
<div><h2>第 3 步:审核要发布的知识</h2><p>先确认测试结果和对内/对外范围,再批准或驳回。批准后才能勾选加入批次。可批准的多条支持一次批量批准。</p>{autoReviewNote(props.releaseCapabilities.test_auto_review_policy) ? <p className="tiny" role="note">{autoReviewNote(props.releaseCapabilities.test_auto_review_policy)}</p> : null}</div>
</div>
{(() => {
// 「可批准」只含尚未决定且门禁通过的条目:已驳回的不能被"全选"顺手翻回来。
const batchable = props.reviewPage.items.filter((item) => item.gate_status === 'ready' && item.review_state === 'pending').map((item) => item.publication_id)
// 已批准且可发布的选中项:一键"发布到生产"(建批+锁定+授权合成一个动作)。
const publishableSelected = selectedIDs.filter((id) => props.reviewPage.items.some((item) => item.publication_id === id && item.review_state === 'approved' && item.gate_status === 'ready'))
return <div className="release-toolbar"><div className="release-toolbar-actions">
<button type="button" disabled={!batchable.length || props.reviewingId === 'batch'} onClick={() => setSelectedIDs(batchable)}>全选可批准({batchable.length})</button>
<button type="button" disabled={!selectedIDs.length || props.reviewingId === 'batch'} onClick={() => void props.onBatchReview?.(selectedIDs, 'approved', 'internal', 'approved_for_release')}>{props.reviewingId === 'batch' ? '正在批量处理…' : `批量批准选中(${selectedIDs.length})`}</button>
<button type="button" disabled={!selectedIDs.length || props.reviewingId === 'batch'} onClick={() => void props.onBatchReview?.(selectedIDs, 'rejected', 'internal', 'needs_correction')}>批量驳回选中({selectedIDs.length})</button>
{isAdmin && props.releaseCapabilities.production_release_requests_enabled ? <button type="button" className="primary" disabled={!publishableSelected.length} onClick={() => props.onStartReleaseAction?.('publish_now', 'publish-now', `${publishableSelected.length} 项`, publishableSelected)}>发布到生产(选中 {publishableSelected.length} 项)</button> : null}
<div>
<h2>待发布({publishReady.length}{props.selectedDeleteIDs.length ? ` + 下架 ${props.selectedDeleteIDs.length}` : ''})</h2>
<p>已批准、可直接发布到生产的知识。点单条后面的按钮即可发布。</p>
{autoReviewNote(props.releaseCapabilities.test_auto_review_policy) ? <p className="tiny" role="note">{autoReviewNote(props.releaseCapabilities.test_auto_review_policy)}</p> : null}
</div>
<div className="release-toolbar-actions">
<button type="button" disabled={!publishReady.length} onClick={() => setSelectedIDs(publishReady.map((item) => item.publication_id))}>全选({publishReady.length})</button>
<button type="button" className="primary" disabled={!publishSelectedIDs.length || !props.releaseCapabilities.production_release_requests_enabled} onClick={() => startPublish(publishableSelected, `${publishSelectedIDs.length} 项`, selectedDeleteIDs)}>发布到生产({publishSelectedIDs.length} 项)</button>
{props.reviewBatchMessage ? <small role="status">{props.reviewBatchMessage}</small> : null}
</div></div>
})()}
{batchBlocker ? <div className="button-reason" role="note"><strong>{`为什么按钮不能点:${batchBlocker}`}</strong></div> : null}
<div className="review-decision-guide" aria-label="审核判断标准">
<h3>如何决定批准或驳回</h3>
<p className="approve-guide">可以批准:基础测试通过,你已确认搜索结果相关,而且发布范围正确</p>
<p className="reject-guide">应该驳回:内容错误、过期、敏感、搜索结果不相关,或者你无法确认</p>
</div>
</div>
{props.reviewError ? <div className="error-banner" role="alert">{props.reviewError}</div> : null}
{!props.reviewLoading && !props.reviewError && props.reviewPage.items.length === 0 ? <div className="empty-state">当前没有带最新验收结果的审核候选。</div> : null}
{props.reviewPage.items.length > 0 ? <div className="table-wrap"><table className="review-table"><thead><tr><th>选择</th><th>知识内容</th><th>测试结果</th><th>能否继续</th><th>发布范围</th><th>审核状态</th><th>操作</th></tr></thead><tbody>
{props.reviewPage.items.map((item) => {
const visibility = visibilityByID[item.publication_id] ?? (item.decided_visibility || item.current_visibility)
const selectable = item.review_state === 'approved' && item.gate_status === 'ready'
return <tr key={item.publication_id}>
<td><input type="checkbox" aria-label={`选择${item.title}`} checked={selectedIDs.includes(item.publication_id)} disabled={!selectable} onChange={() => toggleSelected(item.publication_id)} /></td>
<td><strong>{item.title}</strong><span>{sourceTypeLabels[item.source_type] ?? item.source_type}</span></td>
<td className="acceptance-summary">
<strong>{item.knowledge_exists === 'passed' && item.chunks_present === 'passed' ? '基础测试通过' : '基础测试未通过'}</strong>
<span>{item.retrieval_hit === 'manual_required' ? '搜索效果需人工确认' : `搜索测试${acceptanceLabels[item.retrieval_hit]}`}</span>
<details><summary>查看测试详情</summary><small>知识读取:{acceptanceLabels[item.knowledge_exists]};内容处理:{acceptanceLabels[item.chunks_present]};搜索验证:{acceptanceLabels[item.retrieval_hit]}</small></details>
</td>
<td><span className={`status status-${item.gate_status === 'ready' ? 'completed' : 'failed'}`}>{reviewGateLabel(item)}</span></td>
<td><select value={visibility} onChange={(event) => setVisibilityByID((current) => ({ ...current, [item.publication_id]: event.target.value as Visibility }))}><option value="internal">仅内部员工</option><option value="external">允许外部用户</option></select></td>
<td><span className={`status status-${item.review_state === 'approved' ? 'completed' : item.review_state === 'rejected' ? 'failed' : 'pending'}`}>{reviewLabels[item.review_state]}</span>{item.reviewer_ref ? <small>{item.reviewer_ref}</small> : null}</td>
<td><div className="row-actions"><button type="button" disabled={item.gate_status !== 'ready' || props.reviewingId === item.publication_id} onClick={() => props.onReview(item.publication_id, 'approved', visibility, 'approved_for_release')}>批准</button><button type="button" className="secondary-action" disabled={props.reviewingId === item.publication_id} onClick={() => props.onReview(item.publication_id, 'rejected', visibility, 'needs_correction')}>驳回</button>{isAdmin && props.releaseCapabilities.production_release_requests_enabled && item.review_state === 'approved' && item.gate_status === 'ready' ? <button type="button" title="建批(冻结+锁定)并授权生产发布,一个动作完成" onClick={() => props.onStartReleaseAction?.('publish_now', 'publish-now', item.title, [item.publication_id])}>发布到生产</button> : null}</div></td>
</tr>
})}
{!props.reviewLoading && publishReady.length === 0 ? <div className="empty-state">没有待发布的已批准知识。到「来源与目录」标注后,在「解析监控」处理完成即可发布。</div> : null}
{publishReady.length > 0 ? <div className="table-wrap"><table className="review-table"><thead><tr><th>选择</th><th>知识</th><th>目标</th><th>测试</th><th>审核</th><th>操作</th></tr></thead><tbody>
{publishReady.map((item) => <tr key={item.publication_id}>
<td><input type="checkbox" aria-label={`选择${item.title}`} checked={selectedIDs.includes(item.publication_id)} onChange={() => toggleSelected(item.publication_id)} /></td>
<td><strong>{item.title}</strong><span>{sourceTypeLabels[item.source_type] ?? item.source_type}</span></td>
<td>{item.current_visibility === 'internal' ? '对内知识库' : '对外知识库'}</td>
<td>{item.knowledge_exists === 'passed' && item.chunks_present === 'passed' ? '通过' : '未通过'}</td>
<td><span className="status status-completed">已批准</span>{item.reviewer_ref ? <small>{item.reviewer_ref}</small> : null}</td>
<td><div className="row-actions"><button type="button" title="建批(冻结+锁定)并授权生产发布,一个动作完成" disabled={!props.releaseCapabilities.production_release_requests_enabled} onClick={() => startPublish([item.publication_id], item.title)}>发布到生产</button><button type="button" className="secondary-action" onClick={() => props.onReview(item.publication_id, 'rejected', item.current_visibility === 'external' ? 'external' : 'internal', 'needs_correction')}>改为驳回</button></div></td>
</tr>)}
</tbody></table></div> : null}
<div className="batch-requirements" aria-label="创建批次条件"><strong>创建批次还需要</strong><span className={props.selectedDeleteIDs.length === 0 || deleteConfirmed ? 'met' : 'unmet'}>确认所选发布动作</span><span className={confirmedSelection ? 'met' : 'unmet'}>至少 1 项动作通过确认</span><span className={batchName.trim() ? 'met' : 'unmet'}>填写批次名称</span></div>
<div className="batch-create-bar"><label>批次名称<input value={batchName} onChange={(event) => setBatchName(event.target.value)} placeholder="例如:9月第一批知识" /></label><span>已选 {selectedCount} 项{props.selectedDeleteIDs.length > 0 && !deleteConfirmed ? '(删除待确认)' : ''}</span><button type="button" title={batchBlocker || '创建即锁定清单(清单在建批时冻结,锁定不会上线)'} disabled={Boolean(batchBlocker) || props.batchLoading} onClick={() => props.onCreateBatch(batchName, selectedIDs, props.selectedDeleteIDs)}>创建并锁定清单</button></div>
</section>
<section className="panel batch-panel" id="batch-actions">
<div className="panel-heading"><div><h2>第 4 步:创建并锁定发布清单</h2><p>建批时自动冻结清单并立即锁定:本批内容此后不再变化,但仍不会发布到生产。</p></div><span className="safe-badge">锁定清单 ≠ 上线</span></div>
{props.batchError ? <div className="error-banner" role="alert">{props.batchError}</div> : null}
{!props.batchLoading && !props.batchError && props.batchPage.items.length === 0 ? <div className="empty-state">尚无草稿或已锁定的发布清单。</div> : null}
{props.batchPage.items.length > 0 ? <div className="batch-grid"><div className="table-wrap"><table><thead><tr><th>批次名称</th><th>状态</th><th>知识数量</th><th>内容状态</th><th>操作</th></tr></thead><tbody>
{props.batchPage.items.map((batch) => <tr key={batch.id}><td><strong>{batch.name}</strong></td><td><span className={`status status-${batch.state === 'sealed' ? 'completed' : 'pending'}`}>{batchLabels[batch.state]}</span></td><td>{batch.item_count}</td><td>{batch.state === 'sealed' ? '内容已锁定' : '仍可检查调整'}</td><td><div className="row-actions"><button type="button" className="secondary-action" onClick={() => props.onSelectBatch(batch.id)}>查看内容</button>{batch.state === 'draft' ? <button type="button" disabled={props.mutatingBatchId === batch.id} onClick={() => props.onSealBatch(batch.id)}>锁定清单(不会上线)</button> : null}{batch.state === 'sealed' && isAdmin ? <button type="button" onClick={() => props.onStartReleaseAction?.('authorize', batch.id, batch.name)}>授权发布</button> : null}</div></td></tr>)}
</tbody></table></div><div className="batch-detail"><h3>本批次包含</h3>{props.batchDetail ? <>{props.batchDetail.items.map((item) => <div className="batch-detail-row" key={item.publication_id}><span><strong>{item.title}</strong><small>{item.action === 'delete' ? '删除生产知识' : '新增或更新生产知识'}</small></span><b>{item.decided_visibility === 'internal' ? '仅内部员工' : '允许外部用户'}</b></div>)}{props.batchDetail.items.length === 0 ? <div className="empty-state">批次没有知识。</div> : null}</> : <div className="empty-state">点击“查看内容”核对本次发布清单。</div>}</div></div> : null}
{pendingItems.length > 0 ? <>
<div className="panel-heading release-toolbar">
<div><h3>待你审核({pendingItems.length})</h3><p>先确认测试结果与发布范围,再批准或驳回。可批准的多条可一次批。</p></div>
<div className="release-toolbar-actions">
<button type="button" disabled={!pendingItems.filter((item) => item.gate_status === 'ready').length || props.reviewingId === 'batch'} onClick={() => setSelectedIDs(pendingItems.filter((item) => item.gate_status === 'ready').map((item) => item.publication_id))}>全选可批准({pendingItems.filter((item) => item.gate_status === 'ready').length})</button>
<button type="button" disabled={!selectedIDs.length || props.reviewingId === 'batch'} onClick={() => void props.onBatchReview?.(selectedIDs, 'approved', 'internal', 'approved_for_release')}>{props.reviewingId === 'batch' ? '正在批量处理…' : `批量批准(${selectedIDs.length})`}</button>
<button type="button" disabled={!selectedIDs.length || props.reviewingId === 'batch'} onClick={() => void props.onBatchReview?.(selectedIDs, 'rejected', 'internal', 'needs_correction')}>批量驳回({selectedIDs.length})</button>
</div>
</div>
{batchBlocker ? <div className="button-reason" role="note"><strong>{`为什么按钮不能点:${batchBlocker}`}</strong></div> : null}
<div className="table-wrap"><table className="review-table"><thead><tr><th>选择</th><th>知识</th><th>测试结果</th><th>能否继续</th><th>发布范围</th><th>操作</th></tr></thead><tbody>
{pendingItems.map((item) => {
const visibility = visibilityByID[item.publication_id] ?? (item.decided_visibility || item.current_visibility)
return <tr key={item.publication_id}>
<td><input type="checkbox" aria-label={`选择${item.title}`} checked={selectedIDs.includes(item.publication_id)} onChange={() => toggleSelected(item.publication_id)} /></td>
<td><strong>{item.title}</strong><span>{sourceTypeLabels[item.source_type] ?? item.source_type}</span></td>
<td className="acceptance-summary"><strong>{item.knowledge_exists === 'passed' && item.chunks_present === 'passed' ? '基础测试通过' : '基础测试未通过'}</strong><span>{item.retrieval_hit === 'manual_required' ? '搜索效果需人工确认' : `搜索测试${acceptanceLabels[item.retrieval_hit]}`}</span></td>
<td><span className={`status status-${item.gate_status === 'ready' ? 'completed' : 'failed'}`}>{reviewGateLabel(item)}</span></td>
<td><select value={visibility} onChange={(event) => setVisibilityByID((current) => ({ ...current, [item.publication_id]: event.target.value as Visibility }))}><option value="internal">仅内部员工</option><option value="external">允许外部用户</option></select></td>
<td><div className="row-actions"><button type="button" disabled={item.gate_status !== 'ready' || props.reviewingId === item.publication_id} onClick={() => props.onReview(item.publication_id, 'approved', visibility, 'approved_for_release')}>批准</button><button type="button" className="secondary-action" disabled={props.reviewingId === item.publication_id} onClick={() => props.onReview(item.publication_id, 'rejected', visibility, 'needs_correction')}>驳回</button></div></td>
</tr>
})}
</tbody></table></div>
</> : null}
{rejectedItems.length > 0 ? <details className="release-rejected"><summary>已驳回({rejectedItems.length})</summary><ul>{rejectedItems.map((item) => <li key={item.publication_id}><span>{item.title}</span><button type="button" className="secondary-action" disabled={props.reviewingId === item.publication_id} onClick={() => props.onReview(item.publication_id, 'approved', item.current_visibility === 'external' ? 'external' : 'internal', 'approved_for_release')}>改为批准</button></li>)}</ul></details> : null}
</section>
<section className="panel execution-panel" id="release-execution">
<div className="panel-heading"><div><h2>第 5–7 步:生产确认、发布验证与回滚</h2><p>生产动作只对管理员开放:点击后需逐字输入固定确认语句;服务端请求门禁与执行门禁仍须开启。发布后的三通道读回与官方 API 验收由 Release Worker 自动完成,这里只读展示结果。</p></div><span className="safe-badge">{props.releaseCapabilities.production_release_requests_enabled ? '生产操作可执行(待确认)' : '生产操作已锁定'}</span></div>
<div className="panel-heading"><div><h2>发布记录</h2><p>最近 20 条生产发布与回滚。生产确认、发布验证与回滚都由 Release Worker 完成,这里只读展示结果。</p></div><span className="safe-badge">{props.releaseCapabilities.production_release_requests_enabled ? '生产操作可执行(待确认)' : '生产操作已锁定'}</span><span className="safe-badge">Release Worker 默认关闭</span></div>
{props.pendingReleaseAction ? <div className="release-action-confirm" role="group" aria-label="生产动作确认">
<p><b>{releaseActionLabels[props.pendingReleaseAction.kind]}</b>「{props.pendingReleaseAction.label}」—— 请输入固定确认语句 <code>{productionConfirmationPhrases[props.pendingReleaseAction.kind]}</code> 后执行。</p>
<input value={props.releaseActionPhrase ?? ''} onChange={(event) => props.onReleaseActionPhrase?.(event.target.value)} placeholder={productionConfirmationPhrases[props.pendingReleaseAction.kind]} aria-label="生产动作确认语句" />
<button type="button" disabled={props.releaseActionBusy || (props.releaseActionPhrase ?? '').trim() !== productionConfirmationPhrases[props.pendingReleaseAction.kind]} onClick={() => props.onSubmitReleaseAction?.()}>{props.releaseActionBusy ? '提交中…' : '确认执行'}</button>
<button type="button" className="secondary-action" disabled={props.releaseActionBusy} onClick={() => props.onCancelReleaseAction?.()}>取消</button>
</div> : null}
{props.releaseActionError ? <div className="error-banner" role="alert">{props.releaseActionError}</div> : null}
{props.releaseActionMessage ? <p className="success-message" role="status">{props.releaseActionMessage}</p> : null}
{props.executionError ? <div className="error-banner" role="alert">{props.executionError}</div> : null}
{!props.executionLoading && !props.executionError && props.executionPage.items.length === 0 ? <div className="empty-state">尚无生产发布或回滚执行记录。</div> : null}
{!props.executionLoading && !props.executionError && props.executionPage.items.length === 0 ? <div className="empty-state">还没有发布记录。发布一条知识后,这里会出现执行进度与逐项结果。</div> : null}
{props.executionPage.items.length > 0 ? <div className="batch-grid execution-grid"><div className="table-wrap"><table><thead><tr><th>开始时间</th><th>操作</th><th>状态</th><th>批次进度</th><th>完成进度</th><th>授权人</th><th>操作</th></tr></thead><tbody>
{props.executionPage.items.map((execution) => <tr key={execution.id}><td>{formatTime(execution.created_at)}</td><td>{execution.operation === 'publish' ? '发布' : '回滚'}</td><td><span className={`status status-${execution.state}`}>{executionLabels[execution.state]}</span>{executionStateDetail(execution, props.executionPage.items) ? <small>{executionStateDetail(execution, props.executionPage.items)}</small> : null}{execution.error_code ? <small>{releaseFailureMessage(execution.error_code)}</small> : null}</td><td>{execution.total_batches>0?`批次 ${execution.current_batch} / ${execution.total_batches}`:'等待开始'}<small>每批最多 {execution.batch_size} 项</small></td><td>{execution.completed_item_count}/{execution.item_count}{execution.failed_item_count ? <small>失败 {execution.failed_item_count}</small> : null}</td><td>{execution.authorized_by}</td><td><div className="row-actions"><button type="button" className="secondary-action" onClick={() => props.onSelectExecution(execution.id)}>查看结果</button>{isAdmin && execution.state === 'failed' ? <button type="button" onClick={() => props.onStartReleaseAction?.('retry', execution.id, `执行 ${execution.id.slice(0, 8)}…`)}>重排</button> : null}{isAdmin && execution.operation === 'publish' && execution.state === 'completed' ? <button type="button" onClick={() => props.onStartReleaseAction?.('rollback', execution.id, `执行 ${execution.id.slice(0, 8)}…`)}>回滚</button> : null}</div></td></tr>)}
{props.executionPage.items.map((execution) => <tr key={execution.id}><td>{formatTime(execution.created_at)}</td><td>{execution.operation === 'publish' ? '发布' : '回滚'}</td><td><span className={`status status-${execution.state}`}>{executionLabels[execution.state]}</span>{executionStateDetail(execution, props.executionPage.items) ? <small>{executionStateDetail(execution, props.executionPage.items)}</small> : null}{execution.error_code ? <small>{releaseFailureMessage(execution.error_code)}</small> : null}</td><td>{execution.total_batches > 0 ? `批次 ${execution.current_batch} / ${execution.total_batches}` : '等待开始'}<small>每批最多 {execution.batch_size} 项</small></td><td>{execution.completed_item_count}/{execution.item_count}{execution.failed_item_count ? <small>失败 {execution.failed_item_count}</small> : null}</td><td>{execution.authorized_by}</td><td><div className="row-actions"><button type="button" className="secondary-action" onClick={() => props.onSelectExecution(execution.id)}>查看结果</button>{isAdmin && execution.state === 'failed' ? <button type="button" onClick={() => props.onStartReleaseAction?.('retry', execution.id, `执行 ${execution.id.slice(0, 8)}…`)}>重排</button> : null}{isAdmin && execution.operation === 'publish' && execution.state === 'completed' ? <button type="button" onClick={() => props.onStartReleaseAction?.('rollback', execution.id, `执行 ${execution.id.slice(0, 8)}…`)}>回滚</button> : null}</div></td></tr>)}
</tbody></table></div><div className="batch-detail execution-detail"><h3>每项知识的结果</h3>{props.executionDetail ? <>{props.executionDetail.items.map((item) => { const result = releaseItemResult(item); return <div className="batch-detail-row execution-detail-row" key={item.publication_id}><span><strong>{item.title}</strong><small>{result.detail}{item.target_knowledge_base_id ? ` · 目标库 ${item.target_knowledge_base_id.slice(0, 8)}…` : ''}{item.error_code ? ` · ${releaseFailureMessage(item.error_code)}` : ''}</small></span><span><b>{result.outcome}</b></span></div> })}{props.executionDetail.items.length === 0 ? <div className="empty-state">发布尚无逐项结果。</div> : null}</> : <div className="empty-state">点击“查看结果”核对每项知识。</div>}</div></div> : null}
{props.executionChain ? <div className="release-audit-chain">
<h3>发布审计链</h3>
<div className="audit-chain-line"><span>批次</span><b>{props.executionChain.release_batch_name || '未绑定批次'}</b><small>{`创建 ${props.executionChain.created_by || '—'} · 锁定 ${props.executionChain.sealed_by || '—'} · 授权 ${props.executionChain.authorized_by || '—'}`}</small></div>
{props.executionChain.release_change_set_id ? <div className="audit-chain-line"><span>发布计划集</span><b>{props.executionChain.release_change_set_name}</b><small>{`${props.executionChain.release_change_set_state === 'confirmed' ? '已确认' : props.executionChain.release_change_set_state} · 确认人 ${props.executionChain.release_change_set_confirmed_by || '—'} · 摘要 ${props.executionChain.manifest_sha256.slice(0, 8)}…${props.executionChain.manifest_sha256.slice(-6)}`}</small></div> : null}
{props.executionChain.snapshots.length ? <div className="audit-chain-line"><span>来源快照</span><b>{props.executionChain.snapshots.map((snap) => `${snap.source_name}(${snap.file_count})`).join('、')}</b></div> : null}
{props.executionChain.catalog_change_sets.length ? <div className="audit-chain-line"><span>来源变更集</span><b>{props.executionChain.catalog_change_sets.map((set) => `${set.id}·${set.state}`).join('、')}</b></div> : null}
{props.executionChain.rollback_execution_id ? <div className="audit-chain-line"><span>补偿回滚</span><b>已关联回滚执行</b></div> : null}
{props.executionChain.prior_execution_id ? <div className="audit-chain-line"><span>上游发布</span><b>由发布执行补偿而来</b></div> : null}
</div> : null}
</section>
<details className="release-more" id="release-plan">
<summary>更多 · 发布计划、下架与批次清单</summary>
<section className="panel release-plan-panel">
<div className="panel-heading"><div><h3>发布计划</h3><p>来源与目录 → 测试知识库 → 生产知识库。来源标注是最终 Truth Source。</p></div><span className="safe-badge">按知识级别同步</span></div>
<div className="release-plan-summary"><span>新增 {props.releasePlan.summary.add}</span><span>更新 {props.releasePlan.summary.update}</span><span>删除 {props.releasePlan.summary.delete}</span><span>阻断 {props.releasePlan.summary.blocked}</span><span>未变化 {props.releasePlan.summary.unchanged}</span></div>
<div className="release-plan-filters" role="search">
<label>动作<select value={planActionFilter} onChange={(event) => { setPlanActionFilter(event.target.value as typeof planActionFilter); setPlanPage(0) }}><option value="">全部</option><option value="add">新增</option><option value="update">更新</option><option value="delete">删除</option><option value="blocked">仅阻断</option></select></label>
<label>目标<select value={planScopeFilter} onChange={(event) => { setPlanScopeFilter(event.target.value as typeof planScopeFilter); setPlanPage(0) }}><option value="">全部</option><option value="internal">对内</option><option value="external">对外</option></select></label>
<label className="filter-check"><input type="checkbox" checked={planOnlyReleasable} onChange={(event) => { setPlanOnlyReleasable(event.target.checked); setPlanPage(0) }} />仅可发布</label>
<span className="filter-count">{`筛选 ${planFiltered.length} / 全部 ${props.releasePlan.items.length}`}</span>
</div>
{planPageItems.length ? <div className="table-wrap"><table className="release-plan-table"><thead><tr><th>选择</th><th>知识</th><th>目标</th><th>计划动作</th><th>测试状态</th><th>生产状态</th><th>能否发布</th></tr></thead><tbody>{planPageItems.map((item, index) => <tr key={`${item.publication_id}-${item.title}-${item.target_scope}-${index}`} className={item.action === 'delete' && item.can_release ? 'plan-delete' : item.can_release ? '' : 'plan-blocked'}><td>{item.action === 'delete' && item.can_release ? <input type="checkbox" aria-label={`选择删除${item.title}`} checked={props.selectedDeleteIDs.includes(item.publication_id)} onChange={() => { props.onToggleDelete(item.publication_id); setDeleteConfirmed(false) }} /> : '—'}</td><td><strong>{item.title}</strong></td><td>{item.target_scope === 'internal' ? '对内知识库' : '对外知识库'}</td><td>{actionLabel(item)}</td><td>{item.test_state === 'ready' ? '已通过' : item.test_state === 'not_required' ? '无需测试' : '未就绪'}</td><td>{item.production_state === 'present' ? '已存在' : '不存在'}</td><td>{item.can_release ? item.action === 'delete' ? '将从生产检索中移除' : '可加入发布批次' : item.blocker === 'source_unavailable' ? '来源当前不可用,保留生产知识' : '测试未就绪,当前阻断'}</td></tr>)}</tbody></table></div> : planFiltered.length ? <div className="empty-state">当前筛选没有发布变更。</div> : <div className="empty-state">来源、测试与生产状态一致,当前没有发布变更。</div>}
{planPageCount > 1 ? <div className="release-plan-pager"><button type="button" className="secondary-action" disabled={planSafePage === 0} onClick={() => setPlanPage(planSafePage - 1)}>上一页</button><span>{`第 ${planSafePage + 1} / ${planPageCount} 页 · 每页 ${planPageSize} 条`}</span><button type="button" className="secondary-action" disabled={planSafePage >= planPageCount - 1} onClick={() => setPlanPage(planSafePage + 1)}>下一页</button></div> : null}
<div className="release-changeset-panel">
<div className="release-changeset-heading"><div><h3>冻结发布计划集</h3><p>建批时自动冻结当前计划;同一份计划复用同一版本。</p></div><span className={`status status-${changeSet && changeSet.state === 'confirmed' ? 'completed' : 'pending'}`}>{changeSet ? (changeSet.state === 'confirmed' ? `v${changeSet.number} · 已确认` : `v${changeSet.number} · 待确认`) : '尚未生成'}</span></div>
{changeSet ? <p className="tiny">{`清单 ${changeSet.item_count} 项(新增${changeSet.add_count}·更新${changeSet.update_count}·删除${changeSet.delete_count}·阻断${changeSet.blocked_count})· 摘要 ${changeSet.manifest_sha256.slice(0, 8)}…`}</p> : null}
{changeSetError ? <p className="form-error">{changeSetError}</p> : null}
<div className="release-changeset-actions">{changeSet ? <small className="safe-badge">建批时自动冻结当前计划,无需手动确认冻结</small> : <small>建批时会自动冻结当前发布计划</small>}</div>
</div>
<label className="delete-confirmation"><input type="checkbox" aria-label="确认删除生产知识" checked={deleteConfirmed} onChange={(event) => setDeleteConfirmed(event.target.checked)} /><span><strong>我确认所选删除项会停止生产检索</strong><small>下架只停用检索、不删除行,可恢复。</small></span></label>
<div className="batch-create-bar"><label>批次名称<input value={batchName} onChange={(event) => setBatchName(event.target.value)} placeholder="例如:9月第一批知识" /></label><span>已选 {selectedCount} 项{props.selectedDeleteIDs.length > 0 && !deleteConfirmed ? '(删除待确认)' : ''}</span><button type="button" title={batchBlocker || '创建即锁定清单(清单在建批时冻结,锁定不会上线)'} disabled={Boolean(batchBlocker) || props.batchLoading} onClick={() => props.onCreateBatch(batchName, selectedIDs, props.selectedDeleteIDs)}>创建并锁定清单</button></div>
<div className="batch-requirements" aria-label="创建批次条件"><strong>创建批次还需要</strong><span className={props.selectedDeleteIDs.length === 0 || deleteConfirmed ? 'met' : 'unmet'}>确认所选发布动作</span><span className={confirmedSelection ? 'met' : 'unmet'}>至少 1 项动作通过确认</span><span className={batchName.trim() ? 'met' : 'unmet'}>填写批次名称</span></div>
</section>
<section className="panel batch-panel" id="batch-actions">
<div className="panel-heading"><div><h3>批次清单</h3><p>建批即锁定;锁定 ≠ 上线。日常发布直接在上面「待发布」里点按钮;已锁定的批次也可以在这里逐条做生产确认。</p></div><span className="safe-badge">锁定清单 ≠ 上线</span></div>
{props.batchError ? <div className="error-banner" role="alert">{props.batchError}</div> : null}
{props.batchPage.items.length === 0 ? <div className="empty-state">还没有批次。用上面的发布计划表创建,或直接在「待发布」里一键发布。</div> : <div className="batch-grid"><div className="table-wrap"><table><thead><tr><th>批次名称</th><th>状态</th><th>知识数量</th><th>内容状态</th><th>操作</th></tr></thead><tbody>
{props.batchPage.items.map((batch) => <tr key={batch.id}><td><strong>{batch.name}</strong></td><td><span className={`status status-${batch.state === 'sealed' ? 'completed' : 'pending'}`}>{batchLabels[batch.state]}</span></td><td>{batch.item_count}</td><td>{batch.state === 'sealed' ? '内容已锁定' : '仍可检查调整'}</td><td><div className="row-actions"><button type="button" className="secondary-action" onClick={() => props.onSelectBatch(batch.id)}>查看内容</button>{batch.state === 'draft' ? <button type="button" disabled={props.mutatingBatchId === batch.id} onClick={() => props.onSealBatch(batch.id)}>锁定清单(不会上线)</button> : null}{batch.state === 'sealed' && isAdmin ? <button type="button" onClick={() => props.onStartReleaseAction?.('authorize', batch.id, batch.name)}>授权发布</button> : null}</div></td></tr>)}
</tbody></table></div><div className="batch-detail"><h3>本批次包含</h3>{props.batchDetail ? <>{props.batchDetail.items.map((item) => <div className="batch-detail-row" key={item.publication_id}><span><strong>{item.title}</strong><small>{item.action === 'delete' ? '删除生产知识' : '新增或更新生产知识'}</small></span><b>{item.decided_visibility === 'internal' ? '仅内部员工' : '允许外部用户'}</b></div>)}{props.batchDetail.items.length === 0 ? <div className="empty-state">批次没有知识。</div> : null}</> : <div className="empty-state">点击“查看内容”核对本次发布清单。</div>}</div></div>}
</section>
</details>
</main>
}