- 修改证据下载接口,分别签发预览地址与带保存名的下载地址,避免浏览器使用对象键哈希作为保存名。 - 待匹配清单接口调整,按外部单号合计数量,不再返回外部项次,提升数据展示的清晰度。 - 移除待匹配桶的「清空并重新解析」功能,简化操作流程,确保用户体验一致性。 - 新增跨页全选支持的 API,允许用户在待处理池中选择全部待处理明细 ID,优化批量操作体验。
244 lines
11 KiB
Vue
244 lines
11 KiB
Vue
<!--
|
||
features/chat/components/messages/TransferPendingMatchPanel.vue
|
||
用途:「待匹配」桶只读清单。上段是启用类型现在圈得住的行,带「去匹配」;
|
||
下段是其余已落档。两段都按外部单号展示,数量是该单号的合计。
|
||
依赖:Element Plus ElTable/ElTableColumn/ElButton/ElPagination、props.records、i18n。
|
||
逻辑:清单不提供重解析。重解析在来源卡,只重放当天最新一份归档。
|
||
2026-10-22 起移除行上「清空并重新解析」,并不再展示外部项次。
|
||
-->
|
||
<script setup lang="ts">
|
||
import { ref, watch } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
import { ElButton, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
|
||
import type {
|
||
TransferPendingMatchRecord,
|
||
TransferRecordKind,
|
||
} from '../../types/transfer.types';
|
||
|
||
const props = withDefaults(defineProps<{
|
||
/** 其余已落档的当前页(segment=outside)。 */
|
||
records: TransferPendingMatchRecord[];
|
||
/** 其余已落档的全量计数。 */
|
||
total?: number;
|
||
/** 当前可匹配的当前页(segment=matchable)。 */
|
||
matchableRecords?: TransferPendingMatchRecord[];
|
||
/** 当前可匹配的全量计数。 */
|
||
matchableTotal?: number;
|
||
busy?: boolean;
|
||
}>(), {
|
||
total: 0,
|
||
matchableRecords: () => [],
|
||
matchableTotal: 0,
|
||
});
|
||
|
||
const emit = defineEmits<{
|
||
/** 「去匹配」引导:切到现有库存匹配入口(来源选择卡),清单本身不提供执行动作。 */
|
||
'go-match': [];
|
||
refresh: [];
|
||
/** 其余已落档翻页。 */
|
||
'page-change': [query: { page: number }];
|
||
/** 当前可匹配翻页。 */
|
||
'matchable-page-change': [query: { page: number }];
|
||
}>();
|
||
|
||
const { t } = useI18n();
|
||
|
||
/** 分页页码(本地 UI 态;数据由父级按 page-change 拉取后经 props 回流)。
|
||
* 翻页/收拢统一经 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 }));
|
||
|
||
/**
|
||
* 桶变小后把页码收回最后一页,避免停在空白页。
|
||
* @param page - 当前页码 ref
|
||
* @param total - 该段全量计数
|
||
*/
|
||
function clampPage(page: typeof currentPage, total: number) {
|
||
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
|
||
if (page.value > maxPage) page.value = maxPage;
|
||
}
|
||
|
||
watch(() => props.total, (total = 0) => clampPage(currentPage, total));
|
||
watch(() => props.matchableTotal, (total = 0) => clampPage(matchablePage, total));
|
||
|
||
/**
|
||
* 表格行键:合并后的代表档 id 加内部单号,避免同一单号多行撞键。
|
||
* @param record - 待匹配清单行(可能已按外部单号合计)
|
||
* @returns 行键
|
||
*/
|
||
function rowKey(record: TransferPendingMatchRecord): string {
|
||
return `${record.ledger_record_id}|${record.doc_no}`;
|
||
}
|
||
|
||
/** el-table 行类:注入行定位类(替代旧行 testid)。 */
|
||
function rowClassName({ row }: { row: TransferPendingMatchRecord }): string {
|
||
return `transfer-pending-match-row-${row.doc_no}`;
|
||
}
|
||
|
||
/**
|
||
* 行上记录类型展示文案(入站/出站)。
|
||
* @param kind - 档记录类型;缺省按入站
|
||
*/
|
||
function recordKindLabel(kind?: TransferRecordKind | null): string {
|
||
return kind === 'outbound'
|
||
? t('chat.transfer.streamOutbound')
|
||
: t('chat.transfer.streamInbound');
|
||
}
|
||
|
||
/**
|
||
* 清单单元格展示:空白外部单号显示占位。
|
||
* @param value - 档上的文本;null、undefined、纯空白都视为没有值
|
||
* @returns 去空白后的原文,或占位符
|
||
*/
|
||
function displayCell(value?: string | null): string {
|
||
const text = (value ?? '').trim();
|
||
return text || '—';
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-pending-match-panel">
|
||
<div class="mb-2 flex items-center justify-between gap-2">
|
||
<div class="min-w-0">
|
||
<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>
|
||
<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') }}
|
||
</el-button>
|
||
</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.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>
|
||
</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>
|
||
<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>
|
||
|
||
<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"
|
||
:row-key="rowKey"
|
||
:row-class-name="rowClassName"
|
||
size="small"
|
||
class="text-xs"
|
||
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>
|
||
</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>
|
||
</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>
|
||
<!-- 服务端分页条(单页时隐藏):total=桶全量计数,页码变化统一经 watch 上抛;
|
||
文案走全局 ElConfigProvider 四语言 locale -->
|
||
<el-pagination
|
||
v-if="(total ?? 0) > PAGE_SIZE"
|
||
v-model:current-page="currentPage"
|
||
:total="total ?? 0"
|
||
:page-size="PAGE_SIZE"
|
||
layout="total, prev, pager, next, jumper"
|
||
size="small"
|
||
class="mt-2 justify-end"
|
||
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.pendingMatchOutsideEmpty') }}
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</template>
|