feat(in-transit-transfer): 更新证据下载与待匹配清单逻辑
- 修改证据下载接口,分别签发预览地址与带保存名的下载地址,避免浏览器使用对象键哈希作为保存名。 - 待匹配清单接口调整,按外部单号合计数量,不再返回外部项次,提升数据展示的清晰度。 - 移除待匹配桶的「清空并重新解析」功能,简化操作流程,确保用户体验一致性。 - 新增跨页全选支持的 API,允许用户在待处理池中选择全部待处理明细 ID,优化批量操作体验。
This commit is contained in:
1 parent
4c2a7e2a23
commit
663f401873
50 files changed
+2156
-1309
No files matched your search
@@ -1,25 +1,18 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferPendingMatchPanel.vue
|
||||
用途:「待匹配」桶清单 +「清空并重新解析」维护入口。上段是启用类型现在
|
||||
圈得住的行,带「去匹配」;下段是其余已落档,只读。两段都保留行级清空重解析。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElDialog/ElButton/ElPagination
|
||||
(2026-10-20 工具条与弹层按钮补齐 EP)、props.records、
|
||||
fetchPendingMatchReparsePreview、useChatTransfer().reparsePendingMatch、i18n。
|
||||
逻辑:行级「清空重解析」带上行上 record_kind(缺省 inbound),预检/执行同传,避免出站行
|
||||
误清入站档;弹窗展示证据流/文件份数/规则/清除与保留行数。
|
||||
用途:「待匹配」桶只读清单。上段是启用类型现在圈得住的行,带「去匹配」;
|
||||
下段是其余已落档。两段都按外部单号展示,数量是该单号的合计。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElButton/ElPagination、props.records、i18n。
|
||||
逻辑:清单不提供重解析。重解析在来源卡,只重放当天最新一份归档。
|
||||
2026-10-22 起移除行上「清空并重新解析」,并不再展示外部项次。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { ElButton, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
|
||||
import { transferDialogShellAttrs } from './transferDialogShell';
|
||||
import { fetchPendingMatchReparsePreview } from '../../api/transfer.api';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
import type {
|
||||
TransferPendingMatchRecord,
|
||||
TransferPendingMatchReparsePreview,
|
||||
TransferPendingMatchReparseResult,
|
||||
TransferRecordKind,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
@@ -50,8 +43,6 @@ const emit = defineEmits<{
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
// 维护链路专用实例(组件自驱动,模式同 TransferMessageView):仅消费 reparsePendingMatch
|
||||
const transfer = useChatTransfer();
|
||||
|
||||
/** 分页页码(本地 UI 态;数据由父级按 page-change 拉取后经 props 回流)。
|
||||
* 翻页/收拢统一经 watch(currentPage) 上抛(单一出口,收拢也通知宿主重拉)。 */
|
||||
@@ -76,18 +67,10 @@ watch(() => props.total, (total = 0) => clampPage(currentPage, total));
|
||||
watch(() => props.matchableTotal, (total = 0) => clampPage(matchablePage, total));
|
||||
|
||||
/**
|
||||
* 确认弹窗状态:source=当前操作来源;preview=预检数据(弹窗内容唯一数据源);
|
||||
* previewLoading=预检在途;confirming=执行在途(防重复点击);result=执行成功摘要;
|
||||
* errorMessage=中止原因(预检失败或后端整体中止 TRANSFER.REPARSE_PARSE_FAILED 透传)。
|
||||
* 表格行键:合并后的代表档 id 加内部单号,避免同一单号多行撞键。
|
||||
* @param record - 待匹配清单行(可能已按外部单号合计)
|
||||
* @returns 行键
|
||||
*/
|
||||
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);
|
||||
const result = ref<TransferPendingMatchReparseResult | null>(null);
|
||||
const errorMessage = ref('');
|
||||
|
||||
function rowKey(record: TransferPendingMatchRecord): string {
|
||||
return `${record.ledger_record_id}|${record.doc_no}`;
|
||||
}
|
||||
@@ -108,87 +91,14 @@ function recordKindLabel(kind?: TransferRecordKind | null): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击来源行「清空重解析」:先调预检(只读零副作用),成功才进入确认态。
|
||||
* 【AI 触发时机】用户点击行级按钮时调用;禁止跳过预检直接执行。
|
||||
*
|
||||
* @param sourceCode - 行来源实例编码
|
||||
* @param recordKind - 行上档记录类型(outbound 时重建出站流)
|
||||
* 清单单元格展示:空白外部单号显示占位。
|
||||
* @param value - 档上的文本;null、undefined、纯空白都视为没有值
|
||||
* @returns 去空白后的原文,或占位符
|
||||
*/
|
||||
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, recordKind);
|
||||
} catch (e) {
|
||||
errorMessage.value = e instanceof Error ? e.message : String(e);
|
||||
} finally {
|
||||
previewLoading.value = false;
|
||||
}
|
||||
function displayCell(value?: string | null): string {
|
||||
const text = (value ?? '').trim();
|
||||
return text || '—';
|
||||
}
|
||||
|
||||
/** 关闭确认弹窗并清空全部弹窗态(取消/成功后关闭共用,幂等)。 */
|
||||
function closeReparseDialog() {
|
||||
dialogSource.value = null;
|
||||
dialogRecordKind.value = 'inbound';
|
||||
preview.value = null;
|
||||
result.value = null;
|
||||
errorMessage.value = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认执行清空重建:调 POST reparse(单事务在后端,先全量预解析、失败一行不删)。
|
||||
*/
|
||||
async function confirmReparse() {
|
||||
if (!dialogSource.value || confirming.value) return;
|
||||
confirming.value = true;
|
||||
errorMessage.value = '';
|
||||
try {
|
||||
result.value = await transfer.reparsePendingMatch(
|
||||
dialogSource.value,
|
||||
dialogRecordKind.value,
|
||||
);
|
||||
emit('refresh');
|
||||
} catch (e) {
|
||||
errorMessage.value = e instanceof Error ? e.message : String(e);
|
||||
} finally {
|
||||
confirming.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// —— 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')}`
|
||||
: '',
|
||||
);
|
||||
const profileLine = computed(() => {
|
||||
const profile = preview.value?.profile;
|
||||
if (!profile) return '';
|
||||
return `${t('chat.transfer.reparseProfilePrefix')}${profile.code}${t('chat.transfer.reparseProfileVersionPrefix')}${profile.version}`;
|
||||
});
|
||||
const rowsLine = computed(() =>
|
||||
preview.value
|
||||
? `${t('chat.transfer.reparseRowsClearPrefix')}${preview.value.clearable_rows}${t('chat.transfer.reparseRowsClearSuffix')}${t('chat.transfer.reparseRowsKeptPrefix')}${preview.value.kept_rows}${t('chat.transfer.reparseRowsKeptSuffix')}`
|
||||
: '',
|
||||
);
|
||||
const successLine = computed(() =>
|
||||
result.value
|
||||
? `${t('chat.transfer.reparseSuccessPrefix')}${result.value.cleared}${t('chat.transfer.reparseSuccessReinsertPrefix')}${result.value.reinserted}${t('chat.transfer.reparseSuccessSuffix')}`
|
||||
: '',
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -237,7 +147,12 @@ const successLine = computed(() =>
|
||||
<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>
|
||||
<template #default="{ row }"><span class="font-semibold">{{ row.doc_no || '—' }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-pending-match-external-doc">{{ displayCell(row.external_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>
|
||||
@@ -251,21 +166,6 @@ const successLine = computed(() =>
|
||||
<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"
|
||||
@@ -302,7 +202,12 @@ const successLine = computed(() =>
|
||||
</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>
|
||||
<span class="font-semibold">{{ row.doc_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-pending-match-external-doc">{{ displayCell(row.external_doc_no) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColMaterial')" min-width="110" class-name="whitespace-nowrap">
|
||||
@@ -317,22 +222,6 @@ const successLine = computed(() =>
|
||||
<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 }">
|
||||
<!-- 行级维护入口(Task 8):点击先调预检再弹确认,不在行上直接执行 -->
|
||||
<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>
|
||||
<!-- 服务端分页条(单页时隐藏):total=桶全量计数,页码变化统一经 watch 上抛;
|
||||
文案走全局 ElConfigProvider 四语言 locale -->
|
||||
@@ -350,72 +239,5 @@ const successLine = computed(() =>
|
||||
{{ $t('chat.transfer.pendingMatchOutsideEmpty') }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 「清空并重新解析」确认弹层(Task 8;内容唯一数据源=预检接口,禁止本地估算)。
|
||||
v-if + model-value=true:打开即渲染、关闭即卸载(无过渡等待,测试语义同旧行为) -->
|
||||
<el-dialog
|
||||
v-if="dialogSource"
|
||||
:model-value="true"
|
||||
v-bind="transferDialogShellAttrs"
|
||||
width="28rem"
|
||||
class="rounded-2xl bg-surface"
|
||||
>
|
||||
<template #header>
|
||||
<h3 class="text-base font-bold text-primary" data-testid="transfer-pending-match-reparse-dialog">
|
||||
{{ $t('chat.transfer.reparseTitle') }}
|
||||
</h3>
|
||||
</template>
|
||||
<p class="text-xs font-semibold text-secondary">{{ dialogSource }}</p>
|
||||
|
||||
<p v-if="previewLoading" class="mt-3 text-xs text-muted" data-testid="transfer-pending-match-reparse-loading">
|
||||
…
|
||||
</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>
|
||||
<span v-else class="font-bold text-amber-600" data-testid="transfer-pending-match-reparse-profile-empty">
|
||||
{{ $t('chat.transfer.reparseProfileEmpty') }}
|
||||
</span>
|
||||
</li>
|
||||
<li data-testid="transfer-pending-match-reparse-rows">{{ rowsLine }}</li>
|
||||
</ul>
|
||||
|
||||
<p
|
||||
v-if="result"
|
||||
class="mt-3 rounded-lg bg-emerald-50 px-3 py-2 text-xs font-bold text-emerald-700"
|
||||
data-testid="transfer-pending-match-reparse-result"
|
||||
>
|
||||
{{ successLine }}
|
||||
</p>
|
||||
<p
|
||||
v-if="errorMessage"
|
||||
class="mt-3 rounded-lg bg-red-50 px-3 py-2 text-xs font-bold text-red-600"
|
||||
data-testid="transfer-pending-match-reparse-error"
|
||||
>
|
||||
{{ $t('chat.transfer.reparseFailedPrefix') }}{{ errorMessage }}
|
||||
</p>
|
||||
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<el-button
|
||||
data-testid="transfer-pending-match-reparse-cancel"
|
||||
@click="closeReparseDialog"
|
||||
>
|
||||
{{ $t('chat.transfer.cancel') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="!result"
|
||||
type="primary"
|
||||
color="#4f46e5"
|
||||
:disabled="!preview || confirming"
|
||||
data-testid="transfer-pending-match-reparse-confirm"
|
||||
@click="confirmReparse"
|
||||
>
|
||||
{{ $t('chat.transfer.reparseButton') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user