Files
syops/frontend/src/features/chat/components/shipping-review/ReviewAutomationStatusPanel.vue
T

108 lines
3.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!--
features/chat/components/shipping-review/ReviewAutomationStatusPanel.vue
用途:复核工作台「自动处理状态」只读区(技术 Gate 进度,禁止业务用户点技术重试)。
依赖:vue-i18n、ShippingProcessGateUserSummary。
逻辑:仅在任务已创建后展示 gates_track;按 sequence_no 排序,并在首个未完成阶段后
抑制矛盾的下游“已通过”,不提供技术写操作。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingProcessGateUserSummary } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
processGate: ShippingProcessGateUserSummary | null | undefined;
taskCreated?: boolean;
}>();
const { t, te } = useI18n();
const track = computed(() => {
if (!props.taskCreated) return [];
const ordered = [...(props.processGate?.gates_track || [])]
.sort((left, right) => Number(left.sequence_no || 0) - Number(right.sequence_no || 0));
let upstreamReached = true;
return ordered.map((item) => {
const status = String(item.status || 'not_started');
const normalizedStatus = upstreamReached ? status : 'not_started';
if (!['passed', 'skipped'].includes(status)) upstreamReached = false;
return { ...item, status: normalizedStatus };
});
});
const visible = computed(() => track.value.length > 0);
const technicalOnly = computed(() => Boolean(
(props.processGate as { technical_auto_only?: boolean } | null | undefined)?.technical_auto_only,
));
/**
* Gate 状态本地化标签。
*/
function statusLabel(status: string): string {
const key = `chat.shippingOrderReview.automationStatus.statuses.${status}`;
return te(key) ? t(key) : status;
}
/**
* 状态点样式。
*/
function statusClass(status: string): string {
const s = String(status || '');
if (s === 'passed' || s === 'skipped') {
return 'bg-emerald-500';
}
if (s === 'running' || s === 'queued') {
return 'bg-sky-500 animate-pulse';
}
if (s === 'blocked_manual' || s === 'blocked_retryable' || s === 'waiting_external') {
return 'bg-amber-500';
}
if (s === 'failed_terminal') {
return 'bg-rose-500';
}
return 'bg-slate-300 dark:bg-slate-600';
}
</script>
<template>
<section
v-if="visible"
class="rounded-xl border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-800 dark:bg-slate-900"
data-testid="review-automation-status-panel"
>
<header class="mb-2">
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.automationStatus.title') }}</h2>
<p class="mt-0.5 text-xs text-muted">{{ t('chat.shippingOrderReview.automationStatus.subtitle') }}</p>
</header>
<ol class="space-y-1.5">
<li
v-for="item in track"
:key="String(item.gate_code)"
class="flex items-center gap-2 text-[11px] text-secondary"
>
<span
class="inline-block h-2 w-2 shrink-0 rounded-full"
:class="statusClass(String(item.status || ''))"
aria-hidden="true"
/>
<span class="min-w-0 flex-1 truncate">{{ item.label || item.gate_code }}</span>
<span class="shrink-0 text-muted">{{ statusLabel(String(item.status || '')) }}</span>
</li>
</ol>
<p
v-if="technicalOnly"
class="mt-2 text-[11px] text-muted"
data-testid="review-automation-technical-hint"
>
{{ t('chat.shippingOrderReview.automationStatus.technicalHint') }}
</p>
<p
v-else-if="processGate?.blocking_message"
class="mt-2 text-[11px] text-amber-900 dark:text-amber-100"
>
{{ processGate.blocking_message }}
</p>
</section>
</template>