feat(short-drama-agent-front): 接入联合修订与图片费用审计

This commit is contained in:
GJ committed 2026-11-16 17:20:18 +08:00
1 parent 87427d9d43
commit f6edc4eb70
52 files changed
+5060 -516

No files matched your search

@@ -0,0 +1,183 @@
<script setup lang="ts">
import { computed } from 'vue'
import { NButton, NInput, NInputNumber, NSelect } from 'naive-ui'
import { Trash2 } from '@lucide/vue'
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
import { auditArtifactLabels, auditFindingLabels, auditOutcomeLabels } from './labels'
import type { BillingFacts } from './types'
/** 图片和视频费用审计共用的证据字段,不替用户确认原件。 */
defineProps<{ /** 正式提交期间锁定编辑。 */ disabled: boolean }>()
/** 实际登记人。 */
const operator = defineModel<string>('operator', { required: true })
/** 完整待登记事实,原请求身份由各域的正式GET注入。 */
const facts = defineModel<BillingFacts>({ required: true })
/** 引用选项仅来自当前包内材料。 */
const options = computed(() =>
facts.value.artifacts
.filter(item => item.id.trim())
.map(item => ({ label: `${item.id} · ${item.recordId || '未填记录编号'}`, value: item.id }))
)
/**
* 每次字段更新发出完整事实,兼容原有ref表单映射。
* @param change 用户本次修改
*/
function update(change: Partial<BillingFacts>) {
facts.value = { ...facts.value, ...change }
}
/** 仅添加空白材料,不预填供应方事实或摘要。 */
function add() {
update({
artifacts: [...facts.value.artifacts, { id: '', kind: 'client-log', recordId: '', sha256: '', reference: '' }]
})
}
/**
* 移除材料时清理悬空引用,不补造其它材料。
* @param index 待移除材料的位置
*/
function remove(index: number) {
const id = facts.value.artifacts[index]?.id
update({
artifacts: facts.value.artifacts.filter((_, current) => current !== index),
execution: {
...facts.value.execution,
evidenceIds: facts.value.execution.evidenceIds.filter(value => value !== id)
},
billing: { ...facts.value.billing, evidenceIds: facts.value.billing.evidenceIds.filter(value => value !== id) }
})
}
</script>
<template>
<!-- 以下是媒体域共用的原件登记模块,未知事实保持未知。 -->
<div class="workspace-section-stack">
<p class="text-sm text-muted">
请保存原件并填写非敏感定位说明。供应方请求号与本地请求、LangSmith 编号不能互相代用。
</p>
<label class="workspace-form-field"
><span>登记人</span
><NInput v-model:value="operator" :maxlength="120" :disabled="disabled" aria-label="费用证据登记人"
/></label>
<div class="workspace-form-field">
<span>与原请求的关联</span
><NSelect
:value="facts.correlation"
@update:value="update({ correlation: $event })"
:disabled="disabled"
aria-label="与原请求的关联"
:options="[
{ label: '尚未核实', value: 'unverified' },
{ label: '关联有歧义', value: 'ambiguous' },
{ label: '已唯一关联', value: 'unique' }
]"
/>
</div>
<label class="workspace-form-field"
><span>真实供应方请求号(未知留空)</span
><NInput
:value="facts.providerRequestId ?? ''"
@update:value="update({ providerRequestId: $event || null })"
:maxlength="200"
:disabled="disabled"
aria-label="真实供应方请求号"
/></label>
<article
v-for="(item, index) in facts.artifacts"
:key="index"
class="surface-inset p-4 workspace-section-stack min-w-0"
>
<div class="flex items-center justify-between gap-3">
<h4 class="text-sm font-medium">原件 {{ index + 1 }}</h4>
<WorkspaceActionTooltip label="删除原件"
><NButton
class="workspace-action-button icon-button"
:disabled="disabled"
aria-label="删除原件"
@click="remove(index)"
><Trash2 :size="16" /></NButton
></WorkspaceActionTooltip>
</div>
<label class="workspace-form-field"
><span>包内引用键</span
><NInput v-model:value="item.id" :maxlength="120" :disabled="disabled" aria-label="原件包内引用键"
/></label>
<div class="workspace-form-field">
<span>原件来源</span
><NSelect
v-model:value="item.kind"
:options="Object.entries(auditArtifactLabels).map(([value, label]) => ({ value, label }))"
:disabled="disabled"
aria-label="原件来源"
/>
</div>
<label class="workspace-form-field"
><span>原件记录编号</span
><NInput v-model:value="item.recordId" :maxlength="200" :disabled="disabled" aria-label="原件记录编号"
/></label>
<label class="workspace-form-field"
><span>原件 SHA256</span
><NInput v-model:value="item.sha256" :maxlength="64" :disabled="disabled" aria-label="原件 SHA256"
/></label>
<label class="workspace-form-field"
><span>非敏感原件定位说明</span
><NInput
v-model:value="item.reference"
type="textarea"
:maxlength="1000"
:disabled="disabled"
aria-label="原件定位说明"
/></label>
</article>
<NButton class="self-start" :disabled="disabled || facts.artifacts.length >= 20" @click="add">添加原件</NButton>
<div class="workspace-form-field">
<span>供应方执行结果</span
><NSelect
:value="facts.execution.outcome"
@update:value="update({ execution: { ...facts.execution, outcome: $event } })"
:options="Object.entries(auditOutcomeLabels).map(([value, label]) => ({ value, label }))"
:disabled="disabled"
aria-label="供应方执行结果"
/>
</div>
<div class="workspace-form-field">
<span>执行依据原件</span
><NSelect
:value="facts.execution.evidenceIds"
@update:value="update({ execution: { ...facts.execution, evidenceIds: $event } })"
multiple
:options="options"
:disabled="disabled"
aria-label="执行依据原件"
/>
</div>
<div class="workspace-form-field">
<span>原始费用结论</span
><NSelect
:value="facts.billing.finding"
@update:value="update({ billing: { ...facts.billing, finding: $event } })"
:options="Object.entries(auditFindingLabels).map(([value, label]) => ({ value, label }))"
:disabled="disabled"
aria-label="原始费用结论"
/>
</div>
<div class="workspace-form-field">
<span>费用依据原件</span
><NSelect
:value="facts.billing.evidenceIds"
@update:value="update({ billing: { ...facts.billing, evidenceIds: $event } })"
multiple
:options="options"
:disabled="disabled"
aria-label="费用依据原件"
/>
</div>
<label class="workspace-form-field"
><span>实际金额({{ facts.billing.currency }},未知留空)</span
><NInputNumber
:value="facts.billing.amount"
@update:value="update({ billing: { ...facts.billing, amount: $event } })"
:min="0"
clearable
:disabled="disabled"
aria-label="原件实际金额"
/></label>
</div>
</template>
+41
View File
@@ -0,0 +1,41 @@
import type { BillingFacts } from './types'
/**
* 校验共用原件及引用格式,未知声明可登记,不证明原件真实。
* @param evidence 当前完整事实
* @param localIds 不能冒充供应方编号的原本地身份
* @returns 字段校验原因
*/
export function billingEvidenceIssues(
evidence: BillingFacts,
localIds: readonly (string | undefined)[] = []
): string[] {
const issues: string[] = []
const ids = evidence.artifacts.map(item => item.id)
if (!ids.length || ids.length > 20 || new Set(ids).size !== ids.length)
issues.push('请提供 1~20 项原件,引用键不能重复。')
if (
evidence.artifacts.some(
item =>
!item.id.trim() ||
item.id.length > 120 ||
!item.recordId.trim() ||
item.recordId.length > 200 ||
!/^[a-f0-9]{64}$/.test(item.sha256) ||
!item.reference.trim() ||
item.reference.length > 1000
)
)
issues.push('请填写每项原件的引用键、记录编号、64 位小写 SHA256 及定位说明。')
if ([...evidence.execution.evidenceIds, ...evidence.billing.evidenceIds].some(id => !ids.includes(id)))
issues.push('执行或费用引用的原件已不存在,请重新选择。')
if (evidence.billing.amount !== null && (!Number.isFinite(evidence.billing.amount) || evidence.billing.amount < 0))
issues.push('实际金额需为非负数,未知请留空。')
if (
evidence.providerRequestId &&
(localIds.includes(evidence.providerRequestId) ||
evidence.artifacts.some(item => item.kind === 'langsmith' && item.recordId === evidence.providerRequestId))
)
issues.push('本地任务、请求或 LangSmith 编号不能作为供应方请求号。')
return issues
}
+17
View File
@@ -0,0 +1,17 @@
/** 原件来源使用中文选项,提交保留原枚举。 */
export const auditArtifactLabels = {
'provider-execution': '供应方执行原件',
'provider-billing': '供应方账单原件',
'provider-support': '供应方官方支持材料',
langsmith: 'LangSmith 观测记录',
'client-log': '客户端日志'
}
/** 原执行结论不替代质量结论。 */
export const auditOutcomeLabels = {
'not-received': '供应方未接收',
succeeded: '供应方执行完成',
failed: '供应方执行失败',
unknown: '执行结果未知'
}
/** 原收费结论不以零 Token 推断。 */
export const auditFindingLabels = { charged: '已收费', 'no-charge': '未收费', unknown: '费用未知' }
+24
View File
@@ -0,0 +1,24 @@
/** 图片与视频共用的外部原件,声明来源不代表已核实。 */
export interface BillingArtifact {
/** 包内唯一引用键。 */ id: string
/** 原件来源。 */ kind: 'provider-execution' | 'provider-billing' | 'provider-support' | 'langsmith' | 'client-log'
/** 外部原记录编号。 */ recordId: string
/** 用户核对的原件摘要。 */ sha256: string
/** 不含凭据的定位说明。 */ reference: string
}
/** 共享执行与费用事实,不包含图片或视频特有身份。 */
export interface BillingFacts {
/** 关联程度。 */ correlation: 'unique' | 'ambiguous' | 'unverified'
/** 真实供应方编号,未知保持null。 */ providerRequestId: string | null
/** 待核查外部材料。 */ artifacts: BillingArtifact[]
/** 执行事实。 */ execution: {
/** 执行结论。 */ outcome: 'not-received' | 'succeeded' | 'failed' | 'unknown'
/** 包内原件引用。 */ evidenceIds: string[]
}
/** 费用事实,不能改写原账单。 */ billing: {
/** 费用结论。 */ finding: 'charged' | 'no-charge' | 'unknown'
/** 实际金额,未知为null。 */ amount: number | null
/** 原币种。 */ currency: string
/** 包内账单引用。 */ evidenceIds: string[]
}
}
@@ -1,4 +1,5 @@
<script setup lang="ts">
import ImageBillingAuditPanel from './ImageBillingAuditPanel.vue'
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton, NCheckbox, NDatePicker, NInput, NInputNumber, NSelect, NCollapse, NCollapseItem } from 'naive-ui'
import { useQuery } from '../../composables/useQuery'
@@ -31,24 +32,44 @@ const query = useQuery(key, (id, signal) => imageAuthorizationApi.list(id, signa
/** 授权型号来自真实目录。 */
const catalog = useQuery(key, (_, signal) => generationConfigApi.catalog(signal))
/** 当前用户明确填写的授权草稿,金额、次数及时间均不预填。 */
const draft = ref({
models: [] as string[],
scopes: [] as ImageAuthorizationScope[],
targets: '',
budget: '',
reserve: '',
count: null as number | null,
expires: null as number | null,
approvedBy: '',
note: '',
accepted: false
})
/**
* 新项目和成功登记后都使用空草稿,不继承其它项目的批准。
* @returns 未填写金额、次数、范围与确认的表单
*/
function emptyAuthorizationDraft() {
return {
models: [] as string[],
scopes: [] as ImageAuthorizationScope[],
targets: '',
budget: '',
reserve: '',
count: null as number | null,
expires: null as number | null,
approvedBy: '',
note: '',
accepted: false
}
}
/** 用户明确填写的持续授权草稿。 */
const draft = ref(emptyAuthorizationDraft())
/** 原设置抽屉内的费用审计模式,不叠加新主界面。 */
const auditRequestId = ref('')
/** 同一固定底栏提交当前图片审计。 */
const auditPanel = ref<InstanceType<typeof ImageBillingAuditPanel> | null>(null)
/** 用户主动选择追加的原unknown请求。 */
const additionalRequestId = ref('')
/** 追加次数和接受风险均不预填。 */
const additionalDraft = ref({ count: null as number | null, approvedBy: '', note: '', accepted: false })
/** 当前真实原请求,镜头、型号、来源及计划不能由表单改写。 */
const additionalRequest = computed(() => query.data.value?.requests.find(row => row.id === additionalRequestId.value))
/** 原批准撤销目标。 */
const revokeId = ref('')
/** 实际撤销操作者及理由。 */
const revocation = ref({ revokedBy: '', reason: '' })
/** 同步写入的就地加载。 */
const saving = ref(false)
/** 写入后刷新期间保持本次操作名称,不误显示其它授权动作。 */
const pendingSubmitLabel = ref('')
/** 同草稿失败后仍使用原幂等键,不能自动另开授权。 */
const idempotencyKey = ref(crypto.randomUUID())
/** 只在主动提交时显示校验消息。 */
@@ -67,20 +88,31 @@ const modelOptions = computed(
/** 所有范围名称与真实枚举共用。 */
const scopeOptions = Object.entries(imageScopeLabels).map(([value, label]) => ({ label, value }))
/** 撤销与创建各有独立提交名称。 */
const submitLabel = computed(() => (revokeId.value ? '确认撤销授权' : '登记有限持续授权'))
/** 读取失败时保守禁止写入,空表单允许主动校验。 */
const canSave = computed(
const submitLabel = computed(
() =>
!props.disabled &&
!saving.value &&
!!query.data.value &&
!query.loading.value &&
!query.error.value &&
(revokeId.value !== '' || !!modelOptions.value.length)
pendingSubmitLabel.value ||
(auditRequestId.value
? (auditPanel.value?.submitLabel ?? '读取图片费用审计')
: revokeId.value
? '确认撤销授权'
: additionalRequestId.value
? '登记人工有限追加许可'
: '登记有限持续授权')
)
/** 读取失败时保守禁止写入,空表单允许主动校验。 */
const canSave = computed(() =>
auditRequestId.value
? !!auditPanel.value?.canSubmit
: !props.disabled &&
!saving.value &&
!!query.data.value &&
!query.loading.value &&
!query.error.value &&
(revokeId.value !== '' || additionalRequestId.value !== '' || !!modelOptions.value.length)
)
watch(saving, value => emit('busy', value), { flush: 'sync' })
watch(
[draft, revocation],
[draft, revocation, additionalDraft],
() => {
validation.value = ''
},
@@ -90,12 +122,36 @@ watch(
/** 校验后同步登记或撤销,不触发图片生成。 */
async function save() {
if (!canSave.value) return
if (auditRequestId.value) {
await auditPanel.value?.submit()
return
}
const project = props.projectId
if (revokeId.value) {
if (!revocation.value.revokedBy.trim() || !revocation.value.reason.trim()) {
validation.value = '请填写撤销操作者和原因。'
return
}
} else if (additionalRequestId.value) {
const original = additionalRequest.value,
value = additionalDraft.value
if (
!original ||
original.status !== 'unknown' ||
original.input.scope !== 'keyframe' ||
original.input.provider !== 'openai-image' ||
original.output?.result ||
!Number.isInteger(value.count) ||
!value.count ||
value.count < 1 ||
value.count > 100 ||
!value.approvedBy.trim() ||
!value.note.trim() ||
!value.accepted
) {
validation.value = '请核对原未知首帧请求,填写1~100次、批准人和说明,并主动接受原费用未知风险。'
return
}
} else {
const value = draft.value
const budget = usdToMicros(value.budget),
@@ -121,6 +177,7 @@ async function save() {
return
}
}
pendingSubmitLabel.value = submitLabel.value
saving.value = true
try {
if (revokeId.value) {
@@ -132,6 +189,28 @@ async function save() {
revokeId.value = ''
revocation.value = { revokedBy: '', reason: '' }
showActionFeedback(message, '已撤销未来领取,原请求和历史费用保留。', 'success')
} else if (additionalRequestId.value) {
const value = additionalDraft.value
const result = await imageAuthorizationApi.create(project, {
mode: 'additional',
idempotencyKey: idempotencyKey.value,
parentRequestId: additionalRequestId.value,
maxRequests: value.count!,
acknowledgeUnknownPriorBilling: true,
approvedBy: value.approvedBy.trim(),
approvalNote: value.note.trim()
})
if (disposed || project !== props.projectId) return
idempotencyKey.value = crypto.randomUUID()
additionalRequestId.value = ''
additionalDraft.value = { count: null, approvedBy: '', note: '', accepted: false }
showActionFeedback(
message,
result.status === 'revoked'
? '原追加许可已撤销,不能重新领取。'
: '人工追加许可已登记,未发起任何生成;原未知费用保留。',
'info'
)
} else {
const value = draft.value
await imageAuthorizationApi.create(project, {
@@ -154,18 +233,7 @@ async function save() {
})
if (disposed || project !== props.projectId) return
idempotencyKey.value = crypto.randomUUID()
draft.value = {
models: [],
scopes: [],
targets: '',
budget: '',
reserve: '',
count: null,
expires: null,
approvedBy: '',
note: '',
accepted: false
}
draft.value = emptyAuthorizationDraft()
showActionFeedback(message, '有限持续授权已登记。', 'success')
}
revision.value++
@@ -176,8 +244,40 @@ async function save() {
await query.refresh()
} finally {
saving.value = false
pendingSubmitLabel.value = ''
}
}
/** 审计动作后只读刷新余额,不启动任何生成。 */
async function auditChanged() {
revision.value++
await query.refresh()
}
/** 当前表单编辑不会自动追加、核清或重新领取。 */
watch(
() => props.projectId,
() => {
draft.value = emptyAuthorizationDraft()
revocation.value = { revokedBy: '', reason: '' }
validation.value = ''
auditRequestId.value = ''
additionalRequestId.value = ''
revokeId.value = ''
idempotencyKey.value = crypto.randomUUID()
additionalDraft.value = { count: null, approvedBy: '', note: '', accepted: false }
},
{ flush: 'sync' }
)
/**
* 显式选择原unknown请求后展示独立追加表单。
* @param requestId 原应用费用请求
*/
function startAdditional(requestId: string) {
additionalRequestId.value = requestId
revokeId.value = ''
additionalDraft.value = { count: null, approvedBy: '', note: '', accepted: false }
idempotencyKey.value = crypto.randomUUID()
validation.value = ''
}
/** 公共固定底栏调用当前操作。 */
defineExpose({ save, canSave, submitLabel })
</script>
@@ -185,166 +285,300 @@ defineExpose({ save, canSave, submitLabel })
<template>
<!-- 以下是授权余额、原请求与有限批准模块 -->
<div class="workspace-section-stack">
<WorkspaceSectionHeading
title="OpenAI 图片授权"
description="授权仅覆盖明确选择的图片范围。其他图片供应方需单独确认;视频、独立视觉审核、修复及主资产确认继续单独操作。"
<ImageBillingAuditPanel
v-if="auditRequestId"
ref="auditPanel"
:project-id="projectId"
:request-id="auditRequestId"
:disabled="disabled"
@busy="saving = $event"
@back="auditRequestId = ''"
@changed="auditChanged"
/>
<NButton class="self-start" :loading="query.loading.value" :disabled="saving" @click="query.refresh"
>刷新授权与请求</NButton
>
<p v-if="query.loading.value && !query.data.value" role="status">正在读取授权…</p>
<p v-if="query.error.value" role="alert" class="text-sm text-muted">{{ query.error.value }}</p>
<p v-if="query.data.value?.billingBlocked" class="surface-inset p-4 text-sm" role="status">
原请求在途、缺少回执或用量,或用量价超过预留,已停止后续 OpenAI 收费。新增授权无法绕过,请核对下方原请求。
</p>
<p v-if="query.data.value && !query.data.value.authorizations.length" class="text-sm text-muted">
暂无图片授权。
</p>
<article
v-for="item in query.data.value?.authorizations ?? []"
:key="item.id"
class="surface-inset p-4 space-y-3 min-w-0"
>
<p class="font-semibold">
{{ item.status === 'revoked' ? '已撤销' : item.expired ? '已到期' : '已批准' }} ·
{{ item.input.models.join('、') }}
</p>
<p class="text-sm">
累计预算 {{ formatMicros(item.input.budgetMicros) }} · 已记账及未结预留
{{ formatMicros(item.accountedMicros) }} · 剩余 {{ formatMicros(item.remainingMicros) }}
</p>
<p class="text-sm">
已请求 {{ item.usedRequests }} / {{ item.input.maxRequests }} 次 · 剩余 {{ item.remainingRequests }} 次
· 单次预留 {{ formatMicros(item.input.perRequestMicros) }}
</p>
<p class="text-sm">
{{ item.input.scopes.map(scope => imageScopeLabels[scope]).join('、') }} · 有效期至
{{ new Date(item.input.expiresAt).toLocaleString('zh-CN', { hour12: false }) }}
</p>
<p v-if="item.billingBlocked" class="text-sm">此授权存在未核清费用。</p>
<RawDataDetails :value="item.input" title="批准范围与材料" />
<NButton v-if="item.status !== 'revoked'" :disabled="saving || disabled" @click="revokeId = item.id"
>撤销此授权</NButton
<template v-else>
<WorkspaceSectionHeading
title="OpenAI 图片授权"
description="授权仅覆盖明确选择的图片范围。其他图片供应方需单独确认;视频、独立视觉审核、修复及主资产确认继续单独操作。"
/>
<NButton class="self-start" :loading="query.loading.value" :disabled="saving" @click="query.refresh"
>刷新授权与请求</NButton
>
</article>
<!-- 以下是保留全部状态的原生成请求及费用模块 -->
<NCollapse v-if="query.data.value?.requests.length">
<NCollapseItem name="requests" title="原生成请求与费用状态">
<article
v-for="item in query.data.value.requests"
:key="item.id"
class="mb-4 surface-inset p-4 space-y-2 min-w-0"
<p v-if="query.loading.value && !query.data.value" role="status">正在读取授权…</p>
<p v-if="query.error.value" role="alert" class="text-sm text-muted">{{ query.error.value }}</p>
<p v-if="query.data.value?.billingBlocked" class="surface-inset p-4 text-sm" role="status">
原请求在途、缺少回执或用量,或用量价超过预留,已停止后续 OpenAI
收费。原未知请求和预留会保留。普通授权不能绕过;同一精确计划的人工有限追加须单独批准。请核对下方原请求。
</p>
<p v-if="query.data.value && !query.data.value.authorizations.length" class="text-sm text-muted">
暂无图片授权。
</p>
<article
v-for="item in query.data.value?.authorizations ?? []"
:key="item.id"
class="surface-inset p-4 space-y-3 min-w-0"
>
<p class="font-semibold">
{{ item.status === 'revoked' ? '已撤销' : item.expired ? '已到期' : '已批准' }} ·
{{ item.input.models.join('、') }}
</p>
<p class="text-sm">
累计预算 {{ formatMicros(item.input.budgetMicros) }} · 已记账及未结预留
{{ formatMicros(item.accountedMicros) }} · 剩余 {{ formatMicros(item.remainingMicros) }}
</p>
<p class="text-sm">
已请求 {{ item.usedRequests }} / {{ item.input.maxRequests }} 次 · 剩余
{{ item.remainingRequests }} 次 · 单次预留 {{ formatMicros(item.input.perRequestMicros) }}
</p>
<p class="text-sm">
{{ item.input.scopes.map(scope => imageScopeLabels[scope]).join('、') }} · 有效期至
{{ new Date(item.input.expiresAt).toLocaleString('zh-CN', { hour12: false }) }}
</p>
<p v-if="item.billingBlocked" class="text-sm">此授权存在未核清费用。</p>
<RawDataDetails :value="item.input" title="批准范围与材料" />
<NButton v-if="item.status !== 'revoked'" :disabled="saving || disabled" @click="revokeId = item.id"
>撤销此授权</NButton
>
<p class="text-sm font-semibold">
</article>
<!-- 以下是保留全部状态的原生成请求及费用模块 -->
<NCollapse v-if="query.data.value?.requests.length">
<NCollapseItem name="requests" title="原生成请求与费用状态">
<article
v-for="item in query.data.value.requests"
:key="item.id"
class="mb-4 surface-inset p-4 space-y-2 min-w-0"
>
<p class="text-sm font-semibold">
{{
item.status === 'completed'
? '图片回执完整,质量另行审核'
: item.status === 'running'
? '已领取发送资格,禁止重发'
: '结果或费用未知,禁止重试'
}}
</p>
<p class="wrap-anywhere text-xs">
{{ item.id }} · {{ imageScopeLabels[item.input.scope] }} · {{ item.input.targetId }}
</p>
<p class="text-sm">
原预留 {{ formatMicros(item.input.reservedMicros) }} · 公开用量价
{{ formatMicros(item.output?.usageCostMicros) }} ·
{{
item.output?.actualBilledMicros == null
? '账单未核实'
: `实际账单 ${formatMicros(item.output.actualBilledMicros)}`
}}
</p>
<p v-if="query.data.value.blockingRequestIds.includes(item.id)" class="text-sm">
{{ imageRequestBlockReason(item) }} 完整同计划回执仍可免费复用。
</p>
<p class="text-sm">原型号 {{ item.input.model }} · 原镜头 / 目标 {{ item.input.targetId }}</p>
<p v-if="item.billingAudit" class="text-sm">
费用审计:{{
item.billingAudit.released
? '已核清,原执行和预留保留'
: item.billingAudit.status === 'blocked'
? '保留阻断'
: '尚未独立复核'
}}
· 核实金额 {{ formatMicros(item.billingAudit.reviewedAmountMicros) }}
</p>
<div class="workspace-action-group">
<NButton
class="workspace-action-button"
:disabled="saving || disabled"
@click="auditRequestId = item.id"
>原请求费用审计</NButton
><NButton
v-if="
item.status === 'unknown' &&
item.input.scope === 'keyframe' &&
item.input.provider === 'openai-image' &&
!item.output?.result
"
class="workspace-action-button"
:disabled="saving || disabled"
@click="startAdditional(item.id)"
>人工有限追加</NButton
>
</div>
<RawDataDetails :value="item" title="原请求、来源及回执详情" />
</article>
</NCollapseItem>
</NCollapse>
<!-- 以下是原精确计划的人工追加次数和撤销,原unknown仍保留。 -->
<section v-if="query.data.value?.additionalAuthorizations?.length" class="workspace-section-stack">
<WorkspaceSectionHeading
title="人工有限追加许可"
description="只适用原精确计划,不增加预算;一次成功后停止,不自动消费剩余次数。"
/>
<article
v-for="permit in query.data.value.additionalAuthorizations"
:key="permit.id"
class="surface-inset p-4 space-y-3 text-sm"
>
<p>
{{
item.status === 'completed'
? '图片回执完整,质量另行审核'
: item.status === 'running'
? '已领取发送资格,禁止重发'
: '结果或费用未知,禁止重试'
permit.status === 'approved'
? '已批准'
: permit.status === 'revoked'
? '已撤销'
: '状态待核对'
}}
· 已用 {{ permit.usedRequests }} / {{ permit.input.maxRequests }} 次 · 剩余
{{ permit.remainingRequests }} 次
</p>
<p class="wrap-anywhere text-xs">
{{ item.id }} · {{ imageScopeLabels[item.input.scope] }} · {{ item.input.targetId }}
</p>
<p class="text-sm">
原预留 {{ formatMicros(item.input.reservedMicros) }} · 公开用量价
{{ formatMicros(item.output?.usageCostMicros) }} ·
{{
item.output?.actualBilledMicros == null
? '账单未核实'
: `实际账单 ${formatMicros(item.output.actualBilledMicros)}`
}}
</p>
<p v-if="query.data.value.blockingRequestIds.includes(item.id)" class="text-sm">
{{ imageRequestBlockReason(item) }} 完整同计划回执仍可免费复用。
</p>
<RawDataDetails :value="item" title="原请求、来源及回执详情" />
<p v-if="permit.status === 'revoked'">剩余次数不可领取。</p>
<p>原请求 {{ permit.input.parentRequestId }} · 批准人 {{ permit.input.approvedBy }}</p>
<RawDataDetails :value="permit" title="追加许可与原计划详情" /><NButton
v-if="permit.status === 'approved'"
:disabled="saving || disabled"
@click="revokeId = permit.id"
>撤销此追加许可</NButton
>
</article>
</NCollapseItem>
</NCollapse>
<!-- 以下是独立撤销表单,底栏明确提交 -->
<section v-if="revokeId" class="workspace-section-stack">
<WorkspaceSectionHeading
title="撤销未来领取"
description="已领取请求可能已经发送。撤销不会取消、退款或删除原请求。"
/>
<p class="wrap-anywhere text-xs">{{ revokeId }}</p>
<label class="workspace-form-field"
><span>撤销操作者</span
><NInput v-model:value="revocation.revokedBy" :maxlength="200" :disabled="saving"
/></label>
<label class="workspace-form-field"
><span>撤销原因</span
><NInput v-model:value="revocation.reason" type="textarea" :maxlength="2000" :disabled="saving"
/></label>
<NButton :disabled="saving" @click="revokeId = ''">返回创建授权</NButton>
</section>
<!-- 以下是用户明确填写的有限持续授权,不预填金额、次数及日期 -->
<section v-else class="workspace-section-stack">
<WorkspaceSectionHeading
title="创建有限持续授权"
description="单次预留金额不是供应方实际账单的硬上限。按实际 Token 浮动计费,实际费用可能超过预留。超预留、缺回执或用量时将停止后续收费。"
/>
<div class="grid grid-cols-1 gap-(--app-field-gap) sm:grid-cols-2">
<div class="workspace-form-field">
<span>授权型号</span
><NSelect
aria-label="授权型号"
v-model:value="draft.models"
multiple
:options="modelOptions"
</section>
<!-- 以下是独立撤销表单,底栏明确提交 -->
<section v-if="revokeId" class="workspace-section-stack">
<WorkspaceSectionHeading
title="撤销未来领取"
description="已领取请求可能已经发送。撤销不会取消、退款或删除原请求。"
/>
<p class="wrap-anywhere text-xs">{{ revokeId }}</p>
<label class="workspace-form-field"
><span>撤销操作者</span
><NInput v-model:value="revocation.revokedBy" :maxlength="200" :disabled="saving"
/></label>
<label class="workspace-form-field"
><span>撤销原因</span
><NInput v-model:value="revocation.reason" type="textarea" :maxlength="2000" :disabled="saving"
/></label>
<NButton :disabled="saving" @click="revokeId = ''">返回创建授权</NButton>
</section>
<section v-else-if="additionalRequestId && additionalRequest" class="workspace-section-stack">
<WorkspaceSectionHeading
title="原精确计划人工有限追加"
description="原请求的结果和费用仍未知。本许可只允许用户另行主动发起有限次数,不自动生成或核清旧费用。"
/>
<p class="text-sm">
原请求 {{ additionalRequest.id }} · 原型号 {{ additionalRequest.input.model }} · 原镜头
{{ additionalRequest.input.targetId }} · 原预留
{{ formatMicros(additionalRequest.input.reservedMicros) }} · 原实际账单
{{ formatMicros(additionalRequest.output?.actualBilledMicros) }}
</p>
<RawDataDetails
:value="{
原请求: additionalRequest.id,
原镜头: additionalRequest.input.targetId,
原计划: additionalRequest.input.planFingerprint,
原来源: additionalRequest.input.sourceFingerprint,
原批准: additionalRequest.input.authorizationId
}"
title="原精确范围详情(只读)"
/>
<label class="workspace-form-field"
><span>用户批准的追加次数(1~100)</span
><NInputNumber
v-model:value="additionalDraft.count"
:min="1"
:max="100"
:disabled="saving"
placeholder="选择明确批准的型号"
/>
</div>
<div class="workspace-form-field">
<span>授权范围</span
><NSelect
aria-label="授权范围"
v-model:value="draft.scopes"
multiple
:options="scopeOptions"
aria-label="人工追加次数"
/></label>
<label class="workspace-form-field"
><span>追加批准人</span
><NInput
v-model:value="additionalDraft.approvedBy"
:maxlength="200"
:disabled="saving"
placeholder="选择图片范围"
/>
aria-label="追加批准人"
/></label>
<label class="workspace-form-field"
><span>追加批准说明</span
><NInput
v-model:value="additionalDraft.note"
type="textarea"
:maxlength="2000"
:disabled="saving"
aria-label="追加批准说明"
/></label>
<NCheckbox v-model:checked="additionalDraft.accepted" :disabled="saving"
>我接受原请求及其费用仍未知,明确批准上述有限次数;新旧请求共用原预算,范围、型号、来源或计划变化时不能使用。</NCheckbox
>
<NButton class="self-start" :disabled="saving" @click="additionalRequestId = ''"
>取消追加许可登记</NButton
>
</section>
<!-- 以下是用户明确填写的有限持续授权,不预填金额、次数及日期 -->
<section v-else class="workspace-section-stack">
<WorkspaceSectionHeading
title="创建有限持续授权"
description="单次预留金额不是供应方实际账单的硬上限。按实际 Token 浮动计费,实际费用可能超过预留。超预留、缺回执或用量时将停止后续收费。"
/>
<div class="grid grid-cols-1 gap-(--app-field-gap) sm:grid-cols-2">
<div class="workspace-form-field">
<span>授权型号</span
><NSelect
aria-label="授权型号"
v-model:value="draft.models"
multiple
:options="modelOptions"
:disabled="saving"
placeholder="选择明确批准的型号"
/>
</div>
<div class="workspace-form-field">
<span>授权范围</span
><NSelect
aria-label="授权范围"
v-model:value="draft.scopes"
multiple
:options="scopeOptions"
:disabled="saving"
placeholder="选择图片范围"
/>
</div>
<label class="workspace-form-field"
><span>累计预算(USD)</span
><NInput v-model:value="draft.budget" :disabled="saving" placeholder="填写累计准入预算"
/></label>
<label class="workspace-form-field"
><span>单次预留(USD)</span
><NInput v-model:value="draft.reserve" :disabled="saving" placeholder="填写每次发送前的预留"
/></label>
<label class="workspace-form-field"
><span>累计请求次数</span
><NInputNumber
v-model:value="draft.count"
:min="1"
:max="10000"
:precision="0"
:disabled="saving"
/></label>
<label class="workspace-form-field"
><span>到期时间</span
><NDatePicker v-model:value="draft.expires" type="datetime" clearable :disabled="saving"
/></label>
</div>
<label class="workspace-form-field"
><span>累计预算(USD)</span
><NInput v-model:value="draft.budget" :disabled="saving" placeholder="填写累计准入预算"
><span>目标编号限制(可选)</span
><NInput
v-model:value="draft.targets"
type="textarea"
:disabled="saving"
placeholder="留空覆盖所选范围;填写正式主体、形态、镜头或布局编号,以逗号或换行分隔"
/></label>
<label class="workspace-form-field"
><span>单次预留(USD)</span
><NInput v-model:value="draft.reserve" :disabled="saving" placeholder="填写每次发送前的预留"
><span>批准人</span><NInput v-model:value="draft.approvedBy" :maxlength="200" :disabled="saving"
/></label>
<label class="workspace-form-field"
><span>累计请求次数</span
><NInputNumber v-model:value="draft.count" :min="1" :max="10000" :precision="0" :disabled="saving"
><span>批准说明</span
><NInput v-model:value="draft.note" type="textarea" :maxlength="2000" :disabled="saving"
/></label>
<label class="workspace-form-field"
><span>到期时间</span
><NDatePicker v-model:value="draft.expires" type="datetime" clearable :disabled="saving"
/></label>
</div>
<label class="workspace-form-field"
><span>目标编号限制(可选)</span
><NInput
v-model:value="draft.targets"
type="textarea"
:disabled="saving"
placeholder="留空覆盖所选范围;填写正式主体、形态、镜头或布局编号,以逗号或换行分隔"
/></label>
<label class="workspace-form-field"
><span>批准人</span><NInput v-model:value="draft.approvedBy" :maxlength="200" :disabled="saving"
/></label>
<label class="workspace-form-field"
><span>批准说明</span
><NInput v-model:value="draft.note" type="textarea" :maxlength="2000" :disabled="saving"
/></label>
<NCheckbox v-model:checked="draft.accepted" :disabled="saving"
>我接受按 Token 浮动计费,单次实际账单可能超过预留;有效范围内后续图片不再逐张确认收费。</NCheckbox
>
</section>
<p v-if="validation" role="alert" class="text-sm">{{ validation }}</p>
<NCheckbox v-model:checked="draft.accepted" :disabled="saving"
>我接受按 Token 浮动计费,单次实际账单可能超过预留;有效范围内后续图片不再逐张确认收费。</NCheckbox
>
</section>
<p v-if="validation" role="alert" class="text-sm">{{ validation }}</p>
</template>
</div>
</template>
@@ -0,0 +1,207 @@
<script setup lang="ts">
import { computed, watch } from 'vue'
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NSelect } from 'naive-ui'
import WorkspaceSectionHeading from '../../components/ui/WorkspaceSectionHeading.vue'
import RawDataDetails from '../../components/ui/RawDataDetails.vue'
import BillingEvidenceFields from '../billing-audit/BillingEvidenceFields.vue'
import { useImageBillingAudit } from './useImageBillingAudit'
import { formatMicros, imageScopeLabels } from './model'
import { userFacingText } from '../../lib/user-facing-text'
/** 原图片授权抽屉内的审计模式,底栏由同一抽屉提供。 */
const props = defineProps<{
/** 原项目。 */ projectId: string
/** 原应用费用请求。 */ requestId: string
/** 正式活动锁。 */ disabled: boolean
}>()
/** 审计后刷新原授权余额和请求;返回时不产生写入。 */
const emit = defineEmits<{ changed: []; back: []; busy: [value: boolean] }>()
/** 图片域复用同步查询和独立复核。 */
const form = useImageBillingAudit(props, () => emit('changed'))
/** 原请求与审计结论分别展示。 */
const view = computed(() => form.query.data.value)
/** 仅当前版本的真实材料可以参与复核。 */
const evidenceOptions = computed(() =>
form.currentEvidence.value.map((row, index) => ({
label: `材料 ${index + 1} · ${row.body.operator}`,
value: row.id
}))
)
watch(form.saving, value => emit('busy', value), { flush: 'sync' })
/** 原设置固定底栏调用当前审计操作。 */
defineExpose({ canSubmit: form.canSubmit, saving: form.saving, submit: form.submit, submitLabel: form.submitLabel })
</script>
<template>
<!-- 以下是原请求身份、原预留和独立审计结论。 -->
<div class="workspace-section-stack">
<WorkspaceSectionHeading
title="图片原请求费用审计"
description="登记原件后仍需独立复核。核清费用不代表生图成功、质量通过或可以设为主图。"
/>
<div class="flex flex-wrap gap-3">
<NButton :disabled="form.saving.value" @click="emit('back')">返回授权与原请求</NButton
><NButton :disabled="form.saving.value" :loading="form.query.loading.value" @click="form.refresh"
>刷新原请求与审计</NButton
>
</div>
<p v-if="form.query.loading.value" role="status">正在读取原图片请求费用…</p>
<p v-if="form.query.error.value" role="alert">{{ form.query.error.value }}</p>
<template v-if="view">
<section class="surface-inset p-4 workspace-section-stack text-sm min-w-0">
<h4 class="font-medium">{{ view.billingBlocked ? '本原请求费用仍阻断' : '本原请求当前无费用阻断' }}</h4>
<p>
原执行:{{
view.originalRequestStatus === 'unknown'
? '结果或费用未知'
: view.originalRequestStatus === 'completed'
? '原图片回执完整,质量另行审核'
: '原执行尚待核对'
}}
· 费用审计:{{
view.status === 'released' ? '已核清' : view.status === 'blocked' ? '保留阻断' : '等待人工复核'
}}
</p>
<p>
{{ imageScopeLabels[view.identity.scope] }} · {{ view.identity.provider }} /
{{ view.identity.model }}
</p>
<p>
原预留 {{ formatMicros(view.reservedMicros) }} · 原公开用量价
{{ formatMicros(view.originalUsageCostMicros) }} · 原实际账单
{{ formatMicros(view.originalActualBilledMicros) }}
</p>
<p>
审计核实金额
{{ formatMicros(view.reviewedAmountMicros) }}。此值不覆盖原账单,原预留和已用次数不退回。
</p>
<p>
原供应方请求号:{{ view.originalProviderRequestId ?? '未取得真实供应方编号' }} ·
{{ view.hasOriginalReceipt ? '存在原成功回执' : '尚无原成功回执' }}
</p>
<p>
原始费用阻断:{{ view.originalBillingBlocked ? '有' : '无' }} · 当前有效费用阻断:{{
view.billingBlocked ? '有' : '无'
}}
</p>
<RawDataDetails
:value="{
identity: view.identity,
taskFingerprint: view.taskFingerprint,
evidenceSetFingerprint: view.evidenceSetFingerprint,
reviewFingerprint: view.reviewFingerprint
}"
title="原请求、镜头、计划及版本详情"
/>
</section>
<div class="workspace-form-field">
<span>本次独立操作</span
><NSelect
v-model:value="form.action.value"
:disabled="form.saving.value"
aria-label="图片费用本次操作"
:options="[
{ label: '登记外部证据', value: 'evidence' },
{ label: '独立人工复核', value: 'review' }
]"
/>
</div>
<!-- 以下是共享媒体证据编辑,图片身份由原GET原样绑定。 -->
<BillingEvidenceFields
v-if="form.action.value === 'evidence'"
v-model="form.facts.value"
v-model:operator="form.operator.value"
:disabled="form.saving.value"
/>
<section v-else class="workspace-section-stack">
<div class="workspace-form-field">
<span>已登记的当前版本材料</span
><NSelect
v-model:value="form.evidenceId.value"
:options="evidenceOptions"
:disabled="form.saving.value"
placeholder="主动选择已核对的证据包"
aria-label="图片费用复核材料"
/>
</div>
<RawDataDetails
v-if="form.selectedEvidence.value"
:value="form.selectedEvidence.value"
title="待复核原件完整内容"
/>
<div class="workspace-form-field">
<span>复核决定</span
><NSelect
v-model:value="form.decision.value"
:disabled="form.saving.value"
aria-label="图片费用复核决定"
:options="[
{ label: '保留费用阻断', value: 'keep_blocked' },
{ label: '核清费用,仅影响未来收费门禁', value: 'release_future_charges' }
]"
/>
</div>
<ul
v-if="form.decision.value === 'release_future_charges' && form.releaseIssues.value.length"
class="space-y-2 text-sm"
>
<li v-for="issue in form.releaseIssues.value" :key="issue">{{ issue }}</li>
</ul>
<label class="workspace-form-field"
><span>独立复核人</span
><NInput
v-model:value="form.reviewer.value"
:maxlength="120"
:disabled="form.saving.value"
aria-label="图片费用复核人"
/></label>
<label class="workspace-form-field"
><span>复核理由</span
><NInput
v-model:value="form.reason.value"
type="textarea"
:maxlength="2000"
:disabled="form.saving.value"
aria-label="图片费用复核理由"
/></label>
<label class="workspace-form-field"
><span>已核对材料的 SHA256</span
><NInput
v-model:value="form.confirmationSha256.value"
:maxlength="64"
:disabled="form.saving.value"
aria-label="图片费用确认材料 SHA256"
/></label>
<p class="text-sm text-muted">
请实际核验原件的账户、项目与Key标识、UTC范围、型号和唯一请求归属;不要填写秘密Key。费用核清不会重发原未知计划。
</p>
</section>
<NCheckbox v-model:checked="form.confirmed.value" :disabled="form.saving.value"
>我已核对当前原请求、完整材料及本次操作;登记不解锁,复核不批准生成、质量或主图。</NCheckbox
>
<p v-if="form.validation.value" role="alert" class="text-sm">{{ form.validation.value }}</p>
<!-- 以下是原始证据和单调复核历史,未完成材料不显示为新增阻断。 -->
<NCollapse
><NCollapseItem name="history" title="证据与独立复核历史"
><p v-if="!view.history.evidence.length && !view.history.reviews.length" class="text-sm">
暂无审计历史。正常已结算请求的未复核状态不新增费用阻断。
</p>
<RawDataDetails
v-for="record in view.history.evidence"
:key="record.id"
:value="record"
:title="`原件登记 · ${record.body.operator}`" /><RawDataDetails
v-for="record in [...view.history.reviews].sort(
(a, b) => (a.revision ?? 0) - (b.revision ?? 0)
)"
:key="record.id"
:value="record"
:title="`第 ${record.revision ?? '待确认'} 次复核 · ${record.body.reviewer}`"
/></NCollapseItem>
<NCollapseItem v-if="view.releaseIssues.length" name="issues" title="正式费用核查详情"
><p v-for="issue in view.releaseIssues" :key="issue" class="text-sm">
{{ userFacingText(issue) }}
</p></NCollapseItem
></NCollapse
>
</template>
</div>
</template>
+2 -1
View File
@@ -1,5 +1,6 @@
import { request } from '../../lib/http'
import type {
ImageAdditionalAuthorizationInput,
ImageAuthorizationInput,
ImageAuthorizationList,
ImageAuthorizationPreview,
@@ -39,7 +40,7 @@ export const imageAuthorizationApi = {
* @param input 本次不可变批准
* @returns 原授权标识及状态
*/
create: (projectId: string, input: ImageAuthorizationInput) =>
create: (projectId: string, input: ImageAuthorizationInput | ImageAdditionalAuthorizationInput) =>
request<{ authorizationId: string; status: string }>(root(projectId), { method: 'POST', body: input }),
/**
* 撤销未来领取并保留原件。
@@ -0,0 +1,47 @@
import { request } from '../../lib/http'
import type { ImageBillingAuditView, ImageBillingEvidenceInput, ImageBillingReviewInput } from './billing-audit.types'
/**
* 精确绑定原项目和原应用请求,不复用视频任务路径。
* @param projectId 原项目
* @param requestId 原应用费用请求
* @returns 正式图片费用审计路径
*/
function path(projectId: string, requestId: string) {
return `/projects/${encodeURIComponent(projectId)}/image-requests/${encodeURIComponent(requestId)}/audit`
}
/** 同步、免费图片费用审计;任何动作都不启动生产。 */
export const imageBillingAuditApi = {
/**
* 读取原身份和并发版本。
* @param projectId 原项目
* @param requestId 原应用费用请求
* @param signal 取消旧范围读取
* @returns 原请求审计视图
*/
get: (projectId: string, requestId: string, signal?: AbortSignal) =>
request<ImageBillingAuditView>(path(projectId, requestId), { signal }),
/**
* 幂等登记外部原件,不解除阻断。
* @param projectId 原项目
* @param requestId 原应用费用请求
* @param body 正式身份及登记人
* @returns 新审计视图和登记回执
*/
evidence: (projectId: string, requestId: string, body: ImageBillingEvidenceInput) =>
request<ImageBillingAuditView & { evidenceId: string; reused: boolean }>(
path(projectId, requestId) + '/evidence',
{ method: 'POST', body }
),
/**
* 独立复核当前完整证据版本,不改变原执行、质量或主图。
* @param projectId 原项目
* @param requestId 原应用费用请求
* @param body 用户明确核对的复核材料
* @returns 当前正式审计和幂等回执
*/
review: (projectId: string, requestId: string, body: ImageBillingReviewInput) =>
request<ImageBillingAuditView & { reused: boolean }>(path(projectId, requestId) + '/reviews', {
method: 'POST',
body
})
}
@@ -0,0 +1,86 @@
import { billingEvidenceIssues } from '../billing-audit/evidence'
import type { BillingFacts } from '../billing-audit/types'
import type { ImageBillingAuditView, ImageBillingEvidenceInput } from './billing-audit.types'
/**
* 核对USD金额是否可精确表示为整数微美元,零金额必须显式填写。
* @param amount 原金额或未知
* @returns 精确整数微美元或null
*/
export function imageBillingAmountMicros(amount: number | null): number | null {
if (amount === null || !Number.isFinite(amount) || amount < 0 || !/^\d+(\.\d{1,6})?$/.test(String(amount)))
return null
const [whole = '0', fraction = ''] = String(amount).split('.')
const micros = Number(whole) * 1_000_000 + Number(fraction.padEnd(6, '0'))
return Number.isSafeInteger(micros) ? micros : null
}
/**
* 校验图片证据格式和本地身份,不把未知材料当成核实结论。
* @param facts 用户填写的事实
* @param view 原正式审计身份
* @returns 可操作校验原因
*/
export function imageBillingEvidenceIssues(facts: BillingFacts, view: ImageBillingAuditView): string[] {
const identity = view.identity
const issues = billingEvidenceIssues(facts, [
identity.requestId,
identity.candidateId,
identity.authorizationId,
identity.targetId,
identity.projectId
])
if (
facts.billing.currency !== 'USD' ||
(facts.billing.amount !== null && imageBillingAmountMicros(facts.billing.amount) === null)
)
issues.push('图片账单金额需为可精确表示的USD非负数,最多6位小数;未知请留空。')
return issues
}
/**
* 核清前检查材料是否具备正式条件,最终真实性、唯一认领仍由人工和服务端核验。
* @param evidence 用户明确选中的已登记证据
* @param view 原图片费用审计
* @returns 不能核清的原因
*/
export function imageBillingReleaseIssues(
evidence: ImageBillingEvidenceInput['evidence'] | undefined,
view: ImageBillingAuditView
): string[] {
if (!evidence) return ['请先选择已登记的证据包。']
const issues = imageBillingEvidenceIssues(evidence, view)
if (
Object.entries(view.identity).some(
([key, value]) => evidence.identity[key as keyof typeof evidence.identity] !== value
)
)
issues.push('证据身份与原请求不一致。')
if (!['unknown', 'completed'].includes(view.originalRequestStatus)) issues.push('原请求尚未形成可复核的结束状态。')
if (
evidence.correlation !== 'unique' ||
evidence.execution.outcome === 'unknown' ||
evidence.billing.finding === 'unknown' ||
evidence.billing.amount === null
)
issues.push('唯一关联、执行终态或实际费用仍未确认。')
const execution = evidence.artifacts.filter(item => evidence.execution.evidenceIds.includes(item.id)),
billing = evidence.artifacts.filter(item => evidence.billing.evidenceIds.includes(item.id))
if (
!execution.some(item => ['provider-execution', 'provider-support'].includes(item.kind)) ||
!billing.some(item => ['provider-billing', 'provider-support'].includes(item.kind))
)
issues.push('执行与费用分别需要供应方原件,观测记录不能替代。')
if (evidence.billing.finding === 'no-charge' && evidence.billing.amount !== 0)
issues.push('未收费必须有明确零金额依据。')
if (evidence.execution.outcome === 'not-received') {
if (
evidence.billing.finding !== 'no-charge' ||
evidence.billing.amount !== 0 ||
!execution.some(item => item.kind === 'provider-support')
)
issues.push('未接收需要官方支持原件及未收费说明。')
} else if (!evidence.providerRequestId) issues.push('缺少真实供应方请求号。')
if (view.hasOriginalReceipt && evidence.execution.outcome !== 'succeeded') issues.push('外部声明与原成功回执冲突。')
if (view.originalProviderRequestId && view.originalProviderRequestId !== evidence.providerRequestId)
issues.push('供应方编号与原回执不一致。')
return issues
}
@@ -0,0 +1,70 @@
import type { BillingFacts } from '../billing-audit/types'
import type { ImageAuthorizationScope } from './types'
/** 原图片费用请求身份,完整复制GET,不由当前新资产推导。 */
export interface ImageBillingIdentity {
/** 原项目。 */ projectId: string
/** 原应用费用请求。 */ requestId: string
/** 原批准。 */ authorizationId: string
/** 原业务范围。 */ scope: ImageAuthorizationScope
/** 原主体、形态、镜头或布局。 */ targetId: string
/** 原候选。 */ candidateId: string
/** 原来源版本。 */ sourceFingerprint: string
/** 原精确费用计划。 */ planFingerprint: string
/** 原完整请求版本。 */ requestFingerprint: string
/** 固定供应方。 */ provider: 'openai-image'
/** 原型号。 */ model: string
}
/** 只登记外部事实,不修改原unknown和账单字段。 */
export interface ImageBillingEvidenceInput {
/** 原请求及原授权完整版本。 */ expectedTaskFingerprint: string
/** 实际登记人。 */ operator: string
/** 身份及待人工核验的材料。 */ evidence: BillingFacts & { /** 原完整身份。 */ identity: ImageBillingIdentity }
}
/** 图片费用的独立人工复核,不改写像素、质量或主图。 */
export interface ImageBillingReviewInput {
/** 用户选中的正式证据包。 */ evidenceId: string
/** 原请求版本。 */ expectedTaskFingerprint: string
/** 完整证据集合。 */ expectedEvidenceSetFingerprint: string
/** 上一次复核版本。 */ expectedReviewFingerprint: string
/** 用户明确选择的决定。 */ decision: 'keep_blocked' | 'release_future_charges'
/** 实际复核人。 */ reviewer: string
/** 复核原因。 */ reason: string
/** 用户核对材料的真实摘要。 */ confirmationSha256: string
}
/** 不可变审计事件,复核先后以revision为准。 */
export interface ImageBillingEvent<T> {
/** 正式事件身份。 */ id: string
/** 原请求身份。 */ requestId: string
/** 原请求版本。 */ taskFingerprint: string
/** 原事件正文。 */ body: T
/** 稳定事件摘要。 */ digest: string
/** 服务端可能提供的记录时间。 */ createdAt?: string
/** 复核单调序号。 */ revision?: number
}
/** 图片原请求的权威审计视图。 */
export interface ImageBillingAuditView {
/** 原项目。 */ projectId: string
/** 原应用费用请求。 */ requestId: string
/** 完整原身份。 */ identity: ImageBillingIdentity
/** 原请求和授权完整版本。 */ taskFingerprint: string
/** 当前证据集合版本。 */ evidenceSetFingerprint: string
/** 当前复核版本。 */ reviewFingerprint: string
/** 原请求执行状态。 */ originalRequestStatus: string
/** 原预留,核清不退回。 */ reservedMicros: number
/** 原用量价,未知为null。 */ originalUsageCostMicros: number | null
/** 原实际账单,未知为null。 */ originalActualBilledMicros: number | null
/** 真实供应方编号,缺失不能补造。 */ originalProviderRequestId: string | null
/** 原成功回执是否存在。 */ hasOriginalReceipt: boolean
/** 原请求的原始阻断。 */ originalBillingBlocked: boolean
/** 有效复核之后的当前阻断。 */ billingBlocked: boolean
/** 当前有效解除。 */ released: boolean
/** 当前审计结论,不是执行结论。 */ status: 'unreviewed' | 'blocked' | 'released'
/** 有效解除的复核。 */ reviewId: string | null
/** 审计核实金额,不覆盖原账单。 */ reviewedAmountMicros: number | null
/** 当前不能解除的正式原因。 */ releaseIssues: string[]
/** 完整不可变历史。 */ history: {
/** 全部登记原件。 */ evidence: ImageBillingEvent<ImageBillingEvidenceInput>[]
/** 全部独立复核。 */ reviews: ImageBillingEvent<ImageBillingReviewInput>[]
}
}
+109 -1
View File
@@ -40,6 +40,7 @@ export function formatMicros(value: number | null | undefined): string {
* @param targetId 实际目标
* @param model 实际预览型号
* @param planFingerprint 免费计划返回的指纹,仅普通计划可提供
* @param additional 用户主动选择且需要核对精确来源的有限许可
* @returns 可复用、已授权或阻断说明
*/
export function imageChargeEligibility(
@@ -47,7 +48,12 @@ export function imageChargeEligibility(
scope: ImageAuthorizationScope,
targetId: string,
model: string,
planFingerprint?: string
planFingerprint?: string,
additional?: {
/** 用户明确选中的许可。 */ id: string
/** 当前正式来源。 */ sourceFingerprint: string
/** 当前原项目。 */ projectId: string
}
) {
const reusable = list.requests.find(
row =>
@@ -65,6 +71,35 @@ export function imageChargeEligibility(
reusable: true,
message: '同计划完整回执可免费复用,不新增请求次数;图片质量仍按原审核结果。'
}
if (additional)
return scope === 'keyframe' && planFingerprint
? additionalImageEligibility(
list,
additional.id,
additional.projectId,
targetId,
model,
additional.sourceFingerprint,
planFingerprint
)
: { allowed: false, reusable: false, message: '追加许可只适用于已重新核对的原精确首帧计划。' }
if (
planFingerprint &&
list.requests.some(
row =>
row.status === 'unknown' &&
row.input.scope === scope &&
row.input.targetId === targetId &&
row.input.model === model &&
row.input.planFingerprint === planFingerprint &&
!row.output?.result
)
)
return {
allowed: false,
reusable: false,
message: '原精确计划仍有结果或费用未知的请求。即使费用已核清,也不能普通重发;需主动核对人工有限追加许可。'
}
if (list.billingBlocked)
return {
allowed: false,
@@ -116,3 +151,76 @@ export function imageRequestBlockReason(request: ImageChargeRequest): string {
if (usageCost > request.input.reservedMicros) return '公开用量价超过单次预留,后续收费暂停。'
return ''
}
/**
* 仅提示原精确首帧计划的追加准入,最终费用领取仍由服务端事务核对。
* @param list 原项目正式费用投影
* @param permitId 用户主动选中的许可
* @param projectId 当前原项目
* @param targetId 当前镜头
* @param model 当前预览型号
* @param sourceFingerprint 当前正式来源
* @param planFingerprint 当前精确费用计划
* @returns 当前是否满足追加条件及原因
*/
export function additionalImageEligibility(
list: ImageAuthorizationList,
permitId: string,
projectId: string,
targetId: string,
model: string,
sourceFingerprint: string,
planFingerprint: string
) {
const permit = list.additionalAuthorizations?.find(row => row.id === permitId)
const parent = list.requests.find(row => row.id === permit?.input.parentRequestId)
const grant = list.authorizations.find(row => row.id === parent?.input.authorizationId)
if (
!permit ||
permit.status !== 'approved' ||
!Number.isSafeInteger(permit.remainingRequests) ||
permit.remainingRequests < 1 ||
!Number.isSafeInteger(permit.usedRequests) ||
permit.usedRequests < 0 ||
!parent ||
parent.status !== 'unknown' ||
parent.output?.result ||
parent.input.projectId !== projectId ||
parent.input.scope !== 'keyframe' ||
parent.input.provider !== 'openai-image' ||
parent.input.targetId !== targetId ||
parent.input.model !== model ||
parent.input.sourceFingerprint !== sourceFingerprint ||
parent.input.planFingerprint !== planFingerprint ||
!grant ||
grant.status !== 'approved' ||
grant.expired ||
!(Date.parse(grant.input.expiresAt) > Date.now()) ||
!Number.isSafeInteger(grant.remainingRequests) ||
grant.remainingRequests < 1 ||
!Number.isSafeInteger(grant.remainingMicros) ||
!Number.isSafeInteger(grant.input.perRequestMicros) ||
grant.input.perRequestMicros < 1 ||
grant.remainingMicros < grant.input.perRequestMicros
)
return {
allowed: false,
reusable: false,
message: '所选追加许可已撤销、用尽,或原镜头、型号、来源、计划及预算不匹配。请重新核对原请求。'
}
const blockers = list.requests.filter(row => list.blockingRequestIds.includes(row.id))
if (
blockers.some(
row =>
row.status !== 'unknown' ||
row.input.planFingerprint !== planFingerprint ||
(row.id !== parent.id && row.input.additionalAuthorizationId !== permit.id)
)
)
return { allowed: false, reusable: false, message: '仍有在途或未被本次许可覆盖的原请求,不能追加。' }
return {
allowed: true,
reusable: false,
message: `人工追加许可:已用 ${permit.usedRequests} 次,剩余 ${permit.remainingRequests} 次。原未知请求和预留保持;仅本次主动生成,不会自动用完剩余次数。`
}
}
+28
View File
@@ -24,8 +24,15 @@ export interface ImageAuthorizationInput {
export interface ImageChargeRequest {
/** 原请求标识。 */ id: string
/** 原执行状态。 */ status: string
/** 当前有效审计,不覆盖原状态、用量或账单。 */ billingAudit?: {
/** 审计状态。 */ status: 'unreviewed' | 'blocked' | 'released'
/** 有效解除。 */ released: boolean
/** 独立复核。 */ reviewId: string | null
/** 核实金额。 */ reviewedAmountMicros: number | null
}
/** 不可变原输入。 */ input: {
/** 原项目。 */ projectId: string
/** 用户主动选用的人工追加许可。 */ additionalAuthorizationId?: string
/** 原范围。 */ scope: ImageAuthorizationScope
/** 原目标。 */ targetId: string
/** 原候选。 */ candidateId: string
@@ -47,6 +54,16 @@ export interface ImageChargeRequest {
/** 项目授权余额与原请求。 */
export interface ImageAuthorizationList {
/** 原始在途或未知记录仍完整保留。 */ originalBlockingRequestIds?: string[]
/** 人工有限追加许可,不增加原预算。 */ additionalAuthorizations?: Array<{
/** 正式追加许可。 */ id: string
/** approved或revoked等真实状态。 */ status: string
/** 原不可变批准及服务端父输入摘要。 */ input: ImageAdditionalAuthorizationInput & {
/** 原完整输入摘要。 */ parentInputFingerprint: string
}
/** 已领取的模型请求次数。 */ usedRequests: number
/** 尚可人工领取次数。 */ remainingRequests: number
}>
/** 服务端计算的授权投影。 */ authorizations: Array<{
/** 原批准记录。 */ id: string
/** 原批准状态。 */ status: string
@@ -90,3 +107,14 @@ export interface ImageAuthorizationPreview {
/** 不承诺实际账单硬上限。 */ hardProviderCostCap: false
/** 当前授权与费用状态。 */ authorization: ImageAuthorizationList
}
/** 接受原费用未知风险后的有限人工追加,只允许服务端继承原精确计划。 */
export interface ImageAdditionalAuthorizationInput {
/** 明确追加模式。 */ mode: 'additional'
/** 本次批准唯一键,同内容重放保持。 */ idempotencyKey: string
/** 原应用费用请求,不能使用候选或Provider编号。 */ parentRequestId: string
/** 明确批准1~100次,不自动用完。 */ maxRequests: number
/** 用户主动接受原费用仍未知。 */ acknowledgeUnknownPriorBilling: true
/** 实际批准人。 */ approvedBy: string
/** 批准说明。 */ approvalNote: string
}
@@ -0,0 +1,250 @@
import { computed, onScopeDispose, ref, watch } from 'vue'
import { useQuery } from '../../composables/useQuery'
import { ApiError, errorMessage } from '../../lib/http'
import { useActionMessage } from '../../components/ui/useActionMessage'
import type { BillingFacts } from '../billing-audit/types'
import { imageBillingAuditApi } from './billing-audit-api'
import { imageBillingEvidenceIssues, imageBillingReleaseIssues } from './billing-audit'
/**
* 在原图片授权入口处理原请求的登记和独立复核,不执行生成或质量动作。
* @param props 原项目与应用费用请求
* @param changed 写入后刷新原授权余额和请求
* @returns 当前权威审计、独立表单和固定底栏操作
*/
export function useImageBillingAudit(
props: { projectId: string; requestId: string; disabled?: boolean },
changed: () => Promise<void> | void
) {
/** 当前原范围与提交回执隔离。 */
const key = computed(() => JSON.stringify([props.projectId, props.requestId]))
/** 组件离开后不应用旧提交结果。 */
let disposed = false
onScopeDispose(() => {
disposed = true
})
/** 原身份、版本和完整历史只来自正式GET。 */
const query = useQuery(key, async (value, signal) => {
const [projectId, requestId] = JSON.parse(value) as [string, string]
const result = await imageBillingAuditApi.get(projectId, requestId, signal)
if (
!result ||
result.projectId !== projectId ||
result.requestId !== requestId ||
result.identity?.projectId !== projectId ||
result.identity.requestId !== requestId ||
result.identity.provider !== 'openai-image' ||
![result.taskFingerprint, result.evidenceSetFingerprint, result.reviewFingerprint].every(hash =>
/^[a-f0-9]{64}$/.test(hash)
) ||
!Array.isArray(result.history?.evidence) ||
!Array.isArray(result.history?.reviews)
)
throw new Error('原图片请求身份或审计版本无法核对,请重新读取。')
return result
})
/** 登记和复核始终是两个独立用户动作。 */
const action = ref<'evidence' | 'review'>('evidence')
/** 实际登记署名。 */
const operator = ref('')
/** 外部事实默认未知,不预填真实Provider号或账单。 */
const facts = ref<BillingFacts>({
correlation: 'unverified',
providerRequestId: null,
artifacts: [],
execution: { outcome: 'unknown', evidenceIds: [] },
billing: { finding: 'unknown', amount: null, currency: 'USD', evidenceIds: [] }
})
/** 用户主动选择当前正式证据。 */
const evidenceId = ref('')
/** 独立复核实际署名。 */
const reviewer = ref('')
/** 独立复核理由。 */
const reason = ref('')
/** 人工核对材料的真实摘要,不从本地身份伪造。 */
const confirmationSha256 = ref('')
/** 默认保留原阻断,解除需用户主动切换。 */
const decision = ref<'keep_blocked' | 'release_future_charges'>('keep_blocked')
/** 用户确认的是本次当前版本,刷新和编辑均撤销。 */
const confirmed = ref(false)
/** 同步写入过程防重复操作。 */
const saving = ref(false)
/** 完整校验只在提交时显示。 */
const validation = ref('')
/** 当前原请求的有效版本证据,旧历史仍保留展示。 */
const currentEvidence = computed(
() =>
query.data.value?.history.evidence.filter(
row =>
row.taskFingerprint === query.data.value?.taskFingerprint &&
row.body.expectedTaskFingerprint === query.data.value?.taskFingerprint
) ?? []
)
/** 复核只能使用用户选中的当前正式材料。 */
const selectedEvidence = computed(() => currentEvidence.value.find(row => row.id === evidenceId.value))
/** 核清不依据零token、unknown、观测记录或本地编号推断。 */
const releaseIssues = computed(() =>
query.data.value
? imageBillingReleaseIssues(selectedEvidence.value?.body.evidence, query.data.value)
: ['请先读取原请求审计。']
)
/** 固定底栏区分登记、保留和核清。 */
const submitLabel = computed(() =>
action.value === 'evidence'
? '登记图片费用证据'
: decision.value === 'keep_blocked'
? '确认保留费用阻断'
: '确认核清原请求费用'
)
/** 真实版本已读且用户明确确认后才允许提交。 */
const canSubmit = computed(
() =>
!!query.data.value &&
!query.loading.value &&
!query.error.value &&
!saving.value &&
!props.disabled &&
confirmed.value &&
(action.value !== 'review' ||
(!!selectedEvidence.value &&
(decision.value !== 'release_future_charges' || !releaseIssues.value.length)))
)
/** 使用原NMessage反馈。 */
const message = useActionMessage()
watch(
[action, facts, operator, evidenceId, reviewer, reason, confirmationSha256, decision],
() => {
confirmed.value = false
validation.value = ''
},
{ deep: true, flush: 'sync' }
)
watch(
query.data,
() => {
confirmed.value = false
},
{ flush: 'sync' }
)
/** 项目或原请求切换不继承证据、签署或人工确认。 */
watch(
key,
() => {
action.value = 'evidence'
operator.value = ''
facts.value = {
correlation: 'unverified',
providerRequestId: null,
artifacts: [],
execution: { outcome: 'unknown', evidenceIds: [] },
billing: { finding: 'unknown', amount: null, currency: 'USD', evidenceIds: [] }
}
evidenceId.value = ''
reviewer.value = ''
reason.value = ''
confirmationSha256.value = ''
decision.value = 'keep_blocked'
confirmed.value = false
validation.value = ''
},
{ flush: 'sync' }
)
/** 免费读取当前GET,保留本次用户表单并要求重新确认。 */
async function refresh() {
confirmed.value = false
await query.refresh()
}
/** 登记与复核分开提交,409刷新正式GET,保留输入并等待重新确认。 */
async function submit() {
const view = query.data.value
if (!view || !canSubmit.value) return
const errors =
action.value === 'evidence'
? [
...imageBillingEvidenceIssues(facts.value, view),
...(!operator.value.trim() || operator.value.trim().length > 120
? ['请填写1~120字的实际登记人。']
: [])
]
: [
...(!selectedEvidence.value ? ['请重新选择当前版本的正式证据。'] : []),
...(decision.value === 'release_future_charges' ? releaseIssues.value : []),
...(!reviewer.value.trim() ||
reviewer.value.trim().length > 120 ||
reason.value.trim().length < 4 ||
reason.value.trim().length > 2000 ||
!/^[a-f0-9]{64}$/.test(confirmationSha256.value)
? ['请填写实际复核人、4~2000字理由及真实材料SHA256。']
: [])
]
if (errors.length) {
validation.value = [...new Set(errors)].join(' ')
return
}
const target = key.value
const operation = action.value
saving.value = true
confirmed.value = false
try {
const result =
operation === 'evidence'
? await imageBillingAuditApi.evidence(view.projectId, view.requestId, {
expectedTaskFingerprint: view.taskFingerprint,
operator: operator.value.trim(),
evidence: {
...JSON.parse(JSON.stringify(facts.value)),
identity: JSON.parse(JSON.stringify(view.identity))
}
})
: await imageBillingAuditApi.review(view.projectId, view.requestId, {
evidenceId: evidenceId.value,
expectedTaskFingerprint: view.taskFingerprint,
expectedEvidenceSetFingerprint: view.evidenceSetFingerprint,
expectedReviewFingerprint: view.reviewFingerprint,
decision: decision.value,
reviewer: reviewer.value.trim(),
reason: reason.value.trim(),
confirmationSha256: confirmationSha256.value
})
if (disposed || target !== key.value) return
if (result?.projectId !== view.projectId || result.requestId !== view.requestId)
throw new Error('费用回执与原请求不一致,请重新读取。')
message?.info(
operation === 'evidence'
? '证据已登记,仍需独立人工复核。'
: result.billingBlocked
? '复核已记录,原请求费用仍阻断。'
: '原请求费用已核清;原执行状态、图片质量与主图资格保持独立。'
)
await refresh()
if (!disposed && target === key.value) await changed()
} catch (cause) {
if (disposed || target !== key.value) return
message?.error(errorMessage(cause))
if (cause instanceof ApiError && cause.status === 409) await refresh()
} finally {
saving.value = false
}
}
return {
query,
action,
operator,
facts,
evidenceId,
reviewer,
reason,
confirmationSha256,
decision,
confirmed,
saving,
validation,
currentEvidence,
selectedEvidence,
releaseIssues,
submitLabel,
canSubmit,
refresh,
submit
}
}
+12 -3
View File
@@ -171,7 +171,9 @@ export const productionApi = {
/** 按本次请求选择的图片模型与参数预览最终输入,不创建首帧任务。 */
previewKeyframe: (
shotId: string,
input: Pick<GenerateKeyframeInput, 'provider' | 'generationOptions' | 'width' | 'height'>,
input: Pick<GenerateKeyframeInput, 'provider' | 'width' | 'height'> & {
/** 已保存草案中的原模型参数。 */ generationOptions?: Record<string, unknown>
},
signal?: AbortSignal
) =>
request<KeyframeGenerationPreview>(`${shotPath(shotId)}/keyframe/preview`, {
@@ -179,8 +181,15 @@ export const productionApi = {
signal,
body: input
}),
generateKeyframe: (shotId: string, input: GenerateKeyframeInput) =>
request<ShotKeyframe | null>(`${shotPath(shotId)}/keyframe`, {
/**
* 提交用户确认的单镜首帧,追加许可显式绑定原项目。
* @param shotId 正式镜头
* @param input 已核对的模型参数及可选人工许可
* @param projectId 原项目范围
* @returns 原候选回执
*/
generateKeyframe: (shotId: string, input: GenerateKeyframeInput, projectId?: string) =>
request<ShotKeyframe | null>(keyframeScope(`${shotPath(shotId)}/keyframe`, projectId), {
method: 'POST',
body: input,
timeoutMs: 0
@@ -1,4 +1,8 @@
<script setup lang="ts">
import { useQuery } from '../../../composables/useQuery'
import { imageAuthorizationApi } from '../../image-authorization/api'
import { formatMicros } from '../../image-authorization/model'
import { NSelect } from 'naive-ui'
import KeyframePreviewChecks from './KeyframePreviewChecks.vue'
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
import { useImageGenerationPreview, type ImageGenerationSubmission } from '../../subject-images/generation-preview'
@@ -28,6 +32,8 @@ const props = defineProps<{
shotTitle: string
projectId: string
disabled: boolean
/** 原镜头条件仍有效时允许免费核对追加许可,不放开普通未知重发。 */
additionalAllowed?: boolean
replacePrimary?: boolean
/** 当前镜头的正式摄影设计。 */
direction?: ShotDirection | null
@@ -35,6 +41,8 @@ const props = defineProps<{
visualState?: ShotVisualState | null
/** 提交前已有候选,用于区分下载恢复与历史候选。 */
previousCandidateIds?: readonly string[]
/** 免费查看经当前预览核实的已有完整候选,不产生POST。 */
reuseExisting?: (fingerprint: string) => Promise<boolean>
/** 仅发送已经确认的当前快照。 */
submitGeneration: (input: GenerateKeyframeInput) => Promise<ImageGenerationSubmission>
}>()
@@ -69,6 +77,58 @@ const generationCatalog = ref<GenerationModelCatalog | null>(null)
const generationCatalogError = ref('')
/** 实际项目及镜头配置解析后的模型。 */
const imageProvider = ref('')
/** 当前用户主动选择的许可,重新打开或切换范围后不保留默认选择。 */
const additionalId = ref<string | null>(null)
/** 人工追加只属于OpenAI,不改变其它供应方的未知请求保护。 */
const canInspectAdditional = computed(() => !!props.additionalAllowed && imageProvider.value === 'openai-image')
/** 仅需要核对原失败请求时读取已有许可,不自动创建。 */
const additionalKey = computed(() =>
open.value && canInspectAdditional.value ? JSON.stringify([props.projectId, props.shotId]) : ''
)
/** 当前原项目的有限许可和原unknown历史。 */
const additionalQuery = useQuery(additionalKey, async (value, signal) => {
if (!value) return null
const [projectId] = JSON.parse(value) as [string, string]
const result = await imageAuthorizationApi.list(projectId, signal)
if (!result || !Array.isArray(result.requests) || !Array.isArray(result.authorizations))
throw new Error('原请求与授权记录读取不完整,请重新核对。')
return result
})
/** 只列原镜头已有且未撤销、尚有次数的许可,不自动选中。 */
const additionalOptions = computed(() =>
(additionalQuery.data.value?.additionalAuthorizations ?? [])
.filter(
permit =>
permit.status === 'approved' &&
permit.remainingRequests > 0 &&
additionalQuery.data.value?.requests.some(
row =>
row.id === permit.input.parentRequestId &&
row.input.projectId === props.projectId &&
row.input.targetId === props.shotId &&
row.input.scope === 'keyframe'
)
)
.map(permit => ({
label: `${permit.input.approvedBy} · 已用 ${permit.usedRequests} / 剩余 ${permit.remainingRequests} 次`,
value: permit.id
}))
)
/** 已选许可及其原unknown,不改写原范围或金额。 */
const additionalPermit = computed(() =>
additionalQuery.data.value?.additionalAuthorizations?.find(permit => permit.id === additionalId.value)
)
/** 原未知费用与预留保持显示。 */
const additionalParent = computed(() =>
additionalQuery.data.value?.requests.find(row => row.id === additionalPermit.value?.input.parentRequestId)
)
watch(
[() => props.projectId, () => props.shotId, open],
() => {
additionalId.value = null
},
{ flush: 'sync' }
)
/** 本次明确参数。 */
const imageGenerationOptions = ref<GenerationOptions>({})
/** 项目画幅。 */
@@ -76,7 +136,8 @@ const projectAspectRatio = ref<CreativeProfileAspectRatio>('9:16')
/** 预览和生成复用当前请求字段,生成时再附加版本及候选标记。 */
const generationInput = computed(() => ({
provider: imageProvider.value || undefined,
generationOptions: imageGenerationOptions.value
generationOptions: imageGenerationOptions.value,
...(additionalId.value ? { additionalAuthorizationId: additionalId.value } : {})
}))
/** 首帧与主体图片使用同一套预览确认与未知费用保护。 */
const {
@@ -84,6 +145,7 @@ const {
acknowledged,
requiresCostConfirmation,
chargeNotice,
reusableResult,
loading,
submitting,
error,
@@ -100,17 +162,32 @@ const {
targetId: props.shotId,
exactPreview: true
}),
recoveryTarget: () => (props.shotId ? 'keyframe:' + props.shotId : ''),
additionalAuthorizationId: () => additionalId.value ?? undefined,
recoveryTarget: () =>
props.shotId
? additionalId.value && additionalPermit.value
? `keyframe:${props.projectId}:${props.shotId}:additional:${additionalId.value}:used:${additionalPermit.value.usedRequests}`
: 'keyframe:' + props.shotId
: '',
previousCandidateIds: () => props.previousCandidateIds,
target: () => JSON.stringify([props.shotId, props.direction, props.visualState]),
target: () => JSON.stringify([props.projectId, props.shotId, props.direction, props.visualState]),
input: () => generationInput.value,
disabled: () => props.disabled || !imageProvider.value,
disabled: () =>
(props.disabled && !canInspectAdditional.value) ||
!imageProvider.value ||
(!!additionalId.value &&
(imageProvider.value !== 'openai-image' || additionalQuery.loading.value || !!additionalQuery.error.value)),
load: async (input, signal) => {
const shotId = props.shotId
const result = await productionApi.previewKeyframe(shotId, input, signal)
const result = await productionApi.previewKeyframe(
shotId,
{ provider: input.provider, generationOptions: input.generationOptions },
signal
)
if (result?.shotId !== shotId) throw new Error('预览结果与当前镜头不匹配。')
return result
},
reuseResult: props.reuseExisting ? result => props.reuseExisting!(result.previewFingerprint) : undefined,
generate: input => props.submitGeneration({ ...input, setPrimary: false })
})
@@ -169,7 +246,7 @@ watch(
<AppForm
ref="formRef"
:model="imageGenerationOptions"
:disabled="disabled || submitting"
:disabled="(disabled && !canInspectAdditional) || submitting"
:reset-key="`${open}:${shotId}`"
validate-on-change
@submit="submit"
@@ -196,6 +273,31 @@ watch(
<ContextNotice v-else-if="generationCatalogError" type="warning" :show-icon="false" class="mt-5 text-xs">
生成模型目录读取失败:{{ generationCatalogError }}
</ContextNotice>
<!-- 以下是用户主动选择的原精确计划追加许可,普通unknown不放行。 -->
<section v-if="canInspectAdditional" class="workspace-section-stack mt-5">
<p class="text-sm">
原请求和费用仍未知。只可使用已单独批准的有限许可,重新预览核对精确计划;不会自动追加或消费剩余次数。
</p>
<NSelect
v-model:value="additionalId"
clearable
:options="additionalOptions"
:disabled="submitting || additionalQuery.loading.value"
placeholder="主动选择已有人工追加许可(可不选,仅免费预览)"
aria-label="本次人工追加许可"
/><NButton
:loading="additionalQuery.loading.value"
:disabled="submitting"
@click="additionalQuery.refresh"
>刷新追加许可与原请求</NButton
>
<p v-if="additionalQuery.error.value" role="alert">{{ additionalQuery.error.value }}</p>
<p v-if="additionalParent" class="text-sm">
原镜头 {{ additionalParent.input.targetId }} · 原型号 {{ additionalParent.input.model }} · 原预留
{{ formatMicros(additionalParent.input.reservedMicros) }} · 原账单
{{ formatMicros(additionalParent.output?.actualBilledMicros) }}
</p>
</section>
<!-- 以下是正式摄影设计与画面状态 -->
<NCollapse v-if="direction || visualState" class="mt-5">
<NCollapseItem v-if="direction" name="direction" title="当前镜头设计">
@@ -261,7 +363,7 @@ watch(
:loading="submitting"
@click="formRef?.validate(submit)"
type="primary"
>确认生成首帧</NButton
>{{ reusableResult ? '查看已有同计划候选' : '确认生成首帧' }}</NButton
>
</template>
</AppDialog>
@@ -403,6 +403,17 @@ const canGenerateKeyframe = computed(
!!props.keyframeReadiness &&
props.keyframeReadiness.issues.length === 0
)
/** 原镜头、来源和活动任务条件仍满足时,只允许重新免费预览及受控追加,不放行普通重发。 */
const canUseAdditional = computed(
() =>
!assetBlocked.value &&
!query.loading.value &&
!!query.data.value &&
!keyframes.value.some(item => ['pending', 'generating'].includes(item.status)) &&
!!props.keyframeReadiness &&
props.keyframeReadiness.issues.length === 0 &&
keyframes.value.some(item => item.recoveryRequired)
)
const canGenerateVideo = computed(
() =>
!assetBlocked.value &&
@@ -513,17 +524,54 @@ async function generatePrompt() {
await refreshAll()
}
/**
* 从正式GET候选中查看精确预览对应的完整结果,不重新POST或修改主图。
* @param fingerprint 当前正式首帧预览指纹
* @returns 是否已经定位到完整同计划候选
*/
async function reuseExistingKeyframe(fingerprint: string) {
const projectId = props.projectId,
shotId = props.shot.shotId
await query.refresh()
if (disposed || props.projectId !== projectId || props.shot.shotId !== shotId || query.error.value) return false
const candidate = keyframes.value.find(
item =>
item.shotId === props.shot.shotId &&
item.status === 'completed' &&
!!item.imageUrl &&
item.recoveryRequired === false &&
item.providerInputFingerprint === fingerprint
)
if (!candidate) return false
actionMessage?.info('已读取已有同计划候选,没有新增模型请求;质量与主图资格仍需分别核对。')
return true
}
/**
* 提交已确认的首帧输入,并刷新该镜头候选。
* @param input 预览绑定的生成参数
* @returns 真实提交结果与可能的冲突
*/
async function generateKeyframe(input: GenerateKeyframeInput) {
if (!canGenerateKeyframe.value || !input.expectedPreviewFingerprint) return { accepted: false }
if (
(!canGenerateKeyframe.value &&
!(
input.additionalAuthorizationId &&
input.provider === 'openai-image' &&
input.setPrimary === false &&
canUseAdditional.value
)) ||
!input.expectedPreviewFingerprint
)
return { accepted: false }
const shotId = props.shot.shotId
const projectId = props.projectId
const accepted = await runOperation(projectId, `生成镜头 ${props.shot.shotNo} 首帧`, async () => {
const result = await productionApi.generateKeyframe(shotId, input)
const result = await productionApi.generateKeyframe(
shotId,
input,
input.additionalAuthorizationId ? projectId : undefined
)
if (
!result?.id ||
result.shotId !== shotId ||
@@ -1256,8 +1304,10 @@ defineExpose({ inspectSpecs, inspecting })
:direction="shot.direction"
:visual-state="shot.visualState"
:disabled="!canGenerateKeyframe"
:additional-allowed="canUseAdditional"
:previous-candidate-ids="keyframes.map(item => item.id)"
:submit-generation="generateKeyframe"
:reuse-existing="reuseExistingKeyframe"
/>
</section>
</template>
@@ -1,16 +1,15 @@
<script setup lang="ts">
import BillingEvidenceFields from '../../billing-audit/BillingEvidenceFields.vue'
import type { BillingFacts } from '../../billing-audit/types'
import { computed, watch } from 'vue'
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NInputNumber, NSelect } from 'naive-ui'
import { Trash2 } from '@lucide/vue'
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput, NSelect } from 'naive-ui'
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
import WorkspaceActionTooltip from '../../../components/ui/WorkspaceActionTooltip.vue'
import WorkspaceSectionHeading from '../../../components/ui/WorkspaceSectionHeading.vue'
import { formatDate } from '../../../lib/format'
import { useVideoAudit } from '../useVideoAudit'
import {
auditArtifactLabels,
auditFindingLabels,
auditOutcomeLabels,
auditFindingLabels,
auditStatusLabels,
auditRequestStatusLabels,
auditStepLabels
@@ -31,6 +30,31 @@ const form = useVideoAudit(props, () => emit('changed'))
const audit = computed(() => form.query.data.value?.audit)
/** 原任务质量和费用保持原输出。 */
const original = computed(() => form.query.data.value?.original)
/** 原ref表单映射至共享证据字段,保留已有视频审计状态和接口。 */
const evidenceFacts = computed<BillingFacts>({
get: () => ({
correlation: form.correlation.value,
providerRequestId: form.providerRequestId.value || null,
artifacts: form.artifacts.value,
execution: { outcome: form.outcome.value, evidenceIds: form.executionIds.value },
billing: {
finding: form.finding.value,
amount: form.amount.value,
currency: audit.value?.currency ?? '',
evidenceIds: form.billingIds.value
}
}),
set: value => {
form.correlation.value = value.correlation
form.providerRequestId.value = value.providerRequestId ?? ''
form.artifacts.value = value.artifacts
form.outcome.value = value.execution.outcome
form.executionIds.value = value.execution.evidenceIds
form.finding.value = value.billing.finding
form.amount.value = value.billing.amount
form.billingIds.value = value.billing.evidenceIds
}
})
/** 真实步骤选项。 */
const stepOptions = computed(
() =>
@@ -44,12 +68,6 @@ const evidenceOptions = computed(
value: row.id
})) ?? []
)
/** 下拉选项保留实际枚举值。 */
const artifactKinds = Object.entries(auditArtifactLabels).map(([value, label]) => ({ value, label }))
/** 执行结果选项。 */
const outcomeOptions = Object.entries(auditOutcomeLabels).map(([value, label]) => ({ value, label }))
/** 费用结果选项。 */
const findingOptions = Object.entries(auditFindingLabels).map(([value, label]) => ({ value, label }))
watch(form.saving, value => emit('busy', value), { flush: 'sync' })
/** 主操作由原抽屉固定 footer 提供。 */
defineExpose({ canSubmit: form.canSubmit, saving: form.saving, submit: form.submit, submitLabel: form.submitLabel })
@@ -190,140 +208,12 @@ defineExpose({ canSubmit: form.canSubmit, saving: form.saving, submit: form.subm
/>
</div>
<!-- 以下是外部原件登记表单,默认未知,原件引用不执行 URL -->
<section v-if="form.action.value === 'evidence'" class="workspace-section-stack">
<p class="text-sm text-muted">
请保存原件并填写非敏感定位说明。真实供应方请求号与本地请求、LangSmith
编号分别记录,不能互相代用。
</p>
<label class="workspace-form-field"
><span>登记人</span
><NInput v-model:value="form.operator.value" :maxlength="120" :disabled="form.saving.value"
/></label>
<div class="grid grid-cols-1 gap-(--app-field-gap) sm:grid-cols-2">
<div class="workspace-form-field">
<span>与原请求的关联</span
><NSelect
aria-label="与原请求的关联"
v-model:value="form.correlation.value"
:disabled="form.saving.value"
:options="[
{ label: '尚未核实', value: 'unverified' },
{ label: '关联有歧义', value: 'ambiguous' },
{ label: '已唯一关联', value: 'unique' }
]"
/>
</div>
<label class="workspace-form-field"
><span>真实供应方请求号(未知留空)</span
><NInput
v-model:value="form.providerRequestId.value"
:maxlength="200"
:disabled="form.saving.value"
/></label>
</div>
<article
v-for="(item, index) in form.artifacts.value"
:key="index"
class="surface-inset p-4 workspace-section-stack min-w-0"
>
<div class="flex items-center justify-between gap-3">
<h3 class="font-semibold">原件 {{ index + 1 }}</h3>
<WorkspaceActionTooltip label="删除原件"
><NButton
class="workspace-action-button icon-button"
:disabled="form.saving.value"
aria-label="删除原件"
@click="form.removeArtifact(index)"
><Trash2 :size="16" /></NButton
></WorkspaceActionTooltip>
</div>
<div class="grid grid-cols-1 gap-(--app-field-gap) sm:grid-cols-2">
<label class="workspace-form-field"
><span>包内引用键</span
><NInput v-model:value="item.id" :maxlength="120" :disabled="form.saving.value"
/></label>
<div class="workspace-form-field">
<span>原件来源</span
><NSelect
aria-label="原件来源"
v-model:value="item.kind"
:options="artifactKinds"
:disabled="form.saving.value"
/>
</div>
</div>
<label class="workspace-form-field"
><span>原件记录编号</span
><NInput v-model:value="item.recordId" :maxlength="200" :disabled="form.saving.value"
/></label>
<label class="workspace-form-field"
><span>原件 SHA256</span
><NInput v-model:value="item.sha256" :maxlength="64" :disabled="form.saving.value"
/></label>
<label class="workspace-form-field"
><span>非敏感原件定位说明</span
><NInput
v-model:value="item.reference"
type="textarea"
:maxlength="1000"
:disabled="form.saving.value"
/></label>
</article>
<NButton
:disabled="form.saving.value || form.artifacts.value.length >= 20"
@click="form.addArtifact"
>添加原件</NButton
>
<div class="grid grid-cols-1 gap-(--app-field-gap) sm:grid-cols-2">
<div class="workspace-form-field">
<span>供应方执行结果</span
><NSelect
aria-label="供应方执行结果"
v-model:value="form.outcome.value"
:options="outcomeOptions"
:disabled="form.saving.value"
/>
</div>
<div class="workspace-form-field">
<span>执行依据原件</span
><NSelect
aria-label="执行依据原件"
v-model:value="form.executionIds.value"
multiple
:options="form.artifactOptions.value"
:disabled="form.saving.value"
/>
</div>
<div class="workspace-form-field">
<span>原始费用结论</span
><NSelect
aria-label="原始费用结论"
v-model:value="form.finding.value"
:options="findingOptions"
:disabled="form.saving.value"
/>
</div>
<div class="workspace-form-field">
<span>费用依据原件</span
><NSelect
aria-label="费用依据原件"
v-model:value="form.billingIds.value"
multiple
:options="form.artifactOptions.value"
:disabled="form.saving.value"
/>
</div>
<label class="workspace-form-field"
><span>实际金额({{ audit.currency }},未知留空)</span
><NInputNumber
v-model:value="form.amount.value"
:min="0"
clearable
:disabled="form.saving.value"
/></label>
</div>
</section>
<!-- 以下是独立人工复核表单,资料不足时保留阻断 -->
<BillingEvidenceFields
v-if="form.action.value === 'evidence'"
v-model="evidenceFacts"
v-model:operator="form.operator.value"
:disabled="form.saving.value"
/>
<section v-else class="workspace-section-stack">
<div class="workspace-form-field">
<span>选择已登记证据包</span
+2
View File
@@ -348,6 +348,8 @@ export interface GenerateKeyframesInput {
/** 单镜头首帧生成参数。 */
export interface GenerateKeyframeInput {
/** 用户主动选择的人工有限追加许可,只作用于原精确OpenAI首帧计划。 */
additionalAuthorizationId?: string
/** 用户确认的最终输入版本。 */
expectedPreviewFingerprint?: string
/** 单镜头生成总是先生成候选。 */ setPrimary: boolean
+9 -50
View File
@@ -1,22 +1,8 @@
import { billingEvidenceIssues } from '../billing-audit/evidence'
import type { VideoAuditEvidence, VideoAuditStep, VideoAuditView } from './video-audit.types'
/** 原件来源使用中文选项,提交保留原枚举。 */
export const auditArtifactLabels = {
'provider-execution': '供应方执行原件',
'provider-billing': '供应方账单原件',
'provider-support': '供应方官方支持材料',
langsmith: 'LangSmith 观测记录',
'client-log': '客户端日志'
}
/** 原执行结论不替代质量结论。 */
export const auditOutcomeLabels = {
'not-received': '供应方未接收',
succeeded: '供应方执行完成',
failed: '供应方执行失败',
unknown: '执行结果未知'
}
/** 原收费结论不以零 Token 推断。 */
export const auditFindingLabels = { charged: '已收费', 'no-charge': '未收费', unknown: '费用未知' }
/** 图片与视频复用原件、执行和费用选项,保留原导出路径。 */
export { auditArtifactLabels, auditOutcomeLabels, auditFindingLabels } from '../billing-audit/labels'
/** 费用审计状态中文。 */
export const auditStatusLabels = { unreviewed: '等待人工核查', blocked: '保留费用阻断', released: '此步骤费用已核清' }
/** 原请求步骤名称。 */
@@ -35,39 +21,12 @@ export const auditStepLabels: Record<string, string> = {
* @returns 校验问题
*/
export function auditEvidenceIssues(evidence: VideoAuditEvidence): string[] {
const issues: string[] = []
const ids = evidence.artifacts.map(item => item.id)
if (!ids.length || ids.length > 20 || new Set(ids).size !== ids.length)
issues.push('请提供 1~20 项原件,引用键不能重复。')
if (
evidence.artifacts.some(
item =>
!item.id.trim() ||
item.id.length > 120 ||
!item.recordId.trim() ||
item.recordId.length > 200 ||
!/^[a-f0-9]{64}$/.test(item.sha256) ||
!item.reference.trim() ||
item.reference.length > 1000
)
)
issues.push('请填写每项原件的引用键、记录编号、64 位小写 SHA256 及定位说明。')
if ([...evidence.execution.evidenceIds, ...evidence.billing.evidenceIds].some(id => !ids.includes(id)))
issues.push('执行或费用引用的原件已不存在,请重新选择。')
if (evidence.billing.amount !== null && (!Number.isFinite(evidence.billing.amount) || evidence.billing.amount < 0))
issues.push('实际金额需为非负数,未知请留空。')
if (
evidence.providerRequestId &&
([
evidence.identity.requestId,
evidence.identity.taskId,
evidence.identity.workflowExecutionId,
evidence.identity.videoId
].includes(evidence.providerRequestId) ||
evidence.artifacts.some(item => item.kind === 'langsmith' && item.recordId === evidence.providerRequestId))
)
issues.push('本地任务、请求或 LangSmith 编号不能作为供应方请求号。')
return issues
return billingEvidenceIssues(evidence, [
evidence.identity.requestId,
evidence.identity.taskId,
evidence.identity.workflowExecutionId,
evidence.identity.videoId
])
}
/**
* 资料不完整时禁用核清,最终真实性与唯一认领仍由人工及服务端核验。
+3
View File
@@ -56,7 +56,10 @@ export interface Project {
/** 正式数据库剧集;episode 是编号,与 Breakdown 的 episodeNo 区分。 */
export interface Episode {
/** 正式集ID;缺失时不能构造环境采用证据。 */
id?: string
/** 正式所属项目,环境证据必须与当前项目一致。 */
projectId?: string
episode: number
targetDurationSeconds: number | null
title: string
+88 -66
View File
@@ -53,11 +53,12 @@ import SubjectCoverageAudit from './components/SubjectCoverageAudit.vue'
import type { SubjectCoverageIssue } from './coverage.types'
import WorkflowExecutionPanel from '../workflows/WorkflowExecutionPanel.vue'
import { useWorkflowExecution } from '../workflows/execution'
import { useStoryboard } from './useStoryboard'
import { useStoryboard, type StoryboardCommand } from './useStoryboard'
import { storyboardApi, type StoryboardDurationAudit } from './api'
import { projectsApi } from '../projects/api'
import type { ProjectDurationBudgetSummary } from '../projects/types'
/** 默认查看当前镜头设计,生成配置仅从工具入口打开。 */
const detailTab = ref('design')
/** 即使生产入口受来源门禁限制,也可免费核对连续性。 */
const continuityOpen = ref(false)
@@ -128,8 +129,44 @@ const {
visualStateComplete,
hasCurrentEpisodeShots,
executions,
run
run: runCommand
} = useStoryboard()
/** 本页主动操作产生的回执直接显示,恢复的历史回执保持默认收起。 */
const currentActionReceipt = ref(false)
/**
* 仅标记本页明确发起的操作,保留原命令、参数、费用确认和任务观察流程。
* @param command 用户已确认的生成阶段
* @returns 原操作的提交及状态读取完成
*/
async function run(command: StoryboardCommand): Promise<void> {
if (!allowed.value[command]) return
currentActionReceipt.value = true
await runCommand(command)
}
watch(
id,
() => {
currentActionReceipt.value = false
},
{ flush: 'sync' }
)
/** 本页真实任务入口,过滤不属于单集重生成的拆解任务。 */
const taskEntries = computed(() =>
executions.filter(
item =>
item.observer.executionId.value &&
(item.title !== '单集镜头重生成' ||
item.observer.query.data.value?.metadata?.action === 'regenerate-storyboard-episode')
)
)
/** 当前活动或尚待读取的记录保持直接可见。 */
const currentTasks = computed(() =>
taskEntries.value.filter(item => item.observer.query.data.value?.status !== 'completed')
)
/** 已完成任务完整保留在默认收起的历史区域,失败记录仍直接显示。 */
const historicalTasks = computed(() =>
taskEntries.value.filter(item => item.observer.query.data.value?.status === 'completed')
)
/**
* 显示正式派生状态与当前任务,不将候选或领取回执当作审核通过。
* @param item 当前正式镜头
@@ -276,7 +313,7 @@ function exportEpisode() {
'application/json'
)
}
/** 回执到达后打开诊断区;平时留出镜头检查空间。 */
/** 生成配置由用户主动打开,历史回执恢复不打断镜头浏览。 */
const toolsOpen = ref(false)
/** 覆盖审计只保存剧集与镜头坐标,正式 ID 从当前查询结果中定位。 */
const auditLocation = ref<SubjectCoverageIssue | null>(null)
@@ -327,7 +364,6 @@ watch(
() => session.value.receipt,
receipt => {
if (receipt) {
toolsOpen.value = true
/** 正式镜头重生成完成后重新读取预算与审计,避免展示旧时长。 */
if (receipt.kind === 'shots' && id.value) void refreshDuration(id.value)
}
@@ -367,21 +403,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<ContextNotice v-if="episodeSourceUnavailable" type="info" :show-icon="false">
本集镜头已更新。标题和剧情详情待补齐。
</ContextNotice>
<!-- 以下是镜头生产所需的全项目设计进度,生成操作仍需单独确认。 -->
<ContextNotice v-if="projectDesignGap" type="info">
<div class="flex flex-wrap items-center gap-x-3">
<span>
全项目有效进度:镜头设计 {{ projectDesignGap.directionCount }}/{{
projectDesignGap.shotCount
}}, 画面状态 {{ projectDesignGap.visualStateCount }}/{{ projectDesignGap.shotCount }}。
<template v-if="projectDesignGap.staleDirectionCount || projectDesignGap.staleVisualStateCount">
需更新:镜头设计 {{ projectDesignGap.staleDirectionCount ?? 0 }} 个、画面状态
{{ projectDesignGap.staleVisualStateCount ?? 0 }} 个。
</template>
</span>
<NButton text size="small" @click="toolsOpen = true">查看生成选项</NButton>
</div>
</ContextNotice>
<ContextNotice v-if="currentEpisodeDurationIssues.length" type="warning" :show-icon="false">
<div class="text-sm font-medium">
本集有 {{ currentEpisodeDurationIssues.length }} 条分镜时长建议(不阻断生成)
@@ -454,6 +475,12 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
>
</div>
<div class="toolbar-actions">
<!-- 以下是统一中性底面的低频操作,位于工具栏最左侧。 -->
<ActionMenu
label="分镜更多操作"
:items="[{ key: 'export', label: '导出本集', disabled: !shots.length }]"
@select="exportEpisode"
/>
<!-- 以下是复用生产工作区的连续性审核入口 -->
<WorkspaceActionTooltip label="连续性审核" mobile-only
><NButton
@@ -461,35 +488,21 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
:disabled="!id || shots.length < 2"
aria-label="连续性审核"
@click="continuityOpen = true"
><ScanEye :size="18" class="mobile-action-icon" /><span class="workspace-action-label"
>连续性审核</span
></NButton
><template #icon><ScanEye :size="15" /></template>
<span class="workspace-action-label">连续性审核</span></NButton
></WorkspaceActionTooltip
>
<div class="flex gap-3">
<ActionMenu
label="分镜更多操作"
:items="[{ key: 'export', label: '导出本集', disabled: !shots.length }]"
@select="exportEpisode"
/>
</div>
<!-- 以下是全屏分镜生成配置与回执,标题与关闭栏固定。 -->
<WorkspaceTools
:pending="operation.pending"
:pending-label="operation.label"
v-model:open="toolsOpen"
title="分镜生成配置与回执"
title="分镜生成"
label="生成与恢复"
:has-receipt="!!session.receipt"
fullscreen
>
<div class="flex flex-wrap items-end justify-between gap-4">
<div>
<h2 class="text-lg font-semibold">分镜设计</h2>
<p class="mt-2 text-sm text-muted">从镜头拆解到摄影设计,再补齐每一镜的即时状态。</p>
</div>
</div>
<!-- 以下是按正式 Episode、Beat、Shot 选择的生成范围。 -->
<section class="workspace-section-stack" aria-label="派生镜头范围">
<label class="workspace-form-field"
@@ -504,8 +517,10 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
{ label: '全项目', value: 'project' }
]"
/></label>
<p class="text-sm">{{ scopeLabel }} · 默认复用已有有效结果。</p>
<NCollapse
<p class="text-sm">
{{ scopeLabel }} · {{ force ? '覆盖已有结果' : '只补缺失或过期结果' }}
</p>
<NCollapse v-if="generationScope === 'selected'"
><NCollapseItem name="range-selection" title="选择镜头(按段落)">
<BeatShotDirectory
:shots="shots"
@@ -609,6 +624,15 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</div>
</AppForm>
</section>
<!-- 以下是完整项目进度,仅在生成配置中核对。 -->
<p v-if="projectDesignGap" class="text-sm text-muted">
全项目:摄影 {{ projectDesignGap.directionCount }}/{{ projectDesignGap.shotCount }} · 画面
{{ projectDesignGap.visualStateCount }}/{{ projectDesignGap.shotCount }}
<span v-if="projectDesignGap.staleDirectionCount || projectDesignGap.staleVisualStateCount">
· 过期摄影 {{ projectDesignGap.staleDirectionCount ?? 0 }} / 画面
{{ projectDesignGap.staleVisualStateCount ?? 0 }}
</span>
</p>
<!-- 以下是共用中性底色的本集设计进度模块。 -->
<section
class="storyboard-coverage workspace-panel grid grid-cols-1 gap-4 sm:grid-cols-2"
@@ -647,11 +671,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<h3 class="text-sm font-semibold">
<span class="mr-2 font-mono text-xs text-muted">00</span>本集镜头拆解
</h3>
<p class="mt-2 text-xs leading-6 text-muted">
只重新拆解当前选择的第
{{ episodeNo }}
集,其他剧集不受影响。新镜头会替换旧镜头,并清空本集已有的导演设计、即时状态、首帧与视频结果。
</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
@@ -677,9 +696,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<h3 class="text-sm font-semibold">
<span class="mr-2 font-mono text-xs text-muted">01</span>导演摄影设计
</h3>
<p class="mt-2 text-xs leading-6 text-muted">
先准备摄影,再由用户另行发起画面状态生成。已有有效镜头自动复用。
</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
@@ -712,9 +728,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<h3 class="text-sm font-semibold">
<span class="mr-2 font-mono text-xs text-muted">02</span>即时视觉状态
</h3>
<p class="mt-2 text-xs leading-6 text-muted">
先补齐导演设计,再生成表情、姿态和环境等画面状态。
</p>
</div>
<div class="flex flex-wrap gap-2">
<ConfirmAction
@@ -747,9 +760,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</p>
<!-- 以下是所选范围的只读参考素材与分阶段生产缺口。 -->
<StagedShotPreparation :project-id="id" :shots="selectedShots" :active="toolsOpen" />
<p class="mt-4 text-[11px] leading-6 text-muted">
设计更新后,请依次更新画面状态和视频提示词。自动修复次数只用于画面状态。
</p>
<section>
<h3 class="text-sm font-semibold">视频提示词批量操作</h3>
<p class="my-3 text-xs leading-6 text-muted">
@@ -773,13 +783,7 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
</section>
<!-- 以下是正式分镜后台执行状态模块 -->
<WorkflowExecutionPanel
v-for="entry in executions.filter(
item =>
item.observer.executionId.value &&
(item.title !== '单集镜头重生成' ||
item.observer.query.data.value?.metadata?.action ===
'regenerate-storyboard-episode')
)"
v-for="entry in currentTasks"
:key="entry.title"
:title="entry.title"
:execution="entry.observer.query.data.value"
@@ -791,7 +795,31 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
@refresh="entry.observer.query.refresh"
@dismiss="entry.observer.dismiss"
/>
<GenerationReceipt v-if="session.receipt" :receipt="session.receipt" />
<GenerationReceipt
v-if="currentActionReceipt && session.receipt"
:receipt="session.receipt"
/>
<!-- 以下是可随时查看的历史回执,不恢复弹窗或遮挡当前配置。 -->
<NCollapse v-if="historicalTasks.length || (!currentActionReceipt && session.receipt)">
<NCollapseItem name="history" title="历史任务与回执">
<div class="workspace-section-stack">
<WorkflowExecutionPanel
v-for="entry in historicalTasks"
:key="entry.title"
:title="entry.title"
:execution="entry.observer.query.data.value"
:loading="entry.observer.query.loading.value"
:error="entry.observer.query.error.value"
@refresh="entry.observer.query.refresh"
@dismiss="entry.observer.dismiss"
/>
<GenerationReceipt
v-if="!currentActionReceipt && session.receipt"
:receipt="session.receipt"
/>
</div>
</NCollapseItem>
</NCollapse>
</div>
</div>
</WorkspaceTools>
@@ -845,7 +873,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
<h3>
镜头目录 <span>{{ shots.length }} 镜</span>
</h3>
<span>已选 {{ checkedShotIds.length }} 镜</span>
</div>
<NScrollbar
class="panel-scroll directory-scroll"
@@ -856,11 +883,6 @@ const rules = { concurrency: integerRule('批量并发'), maxRepairAttempts: int
:shots="shots"
:active-id="shot?.shotId || ''"
item-class="shot-link"
selectable
:checked-ids="checkedShotIds"
:selection-disabled="operation.pending || query.loading.value"
@toggle="toggleShots([$event])"
@toggle-beat="toggleShots"
@select="selectedShot = $event"
>
<template #meta="{ shot: item }">
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { visualStateTimeIssueLabel } from '../visual-state-time'
import { userFacingText } from '../../../lib/user-facing-text'
import ContextNotice from '../../../components/ui/ContextNotice.vue'
@@ -87,7 +88,9 @@ function exportReceipt() {
<p>{{ item.error || '—' }}</p>
<p v-for="(issue, index) in item.remainingIssues" :key="index" class="mt-2 text-danger">
剧情段落 {{ issue.beatNo ?? '—' }} / 镜头 {{ issue.shotNo ?? '—' }}
{{ issue.subjectRef }}:{{ userFacingText(issue.message) }}
<span v-if="visualStateTimeIssueLabel(issue)"
>{{ visualStateTimeIssueLabel(issue) }} · </span
>{{ issue.subjectRef }}:{{ userFacingText(issue.message) }}
</p>
</td>
</tr>
@@ -0,0 +1,79 @@
<script setup lang="ts">
import { NCollapse, NCollapseItem, NInput } from 'naive-ui'
import VisualStateContinuity from './VisualStateContinuity.vue'
import DirectionCameraFields from './DirectionCameraFields.vue'
import type { ShotReviewDraft } from '../derived-review.types'
import { jointFieldLabels } from '../joint-review'
/** 同一摄影审核抽屉中的有界联合编辑,不新增身份或形态;环境需本集证据。 */
defineProps<{ /** 正式提交时保持完整草案稳定。 */ disabled: boolean }>()
/** 当前完整草案,未开放字段保留原值。 */
const draft = defineModel<ShotReviewDraft>({ required: true })
/** 服务端允许修改的主体0秒字段。 */
const fields = ['expression', 'pose', 'gaze', 'position', 'transientState'] as const
/** 现有环境Schema的四个字段,未知值保持原空字符串。 */
const environmentFields = ['timeOfDay', 'weather', 'atmosphere', 'transientState'] as const
</script>
<template>
<!-- 以下是原摄影编辑器共用字段,摄影枚举和正式动作保持只读。 -->
<div class="workspace-section-stack">
<DirectionCameraFields
v-model:composition="draft.direction.composition"
v-model:camera-position="draft.direction.cameraPosition"
:disabled="disabled"
/>
<label class="workspace-form-field"
><span>摄影意图</span
><NInput
v-model:value="draft.direction.visualIntent"
type="textarea"
:disabled="disabled"
:maxlength="4000"
aria-label="联合摄影意图"
/></label>
<!-- 以下是可选环境修订,完整差异及本集原文在同一联合面板核对。 -->
<NCollapse>
<NCollapseItem name="environment" title="环境修订(需本集原文)">
<div class="workspace-section-stack">
<label v-for="field in environmentFields" :key="field" class="workspace-form-field">
<span>{{ jointFieldLabels[field] }}</span>
<NInput
v-model:value="draft.visualState.environment[field]"
type="textarea"
:maxlength="4000"
:disabled="disabled"
:aria-label="`环境${jointFieldLabels[field]}`"
placeholder="未知可留空"
/>
</label>
</div>
</NCollapseItem>
</NCollapse>
<!-- 以下是原正式主体的开拍状态,不能修改主体集合与形态身份。 -->
<section
v-for="subject in draft.visualState.subjects"
:key="subject.subjectRef"
class="workspace-section-stack"
>
<h4 class="text-sm font-medium">{{ subject.formName }} · {{ subject.subjectRef }} · 当前开拍状态</h4>
<label v-for="field in fields" :key="field" class="workspace-form-field"
><span>{{ jointFieldLabels[field] }}</span
><NInput
v-model:value="subject[field]"
type="textarea"
:maxlength="4000"
:disabled="disabled"
:aria-label="`${subject.subjectRef} · ${jointFieldLabels[field]}`"
/></label>
</section>
<label class="workspace-form-field"
><span>衔接与时间依据</span
><NInput
v-model:value="draft.visualState.continuityNote"
type="textarea"
:maxlength="4000"
:disabled="disabled"
aria-label="联合衔接与时间依据"
/></label>
<VisualStateContinuity v-if="draft.visualState.continuityNote" :note="draft.visualState.continuityNote" />
</div>
</template>
@@ -0,0 +1,692 @@
<script setup lang="ts">
import { computed, onScopeDispose, ref, watch } from 'vue'
import { NButton, NCheckbox, NCollapse, NCollapseItem, NInput } from 'naive-ui'
import { WorkspaceSectionHeading } from '../../../components/ui'
import RawDataDetails from '../../../components/ui/RawDataDetails.vue'
import { useActionMessage } from '../../../components/ui/useActionMessage'
import { useQuery } from '../../../composables/useQuery'
import { ApiError, errorMessage } from '../../../lib/http'
import { userFacingText } from '../../../lib/user-facing-text'
import { preparationApi } from '../../storyboard-preparation/api'
import { currentStoryboardApproval } from '../../storyboard-preparation/model'
import { productionApi } from '../../production/api'
import { projectsApi } from '../../projects/api'
import type { KeyframeGenerationPreview } from '../../production/types'
import ImageGenerationPreview from '../../subject-images/components/ImageGenerationPreview.vue'
import { runOperation, getOperation } from '../../workflows/operations'
import { storyboardApi } from '../api'
import { mergeDesignedShots } from '../model'
import { derivedReviewApi } from '../derived-review-api'
import { draftFromFormal } from '../derived-review'
import { jointDraftDifferences, jointValue } from '../joint-review'
import type {
DerivedReviewSelection,
DraftProviderInput,
JointDerivedReviewResult,
ShotDraftPreview,
ShotReviewDraft
} from '../derived-review.types'
import type { DesignedShot } from '../types'
import JointDraftFields from './JointDraftFields.vue'
import ShotDesign from './ShotDesign.vue'
/** 在原摄影抽屉内扩展联合模式,所有动作仍走原草案、预览和采用接口。 */
const props = defineProps<{
/** 正式项目。 */ projectId: string
/** 正式集号。 */ episodeNo: number
/** 当前镜头。 */ shot: DesignedShot
/** 原目录中的镜头位置。 */ shots: DesignedShot[]
/** 实际活动锁。 */ disabled: boolean
}>()
/** 成功采用后只读刷新原分镜工作台。 */
const emit = defineEmits<{ changed: [] }>()
/** 当前完整待审草案。 */
const draft = ref<ShotReviewDraft | null>(null)
/** 保留保存时显式参数,不用当前模型推荐覆盖原参数。 */
const providerInput = ref<DraftProviderInput | undefined>()
/** 只在首次读取时回填,其后版本刷新保留人工输入。 */
const initialized = ref(false)
/** 联合修订与剪辑依据。 */
const reason = ref('')
/** 实际审核人。 */
const reviewer = ref('')
/** 环境修订的本集逐字片段,不预填、不存入草案或本地授权。 */
const environmentQuote = ref('')
/** 当前预检经人工明确确认。 */
const acknowledged = ref(false)
/** 同步保存或正式采用期间锁定底栏和输入。 */
const saving = ref(false)
/** 只让当前写入操作显示加载,其它底栏操作仅禁用。 */
const savingKind = ref<'save' | 'adopt' | null>(null)
/** 免费读取的当前动作,避免两个按钮同时显示加载。 */
const previewKind = ref<'input' | 'adoption' | null>(null)
/** 免费预览与联合预检不阻止用户关闭。 */
const previewing = ref(false)
/** 已核对的草案画面输入,只能用于草案。 */
const preview = ref<ShotDraftPreview | null>(null)
/** 采用后独立读取的正式首帧预览,不能沿用草案指纹。 */
const formalPreview = ref<KeyframeGenerationPreview | null>(null)
/** 冻结同一审核人、完整草案、邻镜及差异,正式采用不重建请求。 */
const checked = ref<{ reviewer: string; shots: DerivedReviewSelection[]; result: JointDerivedReviewResult } | null>(
null
)
/** 当前采用回执与草案保存状态分开。 */
const adopted = ref<JointDerivedReviewResult | null>(null)
/** 409或连接未知后要求显式读取,不自动覆盖或重提。 */
const conflict = ref(false)
/** 表单问题仅在主动操作后展示。 */
const validation = ref('')
/** 当前项目与镜头共同隔离。 */
const key = computed(() => JSON.stringify([props.projectId, props.episodeNo, props.shot.shotId]))
/** 原正式摄影、状态、保存草案及首帧来源共用读取,不推测缺失字段。 */
const source = useQuery(key, async (value, signal) => {
const [projectId, episodeNo, shotId] = JSON.parse(value) as [string, number, string]
const [saved, approval, directions, visuals, keyframe] = await Promise.all([
derivedReviewApi.draft(projectId, shotId, signal),
preparationApi.approval(projectId, signal),
storyboardApi.directions(projectId, episodeNo, signal),
storyboardApi.visualStates(projectId, episodeNo, signal),
productionApi.keyframeSpec(shotId, signal, projectId)
])
if (
!currentStoryboardApproval(approval, projectId) ||
keyframe?.shotId !== shotId ||
keyframe.projectId !== projectId ||
keyframe.episodeNo !== episodeNo ||
!keyframe.formalSourceFingerprint
)
throw new Error('当前正式来源或审核无法核对,请重新读取。')
if (saved && saved.shotId !== shotId) throw new Error('已保存草案不属于当前镜头。')
if (
directions?.projectId !== projectId ||
directions.episodeNo !== episodeNo ||
visuals?.projectId !== projectId ||
visuals.episodeNo !== episodeNo
)
throw new Error('正式摄影状态不属于当前项目或剧集。')
const rows = mergeDesignedShots(directions, visuals)
const shot = rows.find(row => row.shotId === shotId)
if (!shot?.direction || !shot.visualState) throw new Error('联合采用需要已有正式摄影和画面状态,不能填充空状态。')
return {
saved,
formal: draftFromFormal(shot, keyframe, approval.confirmation!.shotFingerprint),
shot,
rows,
keyframe
}
})
/** 原保存记录的修订和状态只由正式GET更新。 */
const saved = computed(() => source.data.value?.saved)
/** 全部变化都展示,越界变化不能通过过滤后提交。 */
const differences = computed(() =>
source.data.value && draft.value ? jointDraftDifferences(source.data.value.formal, draft.value) : []
)
/** 只有真实环境差异才读取本集全文,原摄影模式不增加查询。 */
const hasEnvironmentChanges = computed(() => differences.value.some(item => item.change?.target === 'environment'))
/** 原项目、剧集和镜头隔离本集原文读取。 */
const environmentKey = computed(() => (hasEnvironmentChanges.value ? key.value : ''))
/** 正式项目详情公开完整content,原字节计算SHA,最终外键归属由原采用事务核对。 */
const environmentSource = useQuery(environmentKey, async (value, signal) => {
if (!value) return null
const [projectId, episodeNo] = JSON.parse(value) as [string, number, string]
const project = await projectsApi.detail(projectId, signal)
if (project?.id !== projectId || !Array.isArray(project.episodes))
throw new Error('本集正式原文无法读取,请刷新后核对。')
const matches = project.episodes.filter(episode => episode.episode === episodeNo)
const episode = matches[0]
if (
matches.length !== 1 ||
typeof episode?.id !== 'string' ||
!episode.id.trim() ||
episode.projectId !== projectId ||
typeof episode.content !== 'string'
)
throw new Error('缺少本集正式身份或全文,不能使用摘要代替环境依据。')
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(episode.content))
return {
episodeId: episode.id,
title: episode.title,
content: episode.content,
expectedContentFingerprint: Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join(
''
)
}
})
/** 片段必须逐字出自已读本集全文,匹配仅证明来源和版本,不证明环境语义正确。 */
const environmentEvidence = computed(() => {
const original = environmentSource.data.value,
quote = environmentQuote.value.trim()
if (!original || !quote || quote.length > 4000 || !original.content.includes(quote)) return null
return { episodeId: original.episodeId, expectedContentFingerprint: original.expectedContentFingerprint, quote }
})
/** 环境差异缺证、读取失败或刷新期间不开放预检及采用,普通草案保存仍独立。 */
const environmentReady = computed(
() =>
!hasEnvironmentChanges.value ||
(!!environmentEvidence.value && !environmentSource.loading.value && !environmentSource.error.value)
)
/** 同一已保存版本、完整内容和来源匹配后才有联合采用资格。 */
const savedMatches = computed(
() =>
!!saved.value &&
saved.value.status === 'current' &&
!!draft.value &&
jointValue(saved.value.draft) === jointValue(draft.value)
)
/** 合法白名单之外的差异及其它模式不能混入联合采用。 */
const bounded = computed(
() =>
differences.value.length > 0 &&
differences.value.length <= 40 &&
differences.value.every(item => item.allowed && item.before.length <= 4000 && item.after.length <= 4000) &&
!draft.value?.subjectStateRevision &&
!draft.value?.sceneStateCarryForward
)
/** 超出正式联合契约时解释禁用原因,保留完整原稿供核对。 */
const boundaryNotice = computed(() => {
if (draft.value?.subjectStateRevision || draft.value?.sceneStateCarryForward)
return '当前草案包含其它修订模式,请在原模式核对;联合采用不能混合提交。'
if (differences.value.length > 40) return '本次差异超过40项,请缩小联合修订范围后重新保存。'
if (differences.value.some(item => item.before.length > 4000 || item.after.length > 4000))
return '存在超过4000字的字段差异,请核对完整内容并缩小本次修订范围。'
if (differences.value.some(item => !item.allowed)) return '存在不允许联合修改的事实,请核对下方完整差异。'
return ''
})
/** 中文消息与原页面共用。 */
const message = useActionMessage()
/** 免费请求的取消控制器。 */
let controller: AbortController | undefined
/** 编辑、切换或重新读取来源后立即废弃旧预检。 */
function clearPreview() {
controller?.abort()
preview.value = null
checked.value = null
acknowledged.value = false
previewing.value = false
previewKind.value = null
validation.value = ''
}
watch([draft, providerInput], clearPreview, { deep: true, flush: 'sync' })
/** 署名和修订依据改变只撤销采用确认,原画面输入仍须相同。 */
watch(
[reason, reviewer, environmentQuote, environmentSource.data, environmentSource.loading],
() => {
controller?.abort()
checked.value = null
acknowledged.value = false
previewing.value = false
validation.value = ''
},
{ flush: 'sync' }
)
watch(
key,
() => {
clearPreview()
initialized.value = false
draft.value = null
providerInput.value = undefined
reason.value = ''
reviewer.value = ''
environmentQuote.value = ''
adopted.value = null
formalPreview.value = null
conflict.value = false
},
{ flush: 'sync' }
)
watch(source.data, value => {
clearPreview()
if (value && !initialized.value) {
draft.value = JSON.parse(JSON.stringify(value.saved?.draft ?? value.formal))
providerInput.value = value.saved?.providerInput ?? undefined
initialized.value = true
}
})
onScopeDispose(clearPreview)
/** 原记录有错误或来源读取中时不放行任何写入。 */
const canSave = computed(
() =>
!!draft.value &&
!!source.data.value &&
!source.error.value &&
!source.loading.value &&
!props.disabled &&
!saving.value &&
!previewing.value &&
!adopted.value
)
/** 正式采用仅接收同一份已核对快照。 */
const canAdopt = computed(
() =>
!!checked.value &&
acknowledged.value &&
!saving.value &&
!props.disabled &&
!conflict.value &&
!source.error.value &&
!source.loading.value &&
environmentReady.value &&
!adopted.value
)
/**
* 明确从当前正式内容重新开始,原已保存草案和历史保持。
*/
function editFormal() {
if (!source.data.value || saving.value) return
draft.value = JSON.parse(JSON.stringify(source.data.value.formal))
adopted.value = null
formalPreview.value = null
conflict.value = false
}
/** 显式重读原版本,保留当前人工草案,不自动重存或采用。 */
async function reload() {
clearPreview()
await Promise.all([source.refresh(), ...(hasEnvironmentChanges.value ? [environmentSource.refresh()] : [])])
if (!source.error.value) conflict.value = false
}
/** 显式保存完整原稿,保存成功不能表示采用成功。 */
async function save() {
if (!canSave.value || !draft.value || !source.data.value) return
const target = key.value
savingKind.value = 'save'
saving.value = true
clearPreview()
try {
const result = await derivedReviewApi.saveDraft(props.projectId, props.shot.shotId, {
expectedRevision: saved.value?.revision ?? null,
draft: JSON.parse(JSON.stringify(draft.value)),
...(providerInput.value ? { providerInput: providerInput.value } : {}),
expectedCurrentFormalSourceFingerprint: source.data.value.keyframe.formalSourceFingerprint
})
if (target !== key.value) return
if (result?.shotId !== props.shot.shotId || !Number.isSafeInteger(result.revision))
throw new Error('保存回执无法核对,请读取原草案。')
source.data.value = { ...source.data.value!, saved: result }
message?.success('联合草案已保存,尚未正式采用')
} catch (cause) {
if (target === key.value) {
conflict.value = cause instanceof ApiError && cause.status === 409
message?.error(errorMessage(cause))
}
} finally {
saving.value = false
savingKind.value = null
}
}
/** 免费核对完整草案的正式画面输入和本镜/邻镜版本。 */
async function loadPreview() {
if (!canSave.value || !savedMatches.value || !bounded.value || !draft.value) {
validation.value = '请先保存同一完整草案,并核对全部差异;越界变化不能联合采用。'
return
}
clearPreview()
const pending = new AbortController()
controller = pending
previewKind.value = 'input'
previewing.value = true
const target = key.value
try {
const result = await derivedReviewApi.preview(
props.shot.shotId,
JSON.parse(JSON.stringify(draft.value)),
providerInput.value ?? {},
pending.signal,
props.projectId
)
if (pending.signal.aborted || target !== key.value) return
if (
result?.shotId !== props.shot.shotId ||
result.productionReady !== false ||
!/^[a-f0-9]{64}$/.test(result.draftFingerprint) ||
!/^[a-f0-9]{64}$/.test(result.currentDerivedFingerprint ?? '') ||
!Array.isArray(result.adjacentDerivedVersions) ||
result.adjacentDerivedVersions.length > 2 ||
new Set(result.adjacentDerivedVersions.map(row => row.shotId)).size !==
result.adjacentDerivedVersions.length ||
result.adjacentDerivedVersions.some(row => !row.shotId || !/^[a-f0-9]{64}$/.test(row.derivedFingerprint))
)
throw new Error('草案预览缺少当前摄影或完整邻镜版本,不能联合采用。')
const rows = source.data.value?.rows ?? [],
index = rows.findIndex(shot => shot.shotId === props.shot.shotId)
const neighbors = [rows[index - 1]?.shotId, rows[index + 1]?.shotId].filter(
(shotId): shotId is string => !!shotId
)
if (
result.adjacentDerivedVersions.length !== neighbors.length ||
result.adjacentDerivedVersions.some(row => !neighbors.includes(row.shotId))
)
throw new Error('邻镜列表与当前正式顺序不一致,请重新读取完整来源。')
preview.value = result
} catch (cause) {
if (!pending.signal.aborted && target === key.value) message?.error(errorMessage(cause))
} finally {
if (controller === pending) {
previewing.value = false
previewKind.value = null
}
}
}
/** 免费预检完整采用条件,冻结同一保存版本、差异和邻镜,不写正式记录。 */
async function preflight() {
if (!environmentReady.value) {
validation.value = '请先读取本集完整原文并填写匹配的逐字片段,人工核对环境修改依据。'
return
}
if (
!preview.value ||
!savedMatches.value ||
!bounded.value ||
!reason.value.trim() ||
!reviewer.value.trim() ||
saving.value ||
previewing.value ||
conflict.value ||
props.disabled ||
!draft.value ||
!source.data.value
) {
validation.value = '请先核对已保存草案的画面输入,并填写审核人与联合修订依据。'
return
}
const shots: DerivedReviewSelection[] = [
{
...providerInput.value,
shotId: props.shot.shotId,
draft: JSON.parse(JSON.stringify(draft.value)),
expectedDraftFingerprint: preview.value.draftFingerprint,
expectedCurrentFormalSourceFingerprint: source.data.value.keyframe.formalSourceFingerprint,
jointRevision: {
expectedDraftRevision: saved.value!.revision,
expectedDerivedFingerprint: preview.value.currentDerivedFingerprint!,
expectedNeighbors: JSON.parse(JSON.stringify(preview.value.adjacentDerivedVersions)),
reason: reason.value.trim(),
...(hasEnvironmentChanges.value ? { environmentSource: { ...environmentEvidence.value! } } : {}),
changes: differences.value.map(item => item.change!)
}
}
]
const author = reviewer.value.trim()
const target = key.value
const pending = new AbortController()
controller = pending
previewKind.value = 'adoption'
previewing.value = true
checked.value = null
acknowledged.value = false
try {
const result = await derivedReviewApi.joint(
props.projectId,
{ preview: true, reviewer: author, shots },
pending.signal
)
if (pending.signal.aborted || target !== key.value) return
if (
result?.projectId !== props.projectId ||
!result.preview ||
!/^[a-f0-9]{64}$/.test(result.requestFingerprint) ||
!result.shots?.some(shot => shot.shotId === props.shot.shotId)
)
throw new Error('联合预检回执不完整,尚不能采用。')
checked.value = { reviewer: author, shots, result }
message?.success('联合采用免费预检通过,尚未正式采用')
} catch (cause) {
if (!pending.signal.aborted && target === key.value) {
conflict.value = cause instanceof ApiError && cause.status === 409
message?.error(errorMessage(cause))
if (conflict.value)
await Promise.all([
source.refresh(),
...(hasEnvironmentChanges.value ? [environmentSource.refresh()] : [])
])
}
} finally {
if (controller === pending) {
previewing.value = false
previewKind.value = null
}
}
}
/** 用户明确采用冻结请求;成功后仅刷新正式来源及原首帧预览。 */
async function adopt() {
if (!canAdopt.value || !checked.value) return
const frozen = checked.value
const projectId = props.projectId
const shotId = props.shot.shotId
const target = key.value
savingKind.value = 'adopt'
saving.value = true
try {
let result: JointDerivedReviewResult | undefined
const ok = await runOperation(projectId, '采用联合摄影与开拍状态', async () => {
result = await derivedReviewApi.joint(projectId, {
preview: false,
reviewer: frozen.reviewer,
shots: frozen.shots
})
if (
result?.projectId !== projectId ||
result.preview ||
!result.shots?.some(shot => shot.shotId === shotId) ||
!(result.changed || result.reused)
)
throw new Error('采用回执待核对,请先读取正式内容,不要重复提交。')
})
if (target !== key.value) return
if (!ok) {
const operation = getOperation(projectId)
conflict.value = true
clearPreview()
message?.error(operation.error)
await Promise.all([source.refresh(), ...(hasEnvironmentChanges.value ? [environmentSource.refresh()] : [])])
return
}
adopted.value = result!
clearPreview()
emit('changed')
message?.success('已正式采用联合修订,尚未生成图片或通过视觉审核')
await source.refresh()
try {
formalPreview.value = await productionApi.previewKeyframe(shotId, providerInput.value ?? {})
if (target !== key.value) formalPreview.value = null
} catch (cause) {
if (target === key.value) message?.warning('联合采用已完成,正式首帧预览尚未刷新:' + errorMessage(cause))
}
} finally {
saving.value = false
savingKind.value = null
}
}
/** 同一抽屉固定底栏复用当前模式操作。 */
defineExpose({ saving, savingKind, canSave, canAdopt, save, adopt })
</script>
<template>
<!-- 以下是联合模式的来源与已保存原稿,技术版本默认收起。 -->
<div class="workspace-section-stack">
<WorkspaceSectionHeading
title="摄影与开拍状态联合修订"
description="保留主体、形态与动作事实。环境变化需本集原文依据,保存与正式采用分别执行。"
/>
<NButton class="self-start" :disabled="saving" :loading="source.loading.value" @click="reload"
>重新读取正式来源与草案</NButton
>
<p v-if="source.loading.value" role="status">正在核对完整正式来源…</p>
<p v-if="source.error.value" role="alert">{{ source.error.value }}</p>
<p v-if="saved" class="text-sm">
已保存第 {{ saved.revision }} 版 ·
{{
saved.status === 'current'
? '来源当前有效'
: saved.staleReason
? userFacingText(saved.staleReason)
: '原草案来源已变化,请重新核对'
}}。保存记录不代表正式采用。
</p>
<p v-if="conflict" role="alert">
来源、草案或相邻镜头版本发生冲突。当前输入已保留,请重新读取并核对后再次免费预检。
</p>
<p v-if="adopted" role="status">
{{
adopted.reused ? '同一联合修订已采用,本次为幂等回读。' : '联合修订已正式采用。'
}}原草案和历史保留;图片生成、视觉审核及主图确认仍须分别操作。
</p>
<template v-if="draft && source.data.value">
<NButton class="self-start" :disabled="saving" @click="editFormal">从当前正式内容重新编辑</NButton>
<NCollapse
><NCollapseItem
name="formal"
:title="adopted ? '采用后:当前正式摄影与开拍状态' : '修改前:正式摄影与开拍状态'"
><ShotDesign :shot="source.data.value.shot"
/></NCollapseItem>
<NCollapseItem name="history" title="原草案与摄影历史"
><RawDataDetails
:value="{ 草案: saved, 原摄影原文: source.data.value.shot.direction?.rawJson }"
title="高级详情" /></NCollapseItem
></NCollapse>
<section class="workspace-section-stack">
<WorkspaceSectionHeading
:title="adopted ? '已采用的完整草案' : '修改后:待审完整草案'"
/><JointDraftFields v-model="draft" :disabled="saving || !!adopted" />
</section>
<!-- 以下是全部字段前后差异,越界项明确阻止联合采用。 -->
<section class="workspace-section-stack" aria-label="完整联合差异">
<WorkspaceSectionHeading :title="`完整字段差异(${differences.length} 项)`" />
<p v-if="boundaryNotice" class="text-sm" role="status">{{ boundaryNotice }}</p>
<p v-if="!differences.length" class="text-sm text-muted">与当前正式内容相同。</p>
<article v-for="(item, index) in differences" :key="index" class="space-y-2 text-sm">
<h4 class="font-medium">{{ item.label }}{{ item.allowed ? '' : ' · 不允许联合修改' }}</h4>
<p class="whitespace-pre-wrap wrap-anywhere">修改前:{{ item.before || '(空)' }}</p>
<p class="whitespace-pre-wrap wrap-anywhere">修改后:{{ item.after || '(空)' }}</p>
</article>
</section>
<!-- 以下是存在环境差异时的本集正式全文与人工证据,技术版本默认收起。 -->
<section v-if="hasEnvironmentChanges" class="workspace-section-stack" aria-label="本集原文依据">
<WorkspaceSectionHeading
title="本集原文依据"
description="原文及版本匹配不等于机器语义审核通过,请人工核对环境变化。"
/>
<NButton
class="self-start"
:disabled="saving"
:loading="environmentSource.loading.value"
@click="environmentSource.refresh"
>刷新本集原文</NButton
>
<p v-if="environmentSource.loading.value" class="text-sm" role="status">正在读取本集完整原文…</p>
<p v-if="environmentSource.error.value" class="text-sm" role="alert">
{{ environmentSource.error.value }}
</p>
<template v-if="environmentSource.data.value">
<NCollapse
><NCollapseItem
name="episode-original"
:title="`第 ${episodeNo} 集 · ${environmentSource.data.value.title} · 完整原文`"
>
<p class="text-sm whitespace-pre-wrap wrap-anywhere">
{{ environmentSource.data.value.content }}
</p>
</NCollapseItem></NCollapse
>
<RawDataDetails
:value="{
episodeId: environmentSource.data.value.episodeId,
expectedContentFingerprint: environmentSource.data.value.expectedContentFingerprint
}"
title="本集身份与正文版本"
/>
</template>
<label class="workspace-form-field"
><span>本集原文片段(逐字引用)</span>
<NInput
v-model:value="environmentQuote"
type="textarea"
:maxlength="4000"
:disabled="saving"
placeholder="从本集完整原文复制支持本次修改的片段"
aria-label="环境原文片段"
/>
</label>
<p
v-if="!environmentReady && !environmentSource.loading.value && !environmentSource.error.value"
class="text-sm text-muted"
>
填写匹配的本集片段后可免费预检。
</p>
</section>
<NButton
class="self-start"
:disabled="saving || !savedMatches || !bounded || !!adopted"
:loading="previewing && previewKind === 'input'"
@click="loadPreview"
>免费核对草案画面输入</NButton
>
<!-- 以下是邻镜正式版本及静态衔接依据,不当作真实视频末态。 -->
<section v-if="preview" class="workspace-section-stack" aria-label="联合相邻镜头依据">
<WorkspaceSectionHeading
title="相邻镜头依据"
description="下列是正式静态输入与版本,不能证明尚未验证的真实视频末态。"
/>
<p v-if="!preview.adjacentDerivedVersions?.length" class="text-sm">本镜没有同集紧邻镜头。</p>
<article
v-for="neighbor in preview.adjacentDerivedVersions"
:key="neighbor.shotId"
class="space-y-2 text-sm"
>
<p>
镜头 {{ props.shots.find(shot => shot.shotId === neighbor.shotId)?.beatNo ?? '待确认' }}.{{
props.shots.find(shot => shot.shotId === neighbor.shotId)?.shotNo ?? '待确认'
}}
</p>
<p class="whitespace-pre-wrap">
{{
source.data.value.rows.find(shot => shot.shotId === neighbor.shotId)?.visualState
?.continuityNote || '尚无已保存衔接说明。'
}}
</p>
<RawDataDetails :value="neighbor" title="相邻镜头版本详情" />
</article>
<ImageGenerationPreview
:preview="{ ...preview, previewFingerprint: preview.draftFingerprint }"
:loading="false"
error=""
stale-notice=""
display-only
/>
</section>
<label class="workspace-form-field"
><span>联合修订与剪辑依据</span
><NInput
v-model:value="reason"
type="textarea"
:maxlength="4000"
:disabled="saving"
aria-label="联合修订依据"
/></label>
<label class="workspace-form-field"
><span>审核人</span
><NInput v-model:value="reviewer" :maxlength="120" :disabled="saving" aria-label="联合审核人"
/></label>
<NButton
class="self-start"
:disabled="
!preview || !bounded || !savedMatches || !environmentReady || saving || conflict || !!adopted
"
:loading="previewing && previewKind === 'adoption'"
@click="preflight"
>免费预检联合采用</NButton
>
<NCheckbox v-if="checked" v-model:checked="acknowledged" :disabled="saving"
>我已核对全部差异、相邻镜头版本和剪辑依据,确认采用这份草案。</NCheckbox
>
<ImageGenerationPreview
v-if="formalPreview"
:preview="formalPreview"
:loading="false"
error=""
stale-notice=""
display-only
/>
</template>
<p v-if="validation" role="alert" class="text-sm">{{ validation }}</p>
</div>
</template>
@@ -1,4 +1,6 @@
<script setup lang="ts">
import VisualStateContinuity from './VisualStateContinuity.vue'
import JointDraftReviewPanel from './JointDraftReviewPanel.vue'
import DirectionCameraFields from './DirectionCameraFields.vue'
import DirectionStageReview from './DirectionStageReview.vue'
import { computed, onScopeDispose, ref, watch } from 'vue'
@@ -40,6 +42,10 @@ const props = defineProps<{
}>()
/** 采用后刷新现有分镜设计数据。 */
const emit = defineEmits<{ changed: [] }>()
/** 同一摄影抽屉内的联合模式,不创建第二个页面或弹层。 */
const jointMode = ref(false)
/** 联合模式底栏复用原抽屉。 */
const jointPanel = ref<InstanceType<typeof JointDraftReviewPanel> | null>(null)
/** 当前人工审核抽屉。 */
const open = ref(false)
/** 在同一摄影入口切换受控修订与场景沿用。 */
@@ -92,7 +98,7 @@ const saving = ref(false)
const message = useActionMessage()
/** 关闭或切换镜头后撤销旧读取。 */
const key = computed(() =>
open.value && !directionOnly.value ? JSON.stringify([props.projectId, props.shot.shotId]) : ''
open.value && !directionOnly.value && !jointMode.value ? JSON.stringify([props.projectId, props.shot.shotId]) : ''
)
/** 服务端草案单独读取,不阻塞外部草案的免费预览。 */
const savedDraft = useQuery(key, async (value, signal) => {
@@ -557,13 +563,29 @@ async function adopt() {
<NButton class="workspace-action-button" @click="open = true">摄影草案与审核</NButton>
<AppDrawer
v-model:open="open"
:busy="saving || savingDraft || directionEditor?.saving"
:busy="saving || savingDraft || directionEditor?.saving || jointPanel?.saving"
title="摄影草案与审核"
:description="`第 ${episodeNo} 集 · 镜头 ${shot.beatNo}.${shot.shotNo} · ${shot.title}`"
>
<!-- 以下是原审核入口内的模式切换,不改变原组合或独立摄影能力。 -->
<div v-if="formal" class="mb-5 flex flex-wrap gap-3">
<NButton :disabled="saving || savingDraft || jointPanel?.saving" @click="jointMode = !jointMode">{{
jointMode ? '返回原摄影修订' : '联合修订摄影与开拍状态'
}}</NButton>
</div>
<JointDraftReviewPanel
v-if="open && jointMode && formal"
ref="jointPanel"
:project-id="projectId"
:episode-no="episodeNo"
:shot="shot"
:shots="shots"
:disabled="disabled"
@changed="emit('changed')"
/>
<!-- 以下是画面状态生成之前的独立摄影阶段,原组合流程仍在同一抽屉。 -->
<DirectionStageReview
v-if="open && directionOnly"
v-else-if="open && directionOnly"
ref="directionEditor"
:project-id="projectId"
:episode-no="episodeNo"
@@ -822,9 +844,11 @@ async function adopt() {
</dl>
<NCollapse>
<NCollapseItem name="visual" title="场景与角色状态">
<p v-if="reviewed.selection.draft.visualState.continuityNote" class="mb-2">
{{ reviewed.selection.draft.visualState.continuityNote }}
</p>
<VisualStateContinuity
v-if="reviewed.selection.draft.visualState.continuityNote"
:note="reviewed.selection.draft.visualState.continuityNote"
class="mb-2"
/>
<ul class="space-y-2">
<li
v-for="subject in reviewed.selection.draft.visualState.subjects"
@@ -874,9 +898,28 @@ async function adopt() {
</section>
</div>
<template #footer>
<NButton :disabled="saving || savingDraft || directionEditor?.saving" @click="open = false">关闭</NButton>
<NButton
v-if="directionOnly"
:disabled="saving || savingDraft || directionEditor?.saving || jointPanel?.saving"
@click="open = false"
>关闭</NButton
>
<NButton
v-if="jointMode"
:disabled="!jointPanel?.canSave"
:loading="jointPanel?.savingKind === 'save'"
@click="jointPanel?.save"
>保存联合草案</NButton
>
<NButton
v-if="jointMode"
type="primary"
:disabled="!jointPanel?.canAdopt"
:loading="jointPanel?.savingKind === 'adopt'"
@click="jointPanel?.adopt"
>正式采用联合修订</NButton
>
<NButton
v-if="directionOnly && !jointMode"
type="primary"
:disabled="!directionEditor?.canAdopt"
:loading="directionEditor?.saving"
@@ -884,7 +927,7 @@ async function adopt() {
>正式采用摄影修改</NButton
>
<NButton
v-if="!directionOnly && !useSaved"
v-if="!jointMode && !directionOnly && !useSaved"
:loading="savingDraft"
:disabled="
disabled ||
@@ -899,7 +942,7 @@ async function adopt() {
>保存草案</NButton
>
<NButton
v-if="!directionOnly && reviewed"
v-if="!jointMode && !directionOnly && reviewed"
type="primary"
:loading="saving"
:disabled="disabled || !acknowledged || !reviewer.trim() || !preflight.data.value?.current.valid"
@@ -1,15 +1,16 @@
<script setup lang="ts">
import VisualStateContinuity from './VisualStateContinuity.vue'
import { WorkspaceSectionHeading } from '../../../components/ui'
import { NTag } from 'naive-ui'
import { NCollapse, NCollapseItem, NTag } from 'naive-ui'
import { directionLabel } from '../model'
import type { DesignedShot } from '../types'
/** 正式镜头设计的只读检查;内容编辑尚无后端写接口。 */
/** 正式摄影与当前开拍状态只读展示,编辑沿原草案采用流程。 */
defineProps<{ shot: DesignedShot }>()
</script>
<template>
<div class="workspace-section-stack workspace-section-stack-spacious">
<div :key="shot.shotId" class="workspace-section-stack workspace-section-stack-spacious">
<section>
<!-- 以下是统一的导演设计模块标题 -->
<WorkspaceSectionHeading title="导演摄影设计" />
@@ -30,19 +31,26 @@ defineProps<{ shot: DesignedShot }>()
>
</div>
<dl class="detail-grid">
<dt>构图</dt>
<dd>{{ shot.direction.composition }}</dd>
<dt>机位</dt>
<dd>{{ shot.direction.cameraPosition }}</dd>
<dt>视觉意图</dt>
<dd>{{ shot.direction.visualIntent }}</dd>
</dl></template
</dl>
<!-- 以下是按需展开的完整摄影原文,不裁剪或改写创作内容。 -->
<NCollapse class="mt-4">
<NCollapseItem name="camera-detail" title="构图与机位">
<dl class="detail-grid">
<dt>构图</dt>
<dd class="whitespace-pre-wrap wrap-anywhere">{{ shot.direction.composition }}</dd>
<dt>机位</dt>
<dd class="whitespace-pre-wrap wrap-anywhere">{{ shot.direction.cameraPosition }}</dd>
</dl>
</NCollapseItem>
</NCollapse></template
>
<p v-else class="mt-4 text-sm text-muted">此镜头尚无已保存的导演设计。</p>
</section>
<section>
<!-- 以下是统一的画面状态模块标题 -->
<WorkspaceSectionHeading title="画面状态" />
<WorkspaceSectionHeading title="画面状态 · 开拍0秒" />
<template v-if="shot.visualState"
><dl class="detail-grid mt-4">
<dt>时间</dt>
@@ -53,35 +61,46 @@ defineProps<{ shot: DesignedShot }>()
<dd>{{ shot.visualState.atmosphere || '未指定' }}</dd>
<dt>环境变化</dt>
<dd>{{ shot.visualState.environmentTransientState || '无临时变化' }}</dd>
<dt>连续性</dt>
<dd>{{ shot.visualState.continuityNote || '未附说明' }}</dd>
</dl>
<article
v-for="subject in shot.visualState.subjects"
:key="subject.subjectId"
class="mt-5 surface-inset p-4"
>
<div class="mb-3 flex flex-wrap items-center gap-2">
<code class="subject-ref">{{ subject.subjectRef }}</code
><span class="text-xs font-medium">{{ subject.formName }}</span>
</div>
<dl class="detail-grid">
<template
v-for="field in [
{ key: 'expression', label: '表情' },
{ key: 'pose', label: '姿态' },
{ key: 'gaze', label: '视线' },
{ key: 'position', label: '位置' },
{ key: 'transientState', label: '临时变化' }
] as const"
:key="field.key"
><dt>{{ field.label }}</dt>
<dd>{{ subject[field.key] || '不适用 / 未指定' }}</dd></template
<!-- 以下是完整连续依据与主体状态,普通浏览默认收起。 -->
<NCollapse class="mt-4">
<NCollapseItem name="continuity" title="衔接与时间依据">
<VisualStateContinuity
v-if="shot.visualState.continuityNote"
:note="shot.visualState.continuityNote"
/><span v-else>未附说明;真实视频末态仍待独立证据验证。</span>
</NCollapseItem>
<NCollapseItem name="subjects" :title="`主体开拍状态(${shot.visualState.subjects.length})`">
<article
v-for="subject in shot.visualState.subjects"
:key="subject.subjectId"
class="mb-5 last:mb-0"
>
</dl>
</article></template
<div class="mb-3 flex flex-wrap items-center gap-2">
<code class="subject-ref">{{ subject.subjectRef }}</code
><span class="text-xs font-medium">{{ subject.formName }}</span>
</div>
<dl class="detail-grid">
<template
v-for="field in [
{ key: 'expression', label: '表情' },
{ key: 'pose', label: '姿态' },
{ key: 'gaze', label: '视线' },
{ key: 'position', label: '位置' },
{ key: 'transientState', label: '临时变化' }
] as const"
:key="field.key"
><dt>{{ field.label }}</dt>
<dd>{{ subject[field.key] || '不适用 / 未指定' }}</dd></template
>
</dl>
</article>
</NCollapseItem>
</NCollapse></template
>
<p v-else class="mt-4 text-sm leading-6 text-muted">此镜头还没有画面状态,请先完成镜头设计。</p>
<p v-else class="mt-4 text-sm leading-6 text-muted">
此镜头尚无画面状态。请在“生成与恢复”中核对本次摄影范围后补齐。
</p>
</section>
</div>
</template>
@@ -123,7 +123,7 @@ function referenceAt(index: number) {
></template
>
</WorkspaceSectionHeading>
<p v-if="!shots.length" class="text-xs text-muted">请先在镜头目录勾选要核对的镜头。</p>
<p v-if="!shots.length" class="text-xs text-muted">请先展开“选择镜头”勾选本次范围。</p>
<p v-if="query.loading.value" role="status" class="text-xs text-muted">
正在读取正式生产计划和所选镜头参考素材…
</p>
@@ -0,0 +1,18 @@
<script setup lang="ts">
import { computed } from 'vue'
import { visualStateTimeSections } from '../visual-state-time'
/** 共用原衔接文字的时间语义展示,不新增时间轴或质量规则。 */
const props = defineProps<{ /** 后端完整原文字。 */ note: string }>()
/** 原契约明确分段才分类,历史原文不推定开拍或视频末态。 */
const sections = computed(() => visualStateTimeSections(props.note))
</script>
<template>
<!-- 以下是开拍输入、规划末态、连续要求与视频末态的独立说明。 -->
<div class="space-y-3 text-sm">
<section v-for="(section, index) in sections" :key="index" class="space-y-1">
<p class="font-medium">{{ section.title }}</p>
<p class="whitespace-pre-wrap wrap-anywhere">{{ section.text || '未提供文字依据。' }}</p>
</section>
<p class="text-xs text-muted">规划结束状态和相邻静态输入不代表已验证的真实视频末态。</p>
</div>
</template>
@@ -1,6 +1,7 @@
import { keyframeScope } from '../production/keyframe-scope'
import { request } from '../../lib/http'
import type {
JointDerivedReviewResult,
DirectionReviewInput,
DirectionReviewResult,
DerivedReviewSelection,
@@ -13,6 +14,22 @@ import type {
/** 已审摄影草案的正式读写入口。 */
export const derivedReviewApi = {
/**
* 使用原confirm接口免费预检或采用同一完整联合草案。
* @param projectId 正式项目
* @param body 冻结的审核人、已保存草案和完整差异
* @param signal 取消只读预检
* @returns 整批采用或幂等回执
*/
joint: (
projectId: string,
body: { reviewer: string; shots: DerivedReviewSelection[]; preview: boolean },
signal?: AbortSignal
) =>
request<JointDerivedReviewResult>(
`/projects/${encodeURIComponent(projectId)}/storyboard-derived-reviews/confirm`,
{ method: 'POST', body, signal }
),
/**
* 沿原采用接口免费预检或采用独立摄影,不生成画面状态。
* @param projectId 正式项目
@@ -61,6 +61,11 @@ export type DraftProviderInput = Pick<GenerateKeyframeInput, 'provider' | 'width
/** 草案只有草案指纹,不能提交正式生图。 */
export interface ShotDraftPreview extends Omit<KeyframeGenerationPreview, 'previewFingerprint'> {
/** 本镜完整摄影和开拍状态的版本。 */ currentDerivedFingerprint?: string
/** 正式同集紧邻镜头的完整版本,原样用于联合采用。 */ adjacentDerivedVersions?: Array<{
/** 正式镜头。 */ shotId: string
/** 完整派生版本。 */ derivedFingerprint: string
}>
/** 本次草案的确切输入版本。 */ draftFingerprint: string
/** 草案始终不能直接生成。 */ productionReady: false
/** 项目级制作门禁。 */
@@ -70,6 +75,7 @@ export interface ShotDraftPreview extends Omit<KeyframeGenerationPreview, 'previ
/** 每次人工采用一个或多个已预览镜头。 */
export interface DerivedReviewSelection extends DraftProviderInput {
/** 仅未生产镜头使用的有界联合采用,不能混入其它修订模式。 */ jointRevision?: JointDerivedRevision
/** 正式镜头编号。 */ shotId: string
/** 用户核对过的草案。 */ draft: ShotReviewDraft
/** 对应的免费预览指纹。 */ expectedDraftFingerprint: string
@@ -132,3 +138,60 @@ export interface DirectionReviewResult {
/** 是否已经采用相同草案。 */ alreadyApplied: boolean
}>
}
/** 联合采用逐字段声明,环境修改另需本集原文,主体身份及形态仍不可编辑。 */
export type JointDerivedChange =
| {
/** 摄影意图。 */ target: 'direction'
/** 正式允许字段。 */ field: 'composition' | 'cameraPosition' | 'visualIntent'
/** 正式原值。 */ before: string
/** 草案目标值。 */ after: string
}
| {
/** 本镜0秒环境。 */ target: 'environment'
/** 正式允许的四项环境字段。 */ field: 'timeOfDay' | 'weather' | 'atmosphere' | 'transientState'
/** 正式原值,未知可为空。 */ before: string
/** 草案目标值,不猜测未知天气。 */ after: string
}
| {
/** 衔接文字。 */ target: 'visualState'
/** 正式允许字段。 */ field: 'continuityNote'
/** 正式原值。 */ before: string
/** 草案目标值。 */ after: string
}
| {
/** 主体0秒状态。 */ target: 'subject'
/** 正式主体。 */ subjectRef: string
/** 正式允许字段。 */ field: 'expression' | 'pose' | 'gaze' | 'position' | 'transientState'
/** 正式原值。 */ before: string
/** 草案目标值。 */ after: string
}
/** 联合采用绑定已保存草案、当前派生与完整邻镜版本。 */
export interface JointDerivedRevision {
/** 仅存在环境差异时提供,由正式项目详情的本集全文及人工片段形成。 */
environmentSource?: {
/** 当前正式集ID,采用事务最终核对Storyboard外键。 */ episodeId: string
/** 本集完整content原字节SHA256,不使用摘要或截取正文。 */ expectedContentFingerprint: string
/** 人工选择的本集逐字片段。 */ quote: string
}
/** 已保存草案修订。 */ expectedDraftRevision: number
/** 当前摄影及画面状态版本。 */ expectedDerivedFingerprint: string
/** 完整同集紧邻镜头版本。 */ expectedNeighbors: NonNullable<ShotDraftPreview['adjacentDerivedVersions']>
/** 用户确认的修订与剪辑依据。 */ reason: string
/** 全部允许差异,不得漏报或重复。 */ changes: JointDerivedChange[]
}
/** 联合采用的同步事务回执,不代表生图或质量通过。 */
export interface JointDerivedReviewResult {
/** 正式项目。 */ projectId: string
/** 是否只读预检。 */ preview: boolean
/** 是否真实写入。 */ changed: boolean
/** 是否复用同一已采用请求。 */ reused: boolean
/** 本次完整请求版本。 */ requestFingerprint: string
/** 整批返回的正式归属。 */ shots: Array<{
/** 正式镜头。 */ shotId: string
/** 摄影记录。 */ directionId: string
/** 画面状态记录。 */ visualStateId: string
}>
}
+171
View File
@@ -0,0 +1,171 @@
import type { JointDerivedChange, ShotReviewDraft } from './derived-review.types'
/** 完整差异展示包含不可修改项,不能只列允许字段而隐藏越界变化。 */
export interface JointDraftDifference {
/** 中文字段或主体位置。 */ label: string
/** 修改前原文。 */ before: string
/** 修改后原文。 */ after: string
/** 是否属于正式联合采用白名单。 */ allowed: boolean
/** 可提交的差异,越界项不构造请求。 */ change?: JointDerivedChange
}
/** 摄影、主体和时间状态共用的中文字段名。 */
export const jointFieldLabels: Record<string, string> = {
composition: '构图',
cameraPosition: '摄影机位置',
visualIntent: '摄影意图',
continuityNote: '衔接与时间依据',
expression: '表情',
pose: '姿态',
gaze: '视线',
position: '位置',
transientState: '即时变化',
formId: '形态身份',
formName: '形态名称',
shotNo: '镜头编号',
timeOfDay: '时间',
weather: '天气',
atmosphere: '氛围',
shotSize: '景别',
cameraAngle: '摄影角度',
cameraMovement: '运镜',
lensIntent: '焦段',
depthOfField: '景深'
}
/**
* 稳定比较完整JSON草案,属性顺序不构成修改。
* @param value 真实字段值
* @returns 可比较的稳定原文
*/
export function jointValue(value: unknown): string {
if (typeof value === 'string') return JSON.stringify(value)
if (value === undefined) return '(字段缺失)'
if (value && typeof value === 'object' && !Array.isArray(value))
return JSON.stringify(
Object.fromEntries(
Object.entries(value)
.toSorted(([a], [b]) => a.localeCompare(b))
.map(([key, item]) => [key, jointValue(item)])
)
)
if (Array.isArray(value)) return JSON.stringify(value.map(jointValue))
return JSON.stringify(value)
}
/**
* 比对完整正式内容与待审草案,允许差异与越界差异都完整展示。
* @param formal 当前正式摄影和0秒状态
* @param draft 用户完整待审草案
* @returns 全部逐字段差异,不能从中悄悄删除越界项后采用
*/
export function jointDraftDifferences(formal: ShotReviewDraft, draft: ShotReviewDraft): JointDraftDifference[] {
const differences: JointDraftDifference[] = []
/**
* 比对真实值,只为正式允许的字符串字段形成差异声明。
* @param label 中文字段名
* @param before 正式原值
* @param after 完整草案值
* @param change 允许字段的正式差异
*/
function compare(label: string, before: unknown, after: unknown, change?: JointDerivedChange) {
if (jointValue(before) === jointValue(after)) return
differences.push({
label,
before: typeof before === 'string' ? before : jointValue(before),
after: typeof after === 'string' ? after : jointValue(after),
allowed: !!change,
change
})
}
for (const field of new Set([...Object.keys(formal.direction), ...Object.keys(draft.direction)])) {
const key = field as keyof typeof formal.direction
const before = formal.direction[key],
after = draft.direction[key]
const allowed =
['composition', 'cameraPosition', 'visualIntent'].includes(field) &&
typeof before === 'string' &&
typeof after === 'string'
compare(
`摄影 · ${jointFieldLabels[field] ?? field}`,
before,
after,
allowed
? {
target: 'direction',
field: field as 'composition' | 'cameraPosition' | 'visualIntent',
before: before as string,
after: after as string
}
: undefined
)
}
compare('画面状态 · 镜头编号', formal.visualState.shotNo, draft.visualState.shotNo)
compare('画面状态 · 衔接与时间依据', formal.visualState.continuityNote, draft.visualState.continuityNote, {
target: 'visualState',
field: 'continuityNote',
before: formal.visualState.continuityNote,
after: draft.visualState.continuityNote
})
for (const field of new Set([
...Object.keys(formal.visualState.environment),
...Object.keys(draft.visualState.environment)
])) {
const key = field as keyof typeof formal.visualState.environment
const before = formal.visualState.environment[key],
after = draft.visualState.environment[key]
const allowed =
['timeOfDay', 'weather', 'atmosphere', 'transientState'].includes(field) &&
typeof before === 'string' &&
typeof after === 'string'
compare(
`环境 · ${jointFieldLabels[field] ?? field}`,
before,
after,
allowed ? { target: 'environment', field: key, before, after } : undefined
)
}
const previous = new Map(formal.visualState.subjects.map(subject => [subject.subjectRef, subject]))
const next = new Map(draft.visualState.subjects.map(subject => [subject.subjectRef, subject]))
if (previous.size !== formal.visualState.subjects.length || next.size !== draft.visualState.subjects.length)
compare('主体重复或集合异常', formal.visualState.subjects, draft.visualState.subjects)
for (const subjectRef of new Set([...previous.keys(), ...next.keys()])) {
const before = previous.get(subjectRef),
after = next.get(subjectRef)
if (!before || !after) {
compare(`${subjectRef} · 主体集合`, before, after)
continue
}
for (const field of new Set([...Object.keys(before), ...Object.keys(after)])) {
const key = field as keyof typeof before
const allowed =
['expression', 'pose', 'gaze', 'position', 'transientState'].includes(field) &&
typeof before[key] === 'string' &&
typeof after[key] === 'string'
compare(
`${subjectRef} · ${jointFieldLabels[field] ?? field}`,
before[key],
after[key],
allowed
? {
target: 'subject',
subjectRef,
field: field as 'expression' | 'pose' | 'gaze' | 'position' | 'transientState',
before: before[key],
after: after[key]
}
: undefined
)
}
}
for (const field of new Set([...Object.keys(formal), ...Object.keys(draft)])) {
if (['direction', 'visualState'].includes(field)) continue
compare(
field === 'expectedShotFingerprint'
? '正式分镜版本'
: field === 'sceneSources'
? '场景参考与几何版本'
: '修订模式',
formal[field as keyof ShotReviewDraft],
draft[field as keyof ShotReviewDraft]
)
}
return differences
}
+3
View File
@@ -75,6 +75,9 @@ export interface EpisodeVisualStates {
/** 导演设计与视觉状态统一呈现的校验问题。 */
export interface StoryboardIssue {
/** 原时间或其它结构化问题码,不改变业务判断。 */ code?: string
/** 确定性冲突与人工待审分别展示。 */ severity?: 'error' | 'needs_review'
/** 原问题字段用于定位。 */ field?: string
episodeNo: number
beatNo: number | null
shotNo: number | null
@@ -0,0 +1,45 @@
/** 统一时间契约的展示分段,不能作为模型结果有效性的判断。 */
export interface VisualStateTimeSection {
/** 后端明确提供的分类。 */ kind: 'input' | 'planned' | 'continuity' | 'video' | 'legacy'
/** 普通用户可读标题。 */ title: string
/** 原文字内容,不翻译或改写。 */ text: string
}
/**
* 只按正式四种显式标记排版,旧文字保持原样,不按动作关键词推断时间或审核结果。
* @param note 原continuityNote
* @returns 可展示的完整原文分段
*/
export function visualStateTimeSections(note: string): VisualStateTimeSection[] {
const markers = [...note.matchAll(/【(输入事实|规划末态|连续要求|视频末态)】/g)]
if (!markers.length) return [{ kind: 'legacy', title: '原衔接说明(未分段)', text: note }]
const kinds = { 输入事实: 'input', 规划末态: 'planned', 连续要求: 'continuity', 视频末态: 'video' } as const
const titles = {
输入事实: '已确认的输入事实',
规划末态: '规划中的镜头结束状态',
连续要求: '相邻镜头连续性要求',
视频末态: '视频末态声明(仍需真实视频证据核验)'
}
const sections: VisualStateTimeSection[] = []
const prefix = note.slice(0, markers[0]!.index).trim()
if (prefix) sections.push({ kind: 'legacy', title: '原补充说明', text: prefix })
markers.forEach((marker, index) => {
const name = marker[1] as keyof typeof kinds
sections.push({
kind: kinds[name],
title: titles[name],
text: note.slice(marker.index! + marker[0].length, markers[index + 1]?.index ?? note.length).trim()
})
})
return sections
}
/**
* 仅使用后端问题码与severity命名,保留原消息和定位,不自行判定质量。
* @param issue 原问题
* @returns 时间问题标题或空值
*/
export function visualStateTimeIssueLabel(issue: { code?: string; severity?: string }) {
if (issue.code === 'VISUAL_STATE_START_CONFLICT') return '开拍状态冲突'
if (issue.code === 'VISUAL_STATE_TIME_NEEDS_REVIEW') return '时间语义待人工核对'
if (issue.code === 'VISUAL_STATE_VIDEO_END_UNSUPPORTED') return '真实视频末态缺少证据'
return issue.severity === 'needs_review' ? '需要人工核对' : ''
}
@@ -101,6 +101,10 @@ interface PreviewOptions<Input extends object, Preview extends ImageGenerationPr
/** 当前正式目标。 */ targetId: string
/** 免费路由是否完整覆盖当前输入。 */ exactPreview: boolean
}
/** 用户主动选中的人工追加许可,仅首帧可用。 */
additionalAuthorizationId?: () => string | undefined
/** 已有完整同计划候选时只读查看,不能新增请求。 */
reuseResult?: (preview: Preview) => Promise<boolean>
/** 当前完整生成参数。 */
input: () => Input
/** 当前是否允许提交。 */
@@ -139,6 +143,8 @@ export function useImageGenerationPreview<Input extends object, Preview extends
const requiresCostConfirmation = computed(
() => preview.value?.provider !== 'openai-image' || !options.chargeContext
)
/** 只有正式费用计划证明完整回执可复用时才允许只读查看。 */
const reusableResult = computed(() => charge.value?.reusable === true && !!options.reuseResult)
/** 授权与未知费用显示在当前生成入口。 */
const chargeNotice = computed(() => charge.value?.message ?? '')
/** 输入快照同时绑定界面目标和显隐周期。 */
@@ -160,7 +166,7 @@ export function useImageGenerationPreview<Input extends object, Preview extends
!options.disabled() &&
!submitting.value &&
!loading.value &&
!recoveryNotice.value &&
(!recoveryNotice.value || reusableResult.value) &&
!!preview.value &&
(requiresCostConfirmation.value ? acknowledged.value : charge.value?.allowed === true)
)
@@ -212,7 +218,7 @@ export function useImageGenerationPreview<Input extends object, Preview extends
const context = options.chargeContext?.()
if (result.provider === 'openai-image' && context) {
const values = input as Record<string, unknown>
let list, planFingerprint: string | undefined
let list, planFingerprint: string | undefined, sourceFingerprint: string | undefined
if (context.exactPreview && ['identity', 'form', 'keyframe'].includes(context.scope)) {
const plan = await imageAuthorizationApi.preview(
context.projectId,
@@ -238,6 +244,7 @@ export function useImageGenerationPreview<Input extends object, Preview extends
throw new Error('授权计划与当前预览不匹配,请重新读取。')
list = plan.authorization
planFingerprint = plan.planFingerprint
sourceFingerprint = plan.context.sourceFingerprint
} else list = await imageAuthorizationApi.list(context.projectId, abort.signal)
if (current !== revision || abort.signal.aborted) return
charge.value = imageChargeEligibility(
@@ -245,7 +252,14 @@ export function useImageGenerationPreview<Input extends object, Preview extends
context.scope,
context.targetId,
result.model,
planFingerprint
planFingerprint,
options.additionalAuthorizationId?.()
? {
id: options.additionalAuthorizationId()!,
sourceFingerprint: sourceFingerprint ?? '',
projectId: context.projectId
}
: undefined
)
}
preview.value = result
@@ -259,6 +273,18 @@ export function useImageGenerationPreview<Input extends object, Preview extends
/** 明确提交一次;预览过期只重读预览,绝不自动重新生成。 */
async function submit() {
if (!canSubmit.value || !preview.value) return
if (reusableResult.value && options.reuseResult) {
submitting.value = true
try {
if (await options.reuseResult(preview.value)) options.open.value = false
else error.value = '当前候选列表还未核对到原完整结果,请刷新候选后查看;不会重新收费。'
} catch (cause) {
error.value = errorMessage(cause)
} finally {
submitting.value = false
}
return
}
const current = revision
const input = JSON.parse(JSON.stringify(options.input())) as Input
const fingerprint = preview.value.previewFingerprint
@@ -313,6 +339,7 @@ export function useImageGenerationPreview<Input extends object, Preview extends
preview,
requiresCostConfirmation,
chargeNotice,
reusableResult,
acknowledged,
loading,
submitting,
@@ -1,4 +1,5 @@
<script setup lang="ts">
import { visualStateTimeIssueLabel } from '../storyboard/visual-state-time'
import WorkspaceActionTooltip from '../../components/ui/WorkspaceActionTooltip.vue'
import ConfirmAction from './ConfirmAction.vue'
import { useQuery } from '../../composables/useQuery'
@@ -112,6 +113,9 @@ const derivedEpisodes = computed(() => {
(
issue
): issue is {
code?: string
severity?: 'error' | 'needs_review'
field?: string
episodeNo: number
beatNo: number | null
shotNo: number | null
@@ -639,7 +643,9 @@ function isInputMode(value: unknown, inputMode: string): boolean {
: '状态待确认'
}}<span v-if="item.error">:{{ derivedErrorSummary(item.error) }}</span>
<p v-for="(issue, index) in item.issues" :key="index" class="mt-1">
段落 {{ issue.beatNo ?? '待确认' }} · 镜头 {{ issue.shotNo ?? '待确认' }}:{{
<span v-if="visualStateTimeIssueLabel(issue)"
>{{ visualStateTimeIssueLabel(issue) }} · </span
>段落 {{ issue.beatNo ?? '待确认' }} · 镜头 {{ issue.shotNo ?? '待确认' }}:{{
userFacingText(issue.message)
}}
</p>