169 lines
5.9 KiB
Vue
169 lines
5.9 KiB
Vue
<!--
|
||
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: 'inventorySource',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventorySource'),
|
||
value: String(line?.inventory_source_code || line?.inventory_source?.code || '').trim() || '—',
|
||
},
|
||
{
|
||
key: 'inventoryFile',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventoryFile'),
|
||
value: String(line?.inventory_file_no || '').trim() || '—',
|
||
},
|
||
{
|
||
key: 'inventoryFileSha256',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventoryFileSha256'),
|
||
value: String(line?.inventory_file_sha256 || '').trim() || '—',
|
||
},
|
||
{
|
||
key: 'inventoryRow',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventoryRow'),
|
||
value: line?.inventory_row_index != null ? String(line.inventory_row_index) : '—',
|
||
},
|
||
{
|
||
key: 'requiredQty',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.requiredQty'),
|
||
value: String(line?.required_qty || '').trim() || '—',
|
||
},
|
||
{
|
||
key: 'availableQty',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.availableQty'),
|
||
value: String(line?.available_qty || '').trim() || '—',
|
||
},
|
||
{
|
||
key: 'matchAttempt',
|
||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.matchAttempt'),
|
||
value: line?.match_attempt_id != null ? String(line.match_attempt_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-default bg-slate-50/80 px-3 py-2 text-xs 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-secondary">
|
||
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.title') }}
|
||
</p>
|
||
<div class="flex items-center gap-2">
|
||
<button
|
||
type="button"
|
||
class="rounded border border-default px-2 py-0.5 text-[11px] text-sky-700 hover:bg-white dark:text-sky-300"
|
||
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-muted hover-surface-strong"
|
||
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-muted">{{ row.label }}</dt>
|
||
<dd
|
||
class="mt-0.5 break-words text-[11px] text-primary"
|
||
:class="row.emphasize ? 'font-medium text-rose-700 dark:text-rose-300' : ''"
|
||
>
|
||
{{ row.value }}
|
||
</dd>
|
||
</div>
|
||
</dl>
|
||
</div>
|
||
</template>
|