feat(in-transit-transfer): 落地证据流重解析并纳入货代与排程配套改动
外部单号进入异动档自然键,圈档按 T-2 成熟封顶,当前归档可单独重解析。同批带上 Crane 禁整页刷新、ODM 白名单降级、排程抽屉与执行记录日期窗,以及 YAML 库存源下线。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
911afa0f73
commit
4c2a7e2a23
145 files changed
+11695
-4214
No files matched your search
@@ -1,30 +1,17 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferPendingMatchPanel.vue
|
||||
用途:「待匹配」桶清单(D16,规格 §10/§12.3)+「清空并重新解析」维护入口(Task 8,
|
||||
规格 §6,后端 Task 7)——已抓取尚未匹配的外部入站记录(档记录尚无 items),
|
||||
首页待办看板第 4 张卡的抽屉数据源;解析规则修改后可按来源清空旧映射档行、
|
||||
以当前绑定入站解析规则重建(确认弹窗数据来自预检接口,执行失败透出中止未删语义)。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElDialog(2026-10-16 EP 组件化:表格与确认
|
||||
弹层壳迁 EP,预检→确认→执行语义不变)、props.records(GET /backlog/pending-match
|
||||
投影)、fetchPendingMatchReparsePreview(预检,只读)、
|
||||
useChatTransfer().reparsePendingMatch(执行+刷新桶)、i18n chat.transfer.*。
|
||||
逻辑:清单主体仍按后端稳定排序只读渲染(无勾选列,不可执行;「去匹配」上抛 go-match
|
||||
由父级切库存匹配入口);行级「清空重解析」按钮点击先调预检(GET reparse-preview)
|
||||
再弹确认——弹窗展示文件份数/规则 code+version(或「未绑定解析规则」)/将清除行数/
|
||||
证据缺失保留行数,数据只来自预检响应、禁止本地估算;确认调执行端点(单事务在后端),
|
||||
成功后 emit refresh 由宿主重拉清单并展示结果摘要(清除 N/重落 M),失败在弹窗内
|
||||
透出后端 reason(解析失败一行未删)。行定位:el-table 行不支持逐行 attr,
|
||||
行 testid 改经 row-class-name 注入(transfer-pending-match-row-<doc_no>)。
|
||||
弹层壳禁 ESC/遮罩点击/X 关闭(仅取消/确认按钮可关,防误触关闭维护操作)。
|
||||
服务端分页(2026-10-16):后端接口分页 envelope,本组件只持页码 UI 态,
|
||||
翻页上抛 page-change 由宿主(TransferHomePanel)拉取当前页。
|
||||
文案遵守 R4:chat.transfer 新键一律纯文本(无 {xxx} 插值,vue-i18n 11.4.7
|
||||
深层嵌套键命名插值异常),动态数量由脚本拼接。
|
||||
用途:「待匹配」桶清单 +「清空并重新解析」维护入口。上段是启用类型现在
|
||||
圈得住的行,带「去匹配」;下段是其余已落档,只读。两段都保留行级清空重解析。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElDialog/ElButton/ElPagination
|
||||
(2026-10-20 工具条与弹层按钮补齐 EP)、props.records、
|
||||
fetchPendingMatchReparsePreview、useChatTransfer().reparsePendingMatch、i18n。
|
||||
逻辑:行级「清空重解析」带上行上 record_kind(缺省 inbound),预检/执行同传,避免出站行
|
||||
误清入站档;弹窗展示证据流/文件份数/规则/清除与保留行数。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElDialog, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { ElButton, ElDialog, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
|
||||
import { transferDialogShellAttrs } from './transferDialogShell';
|
||||
import { fetchPendingMatchReparsePreview } from '../../api/transfer.api';
|
||||
@@ -33,22 +20,33 @@ import type {
|
||||
TransferPendingMatchRecord,
|
||||
TransferPendingMatchReparsePreview,
|
||||
TransferPendingMatchReparseResult,
|
||||
TransferRecordKind,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
/** 当前页记录切片(服务端分页返回;父级经 loadPendingMatchRecords 拉取)。 */
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 其余已落档的当前页(segment=outside)。 */
|
||||
records: TransferPendingMatchRecord[];
|
||||
/** 桶全量计数(分页器数据源;不传视为 0=隐藏分页条)。 */
|
||||
/** 其余已落档的全量计数。 */
|
||||
total?: number;
|
||||
/** 当前可匹配的当前页(segment=matchable)。 */
|
||||
matchableRecords?: TransferPendingMatchRecord[];
|
||||
/** 当前可匹配的全量计数。 */
|
||||
matchableTotal?: number;
|
||||
busy?: boolean;
|
||||
}>();
|
||||
}>(), {
|
||||
total: 0,
|
||||
matchableRecords: () => [],
|
||||
matchableTotal: 0,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 「去匹配」引导:切到现有库存匹配入口(来源选择卡),清单本身不提供执行动作。 */
|
||||
'go-match': [];
|
||||
refresh: [];
|
||||
/** 翻页:宿主据此调用 loadPendingMatchRecords({page}) 拉取对应页(服务端分页)。 */
|
||||
/** 其余已落档翻页。 */
|
||||
'page-change': [query: { page: number }];
|
||||
/** 当前可匹配翻页。 */
|
||||
'matchable-page-change': [query: { page: number }];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -59,15 +57,23 @@ const transfer = useChatTransfer();
|
||||
* 翻页/收拢统一经 watch(currentPage) 上抛(单一出口,收拢也通知宿主重拉)。 */
|
||||
const PAGE_SIZE = TRANSFER_PAGE_SIZE;
|
||||
const currentPage = ref(1);
|
||||
const matchablePage = ref(1);
|
||||
|
||||
watch(currentPage, (page) => emit('page-change', { page }));
|
||||
watch(matchablePage, (page) => emit('matchable-page-change', { page }));
|
||||
|
||||
// 桶变小(清空重解析/刷新)后收拢当前页防空白页:页码变化经上述 watch 上抛,
|
||||
// 宿主重拉后 props.records/total 回流,避免停留在越界空页。
|
||||
watch(() => props.total, (total = 0) => {
|
||||
/**
|
||||
* 桶变小后把页码收回最后一页,避免停在空白页。
|
||||
* @param page - 当前页码 ref
|
||||
* @param total - 该段全量计数
|
||||
*/
|
||||
function clampPage(page: typeof currentPage, total: number) {
|
||||
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
|
||||
if (currentPage.value > maxPage) currentPage.value = maxPage;
|
||||
});
|
||||
if (page.value > maxPage) page.value = maxPage;
|
||||
}
|
||||
|
||||
watch(() => props.total, (total = 0) => clampPage(currentPage, total));
|
||||
watch(() => props.matchableTotal, (total = 0) => clampPage(matchablePage, total));
|
||||
|
||||
/**
|
||||
* 确认弹窗状态:source=当前操作来源;preview=预检数据(弹窗内容唯一数据源);
|
||||
@@ -75,6 +81,7 @@ watch(() => props.total, (total = 0) => {
|
||||
* errorMessage=中止原因(预检失败或后端整体中止 TRANSFER.REPARSE_PARSE_FAILED 透传)。
|
||||
*/
|
||||
const dialogSource = ref<string | null>(null);
|
||||
const dialogRecordKind = ref<TransferRecordKind>('inbound');
|
||||
const preview = ref<TransferPendingMatchReparsePreview | null>(null);
|
||||
const previewLoading = ref(false);
|
||||
const confirming = ref(false);
|
||||
@@ -91,22 +98,35 @@ function rowClassName({ row }: { row: TransferPendingMatchRecord }): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击来源行「清空重解析」:先调预检(只读零副作用),成功才进入确认态。
|
||||
* 【AI 触发时机】用户点击行级按钮时调用;禁止跳过预检直接执行
|
||||
* (确认弹窗必须展示预检数据,让操作者在执行前看到重建范围)。
|
||||
*
|
||||
* @param sourceCode - 行来源实例编码(业务约束:来自待匹配记录,禁止传显示名)
|
||||
* 行上记录类型展示文案(入站/出站)。
|
||||
* @param kind - 档记录类型;缺省按入站
|
||||
*/
|
||||
async function openReparseDialog(sourceCode: string) {
|
||||
function recordKindLabel(kind?: TransferRecordKind | null): string {
|
||||
return kind === 'outbound'
|
||||
? t('chat.transfer.streamOutbound')
|
||||
: t('chat.transfer.streamInbound');
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击来源行「清空重解析」:先调预检(只读零副作用),成功才进入确认态。
|
||||
* 【AI 触发时机】用户点击行级按钮时调用;禁止跳过预检直接执行。
|
||||
*
|
||||
* @param sourceCode - 行来源实例编码
|
||||
* @param recordKind - 行上档记录类型(outbound 时重建出站流)
|
||||
*/
|
||||
async function openReparseDialog(
|
||||
sourceCode: string,
|
||||
recordKind: TransferRecordKind = 'inbound',
|
||||
) {
|
||||
dialogSource.value = sourceCode;
|
||||
dialogRecordKind.value = recordKind;
|
||||
preview.value = null;
|
||||
result.value = null;
|
||||
errorMessage.value = '';
|
||||
previewLoading.value = true;
|
||||
try {
|
||||
preview.value = await fetchPendingMatchReparsePreview(sourceCode);
|
||||
preview.value = await fetchPendingMatchReparsePreview(sourceCode, recordKind);
|
||||
} catch (e) {
|
||||
// 预检失败(网络/权限等):错误落弹窗内文案,不进入可确认态(confirm 由 !preview 拦截)
|
||||
errorMessage.value = e instanceof Error ? e.message : String(e);
|
||||
} finally {
|
||||
previewLoading.value = false;
|
||||
@@ -116,6 +136,7 @@ async function openReparseDialog(sourceCode: string) {
|
||||
/** 关闭确认弹窗并清空全部弹窗态(取消/成功后关闭共用,幂等)。 */
|
||||
function closeReparseDialog() {
|
||||
dialogSource.value = null;
|
||||
dialogRecordKind.value = 'inbound';
|
||||
preview.value = null;
|
||||
result.value = null;
|
||||
errorMessage.value = '';
|
||||
@@ -123,15 +144,16 @@ function closeReparseDialog() {
|
||||
|
||||
/**
|
||||
* 确认执行清空重建:调 POST reparse(单事务在后端,先全量预解析、失败一行不删)。
|
||||
* 成功 → 展示结果摘要(清除 N/重落 M)并 emit refresh 让宿主重拉待匹配清单;
|
||||
* 失败 → 弹窗保持打开并透出后端 reason(含「中止未删」语义),不刷新清单。
|
||||
*/
|
||||
async function confirmReparse() {
|
||||
if (!dialogSource.value || confirming.value) return;
|
||||
confirming.value = true;
|
||||
errorMessage.value = '';
|
||||
try {
|
||||
result.value = await transfer.reparsePendingMatch(dialogSource.value);
|
||||
result.value = await transfer.reparsePendingMatch(
|
||||
dialogSource.value,
|
||||
dialogRecordKind.value,
|
||||
);
|
||||
emit('refresh');
|
||||
} catch (e) {
|
||||
errorMessage.value = e instanceof Error ? e.message : String(e);
|
||||
@@ -142,6 +164,11 @@ async function confirmReparse() {
|
||||
|
||||
// —— R4 纯文本拼接文案:vue-i18n 11.4.7 深层嵌套键命名插值异常,禁 {xxx} 占位;
|
||||
// 动态数量一律「纯文本键 + 脚本拼接」(先例 shippingOrderReview.releaseBar.missingPrefix/Suffix)。
|
||||
const streamLine = computed(() =>
|
||||
`${t('chat.transfer.reparseStreamPrefix')}${recordKindLabel(
|
||||
preview.value?.record_kind ?? dialogRecordKind.value,
|
||||
)}`,
|
||||
);
|
||||
const filesLine = computed(() =>
|
||||
preview.value
|
||||
? `${t('chat.transfer.reparseFilesPrefix')}${preview.value.files.length}${t('chat.transfer.reparseFilesSuffix')}`
|
||||
@@ -171,28 +198,95 @@ const successLine = computed(() =>
|
||||
<h3 class="text-sm font-bold text-primary">{{ $t('chat.transfer.transferPendingMatchTitle') }}</h3>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ $t('chat.transfer.transferPendingMatchReadOnlyHint') }}</p>
|
||||
</div>
|
||||
<div class="flex shrink-0 items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
data-testid="transfer-pending-match-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-indigo-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-pending-match-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<section class="mb-4" data-testid="transfer-pending-match-matchable">
|
||||
<div class="mb-2 flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<h4 class="text-sm font-bold text-primary">{{ $t('chat.transfer.pendingMatchMatchableTitle') }} · {{ matchableTotal }}</h4>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ $t('chat.transfer.pendingMatchMatchableHint') }}</p>
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
color="#4f46e5"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-pending-match-go"
|
||||
@click="emit('go-match')"
|
||||
>
|
||||
{{ $t('chat.transfer.transferPendingMatchGoMatch') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="matchableRecords.length"
|
||||
:data="matchableRecords"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-pending-match-matchable-table"
|
||||
>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColRecordKind')" min-width="72" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ recordKindLabel(row.record_kind) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="doc_no" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }"><span class="font-semibold">{{ row.doc_no }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColMaterial')" min-width="110" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.material_code || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColName')" min-width="140">
|
||||
<template #default="{ row }">{{ row.material_name || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDate')" min-width="100" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColQuantity')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.quantity ?? '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colAction')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="busy"
|
||||
:data-source="row.source_code"
|
||||
data-testid="transfer-pending-match-reparse"
|
||||
@click="openReparseDialog(row.source_code, row.record_kind ?? 'inbound')"
|
||||
>
|
||||
{{ $t('chat.transfer.reparseButton') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchableTotal > PAGE_SIZE"
|
||||
v-model:current-page="matchablePage"
|
||||
:total="matchableTotal"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-pending-match-matchable-pagination"
|
||||
/>
|
||||
<div v-else-if="!matchableRecords.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.pendingMatchMatchableEmpty') }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- EP 表格壳:只读清单(数据=服务端当前页切片),横向滚动由 el-table 内建;行级维护入口语义不变 -->
|
||||
<section data-testid="transfer-pending-match-outside">
|
||||
<div class="mb-2">
|
||||
<h4 class="text-sm font-bold text-primary">{{ $t('chat.transfer.pendingMatchOutsideTitle') }}</h4>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ $t('chat.transfer.pendingMatchOutsideHint') }}</p>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="records.length"
|
||||
:data="records"
|
||||
@@ -203,6 +297,9 @@ const successLine = computed(() =>
|
||||
data-testid="transfer-pending-match-table"
|
||||
>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColRecordKind')" min-width="72" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ recordKindLabel(row.record_kind) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="doc_no" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold">{{ row.doc_no }}</span>
|
||||
@@ -223,16 +320,17 @@ const successLine = computed(() =>
|
||||
<el-table-column :label="$t('chat.transfer.colAction')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<!-- 行级维护入口(Task 8):点击先调预检再弹确认,不在行上直接执行 -->
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-indigo-200 px-2 py-0.5 text-[11px] font-bold text-indigo-600 hover:bg-indigo-50 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="busy"
|
||||
:data-source="row.source_code"
|
||||
data-testid="transfer-pending-match-reparse"
|
||||
@click="openReparseDialog(row.source_code)"
|
||||
@click="openReparseDialog(row.source_code, row.record_kind ?? 'inbound')"
|
||||
>
|
||||
{{ $t('chat.transfer.reparseButton') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
@@ -249,8 +347,9 @@ const successLine = computed(() =>
|
||||
data-testid="transfer-pending-match-pagination"
|
||||
/>
|
||||
<div v-else-if="!records.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-pending-match-empty">
|
||||
{{ $t('chat.transfer.transferPendingMatchEmpty') }}
|
||||
{{ $t('chat.transfer.pendingMatchOutsideEmpty') }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 「清空并重新解析」确认弹层(Task 8;内容唯一数据源=预检接口,禁止本地估算)。
|
||||
v-if + model-value=true:打开即渲染、关闭即卸载(无过渡等待,测试语义同旧行为) -->
|
||||
@@ -273,6 +372,7 @@ const successLine = computed(() =>
|
||||
</p>
|
||||
|
||||
<ul v-else-if="preview" class="mt-3 space-y-1 rounded-lg bg-surface-soft p-3 text-xs text-secondary">
|
||||
<li data-testid="transfer-pending-match-reparse-stream">{{ streamLine }}</li>
|
||||
<li data-testid="transfer-pending-match-reparse-files">{{ filesLine }}</li>
|
||||
<li data-testid="transfer-pending-match-reparse-profile">
|
||||
<template v-if="preview.profile">{{ profileLine }}</template>
|
||||
@@ -299,24 +399,22 @@ const successLine = computed(() =>
|
||||
</p>
|
||||
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
|
||||
<el-button
|
||||
data-testid="transfer-pending-match-reparse-cancel"
|
||||
@click="closeReparseDialog"
|
||||
>
|
||||
{{ $t('chat.transfer.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!result"
|
||||
type="button"
|
||||
class="rounded-lg bg-indigo-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-indigo-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
type="primary"
|
||||
color="#4f46e5"
|
||||
:disabled="!preview || confirming"
|
||||
data-testid="transfer-pending-match-reparse-confirm"
|
||||
@click="confirmReparse"
|
||||
>
|
||||
{{ $t('chat.transfer.reparseButton') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user