统一 Case/Progress 阶段 label_key、修复 Job 成功未推进 OT 的可重试失败投影与写路径,并落地 OT 后行级匹配/波次履约与版面诊断开关。 Co-authored-by: Cursor <cursoragent@cursor.com>
112 lines
4.4 KiB
Vue
112 lines
4.4 KiB
Vue
<!--
|
||
features/chat/components/shipping-review/ReviewProfileMatchPanel.vue
|
||
用途:复核工作台文档模板匹配只读区(用户四态;管理员详细在技术诊断)。
|
||
依赖:vue-i18n、ShippingOrderReviewProfileMatch。
|
||
逻辑:普通用户只显示 matched/unmatched/ambiguous/unknown;
|
||
required_field_missing 不在此展示;分数/Profile ID 仅 admin visibility。
|
||
-->
|
||
<script setup lang="ts">
|
||
import { computed } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import type { ShippingOrderReviewProfileMatch } from '@/features/chat/types/shipping.api.types';
|
||
|
||
const props = defineProps<{
|
||
profileMatch: ShippingOrderReviewProfileMatch | null | undefined;
|
||
}>();
|
||
|
||
const { t, te } = useI18n();
|
||
|
||
const visible = computed(() => {
|
||
const match = props.profileMatch;
|
||
if (!match) return false;
|
||
if (match.visibility === 'admin_only' && match.available === false) return false;
|
||
return Boolean(match.available !== false);
|
||
});
|
||
|
||
const isAdminView = computed(() => String(props.profileMatch?.visibility || '') === 'admin');
|
||
const needsReview = computed(() => Boolean(props.profileMatch?.needs_review));
|
||
|
||
/**
|
||
* 匹配状态本地化(用户四态)。
|
||
*/
|
||
const statusLabel = computed(() => {
|
||
const status = String(props.profileMatch?.status || '').trim();
|
||
const key = `chat.shippingOrderReview.profileMatch.status.${status}`;
|
||
return status && te(key) ? t(key) : (status || '—');
|
||
});
|
||
|
||
/**
|
||
* 选中模板展示名(用户仅 display_name)。
|
||
*/
|
||
const selectedLabel = computed(() => {
|
||
const selected = props.profileMatch?.selected_profile;
|
||
if (!selected) {
|
||
return t('chat.shippingOrderReview.profileMatch.noSelected');
|
||
}
|
||
const name = String(selected.display_name || selected.profile_code || '').trim();
|
||
if (!name) return t('chat.shippingOrderReview.profileMatch.noSelected');
|
||
if (!isAdminView.value) return name;
|
||
const version = selected.version != null ? ` v${selected.version}` : '';
|
||
return `${name}${version}`;
|
||
});
|
||
</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-profile-match-panel"
|
||
:data-status="String(profileMatch?.status || '')"
|
||
>
|
||
<header class="flex flex-wrap items-start justify-between gap-2">
|
||
<div>
|
||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.profileMatch.title') }}</h2>
|
||
<p class="mt-0.5 text-xs text-muted">{{ t('chat.shippingOrderReview.profileMatch.subtitle') }}</p>
|
||
</div>
|
||
<span
|
||
class="rounded-full px-2.5 py-1 text-xs font-medium"
|
||
:class="needsReview
|
||
? 'bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100'
|
||
: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100'"
|
||
data-testid="review-profile-match-badge"
|
||
>
|
||
{{ statusLabel }}
|
||
</span>
|
||
</header>
|
||
|
||
<dl class="mt-2 space-y-1 text-xs text-secondary">
|
||
<div class="flex flex-wrap gap-x-2">
|
||
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.selected') }}</dt>
|
||
<dd class="font-medium text-primary" data-testid="review-profile-match-selected">{{ selectedLabel }}</dd>
|
||
</div>
|
||
</dl>
|
||
|
||
<template v-if="isAdminView">
|
||
<dl class="mt-2 space-y-1 text-xs text-secondary">
|
||
<div v-if="profileMatch?.route_type" class="flex flex-wrap gap-x-2">
|
||
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.routeType') }}</dt>
|
||
<dd class="font-mono">{{ profileMatch.route_type }}</dd>
|
||
</div>
|
||
<div v-if="profileMatch?.execution_mode" class="flex flex-wrap gap-x-2">
|
||
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.executionMode') }}</dt>
|
||
<dd class="font-mono">{{ profileMatch.execution_mode }}</dd>
|
||
</div>
|
||
</dl>
|
||
<ul
|
||
v-if="(profileMatch?.candidates || []).length"
|
||
class="mt-2 space-y-1.5"
|
||
data-testid="review-profile-match-candidates"
|
||
>
|
||
<li
|
||
v-for="(item, idx) in profileMatch?.candidates || []"
|
||
:key="`${item.profile_code}-${item.version}-${idx}`"
|
||
class="rounded-lg border border-default bg-surface-soft px-2.5 py-1.5 text-[11px] text-secondary"
|
||
>
|
||
<span class="font-mono">{{ item.profile_code }}</span>
|
||
<span v-if="item.score != null" class="ml-2 text-muted">{{ item.score }}</span>
|
||
</li>
|
||
</ul>
|
||
</template>
|
||
</section>
|
||
</template>
|