128 lines
5.6 KiB
Vue
128 lines
5.6 KiB
Vue
/**
|
||
* features/workspace/shipping-task-center/StpProgressFactsPanel.vue
|
||
* 用途:展示后端 ui_state.summary.stp_facts,含逐行 Reservation/料号/实际库存源/文件证据。
|
||
* 依赖:ShippingTaskUiState.summary.stp_facts、element-plus、vue-i18n。
|
||
* 逻辑:由 ShippingTaskWorkbench 在待办栏下方挂载;无 stp_facts 时不渲染;不发明进度。
|
||
*/
|
||
<script setup lang="ts">
|
||
import { computed } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { ElTable, ElTableColumn } from 'element-plus';
|
||
import type { ShippingStpFacts } from '@/features/chat/types/shipping.api.types';
|
||
|
||
type StpLine = NonNullable<ShippingStpFacts['line_resolutions']>[number] & { rowKey: string; displayLine: number };
|
||
|
||
const props = defineProps<{
|
||
facts: ShippingStpFacts | null | undefined;
|
||
}>();
|
||
|
||
const { t, te } = useI18n();
|
||
|
||
const visible = computed(() => Boolean(props.facts));
|
||
const resolutionEntries = computed(() => {
|
||
const counts = props.facts?.resolution_counts || {};
|
||
return Object.entries(counts).map(([disposition, count]) => ({ disposition, count }));
|
||
});
|
||
const lineRows = computed<StpLine[]>(() => (props.facts?.line_resolutions || []).map((row, index) => ({
|
||
...row,
|
||
rowKey: `${row.line_no || row.line_index || 'line'}-${index}`,
|
||
displayLine: (row.line_index ?? index) + 1,
|
||
})));
|
||
|
||
/**
|
||
* 行级 disposition 文案;未知码回退原文。
|
||
*/
|
||
function dispositionLabel(disposition: string): string {
|
||
const key = `workspace.shippingNotice.stpFacts.disposition.${disposition}`;
|
||
return te(key) ? t(key) : disposition;
|
||
}
|
||
|
||
/**
|
||
* 行证据摘要:文件号 + 行引用键。
|
||
*/
|
||
function evidenceText(row: NonNullable<ShippingStpFacts['line_resolutions']>[number]): string {
|
||
const fileNo = String(row?.inventory_file_no || '').trim();
|
||
const ref = row?.inventory_row_ref;
|
||
const refParts = [
|
||
ref?.reservation_id,
|
||
ref?.part_number,
|
||
ref?.source_code,
|
||
].filter(Boolean).map(String);
|
||
if (fileNo && refParts.length) return `${fileNo} · ${refParts.join('/')}`;
|
||
if (fileNo) return fileNo;
|
||
if (refParts.length) return refParts.join('/');
|
||
return '—';
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<section
|
||
v-if="visible && facts"
|
||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
|
||
data-testid="stp-progress-facts-panel"
|
||
>
|
||
<h3 class="mb-2 text-sm font-semibold text-secondary">
|
||
{{ $t('workspace.shippingNotice.stpFacts.title') }}
|
||
</h3>
|
||
<dl class="grid gap-2 text-xs sm:grid-cols-2">
|
||
<div>
|
||
<dt class="text-muted">{{ $t('workspace.shippingNotice.stpFacts.inventorySourceStatus') }}</dt>
|
||
<dd class="font-medium text-secondary">{{ facts.inventory_source_status || '—' }}</dd>
|
||
</div>
|
||
<div>
|
||
<dt class="text-muted">{{ $t('workspace.shippingNotice.stpFacts.inventorySourceCode') }}</dt>
|
||
<dd class="font-medium text-secondary">{{ facts.inventory_source_code || '—' }}</dd>
|
||
</div>
|
||
<div class="sm:col-span-2">
|
||
<dt class="text-muted">{{ $t('workspace.shippingNotice.stpFacts.frozenCandidates') }}</dt>
|
||
<dd class="font-medium text-secondary">
|
||
{{ (facts.frozen_candidate_codes || []).join(', ') || '—' }}
|
||
</dd>
|
||
</div>
|
||
<div v-if="facts.multi_source_excel_block" class="sm:col-span-2 rounded-lg bg-amber-50 px-3 py-2 text-amber-900">
|
||
{{ $t('workspace.shippingNotice.stpFacts.multiSourceBlock') }}
|
||
<span v-if="(facts.resolved_ok_source_codes || []).length">
|
||
({{ (facts.resolved_ok_source_codes || []).join(', ') }})
|
||
</span>
|
||
</div>
|
||
<div v-if="resolutionEntries.length" class="sm:col-span-2">
|
||
<dt class="mb-1 text-muted">{{ $t('workspace.shippingNotice.stpFacts.resolutionCounts') }}</dt>
|
||
<dd class="flex flex-wrap gap-2">
|
||
<span
|
||
v-for="item in resolutionEntries"
|
||
:key="item.disposition"
|
||
class="rounded-full border border-default/70 px-2 py-0.5 text-secondary"
|
||
>
|
||
{{ dispositionLabel(item.disposition) }}
|
||
× {{ item.count }}
|
||
</span>
|
||
</dd>
|
||
</div>
|
||
</dl>
|
||
|
||
<div v-if="lineRows.length" class="mt-3">
|
||
<div>{{ $t('workspace.shippingNotice.stpFacts.lineTableTitle') }}</div>
|
||
<ElTable :data="lineRows" row-key="rowKey">
|
||
<ElTableColumn :label="$t('workspace.shippingNotice.stpFacts.colLine')" min-width="72">
|
||
<template #default="{ row }">{{ (row as StpLine).displayLine }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="$t('workspace.shippingNotice.stpFacts.colReservation')" min-width="120">
|
||
<template #default="{ row }">{{ (row as StpLine).effective_reservation_id || '—' }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="$t('workspace.shippingNotice.stpFacts.colPart')" min-width="120">
|
||
<template #default="{ row }">{{ (row as StpLine).part_number || '—' }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="$t('workspace.shippingNotice.stpFacts.colDisposition')" min-width="120">
|
||
<template #default="{ row }">{{ dispositionLabel(String((row as StpLine).disposition || 'unknown')) }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="$t('workspace.shippingNotice.stpFacts.colSource')" min-width="120">
|
||
<template #default="{ row }">{{ (row as StpLine).resolved_inventory_source_code || '—' }}</template>
|
||
</ElTableColumn>
|
||
<ElTableColumn :label="$t('workspace.shippingNotice.stpFacts.colEvidence')" min-width="180">
|
||
<template #default="{ row }">{{ evidenceText(row as StpLine) }}</template>
|
||
</ElTableColumn>
|
||
</ElTable>
|
||
</div>
|
||
</section>
|
||
</template>
|