267 lines
12 KiB
Vue
267 lines
12 KiB
Vue
<script setup lang="ts">
|
||
import ContextNotice from '../../../components/ui/ContextNotice.vue'
|
||
|
||
import IssueHint from '../../../components/ui/IssueHint.vue'
|
||
import { productionMessage } from '../production-messages'
|
||
import { useKeyframeVision } from '../keyframe-vision'
|
||
import { computed, ref, watch } from 'vue'
|
||
import SourceReviewDrawer from './SourceReviewDrawer.vue'
|
||
import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality'
|
||
import { NButton, NTag } from 'naive-ui'
|
||
import { AssetImage, AssetOpenLink, StatusBadge } from '../../../components/ui'
|
||
import { formatDate } from '../../../lib/format'
|
||
import { productionStatusLabel } from '../model'
|
||
import type { ShotKeyframe } from '../types'
|
||
|
||
/** 首帧卡片统一主图标识、质量结论和晋升限制。 */
|
||
const props = defineProps<{
|
||
item: ShotKeyframe
|
||
/** 正式项目归属,用于查询候选审核。 */
|
||
projectId?: string
|
||
shotId: string
|
||
/** 审核后递增以刷新持久化质量状态。 */
|
||
reviewRevision?: number
|
||
shotNo: number
|
||
stale: boolean
|
||
blocked: boolean
|
||
/** 只在当前源图编辑任务运行期间显示局部加载。 */
|
||
editing?: boolean
|
||
/** 仅本候选在下载时显示加载。 */
|
||
recovering?: boolean
|
||
validationPassed: boolean | null
|
||
confirming: boolean
|
||
}>()
|
||
/** 用户显式打开来源复核,不能自动调用模型。 */
|
||
const sourceReviewOpen = ref(false)
|
||
watch(
|
||
() => JSON.stringify([props.projectId, props.shotId, props.item.id]),
|
||
() => {
|
||
sourceReviewOpen.value = false
|
||
},
|
||
{ flush: 'sync' }
|
||
)
|
||
/** 用户显式触发候选审核、确认或免费恢复。 */
|
||
const emit = defineEmits<{
|
||
recover: []
|
||
quality: []
|
||
edit: []
|
||
select: []
|
||
confirm: []
|
||
cancel: []
|
||
history: []
|
||
settled: []
|
||
}>()
|
||
/** 每张可见候选可独立找回自己的审核任务。 */
|
||
const visionKey = computed(() =>
|
||
props.item.status === 'completed'
|
||
? JSON.stringify(
|
||
props.projectId ? [props.shotId, props.item.id, props.projectId] : [props.shotId, props.item.id]
|
||
)
|
||
: ''
|
||
)
|
||
const vision = useKeyframeVision(visionKey, false)
|
||
watch(
|
||
() => vision.state.value.active,
|
||
(active, previous) => {
|
||
if (previous && !active && visionKey.value) emit('settled')
|
||
}
|
||
)
|
||
/** 画幅不符的历史图保留浏览和只读审核记录。 */
|
||
const wrongCanvas = computed(() => props.item.canvasDiagnosis?.status === 'mismatch')
|
||
/** 查询范围包含项目及来源证据,切换立即取消旧请求。 */
|
||
const reviewKey = computed(() =>
|
||
props.item.status === 'completed'
|
||
? JSON.stringify([props.shotId, props.item.id, props.projectId, props.reviewRevision ?? 0, props.item])
|
||
: ''
|
||
)
|
||
/** 所有质量徽标使用当前有效质量。 */
|
||
const reviewQuery = useEffectiveKeyframeQuality(reviewKey, vision)
|
||
/** 当前有效质量,不使用会话内历史校验兜底。 */
|
||
const effectiveStatus = reviewQuery.status
|
||
/** 旧来源或已损坏的输入证据不能被会话中的历史通过覆盖。 */
|
||
const isPassed = computed(
|
||
() =>
|
||
!props.stale &&
|
||
!vision.history.data.value?.some(
|
||
item => item.id === reviewQuery.data.value?.validationTaskId && item.legacyTermination
|
||
) &&
|
||
!wrongCanvas.value &&
|
||
props.item.inputSnapshotStatus !== 'invalid' &&
|
||
(effectiveStatus.value === 'passed' || effectiveStatus.value === 'manual_accepted')
|
||
)
|
||
/** 独立来源审核变化后同步当前候选和外层列表。 */
|
||
function onSourceChanged() {
|
||
void reviewQuery.refresh()
|
||
emit('settled')
|
||
}
|
||
/** 晋升入口只接受持久化通过和已结算审核。 */
|
||
const canSelect = computed(
|
||
() =>
|
||
props.item.status === 'completed' &&
|
||
!!props.item.imageUrl &&
|
||
props.item.source !== 'provider_variant' &&
|
||
!props.item.isPrimary &&
|
||
!props.stale &&
|
||
props.item.inputSnapshotStatus !== 'invalid' &&
|
||
isPassed.value &&
|
||
!reviewQuery.error.value &&
|
||
!vision.blocked.value &&
|
||
!vision.state.value.resumable
|
||
)
|
||
</script>
|
||
|
||
<template>
|
||
<article class="keyframe-card">
|
||
<!-- 以下是首帧画面模块,主图身份通过下方文字标签说明 -->
|
||
<div class="relative">
|
||
<AssetImage
|
||
:src="item.status === 'completed' ? item.imageUrl : null"
|
||
:alt="`镜头 ${shotNo} 首帧`"
|
||
preview
|
||
:empty-text="item.status === 'failed' ? '首帧生成失败' : '首帧生成中'"
|
||
/>
|
||
<AssetOpenLink :src="item.status === 'completed' ? item.imageUrl : null" label="打开图片" />
|
||
</div>
|
||
<div class="p-3">
|
||
<div class="flex flex-wrap items-center gap-2">
|
||
<StatusBadge :status="item.status" :label="productionStatusLabel(item.status)" />
|
||
<NTag v-if="item.source !== 'provider_variant'" size="small" :bordered="false">
|
||
{{ item.isPrimary ? '主首帧' : '候选首帧' }}
|
||
</NTag>
|
||
<NTag
|
||
v-if="effectiveStatus === 'manual_accepted' && isPassed"
|
||
size="small"
|
||
type="success"
|
||
:bordered="false"
|
||
>人工已接受</NTag
|
||
>
|
||
<NTag v-else-if="isPassed" size="small" type="success" :bordered="false">质量通过</NTag>
|
||
<NTag v-else-if="effectiveStatus === 'needs_review'" size="small" type="warning" :bordered="false"
|
||
>待人工复核</NTag
|
||
>
|
||
<NTag v-else-if="effectiveStatus === 'failed'" size="small" type="error" :bordered="false"
|
||
>质量未通过</NTag
|
||
>
|
||
<NTag v-else-if="item.status === 'completed'" size="small" :bordered="false">
|
||
{{ effectiveQualityLabels[effectiveStatus] }}
|
||
</NTag>
|
||
<NTag v-if="item.source === 'provider_variant'" size="small" :bordered="false">视频参考图</NTag>
|
||
<NTag v-if="item.isPrimary && stale" size="small" type="warning" :bordered="false">已过期</NTag>
|
||
<!-- 以下是完整尺寸信息模块,数据缺失时隐藏 -->
|
||
<span v-if="item.width && item.height" class="text-[10px] text-muted"
|
||
>{{ item.width }} × {{ item.height }}</span
|
||
>
|
||
</div>
|
||
<!-- 以下是候选的来源、画幅与后台审核状态 -->
|
||
<p v-if="item.provider || item.model" class="mt-2 wrap-anywhere text-xs text-muted">
|
||
{{ [item.provider, item.model].filter(Boolean).join(' / ') }}
|
||
</p>
|
||
<p
|
||
v-if="item.canvasDiagnosis && item.status === 'completed'"
|
||
class="mt-2 text-xs"
|
||
:class="wrongCanvas ? 'text-danger' : 'text-muted'"
|
||
>
|
||
{{
|
||
wrongCanvas
|
||
? `历史画幅 ${item.canvasDiagnosis.actual ?? '未知'} 与交付画幅 ${item.canvasDiagnosis.expected ?? '未知'} 不符,仅供查看。`
|
||
: item.canvasDiagnosis.status === 'matched'
|
||
? `匹配交付画幅 ${item.canvasDiagnosis.expected}`
|
||
: '画幅尚未确认'
|
||
}}
|
||
</p>
|
||
<p
|
||
v-if="vision.state.value.active || vision.state.value.unknown || vision.uncertain.value"
|
||
role="status"
|
||
class="mt-2 text-xs text-muted"
|
||
>
|
||
{{ vision.state.value.active?.executionId ? '质量审核在后台进行' : '审核结果或费用待核查' }}
|
||
</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: '生成输入证据已失效' }[
|
||
item.inputSnapshotStatus
|
||
]
|
||
}}
|
||
<span v-if="item.providerInputFingerprint" :title="item.providerInputFingerprint">
|
||
· {{ item.providerInputFingerprint.slice(0, 12) }}</span
|
||
>
|
||
</p>
|
||
<p v-if="item.recoveryRequired" class="mt-2 text-xs text-muted">
|
||
{{
|
||
productionMessage(
|
||
item.recoveryReason ||
|
||
(item.canRecoverSavedResult
|
||
? '可以恢复已生成图片的下载。'
|
||
: '原请求结果待核查,请先核对候选和模型服务记录。')
|
||
)
|
||
}}
|
||
</p>
|
||
<NButton
|
||
v-if="item.canRecoverSavedResult"
|
||
class="mt-2"
|
||
size="small"
|
||
:disabled="blocked || recovering"
|
||
:loading="recovering"
|
||
@click="emit('recover')"
|
||
>恢复已生成图片</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
|
||
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
|
||
>
|
||
<NButton v-if="canSelect" :disabled="blocked" text size="small" @click="emit('select')">
|
||
设为主首帧
|
||
</NButton>
|
||
</div>
|
||
<ContextNotice v-if="confirming && canSelect" type="info" :show-icon="false" class="mt-2 text-xs">
|
||
<p>该候选已满足当前质量要求。确认让后续视频使用此首帧?</p>
|
||
<div class="mt-2 flex gap-3">
|
||
<NButton type="primary" :disabled="blocked" @click="emit('confirm')">确认切换</NButton>
|
||
<NButton text size="small" @click="emit('cancel')">取消</NButton>
|
||
</div>
|
||
</ContextNotice>
|
||
</div>
|
||
</article>
|
||
<SourceReviewDrawer
|
||
v-if="projectId && sourceReviewOpen"
|
||
v-model:open="sourceReviewOpen"
|
||
:project-id="projectId"
|
||
:shot-id="shotId"
|
||
:keyframe-id="item.id"
|
||
@changed="onSourceChanged"
|
||
/>
|
||
</template>
|