Files
syops/frontend/src/features/chat/components/shipping-review/ReviewLineFulfillmentDetail.vue
T
hugoandCursor fd6a23f870 feat(shipping-notice): 收敛复核阶段同源投影与 OT 后履约推进
统一 Case/Progress 阶段 label_key、修复 Job 成功未推进 OT 的可重试失败投影与写路径,并落地 OT 后行级匹配/波次履约与版面诊断开关。

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-07 13:11:14 +08:00

134 lines
4.7 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/ReviewLineFulfillmentDetail.vue
用途:订单明细行内履约摘要(查看履约详情);不进入库存工作台。
依赖:vue-i18n、ShippingOrderReviewLineFulfillmentLine。
逻辑:由 ShippingOrderReviewView 在展开行下方挂载;展示 wave/task/快照/匹配时间/
决定来源/失败原因,并提供审计入口。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
line: ShippingOrderReviewLineFulfillmentLine | null | undefined;
taskNo?: string | null;
}>();
const emit = defineEmits<{
'open-audit': [];
close: [];
}>();
const { t, te } = useI18n();
/**
* 展示用字段行。
*/
const rows = computed(() => {
const line = props.line;
const decision = line?.decision;
const waveNo = decision?.wave_no ?? null;
const taskNo = String(props.taskNo || '').trim()
|| (decision?.task_id != null ? String(decision.task_id) : '');
const source = String(line?.decision_source || decision?.decision_source || '').trim();
const sourceKey = `chat.shippingOrderReview.lineFulfillmentDetail.decisionSourceValue.${source}`;
const sourceLabel = source
? (te(sourceKey) ? t(sourceKey) : source)
: '—';
const failure = String(line?.auto_fulfill_error_message || '').trim();
return [
{
key: 'wave',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.wave'),
value: waveNo != null ? String(waveNo) : '—',
},
{
key: 'task',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.task'),
value: taskNo || '—',
},
{
key: 'snapshot',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.snapshotId'),
value: line?.inventory_snapshot_id != null ? String(line.inventory_snapshot_id) : '—',
},
{
key: 'matchedAt',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.matchedAt'),
value: formatTime(line?.inventory_checked_at),
},
{
key: 'decisionSource',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.decisionSource'),
value: sourceLabel,
},
{
key: 'failure',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.failureReason'),
value: failure || t('chat.shippingOrderReview.lineFulfillmentDetail.noFailure'),
emphasize: Boolean(failure),
},
];
});
/**
* 格式化匹配/校验时间。
*/
function formatTime(value: string | null | undefined): string {
if (!value) return '—';
const date = new Date(value);
return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleString();
}
</script>
<template>
<div
class="rounded-md border border-slate-200 bg-slate-50/80 px-3 py-2 text-xs dark:border-slate-700 dark:bg-slate-950/50"
data-testid="review-line-fulfillment-summary"
role="region"
:aria-label="t('chat.shippingOrderReview.lineFulfillmentDetail.title')"
>
<div class="mb-2 flex items-center justify-between gap-2">
<p class="font-medium text-slate-700 dark:text-slate-200">
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.title') }}
</p>
<div class="flex items-center gap-2">
<button
type="button"
class="rounded border border-slate-300 px-2 py-0.5 text-[11px] text-sky-700 hover:bg-white dark:border-slate-600 dark:text-sky-300 dark:hover:bg-slate-900"
data-testid="review-line-fulfillment-open-audit"
@click="emit('open-audit')"
>
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.openAudit') }}
</button>
<button
type="button"
class="rounded px-2 py-0.5 text-[11px] text-slate-500 hover:bg-slate-100 dark:hover:bg-slate-800"
data-testid="review-line-fulfillment-summary-close"
@click="emit('close')"
>
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.close') }}
</button>
</div>
</div>
<dl class="grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3">
<div
v-for="row in rows"
:key="row.key"
class="min-w-0 rounded bg-white/70 px-2 py-1.5 dark:bg-slate-900/60"
:data-testid="`review-line-fulfillment-field-${row.key}`"
>
<dt class="text-[10px] font-medium text-slate-500 dark:text-slate-400">{{ row.label }}</dt>
<dd
class="mt-0.5 break-words text-[11px] text-slate-800 dark:text-slate-100"
:class="row.emphasize ? 'font-medium text-rose-700 dark:text-rose-300' : ''"
>
{{ row.value }}
</dd>
</div>
</dl>
</div>
</template>