feat(shipping-notice): 收敛复核阶段同源投影与 OT 后履约推进

统一 Case/Progress 阶段 label_key、修复 Job 成功未推进 OT 的可重试失败投影与写路径,并落地 OT 后行级匹配/波次履约与版面诊断开关。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-07 13:11:14 +08:00
1 parent 74270adc22
commit fd6a23f870
100 files changed
+12138 -1017

No files matched your search

@@ -0,0 +1,155 @@
<!--
features/chat/components/shipping-review/ReviewCurrentProcessingCard.vue
用途:正式 OT 创建后的右侧「当前处理状态」主卡(阶段 + 自动推进合并)。
依赖:vue-i18n、ShippingOrderReviewAutomation、resolveShippingProcessingStageLabel。
逻辑:优先消费 Progress 同源的 stageCode + stageLabelKey;Case current_stage 仅降级;
禁止把阶段码直接当用户文案;Job 明细与 task_missing 诊断仅管理员区;
由 ShippingOrderReviewView 在 has_formal_ot / task_missing 时置顶渲染。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewAutomation } from '@/features/chat/types/shipping.api.types';
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
const props = defineProps<{
stageCode?: string | null;
stageLabelKey?: string | null;
stageInconsistent?: boolean;
taskMissing?: boolean;
taskNo?: string | null;
confirmedTaskId?: number | null;
showAdminDiagnosis?: boolean;
automation?: ShippingOrderReviewAutomation | null;
showRetry?: boolean;
retrying?: boolean;
}>();
const emit = defineEmits<{
retry: [];
}>();
const { t, te } = useI18n();
/**
* 当前处理阶段展示文案:消费 label_key,禁止直接展示阶段码。
*/
const stageLabel = computed(() => {
if (props.taskMissing) {
return t('chat.shippingOrderReview.currentProcessing.taskMissing');
}
if (props.stageInconsistent) {
return t('chat.shippingOrderReview.currentProcessing.stateInconsistent');
}
return resolveShippingProcessingStageLabel(
String(props.stageCode || ''),
te,
t,
props.stageLabelKey,
);
});
/**
* 自动推进用户态文案(消费 phase,禁止前端猜建单/推进)。
*/
const statusLabel = computed(() => {
const automation = props.automation;
const status = String(automation?.status || '').trim().toLowerCase();
const phase = String(automation?.phase || '').trim();
if (props.taskMissing) {
return t('chat.shippingOrderReview.currentProcessing.statusTaskMissing');
}
if (status === 'waiting_to_start') {
return phase === 'pre_ot_stp'
? t('chat.shippingOrderReview.automation.waitingPreOt')
: t('chat.shippingOrderReview.automation.waitingPostOt');
}
if (status === 'queued' || status === 'running') {
return t('chat.shippingOrderReview.currentProcessing.statusRunning');
}
if (status === 'failed' || status === 'manual_fallback') {
return t('chat.shippingOrderReview.currentProcessing.statusFailedRetryable');
}
if (status === 'completed') {
return t('chat.shippingOrderReview.currentProcessing.statusCompleted');
}
return t('chat.shippingOrderReview.currentProcessing.statusIdle');
});
/**
* 主卡重试:仅在有 task_no 且非 task_missing 时由父组件控制 showRetry。
*/
const canShowRetry = computed(() => (
Boolean(props.showRetry)
&& !props.taskMissing
&& Boolean(String(props.taskNo || '').trim())
));
</script>
<template>
<section
class="rounded-xl border border-sky-200 bg-sky-50/80 p-3 shadow-sm dark:border-sky-900 dark:bg-sky-950/30"
data-testid="review-current-processing-card"
:data-task-missing="taskMissing ? '1' : '0'"
:data-automation-status="String(automation?.status || '')"
:data-automation-phase="String(automation?.phase || '')"
>
<header class="mb-2">
<h2 class="text-sm font-semibold text-sky-950 dark:text-sky-100">
{{ t('chat.shippingOrderReview.currentProcessing.title') }}
</h2>
<p class="mt-0.5 text-xs text-sky-900/80 dark:text-sky-200/80">
{{ stageLabel }}
</p>
</header>
<dl class="space-y-1 text-xs text-sky-950 dark:text-sky-100">
<div class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentProcessing.status') }}</dt>
<dd data-testid="review-current-processing-status">{{ statusLabel }}</dd>
</div>
<div v-if="taskNo" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentProcessing.formalOt') }}</dt>
<dd class="font-mono" data-testid="review-current-processing-ot">{{ taskNo }}</dd>
</div>
</dl>
<p
v-if="taskMissing"
class="mt-2 text-[11px] text-rose-800 dark:text-rose-200"
data-testid="review-current-processing-task-missing"
>
{{ t('chat.shippingOrderReview.currentProcessing.taskMissingHint') }}
</p>
<aside
v-if="taskMissing && showAdminDiagnosis"
class="mt-2 rounded border border-rose-300 bg-rose-50/80 p-2 text-[11px] text-rose-950 dark:border-rose-800 dark:bg-rose-950/40 dark:text-rose-100"
data-testid="review-current-processing-admin-diagnosis"
>
<p class="font-medium">{{ t('chat.shippingOrderReview.currentProcessing.adminDiagnosisTitle') }}</p>
<p v-if="confirmedTaskId != null" class="mt-1 font-mono">
{{ t('chat.shippingOrderReview.currentProcessing.confirmedTaskId', { id: confirmedTaskId }) }}
</p>
<p class="mt-1">
{{ t('chat.shippingOrderReview.currentProcessing.adminDiagnosisStatus') }}
</p>
<p class="mt-1 text-muted">
{{ t('chat.shippingOrderReview.currentProcessing.adminDiagnosisHint') }}
</p>
</aside>
<button
v-if="canShowRetry"
type="button"
class="mt-3 inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-2.5 py-1.5 text-xs text-amber-950 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
data-testid="review-current-processing-retry"
:disabled="retrying"
@click="emit('retry')"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ t('chat.shippingOrderReview.autoProgress.retryStp') }}
</button>
</section>
</template>