diff --git a/src/features/production/components/KeyframeCard.vue b/src/features/production/components/KeyframeCard.vue index f0139f2..32ed6a6 100644 --- a/src/features/production/components/KeyframeCard.vue +++ b/src/features/production/components/KeyframeCard.vue @@ -6,8 +6,7 @@ import { productionMessage } from '../production-messages' import { useKeyframeVision } from '../keyframe-vision' import { computed, ref, watch } from 'vue' import SourceReviewDrawer from './SourceReviewDrawer.vue' -import { useQuery } from '../../../composables/useQuery' -import { qualityApi } from '../quality-api' +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' @@ -69,23 +68,16 @@ watch( ) /** 画幅不符的历史图保留浏览和只读审核记录。 */ const wrongCanvas = computed(() => props.item.canvasDiagnosis?.status === 'mismatch') -/** 质量状态以数据库为准;会话内检查仅在历史状态未知时兜底。 */ +/** 查询范围包含项目及来源证据,切换立即取消旧请求。 */ const reviewKey = computed(() => - props.item.status === 'completed' ? JSON.stringify([props.shotId, props.item.id, props.reviewRevision ?? 0]) : '' + props.item.status === 'completed' + ? JSON.stringify([props.shotId, props.item.id, props.projectId, props.reviewRevision ?? 0, props.item]) + : '' ) -const reviewQuery = useQuery(reviewKey, (value, signal) => { - if (!value) return Promise.resolve(null) - const [shotId, keyframeId] = JSON.parse(value) as [string, string, number] - return qualityApi.keyframeQualityReview(shotId, keyframeId, signal) -}) -const effectiveStatus = computed(() => reviewQuery.data.value?.effectiveQualityStatus ?? 'unknown') -/** 其余未达可用门禁的独立质量状态。 */ -const reviewLabels: Record = { - stale: '审核来源过期', - blocked: '质量受阻', - insufficient_evidence: '审核证据不足', - unknown: '质量待确认' -} +/** 所有质量徽标使用当前有效质量。 */ +const reviewQuery = useEffectiveKeyframeQuality(reviewKey, vision) +/** 当前有效质量,不使用会话内历史校验兜底。 */ +const effectiveStatus = reviewQuery.status /** 旧来源或已损坏的输入证据不能被会话中的历史通过覆盖。 */ const isPassed = computed( () => @@ -97,6 +89,11 @@ const isPassed = computed( props.item.inputSnapshotStatus !== 'invalid' && (effectiveStatus.value === 'passed' || effectiveStatus.value === 'manual_accepted') ) +/** 独立来源审核变化后同步当前候选和外层列表。 */ +function onSourceChanged() { + void reviewQuery.refresh() + emit('settled') +} /** 晋升入口只接受持久化通过和已结算审核。 */ const canSelect = computed( () => @@ -142,21 +139,11 @@ const canSelect = computed( 待人工复核 - 质量未通过 - - {{ reviewLabels[effectiveStatus] ?? '质量待确认' }} + + {{ effectiveQualityLabels[effectiveStatus] }} 视频参考图 已过期 @@ -267,5 +254,6 @@ const canSelect = computed( :project-id="projectId" :shot-id="shotId" :keyframe-id="item.id" + @changed="onSourceChanged" /> diff --git a/src/features/production/components/KeyframeExecutionStatus.vue b/src/features/production/components/KeyframeExecutionStatus.vue index 4871ec6..3fbb987 100644 --- a/src/features/production/components/KeyframeExecutionStatus.vue +++ b/src/features/production/components/KeyframeExecutionStatus.vue @@ -19,29 +19,10 @@ const props = withDefaults( ) /** 仅触发只读刷新。 */ const emit = defineEmits<{ refresh: [] }>() -/** 只有明确质量通过且未标记恢复才使用成功语义。 */ -const passed = computed( - () => - props.execution.status === 'completed' && - props.execution.result?.passed === true && - props.execution.result.qualityDecision === 'passed' && - props.execution.result.recoveryRequired !== true -) -/** 执行完成后仍清晰保留真实质量结论。 */ +/** 执行记录仅表达处理状态,当前质量由候选的正式接口独立展示。 */ const label = computed(() => { - if (passed.value) return '审核质量通过' - if (props.execution.status === 'failed') return '执行失败,质量未确认' - if (props.execution.status === 'completed') { - const quality = props.execution.result?.qualityDecision - const labels: Record = { - failed: '质量未通过', - needs_review: '质量待复核', - stale: '审核来源已失效', - blocked: '质量受阻', - insufficient_evidence: '证据不足' - } - return `执行完成,${typeof quality === 'string' && labels[quality] ? labels[quality] : props.execution.result?.passed === false ? '质量未通过' : '质量待核对'}` - } + if (props.execution.status === 'failed') return '执行失败,质量请查看当前结论' + if (props.execution.status === 'completed') return '执行完成,质量请查看当前结论' return props.execution.status === 'pending' ? '等待审核' : props.execution.status === 'running' @@ -52,7 +33,7 @@ const label = computed(() => { diff --git a/src/features/production/components/KeyframeValidationHistory.vue b/src/features/production/components/KeyframeValidationHistory.vue index dc5f0a9..ac47d69 100644 --- a/src/features/production/components/KeyframeValidationHistory.vue +++ b/src/features/production/components/KeyframeValidationHistory.vue @@ -8,7 +8,7 @@ import { computed, ref, watch } from 'vue' import { NButton, NInput } from 'naive-ui' import { errorMessage } from '../../../lib/http' import ReadonlyInspection from '../../../components/ui/ReadonlyInspection.vue' -import { useQuery } from '../../../composables/useQuery' +import { useEffectiveKeyframeQuality, effectiveQualityLabels } from '../effective-keyframe-quality' import { formatDate } from '../../../lib/format' import { physicalRetryTarget, submitKeyframeVision, useKeyframeVision } from '../keyframe-vision' import KeyframeExecutionHistory from './KeyframeExecutionHistory.vue' @@ -51,13 +51,8 @@ const visionKey = computed(() => ) : '' ) -const { - history: query, - execution, - state, - uncertain, - submissionMode -} = props.observation ?? useKeyframeVision(visionKey) +const observation = props.observation ?? useKeyframeVision(visionKey) +const { history: query, execution, state, uncertain, submissionMode } = observation /** 后台结束时同步刷新人工复核与候选状态。 */ watch( () => state.value.active, @@ -69,11 +64,7 @@ watch( } ) /** 复核证据仅在展开历史时读取,不触发 Vision 或写入审核结论。 */ -const reviewQuery = useQuery(key, (value, signal) => { - if (!value) return Promise.resolve(null) - const [, shotId, keyframeId] = JSON.parse(value) as [string | undefined, string, string] - return qualityApi.keyframeQualityReview(shotId, keyframeId, signal) -}) +const reviewQuery = useEffectiveKeyframeQuality(visionKey, observation) /** 当前正式质量摘要。 */ const review = computed(() => reviewQuery.data.value) /** 终止记录不能经人工接受绕过独立授权与 Primary 门禁。 */ @@ -197,14 +188,13 @@ const gazeEvidenceLabels: Record = { ambiguous: '不明确', unverifiable: '无法核实' } -const decisionLabel = (value: string) => - ({ - passed: 'AI 校验通过', - failed: 'AI 校验未通过', - needs_review: '需要人工复核', - manual_accepted: '人工已接受', - unknown: '未校验' - })[value] ?? '待确认' +/** + * 历史机器结论的中文名称,仅用于追溯。 + * @param value 原机器状态 + * @returns 可读质量名称 + */ +const decisionLabel = (value: keyof typeof effectiveQualityLabels) => effectiveQualityLabels[value] ?? '质量待确认' +/** 用户本次明确选择的人工决定。 */ const reviewAction = ref<'accepted' | 'rejected' | null>(null) const reviewReason = ref('') const reviewer = ref('user') @@ -212,10 +202,23 @@ const submitting = ref(false) const submitError = ref('') const submitSuccess = ref('') +/** 归属或门禁变化撤销旧表单,不能把旧确认带到新候选。 */ +watch( + [key, reviewQuery.manualReviewAvailable], + () => { + reviewAction.value = null + reviewReason.value = '' + submitError.value = '' + submitSuccess.value = '' + }, + { flush: 'sync' } +) + /** 人工接受必须先执行最新安全预检查;任何写入都需要明确按钮操作。 */ async function submitReview() { if ( !reviewAction.value || + !reviewQuery.manualReviewAvailable.value || !review.value?.validationTaskId || !reviewReason.value.trim() || !reviewer.value.trim() || @@ -295,8 +298,8 @@ const records = computed(() => >

