refactor(in-transit-transfer): 行归属解耦、按行执行三层门禁并重构术语为匹配

- 行不迁移:匹配记录降级为评估留痕(scope/counts/hash 留痕不拦执行),
  匹配/重查原地刷新行并续行级新鲜度(updated_at)
- 执行改按行:POST /items/execute 三层门禁(行级新鲜度 TTL/文件版本对账/写前复查),
  Run 留痕不绑匹配记录;消失行 blocked_file_removed fail-closed 入异常池
- 恢复处理收敛为行级重查(batch-resume 删除);待处理池补齐匹配窗口字段,
  排序改业务稳定键(收料日期→Invoice→created_at,操作不再引起跳位)
- 首页待办看板四队列:可调拨明细/待恢复异常/已人工关闭/结果未知;「最近预检」移除;
  收料日期默认 T-1 并加输入期限制;「重新查询 ERP」更名「重查」
- 术语重构 precheck→match:表 transfer_matchings、列 matching_id/matching_no/matching_hash、
  API /matchings、单号前缀 MTG、状态值 prechecking→matching(迁移 rn1a2b3c4d5e6,模块未上线无兼容层)
- 修复 integration_connector mapping 扇出嵌套丢行缺陷;对账结论:0 vs 30/40/36
  系收料仓库映射曾指向错误账套 TGHX(已改 TGHX1),探针留档 backend/tmp
- 测试:后端 in_transit_transfer+api+connector 393 passed;前端 chat 713 passed;build ✓
This commit is contained in:
hugo committed 2026-09-24 00:24:03 +08:00
1 parent f9f5053f0b
commit 0cf3c24119
108 files changed
+3660 -2356

No files matched your search

