目录修改提案落在已驳回的项上时,改前写出被驳回的原值:plan_patch 交回的 before 带上驳回的值、before_status 写 rejected(只改给人看的信息,算改后、算状态照旧按没有这一项,保存时照旧换成人工确认的新值);助手流的提案卡片、表助手的提案卡片和待保存的修改写「已驳回:<原值>」,和导入预览「目标里这一项已经驳回」一致;check-catalog-loop、check-stream 补对应检查

This commit is contained in:
ThearchyHelios
2026-10-14 14:07:15 +08:00
parent eb8d73b6da
commit a78affa2f1
8 changed files with 122 additions and 17 deletions
+8 -5
View File
@@ -8,7 +8,8 @@ import { CatalogImpactList } from '../components/CatalogImpact'
import { CATALOG_PATCH_TEXT as T, CATALOG_STATUS_LABEL, CATALOG_UI_TEXT as UT } from '../lib/terms'
import type { CatalogPatchChange } from '../types'
import {
catalogTableHref, codeMeaning, patchSubmit, patchTarget, patchValueText, patchWhere, type CatalogPatch,
beforeStatusShown, catalogTableHref, codeMeaning, patchBeforeText, patchSubmit, patchTarget, patchValueText, patchWhere,
type CatalogPatch,
} from './catalogPatch'
// ===========================================================================
@@ -183,13 +184,15 @@ function ChangeRow({ change: c, dense }: { change: CatalogPatchChange; dense: bo
</div>
<dl className="mt-1 grid grid-cols-[auto_minmax(0,1fr)] gap-x-2 gap-y-0.5 text-2xs leading-relaxed">
<dt className="text-faint">{T.before}</dt>
<dd className={clsx('break-words', c.before == null ? 'text-faint' : 'text-dim')} data-patch-before="">
{patchValueText(c.path, c.before)}
{c.before != null && c.before_status && <span className="text-faint">({CATALOG_STATUS_LABEL[c.before_status]})</span>}
<dd className={clsx('break-words', c.before == null || c.before_status === 'rejected' ? 'text-faint' : 'text-dim')} data-patch-before=""
data-patch-before-status={c.before_status ?? undefined}>
{patchBeforeText(c)}
{beforeStatusShown(c) && <span className="text-faint">({CATALOG_STATUS_LABEL[c.before_status!]})</span>}
</dd>
<dt className="text-faint">{T.after}</dt>
<dd className="break-words text-fg" data-patch-after="">
{isCodes ? <CodesAfter before={c.before} after={c.after} /> : patchValueText(c.path, c.after)}
{/* 被驳回的码值不算:保存时整项换成新的,改后的码值都是新加的 */}
{isCodes ? <CodesAfter before={c.before_status === 'rejected' ? null : c.before} after={c.after} /> : patchValueText(c.path, c.after)}
</dd>
{c.reason && (
<>
+14
View File
@@ -141,6 +141,20 @@ export function patchValueText(path: string, v: unknown): string {
return typeof v === 'string' ? v : JSON.stringify(v)
}
/**
* 改前那一格(卡片、表助手的提案和待保存的修改都用它):被驳回的项写「已驳回:原值」——服务端把驳回的原值也交回来
* (before_status 为 rejected),保存时照旧换成人工确认的新值;只写「未填写」就看不出原来有一个被驳回的值,和导入预览
* 「目标里这一项已经驳回」对不上。别的照 patchValueText 写,没有值写「未填写」
*/
export function patchBeforeText(change: Pick<CatalogPatchChange, 'path' | 'before' | 'before_status'>): string {
const text = patchValueText(change.path, change.before)
return change.before_status === 'rejected' && change.before != null ? CATALOG_PATCH_TEXT.beforeRejected(text) : text
}
/** 改前要不要跟一个状态(「(推断)」):有值、不是被驳回的(被驳回的状态已经写在 patchBeforeText 里) */
export const beforeStatusShown = (change: Pick<CatalogPatchChange, 'before' | 'before_status'>) =>
change.before != null && !!change.before_status && change.before_status !== 'rejected'
/** 交回保存、预览的那一份:路径、原样取值、理由 */
export function patchSubmit(changes: CatalogPatchChange[]) {
return changes.map((c) => ({ path: c.path, value: c.value, ...(c.reason ? { reason: c.reason } : {}) }))