Files
syops/frontend/src/features/chat/components/shipping-review/ReviewProfileMatchPanel.vue
T
hugo 1b6483a4ea feat(shipping-notice,receipt-report): 新增收料报表功能并优化发货通知流程
清理废弃的shipping xfa ocr automark相关代码和job配置
新增收料报表管理的前端页面、路由和侧边栏入口
新增后端收料报表配置接口、数据库模型和RPA脚本
优化发货通知流程的重试策略,将shipping相关job默认不自动重试
移除废弃的库存源确认相关逻辑,更新流程门禁规则
重构订单模板的值适配器模块,新增坐标OCR值适配器
清理前端shipping菜单和action的废弃选项
更新相关文档和测试用例,调整.gitignore忽略规则
2026-08-20 20:23:10 +08:00

139 lines
6.0 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/ReviewProfileMatchPanel.vue
用途:复核工作台文档模板匹配只读区(用户四态;管理员详细在技术诊断)。
依赖:vue-i18n、ShippingOrderReviewProfileMatch。
逻辑:普通用户只显示 matched/unmatched/ambiguous/unknown;
required_field_missing 不在此展示;分数/Profile ID 仅 admin visibility。
-->
<script setup lang="ts">
import { computed, ref, watch } 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 candidateCount = computed(() => (props.profileMatch?.candidates || []).length);
// 候选模板始终按需披露,避免模板数量增长撑长工作台;人工关注状态仍通过徽标表达。
const defaultCandidatesExpanded = computed(() => false);
const candidatesOpenOverride = ref<boolean | null>(null);
const candidatesExpanded = computed(() => candidatesOpenOverride.value ?? defaultCandidatesExpanded.value);
watch(
() => `${props.profileMatch?.status || ''}:${props.profileMatch?.selected_profile?.profile_code || ''}:${candidateCount.value}`,
() => { candidatesOpenOverride.value = null; },
);
function toggleCandidates() {
candidatesOpenOverride.value = !candidatesExpanded.value;
}
/**
* 匹配状态本地化(用户四态)。
*/
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 || '').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 && candidateCount">
<button
type="button"
class="mt-3 flex w-full items-center justify-between rounded-lg border border-default bg-surface-soft px-2.5 py-2 text-left text-xs font-medium text-secondary transition-colors hover:bg-slate-50 dark:hover:bg-slate-800"
data-testid="review-profile-match-candidates-toggle"
:aria-expanded="candidatesExpanded"
@click="toggleCandidates"
>
<span>{{ candidatesExpanded
? t('chat.shippingOrderReview.profileMatch.collapseCandidates')
: t('chat.shippingOrderReview.profileMatch.expandCandidates', { count: candidateCount }) }}</span>
<span aria-hidden="true" class="text-muted">{{ candidatesExpanded ? '−' : '+' }}</span>
</button>
<div v-if="candidatesExpanded" data-testid="review-profile-match-details">
<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
class="mt-2 max-h-48 space-y-1.5 overflow-y-auto pr-1"
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>{{ item.display_name || t('chat.shippingOrderReview.profileMatch.noSelected') }}</span>
<span v-if="item.score != null" class="ml-2 text-muted">{{ item.score }}</span>
</li>
</ul>
</div>
</template>
</section>
</template>