feat(shipping-notice): 完善发货通知自动推进与多库存源复核闭环

This commit is contained in:
hugo committed 2026-08-09 11:43:53 +08:00
1 parent cfa19a0b7b
commit 8e0bbf7a81
180 files changed
+31210 -1864

No files matched your search

@@ -56,6 +56,11 @@ const unavailableSuggestions = computed(() =>
(props.suggestions || []).filter((item) => String(item.status || '') === 'provider_unavailable'),
);
/** 前门禁失败(未调用 Dify)的记录必须明确展示,错误码指向 i18n errors.json;避免用户误认为 AI 已跑过。 */
const gatedFailedSuggestions = computed(() =>
(props.suggestions || []).filter((item) => String(item.status || '') === 'gated_failed'),
);
/** 将 Provider 失败码转成可执行的业务提示,不向用户暴露底层地址或异常正文。 */
function unavailableMessage(item?: ShippingOrderReviewLlmSuggestion): string {
if (String(item?.error_code || '') === 'SHIPPING.REVIEW_LLM_DISABLED') {
@@ -64,6 +69,31 @@ function unavailableMessage(item?: ShippingOrderReviewLlmSuggestion): string {
return t('chat.shippingOrderReview.llmSuggestion.unavailableProvider');
}
/**
* 门禁失败 short 提示(一层标题):用 errors.json 本地化;缺失时给通用提示避免裸 code。
* 完全消费后端投影的 item.error_code,前端绝对不推导「为什么失败」。
*/
function gatedShortMessage(item: ShippingOrderReviewLlmSuggestion): string {
const code = String(item.error_code || '');
const key = `errors.${code}`;
if (code && te(key)) return t(key);
return t('chat.shippingOrderReview.llmSuggestion.status.gated_failed');
}
/**
* 门禁失败 detail 提示(二层详情):查 errors.json 的 `${code}Detail` 或通用 hint。
* 同样不推导原因,纯 i18n 查表。
*/
function gatedDetailMessage(item: ShippingOrderReviewLlmSuggestion): string | null {
const code = String(item.error_code || '');
if (!code) return null;
const detailKey = `errors.${code}Detail`;
if (te(detailKey)) return t(detailKey);
const hintKey = `chat.shippingOrderReview.llmSuggestion.gateDetail.${code.replace(/^SHIPPING\./, '')}`;
if (te(hintKey)) return t(hintKey);
return null;
}
const statusLabel = computed(() => {
if (props.suggestionLoading) return t('chat.shippingOrderReview.llmSuggestion.status.pending');
const latest = (props.suggestions || [])[0];
@@ -218,8 +248,59 @@ function onDecide(payload: { decision: 'accept' | 'modify' | 'reject'; reason: s
>
{{ unavailableMessage(unavailableSuggestions[0]) }}
</div>
<ul
v-if="gatedFailedSuggestions.length"
class="mt-3 space-y-2"
data-testid="review-llm-gated-failed-list"
>
<li
v-for="item in gatedFailedSuggestions"
:key="item.suggestion_no"
class="rounded border border-sky-200 bg-sky-50/60 px-2 py-2 text-xs text-sky-800 dark:border-sky-900 dark:bg-sky-950/30 dark:text-sky-200"
role="note"
>
<div class="flex items-start justify-between gap-2">
<div class="min-w-0 flex-1">
<div class="font-medium leading-snug">{{ suggestionFieldLabel(item) }}</div>
<p class="mt-1 leading-snug">{{ gatedShortMessage(item) }}</p>
<p
v-if="gatedDetailMessage(item)"
class="mt-1 text-[11px] leading-relaxed opacity-80"
>
{{ gatedDetailMessage(item) }}
</p>
<p
v-if="item.evidence_summary"
class="mt-1 flex flex-wrap gap-x-3 gap-y-0.5 text-[11px] opacity-80"
>
<span v-if="item.evidence_summary.level">
{{ t('chat.shippingOrderReview.llmSuggestion.evidenceLevelLabel') }}:{{ evidenceLevelLabel(item.evidence_summary.level) }}
</span>
<span v-if="item.evidence_summary.auto_upgraded">
{{ t('chat.shippingOrderReview.llmSuggestion.autoUpgradedLabel') }}
</span>
<span v-if="typeof item.evidence_summary.field_count === 'number'">
{{ t('chat.shippingOrderReview.llmSuggestion.fieldCountLabel') }}:{{ item.evidence_summary.field_count }}
</span>
<span v-if="item.evidence_summary.context_truncated">
{{ t('chat.shippingOrderReview.llmSuggestion.contextTruncatedLabel') }}
</span>
</p>
</div>
<button
type="button"
class="shrink-0 rounded border border-sky-300 bg-white px-2 py-0.5 text-xs text-sky-700 dark:border-sky-700 dark:bg-slate-900 dark:text-sky-200"
:disabled="!canRequest"
:aria-label="t('chat.shippingOrderReview.llmSuggestion.request')"
@click="emit('requestSuggestion')"
>
{{ t('chat.shippingOrderReview.llmSuggestion.request') }}
</button>
</div>
</li>
</ul>
<p
v-if="!pendingSuggestions.length && !failedSuggestions.length && !unavailableSuggestions.length"
v-if="!pendingSuggestions.length && !failedSuggestions.length && !unavailableSuggestions.length && !gatedFailedSuggestions.length"
class="mt-3 text-xs text-slate-500"
>
{{ t('chat.shippingOrderReview.llmSuggestion.empty') }}