feat(shipping-notice): 调拨预检解析增强与批号列交互完善
- 异动解析跳过无异动日期的在途/执行中行,兼容 datetime 日期单元格 - ERP 网关故障降级为逐票阻断并带原因,不再炸整来源 - 预检明细唯一约束升粒度:(预检,来源,单号,料号,收料日期) - Invoice 恢复单号锚定并移至料号前;批号 lot_no 全链贯通, 拨出/拨入批号按 WTP→HOW 转换展示;新增收料日期列 - 预检表格筛选/全选;单行与批量重查 ERP 库存 - 收料日期范围作为预检查询范围,截止卡控不超出 D+1 规则 - 来源多选打包下载收料文件;调拨消息与子流程容器放宽宽度 - 预检恢复明细补齐收料日期与批号字段(修复卡片三列空值)
This commit is contained in:
1 parent
a06ff79d7c
commit
1ba38e1685
44 files changed
+963
-121
No files matched your search
@@ -346,7 +346,7 @@
|
||||
|
||||
<template v-else-if="activeTab === 'mappings'">
|
||||
<label><span>{{ t('admin.shippingInventory.source') }}</span><select v-model.number="mapping.inventory_source_id" class="select-field" required><option :value="0">{{ t('admin.shippingInventory.chooseSource') }}</option><option v-for="item in sources" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
|
||||
<label><span>{{ t('admin.shippingInventory.freightWarehouse') }}</span><input v-model="mapping.freight_warehouse_id" class="input-field" :placeholder="t('admin.shippingInventory.defaultMapping')"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.freightWarehouse') }}</span><input v-model="mapping.freight_warehouse_id" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalSystem') }}</span><input v-model="mapping.external_system_code" class="input-field" required></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalOrganization') }}</span><input v-model="mapping.external_organization_code" class="input-field"></label>
|
||||
<label><span>{{ t('admin.shippingInventory.externalSite') }}</span><input v-model="mapping.external_site_code" class="input-field"></label>
|
||||
@@ -746,7 +746,9 @@ const currentItems = computed<Item[]>(() => {
|
||||
});
|
||||
const compatibleProfiles = computed(() => profiles.value.filter((item) => item.connector_type === source.connector_type));
|
||||
const selectedRuleStatus = computed(() => rules.value.find((item) => Number(item.id) === selectedId.value)?.status || 'draft');
|
||||
const ruleReadOnly = computed(() => ['published', 'retired'].includes(selectedRuleStatus.value));
|
||||
// 只读判定必须限定在规则页签:selectedId 是各页签共享的,站点 id 可能与规则 id 相同,
|
||||
// 不加页签限定时已发布规则会让站点页签的保存按钮被误禁用(点击无任何请求)。
|
||||
const ruleReadOnly = computed(() => activeTab.value === 'rules' && ['published', 'retired'].includes(selectedRuleStatus.value));
|
||||
const selectedTemplateStatus = computed(() => excelTemplates.value.find((item) => Number(item.id) === selectedId.value)?.status || 'draft');
|
||||
const selectedParsingStatus = computed(() => parsingProfiles.value.find((item) => Number(item.id) === selectedId.value)?.status || 'draft');
|
||||
const parsingReadOnly = computed(() => activeTab.value === 'parsing' && ['published', 'retired'].includes(selectedParsingStatus.value));
|
||||
@@ -1627,11 +1629,13 @@ function serialiseSourceInput(): string {
|
||||
});
|
||||
}
|
||||
|
||||
/** 将收料配置表单稳定序列化,作为统一保存与启用守卫的收料脏检查基线。 */
|
||||
/** 将收料配置表单稳定序列化(含异动解析规则绑定),作为统一保存与启用守卫的收料脏检查基线。 */
|
||||
function serialiseReceiptInput(): string {
|
||||
return JSON.stringify({
|
||||
report_path_json: receiptConfig.report_path_json,
|
||||
query_parameters_json: receiptConfig.query_parameters_json,
|
||||
// 异动解析绑定必须参与脏检查:否则只改绑定时统一保存会跳过收料配置提交,改动被静默丢弃。
|
||||
parsing_profile_id: receiptConfig.parsing_profile_id ? Number(receiptConfig.parsing_profile_id) : null,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@ const jsonHeaders = () => ({ 'Content-Type': 'application/json', ...getAuthHeade
|
||||
export interface CreatePrecheckPayload {
|
||||
source_codes: string[];
|
||||
business_date?: string;
|
||||
receipt_date_from?: string;
|
||||
receipt_date_to?: string;
|
||||
}
|
||||
|
||||
/** 创建预检(只读) */
|
||||
@@ -92,6 +94,21 @@ export const downloadTransferErpInventory = (runNo: string) =>
|
||||
export const downloadTransferExceptions = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/exceptions.xlsx`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 批量重查 ERP 库存(可恢复阻断行;invoice_nos 缺省 = 全部阻断行) */
|
||||
export const requeryTransferItems = (precheckNo: string, invoiceNos?: string[]) =>
|
||||
requestJson<{ precheck_no: string; total: number; results: Array<Record<string, unknown>> }>(
|
||||
`${BASE}/prechecks/${precheckNo}/items/requery`,
|
||||
{ method: 'POST', body: JSON.stringify(invoiceNos ? { invoice_nos: invoiceNos } : {}), headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' } },
|
||||
);
|
||||
|
||||
/** 按选中来源打包下载各自最新归档收料文件(zip) */
|
||||
export const downloadTransferSourceFiles = (sourceCodes: string[]) =>
|
||||
requestBlob(`${BASE}/sources/receipt-files`, {
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ source_codes: sourceCodes }),
|
||||
});
|
||||
|
||||
/** 待处理异常列表(可恢复/已关闭/结果未知 + 老化等级) */
|
||||
export const listTransferBacklog = () =>
|
||||
requestJson<TransferBacklogItem[]>(`${BASE}/backlog`, { headers: getAuthHeaders() });
|
||||
|
||||
@@ -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'
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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,
|
||||
@@ -86,6 +88,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 +195,14 @@ async function onCloseConfirm(reason: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 来源实例选择确认 → 创建预检并切换预检卡(决策 4:两步第一步) */
|
||||
async function onSourceConfirm(sourceCodes: string[]) {
|
||||
/** 来源实例选择确认 → 创建预检并切换预检卡(决策 4:两步第一步;收料日期范围为查询范围) */
|
||||
async function onSourceConfirm(
|
||||
sourceCodes: string[],
|
||||
dateRange?: { from?: string; to?: string },
|
||||
) {
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.createPrecheck(sourceCodes);
|
||||
await transfer.createPrecheck(sourceCodes, undefined, dateRange);
|
||||
mode.value = 'precheck';
|
||||
summaryRef.value = transfer.precheck.value;
|
||||
items.value = transfer.items.value;
|
||||
@@ -206,6 +245,7 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
:busy="busy"
|
||||
:retrying="retryingSource"
|
||||
@confirm="onSourceConfirm"
|
||||
@download="onDownloadSources"
|
||||
@retry="onSourceRetry"
|
||||
/>
|
||||
<TransferPrecheckCard
|
||||
@@ -213,8 +253,11 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
:summary="summaryRef"
|
||||
:items="items"
|
||||
: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" />
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
emit execute(invoiceNos)(决策 4/5:无独立确认页)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import type { TransferPrecheckItem, TransferPrecheckSummary } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -14,11 +15,14 @@ const props = defineProps<{
|
||||
items: TransferPrecheckItem[];
|
||||
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 +30,57 @@ const selectedCount = computed(() =>
|
||||
);
|
||||
const executeDisabled = computed(() => props.busy || selectedCount.value === 0);
|
||||
|
||||
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
|
||||
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);
|
||||
}
|
||||
|
||||
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 selectedBlockedCount = computed(() =>
|
||||
filtered.value.filter((item) => isBlocked(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) => isBlocked(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);
|
||||
}
|
||||
@@ -78,19 +129,53 @@ function resultLabel(result: string): string {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<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 || selectedBlockedCount === 0"
|
||||
data-testid="transfer-precheck-requery-selected"
|
||||
@click="requerySelected"
|
||||
>
|
||||
{{ $t('chat.transfer.requerySelected') }}{{ selectedBlockedCount ? `(${selectedBlockedCount})` : '' }}
|
||||
</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.colToBatch') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
</tr>
|
||||
@@ -107,19 +192,22 @@ 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">{{ deriveBatchNo(item.lot_no) }}</td>
|
||||
<td class="p-2">{{ item.to_quantity }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
@@ -132,6 +220,16 @@ function resultLabel(result: string): string {
|
||||
>
|
||||
{{ $t(resultLabel(item.result)) }}
|
||||
</span>
|
||||
<button
|
||||
v-if="isBlocked(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>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -19,15 +19,19 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
confirm: [sourceCodes: string[]];
|
||||
confirm: [sourceCodes: string[], dateRange?: { from?: string; to?: string }];
|
||||
/** 批量重试收料 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('');
|
||||
|
||||
const platforms = computed(() => [...new Set(props.sources.map((source) => source.platform))]);
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
@@ -50,6 +54,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 +101,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 +117,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 });
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -142,6 +154,36 @@ function confirm() {
|
||||
>
|
||||
{{ $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>
|
||||
<div class="ml-auto flex flex-wrap items-center gap-2">
|
||||
<label class="flex items-center gap-1 text-xs text-secondary">
|
||||
<span>{{ $t('chat.transfer.receiptDateFrom') }}</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"
|
||||
/>
|
||||
</label>
|
||||
<label class="flex items-center gap-1 text-xs text-secondary">
|
||||
<span>~</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"
|
||||
/>
|
||||
</label>
|
||||
<span class="text-xs text-muted">{{ $t('chat.transfer.receiptDateHint') }}</span>
|
||||
</div>
|
||||
<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"
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -60,11 +60,20 @@ export function useChatTransfer() {
|
||||
const estimatedQuantity = computed(() => precheck.value?.estimated_transfer_quantity ?? '0');
|
||||
|
||||
/** 创建预检(缺文件时来源级阶段展示等待/失败) */
|
||||
async function createPrecheck(sourceCodes: string[], businessDate?: string) {
|
||||
async function createPrecheck(
|
||||
sourceCodes: string[],
|
||||
businessDate?: string,
|
||||
dateRange?: { from?: string; to?: string },
|
||||
) {
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const summary = await createTransferPrecheck({ source_codes: sourceCodes, business_date: businessDate });
|
||||
const summary = await createTransferPrecheck({
|
||||
source_codes: sourceCodes,
|
||||
business_date: businessDate,
|
||||
receipt_date_from: dateRange?.from,
|
||||
receipt_date_to: dateRange?.to,
|
||||
});
|
||||
precheckId.value = summary.precheck_id;
|
||||
await refreshPrecheck();
|
||||
return summary;
|
||||
|
||||
@@ -50,6 +50,7 @@ export interface TransferPrecheckItem {
|
||||
reason?: string;
|
||||
erp_document_no?: string | null;
|
||||
raw_lines?: TransferRawLine[];
|
||||
lot_no?: string;
|
||||
}
|
||||
|
||||
/** 来源实例级进度(决策 18:来源隔离展示) */
|
||||
|
||||
@@ -844,7 +844,6 @@
|
||||
"exportsHelp": "Read-only inventory export results. Retries and manual exports are not initiated here.",
|
||||
"externalMappings": "Warehouse Mapping",
|
||||
"mappingsHelp": "Map a freight warehouse, or a source default, to an external system warehouse code.",
|
||||
"defaultMapping": "Source Default Mapping",
|
||||
"loadFailed": "Failed to load shipping inventory configuration",
|
||||
"createNew": "New",
|
||||
"saving": "Saving...",
|
||||
@@ -1053,7 +1052,7 @@
|
||||
"publishedImmutable": "Published rules are retained as immutable audit definitions. Create and publish a new rule instead.",
|
||||
"source": "Inventory Source",
|
||||
"chooseSource": "Select an inventory source",
|
||||
"freightWarehouse": "Freight Warehouse (optional)",
|
||||
"freightWarehouse": "Freight Warehouse",
|
||||
"externalSystem": "Target system",
|
||||
"externalOrganization": "Target organization (optional)",
|
||||
"externalSite": "Target site (optional)",
|
||||
|
||||
@@ -3716,9 +3716,19 @@
|
||||
"colName": "Name",
|
||||
"colSpec": "Spec",
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "Receipt Date",
|
||||
"colFromWarehouse": "From warehouse",
|
||||
"colFromQty": "From qty",
|
||||
"colToWarehouse": "To warehouse",
|
||||
"colFromBatch": "Outbound Batch",
|
||||
"colToBatch": "Inbound Batch",
|
||||
"filterPlaceholder": "Filter by material / name / Invoice / batch",
|
||||
"filterAll": "All results",
|
||||
"requerySelected": "Requery selected ERP stock",
|
||||
"receiptDateFrom": "Receipt date from",
|
||||
"receiptDateTo": "Receipt date to",
|
||||
"receiptDateHint": "End cannot exceed the D+1 rule (day before business date)",
|
||||
"requeryRow": "Requery",
|
||||
"colToQty": "To qty",
|
||||
"colResult": "Result",
|
||||
"resultExecutable": "Executable",
|
||||
@@ -3788,6 +3798,7 @@
|
||||
"selectVisible": "Select visible",
|
||||
"selectRetryable": "Select retryable",
|
||||
"batchRetry": "Batch retry RPA",
|
||||
"downloadFiles": "Download receipt files",
|
||||
"selectedRetryableCount": "{count} retryable",
|
||||
"noRetryable": "No selected source needs retry (already ready or fetching)"
|
||||
}
|
||||
|
||||
@@ -844,7 +844,6 @@
|
||||
"exportsHelp": "ดูผลการส่งออกสต็อกแบบอ่านอย่างเดียว ไม่สั่งส่งออกหรือทดลองใหม่ที่นี่",
|
||||
"externalMappings": "การแมปคลัง",
|
||||
"mappingsHelp": "แมปคลังของผู้ให้บริการขนส่ง หรือคลังเริ่มต้นของแหล่งข้อมูล ไปยังรหัสคลังของระบบภายนอก",
|
||||
"defaultMapping": "การแมปเริ่มต้นของแหล่งข้อมูล",
|
||||
"loadFailed": "โหลดการตั้งค่าสินค้าคงคลังขนส่งไม่สำเร็จ",
|
||||
"createNew": "สร้างใหม่",
|
||||
"saving": "กำลังบันทึก...",
|
||||
@@ -1053,7 +1052,7 @@
|
||||
"publishedImmutable": "กฎที่เผยแพร่จะถูกเก็บเป็นคำนิยามตรวจสอบที่แก้ไขไม่ได้ โปรดสร้างและเผยแพร่กฎใหม่แทน",
|
||||
"source": "แหล่งสต็อก",
|
||||
"chooseSource": "เลือกแหล่งสต็อก",
|
||||
"freightWarehouse": "คลังผู้ให้บริการ (ไม่บังคับ)",
|
||||
"freightWarehouse": "คลังผู้ให้บริการ",
|
||||
"externalSystem": "ระบบปลายทาง",
|
||||
"externalOrganization": "องค์กรปลายทาง (ไม่บังคับ)",
|
||||
"externalSite": "สถานที่ปลายทาง (ไม่บังคับ)",
|
||||
|
||||
@@ -3716,9 +3716,19 @@
|
||||
"colName": "ชื่อ",
|
||||
"colSpec": "สเปก",
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "วันที่รับสินค้า",
|
||||
"colFromWarehouse": "คลังต้นทาง",
|
||||
"colFromQty": "จำนวนต้นทาง",
|
||||
"colToWarehouse": "คลังปลายทาง",
|
||||
"colFromBatch": "ล็อตต้นทาง",
|
||||
"colToBatch": "ล็อตปลายทาง",
|
||||
"filterPlaceholder": "กรองตามรหัสวัสดุ / ชื่อ / Invoice / ล็อต",
|
||||
"filterAll": "ทุกผลลัพธ์",
|
||||
"requerySelected": "ตรวจซ้ำ ERP ที่เลือก",
|
||||
"receiptDateFrom": "วันที่รับสินค้าจาก",
|
||||
"receiptDateTo": "วันที่รับสินค้าถึง",
|
||||
"receiptDateHint": "วันสิ้นสุดต้องไม่เกินกฎ D+1 (วันก่อนวันทำการ)",
|
||||
"requeryRow": "ตรวจซ้ำ",
|
||||
"colToQty": "จำนวนปลายทาง",
|
||||
"colResult": "ผลตรวจ",
|
||||
"resultExecutable": "ดำเนินการได้",
|
||||
@@ -3788,6 +3798,7 @@
|
||||
"selectVisible": "เลือกที่เห็นทั้งหมด",
|
||||
"selectRetryable": "เลือกที่ลองใหม่ได้",
|
||||
"batchRetry": "ลองใหม่เป็นชุด",
|
||||
"downloadFiles": "ดาวน์โหลดไฟล์การรับสินค้า",
|
||||
"selectedRetryableCount": "ลองใหม่ได้ {count} รายการ",
|
||||
"noRetryable": "ไม่มีแหล่งที่เลือกต้องลองใหม่ (พร้อมแล้วหรือกำลังดึง)"
|
||||
}
|
||||
|
||||
@@ -973,7 +973,6 @@
|
||||
"exportsHelp": "只读查看库存导出的执行结果;不在此处重试或触发导出。",
|
||||
"externalMappings": "仓库映射",
|
||||
"mappingsHelp": "将货代仓库或库存源默认仓库映射到外部系统仓库编码。",
|
||||
"defaultMapping": "库存源默认映射",
|
||||
"loadFailed": "加载货代库存配置失败",
|
||||
"createNew": "新建",
|
||||
"saving": "保存中...",
|
||||
@@ -1182,7 +1181,7 @@
|
||||
"publishedImmutable": "已发布规则作为审计定义保留,不能修改。请新建规则后重新发布。",
|
||||
"source": "库存源",
|
||||
"chooseSource": "请选择库存源",
|
||||
"freightWarehouse": "货代仓库(可选)",
|
||||
"freightWarehouse": "货代仓库",
|
||||
"externalSystem": "目标系统",
|
||||
"externalOrganization": "目标组织(可选)",
|
||||
"externalSite": "目标地点(可选)",
|
||||
|
||||
@@ -3790,9 +3790,19 @@
|
||||
"colName": "品名",
|
||||
"colSpec": "规格",
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "收料日期",
|
||||
"colFromWarehouse": "拨出仓库",
|
||||
"colFromQty": "拨出数量",
|
||||
"colToWarehouse": "拨入仓库",
|
||||
"colFromBatch": "拨出批号",
|
||||
"colToBatch": "拨入批号",
|
||||
"filterPlaceholder": "按料号 / 品名 / Invoice / 批号筛选",
|
||||
"filterAll": "全部结果",
|
||||
"requerySelected": "重查选中 ERP 库存",
|
||||
"receiptDateFrom": "收料日期起",
|
||||
"receiptDateTo": "收料日期止",
|
||||
"receiptDateHint": "截止不超出 D+1 规则(业务日期前一天)",
|
||||
"requeryRow": "重查",
|
||||
"colToQty": "拨入数量",
|
||||
"colResult": "预检结果",
|
||||
"resultExecutable": "可执行",
|
||||
@@ -3862,6 +3872,7 @@
|
||||
"selectVisible": "全选可见",
|
||||
"selectRetryable": "只选可重试",
|
||||
"batchRetry": "批量重试 RPA",
|
||||
"downloadFiles": "下载收料文件",
|
||||
"selectedRetryableCount": "其中 {count} 个可重试",
|
||||
"noRetryable": "所选来源均无需重试(已就绪或抓取中)"
|
||||
}
|
||||
|
||||
@@ -844,7 +844,6 @@
|
||||
"exportsHelp": "唯讀查看庫存匯出的執行結果;此處不重試或觸發匯出。",
|
||||
"externalMappings": "倉庫映射",
|
||||
"mappingsHelp": "將貨代倉庫或庫存來源預設倉庫對應至外部系統倉庫編碼。",
|
||||
"defaultMapping": "庫存來源預設對應",
|
||||
"loadFailed": "載入貨代庫存設定失敗",
|
||||
"createNew": "新增",
|
||||
"saving": "儲存中...",
|
||||
@@ -1053,7 +1052,7 @@
|
||||
"publishedImmutable": "已發布規則作為稽核定義保留,不能修改。請新增規則後重新發布。",
|
||||
"source": "庫存來源",
|
||||
"chooseSource": "請選擇庫存來源",
|
||||
"freightWarehouse": "貨代倉庫(可選)",
|
||||
"freightWarehouse": "貨代倉庫",
|
||||
"externalSystem": "目標系統",
|
||||
"externalOrganization": "目標組織(可選)",
|
||||
"externalSite": "目標地點(可選)",
|
||||
|
||||
@@ -3716,9 +3716,19 @@
|
||||
"colName": "品名",
|
||||
"colSpec": "規格",
|
||||
"colInvoice": "Invoice",
|
||||
"colReceiptDate": "收料日期",
|
||||
"colFromWarehouse": "撥出倉庫",
|
||||
"colFromQty": "撥出數量",
|
||||
"colToWarehouse": "撥入倉庫",
|
||||
"colFromBatch": "撥出批號",
|
||||
"colToBatch": "撥入批號",
|
||||
"filterPlaceholder": "按料號 / 品名 / Invoice / 批號篩選",
|
||||
"filterAll": "全部結果",
|
||||
"requerySelected": "重查選中 ERP 庫存",
|
||||
"receiptDateFrom": "收料日期起",
|
||||
"receiptDateTo": "收料日期止",
|
||||
"receiptDateHint": "截止不超出 D+1 規則(業務日期前一天)",
|
||||
"requeryRow": "重查",
|
||||
"colToQty": "撥入數量",
|
||||
"colResult": "預檢結果",
|
||||
"resultExecutable": "可執行",
|
||||
@@ -3788,6 +3798,7 @@
|
||||
"selectVisible": "全選可見",
|
||||
"selectRetryable": "只選可重試",
|
||||
"batchRetry": "批次重試 RPA",
|
||||
"downloadFiles": "下載收料文件",
|
||||
"selectedRetryableCount": "其中 {count} 個可重試",
|
||||
"noRetryable": "所選來源均無需重試(已就緒或抓取中)"
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user