feat(in-transit-transfer): 异常恢复一键重建预检并支持按行批量处理
- 新增 resume_service:可恢复阻断行按(来源×收料日期)分组重建范围预检,收料文件不可用自动触发 RPA 重抓,单组失败不影响其余组 - precheck 新增 list_recent_prechecks 最近预检入口:未执行未过期可继续执行,解决预检卡关闭后无处恢复 - manual_close 支持按 item_ids 批量关闭并带审计,retry/backlog 配合按行口径调整 - 前端三区接线换新:首页待办/预检卡/待处理异常接恢复与批量动作,新增 transferDate 日期工具与 e2e 用例 - i18n chat/errors 四语言同步,technical.md 与 funclist 更新,落行归属解耦与 ERP 写路径两份实施计划
This commit is contained in:
1 parent
42b271f92b
commit
556d3fd3db
35 files changed
+2895
-121
No files matched your search
@@ -48,7 +48,7 @@ describe('transfer.api JSON request contract', () => {
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], business_date: '2026-08-18' }));
|
||||
});
|
||||
|
||||
it('直接生成调拨单 POST 带 application/json', () => {
|
||||
it('生成调拨单 POST 带 application/json', () => {
|
||||
executeTransferPrecheck('TPC-1', ['INV-001']);
|
||||
const [, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(init.method).toBe('POST');
|
||||
|
||||
@@ -10,9 +10,12 @@ import type {
|
||||
TransferActionResult,
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferBatchResumeResponse,
|
||||
TransferBatchResult,
|
||||
TransferExecuteResponse,
|
||||
TransferPrecheckDetail,
|
||||
TransferPrecheckSummary,
|
||||
TransferRecentPrecheck,
|
||||
TransferRunResult,
|
||||
TransferSourceFileStatus,
|
||||
TransferSourceOption,
|
||||
@@ -47,6 +50,10 @@ export const getTransferPrecheck = (precheckId: string) =>
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
|
||||
/** 最近预检列表(未执行、未过期、仍拥有归属行;供一键恢复预检卡) */
|
||||
export const listRecentTransferPrechecks = () =>
|
||||
requestJson<TransferRecentPrecheck[]>(`${BASE}/prechecks/recent`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 确认选择范围并直接生成执行 Run */
|
||||
export const executeTransferPrecheck = (precheckId: string, invoiceNos: string[]) =>
|
||||
requestJson<TransferExecuteResponse>(`${BASE}/prechecks/${precheckId}/execute`, {
|
||||
@@ -97,6 +104,30 @@ export const downloadTransferErpInventory = (runNo: string) =>
|
||||
export const downloadTransferExceptions = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/exceptions.xlsx`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 批量重查库存(待处理池多选;单行隔离,按明细 id 直取) */
|
||||
export const batchRequeryTransferItems = (itemIds: number[]) =>
|
||||
requestJson<TransferBatchResult>(`${BASE}/items/batch-requery`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ item_ids: itemIds }),
|
||||
});
|
||||
|
||||
/** 批量恢复异常项到预检流程(按来源+收料日期分组重建预检;单组隔离) */
|
||||
export const batchResumeTransferItems = (itemIds: number[]) =>
|
||||
requestJson<TransferBatchResumeResponse>(`${BASE}/items/batch-resume`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ item_ids: itemIds }),
|
||||
});
|
||||
|
||||
/** 批量人工关闭异常项(原因整批共用;单行隔离) */
|
||||
export const batchManualCloseTransferItems = (itemIds: number[], reason: string) =>
|
||||
requestJson<TransferBatchResult>(`${BASE}/items/batch-manual-close`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ item_ids: itemIds, reason }),
|
||||
});
|
||||
|
||||
/** 批量重查 ERP 库存(可恢复阻断行;invoice_nos 缺省 = 全部阻断行) */
|
||||
export const requeryTransferItems = (precheckNo: string, invoiceNos?: string[]) =>
|
||||
requestJson<{ precheck_no: string; total: number; results: Array<Record<string, unknown>> }>(
|
||||
|
||||
@@ -1,22 +1,92 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferBacklogSummaryCard.vue
|
||||
用途:待处理异常卡(可恢复/已关闭/结果未知三组)+ 人工重试/人工关闭入口。
|
||||
依赖:props.items、i18n chat.transfer.*。
|
||||
逻辑:result_unknown 只读(无重试/关闭按钮);人工关闭由父组件弹窗处理。
|
||||
用途:待处理异常卡(可恢复/已关闭/结果未知三组)——列与预检窗口一致,
|
||||
支持关键字/结果筛选、多选批量操作(重查/恢复处理/标记无需处理)与行级快捷操作。
|
||||
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
|
||||
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
|
||||
勾选集合为卡片本地态,操作经 emit 交父组件调用批量端点并刷新。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import type { TransferBacklogItem } from '../../types/transfer.types';
|
||||
|
||||
defineProps<{
|
||||
const props = defineProps<{
|
||||
items: TransferBacklogItem[];
|
||||
busy?: boolean;
|
||||
/** 初始结果筛选(首页计数卡切片进入:closed 卡落「已关闭」切片等)。 */
|
||||
initialFilter?: 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
retry: [itemId: number];
|
||||
close: [item: TransferBacklogItem];
|
||||
refresh: [];
|
||||
retry: [itemId: number];
|
||||
resume: [itemIds: number[]];
|
||||
requery: [itemIds: number[]];
|
||||
close: [item: TransferBacklogItem];
|
||||
batchClose: [itemIds: number[]];
|
||||
}>();
|
||||
|
||||
/** 勾选集合(本地视图态;仅可恢复行可勾选)。 */
|
||||
const selectedIds = ref<Set<number>>(new Set());
|
||||
const keyword = ref('');
|
||||
const resultFilter = ref<'all' | 'recoverable' | 'closed' | 'unknown'>(props.initialFilter ?? 'all');
|
||||
|
||||
function isActionable(item: TransferBacklogItem): boolean {
|
||||
return item.status === 'blocked_recoverable';
|
||||
}
|
||||
|
||||
const filtered = computed(() =>
|
||||
props.items.filter((item) => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (kw) {
|
||||
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code]
|
||||
.map((value) => String(value ?? '').toLowerCase());
|
||||
if (!haystack.some((value) => value.includes(kw))) return false;
|
||||
}
|
||||
if (resultFilter.value === 'recoverable' && item.status !== 'blocked_recoverable') return false;
|
||||
if (resultFilter.value === 'closed' && item.status !== 'manually_closed') return false;
|
||||
if (resultFilter.value === 'unknown' && item.status !== 'result_unknown') return false;
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
|
||||
const selectedActionableIds = computed(() =>
|
||||
filtered.value.filter((item) => isActionable(item) && selectedIds.value.has(item.item_id)).map((item) => item.item_id),
|
||||
);
|
||||
|
||||
const allFilteredSelected = computed(() => {
|
||||
const actionable = filtered.value.filter(isActionable);
|
||||
return actionable.length > 0 && actionable.every((item) => selectedIds.value.has(item.item_id));
|
||||
});
|
||||
|
||||
function toggleRow(item: TransferBacklogItem, checked: boolean) {
|
||||
const next = new Set(selectedIds.value);
|
||||
if (checked) next.add(item.item_id);
|
||||
else next.delete(item.item_id);
|
||||
selectedIds.value = next;
|
||||
}
|
||||
|
||||
function toggleAll(checked: boolean) {
|
||||
const next = new Set(selectedIds.value);
|
||||
for (const item of filtered.value.filter(isActionable)) {
|
||||
if (checked) next.add(item.item_id);
|
||||
else next.delete(item.item_id);
|
||||
}
|
||||
selectedIds.value = next;
|
||||
}
|
||||
|
||||
function clearSelection() {
|
||||
selectedIds.value = new Set();
|
||||
}
|
||||
|
||||
/** 行操作后/刷新后清理已消失行的勾选残留。 */
|
||||
function pruneSelection() {
|
||||
const alive = new Set(props.items.map((item) => item.item_id));
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => alive.has(id)));
|
||||
}
|
||||
defineExpose({ pruneSelection });
|
||||
|
||||
function agingLabel(level: string): string {
|
||||
const map: Record<string, string> = {
|
||||
warn_3d: 'chat.transfer.agingWarn',
|
||||
@@ -27,6 +97,10 @@ function agingLabel(level: string): string {
|
||||
};
|
||||
return map[level] ?? 'chat.transfer.agingNormal';
|
||||
}
|
||||
|
||||
function rowKey(item: TransferBacklogItem): string {
|
||||
return `${item.item_id}|${item.invoice_no}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -42,47 +116,179 @@ function agingLabel(level: string): string {
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</div>
|
||||
<ul v-if="items.length" class="flex flex-col gap-1.5">
|
||||
<li
|
||||
v-for="item in items"
|
||||
:key="item.item_id"
|
||||
class="flex items-center justify-between gap-2 rounded-lg border border-subtle px-3 py-2 text-xs"
|
||||
:data-testid="`transfer-backlog-${item.invoice_no}`"
|
||||
|
||||
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区 -->
|
||||
<div v-if="selectedActionableIds.length" class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs font-bold text-secondary" data-testid="transfer-backlog-selected-count">
|
||||
{{ $t('chat.transfer.selectedRows', { count: selectedActionableIds.length }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-backlog-batch-requery"
|
||||
:disabled="busy"
|
||||
@click="emit('requery', selectedActionableIds)"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-secondary">
|
||||
{{ item.invoice_no }}
|
||||
<span class="ml-1 text-muted">{{ item.source_code }}</span>
|
||||
</div>
|
||||
<div class="text-[11px] text-muted">
|
||||
{{ item.reason }} · {{ $t(agingLabel(item.aging_level)) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 gap-1.5">
|
||||
<template v-if="item.status === 'blocked_recoverable'">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-2 py-1 font-bold text-brand-700 hover:bg-brand-50"
|
||||
data-testid="transfer-backlog-retry"
|
||||
@click="emit('retry', item.item_id)"
|
||||
>
|
||||
{{ $t('chat.transfer.retryErp') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-red-200 px-2 py-1 font-bold text-red-600 hover:bg-red-50"
|
||||
data-testid="transfer-backlog-close"
|
||||
@click="emit('close', item)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualClose') }}
|
||||
</button>
|
||||
</template>
|
||||
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-muted">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
{{ $t('chat.transfer.requeryRow') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-backlog-batch-resume"
|
||||
:disabled="busy"
|
||||
@click="emit('resume', selectedActionableIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.resumeAction') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-red-200 bg-red-50 px-3 py-1 text-xs font-bold text-red-600 transition hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-backlog-batch-close"
|
||||
:disabled="busy"
|
||||
@click="emit('batchClose', selectedActionableIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualClose') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
data-testid="transfer-backlog-clear-selection"
|
||||
@click="clearSelection"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSelection') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="w-56 rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-backlog-filter"
|
||||
/>
|
||||
<select
|
||||
v-model="resultFilter"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-backlog-result-filter"
|
||||
>
|
||||
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
|
||||
<option value="recoverable">{{ $t('chat.transfer.homeRecoverable') }}</option>
|
||||
<option value="closed">{{ $t('chat.transfer.homeClosed') }}</option>
|
||||
<option value="unknown">{{ $t('chat.transfer.homeUnknown') }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div v-if="filtered.length" class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1180px] text-xs" data-testid="transfer-backlog-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
|
||||
<th class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allFilteredSelected"
|
||||
data-testid="transfer-backlog-select-all"
|
||||
@change="toggleAll(($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colSource') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromQty') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colAging') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colAction') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in filtered"
|
||||
:key="rowKey(item)"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': !isActionable(item) }"
|
||||
:data-testid="`transfer-backlog-${item.invoice_no}`"
|
||||
>
|
||||
<td class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selectedIds.has(item.item_id)"
|
||||
:disabled="!isActionable(item) || busy"
|
||||
:data-testid="`transfer-backlog-check-${item.invoice_no}`"
|
||||
@change="toggleRow(item, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<td class="p-2">{{ item.source_code }}</td>
|
||||
<td class="p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="p-2">{{ item.receipt_date || '—' }}</td>
|
||||
<td class="p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name || '—' }}</td>
|
||||
<td class="p-2">{{ item.from_warehouse || '—' }}</td>
|
||||
<td class="p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
|
||||
<td class="p-2">{{ item.external_quantity ?? '—' }}</td>
|
||||
<td class="p-2">{{ item.to_warehouse || '—' }}</td>
|
||||
<td class="p-2">{{ item.receipt_quantity ?? '—' }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-red-50 text-red-700': item.status === 'blocked_recoverable',
|
||||
'bg-amber-50 text-amber-700': item.status === 'result_unknown',
|
||||
'bg-surface-soft text-muted': item.status === 'manually_closed',
|
||||
}"
|
||||
:title="item.reason || undefined"
|
||||
data-testid="transfer-backlog-result"
|
||||
>
|
||||
{{
|
||||
item.status === 'blocked_recoverable' ? $t('chat.transfer.resultBlocked')
|
||||
: item.status === 'result_unknown' ? $t('chat.transfer.resultUnknown')
|
||||
: $t('chat.transfer.statusClosed')
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
<td class="p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
|
||||
<td class="p-2">
|
||||
<template v-if="isActionable(item)">
|
||||
<button
|
||||
type="button"
|
||||
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-backlog-requery-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('retry', item.item_id)"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-backlog-resume-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('resume', [item.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.resumeAction') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-1 py-0.5 text-[10px] font-bold text-red-600 transition hover:bg-red-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-backlog-close-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('close', item)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualClose') }}
|
||||
</button>
|
||||
</template>
|
||||
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-muted">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.noBacklog') }}
|
||||
</div>
|
||||
|
||||
@@ -89,18 +89,44 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
expect(api.listTransferSources).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('点击历史待办计数卡独立触发 backlog 卡片', async () => {
|
||||
it('点击历史待办计数卡独立触发 backlog 卡片,并按计数卡切片初始筛选', async () => {
|
||||
// [断言意图] 三张计数卡不再落入同一份全量列表:可恢复/已关闭/结果未知
|
||||
// 各自带对应 resultFilter 打开待处理池(否则 0 行的已关闭/结果未知被 50 行可恢复淹没)。
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
|
||||
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal' },
|
||||
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2',
|
||||
status: 'manually_closed', reason: '线下处理', age_days: 2, aging_level: 'closed' },
|
||||
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-003', material_no: 'MAT-3',
|
||||
status: 'result_unknown', reason: '待人工核实', age_days: 3, aging_level: 'result_unknown' },
|
||||
]);
|
||||
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.find('[data-testid="transfer-home-recoverable"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
expect(api.listTransferBacklog).toHaveBeenCalled();
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('recoverable');
|
||||
// 切片后仅可见对应状态行。
|
||||
expect(wrapper.text()).toContain('INV-001');
|
||||
expect(wrapper.text()).not.toContain('INV-002');
|
||||
|
||||
await wrapper.find('[data-testid="transfer-home-back"]').trigger('click');
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-closed"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('closed');
|
||||
expect(wrapper.text()).toContain('INV-002');
|
||||
expect(wrapper.text()).not.toContain('INV-001');
|
||||
|
||||
await wrapper.find('[data-testid="transfer-home-back"]').trigger('click');
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-unknown"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('unknown');
|
||||
expect(wrapper.text()).toContain('INV-003');
|
||||
});
|
||||
|
||||
it('子视图提供“返回首页”并切回 home', async () => {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferHomePanel.vue
|
||||
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——home 视图展示标题、今日待办
|
||||
入口与三张历史待办计数卡;点击入口独立触发 source-select / backlog 卡片。
|
||||
入口、最近预检(一键恢复)与三张历史待办计数卡;点击入口独立触发
|
||||
source-select / backlog / 预检恢复卡片。
|
||||
依赖:TransferMessageView(复用自驱动卡片)、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:home 时只消费 backlogSummary 计数;非 home 时渲染 TransferMessageView。
|
||||
卡片不注入消息流,因此无需后端 ChatLog 消息(决策:补首页入口 A 方案)。
|
||||
逻辑:home 时消费 backlogSummary 计数与 recentPrechecks 列表;非 home 时渲染
|
||||
TransferMessageView。卡片不注入消息流,因此无需后端 ChatLog 消息。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
@@ -20,18 +21,33 @@ const emit = defineEmits<{
|
||||
'flow-active': [active: boolean];
|
||||
}>();
|
||||
|
||||
type HomeView = 'home' | 'source-select' | 'backlog';
|
||||
type HomeView = 'home' | 'source-select' | 'backlog' | 'precheck-restore';
|
||||
/** 待处理池结果筛选(与 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)。 */
|
||||
function openBacklog(filter: BacklogFilter) {
|
||||
backlogFilter.value = filter;
|
||||
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 transfer.loadBacklog();
|
||||
await Promise.all([
|
||||
transfer.loadBacklog().catch(() => undefined),
|
||||
transfer.loadRecentPrechecks().catch(() => undefined),
|
||||
]);
|
||||
}
|
||||
|
||||
onMounted(() => { void loadHomeSummary(); });
|
||||
@@ -39,12 +55,19 @@ watch(view, () => { void loadHomeSummary(); });
|
||||
|
||||
const displayAgentName = computed(() => props.agentName || '在途仓自动调拨');
|
||||
|
||||
/** 非 home 视图把当前入口透传给自驱动的 TransferMessageView(决定 source-select 或 backlog)。 */
|
||||
const childPayload = computed(() => (
|
||||
view.value === 'source-select'
|
||||
? { kind: 'source-select' }
|
||||
: { kind: 'backlog' }
|
||||
));
|
||||
/** 确认窗口剩余分钟(前端按 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));
|
||||
}
|
||||
|
||||
/** 非 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 };
|
||||
return { kind: 'backlog', filter: backlogFilter.value };
|
||||
});
|
||||
|
||||
function goBack() {
|
||||
view.value = 'home';
|
||||
@@ -79,6 +102,35 @@ 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">
|
||||
<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'"
|
||||
>
|
||||
<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>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 历史待办 -->
|
||||
<section aria-label="历史待办">
|
||||
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeHistoryLabel') }}</p>
|
||||
@@ -87,7 +139,7 @@ function goBack() {
|
||||
type="button"
|
||||
data-testid="transfer-home-recoverable"
|
||||
class="rounded-2xl border border-brand-200 bg-brand-50 p-4 text-left transition-colors hover:bg-brand-100"
|
||||
@click="view = 'backlog'"
|
||||
@click="openBacklog('recoverable')"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-brand-600">{{ transfer.backlogSummary.value?.recoverable ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeRecoverable') }}</b>
|
||||
@@ -97,7 +149,7 @@ function goBack() {
|
||||
type="button"
|
||||
data-testid="transfer-home-closed"
|
||||
class="rounded-2xl border border-default bg-surface p-4 text-left transition-colors hover:border-brand-200 hover:bg-brand-50"
|
||||
@click="view = 'backlog'"
|
||||
@click="openBacklog('closed')"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-secondary">{{ transfer.backlogSummary.value?.closed ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeClosed') }}</b>
|
||||
@@ -107,7 +159,7 @@ function goBack() {
|
||||
type="button"
|
||||
data-testid="transfer-home-unknown"
|
||||
class="rounded-2xl border border-amber-200 bg-amber-50 p-4 text-left transition-colors hover:bg-amber-100"
|
||||
@click="view = 'backlog'"
|
||||
@click="openBacklog('unknown')"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-amber-600">{{ transfer.backlogSummary.value?.unknown ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeUnknown') }}</b>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferManualCloseDialog.vue
|
||||
用途:人工关闭弹窗(原因必填;关闭后永久排除,历史保留)。
|
||||
依赖:props(open/invoiceNo)、i18n chat.transfer.*。
|
||||
用途:人工关闭弹窗(原因必填;关闭后永久排除,历史保留);count>1 时按批量文案展示。
|
||||
依赖:props(open/invoiceNo/count)、i18n chat.transfer.*。
|
||||
逻辑:原因为空时确认按钮禁用;确认时 emit confirm(reason)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -10,6 +10,8 @@ import { ref, watch } from 'vue';
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
invoiceNo: string;
|
||||
/** 批量关闭的行数;>1 时忽略 invoiceNo,标题/提示切换为批量文案。 */
|
||||
count?: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -34,8 +36,13 @@ watch(
|
||||
data-testid="transfer-manual-close-dialog"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<h3 class="text-base font-bold text-primary">{{ $t('chat.transfer.manualCloseTitle') }}</h3>
|
||||
<p class="mt-1 text-xs text-muted">{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</p>
|
||||
<h3 class="text-base font-bold text-primary">
|
||||
{{ $t(count && count > 1 ? 'chat.transfer.batchCloseTitle' : 'chat.transfer.manualCloseTitle', count && count > 1 ? { count } : {}) }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
<template v-if="count && count > 1">{{ $t('chat.transfer.manualCloseHint') }}</template>
|
||||
<template v-else>{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</template>
|
||||
</p>
|
||||
<textarea
|
||||
v-model="reason"
|
||||
rows="3"
|
||||
|
||||
@@ -12,10 +12,14 @@ import i18n from '@/i18n';
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferPrecheck: vi.fn(),
|
||||
getTransferPrecheck: vi.fn(),
|
||||
listRecentTransferPrechecks: vi.fn(),
|
||||
executeTransferPrecheck: vi.fn(),
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
batchRequeryTransferItems: vi.fn(),
|
||||
batchResumeTransferItems: vi.fn(),
|
||||
batchManualCloseTransferItems: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
@@ -27,6 +31,7 @@ const api = vi.hoisted(() => ({
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
import { eligibleReceiptDateTo } from './transferDate';
|
||||
|
||||
const payload = {
|
||||
kind: 'precheck',
|
||||
@@ -85,7 +90,7 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
expect((wrapper.find('[data-testid="transfer-check-INV-001"]').element as HTMLInputElement).checked).toBe(true);
|
||||
});
|
||||
|
||||
it('点击“直接生成调拨单”调用 execute API 并切换为结果卡', async () => {
|
||||
it('点击“生成调拨单”调用 execute API 并切换为结果卡', async () => {
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload },
|
||||
global: { plugins: [i18n] },
|
||||
@@ -116,10 +121,12 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
expect(wrapper.text()).not.toContain('审计');
|
||||
});
|
||||
|
||||
it('backlog 视图拉取待处理列表,重试/关闭调用对应 API', async () => {
|
||||
it('backlog 视图拉取待处理列表,行级重查/关闭调用对应 API', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([{
|
||||
item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
|
||||
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal',
|
||||
receipt_date: '2026-08-05', material_name: '连接器组件', from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01', lot_no: 'LOT-10', receipt_quantity: '1200', external_quantity: '1000',
|
||||
}]);
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 1, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
@@ -135,18 +142,132 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('INV-001');
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-retry"]').trigger('click');
|
||||
// 行级重查(原「重新查询 ERP」改名「重查」,复用单行端点)。
|
||||
await wrapper.find('[data-testid="transfer-backlog-requery-INV-001"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.retryTransferItem).toHaveBeenCalledWith(7);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-close"]').trigger('click');
|
||||
// 行级关闭:弹窗原因必填后提交。
|
||||
await wrapper.find('[data-testid="transfer-backlog-close-INV-001"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('线下已处理');
|
||||
await wrapper.find('[data-testid="transfer-close-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.manualCloseTransferItem).toHaveBeenCalledWith(7, '线下已处理');
|
||||
});
|
||||
|
||||
it('来源实例选择:加载列表 → 确认范围 → 创建预检并切换预检卡', async () => {
|
||||
it('backlog 批量:勾选后操作条出现,重查/恢复/批量关闭调用批量端点', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
|
||||
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2', status: 'result_unknown', reason: '', age_days: 2, aging_level: 'result_unknown' },
|
||||
]);
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 1, closed: 0, unknown: 1, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
api.batchRequeryTransferItems.mockResolvedValue({ total: 1, results: [{ item_id: 7, ok: true, status: 'ready_to_execute' }] });
|
||||
api.batchResumeTransferItems.mockResolvedValue({ prechecks: [], file_fetching: [], skipped: [] });
|
||||
api.batchManualCloseTransferItems.mockResolvedValue({ total: 1, results: [{ item_id: 7, ok: true, status: 'manually_closed' }] });
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'backlog' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// result_unknown 行 checkbox 禁用(只读隔离)。
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-check-INV-002"]').element as HTMLInputElement).disabled).toBe(true);
|
||||
// 未勾选时批量操作条不存在。
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-batch-requery"]').exists()).toBe(false);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-batch-requery"]').exists()).toBe(true);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-requery"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7]);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-resume"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.batchResumeTransferItems).toHaveBeenCalledWith([7]);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-close"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('整批线下处理');
|
||||
await wrapper.find('[data-testid="transfer-close-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.batchManualCloseTransferItems).toHaveBeenCalledWith([7], '整批线下处理');
|
||||
});
|
||||
|
||||
it('最近预检入口:仅携带 precheck_id 时按 ID 恢复预检卡', async () => {
|
||||
api.getTransferPrecheck.mockResolvedValue({
|
||||
summary: payload.summary,
|
||||
items: payload.items,
|
||||
sources: payload.sources,
|
||||
});
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'precheck', precheck_id: 'TPC-1' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(api.getTransferPrecheck).toHaveBeenCalledWith('TPC-1');
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('恢复处理成功返回预检时切换预检卡', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
|
||||
]);
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 1, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
api.batchResumeTransferItems.mockResolvedValue({
|
||||
prechecks: [{ precheck_no: 'TPC-9', source_code: 'DBS-AWSBI', receipt_date: '2026-08-05', selected_item_count: 1, executable_count: 1 }],
|
||||
file_fetching: [],
|
||||
skipped: [],
|
||||
});
|
||||
api.getTransferPrecheck.mockResolvedValue({ summary: payload.summary, items: payload.items, sources: payload.sources });
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'backlog' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-resume"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.getTransferPrecheck).toHaveBeenCalledWith('TPC-9');
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('恢复处理全部仍阻断(0 可执行)时不跳预检卡,留在待处理池', async () => {
|
||||
// [断言意图] ERP 未修正时恢复的正确结果是"仍阻断":不打开全阻断的壳预检卡,
|
||||
// 行留在待处理池(fail-closed),避免"恢复了个寂寞"的误导性跳转。
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
|
||||
]);
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 1, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
api.batchResumeTransferItems.mockResolvedValue({
|
||||
prechecks: [{ precheck_no: 'TPC-9', source_code: 'DBS-AWSBI', receipt_date: '2026-08-05', selected_item_count: 1, executable_count: 0 }],
|
||||
file_fetching: [],
|
||||
skipped: [],
|
||||
});
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'backlog' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-resume"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.getTransferPrecheck).not.toHaveBeenCalled();
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('来源实例选择:加载列表 → 确认范围 → 创建预检并切换预检卡(默认携带 D+1 日期范围)', async () => {
|
||||
api.listTransferSources.mockResolvedValue([
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
]);
|
||||
@@ -167,7 +288,12 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.createTransferPrecheck).toHaveBeenCalledWith({ source_codes: ['DBS-AWSBI'], transfer_type: 'in_transit_to_hub' });
|
||||
const cutoff = eligibleReceiptDateTo();
|
||||
expect(api.createTransferPrecheck).toHaveBeenCalledWith({
|
||||
source_codes: ['DBS-AWSBI'], business_date: undefined,
|
||||
receipt_date_from: cutoff, receipt_date_to: cutoff,
|
||||
transfer_type: 'in_transit_to_hub',
|
||||
});
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,13 +1,15 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferMessageView.vue
|
||||
用途:在途调拨消息卡片的自驱动挂载视图——按 payload 形态渲染卡片,并把卡片按钮
|
||||
(直接生成调拨单 / 下载 / 重试 / 关闭)经 useChatTransfer 真实调用 API。
|
||||
(生成调拨单 / 下载 / 重查 / 恢复 / 关闭)经 useChatTransfer 真实调用 API。
|
||||
依赖:Transfer*Card、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:payload 作为初始状态(ChatLog 回放);执行后切换为结果卡;下载走 requestBlob;
|
||||
逻辑:payload 作为初始状态(ChatLog 回放);仅携带 precheck_id 时按 ID 恢复预检卡
|
||||
(最近预检入口);执行后切换为结果卡;下载走 requestBlob;
|
||||
不展示执行审计入口(决策 19)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import TransferPrecheckCard from './TransferPrecheckCard.vue';
|
||||
import TransferFileProgressCard from './TransferFileProgressCard.vue';
|
||||
import TransferProgressCard from './TransferProgressCard.vue';
|
||||
@@ -32,7 +34,8 @@ const props = defineProps<{
|
||||
payload?: Record<string, unknown> | null;
|
||||
}>();
|
||||
|
||||
const { error: notifyError } = useMessage();
|
||||
const { t } = useI18n();
|
||||
const { error: notifyError, success: notifySuccess, warning: notifyWarning } = useMessage();
|
||||
|
||||
/** 统一错误提示:BusinessError 带本地化 message,其余回退到 String(e)。 */
|
||||
function reportError(e: unknown) {
|
||||
@@ -41,6 +44,12 @@ function reportError(e: unknown) {
|
||||
|
||||
const kind = computed(() => String(props.payload?.kind ?? 'precheck'));
|
||||
const mode = ref(kind.value);
|
||||
/** backlog 初始筛选(首页计数卡切片进入:recoverable/closed/unknown;白名单外回落 all)。 */
|
||||
const backlogInitialFilter = computed<'all' | 'recoverable' | 'closed' | 'unknown'>(() => {
|
||||
const value = String(props.payload?.filter ?? 'all');
|
||||
const allowed = ['all', 'recoverable', 'closed', 'unknown'] as const;
|
||||
return (allowed as readonly string[]).includes(value) ? (value as (typeof allowed)[number]) : 'all';
|
||||
});
|
||||
const summaryRef = ref<TransferPrecheckSummary | null>((props.payload?.summary as TransferPrecheckSummary) ?? null);
|
||||
const items = ref<TransferPrecheckItem[]>((props.payload?.items as TransferPrecheckItem[]) ?? []);
|
||||
const runNo = ref(String(props.payload?.run_no ?? ''));
|
||||
@@ -48,6 +57,8 @@ const status = ref(String(props.payload?.status ?? 'executing'));
|
||||
const run = ref<TransferRunResult | null>((props.payload?.run as TransferRunResult) ?? null);
|
||||
const busy = ref(false);
|
||||
const closeTarget = ref<TransferBacklogItem | null>(null);
|
||||
/** 批量标记无需处理的明细 id 集合(与单行关闭共用同一弹窗)。 */
|
||||
const batchCloseIds = ref<number[]>([]);
|
||||
/** 正在重试收料 RPA 的来源编码集合(按来源独立展示重试中)。 */
|
||||
const retryingSource = ref<Set<string>>(new Set());
|
||||
|
||||
@@ -61,8 +72,27 @@ onMounted(() => {
|
||||
if (kind.value === 'source-select') {
|
||||
void transfer.loadSources();
|
||||
}
|
||||
// 最近预检入口:仅携带 precheck_id 无 summary,按 ID 恢复预检进度与明细。
|
||||
if (kind.value === 'precheck' && !summaryRef.value && props.payload?.precheck_id) {
|
||||
void restoreById(String(props.payload.precheck_id));
|
||||
}
|
||||
});
|
||||
|
||||
/** 按预检号恢复预检卡(GET /prechecks/{id},页面刷新/最近预检入口共用)。 */
|
||||
async function restoreById(precheckId: string) {
|
||||
busy.value = true;
|
||||
try {
|
||||
const detail = await transfer.restorePrecheckById(precheckId);
|
||||
mode.value = 'precheck';
|
||||
summaryRef.value = detail.summary;
|
||||
items.value = detail.items;
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** payload 更新时重置本地状态(历史回放/刷新);初始化组合式函数上下文 */
|
||||
function applyPayload(payload?: Record<string, unknown> | null) {
|
||||
if (!payload) return;
|
||||
@@ -178,16 +208,87 @@ async function onBacklogRetry(itemId: number) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量重查(待处理池多选):逐行隔离,完成后刷新列表并弹汇总。 */
|
||||
async function onBacklogRequery(itemIds: number[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await transfer.batchRequery(itemIds);
|
||||
const ok = result.results.filter((entry) => entry.ok).length;
|
||||
notifySuccess(t('chat.transfer.toastRequeryDone', { ok, failed: result.total - ok }));
|
||||
await transfer.loadBacklog();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复处理(行级/多选):按(来源, 收料日期)分组重建预检。仅当重建预检
|
||||
* 含可执行行才切换预检卡(其余份数引导到「最近预检」);全部仍阻断(ERP
|
||||
* 未修正)不跳转,留在待处理池并明确提示;文件不可用的来源已触发重抓。 */
|
||||
async function onBacklogResume(itemIds: number[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await transfer.batchResume(itemIds);
|
||||
await transfer.loadBacklog();
|
||||
const actionable = result.prechecks.filter((entry) => entry.executable_count > 0);
|
||||
const firstActionable = actionable[0];
|
||||
if (firstActionable) {
|
||||
const detail = await transfer.restorePrecheckById(firstActionable.precheck_no);
|
||||
mode.value = 'precheck';
|
||||
summaryRef.value = detail.summary;
|
||||
items.value = detail.items;
|
||||
if (actionable.length > 1) {
|
||||
notifySuccess(t('chat.transfer.toastResumeOpened', { count: actionable.length }));
|
||||
}
|
||||
}
|
||||
const stillBlockedCount = result.prechecks
|
||||
.filter((entry) => entry.executable_count === 0)
|
||||
.reduce((sum, entry) => sum + entry.selected_item_count, 0);
|
||||
if (stillBlockedCount) {
|
||||
notifyWarning(t('chat.transfer.toastResumeStillBlocked', { count: stillBlockedCount }));
|
||||
}
|
||||
const refetching = result.file_fetching.filter((entry) => entry.ok).map((entry) => entry.source_code);
|
||||
if (refetching.length) {
|
||||
notifyWarning(t('chat.transfer.toastResumeRefetching', { sources: refetching.join('、') }));
|
||||
}
|
||||
const failedCount = result.file_fetching.filter((entry) => !entry.ok).length + result.skipped.length;
|
||||
if (failedCount) {
|
||||
notifyWarning(t('chat.transfer.toastResumeSkipped', { count: failedCount }));
|
||||
}
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onBacklogClose(item: TransferBacklogItem) {
|
||||
closeTarget.value = item;
|
||||
}
|
||||
|
||||
/** 批量标记无需处理:复用关闭弹窗(批量文案)。 */
|
||||
function onBacklogBatchClose(itemIds: number[]) {
|
||||
batchCloseIds.value = itemIds;
|
||||
}
|
||||
|
||||
function onCancelClose() {
|
||||
closeTarget.value = null;
|
||||
batchCloseIds.value = [];
|
||||
}
|
||||
|
||||
async function onCloseConfirm(reason: string) {
|
||||
if (!closeTarget.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.manualClose(closeTarget.value.item_id, reason);
|
||||
closeTarget.value = null;
|
||||
if (batchCloseIds.value.length) {
|
||||
const result = await transfer.batchManualClose(batchCloseIds.value, reason);
|
||||
const ok = result.results.filter((entry) => entry.ok).length;
|
||||
notifySuccess(t('chat.transfer.toastCloseDone', { ok, failed: result.total - ok }));
|
||||
batchCloseIds.value = [];
|
||||
} else if (closeTarget.value) {
|
||||
await transfer.manualClose(closeTarget.value.item_id, reason);
|
||||
closeTarget.value = null;
|
||||
}
|
||||
await transfer.loadBacklog();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
@@ -274,16 +375,22 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
<TransferBacklogSummaryCard
|
||||
v-else-if="mode === 'backlog'"
|
||||
:items="transfer.backlog.value"
|
||||
:busy="busy"
|
||||
:initial-filter="backlogInitialFilter"
|
||||
@retry="onBacklogRetry"
|
||||
@requery="onBacklogRequery"
|
||||
@resume="onBacklogResume"
|
||||
@close="onBacklogClose"
|
||||
@batch-close="onBacklogBatchClose"
|
||||
@refresh="() => transfer.loadBacklog()"
|
||||
/>
|
||||
<TransferManualCloseDialog
|
||||
v-if="closeTarget"
|
||||
:open="Boolean(closeTarget)"
|
||||
:invoice-no="closeTarget.invoice_no"
|
||||
v-if="closeTarget || batchCloseIds.length"
|
||||
:open="Boolean(closeTarget || batchCloseIds.length)"
|
||||
:invoice-no="closeTarget?.invoice_no ?? ''"
|
||||
:count="batchCloseIds.length"
|
||||
@confirm="onCloseConfirm"
|
||||
@cancel="closeTarget = null"
|
||||
@cancel="onCancelClose"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -10,6 +10,7 @@ import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
|
||||
import { eligibleReceiptDateTo } from './transferDate';
|
||||
|
||||
const readySources = [
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI 在途仓', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
@@ -85,7 +86,33 @@ describe('TransferSourceSelectCard', () => {
|
||||
it('D+1 规则提示收进 ⓘ 悬浮(title),不再平铺占宽', () => {
|
||||
// [断言意图] 长规则文案通过原生 title 渐进披露,紧凑日期行不换行错位。
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.find('[data-testid="transfer-source-date-hint"]').attributes('title')).toBe('截止不超出 D+1 规则(业务日期前一天)');
|
||||
const title = wrapper.find('[data-testid="transfer-source-date-hint"]').attributes('title') ?? '';
|
||||
expect(title).toContain('D+1 规则');
|
||||
expect(title).toContain('业务日期前一天');
|
||||
});
|
||||
|
||||
it('收料日期默认为 D+1 规则日期(T-1)且上限锁定(输入期限制)', () => {
|
||||
// [断言意图] 默认值与 max 均为上海口径 T-1,未来日期在选择器层面不可选。
|
||||
const wrapper = mountCard();
|
||||
const from = wrapper.find('[data-testid="transfer-source-date-from"]').element as HTMLInputElement;
|
||||
const to = wrapper.find('[data-testid="transfer-source-date-to"]').element as HTMLInputElement;
|
||||
const cutoff = eligibleReceiptDateTo();
|
||||
expect(from.value).toBe(cutoff);
|
||||
expect(to.value).toBe(cutoff);
|
||||
expect(from.max).toBe(cutoff);
|
||||
expect(to.max).toBe(cutoff);
|
||||
});
|
||||
|
||||
it('起始晚于截止时行内提示并禁用确认(不等提交报错)', async () => {
|
||||
// [断言意图] 日期维护期即时卡控:非法区间直接禁用确认并显示行内红字。
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-date-from"]').setValue('2026-09-20');
|
||||
await wrapper.find('[data-testid="transfer-source-date-to"]').setValue('2026-09-10');
|
||||
expect(wrapper.find('[data-testid="transfer-source-date-invalid"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-source-confirm"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
await wrapper.find('[data-testid="transfer-source-date-to"]').setValue('2026-09-22');
|
||||
expect(wrapper.find('[data-testid="transfer-source-date-invalid"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('“只选可重试”勾选无文件/失败来源', async () => {
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { eligibleReceiptDateTo } from './transferDate';
|
||||
import type { TransferSourceOption, TransferType } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -33,9 +34,18 @@ const { warning: notifyWarning } = useMessage();
|
||||
const { t } = useI18n();
|
||||
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
/** 收料日期范围(预检查询范围);截止不得超出 D+1 规则(后端卡控)。 */
|
||||
const dateFrom = ref('');
|
||||
const dateTo = ref('');
|
||||
/** 收料日期范围(预检查询范围):默认 D+1 规则日期(T-1),上限同(输入期限制,
|
||||
* 不等提交报错);后端 RECEIPT_DATE_RANGE_INVALID 卡控保留为双保险。 */
|
||||
const maxReceiptDate = eligibleReceiptDateTo();
|
||||
const dateFrom = ref(maxReceiptDate);
|
||||
const dateTo = ref(maxReceiptDate);
|
||||
|
||||
/** 起始不得晚于截止(清空视为不限,提交 undefined)。 */
|
||||
const dateRangeInvalid = computed(() => {
|
||||
const from = dateFrom.value || null;
|
||||
const to = dateTo.value || null;
|
||||
return from !== null && to !== null && from > to;
|
||||
});
|
||||
/** 调拨业务类型:决定本次预检纳入哪些收料数据;一期仅类型 1 开放。 */
|
||||
const transferType = ref<TransferType>('in_transit_to_hub');
|
||||
|
||||
@@ -70,7 +80,9 @@ const batchRetryDisabled = computed(() => props.busy || selectedRetryableCount.v
|
||||
const selectedHasReadyFile = computed(() =>
|
||||
[...selected.value].some((code) => props.sources.find((s) => s.source_code === code)?.has_ready_file),
|
||||
);
|
||||
const confirmDisabled = computed(() => props.busy || selectedCount.value === 0 || !selectedHasReadyFile.value);
|
||||
const confirmDisabled = computed(() =>
|
||||
props.busy || selectedCount.value === 0 || !selectedHasReadyFile.value || dateRangeInvalid.value,
|
||||
);
|
||||
const downloadDisabled = computed(() => props.busy || !selectedHasReadyFile.value);
|
||||
|
||||
function toggle(sourceCode: string, checked: boolean) {
|
||||
@@ -170,6 +182,7 @@ function confirm() {
|
||||
<input
|
||||
v-model="dateFrom"
|
||||
type="date"
|
||||
:max="maxReceiptDate"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-source-date-from"
|
||||
/>
|
||||
@@ -177,6 +190,8 @@ function confirm() {
|
||||
<input
|
||||
v-model="dateTo"
|
||||
type="date"
|
||||
:max="maxReceiptDate"
|
||||
:min="dateFrom || undefined"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-source-date-to"
|
||||
/>
|
||||
@@ -186,6 +201,10 @@ function confirm() {
|
||||
:title="$t('chat.transfer.receiptDateHint')"
|
||||
data-testid="transfer-source-date-hint"
|
||||
>ⓘ</span>
|
||||
<!-- 输入期校验:起始晚于截止时行内提示并禁用确认(不等提交报错)。 -->
|
||||
<span v-if="dateRangeInvalid" class="text-xs font-bold text-red-600" data-testid="transfer-source-date-invalid">
|
||||
{{ $t('chat.transfer.receiptDateInvalid') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferDate.ts
|
||||
* 用途:在途调拨业务日期工具——按 Asia/Shanghai 计算业务日期(T)与
|
||||
* D+1 成熟规则的可预检截止日(T-1),与后端 date_policy 完全同口径。
|
||||
* 依赖:无(纯函数,便于单测)。
|
||||
* 逻辑:浏览器本地时区不可靠(部署/用户时区任意),必须固定上海时区口径,
|
||||
* 否则前端日期上限与后端 TRANSFER.RECEIPT_DATE_RANGE_INVALID 卡控会漂移。
|
||||
*/
|
||||
|
||||
/** Asia/Shanghai 当前业务日期(YYYY-MM-DD)。 */
|
||||
export function shanghaiBusinessDate(now: Date = new Date()): string {
|
||||
// en-CA 输出恰为 ISO YYYY-MM-DD(locale 无关的稳定格式技巧)。
|
||||
return new Intl.DateTimeFormat('en-CA', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
}).format(now);
|
||||
}
|
||||
|
||||
/** D+1 规则可预检截止日(业务日期 T - 1 天,YYYY-MM-DD)。 */
|
||||
export function eligibleReceiptDateTo(now: Date = new Date()): string {
|
||||
const business = new Date(`${shanghaiBusinessDate(now)}T00:00:00Z`);
|
||||
business.setUTCDate(business.getUTCDate() - 1);
|
||||
return business.toISOString().slice(0, 10);
|
||||
}
|
||||
@@ -9,6 +9,9 @@
|
||||
import { computed, ref, type Ref } from 'vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
batchManualCloseTransferItems,
|
||||
batchResumeTransferItems,
|
||||
batchRequeryTransferItems,
|
||||
cancelTransferRun,
|
||||
createTransferPrecheck,
|
||||
downloadTransferErpInventory,
|
||||
@@ -18,6 +21,7 @@ import {
|
||||
getTransferBacklogSummary,
|
||||
getTransferPrecheck,
|
||||
getTransferRun,
|
||||
listRecentTransferPrechecks,
|
||||
listTransferBacklog,
|
||||
listTransferSources,
|
||||
manualCloseTransferItem,
|
||||
@@ -27,9 +31,12 @@ import {
|
||||
import type {
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferBatchResumeResponse,
|
||||
TransferBatchResult,
|
||||
TransferPrecheckDetail,
|
||||
TransferPrecheckItem,
|
||||
TransferPrecheckSummary,
|
||||
TransferRecentPrecheck,
|
||||
TransferRunResult,
|
||||
TransferSourceOption,
|
||||
TransferSourceProgress,
|
||||
@@ -47,6 +54,7 @@ export function useChatTransfer() {
|
||||
const run = ref<TransferRunResult | null>(null);
|
||||
const backlog = ref<TransferBacklogItem[]>([]);
|
||||
const backlogSummary = ref<TransferBacklogSummary | null>(null);
|
||||
const recentPrechecks = ref<TransferRecentPrecheck[]>([]);
|
||||
const sourceOptions = ref<TransferSourceOption[]>([]);
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
const busy = ref(false);
|
||||
@@ -210,6 +218,35 @@ export function useChatTransfer() {
|
||||
return { items, summary };
|
||||
}
|
||||
|
||||
/** 加载最近预检(未执行、未过期、仍拥有归属行;供一键恢复预检卡) */
|
||||
async function loadRecentPrechecks() {
|
||||
recentPrechecks.value = await listRecentTransferPrechecks();
|
||||
return recentPrechecks.value;
|
||||
}
|
||||
|
||||
/** 按预检号恢复预检进度(最近预检入口 → 预检卡) */
|
||||
async function restorePrecheckById(id: string) {
|
||||
const detail = await getTransferPrecheck(id);
|
||||
precheckId.value = detail.summary.precheck_id;
|
||||
applyDetail(detail);
|
||||
return detail;
|
||||
}
|
||||
|
||||
/** 批量重查库存(单行隔离,结果由调用方刷新列表后展示) */
|
||||
async function batchRequery(itemIds: number[]): Promise<TransferBatchResult> {
|
||||
return batchRequeryTransferItems(itemIds);
|
||||
}
|
||||
|
||||
/** 批量恢复处理:按(来源, 收料日期)分组重建预检,返回预检/重抓/跳过明细 */
|
||||
async function batchResume(itemIds: number[]): Promise<TransferBatchResumeResponse> {
|
||||
return batchResumeTransferItems(itemIds);
|
||||
}
|
||||
|
||||
/** 批量人工关闭(原因整批共用;单行隔离) */
|
||||
async function batchManualClose(itemIds: number[], reason: string): Promise<TransferBatchResult> {
|
||||
return batchManualCloseTransferItems(itemIds, reason);
|
||||
}
|
||||
|
||||
function saveBlob(blob: Blob, filename: string) {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
@@ -228,6 +265,7 @@ export function useChatTransfer() {
|
||||
run.value = null;
|
||||
backlog.value = [];
|
||||
backlogSummary.value = null;
|
||||
recentPrechecks.value = [];
|
||||
sourceOptions.value = [];
|
||||
selected.value = new Set();
|
||||
error.value = '';
|
||||
@@ -242,6 +280,7 @@ export function useChatTransfer() {
|
||||
run,
|
||||
backlog,
|
||||
backlogSummary,
|
||||
recentPrechecks,
|
||||
sourceOptions,
|
||||
selected,
|
||||
selectedCount,
|
||||
@@ -260,6 +299,11 @@ export function useChatTransfer() {
|
||||
loadSources,
|
||||
retrySourceRpa,
|
||||
loadBacklog,
|
||||
loadRecentPrechecks,
|
||||
restorePrecheckById,
|
||||
batchRequery,
|
||||
batchResume,
|
||||
batchManualClose,
|
||||
downloadReceiptFiles,
|
||||
downloadErpInventory,
|
||||
downloadExceptions,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* features/chat/e2e/in-transit-transfer.spec.ts
|
||||
* 用途:在途仓自动调拨全链路契约冒烟(对应 TDD §10 主路径)——
|
||||
* 预检 → 选择子集 → 直接生成调拨单 → Run 恢复 → 下载留底。
|
||||
* 预检 → 选择子集 → 生成调拨单 → Run 恢复 → 下载留底。
|
||||
* 依赖:Vitest、vi.mock(transfer.api)、useChatTransfer。
|
||||
* 逻辑:不启浏览器;用组合式函数 + Mock API 断言产品契约,避免 e2e 环境依赖
|
||||
* (与仓库 shipping e2e 约定一致)。
|
||||
|
||||
@@ -120,7 +120,7 @@ export interface TransferExecuteResponse {
|
||||
result?: TransferRunResult['result'];
|
||||
}
|
||||
|
||||
/** 待处理池项 */
|
||||
/** 待处理池项(明细字段与预检窗口列一致) */
|
||||
export interface TransferBacklogItem {
|
||||
item_id: number;
|
||||
source_code: string;
|
||||
@@ -131,6 +131,52 @@ export interface TransferBacklogItem {
|
||||
age_days: number;
|
||||
aging_level: string;
|
||||
last_attempt_at?: string | null;
|
||||
receipt_date?: string | null;
|
||||
material_name?: string | null;
|
||||
from_warehouse?: string | null;
|
||||
to_warehouse?: string | null;
|
||||
lot_no?: string | null;
|
||||
receipt_quantity?: string | null;
|
||||
external_quantity?: string | null;
|
||||
}
|
||||
|
||||
/** 最近预检(未执行、未过期、仍拥有归属行;counts 为归属行实时聚合) */
|
||||
export interface TransferRecentPrecheck {
|
||||
precheck_no: string;
|
||||
business_date: string;
|
||||
status: string;
|
||||
transfer_type?: string | null;
|
||||
source_codes: string[];
|
||||
counts: {
|
||||
total: number;
|
||||
executable_count: number;
|
||||
blocked_count: number;
|
||||
not_matured_count: number;
|
||||
};
|
||||
estimated_transfer_quantity: string;
|
||||
estimated_external_write_count: number;
|
||||
created_at?: string | null;
|
||||
expires_at?: string | null;
|
||||
}
|
||||
|
||||
/** 批量操作结果(单行隔离:ok 行带 status,失败行带 error) */
|
||||
export interface TransferBatchResult {
|
||||
total: number;
|
||||
results: Array<{ item_id: number; invoice_no?: string; ok: boolean; status?: string; error?: string }>;
|
||||
}
|
||||
|
||||
/** 批量恢复响应(按来源+收料日期分组重建的预检 / 触发重抓的来源 / 跳过行) */
|
||||
export interface TransferBatchResumeResponse {
|
||||
prechecks: Array<{
|
||||
precheck_no: string;
|
||||
source_code: string;
|
||||
receipt_date: string;
|
||||
selected_item_count: number;
|
||||
/** 重建预检后的可执行行数;0 表示 ERP 未修正(不跳预检卡) */
|
||||
executable_count: number;
|
||||
}>;
|
||||
file_fetching: Array<{ source_code: string; ok: boolean; callback_id?: string; error_code?: string }>;
|
||||
skipped: Array<{ item_id: number; invoice_no: string; error: string }>;
|
||||
}
|
||||
|
||||
/** 操作结果(重试/关闭/取消) */
|
||||
|
||||
Reference in new issue
Block a user