Merge branch 'hugo-shipping-notice' into dev
# Conflicts: # backend/app/services/shipping_notice/receipt_report_notification.py
This commit is contained in:
commit
876a7ade7d
212 files changed
+12056
-2889
No files matched your search
@@ -103,6 +103,8 @@ const isTransferMessage = computed(
|
||||
|| message.type === 'transfer-progress'
|
||||
|| message.type === 'transfer-result',
|
||||
);
|
||||
/** 调拨消息带宽表格(预检明细 10+ 列),放宽气泡宽度上限避免横向挤压成局部布局。 */
|
||||
const wideMessage = computed(() => isTransferMessage.value || isContractReviewMessage.value);
|
||||
|
||||
const isLeaveMessage = computed(() =>
|
||||
message.type === 'leave-form'
|
||||
@@ -709,8 +711,8 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
<template>
|
||||
<div
|
||||
:data-msg-index="index"
|
||||
class="group mx-auto mb-6 flex w-full max-w-4xl animate-slide-up"
|
||||
:class="message.role === 'user' ? 'justify-end' : 'justify-start'"
|
||||
class="group mx-auto mb-6 flex w-full animate-slide-up"
|
||||
:class="message.role === 'user' ? 'justify-end' : wideMessage ? 'max-w-[min(96vw,1500px)]' : 'max-w-4xl justify-start'"
|
||||
>
|
||||
<div
|
||||
class="flex flex-col"
|
||||
@@ -721,7 +723,7 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
class="text-[15px] leading-relaxed"
|
||||
:class="message.role === 'user'
|
||||
? 'rounded-2xl rounded-tr-sm bg-brand-600 px-5 py-2.5 text-white shadow-sm shadow-brand-500/15'
|
||||
: isContractReviewMessage
|
||||
: isContractReviewMessage || isTransferMessage
|
||||
? 'w-full'
|
||||
: shippingOrderExtractionState
|
||||
? 'w-full'
|
||||
|
||||
@@ -64,14 +64,14 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
precheck_id: 'TPC-1', status: 'ready_to_execute', business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05', expires_at: '',
|
||||
counts: { file_invoice_count: 1, not_matured_count: 0, prechecked_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200', estimated_erp_write_count: 1, precheck_hash: 'sha256:x',
|
||||
estimated_transfer_quantity: '1200', estimated_external_write_count: 1, precheck_hash: 'sha256:x',
|
||||
});
|
||||
api.getTransferPrecheck.mockResolvedValue({
|
||||
summary: {
|
||||
precheck_id: 'TPC-1', status: 'ready_to_execute', business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05', expires_at: '',
|
||||
counts: { file_invoice_count: 1, not_matured_count: 0, prechecked_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200', estimated_erp_write_count: 1, precheck_hash: 'sha256:x',
|
||||
estimated_transfer_quantity: '1200', estimated_external_write_count: 1, precheck_hash: 'sha256:x',
|
||||
},
|
||||
items: [{
|
||||
source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器组件', specification: 'A',
|
||||
|
||||
@@ -118,8 +118,8 @@ function goBack() {
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 子流程:复用自驱动的 TransferMessageView -->
|
||||
<div v-else class="w-full max-w-4xl pr-2">
|
||||
<!-- 子流程:复用自驱动的 TransferMessageView(预检宽表格需要全宽,上限对齐消息气泡宽布局) -->
|
||||
<div v-else class="w-full max-w-[min(96vw,1500px)] pr-2">
|
||||
<button
|
||||
type="button"
|
||||
data-testid="transfer-home-back"
|
||||
|
||||
@@ -38,7 +38,7 @@ const payload = {
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 1, not_matured_count: 0, prechecked_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200',
|
||||
estimated_erp_write_count: 1,
|
||||
estimated_external_write_count: 1,
|
||||
precheck_hash: 'sha256:x',
|
||||
},
|
||||
items: [{
|
||||
@@ -57,7 +57,7 @@ const runPayload = {
|
||||
run_no: 'RUN-1',
|
||||
status: 'success',
|
||||
result: {
|
||||
erp_documents: [{
|
||||
external_documents: [{
|
||||
document_no: 'TRF-10001', from_warehouse: 'DBS-TRANSIT', to_warehouse: 'HUB-CN01',
|
||||
material_count: 1, total_quantity: '1200', posting_status: 'posted',
|
||||
lines: [{ material_no: 'MAT-1', material_name: '连接器组件', specification: 'A', invoice_no: 'INV-001', quantity: '1200' }],
|
||||
@@ -167,7 +167,7 @@ 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'] });
|
||||
expect(api.createTransferPrecheck).toHaveBeenCalledWith({ source_codes: ['DBS-AWSBI'], transfer_type: 'in_transit_to_hub' });
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,8 @@ import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
|
||||
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
|
||||
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
import { downloadTransferSourceFiles, getTransferPrecheck, requeryTransferItems } from '../../api/transfer.api';
|
||||
import { triggerBlobDownload } from '@/shared/utils/download';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type {
|
||||
TransferBacklogItem,
|
||||
@@ -23,6 +25,7 @@ import type {
|
||||
TransferPrecheckSummary,
|
||||
TransferRunResult,
|
||||
TransferSourceProgress,
|
||||
TransferType,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -86,6 +89,40 @@ function applyPayload(payload?: Record<string, unknown> | null) {
|
||||
applyPayload(props.payload);
|
||||
watch(() => props.payload, applyPayload);
|
||||
|
||||
/** 打包下载选中来源的最新归档收料文件 */
|
||||
async function onDownloadSources(sourceCodes: string[]) {
|
||||
if (!sourceCodes.length) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await downloadTransferSourceFiles(sourceCodes);
|
||||
triggerBlobDownload(result.blob, result.filename ?? `receipt-files-${sourceCodes.length}.zip`);
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 重新获取 ERP 库存:批量重查后用服务端明细原位刷新(保留勾选中仍阻断的行) */
|
||||
async function onRequery(invoiceNos: string[]) {
|
||||
if (!invoiceNos.length || !transfer.precheckId.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
await requeryTransferItems(transfer.precheckId.value, invoiceNos);
|
||||
const detail = await getTransferPrecheck(transfer.precheckId.value);
|
||||
items.value = detail.items;
|
||||
if (detail.summary) summaryRef.value = detail.summary;
|
||||
const stillBlocked = new Set(
|
||||
items.value.filter((item) => String(item.result).startsWith('blocked_')).map((item) => item.invoice_no),
|
||||
);
|
||||
transfer.selected.value = new Set([...transfer.selected.value].filter((no) => stillBlocked.has(no)));
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 直接生成调拨单(决策 4/5:无独立确认页) */
|
||||
async function onExecute(invoiceNos: string[]) {
|
||||
busy.value = true;
|
||||
@@ -159,11 +196,15 @@ async function onCloseConfirm(reason: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 来源实例选择确认 → 创建预检并切换预检卡(决策 4:两步第一步) */
|
||||
async function onSourceConfirm(sourceCodes: string[]) {
|
||||
/** 来源实例选择确认 → 创建预检并切换预检卡(决策 4:两步第一步;收料日期范围为查询范围;调拨类型决定数据范围) */
|
||||
async function onSourceConfirm(
|
||||
sourceCodes: string[],
|
||||
dateRange?: { from?: string; to?: string },
|
||||
transferType?: TransferType,
|
||||
) {
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.createPrecheck(sourceCodes);
|
||||
await transfer.createPrecheck(sourceCodes, undefined, dateRange, transferType);
|
||||
mode.value = 'precheck';
|
||||
summaryRef.value = transfer.precheck.value;
|
||||
items.value = transfer.items.value;
|
||||
@@ -206,15 +247,20 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
:busy="busy"
|
||||
:retrying="retryingSource"
|
||||
@confirm="onSourceConfirm"
|
||||
@download="onDownloadSources"
|
||||
@retry="onSourceRetry"
|
||||
/>
|
||||
<TransferPrecheckCard
|
||||
v-else-if="mode === 'precheck' && summaryRef"
|
||||
:summary="summaryRef"
|
||||
:items="items"
|
||||
:sources="transfer.sources.value"
|
||||
:selected="transfer.selected.value"
|
||||
:requery-busy="busy"
|
||||
:busy="busy"
|
||||
@toggle="(invoiceNo, checked) => transfer.toggleSelect(invoiceNo, checked)"
|
||||
@toggle-all="(invoiceNos, checked) => invoiceNos.forEach((no) => transfer.toggleSelect(no, checked))"
|
||||
@requery="onRequery"
|
||||
@execute="onExecute"
|
||||
/>
|
||||
<TransferProgressCard v-else-if="mode === 'progress'" :run-no="runNo" :status="status" :busy="busy" />
|
||||
|
||||
@@ -1,24 +1,34 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferPrecheckCard.vue
|
||||
用途:预检卡——计数 + 调拨明细表(决策 6 十列)+ 勾选 + “直接生成调拨单”按钮。
|
||||
依赖:props(summary/items/selected/busy)、i18n chat.transfer.*。
|
||||
逻辑:阻断/未成熟项 checkbox 禁用;无选择或 busy 时生成按钮禁用;
|
||||
emit execute(invoiceNos)(决策 4/5:无独立确认页)。
|
||||
用途:预检卡——计数 + 来源失败提示 + 调拨明细表(含筛选)+ 勾选 + “直接生成调拨单”按钮。
|
||||
依赖:props(summary/items/sources/selected/busy)、i18n chat.transfer.*。
|
||||
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断/未成熟项 checkbox 禁用;
|
||||
重查范围含可恢复阻断与可执行行;阻断原因经结果徽标 title 悬浮透出不占行高;
|
||||
无选择或 busy 时生成按钮禁用;emit execute(invoiceNos)(决策 4/5:无独立确认页);
|
||||
来源级解析/文件失败经 sources.error_code 透出(防"安静全 0")。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { TransferPrecheckItem, TransferPrecheckSummary } from '../../types/transfer.types';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import type { TransferPrecheckItem, TransferPrecheckSummary, TransferSourceProgress } from '../../types/transfer.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
summary: TransferPrecheckSummary;
|
||||
items: TransferPrecheckItem[];
|
||||
sources?: TransferSourceProgress[];
|
||||
selected: Set<string>;
|
||||
busy?: boolean;
|
||||
requeryBusy?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggle: [invoiceNo: string, checked: boolean];
|
||||
'toggle-all': [invoiceNos: string[], checked: boolean];
|
||||
execute: [invoiceNos: string[]];
|
||||
requery: [invoiceNos: string[]];
|
||||
}>();
|
||||
|
||||
const selectedCount = computed(() =>
|
||||
@@ -26,10 +36,67 @@ const selectedCount = computed(() =>
|
||||
);
|
||||
const executeDisabled = computed(() => props.busy || selectedCount.value === 0);
|
||||
|
||||
/** 来源级失败(解析/文件/RPA 触发):必须可见,防止计数全 0 却无任何解释。 */
|
||||
const failedSources = computed(() =>
|
||||
(props.sources ?? []).filter((source) => source.error_code || source.error_message),
|
||||
);
|
||||
|
||||
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
|
||||
const keyword = ref('');
|
||||
const resultFilter = ref<'all' | 'executable' | 'blocked' | 'not_matured'>('all');
|
||||
|
||||
function isBlocked(item: TransferPrecheckItem): boolean {
|
||||
return String(item.result).startsWith('blocked_');
|
||||
}
|
||||
|
||||
/** 勾选可用范围:可执行(可生成调拨)或可恢复阻断(可重查 ERP)。 */
|
||||
function isSelectable(item: TransferPrecheckItem): boolean {
|
||||
return item.result === 'executable';
|
||||
}
|
||||
|
||||
function isCheckable(item: TransferPrecheckItem): boolean {
|
||||
return isSelectable(item) || isBlocked(item);
|
||||
}
|
||||
|
||||
/** 可重查行:可恢复阻断 + 可执行(已可执行也允许重查核对最新库存)。 */
|
||||
function isRequeryable(item: TransferPrecheckItem): boolean {
|
||||
return isBlocked(item) || item.result === 'executable';
|
||||
}
|
||||
|
||||
const filtered = computed(() =>
|
||||
props.items.filter((item) => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (kw) {
|
||||
const haystack = [item.material_no, item.material_name, item.invoice_no, item.lot_no]
|
||||
.map((value) => String(value ?? '').toLowerCase());
|
||||
if (!haystack.some((value) => value.includes(kw))) return false;
|
||||
}
|
||||
if (resultFilter.value === 'executable' && item.result !== 'executable') return false;
|
||||
if (resultFilter.value === 'blocked' && !isBlocked(item)) return false;
|
||||
if (resultFilter.value === 'not_matured' && item.result !== 'not_matured') return false;
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
|
||||
const filteredInvoiceNos = computed(() => filtered.value.map((item) => item.invoice_no));
|
||||
const allFilteredSelected = computed(() =>
|
||||
filteredInvoiceNos.value.length > 0 && filteredInvoiceNos.value.every((no) => props.selected.has(no)),
|
||||
);
|
||||
const selectedRequeryableCount = computed(() =>
|
||||
filtered.value.filter((item) => isRequeryable(item) && props.selected.has(item.invoice_no)).length,
|
||||
);
|
||||
|
||||
function toggleAll(): void {
|
||||
emit('toggle-all', filteredInvoiceNos.value, !allFilteredSelected.value);
|
||||
}
|
||||
|
||||
function requerySelected(): void {
|
||||
const nos = filtered.value
|
||||
.filter((item) => isRequeryable(item) && props.selected.has(item.invoice_no))
|
||||
.map((item) => item.invoice_no);
|
||||
if (nos.length) emit('requery', nos);
|
||||
}
|
||||
|
||||
function isChecked(item: TransferPrecheckItem): boolean {
|
||||
return props.selected.has(item.invoice_no);
|
||||
}
|
||||
@@ -41,11 +108,31 @@ function resultLabel(result: string): string {
|
||||
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
|
||||
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
|
||||
blocked_future_date: 'chat.transfer.resultBlocked',
|
||||
erp_query_timeout: 'chat.transfer.resultUnknown',
|
||||
external_query_timeout: 'chat.transfer.resultUnknown',
|
||||
result_unknown: 'chat.transfer.resultUnknown',
|
||||
};
|
||||
return map[result] ?? 'chat.transfer.resultBlocked';
|
||||
}
|
||||
|
||||
/** 阻断原因悬浮文案:已知结果码走 i18n 本地化;带明细后缀(如查询失败的底层原因)原样保留追加。 */
|
||||
const REASON_I18N_KEYS: Record<string, string> = {
|
||||
blocked_quantity_mismatch: 'chat.transfer.reasonQuantityMismatch',
|
||||
blocked_inventory_not_found: 'chat.transfer.reasonInventoryNotFound',
|
||||
blocked_external_query_failed: 'chat.transfer.reasonExternalQueryFailed',
|
||||
blocked_future_date: 'chat.transfer.reasonFutureDate',
|
||||
};
|
||||
|
||||
function reasonTitle(item: TransferPrecheckItem): string | undefined {
|
||||
if (!isBlocked(item) || !item.reason) return undefined;
|
||||
const key = REASON_I18N_KEYS[item.result];
|
||||
if (!key) return item.reason;
|
||||
const base = t(key);
|
||||
const marker = ': ';
|
||||
const detail = item.reason.includes(marker)
|
||||
? item.reason.slice(item.reason.indexOf(marker) + marker.length).trim()
|
||||
: '';
|
||||
return detail ? `${base}:${detail}` : base;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -73,22 +160,65 @@ function resultLabel(result: string): string {
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.estimatedQuantity') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft p-2 text-center">
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.estimated_erp_write_count }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.estimatedErpWrites') }}</div>
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.estimated_external_write_count }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.estimatedExternalWrites') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<div
|
||||
v-if="failedSources.length"
|
||||
class="mb-3 rounded-lg border border-red-200 bg-red-50 p-3 text-xs text-red-700"
|
||||
data-testid="transfer-precheck-source-errors"
|
||||
>
|
||||
<div class="mb-1 font-bold">{{ $t('chat.transfer.sourceErrorTitle') }}</div>
|
||||
<div v-for="source in failedSources" :key="source.source_code" class="leading-5">
|
||||
{{ source.source_code }}:{{ source.error_message || source.error_code }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div 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-precheck-filter"
|
||||
/>
|
||||
<select v-model="resultFilter" class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary" data-testid="transfer-precheck-result-filter">
|
||||
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
|
||||
<option value="executable">{{ $t('chat.transfer.resultExecutable') }}</option>
|
||||
<option value="blocked">{{ $t('chat.transfer.resultBlocked') }}</option>
|
||||
<option value="not_matured">{{ $t('chat.transfer.resultNotMatured') }}</option>
|
||||
</select>
|
||||
<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"
|
||||
:disabled="props.requeryBusy || selectedRequeryableCount === 0"
|
||||
data-testid="transfer-precheck-requery-selected"
|
||||
@click="requerySelected"
|
||||
>
|
||||
{{ $t('chat.transfer.requerySelected') }}{{ selectedRequeryableCount ? `(${selectedRequeryableCount})` : '' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1100px] text-xs" data-testid="transfer-precheck-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
|
||||
<th class="p-2"></th>
|
||||
<th class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allFilteredSelected"
|
||||
data-testid="transfer-precheck-select-all"
|
||||
@change="toggleAll"
|
||||
/>
|
||||
</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.colSpec') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colInvoice') }}</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>
|
||||
@@ -97,8 +227,8 @@ function resultLabel(result: string): string {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in items"
|
||||
:key="item.invoice_no"
|
||||
v-for="item in filtered"
|
||||
:key="`${item.source_code}|${item.invoice_no}|${item.material_no}|${item.receipt_date ?? ''}`"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': !isSelectable(item) }"
|
||||
:data-testid="`transfer-item-${item.invoice_no}`"
|
||||
@@ -107,31 +237,47 @@ function resultLabel(result: string): string {
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isChecked(item)"
|
||||
:disabled="!isSelectable(item) || busy"
|
||||
:disabled="!isCheckable(item) || busy"
|
||||
:data-testid="`transfer-check-${item.invoice_no}`"
|
||||
@change="emit('toggle', item.invoice_no, ($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.specification }}</td>
|
||||
<td class="p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="p-2">{{ item.from_warehouse }}</td>
|
||||
<td class="p-2">{{ deriveBatchNo(item.lot_no) }}</td>
|
||||
<td class="p-2">{{ item.from_quantity ?? '—' }}</td>
|
||||
<td class="p-2">{{ item.to_warehouse }}</td>
|
||||
<td class="p-2">{{ item.to_quantity }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': item.result === 'executable',
|
||||
'bg-amber-50 text-amber-700': item.result === 'not_matured',
|
||||
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'not_matured',
|
||||
}"
|
||||
>
|
||||
{{ $t(resultLabel(item.result)) }}
|
||||
</span>
|
||||
<div class="flex items-center gap-1">
|
||||
<!-- 阻断原因经悬浮提示(title)透出:不占行高;可执行行也提供重查入口 -->
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': item.result === 'executable',
|
||||
'bg-amber-50 text-amber-700': item.result === 'not_matured',
|
||||
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'not_matured',
|
||||
}"
|
||||
:title="reasonTitle(item)"
|
||||
data-testid="transfer-item-result"
|
||||
>
|
||||
{{ $t(resultLabel(item.result)) }}
|
||||
</span>
|
||||
<button
|
||||
v-if="isRequeryable(item)"
|
||||
type="button"
|
||||
class="ml-1 rounded border border-brand-200 px-1 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:disabled="props.requeryBusy"
|
||||
:data-testid="`transfer-requery-${item.invoice_no}`"
|
||||
@click="emit('requery', [item.invoice_no])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@@ -141,7 +287,7 @@ function resultLabel(result: string): string {
|
||||
<div class="mt-3 flex items-center justify-end gap-3 border-t border-subtle pt-3">
|
||||
<span class="text-xs text-muted">
|
||||
{{ $t('chat.transfer.selectedCount', { count: selectedCount }) }} ·
|
||||
{{ $t('chat.transfer.estimatedErpWrites') }}:{{ summary.estimated_erp_write_count }}
|
||||
{{ $t('chat.transfer.estimatedExternalWrites') }}:{{ summary.estimated_external_write_count }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -39,9 +39,9 @@ function reasonLabel(reason: string): string {
|
||||
</div>
|
||||
|
||||
<!-- 已生成 ERP 单据:按单号聚合 + 可展开物料明细 -->
|
||||
<div v-if="run.result.erp_documents.length" class="flex flex-col gap-2">
|
||||
<div v-if="run.result.external_documents.length" class="flex flex-col gap-2">
|
||||
<details
|
||||
v-for="doc in run.result.erp_documents"
|
||||
v-for="doc in run.result.external_documents"
|
||||
:key="doc.document_no"
|
||||
class="rounded-lg border border-default"
|
||||
data-testid="transfer-erp-document"
|
||||
|
||||
@@ -58,7 +58,7 @@ describe('TransferSourceSelectCard', () => {
|
||||
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DBS-AWSBI', 'DBS-AWSSG', 'CRANE-SZ']);
|
||||
});
|
||||
|
||||
it('“清空”清空已选实例', async () => {
|
||||
it('“清空选择”清空已选实例', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-select-visible"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-source-clear"]').trigger('click');
|
||||
@@ -66,6 +66,28 @@ describe('TransferSourceSelectCard', () => {
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('选中后上下文操作条原位替换选择辅助区,清空选择后还原', async () => {
|
||||
// [断言意图] 未选中零死按钮(仅辅助区);有选中时批量操作条同槽位出现并带计数;
|
||||
// 清空选择后还原辅助区——Gmail/Linear 式批量操作栏切换行为。
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.find('[data-testid="transfer-source-aids"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-source-action-bar"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
expect(wrapper.find('[data-testid="transfer-source-aids"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-source-action-bar"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-source-action-bar"]').text()).toContain('已选 1');
|
||||
await wrapper.find('[data-testid="transfer-source-clear"]').trigger('click');
|
||||
expect(wrapper.find('[data-testid="transfer-source-aids"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-source-action-bar"]').exists()).toBe(false);
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('D+1 规则提示收进 ⓘ 悬浮(title),不再平铺占宽', () => {
|
||||
// [断言意图] 长规则文案通过原生 title 渐进披露,紧凑日期行不换行错位。
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.find('[data-testid="transfer-source-date-hint"]').attributes('title')).toBe('截止不超出 D+1 规则(业务日期前一天)');
|
||||
});
|
||||
|
||||
it('“只选可重试”勾选无文件/失败来源', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-select-retryable"]').trigger('click');
|
||||
@@ -86,4 +108,33 @@ describe('TransferSourceSelectCard', () => {
|
||||
await wrapper.find('[data-testid="transfer-source-batch-retry"]').trigger('click');
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSSG']);
|
||||
});
|
||||
|
||||
it('已过期来源显示「文件已过期」徽标且可重试', async () => {
|
||||
// [断言意图] 保留期已到的来源不得误报就绪(has_ready_file=false);
|
||||
// expired 状态与 none/failed 一样允许重新触发收料 RPA。
|
||||
const wrapper = mountCard({}, [
|
||||
{ source_code: 'CRANE-EXP', display_name: '过期在途仓', platform: 'crane', enabled: true, has_ready_file: false, file_status: 'expired' },
|
||||
]);
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-EXP"]').text()).toBe('文件已过期');
|
||||
expect((wrapper.find('[data-testid="transfer-source-retry-CRANE-EXP"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-source-option-CRANE-EXP"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-batch-retry"]').trigger('click');
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['CRANE-EXP']);
|
||||
});
|
||||
|
||||
it('确认默认携带调拨类型 in_transit_to_hub', async () => {
|
||||
// [断言意图] 类型 1 为缺省选中值,确认事件第三参回传类型。
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
expect(wrapper.emitted('confirm')?.[0][2]).toBe('in_transit_to_hub');
|
||||
});
|
||||
|
||||
it('调拨类型 2/3 占位禁用且不可选中', async () => {
|
||||
// [断言意图] 一期仅开放类型 1;占位类型按钮 disabled,防止发起未支持链路。
|
||||
const wrapper = mountCard();
|
||||
expect((wrapper.find('[data-testid="transfer-type-option-hub_repair_out"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -1,15 +1,19 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferSourceSelectCard.vue
|
||||
用途:来源实例选择卡(决策 2/3/4:手工两步第一步)——按平台 DBS/Crane 分组勾选实例,
|
||||
“确认范围并预检”发起预检。
|
||||
选择调拨类型后“确认范围并预检”发起预检。
|
||||
依赖:props.sources、i18n chat.transfer.*。
|
||||
逻辑:平台仅分组不可直接执行;未选任何实例时确认按钮禁用。
|
||||
逻辑:预检参数区(调拨类型 + 收料日期,确认时一并提交)→ 选择辅助/上下文操作条
|
||||
(有选中时原位替换辅助区,承载批量重试/下载/清空选择)→ 平台分组来源列表
|
||||
(平台仅分组不可直接执行)→ 底部唯一实心主按钮「确认范围并预检」(未选禁用);
|
||||
调拨类型决定收料数据范围(类型 1 仅纳入 INVOICE 前缀 HOM/HOX/WTP),
|
||||
类型 2/3 一期占位(禁用,后端同样 fail-closed)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { TransferSourceOption } from '../../types/transfer.types';
|
||||
import type { TransferSourceOption, TransferType } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
sources: TransferSourceOption[];
|
||||
@@ -19,22 +23,39 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
confirm: [sourceCodes: string[]];
|
||||
confirm: [sourceCodes: string[], dateRange?: { from?: string; to?: string }, transferType?: TransferType];
|
||||
/** 批量重试收料 RPA:传来源编码列表 */
|
||||
retry: [sourceCodes: string[]];
|
||||
download: [sourceCodes: string[]];
|
||||
}>();
|
||||
|
||||
const { warning: notifyWarning } = useMessage();
|
||||
const { t } = useI18n();
|
||||
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
/** 收料日期范围(预检查询范围);截止不得超出 D+1 规则(后端卡控)。 */
|
||||
const dateFrom = ref('');
|
||||
const dateTo = ref('');
|
||||
/** 调拨业务类型:决定本次预检纳入哪些收料数据;一期仅类型 1 开放。 */
|
||||
const transferType = ref<TransferType>('in_transit_to_hub');
|
||||
|
||||
/** 类型选项元数据;enabled=false 为占位类型(UI 禁用 + 后端 fail-closed 双保险)。 */
|
||||
const transferTypeOptions: Array<{ value: TransferType; enabled: boolean }> = [
|
||||
{ value: 'in_transit_to_hub', enabled: true },
|
||||
{ value: 'hub_repair_out', enabled: false },
|
||||
{ value: 'hub_to_hub', enabled: false },
|
||||
];
|
||||
|
||||
function transferTypeLabel(value: TransferType): string {
|
||||
return t(`chat.transfer.transferType.${value}`);
|
||||
}
|
||||
|
||||
const platforms = computed(() => [...new Set(props.sources.map((source) => source.platform))]);
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
|
||||
/** 可重试判定:仅 待抓取(none) / 抓取失败(failed) 的来源可重试(ready/fetching 不重复触发)。 */
|
||||
/** 可重试判定:仅 待抓取(none) / 抓取失败(failed) / 已过期(expired) 的来源可重试(ready/fetching 不重复触发)。 */
|
||||
function isRetryable(source: TransferSourceOption): boolean {
|
||||
return source.file_status === 'none' || source.file_status === 'failed';
|
||||
return source.file_status === 'none' || source.file_status === 'failed' || source.file_status === 'expired';
|
||||
}
|
||||
|
||||
/** 全部可重试来源。 */
|
||||
@@ -50,6 +71,7 @@ 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 downloadDisabled = computed(() => props.busy || !selectedHasReadyFile.value);
|
||||
|
||||
function toggle(sourceCode: string, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
@@ -96,6 +118,13 @@ function batchRetry() {
|
||||
emit('retry', codes);
|
||||
}
|
||||
|
||||
function downloadSelected(): void {
|
||||
const codes = [...selected.value].filter(
|
||||
(code) => props.sources.find((s) => s.source_code === code)?.has_ready_file,
|
||||
);
|
||||
if (codes.length) emit('download', codes);
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
if (selectedCount.value === 0) {
|
||||
notifyWarning(t('chat.transfer.needSelectSource'), t('chat.transfer.sourceSelectTitle'));
|
||||
@@ -105,7 +134,7 @@ function confirm() {
|
||||
notifyWarning(t('chat.transfer.needReadyFile'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
emit('confirm', [...selected.value]);
|
||||
emit('confirm', [...selected.value], { from: dateFrom.value || undefined, to: dateTo.value || undefined }, transferType.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -114,7 +143,54 @@ function confirm() {
|
||||
<h3 class="mb-1 text-sm font-bold text-primary">{{ $t('chat.transfer.sourceSelectTitle') }}</h3>
|
||||
<p class="mb-3 text-xs text-muted">{{ $t('chat.transfer.sourceSelectHint') }}</p>
|
||||
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<!-- [ZONE 1] 预检参数区:调拨类型 + 收料日期同组(确认预检时一并提交,参数先行定范围)。 -->
|
||||
<div class="mb-3 rounded-lg border border-subtle p-3" data-testid="transfer-source-params">
|
||||
<p class="mb-2 text-[11px] font-bold text-muted">{{ $t('chat.transfer.precheckParams') }}</p>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs font-bold text-secondary">{{ $t('chat.transfer.transferTypeLabel') }}</span>
|
||||
<button
|
||||
v-for="option in transferTypeOptions"
|
||||
:key="option.value"
|
||||
type="button"
|
||||
class="rounded-full border px-3 py-1 text-xs font-bold disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:class="transferType === option.value
|
||||
? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700'
|
||||
: 'border-brand-200 text-brand-700 hover:bg-brand-50'"
|
||||
:disabled="busy || !option.enabled"
|
||||
:title="option.enabled ? undefined : t('chat.transfer.transferTypeComingSoon')"
|
||||
:data-testid="`transfer-type-option-${option.value}`"
|
||||
@click="transferType = option.value"
|
||||
>
|
||||
{{ transferTypeLabel(option.value) }}
|
||||
<span v-if="!option.enabled" class="ml-1 font-normal opacity-70">{{ t('chat.transfer.transferTypeComingSoon') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs font-bold text-secondary">{{ $t('chat.transfer.receiptDateLabel') }}</span>
|
||||
<input
|
||||
v-model="dateFrom"
|
||||
type="date"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-source-date-from"
|
||||
/>
|
||||
<span class="text-xs text-muted">~</span>
|
||||
<input
|
||||
v-model="dateTo"
|
||||
type="date"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-source-date-to"
|
||||
/>
|
||||
<!-- D+1 规则属低频说明:收进原生 title 悬浮(渐进披露),避免长文案挤压布局。 -->
|
||||
<span
|
||||
class="cursor-help text-xs text-muted"
|
||||
:title="$t('chat.transfer.receiptDateHint')"
|
||||
data-testid="transfer-source-date-hint"
|
||||
>ⓘ</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- [ZONE 2] 选择辅助/上下文操作条:有选中时原位替换辅助区(批量操作惯例),未选中零死按钮。 -->
|
||||
<div v-if="selectedCount === 0" class="mb-3 flex flex-wrap items-center gap-2" data-testid="transfer-source-aids">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
@@ -133,28 +209,45 @@ function confirm() {
|
||||
>
|
||||
{{ $t('chat.transfer.selectRetryable') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-bold text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="batchRetryDisabled"
|
||||
data-testid="transfer-source-batch-retry"
|
||||
@click="batchRetry"
|
||||
>
|
||||
{{ $t('chat.transfer.batchRetry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-clear"
|
||||
@click="clearSelected"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSources') }}
|
||||
</button>
|
||||
<span class="ml-auto text-xs text-muted">
|
||||
</div>
|
||||
<div
|
||||
v-else
|
||||
class="mb-3 flex flex-wrap items-center gap-2 rounded-lg border border-brand-200 bg-brand-50 px-3 py-2"
|
||||
data-testid="transfer-source-action-bar"
|
||||
>
|
||||
<span class="text-xs font-bold text-secondary">
|
||||
{{ $t('chat.transfer.selectedSourceCount', { count: selectedCount }) }}
|
||||
<span v-if="selectedRetryableCount > 0" class="text-amber-600"> · {{ $t('chat.transfer.selectedRetryableCount', { count: selectedRetryableCount }) }}</span>
|
||||
</span>
|
||||
<span class="ml-auto flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="batchRetryDisabled"
|
||||
data-testid="transfer-source-batch-retry"
|
||||
@click="batchRetry"
|
||||
>
|
||||
{{ $t('chat.transfer.batchRetry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft disabled:opacity-50"
|
||||
:disabled="busy || downloadDisabled"
|
||||
data-testid="transfer-source-download"
|
||||
@click="downloadSelected"
|
||||
>
|
||||
{{ $t('chat.transfer.downloadFiles') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-clear"
|
||||
@click="clearSelected"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSources') }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-for="platform in platforms" :key="platform" class="mb-3 rounded-lg border border-subtle">
|
||||
@@ -208,6 +301,13 @@ function confirm() {
|
||||
>
|
||||
{{ t('chat.transfer.fileFailed') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="source.file_status === 'expired'"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-orange-50 px-2 py-0.5 text-[10px] font-bold text-orange-700"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileExpired') }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="inline-flex items-center gap-1 rounded-full bg-surface-strong px-2 py-0.5 text-[10px] font-bold text-muted"
|
||||
@@ -230,8 +330,7 @@ function confirm() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 border-t border-subtle pt-3">
|
||||
<span class="text-xs text-muted">{{ $t('chat.transfer.selectedCount', { count: selectedCount }) }}</span>
|
||||
<div class="flex items-center justify-end border-t border-subtle pt-3">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferBatch.spec.ts
|
||||
* 用途:覆盖批号转换规则。
|
||||
* 依赖:transferBatch、vitest。
|
||||
* 逻辑:WTP 前缀替换为 HOW;其余原样;空值安全。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
|
||||
describe('transferBatch', () => {
|
||||
it('replaces WTP prefix with HOW and keeps the rest', () => {
|
||||
expect(deriveBatchNo('WTP26082728')).toBe('HOW26082728');
|
||||
expect(deriveBatchNo('wtp26082728')).toBe('HOW26082728');
|
||||
});
|
||||
|
||||
it('returns non-WTP values unchanged', () => {
|
||||
expect(deriveBatchNo('HS000131')).toBe('HS000131');
|
||||
expect(deriveBatchNo('4294235')).toBe('4294235');
|
||||
});
|
||||
|
||||
it('returns empty string for empty input', () => {
|
||||
expect(deriveBatchNo('')).toBe('');
|
||||
expect(deriveBatchNo(null)).toBe('');
|
||||
expect(deriveBatchNo(undefined)).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferBatch.ts
|
||||
* 用途:在途调拨批号转换规则(拨出/拨入批号展示)。
|
||||
* 依赖:无。
|
||||
* 逻辑:原批号以 WTP 开头时替换前缀为 HOW 获得真实批号;其余规则不变、原样展示。
|
||||
*/
|
||||
|
||||
/** 原批号(如 WMS 的 WTP26082728)→ 真实批号(HOW26082728);空值/非 WTP 原样返回。 */
|
||||
export function deriveBatchNo(lotNo: string | null | undefined): string {
|
||||
const value = String(lotNo ?? '').trim();
|
||||
if (!value) return '';
|
||||
if (value.toUpperCase().startsWith('WTP')) return `HOW${value.slice(3)}`;
|
||||
return value;
|
||||
}
|
||||
@@ -23,7 +23,7 @@ const summary = {
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 3, not_matured_count: 1, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_erp_write_count: 2,
|
||||
estimated_external_write_count: 2,
|
||||
precheck_hash: 'sha256:x',
|
||||
};
|
||||
|
||||
@@ -82,6 +82,27 @@ describe('TransferPrecheckCard', () => {
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
expect(wrapper.emitted('execute')?.[0][0]).toEqual(['INV-001']);
|
||||
});
|
||||
|
||||
it('同 Invoice 跨收料日期拆票(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||||
// [断言意图] 回归防线(2026-09-21):拆票设计下 invoice_no 不再唯一,
|
||||
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
|
||||
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
|
||||
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
|
||||
const dupItems = [
|
||||
{ source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', receipt_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
];
|
||||
const wrapper = mount(TransferPrecheckCard, {
|
||||
props: { summary, items: dupItems, selected: new Set() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect(wrapper.findAll('tbody tr').length).toBe(3);
|
||||
await wrapper.find('[data-testid="transfer-precheck-filter"]').setValue('HOX');
|
||||
const rows = wrapper.findAll('tbody tr');
|
||||
expect(rows.length).toBe(1);
|
||||
expect(rows[0].text()).toContain('HOX-1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferResultCard', () => {
|
||||
@@ -89,7 +110,7 @@ describe('TransferResultCard', () => {
|
||||
run_no: 'RUN-1',
|
||||
status: 'partial_failed',
|
||||
result: {
|
||||
erp_documents: [{
|
||||
external_documents: [{
|
||||
document_no: 'TRF-10001',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
|
||||
Reference in new issue
Block a user