@@ -1,11 +1,11 @@
<!--
features/chat/components/messages/TransferHomePanel.vue
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——home 视图展示标题、今日待办
入口、最近预检(一键恢复)与三张历史待办计数卡;点击入口独立触发
source-select / backlog / 预检恢复卡片。
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——上区「库存匹配」动作入口,
下区「待办看板」四队列(可调拨明细/待恢复异常/已人工关闭/结果未知),
点击进入对应处理视图(复用自驱动的 TransferMessageView)。
依赖:TransferMessageView(复用自驱动卡片)、useChatTransfer、i18n chat.transfer.*。
逻辑:home 时消费 backlogSummary 计数与 recentPrechecks 列表;非 home 时渲染
TransferMessageView。卡片不注入消息流,因此无需后端 ChatLog 消息。
逻辑:home 时拉取待办汇总与可调拨明细计数;非 home 时渲染 TransferMessageView。
卡片不注入消息流,因此无需后端 ChatLog 消息。
-->
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
@@ -21,15 +21,13 @@ const emit = defineEmits<{
'flow-active': [active: boolean];
}>();
type HomeView = 'home' | 'source-select' | 'backlog' | 'precheck-restore';
type HomeView = 'home' | 'source-select' | 'backlog' | 'executable';
/** 待处理池结果筛选(与 TransferBacklogSummaryCard 的筛选选项一致)。 */
type BacklogFilter = 'all' | 'recoverable' | 'closed' | 'unknown';
const transfer = useChatTransfer();
const view = ref<HomeView>('home');
/** 最近预检入口选中的预检号(precheck-restore 视图传给 TransferMessageView 按ID恢复)。 */
const restorePrecheckId = ref('');
/** 历史待办计数卡对应的初始筛选:点击哪张卡就落到哪个切片,不再一律全量列表。 */
/** 历史待办计数卡对应的初始筛选:点击哪张卡就落到哪个切片。 */
const backlogFilter = ref<BacklogFilter>('all');
/** 打开待处理池并按计数卡切片(recoverable/closed/unknown)。 */
@@ -38,34 +36,27 @@ function openBacklog(filter: BacklogFilter) {
view.value = 'backlog';
}
/** 进入非 home 时通知父级隐藏聊天输入框(决策:来源选择为业务页,无对话输入区)。 */
watch(view, (value) => emit('flow-active', value !== 'home'), { immediate: true });
/** home 视图需要待办汇总与最近预检;进入时拉取。 */
/** home 视图需要待办汇总与可调拨明细计数;进入时拉取。 */
async function loadHomeSummary() {
if (view.value !== 'home') return;
await Promise.all([
transfer.loadBacklog().catch(() => undefined),
transfer.loadRecentPrechecks().catch(() => undefined),
transfer.loadExecutableItems().catch(() => undefined),
]);
}
onMounted(() => { void loadHomeSummary(); });
watch(view, () => { void loadHomeSummary(); });
const displayAgentName = computed(() => props.agentName || '在途仓自动调拨');
/** 进入非 home 时通知父级隐藏聊天输入框(来源选择/待办为业务页,无对话输入区)。 */
watch(view, (value) => emit('flow-active', value !== 'home'), { immediate: true });
/** 确认窗口剩余分钟(前端按 expires_at 计算,用于最近预检行展示)。 */
function remainingMinutes(expiresAt?: string | null): number {
if (!expiresAt) return 0;
const ms = new Date(expiresAt).getTime() - Date.now();
return Math.max(0, Math.ceil(ms / 60000));
}
const displayAgentName = computed(() => props.agentName || '在途仓自动调拨');
/** 非 home 视图把当前入口透传给自驱动的 TransferMessageView。 */
const childPayload = computed(() => {
if (view.value === 'source-select') return { kind: 'source-select' };
if (view.value === 'precheck-restore') return { kind: 'precheck', precheck_id: restorePrecheckId.value };
if (view.value === 'executable') return { kind: 'executable' };
return { kind: 'backlog', filter: backlogFilter.value };
});
@@ -76,7 +67,7 @@ function goBack() {
<template>
<div class="flex w-full flex-col items-center px-4 pb-2 pt-6 md:pb-4">
<!-- home:标题 + 今日/历史待办入口 -->
<!-- home:库存匹配 + 待办看板 -->
<template v-if="view === 'home'">
<h2 data-testid="transfer-home" class="mb-8 mt-6 shrink-0 text-center text-2xl font-bold text-primary md:mt-10 md:text-3xl">
{{ $t('chat.transfer.homeWelcome') }}
@@ -84,9 +75,9 @@ function goBack() {
</h2>
<div class="w-full max-w-3xl space-y-4">
<!-- 今日待办 -->
<section aria-label="今日待办">
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeTodayLabel') }}</p>
<!-- 库存匹配 -->
<section aria-label="库存匹配">
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeMatchLabel') }}</p>
<button
type="button"
data-testid="transfer-home-today"
@@ -102,39 +93,20 @@ function goBack() {
</button>
</section>
<!-- 最近预检:关闭/离开视图后可一键恢复(后端只列未执行、未过期、仍拥有归属行) -->
<section v-if="transfer.recentPrechecks.value.length" aria-label="最近预检">
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeRecentTitle') }}</p>
<div class="flex flex-col gap-2">
<!-- 待办看板 -->
<section aria-label="待办看板">
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeBoardLabel') }}</p>
<div class="grid grid-cols-2 gap-3 lg:grid-cols-4">
<button
v-for="recent in transfer.recentPrechecks.value"
:key="recent.precheck_no"
type="button"
data-testid="transfer-home-recent-precheck"
class="flex w-full items-center gap-3 rounded-2xl border border-default bg-surface p-3 text-left transition-colors hover:border-brand-200 hover:bg-brand-50"
@click="restorePrecheckId = recent.precheck_no; view = 'precheck-restore'"
data-testid="transfer-home-executable"
class="rounded-2xl border border-emerald-200 bg-emerald-50 p-4 text-left transition-colors hover:bg-emerald-100"
@click="view = 'executable'"
>
<span class="min-w-0 flex-1">
<b class="block text-sm font-bold text-primary">{{ recent.precheck_no }}</b>
<span class="mt-0.5 block text-xs text-secondary">
{{ recent.business_date }}
· {{ $t('chat.transfer.executableCount') }} {{ recent.counts.executable_count }}
· {{ $t('chat.transfer.blockedCount') }} {{ recent.counts.blocked_count }}
<template v-if="recent.status === 'prechecking'"> · {{ $t('chat.transfer.recentPrechecking') }}</template>
<template v-else-if="remainingMinutes(recent.expires_at) > 0">
· {{ $t('chat.transfer.recentRemaining', { min: remainingMinutes(recent.expires_at) }) }}
</template>
</span>
</span>
<span class="shrink-0 text-xl text-brand-600">›</span>
<b class="block text-2xl leading-none text-emerald-600">{{ transfer.executableItems.value.length }}</b>
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeExecutable') }}</b>
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeExecutableHint') }}</span>
</button>
</div>
</section>
<!-- 历史待办 -->
<section aria-label="历史待办">
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeHistoryLabel') }}</p>
<div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
<button
type="button"
data-testid="transfer-home-recoverable"
@@ -170,7 +142,7 @@ function goBack() {
</div>
</template>
<!-- 子流程:复用自驱动的 TransferMessageView(预检宽表格需要全宽,上限对齐消息气泡宽布局) -->
<!-- 子流程:复用自驱动的 TransferMessageView(宽表格需要全宽,上限对齐消息气泡宽布局) -->
<div v-else class="w-full max-w-[min(96vw,1500px)] pr-2">
<button
type="button"