fix(short-drama-agent-front): 优化首帧布局与来源复核

This commit is contained in:
GJ committed 2026-11-09 16:38:47 +08:00
1 parent 10e008ca10
commit 3915566994
17 files changed
+733 -223

No files matched your search

+3
View File
@@ -58,6 +58,9 @@
### 布局、说明与间距
- 页面外边距、模块间距优先复用 `--app-content-padding`、`--app-content-gap`;表单与抽屉内部复用对应公共组件的间距,不在各页面随意添加不同数值。
- **表单字段间距为强制要求**:页面、弹窗、抽屉中的标签不能紧贴输入框、下拉框或选择组;自定义字段默认使用 `--app-field-label-gap`(8px),相邻字段默认使用 `--app-field-gap`(16px)。紧凑布局和移动端也不得取消这些必要间距,除非用户明确要求调整。
- 自定义的“标签 + 控件”优先复用 `src/styles/admin.css` 中的 `workspace-form-field`,使用真实的纵向 Flex/Grid `gap`;成熟表单继续复用 `AppForm` / `NFormItem` 的公共排版。禁止仅给行内 `span` 套 `space-y-*` 或垂直 margin 后,就认定标签间距已经生效。
- 修改表单布局时必须核对同模块的全部同类字段,保证同排标签、控件分别对齐;图片与表单并排时,图片标题和字段标签必须复用同一纵向间距值,图片与首排控件的上沿必须对齐;在本地 Chrome 检查桌面、窄屏及必要的加载/校验状态,确认实际留白生效后才算完成。
- 同级模块使用一致的标题、说明、字段间距和上下留白。需要说明时采用“模块标题 + 一句简短说明”,例如画布设置、图片配置、视频配置、动作与物理规则;优先复用 `WorkspaceSectionHeading`。
- 页面、弹窗和抽屉中的同级模块共用左右边界。普通分区直接对齐;需要突出一组内容时,优先用已有的中性背景包住整组内容。背景外沿与相邻模块对齐,组内使用统一内边距,避免透明容器单独缩进。
- 新建剧本等长表单默认每个字段单独占一行并铺满内容宽度;不因改成全屏就自动把原来的字段挤成两列。
+4 -2
View File
@@ -1,11 +1,13 @@
<script setup lang="ts">
import { NPopover } from 'naive-ui'
import { NPopover, type PopoverProps } from 'naive-ui'
import { onScopeDispose, ref } from 'vue'
/** 工作区图标操作共用的悬浮说明。 */
const props = defineProps<{
/** 与按钮无障碍名称一致的操作说明。 */
label: string
/** 提示相对图标的位置;未指定时沿用已有布局。 */
placement?: PopoverProps['placement']
/** 按钮仅在手机端隐藏文字时,只在对应窄屏显示说明。 */
mobileOnly?: boolean
}>()
@@ -26,7 +28,7 @@ onScopeDispose(() => compactMedia?.removeEventListener('change', syncCompact))
<template>
<!-- 以下是图标操作的统一悬浮说明,不额外增加布局容器 -->
<NPopover trigger="hover" placement="bottom-end" :disabled="mobileOnly && !compact">
<NPopover trigger="hover" :placement="placement ?? 'bottom-end'" :disabled="mobileOnly && !compact">
<template #trigger><slot /></template>
{{ label }}
</NPopover>
+11 -3
View File
@@ -1,8 +1,10 @@
<script setup lang="ts">
/** 工作区模块标题、说明与右侧操作的统一展示参数。 */
/** 工作区模块标题、说明及操作位置的统一展示参数。 */
interface Props {
/** 模块标题。 */
title: string
/** 操作放右侧同行或说明下方左侧;默认保持已有页面布局。 */
actionsPlacement?: 'right' | 'below'
/** 模块说明,可通过 description 插槽补充状态与提示。 */
description?: string
}
@@ -12,16 +14,22 @@ defineProps<Props>()
</script>
<template>
<!-- 以下是统一的模块标题与右侧操作模块 -->
<!-- 以下是统一的模块标题与可选同行操作模块 -->
<header class="workspace-section-heading">
<div class="workspace-section-heading-row">
<h3 class="text-sm font-semibold">{{ title }}</h3>
<div v-if="$slots.actions" class="workspace-section-heading-actions"><slot name="actions" /></div>
<div v-if="$slots.actions && actionsPlacement !== 'below'" class="workspace-section-heading-actions">
<slot name="actions" />
</div>
</div>
<!-- 以下是标题下方的说明与状态模块 -->
<div v-if="description || $slots.description" class="workspace-section-description">
<slot name="description">{{ description }}</slot>
</div>
<!-- 以下是正文左侧的模块操作,与标题及说明共用边界 -->
<div v-if="$slots.actions && actionsPlacement === 'below'" class="workspace-section-heading-actions mt-4">
<slot name="actions" />
</div>
</header>
</template>
@@ -1,4 +1,6 @@
<script setup lang="ts">
import { ClipboardCheck, ScanEye, Pencil, History } from '@lucide/vue'
import WorkspaceActionTooltip from '../../../components/ui/WorkspaceActionTooltip.vue'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
import IssueHint from '../../../components/ui/IssueHint.vue'
@@ -94,6 +96,10 @@ function onSourceChanged() {
void reviewQuery.refresh()
emit('settled')
}
/** 审核图标的提示随当前真实任务状态更新。 */
const qualityActionLabel = computed(() =>
vision.state.value.active || vision.state.value.unknown || vision.uncertain.value ? '查看审核进度' : '质量检查'
)
/** 晋升入口只接受持久化通过和已结算审核。 */
const canSelect = computed(
() =>
@@ -178,11 +184,6 @@ const canSelect = computed(
</p>
<IssueHint v-if="item.error" :messages="[productionMessage(item.error)]" type="error" />
<!-- 以下是来源记录与独立的免费恢复入口 -->
<div v-if="item.isPrimary && item.status === 'completed' && projectId" class="mt-4 mb-3">
<NButton class="workspace-action-button" size="small" @click="sourceReviewOpen = true"
>按当前来源人工复核</NButton
>
</div>
<p v-if="item.inputSnapshotStatus" class="mt-2 text-xs text-muted">
{{
{ recorded: '已保存生成输入', 'not-recorded': '历史生成输入未记录', invalid: '生成输入证据已失效' }[
@@ -213,35 +214,50 @@ const canSelect = computed(
>恢复已生成图片</NButton
>
<p class="mt-2 text-[10px] text-muted">{{ formatDate(item.createdAt) }}</p>
<!-- 以下是集中排列的首帧辅助图标操作,提示与无障碍名称一致 -->
<div v-if="item.status === 'completed' && item.imageUrl" class="mt-4 flex flex-wrap items-center gap-2">
<NButton
v-if="!wrongCanvas && !stale"
class="workspace-action-button"
size="small"
@click="emit('quality')"
>
{{
vision.state.value.active || vision.state.value.unknown || vision.uncertain.value
? '查看审核进度'
: '质量检查'
}}
</NButton>
<NButton
<WorkspaceActionTooltip placement="top" v-if="item.isPrimary && projectId" label="按当前来源人工复核">
<NButton
square
class="workspace-action-button icon-button"
aria-label="按当前来源人工复核"
@click="sourceReviewOpen = true"
><ClipboardCheck :size="17"
/></NButton>
</WorkspaceActionTooltip>
<WorkspaceActionTooltip placement="top" v-if="!wrongCanvas && !stale" :label="qualityActionLabel">
<NButton
square
class="workspace-action-button icon-button"
:aria-label="qualityActionLabel"
@click="emit('quality')"
><ScanEye :size="17"
/></NButton>
</WorkspaceActionTooltip>
<WorkspaceActionTooltip
placement="top"
v-if="item.source !== 'provider_variant' && !wrongCanvas && !stale"
class="workspace-action-button"
size="small"
:disabled="blocked"
:loading="editing"
@click="emit('edit')"
>编辑此首帧</NButton
>
<NButton
v-if="item.status === 'completed'"
class="workspace-action-button"
size="small"
@click="emit('history')"
>查看首帧校验历史</NButton
label="编辑此首帧"
>
<NButton
square
class="workspace-action-button icon-button"
:disabled="blocked"
:loading="editing"
aria-label="编辑此首帧"
@click="emit('edit')"
><Pencil :size="17"
/></NButton>
</WorkspaceActionTooltip>
<WorkspaceActionTooltip placement="top" label="查看首帧校验历史">
<NButton
square
class="workspace-action-button icon-button"
aria-label="查看首帧校验历史"
@click="emit('history')"
><History :size="17"
/></NButton>
</WorkspaceActionTooltip>
<NButton v-if="canSelect" :disabled="blocked" text size="small" @click="emit('select')">
设为主首帧
</NButton>
@@ -1,10 +1,18 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NTag } from 'naive-ui'
import StatusBadge from '../../../components/ui/StatusBadge.vue'
import IssueHint from '../../../components/ui/IssueHint.vue'
/** 条件分支显式接收外层定位样式,避免角标定位丢失后占据标题行高。 */
defineOptions({ inheritAttrs: false })
/** 三个生产阶段共用的状态与原因入口参数。 */
defineProps<{
const props = defineProps<{
/** 首帧详情用不占正文行高的文字圆章。 */
iconOnly?: boolean
/** 当前正在重新核对条件,不沿用旧就绪结论。 */
loading?: boolean
/** 后端返回的当前阶段状态。 */
status?: string
/** 状态的中文显示名称。 */
@@ -14,13 +22,68 @@ defineProps<{
/** 当前状态对应的原因说明,没有原因时隐藏入口。 */
messages: string[]
}>()
/** 有问题或过期时优先保留提醒,不能只按 ready 显示通过图标。 */
const attention = computed(
() =>
!!props.warningLabel ||
props.messages.length > 0 ||
['blocked', 'failed', 'cancelled'].includes(props.status ?? '')
)
/** 角标只表示生成条件,不代替机器质量结论。 */
const statusText = computed(
() => `首帧生成条件:${props.loading ? '正在检查' : props.warningLabel || props.label || '待确认'}`
)
/** 圆章保持短文案,未知和检查中不能显示为已就绪。 */
const sealText = computed(() => {
if (props.loading) return '检查中'
if (props.warningLabel) return props.warningLabel.includes('过期') ? '已过期' : '待核对'
if (attention.value) return '待处理'
if (props.status === 'ready') return '已就绪'
if (['skipped', 'completed'].includes(props.status ?? '')) return '已有结果'
if (['in_progress', 'pending', 'queued', 'running', 'generating'].includes(props.status ?? '')) return '进行中'
return '待确认'
})
/** 仅明确可用且不在检查中的条件章使用成功文字色。 */
const available = computed(
() => !props.loading && !attention.value && ['ready', 'skipped', 'completed'].includes(props.status ?? '')
)
</script>
<template>
<!-- 以下是同一行展示状态与查看原因入口的公共模块 -->
<div class="flex flex-wrap items-center justify-end gap-x-3 gap-y-2">
<!-- 以下是固定在右上角的条件圆章,不使用悬浮提示或独立加载行 -->
<div v-if="iconOnly" v-bind="$attrs" class="flex flex-col items-end gap-2">
<div class="production-condition-seal-frame" :class="available ? 'text-success' : 'text-muted'">
<span class="production-condition-seal" role="status" :aria-label="[statusText, ...messages].join(';')">{{
sealText
}}</span>
</div>
<IssueHint :messages="messages" inline />
</div>
<!-- 以下是生产工作区保留的同行状态与原因入口 -->
<div v-else v-bind="$attrs" class="flex flex-wrap items-center justify-end gap-x-3 gap-y-2">
<NTag v-if="warningLabel" size="small" type="warning" :bordered="false">{{ warningLabel }}</NTag>
<StatusBadge v-else-if="status" :status="status" :label="label" />
<IssueHint :messages="messages" inline />
</div>
</template>
<style>
/* 外框限制旋转后的布局边界,避免窄屏出现横向滚动;文字与圆环一起旋转。 */
.production-condition-seal-frame {
width: 64px;
height: 64px;
overflow: hidden;
}
.production-condition-seal {
display: grid;
place-items: center;
width: 64px;
height: 64px;
border: 2px solid currentColor;
border-radius: 50%;
font-size: 14px;
font-weight: 600;
white-space: nowrap;
transform: rotate(45deg);
}
</style>
@@ -97,6 +97,8 @@ const props = defineProps<{
episodeNo?: number
/** 视频提示词就绪项。 */
promptReadiness?: PromptReadinessItem
/** 首帧条件检查状态,在角标内展示以避免正文跳动。 */
keyframeReadinessLoading?: boolean
/** 首帧就绪项。 */
keyframeReadiness?: KeyframeReadinessItem
/** 视频就绪项。 */
@@ -754,13 +756,16 @@ defineExpose({ inspectSpecs, inspecting })
</div>
</div>
<div class="production-stage">
<div class="production-stage-heading">
<div class="production-stage" :class="{ 'production-stage-with-corner': keyframeOnly }">
<div class="production-stage-heading" :class="{ 'pr-24': keyframeOnly }">
<div>
<h5 class="text-sm font-medium">{{ keyframeOnly ? '本镜首帧' : '02 · 首帧' }}</h5>
</div>
<!-- 以下是首帧状态与对应原因入口模块,过期使用警告色 -->
<ProductionStageStatus
:icon-only="keyframeOnly"
:loading="keyframeReadinessLoading"
:class="{ 'production-stage-corner': keyframeOnly }"
:status="keyframeReadiness?.status"
:label="keyframeReadiness ? productionStatusLabel(keyframeReadiness.status) : undefined"
:warning-label="keyframeStale ? '主首帧已过期' : undefined"
@@ -1227,6 +1232,16 @@ defineExpose({ inspectSpecs, inspecting })
.production-stage:first-of-type {
@apply border-t-0;
}
/* 分镜详情由标签正文统一提供顶部留白,此处不再叠加生产阶段内边距;圆章保持右上定位。 */
.production-stage-with-corner {
position: relative;
padding-top: 0;
}
.production-stage-corner {
position: absolute;
top: 0;
right: 0;
}
.production-stage-heading {
@apply flex items-start justify-between gap-4;
}
@@ -1302,4 +1317,11 @@ defineExpose({ inspectSpecs, inspecting })
@apply p-4;
}
}
/* 窄屏标题区固定预留圆章和原因入口的空间,检查状态切换时正文位置保持稳定。 */
@media (max-width: 639px) {
.production-stage-with-corner > .production-stage-heading {
min-height: 72px;
}
}
</style>
@@ -120,7 +120,7 @@ const declarations = {
aria-label="动作证据核对理由"
/>
</div>
<label v-for="(label, field) in declarations" :key="field" class="block space-y-1"
<label v-for="(label, field) in declarations" :key="field" class="workspace-form-field"
><span>{{ label }}</span
><NSelect
:value="item[field] === null ? null : item[field] ? 'yes' : 'no'"
@@ -70,6 +70,42 @@ const formalActions = computed(() => {
return []
}
})
/** 参考职责只转换展示名称,不修改原始绑定或请求值。 */
const referenceRoleLabels: Record<string, string> = {
'identity-anchor': '身份母版',
'form-primary': '形态主图',
'layout-master': '空间布局',
'scene-form-view': '场景机位',
'scene-form': '场景形态',
'style-overall': '整体风格',
'style-character': '人物风格',
'style-scene': '场景风格',
'style-prop': '道具风格'
}
/** 同图同主体合并职责,完整原始绑定仍保留在高级详情。 */
const referenceSummaries = computed(
() =>
new Map(
(form.preview.value?.currentReferenceInput.references ?? []).map(reference => {
const groups = new Map<string, { roles: Set<string>; views: Set<string> }>()
for (const binding of reference.bindings) {
const group = groups.get(binding.subjectRef) ?? {
roles: new Set<string>(),
views: new Set<string>()
}
group.roles.add(referenceRoleLabels[binding.role] ?? '参考依据')
if (binding.viewDescription) group.views.add(binding.viewDescription)
groups.set(binding.subjectRef, group)
}
return [
reference.imageNumber,
[...groups].map(([subject, group]) =>
[subject, [...group.roles].join('、'), ...group.views].join(' · ')
)
]
})
)
)
/** 当前人工记录或新机器任务,供正式执行历史展开。 */
const task = computed(() => form.vision.history.data.value?.find(item => item.sourceReviewId === form.reviewId.value))
/** 已知原任务才允许明确继续,未知费用不显示恢复按钮。 */
@@ -99,7 +135,7 @@ const statusLabels: Record<string, string> = {
description="人工观察、机器审核与跨镜验收分别进行;不会生图或替换主首帧。"
:busy="busy"
>
<div class="space-y-(--app-content-gap)">
<div class="source-review-body">
<!-- 以下是当前有效质量摘要,人工观察通过不代表机器质量通过 -->
<p role="status" class="text-sm">当前质量:{{ effectiveQualityLabels[quality.status.value] }}</p>
<div class="flex flex-wrap gap-3">
@@ -109,45 +145,56 @@ const statusLabels: Record<string, string> = {
@click="form.loadPreview"
>免费预检当前来源</NButton
>
<NInput
v-model:value="form.reviewId.value"
:disabled="!!form.pending.value"
placeholder="输入已有人工来源记录编号以回读"
aria-label="人工来源记录编号"
class="sm:max-w-md"
/>
<NButton
:loading="form.pending.value === 'read'"
:disabled="!!form.pending.value || !form.reviewId.value.trim()"
@click="form.readRecord"
>回读人工记录</NButton
>
</div>
<!-- 以下是原记录的高级查找入口,日常预检会读取可匹配的已有观察 -->
<NCollapse
><NCollapseItem name="record-lookup" title="读取其它来源记录"
><div class="flex flex-wrap items-center gap-3">
<NInput
v-model:value="form.reviewId.value"
:disabled="!!form.pending.value"
placeholder="输入已有人工来源记录编号以回读"
aria-label="人工来源记录编号"
class="sm:max-w-md"
/>
<NButton
:loading="form.pending.value === 'read'"
:disabled="!!form.pending.value || !form.reviewId.value.trim()"
@click="form.readRecord"
>回读人工记录</NButton
>
</div></NCollapseItem
></NCollapse
>
<template v-if="form.preview.value">
<WorkspaceSectionHeading title="保留的原主首帧" description="以下生成输入及旧审核均为历史记录。" />
<AssetImage
class="max-w-sm aspect-square"
:src="form.preview.value.imageUrl"
alt="保留的原主首帧"
object-fit="contain"
preview
/>
<p class="wrap-anywhere text-xs text-muted">原件 SHA:{{ form.preview.value.originalPixels.sha256 }}</p>
<NCollapse
><NCollapseItem title="历史生成输入、旧审核与来源变化" name="original">
<pre class="whitespace-pre-wrap wrap-anywhere text-xs">{{
JSON.stringify(
{
originalProviderInput: form.preview.value.originalProviderInput,
historicalVision: form.preview.value.historicalVision,
sourceChanges: form.preview.value.sourceChanges
},
null,
2
)
}}</pre>
</NCollapseItem></NCollapse
>
<!-- 以下是紧凑原图与原始输入追溯,图片按自然比例展示 -->
<section class="source-review-original">
<AssetImage
class="source-review-image"
:src="form.preview.value.imageUrl"
alt="保留的原主首帧"
object-fit="contain"
preview
/>
<div class="min-w-0 space-y-3">
<WorkspaceSectionHeading
title="保留的原主首帧"
description="点击小图查看原图。当前参考仅用于比较,不代表原图生成时已使用。"
/>
<p v-if="form.restored.value && form.targetMatched.value" class="text-sm text-muted">
已读取当前有效的原观察和依据,无需重复填写或保存;只需修改变化项,未知仍保持未知。
</p>
<RawDataDetails
title="历史输入、图片摘要与来源变化"
:value="{
originalProviderInput: form.preview.value.originalProviderInput,
historicalVision: form.preview.value.historicalVision,
originalPixels: form.preview.value.originalPixels,
sourceChanges: form.preview.value.sourceChanges
}"
/>
</div>
</section>
<WorkspaceSectionHeading
title="本次新参考与逐图观察"
description="新参考仅是本次比较依据,不是原图的生成输入。结构看不清时保留未知,并逐项核对本镜是否需要该证据。"
@@ -171,62 +218,86 @@ const statusLabels: Record<string, string> = {
:value="form.preview.value.applicabilityBasis.facts"
/>
</section>
<div class="grid items-start gap-(--app-content-gap) lg:grid-cols-2">
<!-- 以下是逐参考的小图与核对表单,必要的未知范围按需展开 -->
<div class="source-review-reference-grid">
<section
v-for="(observation, index) in form.observations.value"
:key="observation.imageNumber"
class="min-w-0 space-y-3"
class="source-review-reference"
>
<h3 class="font-medium">比较参考 {{ observation.imageNumber }}</h3>
<AssetImage
class="max-w-sm aspect-square"
:src="
form.preview.value.references.find(r => r.imageNumber === observation.imageNumber)
?.imageUrl
"
:alt="'本次比较参考 ' + observation.imageNumber"
object-fit="contain"
preview
/>
<p
v-for="(binding, b) in form.preview.value.currentReferenceInput.references.find(
r => r.imageNumber === observation.imageNumber
)?.bindings"
:key="b"
class="wrap-anywhere text-sm"
>
{{ binding.subjectRef }} · {{ userFacingText(binding.role) }} {{ binding.viewDescription }}
{{ binding.spatialLayoutVersion }}
</p>
<div v-for="(label, field) in sourceFindingLabels" :key="field" class="block space-y-1 text-sm">
<span>{{ label }}</span
><NSelect
v-model:value="observation.finding[field]"
:options="findingOptions"
:disabled="!!form.pending.value"
:aria-label="'参考 ' + (index + 1) + ' ' + label"
/>
<SourceApplicabilityFields
v-if="
(field === 'structure' || field === 'spatial') &&
observation.finding[field] === 'unknown' &&
form.preview.value.applicabilityBasis
<div class="source-review-reference-media">
<h3 class="text-sm font-medium">比较参考 {{ observation.imageNumber }}</h3>
<AssetImage
class="source-review-image"
:src="
form.preview.value.references.find(r => r.imageNumber === observation.imageNumber)
?.imageUrl
"
v-model="form.assessments.value"
:basis="form.preview.value.applicabilityBasis"
:image-number="observation.imageNumber"
:dimension="field"
:disabled="!!form.pending.value"
:alt="'本次比较参考 ' + observation.imageNumber"
object-fit="contain"
preview
/>
<p
v-for="summary in referenceSummaries.get(observation.imageNumber)"
:key="summary"
class="wrap-anywhere text-xs leading-5 text-muted"
>
{{ summary }}
</p>
</div>
<div class="min-w-0 space-y-4">
<div class="source-review-findings">
<div
v-for="(label, field) in sourceFindingLabels"
:key="field"
class="workspace-form-field text-sm"
>
<span>{{ label }}</span>
<NSelect
v-model:value="observation.finding[field]"
:options="findingOptions"
:disabled="!!form.pending.value"
:aria-label="'参考 ' + (index + 1) + ' ' + label"
/>
</div>
</div>
<NInput
v-model:value="observation.note"
type="textarea"
:maxlength="2000"
:disabled="!!form.pending.value"
placeholder="记录可见事实;无法看清的部分保留未知"
:input-props="{ 'aria-label': '参考 ' + (index + 1) + ' 观察说明' }"
/>
<NCollapse
v-if="
form.preview.value.applicabilityBasis &&
(observation.finding.structure === 'unknown' ||
observation.finding.spatial === 'unknown')
"
>
<NCollapseItem name="applicability" title="不可见证据的适用范围(按需填写)">
<div class="space-y-4">
<section
v-for="field in (['structure', 'spatial'] as const).filter(
field => observation.finding[field] === 'unknown'
)"
:key="field"
class="space-y-2"
>
<h4 class="text-sm font-medium">{{ sourceFindingLabels[field] }}</h4>
<SourceApplicabilityFields
v-model="form.assessments.value"
:basis="form.preview.value.applicabilityBasis"
:image-number="observation.imageNumber"
:dimension="field"
:disabled="!!form.pending.value"
/>
</section>
</div>
</NCollapseItem>
</NCollapse>
</div>
<NInput
v-model:value="observation.note"
type="textarea"
:maxlength="2000"
:disabled="!!form.pending.value"
placeholder="逐图填写可见事实;看不清的安装点明确记录未知"
:input-props="{ 'aria-label': '参考 ' + (index + 1) + ' 观察说明' }"
/>
</section>
</div>
<NInput
@@ -304,56 +375,70 @@ const statusLabels: Record<string, string> = {
}}</pre>
</NCollapseItem></NCollapse
>
<NInput
v-model:value="form.approvedBy.value"
:disabled="!!form.pending.value"
placeholder="真实批准人"
aria-label="费用批准人"
/>
<NInput
v-model:value="form.operator.value"
:disabled="!!form.pending.value"
placeholder="真实操作人"
aria-label="费用操作人"
/>
<NInput
v-model:value="form.approvalSha256.value"
:disabled="!!form.pending.value"
placeholder="真实批准材料 SHA256(64 位)"
aria-label="批准材料摘要"
/>
<label class="block text-sm"
>批准估算下限(CNY)<NInputNumber
v-model:value="form.estimatedMin.value"
:disabled="!!form.pending.value"
:min="0"
placeholder="按真实批准填写"
aria-label="批准费用下限"
/></label>
<label class="block text-sm"
>批准估算上限(CNY)<NInputNumber
v-model:value="form.estimatedMax.value"
:disabled="!!form.pending.value"
:min="0"
placeholder="按真实批准填写"
aria-label="批准费用上限"
/></label>
<NCheckbox v-model:checked="form.approved.value" :disabled="!!form.pending.value"
>明确批准上述完整计划和费用范围</NCheckbox
>
<p v-if="form.authorizationId.value" class="wrap-anywhere text-sm">
本次授权编号:{{ form.authorizationId.value }}
</p>
<NCheckbox
v-if="form.authorizationId.value"
v-model:checked="form.executeApproved.value"
:disabled="!!form.pending.value"
>明确执行本次独立审核,可能产生上述费用</NCheckbox
<NCollapse
><NCollapseItem name="paid-approval" title="准备独立付费审核(按需展开)"
><div class="flex flex-col gap-4">
<NInput
v-model:value="form.approvedBy.value"
:disabled="!!form.pending.value"
placeholder="真实批准人"
aria-label="费用批准人"
/>
<NInput
v-model:value="form.operator.value"
:disabled="!!form.pending.value"
placeholder="真实操作人"
aria-label="费用操作人"
/>
<NInput
v-model:value="form.approvalSha256.value"
:disabled="!!form.pending.value"
placeholder="真实批准材料 SHA256(64 位)"
aria-label="批准材料摘要"
/>
<label class="workspace-form-field text-sm"
>批准估算下限(CNY)<NInputNumber
v-model:value="form.estimatedMin.value"
:disabled="!!form.pending.value"
:min="0"
placeholder="按真实批准填写"
aria-label="批准费用下限"
/></label>
<label class="workspace-form-field text-sm"
>批准估算上限(CNY)<NInputNumber
v-model:value="form.estimatedMax.value"
:disabled="!!form.pending.value"
:min="0"
placeholder="按真实批准填写"
aria-label="批准费用上限"
/></label>
<NCheckbox v-model:checked="form.approved.value" :disabled="!!form.pending.value"
>明确批准上述完整计划和费用范围</NCheckbox
>
<p v-if="form.authorizationId.value" class="wrap-anywhere text-sm">
本次授权编号:{{ form.authorizationId.value }}
</p>
<NCheckbox
v-if="form.authorizationId.value"
v-model:checked="form.executeApproved.value"
:disabled="!!form.pending.value"
>明确执行本次独立审核,可能产生上述费用</NCheckbox
>
</div></NCollapseItem
></NCollapse
>
</section>
<!-- 以下是原始观察及独立保存的适用性结论 -->
<section v-if="form.record.value?.applicabilityAssessment" class="space-y-2 text-sm">
<p v-for="(item, index) in form.record.value.applicabilityAssessment.assessments" :key="index">
<section
v-if="form.record.value?.applicabilityAssessment?.assessments.some(item => item.finding !== 'passed')"
class="space-y-2 text-sm"
>
<p
v-for="(item, index) in form.record.value.applicabilityAssessment.assessments.filter(
item => item.finding !== 'passed'
)"
:key="index"
>
参考 {{ item.imageNumber }} ·
{{
sourceFindingLabels[item.dimension as keyof typeof sourceFindingLabels] ?? item.dimension
@@ -374,6 +459,7 @@ const statusLabels: Record<string, string> = {
<KeyframeExecutionStatus
v-if="
form.vision.execution.data.value &&
['pending', 'running'].includes(form.vision.execution.data.value.status) &&
form.vision.history.data.value?.some(
r => r.sourceReviewId && r.executionId === form.vision.execution.data.value?.id
)
@@ -382,36 +468,43 @@ const statusLabels: Record<string, string> = {
:loading="form.vision.execution.loading.value"
@refresh="form.vision.execution.refresh"
/>
<section
v-for="record in form.vision.history.data.value?.filter(r => r.sourceReviewId)"
:key="record.id"
class="space-y-2"
>
<p class="wrap-anywhere text-sm">
独立新来源审核 · 人工记录 {{ record.sourceReviewId }} · 原任务 {{ record.id }} ·
{{ userFacingText(record.status) }}
</p>
<KeyframeExecutionHistory
:project-id="projectId"
:shot-id="shotId"
:keyframe-id="keyframeId"
:validation-task-id="record.id"
/>
</section>
<p v-if="resultLabel" class="text-sm" role="status">{{ resultLabel }}</p>
<NCollapse v-if="form.result.value"
><NCollapseItem title="本次完整回执(完成不等于通过)" name="receipt">
<pre class="whitespace-pre-wrap wrap-anywhere text-xs">{{
JSON.stringify(form.result.value, null, 2)
}}</pre>
<!-- 以下是默认收起的历史追溯,不让已结束执行干扰当前观察 -->
<NCollapse v-if="form.result.value || form.vision.history.data.value?.some(item => item.sourceReviewId)"
><NCollapseItem name="source-history" title="历史审核与执行记录">
<section
v-for="record in form.vision.history.data.value?.filter(r => r.sourceReviewId)"
:key="record.id"
class="space-y-2"
>
<p class="wrap-anywhere text-sm">
独立新来源审核 · 人工记录 {{ record.sourceReviewId }} · 原任务 {{ record.id }} ·
{{ userFacingText(record.status) }}
</p>
<KeyframeExecutionHistory
:project-id="projectId"
:shot-id="shotId"
:keyframe-id="keyframeId"
:validation-task-id="record.id"
/>
</section>
<NCollapse v-if="form.result.value"
><NCollapseItem title="本次完整回执(完成不等于通过)" name="receipt">
<pre class="whitespace-pre-wrap wrap-anywhere text-xs">{{
JSON.stringify(form.result.value, null, 2)
}}</pre>
</NCollapseItem></NCollapse
>
</NCollapseItem></NCollapse
>
<NButton :loading="form.vision.history.loading.value" @click="refreshQuality">只读刷新审核历史</NButton>
<NButton class="self-start" :loading="form.vision.history.loading.value" @click="refreshQuality"
>只读刷新审核历史</NButton
>
</div>
<template #footer>
<NButton :disabled="busy" @click="open = false">关闭</NButton>
<NButton
v-if="form.preview.value"
v-if="form.preview.value && form.needsSave.value"
type="primary"
:disabled="!!form.pending.value"
:loading="form.pending.value === 'save'"
@@ -419,7 +512,7 @@ const statusLabels: Record<string, string> = {
>保存人工观察(免费)</NButton
>
<NButton
v-if="form.plan.value"
v-if="form.plan.value && form.approved.value && !form.authorizationId.value"
type="primary"
:disabled="!!form.pending.value || !form.approved.value"
:loading="form.pending.value === 'authorize'"
@@ -451,3 +544,77 @@ const statusLabels: Record<string, string> = {
</template>
</AppDrawer>
</template>
<style>
/* 原图、参考与观察共享紧凑间距;列表由可用宽度决定列数,不把两张小图推向两端。 */
.source-review-body {
display: flex;
flex-direction: column;
gap: var(--app-content-gap);
}
.source-review-original {
display: flex;
align-items: flex-start;
gap: 24px;
}
.source-review-reference-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 600px), 1fr));
align-items: start;
gap: 24px;
}
/* 图片标题和字段标签共享 12px 间距,图片与首排控件的上沿必须一致。 */
.source-review-reference {
--app-field-label-gap: 12px;
display: grid;
grid-template-columns: 144px minmax(0, 1fr);
align-items: start;
gap: 20px;
}
.source-review-reference-media {
display: flex;
flex-direction: column;
gap: var(--app-field-label-gap);
min-width: 0;
}
.source-review-findings {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr));
gap: var(--app-field-gap);
}
/* 自然比例缩略图保留全部像素;原图、参考共用,不再用正方形容器制造侧边空白。 */
.source-review-image.asset-image {
display: block;
width: max-content;
max-width: 144px;
aspect-ratio: auto;
background: transparent;
}
.source-review-image.asset-image .reveal-image,
.source-review-image.asset-image .n-image {
width: auto;
height: auto;
background: transparent;
}
.source-review-image.asset-image .reveal-image .n-image img {
width: auto;
height: auto;
max-width: 144px;
max-height: 216px;
object-fit: contain;
}
.source-review-image.asset-image .reveal-image:not(.is-loaded) {
width: 144px;
min-height: 144px;
}
@media (max-width: 639px) {
.source-review-original {
flex-direction: column;
gap: 16px;
}
.source-review-reference {
grid-template-columns: minmax(0, 1fr);
gap: 16px;
}
}
</style>
+24 -3
View File
@@ -176,14 +176,35 @@ export const qualityApi = {
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/quality-review/reject`,
{ method: 'POST', body }
),
keyframeHistory: (shotId: string, keyframeId: string, signal?: AbortSignal, projectId?: string) =>
request<KeyframeValidationHistoryItem[]>(
/**
* 读取公开审核历史,把正式 output 中的来源关联补充到现有消费字段。
* @param shotId 正式镜头
* @param keyframeId 当前候选
* @param signal 取消信号
* @param projectId 项目范围
* @returns 保留原始输出的审核历史
*/
keyframeHistory: async (shotId: string, keyframeId: string, signal?: AbortSignal, projectId?: string) => {
const records = await request<KeyframeValidationHistoryItem[]>(
keyframeScope(
`/storyboard-shots/${encodeURIComponent(shotId)}/keyframes/${encodeURIComponent(keyframeId)}/validations`,
projectId
),
{ signal }
),
)
return records.map(record => {
const output = record.output && typeof record.output === 'object' ? record.output : null
return {
...record,
...(typeof output?.sourceReviewId === 'string' && output.sourceReviewId.trim()
? { sourceReviewId: record.sourceReviewId ?? output.sourceReviewId }
: {}),
...(typeof output?.evidenceKind === 'string'
? { evidenceKind: record.evidenceKind ?? output.evidenceKind }
: {})
}
})
},
/**
* 启动后台首帧质量生成,不把任务开始当作视觉通过。
* @param projectId 正式项目 ID
+72 -6
View File
@@ -39,6 +39,21 @@ export function useSourceReview(key: Ref<string>) {
const observations = ref<SourceObservation[]>([])
/** 人工证据范围,不默认豁免未知。 */
const assessments = ref<EvidenceAssessment[]>([])
/** 仅从仍有效的正式记录恢复原观察,不新增人工结论。 */
const restored = ref(false)
/** 原记录未变化时不再要求重复保存,只有编辑后才显示保存入口。 */
const needsSave = computed(
() =>
!restored.value ||
!record.value ||
JSON.stringify([reviewer.value, reason.value, observations.value, assessments.value]) !==
JSON.stringify([
record.value.review.reviewer,
record.value.review.reason,
record.value.review.observations,
record.value.review.applicability?.assessments ?? []
])
)
/** 正式授权只在本次页面内保留。 */
const authorizationId = ref('')
/** 批准人。 */
@@ -84,6 +99,7 @@ export function useSourceReview(key: Ref<string>) {
targetMatched.value = false
plan.value = null
reviewId.value = ''
restored.value = false
reviewer.value = ''
reason.value = ''
observations.value = []
@@ -112,6 +128,7 @@ export function useSourceReview(key: Ref<string>) {
watch(
reviewId,
() => {
restored.value = false
targetMatched.value = false
record.value = null
plan.value = null
@@ -144,6 +161,7 @@ export function useSourceReview(key: Ref<string>) {
} catch (cause) {
if (valid()) {
if (cause instanceof ApiError && cause.status === 409) {
restored.value = false
plan.value = null
authorizationId.value = ''
approved.value = false
@@ -156,9 +174,40 @@ export function useSourceReview(key: Ref<string>) {
if (target === key.value && cycle === epoch) pending.value = ''
}
}
/**
* 只恢复与当前来源及参考范围完全一致的原人工观察,未知保持原值。
* @param saved 正式回读的记录
* @param comparison 当前免费比较计划
* @returns 是否恢复了有效原稿
*/
function restoreRecord(saved: SourceReviewRecord, comparison: SourceReviewPreview) {
const [shot, image, project] = JSON.parse(key.value) as string[]
const numbers = comparison.currentReferenceInput.references.map(r => r.imageNumber).toSorted()
targetMatched.value =
saved.current &&
comparison.projectId === project &&
comparison.shotId === shot &&
comparison.keyframeId === image &&
comparison.fingerprint === saved.review.expectedFingerprint &&
JSON.stringify(saved.review.observations.map(o => o.imageNumber).toSorted()) === JSON.stringify(numbers) &&
(!saved.review.applicability ||
saved.review.applicability.expectedBasisFingerprint === comparison.applicabilityBasis?.fingerprint)
restored.value = false
if (!targetMatched.value) return false
observations.value = JSON.parse(JSON.stringify(saved.review.observations)) as SourceObservation[]
assessments.value = JSON.parse(
JSON.stringify(saved.review.applicability?.assessments ?? [])
) as EvidenceAssessment[]
reviewer.value = saved.review.reviewer
reason.value = saved.review.reason
restored.value = true
return true
}
/** 免费预检;只有用户操作才编译参考。 */
async function loadPreview() {
await run('preview', async ([s, k, p], signal, valid) => {
const existingReviewId = reviewId.value.trim()
restored.value = false
preview.value = null
assessments.value = []
plan.value = null
@@ -171,6 +220,8 @@ export function useSourceReview(key: Ref<string>) {
throw new Error('比较计划不属于当前首帧。')
reviewId.value = ''
preview.value = data
reviewer.value = ''
reason.value = ''
record.value = null
plan.value = null
observations.value = data.currentReferenceInput.references.map(reference => ({
@@ -184,16 +235,32 @@ export function useSourceReview(key: Ref<string>) {
},
note: ''
}))
// 只读寻找原任务关联的最近来源记录;没有正式记录时继续保留空白未知。
if (!vision.history.data.value && !vision.history.error.value) await vision.history.refresh()
if (!valid()) return
const savedId =
existingReviewId || vision.history.data.value?.find(item => item.sourceReviewId)?.sourceReviewId
if (savedId) {
reviewId.value = savedId
const saved = await sourceReviewApi.get(p!, savedId, signal)
if (!valid()) return
record.value = saved
restoreRecord(saved, data)
}
})
if (restored.value) await loadPlan()
}
/** 免费回读原人工记录;原结论保持不变。 */
async function readRecord() {
restored.value = false
await run('read', async ([, , p], signal, valid) => {
const data = await sourceReviewApi.get(p!, reviewId.value.trim(), signal)
if (!valid()) return
const [s, k] = JSON.parse(key.value) as string[]
record.value = data
preview.value = null
reviewer.value = ''
reason.value = ''
observations.value = []
assessments.value = []
targetMatched.value = false
@@ -212,15 +279,12 @@ export function useSourceReview(key: Ref<string>) {
},
note: ''
}))
targetMatched.value =
comparison.projectId === p &&
comparison.shotId === s &&
comparison.keyframeId === k &&
comparison.fingerprint === data.review.expectedFingerprint
restoreRecord(data, comparison)
plan.value = null
authorizationId.value = ''
}
})
if (restored.value) await loadPlan()
}
/** 保存全部人工观察,既有生产徽标不会据此变更。 */
async function save() {
@@ -273,7 +337,7 @@ export function useSourceReview(key: Ref<string>) {
!controller?.signal.aborted
) {
record.value = next
targetMatched.value = true
if (preview.value) restoreRecord(next, preview.value)
authorizationId.value = ''
plan.value = null
void vision.history.refresh()
@@ -379,6 +443,8 @@ export function useSourceReview(key: Ref<string>) {
})
}
return {
needsSave,
restored,
targetMatched,
vision,
preview,
+3 -9
View File
@@ -715,7 +715,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
><NTab name="design">设计与状态</NTab><NTab name="tools">参考图与提示词</NTab
><NTab name="motion">动作与视线</NTab><NTab name="keyframes">首帧</NTab></NTabs
>
<!-- 以下是统一标签内容起点与模块间距的动作和视线模块 -->
<!-- 以下是动作与视线模块,与首帧统一使用紧凑的标签内容起点 -->
<div
v-if="detailTab === 'motion'"
class="pt-6 workspace-section-stack workspace-section-stack-spacious"
@@ -755,14 +755,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<ShotDesign :shot="shot" />
</div>
<!-- 以下是独立于项目批量制作门禁的单镜头首帧 -->
<div v-if="detailTab === 'keyframes'" class="pt-4">
<p
v-if="keyframeReadiness.loading.value && !keyframeReadiness.data.value"
role="status"
class="text-xs text-muted"
>
正在检查本镜生成条件…
</p>
<div v-if="detailTab === 'keyframes'" class="pt-6">
<NButton
v-if="keyframeReadiness.error.value"
size="small"
@@ -775,6 +768,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
:shot="shot"
:episode-no="episodeNo"
:keyframe-readiness="shotReadiness"
:keyframe-readiness-loading="keyframeReadiness.loading.value"
keyframe-only
:disabled="blocked || !!keyframeReadiness.error.value"
@changed="keyframeReadiness.refresh"
@@ -55,7 +55,7 @@ const savedWarnings = computed(() =>
<template>
<section class="motion-plan-panel" aria-label="镜头动作时间轴">
<!-- 以下是与参考图模块一致的标题、刷新与计划摘要模块 -->
<WorkspaceSectionHeading title="动作时间轴">
<WorkspaceSectionHeading actions-placement="below" title="动作时间轴">
<template #actions>
<WorkspaceRefreshButton label="刷新动作计划" :loading="query.loading.value" @refresh="query.refresh" />
<NButton v-if="projectId" :disabled="disabled || !!query.error.value" @click="editing = true"
@@ -135,7 +135,11 @@ function exportResult(kind: 'spec' | 'prompt') {
<div class="workspace-section-stack workspace-section-stack-spacious">
<section>
<!-- 以下是统一的参考图模块标题、说明与刷新操作模块 -->
<WorkspaceSectionHeading title="主体参考图" description="查看当前镜头的主参考图。缺图时请先补齐。">
<WorkspaceSectionHeading
actions-placement="below"
title="主体参考图"
description="查看当前镜头的主参考图。缺图时请先补齐。"
>
<template #actions>
<WorkspaceRefreshButton
label="刷新参考图"
@@ -185,7 +189,11 @@ function exportResult(kind: 'spec' | 'prompt') {
</section>
<section>
<!-- 以下是统一的生成规格模块标题与读取操作模块 -->
<WorkspaceSectionHeading title="镜头生成方案" description="先补齐镜头设计和画面状态,再查看生成方案。">
<WorkspaceSectionHeading
actions-placement="below"
title="镜头生成方案"
description="先补齐镜头设计和画面状态,再查看生成方案。"
>
<template #actions>
<NButton
:disabled="locked || busy.spec || !shot.direction || !shot.visualState"
@@ -183,7 +183,11 @@ async function inspectGaze() {
<template>
<section class="spatial-bindings-panel" aria-label="人工确认视线目标">
<!-- 以下是统一的视线模块标题、说明与刷新操作模块 -->
<WorkspaceSectionHeading title="视线目标" description="选定朝向或注视目标后,请复查提示词和首帧。">
<WorkspaceSectionHeading
actions-placement="below"
title="视线目标"
description="选定朝向或注视目标后,请复查提示词和首帧。"
>
<template #actions>
<WorkspaceRefreshButton
label="刷新绑定"
+16
View File
@@ -3,6 +3,9 @@
/* 页面外层留白与模块间距统一为 15px,各工作区共用同一对齐基线。 */
--app-content-padding: 15px;
--app-content-gap: 15px;
/* 自定义字段统一使用真实布局间距,避免行内标签的垂直外边距失效。 */
--app-field-label-gap: 8px;
--app-field-gap: 16px;
--app-ink: #191919;
--app-muted: #707070;
--app-body: #ffffff;
@@ -803,3 +806,16 @@ body {
.n-button.workspace-action-button {
background: var(--app-control);
}
/* 中性辅助图标沿用公共正方形尺寸,消除文字按钮内边距对图标居中的影响。 */
.n-button.workspace-action-button.icon-button {
padding: 0;
}
/* 自定义表单字段的公共纵向布局,标签、控件之间必须保留清晰留白。 */
.workspace-form-field {
display: flex;
flex-direction: column;
gap: var(--app-field-label-gap);
min-width: 0;
}
+8 -1
View File
@@ -293,7 +293,14 @@ describe('全站平面主题', () => {
it('业务面板、列表分组和标签以背景区分,保留键盘焦点与选中指示', () => {
// happy-dom 不计算布局;此项保护 CSS 契约,不能替代浏览器视觉验收。
const css = readAllStyles()
expect(css).not.toMatch(/border-radius:\s*[1-9]/)
// 用户明确确认的首帧状态圆章是唯一例外,普通面板、按钮和标签仍必须保持直角。
const roundedRules = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)].filter(([, , declarations]) =>
/border-radius:\s*[1-9]/.test(declarations!)
)
expect(roundedRules.map(([, selector]) => selector!.replace(/\/\*[\s\S]*?\*\//g, '').trim())).toEqual([
'.production-condition-seal'
])
expect(roundedRules[0]?.[2]).toMatch(/border-radius:\s*50%;/)
// 主体身份的新流程用单条分隔线区分下一步操作,普通业务面板仍保持平面表面。
const separators = [...css.matchAll(/([^{}]+)\{([^{}]*)\}/g)]
.filter(([, , declarations]) =>
@@ -298,3 +298,116 @@ it('当前非阻断来源可查看独立计划,服务端明确拒绝时关闭
expect(mock.calls.length).toBe(before)
expect(form.plan.value).toBeNull()
})
/** 当前有效记录可以复用原观察,不把未知改成通过或自动批准。 */
it('回读有效记录保留未知和原理由,未编辑无需重复保存', async () => {
const mock = sourceMock('non_blocking_unknown')
Object.assign(mock.record, { validationEligible: true })
mock.record.review.observations[0]!.finding.structure = 'unknown'
vi.stubGlobal('fetch', mock.fetcher)
const form = scope.run(() => useSourceReview(ref(JSON.stringify(['s', 'k', 'p']))))!
await flushPromises()
form.reviewId.value = 'r'
await form.readRecord()
expect(form.restored.value).toBe(true)
expect(form.observations.value).toEqual(mock.record.review.observations)
expect(form.observations.value[0]!.finding.structure).toBe('unknown')
expect(form.reviewer.value).toBe('审核人')
expect(form.reason.value).toBe('理由')
expect(form.needsSave.value).toBe(false)
expect(form.plan.value?.reviewId).toBe('r')
expect(mock.calls.every(call => call.body === null)).toBe(true)
expect(form.approved.value).toBe(false)
expect(form.executeApproved.value).toBe(false)
form.observations.value[0]!.note = '补充当前可见证据'
expect(form.needsSave.value).toBe(true)
})
it.each(['stale', 'fingerprint', 'references'] as const)('%s 的旧观察不得回填到当前表单', async kind => {
const mock = sourceMock()
if (kind === 'stale') mock.record.current = false
if (kind === 'fingerprint') mock.record.review.expectedFingerprint = 'b'.repeat(64)
if (kind === 'references') mock.record.review.observations = []
vi.stubGlobal('fetch', mock.fetcher)
const form = scope.run(() => useSourceReview(ref(JSON.stringify(['s', 'k', 'p']))))!
await flushPromises()
form.reviewId.value = 'r'
await form.readRecord()
expect(form.restored.value).toBe(false)
expect(form.targetMatched.value).toBe(false)
expect(Object.values(form.observations.value[0]!.finding)).toEqual(Array(5).fill('unknown'))
expect(form.observations.value[0]!.note).toBe('')
expect(form.plan.value).toBeNull()
expect(mock.calls.every(call => call.body === null)).toBe(true)
})
it('显式免费预检会只读回查已有来源记录,匹配后直接恢复观察', async () => {
const mock = sourceMock()
vi.stubGlobal('fetch', mock.fetcher)
const form = scope.run(() => useSourceReview(ref(JSON.stringify(['s', 'k', 'p']))))!
await flushPromises()
form.reviewId.value = 'r'
await form.loadPreview()
expect(form.restored.value).toBe(true)
expect(form.needsSave.value).toBe(false)
expect(form.observations.value).toEqual(mock.record.review.observations)
expect(mock.calls.every(call => call.body === null)).toBe(true)
})
it('免费预检从原审核历史关联来源记录,无需手工输入编号', async () => {
const mock = sourceMock()
vi.stubGlobal('fetch', async (url: RequestInfo | URL, init?: RequestInit) => {
if (String(url).includes('/validations'))
return new Response(
JSON.stringify({
data: [
{
id: 'v',
status: 'completed',
output: { passed: true, sourceReviewId: 'r', evidenceKind: 'independent-source-vision' },
error: null,
steps: [],
startedAt: null,
finishedAt: null,
createdAt: '2026-11-09'
}
]
})
)
return mock.fetcher(url, init)
})
const form = scope.run(() => useSourceReview(ref(JSON.stringify(['s', 'k', 'p']))))!
await flushPromises()
expect(form.reviewId.value).toBe('')
await form.loadPreview()
expect(form.reviewId.value).toBe('r')
expect(form.restored.value).toBe(true)
expect(form.needsSave.value).toBe(false)
expect(mock.calls.every(call => call.body === null)).toBe(true)
})
it('回查原记录期间切换镜头,不接收迟到观察或发起批准', async () => {
const mock = sourceMock()
let finish!: (value: Response) => void
vi.stubGlobal('fetch', (url: RequestInfo | URL, init?: RequestInit) =>
String(url).endsWith('/source-reviews/r')
? new Promise<Response>(resolve => {
finish = resolve
})
: mock.fetcher(url, init)
)
const key = ref(JSON.stringify(['s', 'k', 'p']))
const form = scope.run(() => useSourceReview(key))!
await flushPromises()
form.reviewId.value = 'r'
const loading = form.loadPreview()
await flushPromises()
key.value = JSON.stringify(['s2', 'k2', 'p2'])
finish(new Response(JSON.stringify({ data: mock.record })))
await loading
expect(form.preview.value).toBeNull()
expect(form.restored.value).toBe(false)
expect(form.observations.value).toEqual([])
expect(form.reviewer.value).toBe('')
expect(mock.calls.every(call => call.body === null)).toBe(true)
})