feat(in-transit-transfer): 自动调拨联动收料就绪并分层来源错误

- 调度整合:退役 in_transit_receipt_file_job,收料归档收敛 shipping_receipt_rpa_archive,排程注册表统一
- 自动调拨 Job:调拨前确保各来源当日收料文件就绪(缺失自动触发收料 RPA),严格等量匹配后生成 ERP 调拨单
- worker 手动唤醒:排程工作台支持手动唤醒与 runs 透视,heartbeat 协议同步
- 收料缺失幸存 T2:parse_failed 状态落库(迁移 q4c5)
- 来源错误分层与 stale 时钟换源:改挂 inventory_checked_at 库存查得时刻,展示阈值与执行门禁解耦(迁移 t5a6)
- 新增 wecom_sender 企微通知:每非空 Run 汇总一条,通知失败不影响 ERP 结果
- 同步排程工作台/调拨卡片前端、chat/admin 文案四语言、RPA 脚本与测试全家
This commit is contained in:
hugo committed 2026-09-30 00:20:06 +08:00
1 parent 993e581135
commit abf3d48927
144 files changed
+10161 -2132

No files matched your search

@@ -159,6 +159,9 @@ export const adminRunExcelUrl = (runId: number) => `/api/admin/schedule-runs/${r
export const adminRunInventoryRawZipUrl = (runId: number) =>
`/api/admin/schedule-runs/${runId}/inventory-raw-zip`;
export const adminRunReceiptRawZipUrl = (runId: number) =>
`/api/admin/schedule-runs/${runId}/receipt-raw-zip`;
export interface RpaWorkerHeartbeatWorker {
worker_id?: string;
hostname?: string;
@@ -178,6 +181,7 @@ export interface RpaWorkerHeartbeatWorker {
}
export interface RpaWorkerHeartbeatSummary {
scope?: 'inventory' | 'receipt' | string;
ready: boolean;
message: string;
detail_message?: string;
@@ -191,7 +195,7 @@ export interface RpaWorkerHeartbeatSummary {
workers: RpaWorkerHeartbeatWorker[];
}
export const getAdminRpaWorkersStatus = () =>
getJson<RpaWorkerHeartbeatSummary>('/api/admin/rpa-workers/status');
export const getAdminRpaWorkersStatus = (scope: 'inventory' | 'receipt' = 'inventory') =>
getJson<RpaWorkerHeartbeatSummary>(`/api/admin/rpa-workers/status?scope=${encodeURIComponent(scope)}`);
export type { DifyExecutionSnapshot, ScheduleRun, ScheduleTask, StepLog, TestScheduleRunResult, TestScheduleSqlResult };
@@ -36,7 +36,7 @@ const admin = useSchedulesAdminContext();
</div>
<button
class="inline-flex items-center gap-2 admin-panel px-5 py-2.5 text-sm font-semibold text-secondary transition hover:bg-surface-soft"
@click="admin.loadSchedules"
@click="() => void admin.loadSchedules()"
>
<RefreshCw class="h-5 w-5" />
{{ $t('admin.schedule.refresh') }}
@@ -1,6 +1,6 @@
/**
* features/admin/modules/schedules/components/ScheduleWorkbenchPanel.spec.ts
* 用途:断言执行记录页不默认展示原始库存下载;仅企微深链 raw_zip=1 时突出下载入口。
* 用途:断言执行记录页不默认展示原始库存/收料下载;仅企微深链 raw_zip=1 时突出下载入口。
*/
import { readFileSync } from 'node:fs';
import { resolve } from 'node:path';
@@ -11,13 +11,16 @@ describe('ScheduleWorkbenchPanel run table actions', () => {
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
const content = readFileSync(panelPath, 'utf8');
expect(content).not.toMatch(/downloadScheduleInventoryRawZip\(r\.id\)/);
expect(content).not.toMatch(/downloadScheduleReceiptRawZip\(r\.id\)/);
});
it('only shows raw inventory download when wecom deep link prompt is active', () => {
it('only shows raw inventory/receipt download when wecom deep link prompt is active', () => {
const panelPath = resolve(__dirname, 'ScheduleWorkbenchPanel.vue');
const content = readFileSync(panelPath, 'utf8');
expect(content).toMatch(/wecomRawZipPromptRunId/);
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.inventory_raw_zip_available"/);
expect(content).not.toMatch(/v-if="admin\.expandedScheduleRun\.receipt_raw_zip_available"/);
expect(content).toMatch(/admin\.wecomRawZipPromptRunId === admin\.expandedScheduleRun\.id/);
expect(content).toMatch(/downloadScheduleReceiptRawZip/);
});
});
@@ -34,7 +34,13 @@ const admin = useSchedulesAdminContext();
</div>
<div class="admin-stat-tile px-4 py-3 text-center">
<div class="text-base font-semibold text-amber-600">{{ admin.selectedScheduleRunMetrics.skipped }}</div>
<div class="mt-1 text-xs text-muted">{{ $t('admin.schedule.totalSkipped') }}</div>
<div class="mt-1 text-xs text-muted">{{
admin.isReceiptRpaSchedule
? $t('admin.schedule.totalSkippedReceipt')
: admin.isInventoryRpaSchedule
? $t('admin.schedule.totalSkippedInventory')
: $t('admin.schedule.totalSkipped')
}}</div>
</div>
<div class="admin-stat-tile px-4 py-3 text-center">
<div class="text-base font-semibold text-rose-600">{{ admin.selectedScheduleRunMetrics.failed }}</div>
@@ -131,7 +137,7 @@ const admin = useSchedulesAdminContext();
<p class="mt-1 text-sm text-muted">{{ $t('admin.schedule.recordsSubtitle') }}</p>
</div>
<div
v-if="admin.isInventoryRpaSchedule"
v-if="admin.showsRpaWorkerStatus"
class="inline-flex items-center gap-2 rounded-lg border border-default px-3 py-2 text-xs"
>
<span class="text-muted">{{ $t('admin.schedule.rpaWorker.title') }}</span>
@@ -310,6 +316,20 @@ const admin = useSchedulesAdminContext();
{{ $t('admin.schedule.downloadInventoryRawZipPackage') }}
</button>
</div>
<div
v-if="admin.wecomRawZipPromptRunId === admin.expandedScheduleRun.id && admin.expandedScheduleRun.receipt_raw_zip_available"
class="rounded-xl border border-blue-200 bg-blue-50/80 p-4"
>
<p class="text-sm font-medium text-blue-900">{{ $t('admin.schedule.rawReceiptZipWecomHint') }}</p>
<button
type="button"
class="mt-3 inline-flex items-center gap-2 rounded-xl border border-blue-300 bg-surface px-4 py-2 text-sm font-semibold text-blue-700 shadow-sm transition-colors hover:bg-blue-50"
@click="admin.downloadScheduleReceiptRawZip(admin.expandedScheduleRun.id)"
>
<Download class="h-4 w-4 shrink-0" />
{{ $t('admin.schedule.downloadReceiptRawZipPackage') }}
</button>
</div>
<div
v-if="admin.expandedScheduleRun.kb_sync_status"
class="rounded-xl border border-emerald-200 bg-emerald-50/50 p-3 text-xs text-secondary"
@@ -72,7 +72,7 @@ export function createScheduleAdminState() {
{ key: 'status', label: '', width: 130, min: 50 },
{ key: 'total_count', label: '', width: 70, min: 40 },
{ key: 'success_count', label: '', width: 70, min: 40 },
{ key: 'skipped_count', label: '', width: 70, min: 40 },
{ key: 'skipped_count', label: '', width: 110, min: 88 },
{ key: 'failed_count', label: '', width: 70, min: 40 },
{ key: 'wecom_notified', label: '', width: 100, min: 80 },
{ key: 'detail', label: '', width: 100, min: 80 },
@@ -88,7 +88,7 @@ export function createScheduleAdminState() {
const scheduleConfigCollapsed = ref(true);
const expandedScheduleRunId = ref<number | null>(null);
/** 企微深链 raw_zip=1 进入时待手动下载的执行记录 ID;普通列表浏览不展示原始库存下载入口。 */
/** 企微深链 raw_zip=1 进入时待手动下载的执行记录 ID;普通列表浏览不展示原始库存/收料下载入口。 */
const wecomRawZipPromptRunId = ref<number | null>(null);
const showTestRunDialog = ref(false);
@@ -1,6 +1,6 @@
/**
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminDeepLink.ts
* 用途:解析企微深链 query,定位排程执行记录并在登录后自动下载原始库存包。
* 用途:解析企微深链 query,定位排程执行记录并在登录后自动下载原始库存/收料包。
* 依赖:vue-router、schedule-admin.state、useScheduleAdminRuns。
* 逻辑:SchedulesPage onMounted 在 loadAll 后调用;消费 task_id/run_id/raw_zip/download,自动下载失败时保留手动入口。
*/
@@ -16,11 +16,15 @@ function parsePositiveInt(raw: unknown): number | null {
/**
* 根据路由 query 打开工作台执行记录;raw_zip=1 时展开 run 并保留手动下载按钮。
* 核心逻辑:download=inventory_raw_zip 时登录后自动下载一次;若企微内置浏览器拦截,用户仍可点醒目按钮重试。
* 核心逻辑:download=inventory_raw_zip / receipt_raw_zip 时登录后自动下载一次;
* 若企微内置浏览器拦截,用户仍可点醒目按钮重试。
*/
export function useScheduleAdminDeepLink(
state: ScheduleAdminState,
runs: Pick<ScheduleAdminRuns, 'viewScheduleRuns' | 'downloadScheduleInventoryRawZip'>,
runs: Pick<
ScheduleAdminRuns,
'viewScheduleRuns' | 'downloadScheduleInventoryRawZip' | 'downloadScheduleReceiptRawZip'
>,
) {
const route = useRoute();
const router = useRouter();
@@ -31,7 +35,11 @@ export function useScheduleAdminDeepLink(
const runId = parsePositiveInt(route.query.run_id);
const rawZipPrompt = String(route.query.raw_zip || '') === '1';
const shouldAutoDownloadRawZip = rawZipPrompt && String(route.query.download || '') === 'inventory_raw_zip';
const downloadKind = String(route.query.download || '');
const shouldAutoDownloadInventory =
rawZipPrompt && downloadKind === 'inventory_raw_zip';
const shouldAutoDownloadReceipt =
rawZipPrompt && downloadKind === 'receipt_raw_zip';
state.scheduleViewMode.value = 'workbench';
state.selectedScheduleId.value = taskId;
@@ -42,11 +50,15 @@ export function useScheduleAdminDeepLink(
state.expandedScheduleRunId.value = runId;
if (rawZipPrompt) {
const target = state.selectedScheduleRuns.value.find((item) => item.id === runId);
if (target?.inventory_raw_zip_available) {
if (target?.inventory_raw_zip_available && shouldAutoDownloadInventory) {
state.wecomRawZipPromptRunId.value = runId;
await runs.downloadScheduleInventoryRawZip(runId);
} else if (target?.receipt_raw_zip_available && shouldAutoDownloadReceipt) {
state.wecomRawZipPromptRunId.value = runId;
await runs.downloadScheduleReceiptRawZip(runId);
} else if (target?.inventory_raw_zip_available || target?.receipt_raw_zip_available) {
// 深链仅 raw_zip=1 无 download 时仍展示手动入口。
state.wecomRawZipPromptRunId.value = runId;
if (shouldAutoDownloadRawZip) {
await runs.downloadScheduleInventoryRawZip(runId);
}
}
}
}
@@ -1,9 +1,11 @@
/**
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminList.ts
* 任务列表加载、概览统计、启停/立即执行/删除与视图切换。
* 等待轮询策略:点「立即执行」后每 RUN_NOW_POLL_MS 刷新记录与列表,直到任务离开 running;
* 同一任务仅保留一个轮询(重复点击先清旧定时器)、上一轮未返回时跳过本轮,
* 并设 RUN_NOW_POLL_MAX_MS 上限,防止任务长时间不终态造成页面无限请求。
* 等待轮询策略:点「立即执行」后只轻量刷新任务 last_status(不刷执行记录 runs),
* 直到离开 running 再拉一次 runs;与「执行记录=历史查询、不做定时刷新」对齐。
* 同一任务仅保留一个轮询、上一轮未返回时跳过,并设 RUN_NOW_POLL_MAX_MS 上限。
* 库存/收料 RPA 写 trigger 后会长时间保持 running(awaiting callback),旧逻辑每 5s
* 全量 runs + loading 遮罩会把收料工作台打成「正在查询记录…」连环请求。
*/
import { computed } from 'vue';
import type { ComposerTranslation } from 'vue-i18n';
@@ -18,7 +20,7 @@ import { useMessage } from '@/shared/composables/useMessage';
import type { ScheduleAdminState } from './schedule-admin.state';
import type { ScheduleAdminRuns } from './useScheduleAdminRuns';
/** 立即执行后的等待轮询间隔 */
/** 立即执行后的等待轮询间隔(仅任务列表 last_status) */
const RUN_NOW_POLL_MS = 5_000;
/** 等待轮询总上限:与服务端库存导出超时(默认 900s)对齐,超限后停止自动刷新提示手动查询 */
const RUN_NOW_POLL_MAX_MS = 15 * 60_000;
@@ -47,7 +49,12 @@ export function useScheduleAdminList(
const scheduleDisabledCount = computed(() => schedules.value.filter((item) => !item.enabled).length);
const scheduleRunningCount = computed(() => schedules.value.filter((item) => item.last_status === 'running').length);
const loadSchedules = async () => {
/**
* 加载排程任务列表;可选顺带刷新当前工作台执行记录。
* @param options.includeRuns - 工作台模式下是否拉取 runs;立即执行等待轮询传 false,避免连环打 API
*/
const loadSchedules = async (options?: { includeRuns?: boolean }) => {
const includeRuns = options?.includeRuns !== false;
scheduleLoading.value = true;
try {
schedules.value = await listAdminSchedules();
@@ -62,7 +69,7 @@ export function useScheduleAdminList(
if (!exists && nextScheduleId) {
selectedScheduleId.value = nextScheduleId;
}
if (scheduleViewMode.value === 'workbench' && nextScheduleId) {
if (includeRuns && scheduleViewMode.value === 'workbench' && nextScheduleId) {
await runs.viewScheduleRuns(nextScheduleId);
}
} finally {
@@ -83,6 +90,11 @@ export function useScheduleAdminList(
scheduleViewMode.value = 'overview';
};
/**
* 立即执行排程;等待期只轮询任务 last_status,不定时刷新执行记录。
* 核心逻辑:触发后先拉一次 runs;之后每 RUN_NOW_POLL_MS 仅 listAdminSchedules;
* 终态或超时后再拉一次 runs。库存/收料共用,避免 RPA awaiting 长 running 连环打 runs。
*/
const runScheduleNow = async (taskId: number) => {
try {
await runAdminSchedule(taskId);
@@ -90,8 +102,9 @@ export function useScheduleAdminList(
msg.error(err?.message || t('admin.schedule.msg.runNowFailed'));
return;
}
// [STEP 1] 触发后立刻展示本轮记录一次;任务列表不重复带 runs
await runs.viewScheduleRuns(taskId, true);
await loadSchedules();
await loadSchedules({ includeRuns: false });
// 同一任务只保留一个等待轮询:重复点击先停旧定时器,避免多路 interval 并行放大请求频率
const previousPoll = runNowPollTimers.get(taskId);
@@ -103,8 +116,8 @@ export function useScheduleAdminList(
if (runNowPollsInFlight.has(taskId)) return;
runNowPollsInFlight.add(taskId);
try {
await runs.viewScheduleRuns(taskId, true);
await loadSchedules();
// [STEP 2] 等待期只刷新 last_status,禁止 viewScheduleRuns(否则工作台会遮「正在查询记录…」)
await loadSchedules({ includeRuns: false });
elapsedMs += RUN_NOW_POLL_MS;
const target = schedules.value.find((s: ScheduleTask) => s.id === taskId);
const terminal = !!target?.last_status && target.last_status !== 'running';
@@ -112,6 +125,10 @@ export function useScheduleAdminList(
if (terminal || timedOut) {
clearInterval(pollInterval);
runNowPollTimers.delete(taskId);
// [STEP 3] 终态/超时后再拉一次执行记录,给表格最终结果
if (scheduleViewMode.value === 'workbench') {
await runs.viewScheduleRuns(taskId, true);
}
if (timedOut && !terminal) {
msg.warning(t('admin.schedule.msg.runNowWaitTimeout'));
}
@@ -2,15 +2,17 @@
* features/admin/modules/schedules/composables/schedule-admin/useScheduleAdminRuns.ts
* 执行批次列表:筛选、列宽、展开详情、Excel 下载、指标派生与 RPA Worker 心跳轮询。
* 轮询策略(历史查询与监控职责分离):执行记录列表是纯历史查询,仅切任务/查询/重置时按需加载;
* RPA Worker 在线状态是监控信号,仅在库存排程工作台模式下每 RPA_WORKER_STATUS_POLL_MS 静默轮询一次,
* RPA Worker 在线状态是监控信号,仅在库存/收料排程工作台模式下每 RPA_WORKER_STATUS_POLL_MS 静默轮询一次,
* 后台标签页暂停、请求未返回时跳过(防堆叠),使「在线/离线」徽标及时反映心跳。
* 收料/库存排程的跳过列与统计砖分别显示「无收料/跳过」「无库存/跳过」。
*/
import { computed, onBeforeUnmount, watch, type Ref } from 'vue';
import type { ComposerTranslation } from 'vue-i18n';
import { listAdminScheduleRuns, adminRunInventoryRawZipUrl, getAdminRpaWorkersStatus } from '@/features/admin/api/schedule.api';
import { listAdminScheduleRuns, adminRunInventoryRawZipUrl, adminRunReceiptRawZipUrl, getAdminRpaWorkersStatus } from '@/features/admin/api/schedule.api';
import { useMessage } from '@/shared/composables/useMessage';
import { getAuthHeaders } from '@/shared/utils/auth';
import { formatDateTime } from '../../utils/schedule-format.utils';
import { normalizePlatformJobKey } from '../../utils/schedule-job-key.utils';
import {
getScheduleRunFailedCountTitle as buildScheduleRunFailedCountTitle,
isScheduleRunExcelExportFailed,
@@ -39,7 +41,31 @@ export function useScheduleAdminRuns(
scheduleViewMode,
} = state;
const selectedSchedule = computed(() =>
schedules.value.find((item) => item.id === selectedScheduleId.value) || null,
);
const selectedScheduleJobKey = computed(
() => normalizePlatformJobKey(selectedSchedule.value?.platform_api_path),
);
const isInventoryRpaSchedule = computed(
() => selectedScheduleJobKey.value === 'shipping-inventory-rpa',
);
const isReceiptRpaSchedule = computed(
() => selectedScheduleJobKey.value === 'freight-receipt-rpa',
);
/**
* 同步执行记录列表表头文案;收料/库存排程的「跳过」列分别显示无收料/无库存。
*/
const syncScheduleRunColumnLabels = () => {
const skippedKey = isReceiptRpaSchedule.value
? 'skippedCountReceipt'
: isInventoryRpaSchedule.value
? 'skippedCountInventory'
: 'skippedCount';
const keyToI18n: Record<string, string> = {
run_no: 'runNo',
started_at: 'startedAt',
@@ -47,7 +73,7 @@ export function useScheduleAdminRuns(
status: 'status',
total_count: 'totalCount',
success_count: 'successCount',
skipped_count: 'skippedCount',
skipped_count: skippedKey,
failed_count: 'failedCount',
wecom_notified: 'wecomNotified',
detail: 'detail',
@@ -58,7 +84,11 @@ export function useScheduleAdminRuns(
if (i18nKey) col.label = t(`admin.schedule.columns.${i18nKey}`);
});
};
watch(locale, syncScheduleRunColumnLabels, { immediate: true });
watch(
[locale, isReceiptRpaSchedule, isInventoryRpaSchedule],
syncScheduleRunColumnLabels,
{ immediate: true },
);
const onScheduleColResizeMove = (event: MouseEvent) => {
const resizeState = resizingScheduleCol.value;
@@ -88,10 +118,6 @@ export function useScheduleAdminRuns(
window.addEventListener('mouseup', stopScheduleColResize);
};
const selectedSchedule = computed(() =>
schedules.value.find((item) => item.id === selectedScheduleId.value) || null,
);
const scheduleRunStatusOptions = computed(() => [
{ value: 'all', label: t('admin.schedule.status.all') },
{ value: 'success', label: t('admin.schedule.status.success') },
@@ -152,8 +178,13 @@ export function useScheduleAdminRuns(
return raw ? formatDateTime(raw) : '-';
});
const isInventoryRpaSchedule = computed(
() => selectedSchedule.value?.platform_api_path === 'shipping-inventory-rpa',
/** 库存或收料排程工作台均展示 RPA Worker 心跳徽标。 */
const showsRpaWorkerStatus = computed(
() => isInventoryRpaSchedule.value || isReceiptRpaSchedule.value,
);
const rpaWorkerStatusScope = computed<'inventory' | 'receipt'>(() =>
(isReceiptRpaSchedule.value ? 'receipt' : 'inventory'),
);
const rpaWorkerLastHeartbeatAt = computed(() => {
@@ -171,13 +202,13 @@ export function useScheduleAdminRuns(
* @param silent - 静默模式:由后台轮询调用,不翻转 loading,避免徽标每轮闪烁「加载中」
*/
const refreshRpaWorkerStatus = async (silent = false) => {
if (!isInventoryRpaSchedule.value) {
if (!showsRpaWorkerStatus.value) {
rpaWorkerStatus.value = null;
return;
}
if (!silent) rpaWorkerStatusLoading.value = true;
try {
rpaWorkerStatus.value = await getAdminRpaWorkersStatus();
rpaWorkerStatus.value = await getAdminRpaWorkersStatus(rpaWorkerStatusScope.value);
} catch {
rpaWorkerStatus.value = null;
} finally {
@@ -185,14 +216,14 @@ export function useScheduleAdminRuns(
}
};
// ── RPA Worker 心跳轮询(监控信号,仅库存排程) ─────────────────────────
// ── RPA Worker 心跳轮询(监控信号,库存/收料排程) ───────────────────────
// 心跳由 Worker 每约 20s 上报一次(服务端 TTL 默认 90s),UI 每 10s 刷新即足够;
// 2s 固定轮询只有少量时间点在变化,属于对无变化数据的过度请求。
const RPA_WORKER_STATUS_POLL_MS = 10_000;
/** 是否需要前台轮询心跳:仅工作台模式且当前排程为库存类(该徽标仅在此时可见) */
/** 是否需要前台轮询心跳:工作台模式且当前排程为库存或收料类 */
const shouldPollRpaWorkerStatus = computed(
() => scheduleViewMode.value === 'workbench' && isInventoryRpaSchedule.value && !!selectedScheduleId.value,
() => scheduleViewMode.value === 'workbench' && showsRpaWorkerStatus.value && !!selectedScheduleId.value,
);
let rpaStatusPollTimer: ReturnType<typeof setInterval> | null = null;
@@ -301,6 +332,27 @@ export function useScheduleAdminRuns(
URL.revokeObjectURL(url);
};
/**
* 下载收料原始 ZIP;API 与文件名口径对齐库存 raw zip。
*/
const downloadScheduleReceiptRawZip = async (runId: number) => {
const res = await fetch(adminRunReceiptRawZipUrl(runId), { headers: getAuthHeaders() });
if (!res.ok) {
msg.error(t('admin.schedule.msg.downloadReceiptRawZipFailed'));
return;
}
const blob = await res.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
const disposition = res.headers.get('content-disposition');
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '收料RPA-收料.zip';
document.body.appendChild(a);
a.click();
document.body.removeChild(a);
URL.revokeObjectURL(url);
};
const getScheduleRunFailedCountTitle = (run: (typeof selectedScheduleRuns.value)[number]) =>
buildScheduleRunFailedCountTitle(run, t('admin.schedule.excelExportFailedHint'));
@@ -315,12 +367,15 @@ export function useScheduleAdminRuns(
selectedScheduleRunMetrics,
selectedScheduleLatestRunAt,
isInventoryRpaSchedule,
isReceiptRpaSchedule,
showsRpaWorkerStatus,
rpaWorkerLastHeartbeatAt,
refreshRpaWorkerStatus,
resetScheduleRunFilters,
viewScheduleRuns,
downloadScheduleExcel,
downloadScheduleInventoryRawZip,
downloadScheduleReceiptRawZip,
startScheduleColResize,
formatDateTime,
isScheduleRunExcelExportFailed,
@@ -124,39 +124,40 @@
<label><span>{{ t('admin.shippingInventory.inventorySiteName') }}</span><input v-model="source.display_name" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.connectorType') }}</span><select v-model="source.connector_type" class="select-field"><option value="dbs">{{ t('admin.shippingInventory.platform.dbs') }}</option><option value="crane">{{ t('admin.shippingInventory.platform.crane') }}</option></select></label>
<label><span>{{ t('admin.shippingInventory.connection') }}</span><select v-model.number="source.rpa_profile_id" class="select-field" required><option :value="0">{{ t('admin.shippingInventory.chooseConnection') }}</option><option v-for="item in compatibleProfiles" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }}</option></select></label>
<label><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="source.parsing_profile_id" class="select-field" :disabled="source.enabled"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'movement')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
<label><span>{{ t('admin.shippingInventory.excelTemplates') }}</span><select v-model.number="source.excel_template_id" class="select-field"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in excelTemplates.filter((row) => row.status === 'published')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.template_code }}</option></select></label>
<label><span>{{ t('admin.shippingInventory.warehouseResolution') }}</span><select v-model="source.warehouse_resolution_mode" class="select-field"><option value="fixed">{{ t('admin.shippingInventory.fixedWarehouse') }}</option><option value="inventory_match">{{ t('admin.shippingInventory.inventoryMatch') }}</option></select></label>
<label v-if="source.warehouse_resolution_mode === 'fixed'"><span>{{ t('admin.shippingInventory.warehouse') }}</span><input v-model="source.fixed_warehouse_id" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.snapshotTtl') }}</span><input v-model.number="source.snapshot_ttl_seconds" class="input-field" min="1" type="number" required></label>
<div v-if="!selectedId" class="form-tip full">{{ t('admin.shippingInventory.sourceSavedDisabledHint') }}</div>
<template v-if="source.connector_type === 'dbs'">
<section class="path-card full">
<!-- DBS/Crane 共用「库存报表配置」分组:DBS 含路径+条件,Crane 仅解析绑定;徽标与收料卡同构。 -->
<section class="path-card full" :class="{ configured: inventoryReportConfigExists }">
<button type="button" class="path-card-header" :aria-expanded="inventoryPathOpen" @click="inventoryPathOpen = !inventoryPathOpen">
<span class="path-card-title"><b>{{ t('admin.shippingInventory.reportPath') }}</b></span>
<span class="path-card-title"><b>{{ t('admin.shippingInventory.inventoryReportConfig') }}</b></span>
<span class="path-badge" :class="inventoryReportConfigExists ? 'on' : 'off'">{{ inventoryReportConfigExists ? t('admin.shippingInventory.pathSectionConfigured') : t('admin.shippingInventory.pathSectionNotConfigured') }}</span>
<span class="path-card-toggle" aria-hidden="true">{{ inventoryPathOpen ? '▾' : '▸' }}</span>
</button>
<div v-show="inventoryPathOpen" class="path-card-body">
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
<template v-if="source.connector_type === 'dbs'">
<label><span>{{ t('admin.shippingInventory.programGroup') }}</span><input v-model="source.report_path_json.program_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="source.report_path_json.program_label" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="source.report_path_json.report_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="source.report_path_json.report_name" class="input-field" required></label>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
<div v-for="(parameter, index) in source.query_parameters_json" :key="`${index}-${parameter.name}`" class="parameter-row full">
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
<input class="input-field" :value="parameter.values.join(', ')" :placeholder="t('admin.shippingInventory.parameterValues')" @input="parameter.values = splitValues(($event.target as HTMLInputElement).value)">
<label class="inline-check"><input v-model="parameter.required" type="checkbox">{{ t('admin.shippingInventory.required') }}</label>
<label class="inline-check"><input v-model="parameter.select_all" type="checkbox">{{ t('admin.shippingInventory.selectAll') }}</label>
<button type="button" class="btn-danger btn-sm" @click="source.query_parameters_json.splice(index, 1)">{{ t('admin.delete') }}</button>
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
</template>
<label class="full"><span>{{ t('admin.shippingInventory.parsingProfiles') }}</span><select v-model.number="source.parsing_profile_id" class="select-field"><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'movement')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
</div>
</section>
</template>
<section v-if="selectedId" class="path-card receipt full" :class="{ configured: receiptConfigExists }">
<button type="button" class="path-card-header" :aria-expanded="receiptSectionOpen" @click="toggleReceiptSection">
<span class="path-card-title"><b>{{ t('admin.shippingInventory.receiptReportConfig') }}</b><small>{{ t('admin.shippingInventory.receiptReportConfigHint') }}</small></span>
<span class="path-card-title"><b>{{ t('admin.shippingInventory.receiptReportConfig') }}</b></span>
<span class="path-badge" :class="receiptConfigExists ? 'on' : 'off'">{{ receiptConfigExists ? t('admin.shippingInventory.pathSectionConfigured') : t('admin.shippingInventory.pathSectionNotConfigured') }}</span>
<span class="path-card-toggle" aria-hidden="true">{{ receiptSectionOpen ? '▾' : '▸' }}</span>
</button>
@@ -166,7 +167,7 @@
<label><span>{{ t('admin.shippingInventory.programLabel') }}</span><input v-model="receiptConfig.report_path_json.program_label" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportGroup') }}</span><input v-model="receiptConfig.report_path_json.report_group" class="input-field" required></label>
<label><span>{{ t('admin.shippingInventory.reportName') }}</span><input v-model="receiptConfig.report_path_json.report_name" class="input-field" required></label>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}<small>{{ t('admin.shippingInventory.receiptQueryParametersHint') }}</small></div>
<div class="subsection full">{{ t('admin.shippingInventory.queryParameters') }}</div>
<div v-for="(parameter, index) in receiptConfig.query_parameters_json" :key="`receipt-${index}-${parameter.name}`" class="parameter-row full">
<input v-model="parameter.name" class="input-field" :placeholder="t('admin.shippingInventory.parameterName')">
<select v-model="parameter.mode" class="select-field"><option value="single">{{ t('admin.shippingInventory.single') }}</option><option value="multi_text">{{ t('admin.shippingInventory.multiText') }}</option><option value="multi_select">{{ t('admin.shippingInventory.multiSelect') }}</option></select>
@@ -177,8 +178,7 @@
</div>
<button type="button" class="btn-secondary btn-sm full" @click="addReceiptParameter">{{ t('admin.shippingInventory.addParameter') }}</button>
</template>
<p v-else class="form-tip full">{{ t('admin.shippingInventory.receiptCraneFixedPath') }}</p>
<label class="full"><span>{{ t('admin.shippingInventory.movementBindingLabel') }}</span><select v-model.number="receiptConfig.parsing_profile_id" class="select-field"><option :value="null">{{ t('admin.shippingInventory.movementBindingNone') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'movement')" :key="`movement-bind-${item.id}`" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select><small>{{ t('admin.shippingInventory.movementBindingHint') }}</small></label>
<label class="full"><span>{{ t('admin.shippingInventory.movementBindingLabel') }}</span><select v-model.number="receiptConfig.parsing_profile_id" class="select-field"><option :value="null">{{ t('admin.shippingInventory.movementBindingNone') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose === 'movement')" :key="`movement-bind-${item.id}`" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
</div>
</section>
</template>
@@ -356,49 +356,35 @@
<div class="switch-field"><span>{{ t('admin.shippingInventory.enabled') }}</span><button type="button" class="status-switch" :class="{ on: mapping.enabled }" role="switch" :aria-checked="mapping.enabled" @click="mapping.enabled = !mapping.enabled"><i></i><b>{{ mapping.enabled ? t('admin.shippingInventory.enabledState') : t('admin.shippingInventory.disabledState') }}</b></button></div>
</template>
<section v-if="activeTab === 'sources' && selectedId" class="readiness-card full" :class="{ ready: source.enabled }">
<div class="readiness-inline">
<template v-if="source.enabled">
<span class="readiness-marker is-passed" aria-hidden="true">✓</span>
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.activationReady') }}</b><small v-if="configurationTest?.completed_at">{{ t('admin.shippingInventory.readinessLastVerified', { time: formatDate(configurationTest.completed_at) }) }}</small></div>
<button type="button" class="btn-danger btn-sm" @click="requestSourceDeactivation">{{ t('admin.shippingInventory.deactivateSource') }}</button>
</template>
<template v-else-if="firstBlockingCheck">
<span class="readiness-marker" :class="`is-${firstBlockingCheck.status}`" aria-hidden="true">{{ readinessMarker(firstBlockingCheck.status) }}</span>
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.readinessBlockedBy', { requirement: t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) }) }}</b><small>{{ t('admin.shippingInventory.readinessAutoEnableHint') }}</small></div>
<button v-if="readinessActionLabel(firstBlockingCheck)" type="button" class="readiness-action" :disabled="isReadinessActionBlocked(firstBlockingCheck)" :title="isReadinessActionBlocked(firstBlockingCheck) ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="runReadinessAction(firstBlockingCheck)">{{ readinessActionLabel(firstBlockingCheck) }}</button>
</template>
<template v-else>
<span class="readiness-marker is-passed" aria-hidden="true">✓</span>
<div class="readiness-copy"><b>{{ t('admin.shippingInventory.activationCanEnable') }}</b></div>
<button type="button" class="btn-primary btn-sm" :disabled="sourceDirty" :title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : undefined" @click="requestSourceActivation">{{ t('admin.shippingInventory.activateSource') }}</button>
</template>
<div v-if="isEditableTab" class="form-actions full">
<div
v-if="activeTab === 'sources' && selectedId"
class="source-enabled-footer"
data-testid="source-enabled-row"
>
<button
type="button"
class="status-switch"
:class="{ on: source.enabled }"
role="switch"
:aria-checked="source.enabled"
:disabled="sourceToggling || sourceDirty"
:title="sourceDirty ? t('admin.shippingInventory.saveBeforeReadinessAction') : t('admin.shippingInventory.sourceEnabledToggleHint')"
data-testid="source-enabled-switch"
@click="onSourceEnabledToggle"
>
<i></i>
</button>
<span class="source-enabled-label">{{ t('admin.shippingInventory.enabled') }}</span>
<small class="source-enabled-hint">{{
sourceDirty
? t('admin.shippingInventory.saveBeforeReadinessAction')
: (!source.enabled && firstBlockingCheck
? t('admin.shippingInventory.readinessBlockedBy', { requirement: t(`admin.shippingInventory.activationRequirement.${firstBlockingCheck.code}`) })
: t('admin.shippingInventory.sourceEnabledToggleHint'))
}}</small>
</div>
<details v-if="optionalReadinessChecks.length" class="readiness-optional">
<summary><span>{{ t('admin.shippingInventory.activationOptionalTitle') }}</span><small>{{ t('admin.shippingInventory.readinessOptionalPending', { count: optionalReadinessPending }) }}</small></summary>
<ol class="readiness-steps">
<li v-for="check in optionalReadinessChecks" :key="check.code" :class="`is-${check.status}`">
<span class="readiness-marker" aria-hidden="true">{{ readinessMarker(check.status) }}</span>
<div class="readiness-copy"><b>{{ t(`admin.shippingInventory.activationRequirement.${check.code}`) }}</b><small>{{ readinessDetail(check) }}</small></div>
</li>
</ol>
</details>
<template v-if="configurationTest">
<p v-if="configurationTest.status === 'failed'" class="readiness-run failed">{{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</p>
<p v-if="configurationTest.error_message" class="form-tip">{{ configurationTest.error_message }}</p>
<p v-if="configurationTest.status === 'completed_empty'" class="form-tip">{{ t('admin.shippingInventory.configurationTestEmptyResult') }}</p>
<details v-if="configurationTest.status !== 'failed'" class="readiness-audit">
<summary>{{ t('admin.shippingInventory.configurationTestRunNo') }} {{ configurationTest.run_no }} · {{ t(`admin.shippingInventory.configurationTestStage.${configurationTest.stage}`) }}</summary>
<dl><div><dt>{{ t('admin.shippingInventory.configurationTestConfigVersion') }}</dt><dd>{{ configurationTest.source_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestConnectionVersion') }}</dt><dd>{{ configurationTest.rpa_profile_config_version }}</dd></div><div><dt>{{ t('admin.shippingInventory.configurationTestUpdatedAt') }}</dt><dd>{{ formatDate(configurationTest.completed_at || configurationTest.created_at) }}</dd></div></dl>
<section v-if="configurationTest.status === 'completed'" class="recommendation-list">
<p v-if="configurationTest.result?.current_profile_verified" class="configuration-test-verified">{{ t(`admin.shippingInventory.currentProfileVerified.${configurationTest.result.profile_match_level || 'compatible'}`) }}</p>
<article v-for="candidate in configurationTest.result?.analysis?.match_result?.candidates || []" :key="candidate.profile_id"><b>{{ candidate.display_name }} V{{ candidate.version }}</b><small>{{ t(`admin.shippingInventory.recommendationLevel.${candidate.level}`) }} · {{ t('admin.shippingInventory.configurationTestCandidateHint') }}</small></article>
<p v-if="!configurationTest.result?.current_profile_verified && !(configurationTest.result?.analysis?.match_result?.candidates || []).length">{{ t('admin.shippingInventory.configurationTestNoRecommendation') }}</p>
</section>
</details>
</template>
</section>
<div v-if="isEditableTab" class="form-actions full">
<div class="form-actions-buttons">
<button v-if="!parsingReadOnly" type="submit" class="btn-primary" :disabled="saving || ruleReadOnly || templateReadOnly || inventoryFieldReadOnly">{{ saving ? t('admin.shippingInventory.saving') : t('admin.save') }}</button>
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'draft'" type="button" class="btn-secondary btn-sm" @click="publishCurrentRule">{{ t('admin.shippingInventory.publish') }}</button>
<button v-if="activeTab === 'rules' && selectedId && selectedRuleStatus === 'published'" type="button" class="btn-secondary btn-sm" @click="retireCurrentRule">{{ t('admin.shippingInventory.retire') }}</button>
@@ -412,6 +398,7 @@
<button v-if="selectedId && canDeleteCurrent" type="button" class="btn-danger btn-sm" @click="deleteCurrent">{{ t('admin.delete') }}</button>
<button type="button" class="btn-ghost btn-sm" @click="closeDrawer">{{ t('admin.cancel') }}</button>
</div>
</div>
</form>
</aside>
</div>
@@ -445,7 +432,7 @@
<section class="clone-template-dialog" role="dialog" aria-modal="true" aria-labelledby="bulk-parsing-binding-title">
<header class="clone-template-header"><div><h3 id="bulk-parsing-binding-title">{{ t('admin.shippingInventory.bulkBindParsingProfile') }}</h3><p>{{ t('admin.shippingInventory.bulkBindParsingProfileHint') }}</p></div><button type="button" class="drawer-close" :aria-label="t('admin.close')" @click="closeBulkParsingBinding">×</button></header>
<form class="clone-template-form" @submit.prevent="submitBulkParsingBinding">
<label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><select v-model="bulkBinding.sourceIds" class="select-field" multiple required><option v-for="item in sources.filter((row) => !row.enabled)" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.source_code }}</option></select></label>
<label><span>{{ t('admin.shippingInventory.inventorySites') }}</span><select v-model="bulkBinding.sourceIds" class="select-field" multiple required><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.parsingProfiles') }}</span><select v-model.number="bulkBinding.profileId" class="select-field" required><option :value="0">{{ t('admin.shippingInventory.notConfigured') }}</option><option v-for="item in parsingProfiles.filter((row) => row.status === 'published' && row.purpose !== 'movement')" :key="String(item.id)" :value="Number(item.id)">{{ item.display_name || item.profile_code }} V{{ item.version }}</option></select></label>
<div class="clone-template-actions"><button type="button" class="btn-ghost btn-sm" :disabled="bulkBinding.saving" @click="closeBulkParsingBinding">{{ t('admin.cancel') }}</button><button type="submit" class="btn-primary" :disabled="bulkBinding.saving">{{ bulkBinding.saving ? t('admin.shippingInventory.saving') : t('admin.shippingInventory.bulkBindParsingProfile') }}</button></div>
</form>
@@ -507,9 +494,6 @@ import {
createShippingParsingDraftFromTemporarySession,
adoptShippingInventoryParsingProfile,
listShippingTemporaryInventorySessions,
startShippingInventoryConfigurationTest,
getShippingInventoryConfigurationTest,
getLatestShippingInventoryConfigurationTest,
startShippingInventoryValidationBatch,
getShippingInventoryValidationBatch,
getLatestActiveShippingInventoryValidationBatch,
@@ -532,8 +516,7 @@ import {
getShippingReceiptReportConfig,
saveShippingReceiptReportConfig,
} from '@/features/admin/api/admin.api';
import type { ShippingInventoryConfigurationTest, ShippingInventoryReadinessCheck, ShippingInventoryValidationBatch } from '@/features/admin/api/admin.api';
import { isConfigurationTestRunning, needsReadinessAction, readinessMarkerKind } from './shippingInventoryReadiness';
import type { ShippingInventoryReadinessCheck, ShippingInventoryValidationBatch } from '@/features/admin/api/admin.api';
import { normaliseInventoryReportPath } from './shippingInventorySourceForm';
import { buildReceiptReportConfigPayload } from './receiptReportConfigForm';
import { buildMovementFieldMapping } from './movementParsingProfileForm';
@@ -559,7 +542,7 @@ const orderSchemaPublished = ref(false);
const saving = ref(false);
const confirmation = reactive({
visible: false,
action: '' as 'delete' | 'retireRule' | 'retireTemplate' | 'retireParsing' | 'retireInventoryField' | 'activateSource' | 'deactivateSource' | 'replaceInventorySample' | '',
action: '' as 'delete' | 'retireRule' | 'retireTemplate' | 'retireParsing' | 'retireInventoryField' | 'deactivateSource' | 'replaceInventorySample' | '',
title: '',
message: '',
confirmText: '',
@@ -586,9 +569,7 @@ const temporaryInventorySessions = ref<Item[]>([]);
const selectedTemporaryInventorySession = ref('');
const analysisLoading = ref(false);
const excelTemplates = ref<Item[]>([]);
const configurationTest = ref<ShippingInventoryConfigurationTest | null>(null);
const configurationTestLoading = ref(false);
let configurationTestTimer: number | null = null;
const sourceToggling = ref(false);
const routingFields = ref<Array<{ field_id: string; field_code: string; display_name: string; description?: string; scope: 'header' | 'line' }>>([]);
const templateSystemFacts = ref<string[]>([]);
const templateSourceKinds = ref<Array<TemplateMapping['source_kind']>>([]);
@@ -655,6 +636,7 @@ const templateClone = reactive({ visible: false, template_code: '', display_name
const bulkBinding = reactive({ visible: false, sourceIds: [] as number[], profileId: 0, saving: false });
const batchValidation = reactive({ visible: false, sourceIds: [] as number[], query: '', statusFilter: 'all' as 'all' | 'processing' | 'completed' | 'completed_empty' | 'failed', saving: false, result: null as ShippingInventoryValidationBatch | null });
let batchValidationTimer: number | null = null;
// snapshot_ttl_seconds:管理端不再展示;保存时透传存量值。运行时过期以全局 SHIPPING_NOTICE_INVENTORY_SNAPSHOT_TTL_HOURS 为准。
const source = reactive({ source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [] as Parameter[], enabled: false, activation: { ready: false, checks: [] as ShippingInventoryReadinessCheck[], missing_requirements: [] as string[] } as SourceActivation });
const receiptConfig = reactive({ report_path_json: { program_group: '', program_label: '', report_group: 'Inbound', report_name: '' } as Record<string, string>, query_parameters_json: [] as Parameter[], parsing_profile_id: null as number | null });
const receiptConfigExists = ref(false);
@@ -678,15 +660,18 @@ const matchingOrderFields = computed(() => routingFields.value.filter((field) =>
const canAddParsingMatchKey = computed(() => Boolean(
structureAnalysis.value && unusedMatchingInventoryFields.value.length && unusedOrderMatchFields.value.length,
));
/** 库存报表配置徽标:DBS 看路径四段;Crane 无路径卡内容时看是否已绑库存解析。 */
const inventoryReportConfigExists = computed(() => {
if (source.connector_type !== 'dbs') return Number(source.parsing_profile_id) > 0;
const path = source.report_path_json || {};
return ['program_group', 'program_label', 'report_group', 'report_name']
.every((key) => String((path as Record<string, string>)[key] || '').trim());
});
const sourceDirty = computed(() => Boolean(selectedId.value && (
(sourceBaseline.value && sourceBaseline.value !== serialiseSourceInput())
|| (receiptConfigExists.value && receiptBaseline.value && receiptBaseline.value !== serialiseReceiptInput())
)));
const readinessChecks = computed<ShippingInventoryReadinessCheck[]>(() => source.activation?.checks || []);
const requiredReadinessChecks = computed(() => readinessChecks.value.filter((item) => item.blocking));
const firstBlockingCheck = computed(() => requiredReadinessChecks.value.find((item) => item.status !== 'passed'));
const optionalReadinessChecks = computed(() => readinessChecks.value.filter((item) => !item.blocking));
const optionalReadinessPending = computed(() => optionalReadinessChecks.value.filter((item) => item.status !== 'passed').length);
const firstBlockingCheck = computed(() => (source.activation?.checks || []).find((item) => item.blocking && item.status !== 'passed'));
const sampleReplacementNotice = computed(() => {
const difference = pendingSampleReplacement.value?.difference || {};
const missing = Array.isArray(difference.missing_mapped_headers) ? difference.missing_mapped_headers : [];
@@ -920,15 +905,6 @@ function toggleReceiptSection(): void {
if (receiptSectionOpen.value) receiptSectionTouched.value = true;
}
/** 切换管理对象时同步深链并清空选择,避免不同对象的数据残留在编辑器中。 */
function selectTab(tab: TabKey): void {
activeTab.value = tab;
void router.replace({ query: { ...route.query, section: tab } });
if (tab === 'snapshots') snapshotPage.value = 1;
if (tab === 'exports') exportPage.value = 1;
closeDrawer();
}
/** 接收侧栏或书签中的 section 深链,仅允许打开工作台已注册区段。 */
watch(
() => route.query.section,
@@ -970,7 +946,7 @@ function createNew(): void {
templateSheetColumns.value = {};
}
if (activeTab.value === 'sources') {
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['configuration_test'] } });
Object.assign(source, { source_code: '', display_name: '', connector_type: 'dbs', rpa_profile_id: 0, parsing_profile_id: 0, excel_template_id: 0, warehouse_resolution_mode: 'fixed', fixed_warehouse_id: '', snapshot_ttl_seconds: 86400, report_path_json: { program_group: '', program_label: '', report_group: 'Inventory', report_name: '' }, query_parameters_json: [], enabled: false, activation: { ready: false, checks: [], missing_requirements: ['parsing_profile', 'excel_template'] } });
resetReceiptConfig('dbs');
receiptConfigExists.value = false;
receiptSectionTouched.value = false;
@@ -1029,7 +1005,6 @@ function selectItem(item: Item): void {
: item.report_path_json;
Object.assign(source, { ...item, fixed_warehouse_id: item.fixed_warehouse_id || '', report_path_json: normaliseInventoryReportPath(item.connector_type, reportPath), query_parameters_json: (item.query_parameters_json || []).map((parameter: Parameter) => ({ ...parameter })) });
sourceBaseline.value = serialiseSourceInput();
void restoreConfigurationTest(Number(item.id));
void loadReceiptConfig(Number(item.id), String(item.connector_type || ''));
}
if (activeTab.value === 'rules') Object.assign(rule, {
@@ -1145,9 +1120,6 @@ async function loadTemplateLayout(templateId: number | null): Promise<void> {
/** 关闭抽屉并清除选择,确保切换配置对象时不会残留未保存数据。 */
function closeDrawer(): void {
if (configurationTestTimer !== null) window.clearTimeout(configurationTestTimer);
configurationTestTimer = null;
configurationTest.value = null;
resetReceiptConfig(source.connector_type);
sourceBaseline.value = '';
drawerOpen.value = false;
@@ -1317,12 +1289,11 @@ async function confirmPendingAction(): Promise<void> {
if (action === 'retireTemplate') await retireShippingExcelTemplate(selectedId.value);
if (action === 'retireParsing') await retireShippingInventoryParsingProfile(selectedId.value);
if (action === 'retireInventoryField') await retireShippingInventoryField(selectedId.value);
if (action === 'activateSource') {
await activateShippingInventorySource(selectedId.value);
if (action === 'deactivateSource') {
await deactivateShippingInventorySource(selectedId.value);
await refreshSelectedSource();
return;
}
if (action === 'deactivateSource') await deactivateShippingInventorySource(selectedId.value);
if (action === 'replaceInventorySample') { sampleReplacementConfirmed.value = true; await saveCurrent(); return; }
if (action === 'delete' && activeTab.value === 'profiles') await deleteShippingRpaProfile(selectedId.value);
if (action === 'delete' && activeTab.value === 'sources') await deleteShippingInventorySource(selectedId.value);
@@ -1339,17 +1310,24 @@ async function confirmPendingAction(): Promise<void> {
function clearConfirmation(): void { confirmation.visible = false; confirmation.action = ''; }
/**
* 停用后条件仍满足时,经确认弹窗调用已有 activate API 再次启用。
* 核心逻辑:未保存编辑一律阻断;服务端仍复用正式门禁,前端不放宽启用条件。
* 库存站点启用开关:启用即时调用 activate API;停用经确认后 deactivate。
* 核心逻辑:未保存编辑一律阻断;服务端硬门槛失败时保留停用态并提示。
*/
function requestSourceActivation(): void {
if (!selectedId.value || sourceDirty.value || !source.activation?.ready) return;
confirmation.visible = true;
confirmation.action = 'activateSource';
confirmation.title = t('admin.shippingInventory.activateSource');
confirmation.message = t('admin.shippingInventory.activateSourceConfirm');
confirmation.confirmText = t('admin.shippingInventory.activateSource');
confirmation.tone = 'primary';
async function onSourceEnabledToggle(): Promise<void> {
if (!selectedId.value || sourceDirty.value || sourceToggling.value) {
if (sourceDirty.value) message.warning(t('admin.shippingInventory.saveBeforeReadinessAction'));
return;
}
if (source.enabled) {
requestSourceDeactivation();
return;
}
sourceToggling.value = true;
try {
await activateShippingInventorySource(selectedId.value);
await refreshSelectedSource();
} catch (cause) { showError(cause, 'saveFailed'); }
finally { sourceToggling.value = false; }
}
/** 停用动作使用平台确认弹窗,防止误将正在运行的库存站点下线。 */
@@ -1362,44 +1340,7 @@ function requestSourceDeactivation(): void {
confirmation.tone = 'danger';
}
/** 发起停用库存站点的测试导出,并按后端状态轮询而不凭前端时间猜测结果。 */
async function startConfigurationTest(): Promise<void> {
if (!selectedId.value) return;
configurationTestLoading.value = true;
try {
configurationTest.value = await startShippingInventoryConfigurationTest(selectedId.value);
await pollConfigurationTest();
} catch (cause) { showError(cause, 'configurationTestFailed'); }
finally { configurationTestLoading.value = false; }
}
/** 恢复当前配置对应的最近测试;只有服务端标记为运行中时才重新启动轮询。 */
async function restoreConfigurationTest(sourceId: number): Promise<void> {
try {
const latest = await getLatestShippingInventoryConfigurationTest(sourceId);
if (selectedId.value !== sourceId) return;
configurationTest.value = latest;
if (isConfigurationTestRunning(latest)) await pollConfigurationTest();
} catch (cause) { showError(cause, 'configurationTestFailed'); }
}
/** 读取测试运行的真实异步阶段;完成或失败后停止轮询。 */
async function pollConfigurationTest(): Promise<void> {
const sourceId = selectedId.value;
const runNo = configurationTest.value?.run_no;
if (!sourceId || !runNo) return;
try {
const updated = await getShippingInventoryConfigurationTest(sourceId, runNo);
configurationTest.value = updated;
if (isConfigurationTestRunning(updated)) {
configurationTestTimer = window.setTimeout(() => { void pollConfigurationTest(); }, 2000);
} else {
await refreshSelectedSource();
}
} catch (cause) { showError(cause, 'configurationTestFailed'); }
}
/** 测试结束后回读服务端的启用投影,避免抽屉继续展示测试前的过期门禁。 */
/** 测试结束后回读服务端的启用投影,避免抽屉继续展示过期门禁。 */
async function refreshSelectedSource(): Promise<void> {
const sourceId = selectedId.value;
if (!sourceId) return;
@@ -1598,8 +1539,35 @@ async function onTemplateFile(event: Event): Promise<void> {
message.error(t('admin.shippingInventory.templateLayoutReadFailed'));
}
}
function rowTitle(item: Item): string { return String(item.display_name || item.rule_name || item.source_code || item.profile_code || item.external_warehouse_name || '-'); }
/**
* 列表卡 / 抽屉主标题。
* 核心逻辑:mappings 展示「库存源 → 目标仓库名称」关系边;其它 Tab 按既有字段优先级取值。
* @param item - 当前列表行对象
* @returns 主标题文案
*/
function rowTitle(item: Item): string {
// [STEP] mappings:关系本体是来源↔目标,只显示目标仓名无法扫清单
if (activeTab.value === 'mappings') {
const sourceId = Number(item.inventory_source_id || 0);
const sourceLabel = sourceId ? sourceTitleById(sourceId) : '-';
const targetName = String(item.external_warehouse_name || '-');
return `${sourceLabel} → ${targetName}`;
}
return String(item.display_name || item.rule_name || item.source_code || item.profile_code || item.external_warehouse_name || '-');
}
/**
* 列表卡副标题。
* 核心逻辑:mappings 展示「在途仓编码 → 目标仓编码」;缺在途仓时退化为仅目标编码。
* @param item - 当前列表行对象
* @returns 副标题文案
*/
function rowMeta(item: Item): string {
if (activeTab.value === 'mappings') {
const targetCode = String(item.external_warehouse_code || '-');
const inTransit = String(item.in_transit_warehouse_code || '').trim();
return inTransit ? `${inTransit} → ${targetCode}` : targetCode;
}
if (activeTab.value === 'inventoryFields') return `${t(`admin.shippingInventory.inventoryFieldType.${item.value_type || 'text'}`)} · ${t(`admin.shippingInventory.inventoryFieldPurposeOption.${item.usage_type || 'general'}`)}`;
if (item.connector_type) return String(item.display_name ? t(`admin.shippingInventory.platform.${item.connector_type}`) : item.connector_type);
// 解析规则列表带出用途徽标文案,库存/异动两种规则在列表一眼可分。
@@ -1640,51 +1608,6 @@ function serialiseReceiptInput(): string {
});
}
/** 返回状态轨道的简洁可视标记,文本状态仍由相邻内容提供,避免颜色成为唯一信息来源。 */
function readinessMarker(status: ShippingInventoryReadinessCheck['status']): string {
const marker = readinessMarkerKind(status);
if (marker === 'complete') return '✓';
if (marker === 'attention') return '!';
return '•';
}
/** 将服务端脱敏证据翻译为管理员可理解的当前步骤说明。 */
function readinessDetail(check: ShippingInventoryReadinessCheck): string {
if (check.status === 'passed') return t('admin.shippingInventory.readinessState.passed');
if (check.status === 'stale') return t('admin.shippingInventory.readinessState.stale');
if (check.status === 'failed') return t('admin.shippingInventory.readinessState.failed');
if (check.status === 'empty') return t('admin.shippingInventory.readinessState.empty');
return check.blocking ? t('admin.shippingInventory.readinessState.required') : t('admin.shippingInventory.readinessState.optional');
}
/** 每项门禁只映射一个推荐动作;已经通过和依赖测试的辅助检查不额外制造操作入口。 */
function readinessActionLabel(check: ShippingInventoryReadinessCheck): string {
if (!check.blocking) return '';
if (!needsReadinessAction(check)) return '';
if (check.action === 'run_configuration_test') return configurationTestLoading.value
? t('admin.shippingInventory.configurationTestRunning')
: t('admin.shippingInventory.startConfigurationTest');
return t(`admin.shippingInventory.readinessAction.${check.action}`);
}
/** 未保存的 Source 编辑必须先提交到服务端,确保测试和启用都基于同一配置版本。 */
function isReadinessActionBlocked(check: ShippingInventoryReadinessCheck): boolean {
return sourceDirty.value || (check.action === 'run_configuration_test' && configurationTestLoading.value);
}
/** 将阻断项引导到所属配置区域;测试动作仍停留在当前站点抽屉内执行。 */
function runReadinessAction(check: ShippingInventoryReadinessCheck): void {
if (isReadinessActionBlocked(check)) {
message.warning(t('admin.shippingInventory.saveBeforeReadinessAction'));
return;
}
if (check.action === 'run_configuration_test') { void startConfigurationTest(); return; }
const target: Record<Exclude<ShippingInventoryReadinessCheck['action'], 'run_configuration_test'>, TabKey> = {
configure_connection: 'profiles', configure_parsing_profile: 'parsing',
configure_excel_template: 'templates', configure_warehouse_mapping: 'mappings',
};
selectTab(target[check.action]);
}
function connectionName(sourceCode: unknown): string { const sourceItem = sources.value.find((source) => source.source_code === sourceCode); const profileItem = profiles.value.find((profile) => Number(profile.id) === Number(sourceItem?.rpa_profile_id)); return profileItem?.profile_code || t('admin.shippingInventory.historyNotCaptured'); }
function warehouseName(item: Item): string { return item.warehouse_id || (item.source_code === 'CRANE' ? t('admin.shippingInventory.dynamicWarehouse') : t('admin.shippingInventory.historyNotCaptured')); }
function auditStatus(value: unknown): string { const key = String(value || 'unknown'); return t(`admin.shippingInventory.auditStatus.${key}`); }
@@ -1804,7 +1727,11 @@ onMounted(load);
.condition-empty { color: #8190a0; font-size: 12px; }
.inline-check { flex-direction: row !important; align-items: center; gap: 4px !important; white-space: nowrap; font-size: 11px !important; }
.switch-field { display: flex; flex-direction: column; gap: 6px; color: #64748b; font-size: 12px; font-weight: 500; }.status-switch { display: inline-flex; width: fit-content; align-items: center; gap: 7px; border: 0; background: transparent; padding: 2px 0; color: #94a3b8; font: inherit; font-size: 12px; cursor: pointer; }.status-switch i { position: relative; width: 34px; height: 20px; border-radius: 999px; background: #cbd5e1; transition: background .18s; }.status-switch i::after { position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(15 23 42 / 25%); content: ''; transition: transform .18s; }.status-switch.on { color: #15803d; }.status-switch.on i { background: #22c55e; }.status-switch.on i::after { transform: translateX(14px); }.status-switch b { font-weight: 500; }
.form-actions { position: sticky; z-index: 2; bottom: 0; display: flex; flex-wrap: wrap; gap: 10px; grid-column: 1 / -1; margin: 6px -20px -20px; border-top: 1px solid #dce6ef; background: rgb(255 255 255 / 96%); box-shadow: 0 -8px 18px rgb(15 23 42 / 7%); padding: 14px 20px; backdrop-filter: blur(8px); }
.form-actions { position: sticky; z-index: 2; bottom: 0; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; grid-column: 1 / -1; margin: 6px -20px -20px; border-top: 1px solid #dce6ef; background: rgb(255 255 255 / 96%); box-shadow: 0 -8px 18px rgb(15 23 42 / 7%); padding: 14px 20px; backdrop-filter: blur(8px); }
.source-enabled-footer { display: flex; margin-right: auto; min-width: 0; align-items: center; gap: 10px; }
.source-enabled-label { flex: 0 0 auto; color: #475569; font-size: 13px; font-weight: 600; }
.source-enabled-hint { overflow: hidden; color: #94a3b8; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.form-actions-buttons { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; }
.audit-table-wrap { overflow-x: auto; border: 1px solid #dce6ef; border-radius: 10px; background: #fff; }
.audit-table { table-layout: fixed; border-collapse: collapse; font-size: 12px; }
.audit-table th { position: relative; overflow: hidden; padding: 11px 12px; background: #f8fafc; color: #64748b; font-weight: 600; text-align: left; text-overflow: ellipsis; white-space: nowrap; }
@@ -2,7 +2,7 @@
* features/admin/modules/shipping-inventory/receiptReportConfigForm.ts
* 用途:构建独立收料报表配置的受限保存载荷。
* 依赖:无外部依赖。
* 逻辑:页面仅将收料路径与查询条件提交到收料配置 API,与库存同构(Warehouse 为条件之一),
* 逻辑:页面仅将收料路径与查询条件提交到收料配置 API,与库存同构(查询条件可选,空=页面默认),
* 隔离库存站点字段;收料无独立启停字段,是否运行统一由库存站点 enabled 决定。
*/
+11 -2
View File
@@ -221,9 +221,18 @@ export const getTransferBacklogSummary = () =>
export const listTransferSources = () =>
requestJson<TransferSourceOption[]>(`${BASE}/sources`, { headers: getAuthHeaders() });
/** 对指定来源重新触发一次收料 RPA 抓取 */
/** retry-rpa 响应:parse_failed 本地重解析路径返回 {ok, file_status, reparsed};RPA 触发路径返回原状态投影 */
export interface TransferRetryRpaReparseResult {
source_code: string;
ok: boolean;
file_status: TransferSourceFileStatus['file_status'];
reparsed: true;
}
/** 来源重试(解析失败分层 2026-09-29):parse_failed 先本地重解析返回 200 reparse 结果,
* 其余状态重新触发一次收料 RPA 抓取(202 + fetching / 配置缺失 fail-closed) */
export const retryTransferSourceRpa = (sourceCode: string) =>
requestJson<TransferSourceFileStatus>(`${BASE}/sources/${encodeURIComponent(sourceCode)}/retry-rpa`, {
requestJson<TransferRetryRpaReparseResult | TransferSourceFileStatus>(`${BASE}/sources/${encodeURIComponent(sourceCode)}/retry-rpa`, {
method: 'POST',
headers: jsonHeaders(),
});
@@ -3,15 +3,18 @@
* 用途:消息列表主区域(滚动容器、欢迎页、气泡与思考中占位)。
* 依赖:ChatMessageBubble、各类进度卡、chat.types。
* 逻辑:按 shouldRenderMessage 过滤;货代抽取卡按 run / upload_batch / client_submission 去重只留最后一张;
* 用户气泡在下方已有抽取进度卡时对附件启用 summaryOnly,避免与进度卡重复堆文件明细。
* 用户气泡在下方已有抽取进度卡时对附件启用 summaryOnly,避免与进度卡重复堆文件明细;
* 在途调拨 Agent 首页看板在会话引导期并行预取(prefetchTransferHomeBoard 单飞)。
*/
<script setup lang="ts">
import { watch } from 'vue';
import type { Ref } from 'vue';
import ChatWelcomePanel, { type WelcomeQuestionItem, type WelcomeQuestionSection } from './ChatWelcomePanel.vue';
import ChatThinkingBubble from './ChatThinkingBubble.vue';
import ChatMessageBubble, { type ChatMessageBubbleHandlers } from './messages/ChatMessageBubble.vue';
import TransferHomePanel from './messages/TransferHomePanel.vue';
import ToolRunProgressCard from './ToolRunProgressCard.vue';
import { prefetchTransferHomeBoard } from '../composables/useChatTransfer';
import type { LeaveMessageHandlers } from './messages/LeaveMessageBlock.vue';
import type { ShippingMessageHandlers } from './messages/shippingMessageHandlers';
import type { TrainingHandlers } from './messages/TrainingExamQuestionMessage.vue';
@@ -24,6 +27,7 @@ const {
messages,
shouldRenderMessage,
scrollContainerHolder,
isInTransitTransferAgent,
} = defineProps<{
messages: ChatMessage[];
agentName: string;
@@ -75,6 +79,15 @@ const bindScrollContainer = (node: unknown) => {
scrollContainerHolder.el.value = (node as HTMLElement | null) ?? null;
};
// 在途调拨首页看板预取:面板挂在消息流内(messages 空判),原先等会话消息返回才发
// 看板请求(串行白等会话引导 ~1.5s);这里在「该 Agent 且当前无消息」确立时即预取,
// 面板挂载后命中同一 Promise(consume-once 单飞,见 useChatTransfer.prefetchTransferHomeBoard)。
watch(
() => Boolean(isInTransitTransferAgent) && messages.length === 0,
(active) => { if (active) prefetchTransferHomeBoard(); },
{ immediate: true },
);
/**
* 生成稳定的消息 key,避免切换历史会话时仅因条数相同而复用旧气泡组件。
* 核心逻辑:优先使用服务端/本地消息 ID,其次拼接角色、run_id 与内容摘要。
@@ -2,7 +2,7 @@
features/chat/components/messages/TransferBacklogSummaryCard.vue
用途:待处理异常卡(可恢复/已关闭/结果未知三组)——列与匹配窗口一致,
支持关键字/结果筛选、多选批量操作(重查/恢复处理/标记无需处理)与行级快捷操作。
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
可恢复行按 result_code 细分徽标(blocked_file_removed=文件已移除);
blocked_file_removed 行行内仅留「标记无需继续处理」(重查不可恢复——消失证据
@@ -12,6 +12,7 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import type { TransferBacklogItem } from '../../types/transfer.types';
const props = defineProps<{
@@ -199,7 +200,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
</div>
<div v-if="filtered.length" class="overflow-x-auto">
<table class="w-full min-w-[1180px] text-xs" data-testid="transfer-backlog-table">
<table class="w-full min-w-[1360px] 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">
@@ -210,19 +211,20 @@ function resultLabelKey(item: TransferBacklogItem): string {
@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>
<!-- 表头全列 nowrap:防「拨出仓库/匹配结果」等折行;品名列吃剩余宽度 -->
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAging') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAction') }}</th>
</tr>
</thead>
<tbody>
@@ -242,19 +244,21 @@ function resultLabelKey(item: TransferBacklogItem): string {
@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>
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行;
操作列三按钮保持一行 -->
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
<td class="whitespace-nowrap 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="whitespace-nowrap p-2">{{ item.from_warehouse || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.external_quantity) }}</td>
<td class="whitespace-nowrap p-2">{{ item.to_warehouse || '—' }}</td>
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.receipt_quantity) }}</td>
<td class="p-2">
<span
class="rounded-full px-2 py-0.5 font-bold"
class="whitespace-nowrap 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',
@@ -268,8 +272,8 @@ function resultLabelKey(item: TransferBacklogItem): string {
}}
</span>
</td>
<td class="p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
<td class="p-2">
<td class="whitespace-nowrap p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
<td class="whitespace-nowrap p-2">
<template v-if="isActionable(item)">
<!-- 失效行(文件已移除)隐藏重查/恢复处理:重查会被后端拒绝
(TRANSFER.RETRY_NOT_ALLOWED),恢复处理也无济于事,只留关闭出口 -->
@@ -287,20 +291,22 @@ function resultLabelKey(item: TransferBacklogItem): string {
v-if="!isFileRemoved(item)"
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"
:title="$t('chat.transfer.resumeAction')"
:data-testid="`transfer-backlog-resume-${item.invoice_no}`"
:disabled="busy"
@click="emit('resume', [item.item_id])"
>
{{ $t('chat.transfer.resumeAction') }}
{{ $t('chat.transfer.resumeActionShort') }}
</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"
:title="$t('chat.transfer.manualClose')"
:data-testid="`transfer-backlog-close-${item.invoice_no}`"
:disabled="busy"
@click="emit('close', item)"
>
{{ $t('chat.transfer.manualClose') }}
{{ $t('chat.transfer.manualCloseShort') }}
</button>
</template>
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-muted">
@@ -9,6 +9,7 @@
<script setup lang="ts">
import { computed, ref } from 'vue';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import type { TransferMatchingItem } from '../../types/transfer.types';
const props = defineProps<{
@@ -115,7 +116,7 @@ function checkedTime(item: TransferMatchingItem): string {
</div>
<div v-if="filtered.length" class="overflow-x-auto">
<table class="w-full min-w-[1100px] text-xs" data-testid="transfer-executable-table">
<table class="w-full min-w-[1240px] text-xs" data-testid="transfer-executable-table">
<thead>
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
<th class="p-2">
@@ -126,18 +127,19 @@ function checkedTime(item: TransferMatchingItem): string {
@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.colAction') }}</th>
<!-- 表头全列 nowrap:防「拨出仓库/投入数量」等折行;品名列吃剩余宽度 -->
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAction') }}</th>
</tr>
</thead>
<tbody>
@@ -157,21 +159,22 @@ function checkedTime(item: TransferMatchingItem): string {
@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>
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行 -->
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
<td class="whitespace-nowrap 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="whitespace-nowrap p-2">{{ item.from_warehouse }}</td>
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
<td class="p-2">
{{ item.from_quantity ?? '—' }}
{{ formatQuantity(item.from_quantity) }}
<div v-if="checkedTime(item)" class="text-[10px] text-muted">{{ checkedTime(item) }}</div>
</td>
<td class="p-2">{{ item.to_warehouse }}</td>
<td class="p-2">{{ item.to_quantity }}</td>
<td class="whitespace-nowrap p-2">{{ item.to_warehouse }}</td>
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.to_quantity) }}</td>
<td class="p-2">
<span class="rounded-full bg-emerald-50 px-2 py-0.5 font-bold text-emerald-700" data-testid="transfer-executable-result">
<span class="whitespace-nowrap rounded-full bg-emerald-50 px-2 py-0.5 font-bold text-emerald-700" data-testid="transfer-executable-result">
{{ $t('chat.transfer.resultExecutable') }}
</span>
<div v-if="item.stale" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.staleRow') }}</div>
@@ -37,7 +37,7 @@ const FAILED_TICKET = {
created_at: '2026-09-20T08:00:00',
run_no: 'RUN-1',
items: [
{ invoice_no: 'INV-A', material_no: 'MAT-A', material_name: '物料A', lot_no: 'LOT-A', quantity: '500', unit: '个' },
{ invoice_no: 'INV-A', material_no: 'MAT-A', material_name: '物料A', lot_no: 'WTP26062302', quantity: '500', unit: '个' },
{ invoice_no: 'INV-B', material_no: 'MAT-B', material_name: '物料B', lot_no: 'LOT-B', quantity: '300', unit: 'PCS' },
],
};
@@ -161,6 +161,10 @@ describe('TransferExecutedOrders 已执行明细列表子视图', () => {
// [断言意图] 展开=invoice 粒度行明细(逐 Invoice 行可见)。
expect(items.text()).toContain('INV-A');
expect(items.text()).toContain('INV-B');
// [断言意图] 拨出批号上屏为外部形态(WTP→HOW 展示侧镜像,2026-09-29):
// 行数据保持文件原形 WTP26062302,展示必须转为 HOW26062302。
expect(items.text()).toContain('HOW26062302');
expect(items.text()).not.toContain('WTP26062302');
expect(wrapper.find('[data-testid="transfer-executed-retry-D-FAIL-1"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="transfer-executed-close-D-FAIL-1"]').exists()).toBe(true);
});
@@ -1,17 +1,20 @@
<!--
features/chat/components/messages/TransferExecutedOrders.vue
用途:「已执行调拨单」明细列表子视图(首页统计卡片下钻目标,与待办/可调拨
用途:「执行看板」明细列表子视图(首页统计卡片下钻目标,与待办/可调拨
子视图同模式)——工具栏(← 返回 + 全部 + 日期范围 + 刷新)+ 单分组列表
(单行点击展开 invoice 粒度明细;failed 行 [重查]+单据级 [关闭单];
result_unknown 行仅 [重新触发],D11 无关闭入口)+ 上一页/下一页分页;
result_unknown 行仅 [重新触发],D11 无关闭入口;动作按钮与状态徽标
同簇靠右、紧跟状态展示,2026-09-29 布局调整)+ 上一页/下一页分页;
无自动轮询(进入拉一次 + 手动刷新)。
依赖:transfer.api(fetchExecutedOrders/closeTransferDocument/retriggerTransferDocument)、
transferBatch.deriveBatchNo(拨出批号展示侧 WTP→HOW 镜像)、
useMessage、i18n chat.transfer.homeExecuted.*。
逻辑:props.initialGroup(首页卡片点击带入的初始分组,''=全部)→ mounted→load;
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load;[返回]→
emit('back') 由首页面板切回卡片视图;关闭单走 D18 原因必填弹窗(同单行
影响面 + 「关闭调拨单≠ERP 无单」红线)→close→load。行为与融合卡
(TransferResultCard)一致。分组计数恒全量由后端保证,本视图不消费计数
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load(后端按收料
日期过滤);[返回]→emit('back') 由首页面板切回卡片视图;关闭单走 D18
原因必填弹窗(同单行影响面 + 「关闭调拨单≠ERP 无单」红线)→close→load。
行为与融合卡(TransferResultCard)一致。列表排序(收料日期→数据源→库位
升序)与分组计数恒全量由后端保证,本视图不消费计数
(计数展示在首页 TransferExecutedCards)。
-->
<script setup lang="ts">
@@ -24,6 +27,7 @@ import {
retryTransferOrder,
retriggerTransferDocument,
} from '../../api/transfer.api';
import { deriveBatchNo } from './transferBatch';
import type {
TransferExecutedOrder,
} from '../../types/transfer.types';
@@ -255,55 +259,51 @@ onMounted(() => { void load(); });
{{ order.receipt_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
· {{ $t('chat.transfer.materialCount', { count: order.items.length }) }}
</span>
<span
class="rounded-full px-2 py-0.5 font-bold"
:class="{
'bg-emerald-50 text-emerald-700': order.status_group === 'success',
'bg-sky-50 text-sky-700': order.status_group === 'executing',
'bg-red-50 text-red-700': order.status_group === 'failed',
'bg-amber-50 text-amber-700': order.status_group === 'result_unknown',
}"
:data-testid="`transfer-executed-status-${order.doc_no}`"
>
{{ orderBadgeText(order) }}
</span>
</div>
<!-- 单据级行内动作(D11/D18:result_unknown 仅重新触发;failed 行重查 + 单据级关闭单) -->
<div
v-if="order.status === 'result_unknown' || isFailedOrder(order)"
class="flex flex-wrap gap-2 px-3 pb-2"
>
<button
v-if="order.status === 'result_unknown'"
type="button"
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
:data-testid="`transfer-executed-retrigger-${order.doc_no}`"
:disabled="actionBusy"
@click.stop="onRetrigger(order)"
>
{{ $t('chat.transfer.orderAction.retrigger') }}
</button>
<template v-if="isFailedOrder(order)">
<button
type="button"
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:data-testid="`transfer-executed-retry-${order.doc_no}`"
:disabled="actionBusy"
@click.stop="onRetry(order)"
<!-- 状态徽标与单据级行内动作(D11/D18)同簇靠右:处置动作紧跟状态,扫读动线「状态→处置」 -->
<div class="flex flex-wrap items-center gap-2">
<span
class="rounded-full px-2 py-0.5 font-bold"
:class="{
'bg-emerald-50 text-emerald-700': order.status_group === 'success',
'bg-sky-50 text-sky-700': order.status_group === 'executing',
'bg-red-50 text-red-700': order.status_group === 'failed',
'bg-amber-50 text-amber-700': order.status_group === 'result_unknown',
}"
:data-testid="`transfer-executed-status-${order.doc_no}`"
>
{{ $t('chat.transfer.orderAction.retry') }}
</button>
{{ orderBadgeText(order) }}
</span>
<button
v-if="order.status === 'result_unknown'"
type="button"
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
:data-testid="`transfer-executed-close-${order.doc_no}`"
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
:data-testid="`transfer-executed-retrigger-${order.doc_no}`"
:disabled="actionBusy"
@click.stop="openCloseDialog(order)"
@click.stop="onRetrigger(order)"
>
{{ $t('chat.transfer.orderAction.closeOrder') }}
{{ $t('chat.transfer.orderAction.retrigger') }}
</button>
</template>
<template v-if="isFailedOrder(order)">
<button
type="button"
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:data-testid="`transfer-executed-retry-${order.doc_no}`"
:disabled="actionBusy"
@click.stop="onRetry(order)"
>
{{ $t('chat.transfer.orderAction.retry') }}
</button>
<button
type="button"
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
:data-testid="`transfer-executed-close-${order.doc_no}`"
:disabled="actionBusy"
@click.stop="openCloseDialog(order)"
>
{{ $t('chat.transfer.orderAction.closeOrder') }}
</button>
</template>
</div>
</div>
<!-- 展开明细(invoice 粒度行集) -->
@@ -327,7 +327,9 @@ onMounted(() => { void load(); });
<td class="p-1">{{ item.invoice_no }}</td>
<td class="p-1">{{ item.material_no }}</td>
<td class="p-1">{{ item.material_name }}</td>
<td class="p-1">{{ item.lot_no || '—' }}</td>
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
行上数据保持文件原形态,转换只发生在展示侧) -->
<td class="p-1">{{ deriveBatchNo(item.lot_no) || '—' }}</td>
<td class="p-1">{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template></td>
</tr>
</tbody>
@@ -57,15 +57,20 @@ describe('TransferHomePanel chat home entry', () => {
});
});
it('home 视图渲染标题、今日待办入口与三张历史待办计数卡', async () => {
it('home 视图渲染标题、今日待办入口与两张历史待办计数卡', async () => {
const wrapper = mountHome();
await flushPromises();
expect(wrapper.find('[data-testid="transfer-home"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="transfer-home-today"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="transfer-home-recoverable"]').text()).toContain('6');
expect(wrapper.find('[data-testid="transfer-home-closed"]').text()).toContain('2');
expect(wrapper.find('[data-testid="transfer-home-unknown"]').text()).toContain('1');
// [断言意图] 结果未知行不设首页卡(2026-09-29:行级只读无独立出口,统一走
// 执行看板的结果未知单据);待办池内筛选仍可达,首页不再渲染该卡。
expect(wrapper.find('[data-testid="transfer-home-unknown"]').exists()).toBe(false);
expect(api.getTransferBacklogSummary).toHaveBeenCalled();
// [断言意图] 首屏只取计数:计数卡不消费全量待办列表(68.5kB 级),
// /backlog 全量列表延迟到切片子视图(TransferMessageView backlog 挂载)自行加载。
expect(api.listTransferBacklog).not.toHaveBeenCalled();
});
it('点击“匹配可调拨库存”今日待办入口独立触发来源选择卡(复用 TransferMessageView)', async () => {
@@ -99,8 +104,9 @@ describe('TransferHomePanel chat home entry', () => {
});
it('点击历史待办计数卡独立触发 backlog 卡片,并按计数卡切片初始筛选', async () => {
// [断言意图] 三张计数卡不再落入同一份全量列表:可恢复/已关闭/结果未知
// 各自带对应 resultFilter 打开待处理池(否则 0 行的已关闭/结果未知被 50 行可恢复淹没)。
// [断言意图] 两张计数卡不再落入同一份全量列表:可恢复/已关闭
// 各自带对应 resultFilter 打开待处理池(否则 0 行的已关闭被 50 行可恢复淹没);
// 结果未知无首页卡(2026-09-29),unknown 切片仅池内筛选可达。
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' },
@@ -129,13 +135,6 @@ describe('TransferHomePanel chat home entry', () => {
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('点击已执行统计卡片进入明细列表子视图:initial-group 透传且 flow-active=true', async () => {
@@ -1,14 +1,17 @@
<!--
features/chat/components/messages/TransferHomePanel.vue
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——上区「库存匹配」动作入口,
中区「待办看板」四队列(可调拨明细/待恢复异常/已人工关闭/结果未知),
下区「已执行」统计卡片入口(四张分组计数卡,点击跳转明细列表子视图),
中区「待办看板」三队列(可调拨明细/待恢复异常/已人工关闭;结果未知行
2026-09-29 起不再设首页卡——行级在待办池只读且无独立出口,统一走下方
执行看板的结果未知单据 [重新触发],池内仍可经结果筛选查看),
下区「执行看板」统计卡片入口(四张分组计数卡,点击跳转明细列表子视图),
点击进入对应处理视图(复用自驱动的 TransferMessageView / TransferExecutedOrders)。
依赖:TransferMessageView(复用自驱动卡片)、TransferExecutedCards(已执行卡片入口)、
TransferExecutedOrders(已执行明细列表子视图)、useChatTransfer、i18n chat.transfer.*。
逻辑:home 时拉取待办汇总与可调拨明细计数并挂载已执行卡片;'executed' 子视图由
openExecuted(group) 进入(卡片带入初始分组)并挂载列表组件;其余非 home 视图
渲染 TransferMessageView。卡片不注入消息流,因此无需后端 ChatLog 消息。
逻辑:home 时仅拉待办汇总计数与可调拨明细(首屏不拉全量待办列表,命中
首页预取单飞);'executed' 子视图由 openExecuted(group) 进入(卡片带入
初始分组)并挂载列表组件;其余非 home 视图渲染 TransferMessageView
(backlog 切片在其挂载时自拉全量列表)。卡片不注入消息流,因此无需后端 ChatLog 消息。
-->
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
@@ -37,7 +40,7 @@ const backlogFilter = ref<BacklogFilter>('all');
/** 已执行卡片带入的初始分组(''=全部)。 */
const executedGroup = ref<'success' | 'failed' | 'executing' | 'result_unknown' | ''>('');
/** 打开待处理池并按计数卡切片(recoverable/closed/unknown)。 */
/** 打开待处理池并按计数卡切片(recoverable/closed;unknown 切片仅池内筛选可达)。 */
function openBacklog(filter: BacklogFilter) {
backlogFilter.value = filter;
view.value = 'backlog';
@@ -49,11 +52,12 @@ function openExecuted(group: 'success' | 'failed' | 'executing' | 'result_unknow
view.value = 'executed';
}
/** home 视图需要待办汇总与可调拨明细计数;进入时拉取。 */
/** home 视图仅拉待办汇总计数与可调拨明细——计数卡只消费计数,
* 68.5kB 级全量待办列表延迟到切片子视图(TransferMessageView backlog)自行加载 */
async function loadHomeSummary() {
if (view.value !== 'home') return;
await Promise.all([
transfer.loadBacklog().catch(() => undefined),
transfer.loadBacklogSummary().catch(() => undefined),
transfer.loadExecutableItems().catch(() => undefined),
]);
}
@@ -109,7 +113,7 @@ function goBack() {
<!-- 待办看板 -->
<section aria-label="待办看板">
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeBoardLabel') }}</p>
<div class="grid grid-cols-2 gap-3 lg:grid-cols-4">
<div class="grid grid-cols-2 gap-3 lg:grid-cols-3">
<button
type="button"
data-testid="transfer-home-executable"
@@ -140,16 +144,6 @@ function goBack() {
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeClosed') }}</b>
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeClosedHint') }}</span>
</button>
<button
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="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>
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeUnknownHint') }}</span>
</button>
</div>
</section>
@@ -0,0 +1,72 @@
/**
* features/chat/components/messages/TransferMatchCard.spec.ts
* 用途:匹配卡顶栏「来源失败」横幅过滤——路由未解析失败只行内展示,不进顶栏。
* 依赖:@vue/test-utils、i18n。
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”;
* 后端分层后路由失败保持行级(result=blocked_route_not_resolved),
* 顶栏需按 error_code 客户端排除(历史卡片回放同样生效)。
*/
import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
import i18n from '@/i18n';
import TransferMatchCard from './TransferMatchCard.vue';
import type { TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
/** 最小合法匹配摘要(TransferMatchingSummary 全必填字段齐备,计数为 0) */
function buildSummary(): TransferMatchingSummary {
return {
matching_id: 'MTG-T',
status: 'completed',
business_date: '2026-08-06',
eligible_receipt_date_to: '2026-08-06',
expires_at: '2026-08-06T23:59:59',
counts: {
file_invoice_count: 0,
not_matured_count: 0,
matched_count: 0,
executable_count: 0,
blocked_count: 0,
pending_stock_check_count: 0,
invalid_count: 0,
},
estimated_transfer_quantity: '0',
estimated_external_write_count: 0,
matching_hash: 'hash-test',
};
}
function mountCard(sources: TransferSourceProgress[]) {
return mount(TransferMatchCard, {
props: {
summary: buildSummary(),
items: [],
selected: new Set<number>(),
sources,
},
global: { plugins: [i18n] },
});
}
describe('TransferMatchCard 来源失败顶栏', () => {
it('顶栏不展示 ROUTE_NOT_RESOLVED 来源失败(路由只行内)', () => {
// [断言意图] 路由失败不再升级为来源级 failed(后端分层),顶栏排除
// TRANSFER.ROUTE_NOT_RESOLVED(客户端按 error_code 过滤,历史回放同样生效);
// 其余来源级失败(如文件 schema 无效)仍必须在顶栏可见。
const wrapper = mountCard([
{ source_code: 'A', stage: 'failed', error_code: 'TRANSFER.ROUTE_NOT_RESOLVED', error_message: 'route not resolved' },
{ source_code: 'B', stage: 'failed', error_code: 'TRANSFER_FILE_SCHEMA_INVALID', error_message: 'schema' },
]);
const banner = wrapper.find('[data-testid="transfer-match-failed-sources"]');
expect(banner.exists()).toBe(true);
expect(banner.text()).not.toContain('route not resolved');
expect(banner.text()).toContain('schema');
});
it('仅路由失败时顶栏不渲染', () => {
// [断言意图] 唯一失败来源为路由未解析时,顶栏整体不出现(避免空横幅/全 0 误导)。
const wrapper = mountCard([
{ source_code: 'A', stage: 'blocked_route', error_code: 'TRANSFER.ROUTE_NOT_RESOLVED', error_message: 'route not resolved' },
]);
expect(wrapper.find('[data-testid="transfer-match-failed-sources"]').exists()).toBe(false);
});
});
@@ -13,12 +13,15 @@
可行动项;重查范围含可恢复阻断与可执行行(重查仍按 invoice_no 提交);
阻断原因经结果徽标 title 悬浮透出不占行高;无选择或 busy 时生成按钮禁用;
emit execute(itemIds);来源级解析/文件失败经 sources.error_code 透出
(防"安静全 0")。
(防"安静全 0"),但路由未解析失败(TRANSFER.ROUTE_NOT_RESOLVED)不进顶栏
——路由失败保持行级(result=blocked_route_not_resolved 行内展示),
顶栏按 error_code 客户端排除,历史卡片回放同样生效。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { deriveBatchNo } from './transferBatch';
import { formatQuantity } from './transferFormat';
import type { TransferMatchingItem, TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
const { t } = useI18n();
@@ -50,9 +53,17 @@ const selectedCount = computed(() =>
);
const executeDisabled = computed(() => props.busy || selectedCount.value === 0);
/** 来源级失败(解析/文件/RPA 触发):必须可见,防止计数全 0 却无任何解释。 */
/** 不进顶栏的来源失败码:路由未解析失败由后端保持行级(result=blocked_route_not_resolved),
* 顶栏排除之(历史卡片 sources[].error_code 仍带该码,客户端过滤统一兜住)。 */
const HIDDEN_SOURCE_BANNER_CODES = new Set(['TRANSFER.ROUTE_NOT_RESOLVED']);
/** 来源级失败(解析/文件/RPA 触发):必须可见,防止计数全 0 却无任何解释;路由类失败仅行内展示不进顶栏。 */
const failedSources = computed(() =>
(props.sources ?? []).filter((source) => source.error_code || source.error_message),
(props.sources ?? []).filter(
(source) =>
(source.error_code || source.error_message) &&
!HIDDEN_SOURCE_BANNER_CODES.has(String(source.error_code || '')),
),
);
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
@@ -224,7 +235,7 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
<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-match-source-errors"
data-testid="transfer-match-failed-sources"
>
<div class="mb-1 font-bold">{{ $t('chat.transfer.sourceErrorTitle') }}</div>
<div v-for="source in failedSources" :key="source.source_code" class="leading-5">
@@ -257,7 +268,7 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
</button>
</div>
<div class="overflow-x-auto">
<table class="w-full min-w-[1100px] text-xs" data-testid="transfer-match-table">
<table class="w-full min-w-[1240px] text-xs" data-testid="transfer-match-table">
<thead>
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
<th class="p-2">
@@ -268,17 +279,18 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
@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.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>
<!-- 表头全列 nowrap:防「拨出仓库/投入数量」等折行;品名列吃剩余宽度 -->
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
</tr>
</thead>
<tbody>
@@ -298,15 +310,16 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
@change="emit('toggle', item.item_id as number, ($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>
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行 -->
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
<td class="whitespace-nowrap 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="whitespace-nowrap p-2">{{ item.from_warehouse }}</td>
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no) }}</td>
<td class="p-2">
<div>{{ item.from_quantity ?? '—' }}</div>
<div>{{ formatQuantity(item.from_quantity) }}</div>
<!-- 库存查询时刻小字:数据新鲜度溯源(stale 门禁的可见依据) -->
<div
v-if="checkedAtLabel(item)"
@@ -317,13 +330,13 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
{{ checkedAtLabel(item) }}
</div>
</td>
<td class="p-2">{{ item.to_warehouse }}</td>
<td class="p-2">{{ item.to_quantity }}</td>
<td class="whitespace-nowrap p-2">{{ item.to_warehouse }}</td>
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.to_quantity) }}</td>
<td class="p-2">
<div class="flex flex-wrap items-center gap-1">
<!-- 阻断原因经悬浮提示(title)透出:不占行高;可执行行也提供重查入口 -->
<span
class="rounded-full px-2 py-0.5 font-bold"
class="whitespace-nowrap 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' || item.result === 'pending_stock_check',
@@ -159,13 +159,13 @@ async function onRequery(invoiceNos: string[]) {
}
}
/** 可调拨明细行重查:逐行核对最新库存后刷新队列(行级 retry 不依赖匹配) */
/** 可调拨明细行重查:批量核对最新库存后刷新队列(复用 batch-requery 唯一批量后端,
* 后端按组织一次外部查询——禁止逐行调单行 retry 把 N 行放大成 N 次外部调用) */
async function onExecutableRequery(itemIds: number[]) {
if (!itemIds.length) return;
busy.value = true;
try {
for (const itemId of itemIds) {
await transfer.retry(itemId);
}
await transfer.batchRequery(itemIds);
await transfer.loadExecutableItems();
} catch (e) {
reportError(e);
@@ -2,9 +2,11 @@
features/chat/components/messages/TransferResultCard.vue
用途:融合卡(D9:调拨单清单=进度=结果)——props { run_no } 自驱动轮询 GET /runs/{run_no},
逐单展示「收料日期 · 拨出→拨入 · N 物料 · 合计」与状态徽标(待处理/执行中/ERP 单号/失败),
行明细常驻展开;result_unknown 行 [重新触发](D11 唯一出口,幂等只触发末步);
失败行 [重查库存](emit 上抛,复用既有 batch-requery)+ [关闭单](D18:原因必填 +
同单行影响面 + 「关闭调拨单≠ERP 无单」红线确认);终态出下载区。无取消执行入口(D9)。
行明细常驻展开(Invoice | 料号 | 品名 | 拨出批号 | 投入数量,列序对齐可调拨明细);
单据级动作与状态徽标同排头部右侧(2026-09-29 方案A):result_unknown [重新触发]
(D11 唯一出口,幂等只触发末步);失败行 [重试](emit 上抛,复用既有 batch-requery)+
[关闭单](D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线确认);
终态出下载区。无取消执行入口(D9)。
依赖:props.runNo/initialRun、useChatTransfer(自有实例轮询:startRunPolling/refreshRun)、
transfer.api(retriggerTransferDocument/closeTransferDocument)、useMessage、i18n chat.transfer.*。
逻辑:挂载即拉取打底一帧并按 4s 轮询直至 run 终态(onUnmounted 停止);单次失败保留旧值并显示
@@ -12,6 +14,8 @@
历史回放旧 payload(无 orders)把 result.external_documents 投影为成功单兼容展示。
失败/未知单的单据级 error_message 恒 null(T11 评审移交 + P2-3 契约扩充:后端失败/未知单行带
行级 reason=result_message):❌ 原因行级优先、无则仅展示状态文案,禁止渲染 undefined/null 字样。
「未生成 ERP 单据」区仅收未建单阻断行(2026-09-29 后端口径收窄,已建单失败行不重复展示),
行文案优先行级 message(人话原因)、状态码标签兜底。
-->
<script setup lang="ts">
import { computed, onMounted, onUnmounted, ref } from 'vue';
@@ -19,7 +23,7 @@ import { useI18n } from 'vue-i18n';
import { useMessage } from '@/shared/composables/useMessage';
import { isTerminalRunStatus, useChatTransfer } from '../../composables/useChatTransfer';
import { closeTransferDocument, retriggerTransferDocument } from '../../api/transfer.api';
import type { TransferRunResult, TransferOrder, TransferOrderLine } from '../../types/transfer.types';
import type { TransferRunResult, TransferOrder, TransferOrderLine, TransferExceptionItem } from '../../types/transfer.types';
const props = defineProps<{
/** Run 编号(必传):自驱动轮询与重新触发的目标 Run。 */
@@ -183,7 +187,12 @@ function lineKey(order: TransferOrder, line: TransferOrderLine, index: number):
return `${order.doc_no}|${line.material_no}|${line.lot_no}|${index}`;
}
/** 未入单异常行文案映射(口径不变:blocked/business/technical/unknown/matching_expired)。 */
/** 未入单异常行文案:行级 message(人话原因,如分组阻断单号)优先;无则回落
* 状态码标签映射(blocked/business/technical/unknown/matching_expired)。 */
function exceptionReasonText(exc: TransferExceptionItem): string {
return exc.message?.trim() || t(exceptionReasonLabel(exc.reason));
}
function exceptionReasonLabel(reason: string): string {
const map: Record<string, string> = {
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
@@ -314,13 +323,48 @@ async function confirmCloseOrder() {
· {{ $t('chat.transfer.materialCount', { count: order.lines.length }) }}
<template v-if="order.lines.length"> · {{ orderTotalQuantity(order) }} {{ orderUnit(order) }}</template>
</span>
<span
class="rounded-full px-2 py-0.5 font-bold"
:class="orderBadgeCls(order)"
:data-testid="`transfer-order-status-${order.doc_no}`"
>
{{ orderBadgeText(order) }}
</span>
<!-- 状态徽标 + 单据级动作同排头部右侧(2026-09-29 方案A):「失败→能做什么」
一眼完成,卡片主体回归纯信息展示;动作为单据级(D11 重新触发 / D18 重试+关闭单),
testid 不变供规格定位。 -->
<div class="flex flex-wrap items-center gap-2">
<span
class="rounded-full px-2 py-0.5 font-bold"
:class="orderBadgeCls(order)"
:data-testid="`transfer-order-status-${order.doc_no}`"
>
{{ orderBadgeText(order) }}
</span>
<button
v-if="order.status === 'result_unknown'"
type="button"
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
:data-testid="`transfer-order-retrigger-${order.doc_no}`"
:disabled="actionBusy"
@click="retriggerTarget = order"
>
{{ $t('chat.transfer.orderAction.retrigger') }}
</button>
<template v-if="isFailedOrder(order)">
<button
type="button"
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:data-testid="`transfer-order-retry-${order.doc_no}`"
:disabled="actionBusy"
@click="emit('retry', order)"
>
{{ $t('chat.transfer.orderAction.retry') }}
</button>
<button
type="button"
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
:data-testid="`transfer-order-close-${order.doc_no}`"
:disabled="actionBusy"
@click="openCloseDialog(order)"
>
{{ $t('chat.transfer.orderAction.closeOrder') }}
</button>
</template>
</div>
</div>
<!-- 失败/未知单原因([P2-3 契约扩充] 行级 reason 优先;无则不渲染——状态文案兜底,禁 undefined/null) -->
@@ -332,48 +376,12 @@ async function confirmCloseOrder() {
{{ $t('chat.transfer.orderReasonPrefix', { reason: orderReason(order) }) }}
</div>
<!-- 单据级行内动作(D11/D18:result_unknown 仅重新触发;失败行重查+关闭单) -->
<div
v-if="order.status === 'result_unknown' || isFailedOrder(order)"
class="flex flex-wrap gap-2 px-3 pb-2"
>
<button
v-if="order.status === 'result_unknown'"
type="button"
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
:data-testid="`transfer-order-retrigger-${order.doc_no}`"
:disabled="actionBusy"
@click="retriggerTarget = order"
>
{{ $t('chat.transfer.orderAction.retrigger') }}
</button>
<template v-if="isFailedOrder(order)">
<button
type="button"
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
:data-testid="`transfer-order-retry-${order.doc_no}`"
:disabled="actionBusy"
@click="emit('retry', order)"
>
{{ $t('chat.transfer.orderAction.retry') }}
</button>
<button
type="button"
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
:data-testid="`transfer-order-close-${order.doc_no}`"
:disabled="actionBusy"
@click="openCloseDialog(order)"
>
{{ $t('chat.transfer.orderAction.closeOrder') }}
</button>
</template>
</div>
<!-- 行明细常驻展开(物料 × 批号聚合行) -->
<!-- 行明细常驻展开(物料 × 批号聚合行;Invoice 首列对齐可调拨明细列序) -->
<div class="border-t border-subtle px-3 py-2" :data-testid="`transfer-order-lines-${order.doc_no}`">
<table class="w-full text-xs">
<thead>
<tr class="text-left text-[11px] text-muted">
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
<th class="p-1">{{ $t('chat.transfer.colMaterial') }}</th>
<th class="p-1">{{ $t('chat.transfer.colName') }}</th>
<th class="p-1">{{ $t('chat.transfer.colFromBatch') }}</th>
@@ -382,6 +390,7 @@ async function confirmCloseOrder() {
</thead>
<tbody>
<tr v-for="(line, index) in order.lines" :key="lineKey(order, line, index)" class="border-t border-subtle">
<td class="p-1">{{ line.invoice_no || '—' }}</td>
<td class="p-1">{{ line.material_no }}</td>
<td class="p-1">{{ line.material_name }}</td>
<td class="p-1">{{ line.lot_no || '—' }}</td>
@@ -393,7 +402,8 @@ async function confirmCloseOrder() {
</li>
</ul>
<!-- 未入单异常区(口径不变):早于建单被阻断的行不落在任何单内,fail-closed 单独展示 -->
<!-- 未入单异常区(2026-09-29 收窄:仅未建单被阻断的行——已建单失败行不重复展示;
文案行级 message 优先、状态码标签兜底) -->
<div
v-if="(run?.result?.exceptions?.length ?? 0) > 0"
class="mt-3"
@@ -407,7 +417,7 @@ async function confirmCloseOrder() {
class="rounded-lg bg-red-50 px-3 py-1.5 text-xs text-red-700"
>
<span class="font-bold">{{ exc.invoice_no }}</span>
<span class="mx-1 text-red-400">·</span>{{ exc.source_code }} · {{ $t(exceptionReasonLabel(exc.reason)) }}
<span class="mx-1 text-red-400">·</span>{{ exc.source_code }} · {{ exceptionReasonText(exc) }}
<div class="text-[11px] text-red-500">{{ exc.facts }}</div>
</li>
</ul>
@@ -4,7 +4,9 @@
* 确认提交、重试收料 RPA。
* 依赖:@vue/test-utils、i18n。
* 逻辑:平台 DBS/Crane 仅分组;实例为选择与执行边界(决策 2/3/4);
* 所选来源需至少一个 has_ready_file 才能确认匹配(决策:无 ready 文件禁止确认)。
* 确认需至少一个 has_ready_file(兜底告警),提交范围静默过滤为 ready-only
* (无 ready 文件的勾选项不进匹配,2026-09-29 来源错误分层);
* 重试门禁=仅 fetching 在途不可重试(ready 亦可强制重抓,2026-09-29 去管控)。
*/
import { mount } from '@vue/test-utils';
import { describe, expect, it } from 'vitest';
@@ -52,11 +54,37 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('confirm')).toBeUndefined();
});
it('“全选可见”勾选全部启用实例', async () => {
it('“全选可见”勾选全部启用实例,确认时静默剔除无 ready 文件来源', async () => {
// [断言意图] 门禁新语义:有 ready 文件的勾选项照常放行,无 ready 文件的勾选项
// (DBS-AWSSG none)静默剔除——确认范围只含可执行来源,不再整包提交。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-select-visible"]').trigger('click');
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DBS-AWSBI', 'DBS-AWSSG', 'CRANE-SZ']);
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DBS-AWSBI', 'CRANE-SZ']);
});
it('勾选 ready+parse_failed 确认时只提交 ready 来源', async () => {
// [断言意图] 解析失败来源(has_ready_file=false)勾选后不阻断确认,
// 但确认事件只携带具备 ready 文件的来源码。
const sources = [
{ source_code: 'DSV-OK', display_name: 'ok', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' as const },
{ source_code: 'DSV-BAD', display_name: 'bad', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'parse_failed' as const },
];
const wrapper = mountCard({}, sources);
await wrapper.find('[data-testid="transfer-source-option-DSV-OK"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-option-DSV-BAD"] input').setValue(true);
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DSV-OK']);
});
it('parse_failed 显示解析失败徽标且可重试', async () => {
// [断言意图] 当日收料文件解析失败(file_status=parse_failed)不得误报就绪;
// 与 none/failed/expired 一样允许重新触发收料 RPA。
const wrapper = mountCard({}, [
{ source_code: 'DSV-BAD', display_name: 'bad', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'parse_failed' as const },
]);
expect(wrapper.find('[data-testid="transfer-source-status-DSV-BAD"]').text()).toBe('解析失败');
expect((wrapper.find('[data-testid="transfer-source-retry-DSV-BAD"]').element as HTMLButtonElement).disabled).toBe(false);
});
it('“清空选择”清空已选实例', async () => {
@@ -115,12 +143,28 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.find('[data-testid="transfer-source-date-invalid"]').exists()).toBe(false);
});
it('“只选可重试”勾选无文件/失败来源', async () => {
it('文件已就绪来源行尾重试图标可用,可强制重抓', async () => {
// [断言意图] 2026-09-29 去管控:ready 不再禁用重试(文件内容异常时覆盖重抓),
// 点击行尾图标按单来源 emit retry。
const wrapper = mountCard();
expect((wrapper.find('[data-testid="transfer-source-retry-DBS-AWSBI"]').element as HTMLButtonElement).disabled).toBe(false);
await wrapper.find('[data-testid="transfer-source-retry-DBS-AWSBI"]').trigger('click');
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSBI']);
});
it('抓取中来源重试图标保持禁用(在途去重防并发双跑)', async () => {
const wrapper = mountCard({}, [
{ source_code: 'DSV-FETCH', display_name: 'fetching', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'fetching' },
]);
expect((wrapper.find('[data-testid="transfer-source-retry-DSV-FETCH"]').element as HTMLButtonElement).disabled).toBe(true);
});
it('“只选可重试”包含 ready 来源(ready 亦可强制重抓)', async () => {
// [断言意图] 2026-09-29 去管控:可重试=除 fetching 外全部状态;全选可重试后
// 因含 ready 文件来源,确认按钮不再被「至少一 ready」门禁禁用。
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-select-retryable"]').trigger('click');
const selected = (wrapper.find('[data-testid="transfer-source-confirm"]').element as HTMLButtonElement).disabled;
// 可重试来源为 DBS-AWSSG(none);选中它但无 ready 文件 → 确认仍禁用(门禁)。
expect(selected).toBe(true);
expect((wrapper.find('[data-testid="transfer-source-confirm"]').element as HTMLButtonElement).disabled).toBe(false);
});
it('点击行尾重试图标 emit retry([sourceCode])', async () => {
@@ -129,11 +173,11 @@ describe('TransferSourceSelectCard', () => {
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSSG']);
});
it('批量重试仅传可重试来源', async () => {
it('批量重试传所选全部可重试来源(含 ready)', async () => {
const wrapper = mountCard();
await wrapper.find('[data-testid="transfer-source-select-retryable"]').trigger('click');
await wrapper.find('[data-testid="transfer-source-batch-retry"]').trigger('click');
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSSG']);
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSBI', 'DBS-AWSSG', 'CRANE-SZ']);
});
it('已过期来源显示「文件已过期」徽标且可重试', async () => {
@@ -6,6 +6,9 @@
逻辑:匹配参数区(调拨类型 + 收料日期,确认时一并提交)→ 选择辅助/上下文操作条
(有选中时原位替换辅助区,承载批量重试/下载/清空选择)→ 平台分组来源列表
(平台仅分组不可直接执行)→ 底部唯一实心主按钮「确认范围并匹配」(未选禁用);
确认只提交具备 ready 文件的来源(勾选的无 ready 项如 parse_failed/none 静默剔除,
门禁「至少一 ready」保留为兜底告警);重试除抓取中(fetching)外均可触发
(ready 亦可强制重抓,2026-09-29 去管控),徽标独立文案;
调拨类型决定收料数据范围(类型 1 仅纳入 INVOICE 前缀 HOM/HOX/WTP),
类型 2/3 一期占位(禁用,后端同样 fail-closed)。
-->
@@ -63,9 +66,10 @@ function transferTypeLabel(value: TransferType): string {
const platforms = computed(() => [...new Set(props.sources.map((source) => source.platform))]);
const selectedCount = computed(() => selected.value.size);
/** 可重试判定:仅 待抓取(none) / 抓取失败(failed) / 已过期(expired) 的来源可重试(ready/fetching 不重复触发)。 */
/** 可重试判定:除抓取中(fetching)外均可重试(2026-09-29 去管控:ready 亦可强制重抓,
* 文件内容异常时覆盖重抓;后端 retry-rpa 本无状态门禁);fetching 在途去重防并发双跑。 */
function isRetryable(source: TransferSourceOption): boolean {
return source.file_status === 'none' || source.file_status === 'failed' || source.file_status === 'expired';
return source.file_status !== 'fetching';
}
/** 全部可重试来源。 */
@@ -108,7 +112,7 @@ function selectVisible() {
selected.value = new Set(props.sources.filter((source) => source.enabled).map((source) => source.source_code));
}
/** 只选可重试来源(待抓取/抓取失败),来源多时一键收敛。 */
/** 只选可重试来源(除抓取中外全部状态,含 ready 强制重抓),来源多时一键收敛。 */
function selectRetryable() {
selected.value = new Set(retryableSources.value.map((source) => source.source_code));
}
@@ -137,23 +141,28 @@ function downloadSelected(): void {
if (codes.length) emit('download', codes);
}
/** 确认范围并匹配:只提交具备 ready 文件的来源;无 ready 文件的勾选项(如 parse_failed/none)
* 静默剔除(历史上是「至少一 ready 则整包提交」,会把不可执行来源带进匹配);
* 「至少一 ready」门禁保留为兜底告警(全部无 ready 时拦截)。 */
function confirm() {
if (selectedCount.value === 0) {
notifyWarning(t('chat.transfer.needSelectSource'), t('chat.transfer.sourceSelectTitle'));
return;
}
if (!selectedHasReadyFile.value) {
const readyCodes = [...selected.value].filter(
(code) => props.sources.find((s) => s.source_code === code)?.has_ready_file,
);
if (readyCodes.length === 0) {
notifyWarning(t('chat.transfer.needReadyFile'), t('chat.transfer.sourceSelectTitle'));
return;
}
emit('confirm', [...selected.value], { from: dateFrom.value || undefined, to: dateTo.value || undefined }, transferType.value);
emit('confirm', readyCodes, { from: dateFrom.value || undefined, to: dateTo.value || undefined }, transferType.value);
}
</script>
<template>
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-source-select-card">
<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>
<h3 class="mb-3 text-sm font-bold text-primary">{{ $t('chat.transfer.sourceSelectTitle') }}</h3>
<!-- [ZONE 1] 匹配参数区:调拨类型 + 收料日期同组(确认匹配时一并提交,参数先行定范围)。 -->
<div class="mb-3 rounded-lg border border-subtle p-3" data-testid="transfer-source-params">
@@ -327,6 +336,14 @@ function confirm() {
>
{{ t('chat.transfer.fileExpired') }}
</span>
<!-- 解析失败(parse_failed):当日收料文件解析失败;重试按状态分层——parse_failed=本地重解析,其余状态=重新触发收料 RPA 重抓 -->
<span
v-else-if="source.file_status === 'parse_failed'"
class="inline-flex items-center gap-1 rounded-full bg-red-50 px-2 py-0.5 text-[10px] font-bold text-red-700"
:data-testid="`transfer-source-status-${source.source_code}`"
>
{{ t('chat.transfer.fileParseFailed') }}
</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"
@@ -0,0 +1,24 @@
/**
* features/chat/components/messages/transferDate.spec.ts
* 用途:锁定 T+2 成熟口径的截止日计算(与后端 date_policy 同口径,默认 lag=2)。
* 依赖:被测纯函数 transferDate.ts。
* 逻辑:直接注入 UTC 时刻构造上海业务日,断言跨日/跨月边界不漂移。
*/
import { describe, expect, it } from 'vitest';
import { eligibleReceiptDateTo, shanghaiBusinessDate } from './transferDate';
describe('eligibleReceiptDateTo(T+2 口径)', () => {
it('T=2026-09-28 → 截止 2026-09-26(T-2,海外时差)', () => {
// 上海 9-28 13:00 = UTC 05:00。
expect(eligibleReceiptDateTo(new Date('2026-09-28T05:00:00Z'))).toBe('2026-09-26');
});
it('UTC 月末跨界仍按上海业务日回退 2 天', () => {
// 上海 10-01 00:30 = UTC 9-30 16:30 → T=10-01,截止 09-29。
expect(eligibleReceiptDateTo(new Date('2026-09-30T16:30:00Z'))).toBe('2026-09-29');
});
it('shanghaiBusinessDate 返回上海业务日(UTC 17:00 = 上海次日)', () => {
expect(shanghaiBusinessDate(new Date('2026-08-05T17:00:00Z'))).toBe('2026-08-06');
});
});
@@ -1,12 +1,16 @@
/**
* features/chat/components/messages/transferDate.ts
* 用途:在途调拨业务日期工具——按 Asia/Shanghai 计算业务日期(T)与
* D+1 成熟规则的可匹配截止日(T-1),与后端 date_policy 完全同口径。
* T+lag 成熟规则的可匹配截止日(T - lag,lag 默认 2 即 T+2),
* 与后端 date_policy 完全同口径。
* 依赖:无(纯函数,便于单测)。
* 逻辑:浏览器本地时区不可靠(部署/用户时区任意),必须固定上海时区口径,
* 否则前端日期上限与后端 TRANSFER.RECEIPT_DATE_RANGE_INVALID 卡控会漂移。
*/
/** 成熟滞后天数:与后端 IN_TRANSIT_TRANSFER_MATURITY_LAG_DAYS 默认值一致(T+2,海外时差余量)。 */
const MATURITY_LAG_DAYS = 2;
/** Asia/Shanghai 当前业务日期(YYYY-MM-DD)。 */
export function shanghaiBusinessDate(now: Date = new Date()): string {
// en-CA 输出恰为 ISO YYYY-MM-DD(locale 无关的稳定格式技巧)。
@@ -18,9 +22,9 @@ export function shanghaiBusinessDate(now: Date = new Date()): string {
}).format(now);
}
/** D+1 规则可匹配截止日(业务日期 T - 1 天,YYYY-MM-DD)。 */
/** T+lag 规则可匹配截止日(业务日期 T - lag 天,默认 T-2,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);
business.setUTCDate(business.getUTCDate() - MATURITY_LAG_DAYS);
return business.toISOString().slice(0, 10);
}
@@ -0,0 +1,32 @@
/** formatQuantity 单测:库存/投入数量列「无小数位显示整数、有小数保留原样」。 */
import { describe, expect, it } from 'vitest';
import { formatQuantity } from './transferFormat';
describe('formatQuantity', () => {
it('小数部分全为 0 → 整数展示(ERP 账面固定三位小数场景)', () => {
// [断言意图] "30.000" 展示为 "30",不再出现无意义尾零
expect(formatQuantity('30.000')).toBe('30');
expect(formatQuantity('0.000')).toBe('0');
});
it('有有效小数 → 原样保留,不缩位不舍入', () => {
// [断言意图] "30.250" 保持 "30.250"(展示层不得改写 ERP 原始精度)
expect(formatQuantity('30.250')).toBe('30.250');
expect(formatQuantity('30.5')).toBe('30.5');
});
it('整数字符串/数字原样返回', () => {
expect(formatQuantity('30')).toBe('30');
expect(formatQuantity(36)).toBe('36');
});
it('空值返回缺省占位符,非数值原样返回', () => {
expect(formatQuantity(null)).toBe('—');
expect(formatQuantity(undefined)).toBe('—');
expect(formatQuantity('')).toBe('—');
expect(formatQuantity('N/A')).toBe('N/A');
expect(formatQuantity(null, '0')).toBe('0');
});
});
@@ -0,0 +1,18 @@
/**
* 在途调拨卡片共用的数量展示格式化。
*
* 用途:库存数量/投入数量列来自后端 Decimal 原样字符串(ERP 账面常带固定小数位,
* 如 "30.000"),直接展示出现无意义尾零、显得与投入数量("30")口径不一。
* 依赖:无(纯函数);被 TransferMatchCard / TransferExecutableCard /
* TransferBacklogSummaryCard 的数量列使用。
* 逻辑:可解析为有限数值且无小数部分(小数全 0)→ 整数展示("30.000" → "30");
* 有有效小数 → 原样保留("30.250" → "30.250",不擅自缩位/四舍五入——
* 严格相等判定以 ERP 原始值为准,展示层不得改写精度);非数值/空值 → 原样。
*/
export function formatQuantity(value: string | number | null | undefined, fallback = '—'): string {
if (value === null || value === undefined || value === '') return fallback;
const num = Number(value);
if (!Number.isFinite(num)) return String(value);
return Number.isInteger(num) ? String(num) : String(value);
}
@@ -1,7 +1,8 @@
/**
* features/chat/composables/useChatTransfer.spec.ts
* 用途:验证匹配创建/恢复、选择范围、直接生成执行 Run、结果恢复与防重复;
* 另验证 D8 异步 202 提交后的 Run 轮询(4s 间隔、终态停止、单次失败保留旧值、清理)。
* 另验证 D8 异步 202 提交后的 Run 轮询(4s 间隔、终态停止、单次失败保留旧值、清理)
* 与首页看板预取单飞(幂等预取、consume-once、无预取现发)。
* 依赖:vi.mock(transfer.api)、useChatTransfer。
* 逻辑:用 Mock API 驱动组合式函数,断言状态流转与调用参数;
* 轮询用例用 fake timers 推进 4s 周期并断言终态/失败/清理分支。
@@ -23,11 +24,14 @@ const api = vi.hoisted(() => ({
downloadTransferExceptions: vi.fn(),
listTransferSources: vi.fn(),
retryTransferSourceRpa: vi.fn(),
listTransferBacklog: vi.fn(),
getTransferBacklogSummary: vi.fn(),
listExecutableTransferItems: vi.fn(),
}));
vi.mock('../api/transfer.api', () => api);
import { useChatTransfer } from './useChatTransfer';
import { useChatTransfer, prefetchTransferHomeBoard } from './useChatTransfer';
const summary = {
matching_id: 'MTG-20260806-001',
@@ -377,3 +381,53 @@ describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)',
expect(api.listTransferSources).toHaveBeenCalledTimes(2);
});
});
describe('useChatTransfer 首页看板预取(会话引导期单飞)', () => {
/** 标准看板载荷(供预取槽位消费;单飞槽位是模块级状态,用例结束前必须双槽消费完) */
const backlogSummaryPayload = {
recoverable: 3, closed: 1, unknown: 0,
aging: { warn_3d: 1, escalate_5d: 0, critical_7d: 0 },
};
const executablePayload = { items: [{ item_id: 21 }], counts: { executable_count: 1 } };
beforeEach(() => {
vi.clearAllMocks();
api.getTransferBacklogSummary.mockResolvedValue(backlogSummaryPayload);
api.listExecutableTransferItems.mockResolvedValue(executablePayload);
});
it('预取幂等:重复调用只发一次请求,挂载消费命中同一 Promise 不重发', async () => {
// [断言意图] ChatMessageList 预取与 HomePanel 挂载消费必须共享同一在途请求——
// 这是「会话引导 ∥ 看板数据」并行化的关键;任一槽位在途/未消费时不重复发。
prefetchTransferHomeBoard();
prefetchTransferHomeBoard();
const transfer = useChatTransfer();
await Promise.all([transfer.loadBacklogSummary(), transfer.loadExecutableItems()]);
expect(api.getTransferBacklogSummary).toHaveBeenCalledTimes(1);
expect(api.listExecutableTransferItems).toHaveBeenCalledTimes(1);
expect(transfer.backlogSummary.value?.recoverable).toBe(3);
expect(transfer.executableItems.value).toHaveLength(1);
});
it('consume-once:预取消费后回落现发路径(回到首页的刷新不走旧预取)', async () => {
// [断言意图] 预取只服务首次进首页;切片操作后返回首页的计数刷新必须拿新鲜数据,
// 复用已决 Promise 会展示过期计数。executable 首次消费的仍是预取槽位(1 次),
// 槽位清空后的再次加载才现发(第 2 次)。
prefetchTransferHomeBoard();
const transfer = useChatTransfer();
await transfer.loadBacklogSummary();
await transfer.loadBacklogSummary();
expect(api.getTransferBacklogSummary).toHaveBeenCalledTimes(2); // 预取 1 + 现发 1
await transfer.loadExecutableItems();
expect(api.listExecutableTransferItems).toHaveBeenCalledTimes(1); // 命中预取槽位
await transfer.loadExecutableItems();
expect(api.listExecutableTransferItems).toHaveBeenCalledTimes(2); // 槽位已空 → 现发
});
it('无预取时现发请求(预取是纯加速层,缺失不影响正确性)', async () => {
const transfer = useChatTransfer();
await transfer.loadBacklogSummary();
expect(api.getTransferBacklogSummary).toHaveBeenCalledTimes(1);
expect(transfer.backlogSummary.value?.recoverable).toBe(3);
});
});
@@ -10,7 +10,9 @@
* 4s 轮询 GET /sources 直至全部脱离 fetching(ready/failed/expired/none);
* 勾选集合以明细行 item_id 为键(历史回放行无 item_id 不可选);
* 恢复处理 = 按明细 id 重查库存(batch-requery 是唯一后端);
* 防重复点击(busy);错误统一 useMessage 展示 BusinessError。
* 防重复点击(busy);错误统一 useMessage 展示 BusinessError;
* 首页看板支持会话引导期预取(prefetchTransferHomeBoard 单飞,
* loadBacklogSummary/loadExecutableItems 挂载时消费同一 Promise)。
*/
import { computed, getCurrentScope, onScopeDispose, ref, type Ref } from 'vue';
import i18n from '@/i18n';
@@ -59,6 +61,29 @@ const SOURCE_POLL_INTERVAL_MS = 4000;
/** 来源轮询连续失败停止上限(口径同 Run 轮询):防后端持续不可用时无限空转 */
const SOURCE_POLL_MAX_CONSECUTIVE_FAILURES = 3;
/**
* 首页看板预取(模块级单飞,consume-once):看板卡原先等会话消息返回、
* TransferHomePanel 挂载后才发请求(串行白等会话引导 ~1.5s);ChatMessageList
* 识别到「在途调拨 Agent 且当前无消息」即预取,挂载后的 loadBacklogSummary /
* loadExecutableItems 命中同一 Promise——会话引导与看板数据并行。
* 已知降级(无正确性影响):预取后看板未挂载(如会话实为历史消息)时槽位滞留
* 已决 Promise,后续进入首页不再预取、回落挂载时现发,仅损失一次预取机会。
*/
let homeBoardPrefetchSummary: Promise<TransferBacklogSummary> | null = null;
let homeBoardPrefetchExecutable: ReturnType<typeof listExecutableTransferItems> | null = null;
/** 提前发起首页看板两请求(幂等:任一槽位在途/未消费时不重复发)。 */
export function prefetchTransferHomeBoard(): void {
if (homeBoardPrefetchSummary || homeBoardPrefetchExecutable) return;
const summary = getTransferBacklogSummary();
const executable = listExecutableTransferItems();
// 浮空兜底:预取无人消费时 rejection 不产生 unhandledrejection;消费方仍从原 Promise 拿真实错误
void summary.catch(() => undefined);
void executable.catch(() => undefined);
homeBoardPrefetchSummary = summary;
homeBoardPrefetchExecutable = executable;
}
/**
* Run 轮询终态集合(口径对齐后端 status.py RUN_TRANSITIONS 收尾):
* executing 只流向 success / partial_failed / failed / cancelled——
@@ -424,7 +449,8 @@ export function useChatTransfer() {
}
}
/** 对指定来源重新触发收料 RPA 抓取,并刷新来源状态(触发后 202 + fetching,
/** 对指定来源重试收料,并刷新来源状态(解析失败分层:parse_failed 先本地重解析
* 返回 200——ready/parse_failed,无轮询;其余状态仍触发收料 RPA 返回 202 + fetching,
* loadSources 观察到 fetching 即自动开始来源轮询,RPA 回调收口后状态自动刷新) */
async function retrySourceRpa(sourceCode: string) {
const status = await retryTransferSourceRpa(sourceCode);
@@ -440,9 +466,21 @@ export function useChatTransfer() {
return { items, summary };
}
/** 加载可调拨明细(全局可执行行队列;恢复后的行会出现在这里) */
/** 首页看板计数(仅汇总,不拉全量列表——列表延迟到切片子视图加载);
* 命中首页预取则复用在途请求,否则现发 */
async function loadBacklogSummary() {
const pending = homeBoardPrefetchSummary;
homeBoardPrefetchSummary = null;
const summary = await (pending ?? getTransferBacklogSummary());
backlogSummary.value = summary;
return summary;
}
/** 加载可调拨明细(全局可执行行队列;恢复后的行会出现在这里);命中首页预取则复用在途请求 */
async function loadExecutableItems() {
const payload = await listExecutableTransferItems();
const pending = homeBoardPrefetchExecutable;
homeBoardPrefetchExecutable = null;
const payload = await (pending ?? listExecutableTransferItems());
executableItems.value = payload.items;
return executableItems.value;
}
@@ -522,6 +560,7 @@ export function useChatTransfer() {
loadSources,
retrySourceRpa,
loadBacklog,
loadBacklogSummary,
loadExecutableItems,
batchRequery,
resume,
@@ -107,12 +107,17 @@ export interface ErpDocument {
lines: ErpDocumentLine[];
}
/** 未生成 ERP 单据的异常项 */
/**
* 未生成 ERP 单据的异常项(2026-09-29 口径收窄:仅未建单被阻断的行,已建单
* 失败/未知行的原因与动作由 orders 卡片承载)。
*/
export interface TransferExceptionItem {
source_code: string;
invoice_no: string;
material_no: string;
reason: string;
/** 行级人话原因(= 行 result_message,如分组阻断单号);展示优先于 reason 状态码标签。 */
message?: string;
facts: string;
}
@@ -127,6 +132,8 @@ export type TransferOrderStatus = 'pending' | 'executing' | 'success' | 'duplica
/** 单内行(ERP 写入行粒度聚合:物料+批号;quantity 为 6 位小数字符串,与 D14 快照口径一致) */
export interface TransferOrderLine {
/** 行级溯源收料通知号(2026-09-29 契约扩充;一行恒对应一张 invoice,旧 payload 缺省) */
invoice_no?: string;
material_no: string;
material_name: string;
lot_no: string;
@@ -238,8 +245,8 @@ export interface TransferSourceOption {
display_name: string;
platform: string;
enabled: boolean;
/** 收料文件状态:ready / fetching / failed / expired / none(只读投影货代收料事实) */
file_status?: 'ready' | 'fetching' | 'failed' | 'expired' | 'none';
/** 收料文件状态:ready / fetching / failed / parse_failed / expired / none(只读投影货代收料事实;parse_failed=当日可用收料文件解析失败) */
file_status?: 'ready' | 'fetching' | 'failed' | 'parse_failed' | 'expired' | 'none';
/** 是否已有当前可用的收料文件(门禁:无 ready 文件禁止确认匹配) */
has_ready_file?: boolean;
file_no?: string | null;
@@ -249,7 +256,7 @@ export interface TransferSourceOption {
/** 来源收料文件状态(门禁 + 状态标识 + 重试返回) */
export interface TransferSourceFileStatus {
source_code: string;
file_status: 'ready' | 'fetching' | 'failed' | 'expired' | 'none';
file_status: 'ready' | 'fetching' | 'failed' | 'parse_failed' | 'expired' | 'none';
has_ready_file: boolean;
file_no?: string | null;
file_sha256?: string | null;
+18 -3
View File
@@ -629,7 +629,7 @@
"orderSchemaRequired": "Publish an Order Fields version first; inventory parsing profiles, shipping Excel templates, and routing rules can then reference order fields.",
"connections": "System Connections",
"receiptReportConfig": "Receipt Report Configuration",
"receiptReportConfigHint": "Same structure as inventory configuration: report path + query parameters. Each warehouse in the Warehouse condition exports one receipt file per schedule; report date is never filtered. Receipt has no separate switch and follows the site's unified enablement.",
"receiptReportConfigHint": "Same structure as inventory configuration: report path + query parameters. Query parameters are optional; empty means page defaults. The schedule exports one receipt file per site; report date is never filtered. Receipt has no separate switch and follows the site's unified enablement.",
"receiptQueryParametersHint": "Same as inventory query parameters. Warehouse supports multiple values (comma-separated); each Warehouse exports one receipt file. Report date filtering is never allowed.",
"receiptCraneFixedPath": "Crane receipt export is fixed to Inbound Details and is not split by Warehouse. No query conditions are maintained; execution directly runs the page defaults.",
"pathSectionConfigured": "Configured",
@@ -705,7 +705,7 @@
"movementFields": {
"doc_no": "Doc No.", "line_no": "Line No.", "in_out_flag": "In/Out Flag", "material_code": "Material Code",
"material_name": "Material Name", "warehouse_code": "Warehouse", "storage_code": "Storage Bin", "lot_no": "Lot No.",
"quantity": "Quantity", "movement_date": "Movement Date"
"quantity": "Quantity", "movement_date": "Movement Date", "unit": "Unit"
},
"inventoryAnalysisFailed": "Inventory file structure recognition failed.",
"inventoryAnalysisPreview": "Recognition Preview",
@@ -908,7 +908,9 @@
"parsingBindingOperationDirect": "Direct binding",
"parsingBindingOperationBulk": "Bulk binding",
"parsingBindingVersion": "Configuration version {before} to {after}",
"sourceSavedDisabledHint": "The site remains disabled after its first save. Complete the test export, inventory parsing, and shipping template before activation.",
"sourceSavedDisabledHint": "The site stays disabled after its first save. Bind inventory parsing and a shipping template, then use the enable switch.",
"sourceEnabledToggleHint": "Takes effect immediately",
"inventoryReportConfig": "Inventory report configuration",
"readinessBlockedBy": "One step left before enablement: {requirement}",
"readinessAutoEnableHint": "After completion the system will evaluate and enable the site automatically.",
"readinessLastVerified": "Last verified {time}",
@@ -2183,6 +2185,8 @@
"totalProcessed": "Total processed",
"totalSuccess": "Total success",
"totalSkipped": "Total skipped",
"totalSkippedReceipt": "No receipt / skipped",
"totalSkippedInventory": "No inventory / skipped",
"totalFailed": "Total failed",
"listTitle": "Schedule list",
"recordsTitle": "{name} · Run records",
@@ -2213,6 +2217,10 @@
"downloadInventoryRawZipPackage": "Download raw inventory ZIP",
"rawInventoryZipWecomHint": "This notification includes a raw inventory package. Tap the button below to download.",
"inventoryRawZip": "Raw inventory",
"downloadReceiptRawZip": "Download raw receipt",
"downloadReceiptRawZipPackage": "Download raw receipt ZIP",
"rawReceiptZipWecomHint": "This notification includes a raw receipt package. Tap the button below to download.",
"receiptRawZip": "Raw receipt",
"log": "Log",
"actions": {
"edit": "Edit",
@@ -2230,6 +2238,8 @@
"totalCount": "Processed",
"successCount": "Success",
"skippedCount": "Skipped",
"skippedCountReceipt": "No receipt / skipped",
"skippedCountInventory": "No inventory / skipped",
"failedCount": "Failed",
"excelExportFailedHint": "Inventory sources succeeded, but schedule Excel export failed",
"wecomNotified": "WeCom notify",
@@ -2252,6 +2262,10 @@
"selectPlatformJob": "Select a platform task",
"platformJobShippingInventory": "Shipping inventory RPA",
"platformJobFaqHotAggregate": "FAQ hot aggregate",
"platformJobFileAssetCleanup": "Temporary file asset cleanup",
"transferSourceCodes": "Source instances",
"transferRecoverHistory": "Recover retryable history",
"transferNotifyUsers": "Notify users",
"platformJobFixedAssetsSnapshot": "Fixed assets snapshot",
"shippingInventoryJobHint": "Fetches inventory data from configured sources on schedule; exported asynchronously by the RPA worker.",
"shippingInventoryJobParams": "Job parameters (optional)",
@@ -2454,6 +2468,7 @@
"runNowWaitTimeout": "Timed out waiting for the run to finish (about 15 min); auto refresh stopped, query records manually",
"downloadExcelFailed": "Failed to download Excel",
"downloadInventoryRawZipFailed": "Failed to download raw inventory ZIP",
"downloadReceiptRawZipFailed": "Failed to download raw receipt ZIP",
"deleteFailed": "Delete schedule failed"
},
"difySnapshot": {
+6 -5
View File
@@ -3707,7 +3707,7 @@
"matchTitle": "Transferable stock list",
"businessDate": "Business date",
"executableCount": "Executable",
"notMaturedCount": "Same-day receipt",
"notMaturedCount": "Immature receipts",
"blockedCount": "Blocked",
"estimatedQuantity": "Est. transfer qty",
"estimatedExternalWrites": "Est. ERP documents",
@@ -3768,6 +3768,7 @@
"downloadExceptions": "Download exceptions Excel",
"backlogTitle": "Backlog exceptions",
"resumeAction": "Resume",
"resumeActionShort": "Resume",
"colAging": "Aging",
"colAction": "Actions",
"selectedRows": "{count} selected",
@@ -3779,6 +3780,7 @@
"toastCloseDone": "Closed: {ok} succeeded, {failed} failed",
"batchCloseTitle": "Mark as no further action ({count} items)",
"manualClose": "Mark as no further action",
"manualCloseShort": "Close",
"manualCloseTitle": "Mark as no further action",
"manualCloseHint": "Auto schedule will skip it; history and audit are kept permanently.",
"closeReasonPlaceholder": "Enter a reason (required)",
@@ -3792,7 +3794,6 @@
"resultUnknownReadonly": "Read-only; verify per SOP",
"noBacklog": "No backlog exceptions",
"sourceSelectTitle": "Select receipt source instances",
"sourceSelectHint": "DBS / Crane are platform groups; select the actual source instances to process.",
"transferTypeLabel": "Transfer type",
"transferType": {
"in_transit_to_hub": "In-transit to HUB",
@@ -3817,7 +3818,6 @@
"homeClosed": "Manually closed",
"homeClosedHint": "View reason and restore processing",
"homeUnknown": "Unknown result",
"homeUnknownHint": "Read-only; verify ERP facts offline",
"homeBack": "Back to home",
"retryReceipt": "Retry receipt RPA",
"retrying": "Retrying…",
@@ -3825,6 +3825,7 @@
"fileFetching": "Fetching",
"fileFailed": "Fetch failed",
"fileExpired": "File expired",
"fileParseFailed": "Parse failed",
"sourceErrorTitle": "Source processing failed",
"fileNone": "Pending",
"needReadyFile": "A selected source has no receipt file / is fetching / failed. Retry receipt RPA first.",
@@ -3833,7 +3834,7 @@
"batchRetry": "Batch retry RPA",
"downloadFiles": "Download receipt files",
"selectedRetryableCount": "{count} retryable",
"noRetryable": "No selected source needs retry (already ready or fetching)",
"noRetryable": "No selected source needs retry (fetching in progress)",
"homeMatchLabel": "Stock matching",
"homeBoardLabel": "To-do board",
"homeExecutable": "Executable items",
@@ -3889,7 +3890,7 @@
"toastOrderClosed": "Order closed; its rows returned to the pending pool",
"toastRetriggerAccepted": "Retriggered; the final step is queued",
"homeExecuted": {
"title": "Executed transfer orders",
"title": "Execution Board",
"refresh": "Refresh",
"empty": "No executed orders yet",
"pageInfo": "{total} orders · page {page}",
+2 -2
View File
@@ -196,8 +196,8 @@
"SHIPPING_INVENTORY_RULE_RETIRE_INVALID": "This inventory routing rule cannot be retired.",
"SHIPPING_INVENTORY_SOURCE_DELETE_BLOCKED": "The inventory source is still referenced by business data and cannot be deleted.",
"SHIPPING_INVENTORY_SOURCE_NOT_FOUND": "The inventory source was not found.",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "Complete the test export and activation checks before enabling the inventory site.",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "The inventory site has not completed its production readiness checks and cannot be enabled.",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "Bind an available connection, published inventory parsing, and shipping template before enabling the inventory site.",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "The inventory site does not meet the hard enablement gates (connection, parsing profile, or shipping template) and cannot be enabled.",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_REQUIRED": "Select an inventory sample file.",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_TOO_LARGE": "The inventory sample file exceeds the 20 MB limit.",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_INVALID": "The inventory sample file cannot be recognised. Check its format and headers.",
+19 -4
View File
@@ -629,7 +629,7 @@
"orderSchemaRequired": "โปรดเผยแพร่เวอร์ชันฟิลด์คำสั่งซื้อก่อน เพื่อให้โปรไฟล์การแยกวิเคราะห์สต็อก เทมเพลต Excel สำหรับจัดส่ง และกฎการกำหนดเส้นทางอ้างอิงฟิลด์คำสั่งซื้อได้",
"connections": "การเชื่อมต่อระบบ",
"receiptReportConfig": "การตั้งค่ารายงานรับสินค้า",
"receiptReportConfigHint": "โครงสร้างเหมือนการตั้งค่าสต็อก: เส้นทางรายงาน + เงื่อนไขค้นหา แต่ละ Warehouse ในเงื่อนไขจะส่งออกไฟล์รับสินค้าหนึ่งไฟล์ต่อรอบ และไม่กรองวันที่รายงาน การรับสินค้าไม่มีสวิตช์แยก และจะเปิดหรือปิดตามไซต์โดยรวม",
"receiptReportConfigHint": "โครงสร้างเหมือนการตั้งค่าสต็อก: เส้นทางรายงาน + เงื่อนไขค้นหา เงื่อนไขค้นหาเป็นทางเลือก ว่างหมายถึงใช้ค่าเริ่มต้นของหน้าจอ ตารางเวลาส่งออกหนึ่งไฟล์ต่อไซต์ และไม่กรองวันที่รายงาน การรับสินค้าไม่มีสวิตช์แยก และจะเปิดหรือปิดตามไซต์โดยรวม",
"receiptQueryParametersHint": "เหมือนเงื่อนไขค้นหาสต็อก Warehouse รองรับหลายค่า (คั่นด้วยเครื่องหมายจุลภาค) แต่ละ Warehouse จะส่งออกไฟล์รับสินค้าหนึ่งไฟล์ และห้ามกรองวันที่รายงาน",
"receiptCraneFixedPath": "การส่งออกรับสินค้าของ Crane ถูกกำหนดเป็น Inbound Details และไม่แยกตาม Warehouse ไม่มีการบำรุงรักษาเงื่อนไขค้นหา และระบบจะ Run Report ด้วยค่าเริ่มต้นของหน้าเว็บโดยตรง",
"pathSectionConfigured": "ตั้งค่าแล้ว",
@@ -705,7 +705,7 @@
"movementFields": {
"doc_no": "เลขที่เอกสาร", "line_no": "ลำดับรายการ", "in_out_flag": "เข้า/ออก", "material_code": "รหัสวัสดุ",
"material_name": "ชื่อวัสดุ", "warehouse_code": "คลังสินค้า", "storage_code": "ตำแหน่งจัดเก็บ", "lot_no": "เลขล็อต",
"quantity": "จำนวน", "movement_date": "วันที่เคลื่อนไหว"
"quantity": "จำนวน", "movement_date": "วันที่เคลื่อนไหว", "unit": "หน่วย"
},
"inventoryAnalysisFailed": "การระบุโครงสร้างไฟล์สต็อกล้มเหลว",
"inventoryAnalysisPreview": "ตัวอย่างผลการระบุ",
@@ -908,7 +908,9 @@
"parsingBindingOperationDirect": "ผูกโดยตรง",
"parsingBindingOperationBulk": "ผูกแบบกลุ่ม",
"parsingBindingVersion": "เวอร์ชันการตั้งค่า {before} → {after}",
"sourceSavedDisabledHint": "ไซต์จะยังปิดใช้งานหลังบันทึกครั้งแรก โปรดทำการส่งออกทดสอบ แผนการอ่าน และเทมเพลตการจัดส่งให้เสร็จก่อนเปิดใช้งาน",
"sourceSavedDisabledHint": "ไซต์จะยังปิดใช้งานหลังบันทึกครั้งแรก โปรดผูกแผนการอ่านและเทมเพลตการจัดส่ง แล้วใช้สวิตช์เปิดใช้งาน",
"sourceEnabledToggleHint": "มีผลทันทีเมื่อคลิก",
"inventoryReportConfig": "การกำหนดค่ารายงานสต็อก",
"readinessBlockedBy": "เหลืออีกหนึ่งขั้นก่อนเปิดใช้งาน: {requirement}",
"readinessAutoEnableHint": "เมื่อเสร็จแล้วระบบจะประเมินและเปิดใช้งานไซต์ให้อัตโนมัติ",
"readinessLastVerified": "ตรวจสอบล่าสุด {time}",
@@ -2148,6 +2150,10 @@
"selectPlatformJob": "เลือกงานแพลตฟอร์ม",
"platformJobShippingInventory": "Shipping inventory RPA",
"platformJobFaqHotAggregate": "FAQ hot aggregate",
"platformJobFileAssetCleanup": "Temporary file asset cleanup",
"transferSourceCodes": "Source instances",
"transferRecoverHistory": "Recover retryable history",
"transferNotifyUsers": "Notify users",
"platformJobFixedAssetsSnapshot": "Fixed assets snapshot",
"shippingInventoryJobHint": "ดึงข้อมูลสต็อกจากแหล่งที่กำหนดตามกำหนดเวลา โดย RPA worker ส่งออกแบบอะซิงโครนัส",
"shippingInventoryJobParams": "พารามิเตอร์ Job (ไม่บังคับ)",
@@ -2303,13 +2309,21 @@
"deleteDialogTitle": "ลบตารางเวลา",
"excelExportFailedHint": "แหล่งสต็อกสำเร็จแล้ว แต่การส่งออก Excel ของตารางเวลาล้มเหลว",
"totalSkipped": "รวมที่ข้าม",
"totalSkippedReceipt": "ไม่มีใบรับ/ข้าม",
"totalSkippedInventory": "ไม่มีสต็อก/ข้าม",
"downloadDetail": "ดาวน์โหลดสรุป",
"downloadInventoryRawZip": "ดาวน์โหลดสต็อกดิบ",
"downloadInventoryRawZipPackage": "ดาวน์โหลด ZIP สต็อกดิบ",
"rawInventoryZipWecomHint": "การแจ้งเตือนนี้มีแพ็กสต็อกดิบ กรุณากดปุ่มด้านล่างเพื่อดาวน์โหลดด้วยตนเอง",
"inventoryRawZip": "สต็อกดิบ",
"downloadReceiptRawZip": "ดาวน์โหลดใบรับดิบ",
"downloadReceiptRawZipPackage": "ดาวน์โหลด ZIP ใบรับดิบ",
"rawReceiptZipWecomHint": "การแจ้งเตือนนี้มีแพ็กใบรับดิบ กรุณากดปุ่มด้านล่างเพื่อดาวน์โหลดด้วยตนเอง",
"receiptRawZip": "ใบรับดิบ",
"columns": {
"skippedCount": "ข้าม"
"skippedCount": "ข้าม",
"skippedCountReceipt": "ไม่มีใบรับ/ข้าม",
"skippedCountInventory": "ไม่มีสต็อก/ข้าม"
},
"deleteConfirmMessage": "ยืนยันการลบตารางเวลา \"{name}\"?",
"msg": {
@@ -2323,6 +2337,7 @@
"runNowWaitTimeout": "รอการรันเสร็จสิ้นเกินเวลาที่กำหนด (ประมาณ 15 นาที) หยุดรีเฟรชอัตโนมัติแล้ว โปรดค้นหาบันทึกด้วยตนเอง",
"downloadExcelFailed": "ดาวน์โหลด Excel ล้มเหลว",
"downloadInventoryRawZipFailed": "ดาวน์โหลด ZIP สต็อกดิบล้มเหลว",
"downloadReceiptRawZipFailed": "ดาวน์โหลด ZIP ใบรับดิบล้มเหลว",
"deleteFailed": "ลบตารางเวลาล้มเหลว"
},
"difySnapshot": {
+6 -5
View File
@@ -3707,7 +3707,7 @@
"matchTitle": "รายการสต็อกที่โอนได้",
"businessDate": "วันที่ธุรกิจ",
"executableCount": "ดำเนินการได้",
"notMaturedCount": "รับของวันนี้",
"notMaturedCount": "รับของที่ยังไม่ถึงกำหนด",
"blockedCount": "ถูกบล็อก",
"estimatedQuantity": "จำนวนโอนโดยประมาณ",
"estimatedExternalWrites": "เอกสาร ERP โดยประมาณ",
@@ -3768,6 +3768,7 @@
"downloadExceptions": "ดาวน์โหลด Excel ข้อผิดพลาด",
"backlogTitle": "รายการค้างดำเนินการ",
"resumeAction": "ดำเนินการต่อ",
"resumeActionShort": "กู้คืน",
"colAging": "ความเก่า",
"colAction": "การดำเนินการ",
"selectedRows": "เลือกแล้ว {count} แถว",
@@ -3779,6 +3780,7 @@
"toastCloseDone": "ปิดแล้ว: สำเร็จ {ok} รายการ ล้มเหลว {failed} รายการ",
"batchCloseTitle": "ทำเครื่องหมายไม่ต้องดำเนินการต่อ ({count} รายการ)",
"manualClose": "ทำเครื่องหมายไม่ต้องดำเนินการ",
"manualCloseShort": "ปิด",
"manualCloseTitle": "ทำเครื่องหมายไม่ต้องดำเนินการ",
"manualCloseHint": "หลังปิดระบบอัตโนมัติจะไม่ประมวลผลอีก ประวัติและการตรวจสอบคงอยู่ถาวร",
"closeReasonPlaceholder": "กรอกเหตุผล (จำเป็น)",
@@ -3792,7 +3794,6 @@
"resultUnknownReadonly": "อ่านอย่างเดียว ตรวจตาม SOP",
"noBacklog": "ไม่มีรายการค้างดำเนินการ",
"sourceSelectTitle": "เลือกแหล่งรับของ",
"sourceSelectHint": "DBS / Crane เป็นเพียงกลุ่มแพลตฟอร์ม กรุณาเลือกแหล่งรับของจริงที่ต้องการดำเนินการ",
"transferTypeLabel": "ประเภทการโอนย้าย",
"transferType": {
"in_transit_to_hub": "ระหว่างทางไปยัง HUB",
@@ -3817,7 +3818,6 @@
"homeClosed": "ปิดด้วยตนเองแล้ว",
"homeClosedHint": "สามารถดูสาเหตุและกู้คืนการดำเนินการได้",
"homeUnknown": "ผลลัพธ์ไม่ทราบ",
"homeUnknownHint": "อ่านอย่างเดียว ต้องตรวจสอบข้อเท็จจริง ERP ภายนอก",
"homeBack": "กลับหน้าหลัก",
"retryReceipt": "ลองใหม่ RPA รับของ",
"retrying": "กำลังลองใหม่…",
@@ -3825,6 +3825,7 @@
"fileFetching": "กำลังดึง",
"fileFailed": "ดึงล้มเหลว",
"fileExpired": "ไฟล์หมดอายุ",
"fileParseFailed": "แยกวิเคราะห์ไม่สำเร็จ",
"sourceErrorTitle": "ประมวลผลแหล่งข้อมูลล้มเหลว",
"fileNone": "รอดำเนินการ",
"needReadyFile": "แหล่งที่เลือกไม่มีไฟล์รับของ / กำลังดึง / ล้มเหลว โปรดลอง RPA รับของก่อน",
@@ -3833,7 +3834,7 @@
"batchRetry": "ลองใหม่เป็นชุด",
"downloadFiles": "ดาวน์โหลดไฟล์การรับสินค้า",
"selectedRetryableCount": "ลองใหม่ได้ {count} รายการ",
"noRetryable": "ไม่มีแหล่งที่เลือกต้องลองใหม่ (พร้อมแล้วหรือกำลังดึง)",
"noRetryable": "ไม่มีแหล่งที่เลือกต้องลองใหม่ (กำลังดึงข้อมูล)",
"homeMatchLabel": "จับคู่สต็อก",
"homeBoardLabel": "บอร์ดงานที่ต้องดำเนินการ",
"homeExecutable": "รายการที่โอนได้",
@@ -3889,7 +3890,7 @@
"toastOrderClosed": "ปิดใบโอนย้ายแล้ว รายการกลับไปยังคลังรอดำเนินการ",
"toastRetriggerAccepted": "ทริกเกอร์ใหม่แล้ว ขั้นตอนสุดท้ายอยู่ในคิว",
"homeExecuted": {
"title": "ใบโอนย้ายที่ดำเนินการแล้ว",
"title": "บอร์ดการดำเนินการ",
"refresh": "รีเฟรช",
"empty": "ยังไม่มีใบโอนย้ายที่ดำเนินการแล้ว",
"pageInfo": "ทั้งหมด {total} ใบ · หน้า {page}",
+2 -2
View File
@@ -196,8 +196,8 @@
"SHIPPING_INVENTORY_RULE_RETIRE_INVALID": "ไม่สามารถเลิกใช้งานกฎการกำหนดเส้นทางสินค้าคงคลังนี้ได้",
"SHIPPING_INVENTORY_SOURCE_DELETE_BLOCKED": "แหล่งสินค้าคงคลังยังถูกอ้างอิงโดยข้อมูลธุรกิจและไม่สามารถลบได้",
"SHIPPING_INVENTORY_SOURCE_NOT_FOUND": "ไม่พบแหล่งสินค้าคงคลัง",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "โปรดทำการส่งออกทดสอบและตรวจสอบก่อนเปิดใช้งานไซต์สต็อก",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "ไซต์สต็อกยังไม่ผ่านการตรวจสอบก่อนใช้งานจริง จึงไม่สามารถเปิดใช้งานได้",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "โปรดผูกการเชื่อมต่อที่ใช้ได้ แผนการอ่านที่เผยแพร่แล้ว และเทมเพลตการจัดส่ง ก่อนเปิดใช้ไซต์สต็อก",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "ไซต์สต็อกยังไม่ผ่านเงื่อนไขเปิดใช้งานพื้นฐาน (การเชื่อมต่อ แผนการอ่าน หรือเทมเพลตการจัดส่ง) จึงเปิดใช้ไม่ได้",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_REQUIRED": "โปรดเลือกไฟล์ตัวอย่างสต็อก",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_TOO_LARGE": "ไฟล์ตัวอย่างสต็อกเกินขีดจำกัด 20 MB",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_INVALID": "ไม่สามารถระบุไฟล์ตัวอย่างสต็อกได้ โปรดตรวจสอบรูปแบบไฟล์และหัวตาราง",
+18 -3
View File
@@ -758,7 +758,7 @@
"orderSchemaRequired": "请先在「订单 Schema」发布一个版本;库存解析、发货模板和路由规则才能引用订单字段。",
"connections": "系统连接",
"receiptReportConfig": "收料报表配置",
"receiptReportConfigHint": "与库存配置同构:报表路径 + 查询条件。Warehouse 条件填几个仓,排程逐仓拆分导出几个收料文件;报表日期固定不筛选。收料无独立开关,随站点统一启停。",
"receiptReportConfigHint": "与库存配置同构:报表路径 + 查询条件。查询条件可选,空则使用页面默认;排程按站点一对一导出,报表日期固定不筛选。收料无独立开关,随站点统一启停。",
"receiptQueryParametersHint": "与库存查询条件一致。Warehouse 支持多值(英文逗号分隔),每个 Warehouse 拆分导出一个收料文件;报表日期固定禁填。",
"receiptCraneFixedPath": "Crane 收料固定导出 Inbound Details,不按 Warehouse 拆分,也不维护查询条件;执行时直接使用页面默认条件点击 Run Report。",
"pathSectionConfigured": "已配置",
@@ -834,7 +834,7 @@
"movementFields": {
"doc_no": "单号", "line_no": "项次", "in_out_flag": "进出库别", "material_code": "料号",
"material_name": "品名", "warehouse_code": "仓库", "storage_code": "储位", "lot_no": "批号",
"quantity": "数量", "movement_date": "异动日期"
"quantity": "数量", "movement_date": "异动日期", "unit": "单位"
},
"inventoryAnalysisFailed": "库存文件结构识别失败。",
"inventoryAnalysisPreview": "识别结果预览",
@@ -1037,7 +1037,9 @@
"parsingBindingOperationDirect": "直接绑定",
"parsingBindingOperationBulk": "批量绑定",
"parsingBindingVersion": "配置版本 {before} → {after}",
"sourceSavedDisabledHint": "首次保存后站点保持停用;请完成测试导出、库存解析和发货模板配置后再启用。",
"inventoryReportConfig": "库存报表配置",
"sourceSavedDisabledHint": "首次保存后站点保持停用;请绑定库存解析与发货模板后,用启用开关开启。",
"sourceEnabledToggleHint": "点击立即生效",
"readinessBlockedBy": "启用前还差一步:{requirement}",
"readinessAutoEnableHint": "完成后系统会自动判断并启用站点。",
"readinessLastVerified": "上次验证 {time}",
@@ -2295,6 +2297,8 @@
"totalProcessed": "处理总数",
"totalSuccess": "成功总数",
"totalSkipped": "跳过总数",
"totalSkippedReceipt": "无收料/跳过",
"totalSkippedInventory": "无库存/跳过",
"totalFailed": "失败总数",
"listTitle": "排程列表",
"recordsTitle": "{name} · 执行记录",
@@ -2325,6 +2329,10 @@
"downloadInventoryRawZipPackage": "下载原始库存包",
"rawInventoryZipWecomHint": "本通知含原始库存包,请点击下方按钮手动下载。",
"inventoryRawZip": "原始库存",
"downloadReceiptRawZip": "下载原始收料",
"downloadReceiptRawZipPackage": "下载原始收料包",
"rawReceiptZipWecomHint": "本通知含原始收料包,请点击下方按钮手动下载。",
"receiptRawZip": "原始收料",
"log": "日志",
"actions": {
"edit": "编辑",
@@ -2342,6 +2350,8 @@
"totalCount": "处理",
"successCount": "成功",
"skippedCount": "跳过",
"skippedCountReceipt": "无收料/跳过",
"skippedCountInventory": "无库存/跳过",
"failedCount": "失败",
"excelExportFailedHint": "库存源已成功,但排程 Excel 生成失败",
"wecomNotified": "企微通知",
@@ -2364,6 +2374,10 @@
"selectPlatformJob": "请选择平台任务",
"platformJobShippingInventory": "货代库存 RPA",
"platformJobFaqHotAggregate": "FAQ 热点聚合",
"platformJobFileAssetCleanup": "临时文件资产清理",
"transferSourceCodes": "来源实例",
"transferRecoverHistory": "历史可恢复异常复核",
"transferNotifyUsers": "通知人",
"platformJobFixedAssetsSnapshot": "固资快照",
"shippingInventoryJobHint": "按计划从配置的库存源抓取库存数据,由 RPA Worker 异步导出。",
"shippingInventoryJobParams": "Job 参数(可选)",
@@ -2566,6 +2580,7 @@
"runNowWaitTimeout": "等待执行完成超时(约 15 分钟),已停止自动刷新,可手动查询记录",
"downloadExcelFailed": "下载 Excel 失败",
"downloadInventoryRawZipFailed": "下载原始库存包失败",
"downloadReceiptRawZipFailed": "下载原始收料包失败",
"deleteFailed": "删除排程失败"
},
"difySnapshot": {
+6 -5
View File
@@ -3780,7 +3780,7 @@
"matchTitle": "可调拨清单",
"businessDate": "业务日期",
"executableCount": "可执行",
"notMaturedCount": "当天收料",
"notMaturedCount": "未成熟收料",
"blockedCount": "阻断",
"estimatedQuantity": "预计调拨数量",
"estimatedExternalWrites": "预计 ERP 单据",
@@ -3841,6 +3841,7 @@
"downloadExceptions": "下载异常 Excel",
"backlogTitle": "待处理异常",
"resumeAction": "恢复处理",
"resumeActionShort": "恢复",
"colAging": "老化",
"colAction": "操作",
"selectedRows": "已选 {count} 行",
@@ -3852,6 +3853,7 @@
"toastCloseDone": "关闭完成:{ok} 行成功,{failed} 行失败",
"batchCloseTitle": "标记无需继续处理({count} 项)",
"manualClose": "标记无需继续处理",
"manualCloseShort": "关闭",
"manualCloseTitle": "标记无需继续处理",
"manualCloseHint": "关闭后自动排程不再处理;历史与审计永久保留。",
"closeReasonPlaceholder": "请输入关闭原因(必填)",
@@ -3865,7 +3867,6 @@
"resultUnknownReadonly": "只读,按 SOP 人工核实",
"noBacklog": "暂无待处理异常",
"sourceSelectTitle": "选择收料来源实例",
"sourceSelectHint": "DBS、Crane 仅为平台分组;请勾选实际需要处理的来源实例。",
"transferTypeLabel": "调拨类型",
"transferType": {
"in_transit_to_hub": "在途仓至HUB仓",
@@ -3890,7 +3891,6 @@
"homeClosed": "已人工关闭",
"homeClosedHint": "可查看原因并恢复处理",
"homeUnknown": "结果未知",
"homeUnknownHint": "只读,需线下核实 ERP 事实",
"homeBack": "返回首页",
"retryReceipt": "重试收料 RPA",
"retrying": "重试中…",
@@ -3898,6 +3898,7 @@
"fileFetching": "抓取中",
"fileFailed": "抓取失败",
"fileExpired": "文件已过期",
"fileParseFailed": "解析失败",
"sourceErrorTitle": "来源处理失败",
"fileNone": "待抓取",
"needReadyFile": "所选来源存在无收料文件/或抓取中/或失败,请先重试收料 RPA",
@@ -3906,7 +3907,7 @@
"batchRetry": "批量重试 RPA",
"downloadFiles": "下载收料文件",
"selectedRetryableCount": "其中 {count} 个可重试",
"noRetryable": "所选来源均无需重试(已就绪或抓取中)",
"noRetryable": "所选来源均无需重试(抓取中)",
"homeMatchLabel": "库存匹配",
"homeBoardLabel": "待办看板",
"homeExecutable": "可调拨明细",
@@ -3962,7 +3963,7 @@
"toastOrderClosed": "调拨单已关闭,行已回到待执行池",
"toastRetriggerAccepted": "已重新触发,正在排队执行末步",
"homeExecuted": {
"title": "已执行调拨单",
"title": "执行看板",
"refresh": "刷新",
"empty": "暂无已执行调拨单",
"pageInfo": "共 {total} 张 · 第 {page} 页",
+2 -2
View File
@@ -196,8 +196,8 @@
"SHIPPING_INVENTORY_RULE_RETIRE_INVALID": "当前库存路由规则不能退役。",
"SHIPPING_INVENTORY_SOURCE_DELETE_BLOCKED": "库存源仍被业务数据引用,不能删除。",
"SHIPPING_INVENTORY_SOURCE_NOT_FOUND": "未找到库存源。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "请先完成测试导出和启用检查,再启用库存站点。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "库存站点尚未完成正式运行检查,暂不能启用。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "请先绑定可用连接、已发布库存解析和发货模板,再启用库存站点。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "库存站点尚未满足启用硬门槛(连接、解析方案或发货模板),暂不能启用。",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_REQUIRED": "请选择库存样本文件。",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_TOO_LARGE": "库存样本文件超过 20 MB 限制。",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_INVALID": "库存样本文件无法识别,请检查文件格式和表头。",
+19 -4
View File
@@ -629,7 +629,7 @@
"orderSchemaRequired": "請先在「訂單欄位規則」發佈一個版本;庫存解析、出貨範本和路由規則才能引用訂單欄位。",
"connections": "系統連線",
"receiptReportConfig": "收料報表設定",
"receiptReportConfigHint": "與庫存設定同構:報表路徑 + 查詢條件。Warehouse 條件填幾個倉,排程逐倉拆分匯出幾個收料檔案;報表日期固定不篩選。收料無獨立開關,隨站點統一啟停。",
"receiptReportConfigHint": "與庫存設定同構:報表路徑 + 查詢條件。查詢條件可選,空則使用頁面預設;排程按站點一對一匯出,報表日期固定不篩選。收料無獨立開關,隨站點統一啟停。",
"receiptQueryParametersHint": "與庫存查詢條件一致。Warehouse 支援多值(英文逗號分隔),每個 Warehouse 拆分匯出一個收料檔案;報表日期固定禁填。",
"receiptCraneFixedPath": "Crane 收料固定匯出 Inbound Details,不依 Warehouse 拆分,也不維護查詢條件;執行時直接使用頁面預設條件點擊 Run Report。",
"pathSectionConfigured": "已設定",
@@ -705,7 +705,7 @@
"movementFields": {
"doc_no": "單號", "line_no": "項次", "in_out_flag": "進出庫別", "material_code": "料號",
"material_name": "品名", "warehouse_code": "倉庫", "storage_code": "儲位", "lot_no": "批號",
"quantity": "數量", "movement_date": "異動日期"
"quantity": "數量", "movement_date": "異動日期", "unit": "單位"
},
"inventoryAnalysisFailed": "庫存檔案結構識別失敗。",
"inventoryAnalysisPreview": "識別結果預覽",
@@ -908,7 +908,9 @@
"parsingBindingOperationDirect": "直接綁定",
"parsingBindingOperationBulk": "批量綁定",
"parsingBindingVersion": "設定版本 {before} → {after}",
"sourceSavedDisabledHint": "首次儲存後站點保持停用;請完成測試匯出、庫存解析與出貨範本設定後再啟用。",
"sourceSavedDisabledHint": "首次儲存後站點保持停用;請綁定庫存解析與出貨範本後,用啟用開關開啟。",
"sourceEnabledToggleHint": "點擊立即生效",
"inventoryReportConfig": "庫存報表配置",
"readinessBlockedBy": "啟用前還差一步:{requirement}",
"readinessAutoEnableHint": "完成後系統會自動判斷並啟用站點。",
"readinessLastVerified": "上次驗證 {time}",
@@ -2153,6 +2155,10 @@
"selectPlatformJob": "請選擇平台任務",
"platformJobShippingInventory": "貨代庫存 RPA",
"platformJobFaqHotAggregate": "FAQ 熱點聚合",
"platformJobFileAssetCleanup": "暫存檔案資產清理",
"transferSourceCodes": "來源實例",
"transferRecoverHistory": "歷史可復原異常複核",
"transferNotifyUsers": "通知人",
"platformJobFixedAssetsSnapshot": "固資快照",
"shippingInventoryJobHint": "按計畫從配置的庫存來源抓取庫存資料,由 RPA Worker 非同步匯出。",
"shippingInventoryJobParams": "Job 參數(可選)",
@@ -2308,13 +2314,21 @@
"deleteDialogTitle": "刪除排程",
"excelExportFailedHint": "庫存來源已成功,但排程 Excel 生成失敗",
"totalSkipped": "跳過總數",
"totalSkippedReceipt": "無收料/跳過",
"totalSkippedInventory": "無庫存/跳過",
"downloadDetail": "下載明細",
"downloadInventoryRawZip": "下載原始庫存",
"downloadInventoryRawZipPackage": "下載原始庫存包",
"rawInventoryZipWecomHint": "本通知含原始庫存包,請點擊下方按鈕手動下載。",
"inventoryRawZip": "原始庫存",
"downloadReceiptRawZip": "下載原始收料",
"downloadReceiptRawZipPackage": "下載原始收料包",
"rawReceiptZipWecomHint": "本通知含原始收料包,請點擊下方按鈕手動下載。",
"receiptRawZip": "原始收料",
"columns": {
"skippedCount": "跳過"
"skippedCount": "跳過",
"skippedCountReceipt": "無收料/跳過",
"skippedCountInventory": "無庫存/跳過"
},
"deleteConfirmMessage": "確認刪除排程「{name}」?",
"msg": {
@@ -2328,6 +2342,7 @@
"runNowWaitTimeout": "等待執行完成逾時(約 15 分鐘),已停止自動重新整理,可手動查詢記錄",
"downloadExcelFailed": "下載 Excel 失敗",
"downloadInventoryRawZipFailed": "下載原始庫存包失敗",
"downloadReceiptRawZipFailed": "下載原始收料包失敗",
"deleteFailed": "刪除排程失敗"
},
"difySnapshot": {
+6 -5
View File
@@ -3707,7 +3707,7 @@
"matchTitle": "可調撥清單",
"businessDate": "業務日期",
"executableCount": "可執行",
"notMaturedCount": "當天收料",
"notMaturedCount": "未成熟收料",
"blockedCount": "阻斷",
"estimatedQuantity": "預計調撥數量",
"estimatedExternalWrites": "預計 ERP 單據",
@@ -3768,6 +3768,7 @@
"downloadExceptions": "下載異常 Excel",
"backlogTitle": "待處理異常",
"resumeAction": "恢復處理",
"resumeActionShort": "恢復",
"colAging": "老化",
"colAction": "操作",
"selectedRows": "已選 {count} 行",
@@ -3779,6 +3780,7 @@
"toastCloseDone": "關閉完成:{ok} 行成功,{failed} 行失敗",
"batchCloseTitle": "標記無需繼續處理({count} 項)",
"manualClose": "標記無需繼續處理",
"manualCloseShort": "關閉",
"manualCloseTitle": "標記無需繼續處理",
"manualCloseHint": "關閉後自動排程不再處理;歷史與稽核永久保留。",
"closeReasonPlaceholder": "請輸入關閉原因(必填)",
@@ -3792,7 +3794,6 @@
"resultUnknownReadonly": "唯讀,依 SOP 人工核實",
"noBacklog": "暫無待處理異常",
"sourceSelectTitle": "選擇收料來源實例",
"sourceSelectHint": "DBS、Crane 僅為平台分組;請勾選實際需要處理的來源實例。",
"transferTypeLabel": "調撥類型",
"transferType": {
"in_transit_to_hub": "在途倉至HUB倉",
@@ -3817,7 +3818,6 @@
"homeClosed": "已人工關閉",
"homeClosedHint": "可查看原因並恢復處理",
"homeUnknown": "結果未知",
"homeUnknownHint": "唯讀,需線下核實 ERP 事實",
"homeBack": "返回首頁",
"retryReceipt": "重試收料 RPA",
"retrying": "重試中…",
@@ -3825,6 +3825,7 @@
"fileFetching": "抓取中",
"fileFailed": "抓取失敗",
"fileExpired": "檔案已過期",
"fileParseFailed": "解析失敗",
"sourceErrorTitle": "來源處理失敗",
"fileNone": "待抓取",
"needReadyFile": "所選來源存在無收料檔案/或抓取中/或失敗,請先重試收料 RPA",
@@ -3833,7 +3834,7 @@
"batchRetry": "批次重試 RPA",
"downloadFiles": "下載收料文件",
"selectedRetryableCount": "其中 {count} 個可重試",
"noRetryable": "所選來源均無需重試(已就緒或抓取中)",
"noRetryable": "所選來源均無需重試(抓取中)",
"homeMatchLabel": "庫存匹配",
"homeBoardLabel": "待辦看板",
"homeExecutable": "可調撥明細",
@@ -3889,7 +3890,7 @@
"toastOrderClosed": "調撥單已關閉,行已回到待執行池",
"toastRetriggerAccepted": "已重新觸發,正在排隊執行末步",
"homeExecuted": {
"title": "已執行調撥單",
"title": "執行看板",
"refresh": "重新整理",
"empty": "暫無已執行調撥單",
"pageInfo": "共 {total} 張 · 第 {page} 頁",
+2 -2
View File
@@ -196,8 +196,8 @@
"SHIPPING_INVENTORY_RULE_RETIRE_INVALID": "目前庫存路由規則不能退役。",
"SHIPPING_INVENTORY_SOURCE_DELETE_BLOCKED": "庫存來源仍被業務資料引用,不能刪除。",
"SHIPPING_INVENTORY_SOURCE_NOT_FOUND": "找不到庫存來源。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "請先完成測試匯出與啟用檢查,再啟用庫存站點。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "庫存站點尚未完成正式執行檢查,暫時不能啟用。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_REQUIRED": "請先綁定可用連線、已發布庫存解析與出貨範本,再啟用庫存站點。",
"SHIPPING_INVENTORY_SOURCE_ACTIVATION_BLOCKED": "庫存站點尚未滿足啟用硬門檻(連線、解析方案或出貨範本),暫不能啟用。",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_REQUIRED": "請選擇庫存樣本檔案。",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_FILE_TOO_LARGE": "庫存樣本檔案超過 20 MB 限制。",
"SHIPPING_INVENTORY_STRUCTURE_ANALYSIS_INVALID": "無法識別庫存樣本檔案,請檢查檔案格式與表頭。",
@@ -52,6 +52,7 @@ export interface ScheduleRun {
excel_file_name?: string | null;
excel_file_size?: number | null;
inventory_raw_zip_available?: boolean;
receipt_raw_zip_available?: boolean;
kb_sync_status?: string | null;
kb_group_id?: number | null;
kb_document_id?: number | null;