当前质量复核

-

AI 检查:{{ terminatedReview ? '已终止,无有效结论' : decisionLabel(review.qualityDecision) }}

-

当前状态:{{ terminatedReview ? '质量未确认' : decisionLabel(review.effectiveQualityStatus) }}

+

历史机器结论:{{ terminatedReview ? '已终止,无有效结论' : decisionLabel(review.qualityDecision) }}

+

当前状态:{{ effectiveQualityLabels[reviewQuery.status.value] }}

人工审核:{{ review.manualReview.decision === 'accepted' ? '已接受' : '已拒绝' }} · {{ review.manualReview.reason || '未填写理由' }} @@ -312,7 +315,7 @@ const records = computed(() =>

{{ item.reason }}

-
+

人工复核

请先预览候选图片并确认视觉效果。接受会替换当前主首帧,拒绝只保存审核记录。

diff --git a/src/features/production/components/QualityDialog.vue b/src/features/production/components/QualityDialog.vue index 636e22c..6fd690b 100644 --- a/src/features/production/components/QualityDialog.vue +++ b/src/features/production/components/QualityDialog.vue @@ -14,6 +14,7 @@ import { AppDialog } from '../../../components/ui' import { useKeyframeVision } from '../keyframe-vision' import { allowedTextLines, validQualityInput } from '../quality' import type { QualityAction, QualityInput, QualityTarget } from '../quality.types' +import { useEffectiveKeyframeQuality } from '../effective-keyframe-quality' import { useQuality } from '../useQuality' import QualityResult from './QualityResult.vue' import KeyframeValidationHistory from './KeyframeValidationHistory.vue' @@ -49,6 +50,7 @@ const { key, session, operation, execution, blocked, run } = useQuality( () => { emit('changed') void videoQuery.refresh() + void currentQuality.refresh() }, id => emit('started', id) ) @@ -59,6 +61,13 @@ const visionKey = computed(() => : '' ) const vision = useKeyframeVision(visionKey) +/** 当前候选质量独立回读,不以本会话或后台回执作为当前结论。 */ +const currentQuality = useEffectiveKeyframeQuality(visionKey, vision) +/** 人工审核完成后同步当前质量和外层资产。 */ +function onReviewed() { + void currentQuality.refresh() + emit('changed') +} /** 有原参数时继续;没有原参数时保留只读核查。 */ const visionBlocked = computed(() => !!visionKey.value && vision.blocked.value) /** 质量弹窗重新读取所选候选自身的权限,不以会话历史代替后端事实。 */ @@ -486,10 +495,15 @@ const optionsExpanded = ref(['options']) :observation="vision" :disabled="disabled || pending" initial-open - @reviewed="emit('changed')" + @reviewed="onReviewed" @busy="authorizationPending = $event" /> - +

{{ saved.summary }}

diff --git a/src/features/production/components/QualityResult.vue b/src/features/production/components/QualityResult.vue index 396be35..c1cfe98 100644 --- a/src/features/production/components/QualityResult.vue +++ b/src/features/production/components/QualityResult.vue @@ -6,11 +6,15 @@ import ContextNotice from '../../../components/ui/ContextNotice.vue' import { computed } from 'vue' import { NButton, NCollapse, NCollapseItem } from 'naive-ui' import { downloadText } from '../../../lib/format' -import { keyframeValidationPassed } from '../quality' +import { effectiveQualityLabels } from '../effective-keyframe-quality' +import type { EffectiveKeyframeQualityStatus } from '../quality-api' import type { QualityReceipt } from '../quality.types' /** 摘要、失败与完整逐轮信息默认直接显示,不用完成请求冒充质量通过。 */ -const props = defineProps<{ receipt: QualityReceipt }>() +const props = defineProps<{ + /** 原操作历史回执。 */ receipt: QualityReceipt + /** 首帧当前质量只来自正式回读;尚未取得时为未知。 */ currentStatus?: EffectiveKeyframeQualityStatus +}>() /** 逐镜结果定位事件。 */ const emit = defineEmits<{ locate: [shotId: string] }>() /** 完整最终回执的视觉结论。 */ @@ -20,7 +24,7 @@ const passed = computed(() => : props.receipt.kind === 'video-repair' ? false : props.receipt.kind === 'keyframe' - ? keyframeValidationPassed(props.receipt.result) + ? props.currentStatus === 'passed' || props.currentStatus === 'manual_accepted' : props.receipt.result.passed ) /** 当前失败问题列表。 */ @@ -57,15 +61,30 @@ function exportResult() {
- {{ - receipt.kind === 'video-repair' - ? '修复任务已提交' - : passed - ? '视觉校验通过' - : receipt.kind === 'batch' && !receipt.result.targetCount - ? '未执行镜头' - : '仍需处理' - }} + {{ + receipt.kind === 'keyframe' + ? effectiveQualityLabels[currentStatus ?? 'unknown'] + : receipt.kind === 'video-repair' + ? '修复任务已提交' + : passed + ? receipt.kind === 'video' + ? '视觉校验通过' + : '本次执行记录通过' + : receipt.kind === 'batch' && !receipt.result.targetCount + ? '未执行镜头' + : '仍需处理' + }} 导出结果