feat(in-transit-transfer): 实现在途仓自动调拨Agent一期完整功能
包含后端服务层、任务处理器与消费Worker、前端聊天组件、数据库模型与迁移脚本、测试用例,同时新增外部系统连接器框架基础能力并更新相关文档。
This commit is contained in:
1 parent
f3050164d0
commit
6b53b563e7
177 files changed
+17260
-36
No files matched your search
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* features/chat/api/transfer.api.spec.ts
|
||||
* 用途:锁定在途仓自动调拨 JSON POST 请求头契约——必须携带 Content-Type: application/json,
|
||||
* 否则后端 Flask request.get_json 解析不到 body,导致默认 source_codes=[] 返回 400。
|
||||
* 依赖:Vitest、vi.mock(@/shared/api/client)、transfer.api、getAuthHeaders。
|
||||
* 逻辑:POST(create/execute/cancel/retry/manual-close)断言 headers 含 application/json,
|
||||
* 且 body 序列化正确;GET/blob 端点不强制 Content-Type。
|
||||
*/
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const requestJson = vi.hoisted(() => vi.fn());
|
||||
const requestBlob = vi.hoisted(() => vi.fn());
|
||||
|
||||
vi.mock('@/shared/api/client', () => ({
|
||||
BusinessError: class BusinessError extends Error {},
|
||||
requestJson,
|
||||
requestBlob,
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/utils/auth', () => ({
|
||||
getAuthHeaders: () => ({ Authorization: 'Bearer TEST-TOKEN' }),
|
||||
}));
|
||||
|
||||
import {
|
||||
cancelTransferRun,
|
||||
createTransferPrecheck,
|
||||
executeTransferPrecheck,
|
||||
getTransferBacklogSummary,
|
||||
getTransferPrecheck,
|
||||
getTransferRun,
|
||||
listTransferSources,
|
||||
manualCloseTransferItem,
|
||||
retryTransferItem,
|
||||
} from './transfer.api';
|
||||
|
||||
describe('transfer.api JSON request contract', () => {
|
||||
beforeEach(() => {
|
||||
requestJson.mockReset();
|
||||
requestBlob.mockReset();
|
||||
});
|
||||
|
||||
it('创建预检 POST 带 Content-Type: application/json 与序列化 source_codes', () => {
|
||||
createTransferPrecheck({ source_codes: ['DBS-AWSBI'], business_date: '2026-08-18' });
|
||||
const [url, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/prechecks');
|
||||
expect(init.method).toBe('POST');
|
||||
expect((init.headers as Record<string, string>)['Content-Type']).toBe('application/json');
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], business_date: '2026-08-18' }));
|
||||
});
|
||||
|
||||
it('直接生成调拨单 POST 带 application/json', () => {
|
||||
executeTransferPrecheck('TPC-1', ['INV-001']);
|
||||
const [, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(init.method).toBe('POST');
|
||||
expect((init.headers as Record<string, string>)['Content-Type']).toBe('application/json');
|
||||
expect(init.body).toBe(JSON.stringify({ invoice_nos: ['INV-001'] }));
|
||||
});
|
||||
|
||||
it('重试/关闭/取消 POST 带 application/json', () => {
|
||||
retryTransferItem(7);
|
||||
manualCloseTransferItem(7, '线下已处理');
|
||||
cancelTransferRun('RUN-1', '紧急');
|
||||
for (const [, init] of requestJson.mock.calls as [string, RequestInit][]) {
|
||||
expect(init.method).toBe('POST');
|
||||
expect((init.headers as Record<string, string>)['Content-Type']).toBe('application/json');
|
||||
}
|
||||
});
|
||||
|
||||
it('GET 端点只需鉴权头,不需要强制 Content-Type', () => {
|
||||
getTransferPrecheck('TPC-1');
|
||||
getTransferRun('RUN-1');
|
||||
getTransferBacklogSummary();
|
||||
listTransferSources();
|
||||
for (const [, init] of requestJson.mock.calls as [string, RequestInit][]) {
|
||||
expect(init.headers).toBeDefined();
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,112 @@
|
||||
/**
|
||||
* features/chat/api/transfer.api.ts
|
||||
* 用途:在途仓自动调拨 API 客户端(统一 requestJson / requestBlob,不重复造客户端)。
|
||||
* 依赖:@/shared/api/client(requestJson / requestBlob / BusinessError)、getAuthHeaders。
|
||||
* 逻辑:薄封装后端 /api/in-transit-transfer 全部端点;二进制下载走 requestBlob。
|
||||
*/
|
||||
import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type {
|
||||
TransferActionResult,
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferExecuteResponse,
|
||||
TransferPrecheckDetail,
|
||||
TransferPrecheckSummary,
|
||||
TransferRunResult,
|
||||
TransferSourceFileStatus,
|
||||
TransferSourceOption,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
const BASE = '/api/in-transit-transfer';
|
||||
|
||||
/** JSON 请求头:除鉴权外必须带 Content-Type: application/json,否则 Flask request.get_json 解析不到 body。 */
|
||||
const jsonHeaders = () => ({ 'Content-Type': 'application/json', ...getAuthHeaders() });
|
||||
|
||||
export interface CreatePrecheckPayload {
|
||||
source_codes: string[];
|
||||
business_date?: string;
|
||||
}
|
||||
|
||||
/** 创建预检(只读) */
|
||||
export const createTransferPrecheck = (payload: CreatePrecheckPayload) =>
|
||||
requestJson<TransferPrecheckSummary>(BASE + '/prechecks', {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
/** 恢复预检进度与明细 */
|
||||
export const getTransferPrecheck = (precheckId: string) =>
|
||||
requestJson<TransferPrecheckDetail>(`${BASE}/prechecks/${precheckId}`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
|
||||
/** 确认选择范围并直接生成执行 Run */
|
||||
export const executeTransferPrecheck = (precheckId: string, invoiceNos: string[]) =>
|
||||
requestJson<TransferExecuteResponse>(`${BASE}/prechecks/${precheckId}/execute`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ invoice_nos: invoiceNos }),
|
||||
});
|
||||
|
||||
/** 恢复 Run 最终结果 */
|
||||
export const getTransferRun = (runNo: string) =>
|
||||
requestJson<TransferRunResult>(`${BASE}/runs/${runNo}`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
|
||||
/** 请求停止剩余任务 */
|
||||
export const cancelTransferRun = (runNo: string, reason: string) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/runs/${runNo}/cancel`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
/** 人工重试异常项(仅重新查询 ERP,新 Attempt) */
|
||||
export const retryTransferItem = (itemId: number) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/items/${itemId}/retry`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ kind: 'erp_recheck' }),
|
||||
});
|
||||
|
||||
/** 人工关闭异常项 */
|
||||
export const manualCloseTransferItem = (itemId: number, reason: string) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/items/${itemId}/manual-close`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
/** 下载收料来源文件(zip) */
|
||||
export const downloadTransferReceiptFiles = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/receipt-files`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 下载预检冻结的 ERP 库存表(csv) */
|
||||
export const downloadTransferErpInventory = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/erp-inventory`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 下载七 Sheet 异常 Excel */
|
||||
export const downloadTransferExceptions = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/exceptions.xlsx`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 待处理异常列表(可恢复/已关闭/结果未知 + 老化等级) */
|
||||
export const listTransferBacklog = () =>
|
||||
requestJson<TransferBacklogItem[]>(`${BASE}/backlog`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 待处理异常汇总(含 3/5/7 天老化分级) */
|
||||
export const getTransferBacklogSummary = () =>
|
||||
requestJson<TransferBacklogSummary>(`${BASE}/backlog/summary`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 来源实例列表(平台 DBS/Crane 仅分组,每来源附收料文件状态) */
|
||||
export const listTransferSources = () =>
|
||||
requestJson<TransferSourceOption[]>(`${BASE}/sources`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 对指定来源重新触发一次收料 RPA 抓取 */
|
||||
export const retryTransferSourceRpa = (sourceCode: string) =>
|
||||
requestJson<TransferSourceFileStatus>(`${BASE}/sources/${encodeURIComponent(sourceCode)}/retry-rpa`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
});
|
||||
@@ -7,6 +7,7 @@ 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 type { LeaveMessageHandlers } from './messages/LeaveMessageBlock.vue';
|
||||
import type { ShippingMessageHandlers } from './messages/shippingMessageHandlers';
|
||||
@@ -45,6 +46,8 @@ const {
|
||||
toolRunProgressTitle: string;
|
||||
showScrollToBottom: boolean;
|
||||
hideWelcomePanel?: boolean;
|
||||
/** 在途仓自动调拨 Agent:无消息时渲染专属首页入口区(替代通用欢迎面板)。 */
|
||||
isInTransitTransferAgent?: boolean;
|
||||
pinMessagesToBottom?: boolean;
|
||||
/** 供父级滚动逻辑绑定 main 元素 */
|
||||
scrollContainerHolder: { el: Ref<HTMLElement | null> };
|
||||
@@ -63,6 +66,8 @@ const emit = defineEmits<{
|
||||
'maintenance-view-record-history': [device: MaintenanceDevice];
|
||||
'maintenance-create-record-for-device': [device: MaintenanceDevice];
|
||||
'open-batch-workbench': [];
|
||||
/** 在途仓自动调拨:业务流激活时向上冒泡,父级据此隐藏聊天输入框。 */
|
||||
'transfer-flow-active': [active: boolean];
|
||||
}>();
|
||||
|
||||
const bindScrollContainer = (node: unknown) => {
|
||||
@@ -144,7 +149,7 @@ const isLatestAssistantMessage = (items: ChatMessage[], index: number) => {
|
||||
>
|
||||
<div :class="messages.length === 0 ? 'h-full' : pinMessagesToBottom === false ? 'min-h-full' : 'flex min-h-full flex-col justify-end'">
|
||||
<ChatWelcomePanel
|
||||
v-if="messages.length === 0 && !hideWelcomePanel"
|
||||
v-if="messages.length === 0 && !hideWelcomePanel && !isInTransitTransferAgent"
|
||||
:agent-name="agentName"
|
||||
:suggested-questions-style="suggestedQuestionsStyle"
|
||||
:styled-sections="styledSections"
|
||||
@@ -153,6 +158,12 @@ const isLatestAssistantMessage = (items: ChatMessage[], index: number) => {
|
||||
@select-question="emit('select-question', $event)"
|
||||
/>
|
||||
|
||||
<TransferHomePanel
|
||||
v-if="messages.length === 0 && !hideWelcomePanel && isInTransitTransferAgent"
|
||||
:agent-name="agentName"
|
||||
@flow-active="emit('transfer-flow-active', $event)"
|
||||
/>
|
||||
|
||||
<template v-for="(msg, index) in messages" :key="getMessageKey(msg, index)">
|
||||
<ChatMessageBubble
|
||||
v-if="shouldRenderMessage(msg) && !isDuplicateShippingExtractionMessage(messages, index)"
|
||||
|
||||
@@ -44,7 +44,7 @@ import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
|
||||
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
|
||||
|
||||
import { agentHasIntentUiProfile } from '@/shared/utils/agent-registry.utils';
|
||||
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER } from '@/shared/utils/agent-registry.utils';
|
||||
|
||||
import {
|
||||
SHIPPING_WORKFLOW_KEY,
|
||||
@@ -111,6 +111,13 @@ const isTrainingAgentPage = computed(() => matchesTrainingAgent(page.currentAgen
|
||||
|
||||
const isMaintenanceAgentPage = computed(() => agentHasIntentUiProfile(page.currentAgent, 'maintenance'));
|
||||
|
||||
/** 在途仓自动调拨 Agent:无消息时展示专属首页入口区(决策:补 Chat 首页入口 A 方案)。 */
|
||||
const isInTransitTransferAgent = computed(() => resolveAgentCode(page.currentAgent) === AGENT_CODE_IN_TRANSIT_TRANSFER);
|
||||
|
||||
/** 在途仓自动调拨业务流激活(来源选择/待处理等子视图)时隐藏聊天输入框,模拟业务页。 */
|
||||
const transferFlowActive = ref(false);
|
||||
watch(isInTransitTransferAgent, (isTransfer) => { if (!isTransfer) transferFlowActive.value = false; });
|
||||
|
||||
/** 批次进度工作台按需打开;关闭时不占用对话区右侧布局。 */
|
||||
const batchWorkbenchOpen = ref(false);
|
||||
|
||||
@@ -542,6 +549,8 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:hide-welcome-title="hideWelcomeTitle"
|
||||
|
||||
:is-in-transit-transfer-agent="isInTransitTransferAgent"
|
||||
|
||||
:pin-messages-to-bottom="!isTrainingAgentPage"
|
||||
|
||||
:scroll-container-holder="page.scrollContainerHolder"
|
||||
@@ -570,13 +579,15 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
@open-batch-workbench="openBatchWorkbench"
|
||||
|
||||
@transfer-flow-active="transferFlowActive = $event"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<ChatInputBar
|
||||
|
||||
v-show="!isTrainingWorkspaceExpanded"
|
||||
v-show="!isTrainingWorkspaceExpanded && !transferFlowActive"
|
||||
|
||||
:key="`${page.currentAgentId}-${page.conversationId || 'draft'}-${page.messages.length}`"
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBloc
|
||||
import ChatMessageAttachmentList from './ChatMessageAttachmentList.vue';
|
||||
import MaintenanceDeviceResultCard from './MaintenanceDeviceResultCard.vue';
|
||||
import ContractReviewResultCard from './ContractReviewResultCard.vue';
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
|
||||
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
|
||||
import type { ShippingMessageHandlers } from './shippingMessageHandlers';
|
||||
@@ -94,6 +95,12 @@ const RESTRICTED_INLINE_DOWNLOAD_FILE_NAME = '资产明细全量导出表.csv';
|
||||
|
||||
/** 合同审查结果卡:自身已是完整卡片,外层只需透明容器。 */
|
||||
const isContractReviewMessage = computed(() => message.type === 'procurement-contract-review');
|
||||
const isTransferMessage = computed(
|
||||
() =>
|
||||
message.type === 'transfer-precheck'
|
||||
|| message.type === 'transfer-progress'
|
||||
|| message.type === 'transfer-result',
|
||||
);
|
||||
|
||||
const isLeaveMessage = computed(() =>
|
||||
message.type === 'leave-form'
|
||||
@@ -770,6 +777,10 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
v-else-if="message.type === 'procurement-contract-review'"
|
||||
:message="message"
|
||||
/>
|
||||
<TransferMessageView
|
||||
v-else-if="isTransferMessage"
|
||||
:payload="(message.payload as Record<string, unknown> | undefined)"
|
||||
/>
|
||||
<TrainingExamQuestionMessage
|
||||
v-else-if="isTrainingExamMessage && trainingHandlers.getQuestion()"
|
||||
:question="trainingHandlers.getQuestion()!"
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferBacklogSummaryCard.vue
|
||||
用途:待处理异常卡(可恢复/已关闭/结果未知三组)+ 人工重试/人工关闭入口。
|
||||
依赖:props.items、i18n chat.transfer.*。
|
||||
逻辑:result_unknown 只读(无重试/关闭按钮);人工关闭由父组件弹窗处理。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import type { TransferBacklogItem } from '../../types/transfer.types';
|
||||
|
||||
defineProps<{
|
||||
items: TransferBacklogItem[];
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
retry: [itemId: number];
|
||||
close: [item: TransferBacklogItem];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
function agingLabel(level: string): string {
|
||||
const map: Record<string, string> = {
|
||||
warn_3d: 'chat.transfer.agingWarn',
|
||||
escalate_5d: 'chat.transfer.agingEscalate',
|
||||
critical_7d: 'chat.transfer.agingCritical',
|
||||
result_unknown: 'chat.transfer.resultUnknown',
|
||||
closed: 'chat.transfer.statusClosed',
|
||||
};
|
||||
return map[level] ?? 'chat.transfer.agingNormal';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm" data-testid="transfer-backlog-card">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h3 class="text-sm font-bold text-slate-800">{{ $t('chat.transfer.backlogTitle') }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-slate-200 px-2 py-1 text-xs text-slate-600 hover:bg-slate-50"
|
||||
data-testid="transfer-backlog-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</div>
|
||||
<ul v-if="items.length" class="flex flex-col gap-1.5">
|
||||
<li
|
||||
v-for="item in items"
|
||||
:key="item.item_id"
|
||||
class="flex items-center justify-between gap-2 rounded-lg border border-slate-100 px-3 py-2 text-xs"
|
||||
:data-testid="`transfer-backlog-${item.invoice_no}`"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<div class="font-semibold text-slate-700">
|
||||
{{ item.invoice_no }}
|
||||
<span class="ml-1 text-slate-400">{{ item.source_code }}</span>
|
||||
</div>
|
||||
<div class="text-[11px] text-slate-500">
|
||||
{{ item.reason }} · {{ $t(agingLabel(item.aging_level)) }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex shrink-0 gap-1.5">
|
||||
<template v-if="item.status === 'blocked_recoverable'">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-2 py-1 font-bold text-brand-700 hover:bg-brand-50"
|
||||
data-testid="transfer-backlog-retry"
|
||||
@click="emit('retry', item.item_id)"
|
||||
>
|
||||
{{ $t('chat.transfer.retryErp') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-red-200 px-2 py-1 font-bold text-red-600 hover:bg-red-50"
|
||||
data-testid="transfer-backlog-close"
|
||||
@click="emit('close', item)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualClose') }}
|
||||
</button>
|
||||
</template>
|
||||
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-slate-400">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<div v-else class="rounded-lg bg-slate-50 p-3 text-xs text-slate-500">
|
||||
{{ $t('chat.transfer.noBacklog') }}
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,50 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferFileProgressCard.vue
|
||||
用途:来源实例级收料文件准备进度(决策 18:来源隔离展示,不伪造总百分比)。
|
||||
依赖:props.sources、i18n chat.transfer.*。
|
||||
逻辑:按来源显示 file_ready / waiting_rpa_callback / failed 阶段与文件信息。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import type { TransferSourceProgress } from '../../types/transfer.types';
|
||||
|
||||
defineProps<{
|
||||
sources: TransferSourceProgress[];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="my-2 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm"
|
||||
data-testid="transfer-file-progress-card"
|
||||
>
|
||||
<h3 class="mb-3 text-sm font-bold text-slate-800">{{ $t('chat.transfer.fileProgressTitle') }}</h3>
|
||||
<ul class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="source in sources"
|
||||
:key="source.source_code"
|
||||
class="flex items-center justify-between rounded-lg border border-slate-100 px-3 py-2"
|
||||
:data-testid="`transfer-source-${source.source_code}`"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-semibold text-slate-700">{{ source.source_code }}</div>
|
||||
<div v-if="source.file_no" class="truncate text-xs text-slate-400">
|
||||
{{ source.file_no }}<template v-if="source.file_version"> · v{{ source.file_version }}</template>
|
||||
</div>
|
||||
<div v-else-if="source.error_message" class="truncate text-xs text-red-500">{{ source.error_message }}</div>
|
||||
</div>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-2 py-0.5 text-xs font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': source.stage === 'file_ready',
|
||||
'bg-amber-50 text-amber-700': source.stage === 'waiting_rpa_callback',
|
||||
'bg-red-50 text-red-700': source.stage === 'failed',
|
||||
}"
|
||||
>
|
||||
<template v-if="source.stage === 'file_ready'">{{ $t('chat.transfer.stageFileReady') }}</template>
|
||||
<template v-else-if="source.stage === 'waiting_rpa_callback'">{{ $t('chat.transfer.stageWaitingRpa') }}</template>
|
||||
<template v-else>{{ $t('chat.transfer.stageFailed') }}</template>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferHomePanel.spec.ts
|
||||
* 用途:验证在途仓自动调拨 Agent 的 Chat 首页入口区——
|
||||
* home 视图渲染“今日待办 + 历史待办”计数卡;点击入口独立触发
|
||||
* source-select / backlog 卡片(复用自驱动的 TransferMessageView,不注入消息流)。
|
||||
* 依赖:vi.mock(transfer.api)、@vue/test-utils、i18n。
|
||||
* 逻辑:Mock API 断言入口切换与计数展示;对应后端 backlog/summary 契约面。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferPrecheck: vi.fn(),
|
||||
getTransferPrecheck: vi.fn(),
|
||||
executeTransferPrecheck: vi.fn(),
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
listTransferBacklog: vi.fn(),
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import TransferHomePanel from './TransferHomePanel.vue';
|
||||
|
||||
function mountHome() {
|
||||
return mount(TransferHomePanel, {
|
||||
props: { agentName: '在途仓自动调拨' },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('TransferHomePanel chat home entry', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 6, closed: 2, unknown: 1, aging: { warn_3d: 3, escalate_5d: 2, critical_7d: 1 },
|
||||
});
|
||||
api.listTransferBacklog.mockResolvedValue([]);
|
||||
api.listTransferSources.mockResolvedValue([
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
]);
|
||||
});
|
||||
|
||||
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');
|
||||
expect(api.getTransferBacklogSummary).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('点击“发起今日调拨预检”独立触发来源选择卡(复用 TransferMessageView)', async () => {
|
||||
api.createTransferPrecheck.mockResolvedValue({
|
||||
precheck_id: 'TPC-1', status: 'ready_to_execute', business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05', expires_at: '',
|
||||
counts: { file_invoice_count: 1, not_matured_count: 0, prechecked_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200', estimated_erp_write_count: 1, precheck_hash: 'sha256:x',
|
||||
});
|
||||
api.getTransferPrecheck.mockResolvedValue({
|
||||
summary: {
|
||||
precheck_id: 'TPC-1', status: 'ready_to_execute', business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05', expires_at: '',
|
||||
counts: { file_invoice_count: 1, not_matured_count: 0, prechecked_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200', estimated_erp_write_count: 1, precheck_hash: 'sha256:x',
|
||||
},
|
||||
items: [{
|
||||
source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器组件', specification: 'A',
|
||||
invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200',
|
||||
to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable',
|
||||
}],
|
||||
sources: [{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1' }],
|
||||
});
|
||||
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-today"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-source-select-card"]').exists()).toBe(true);
|
||||
expect(api.listTransferSources).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('点击历史待办计数卡独立触发 backlog 卡片', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
|
||||
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal' },
|
||||
]);
|
||||
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-recoverable"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
expect(api.listTransferBacklog).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('子视图提供“返回首页”并切回 home', async () => {
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-today"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-source-select-card"]').exists()).toBe(true);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-home-back"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-home"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('进入子流程时冒泡 flow-active=true,返回首页时 false(父级据此隐藏聊天输入框)', async () => {
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
expect(wrapper.emitted('flow-active')?.[0]?.[0]).toBe(false);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-home-today"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.emitted('flow-active')?.at(-1)?.[0]).toBe(true);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-home-back"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.emitted('flow-active')?.at(-1)?.[0]).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,134 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferHomePanel.vue
|
||||
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——home 视图展示标题、今日待办
|
||||
入口与三张历史待办计数卡;点击入口独立触发 source-select / backlog 卡片。
|
||||
依赖:TransferMessageView(复用自驱动卡片)、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:home 时只消费 backlogSummary 计数;非 home 时渲染 TransferMessageView。
|
||||
卡片不注入消息流,因此无需后端 ChatLog 消息(决策:补首页入口 A 方案)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
|
||||
const props = defineProps<{
|
||||
agentName?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 业务流激活状态:true 表示进入来源选择/待处理等子视图(父级据此隐藏聊天输入框)。 */
|
||||
'flow-active': [active: boolean];
|
||||
}>();
|
||||
|
||||
type HomeView = 'home' | 'source-select' | 'backlog';
|
||||
|
||||
const transfer = useChatTransfer();
|
||||
const view = ref<HomeView>('home');
|
||||
|
||||
/** 进入非 home 时通知父级隐藏聊天输入框(决策:来源选择为业务页,无对话输入区)。 */
|
||||
watch(view, (value) => emit('flow-active', value !== 'home'), { immediate: true });
|
||||
|
||||
/** home 视图仅需要待办汇总;进入时拉取计数。 */
|
||||
async function loadHomeSummary() {
|
||||
if (view.value !== 'home') return;
|
||||
await transfer.loadBacklog();
|
||||
}
|
||||
|
||||
onMounted(() => { void loadHomeSummary(); });
|
||||
watch(view, () => { void loadHomeSummary(); });
|
||||
|
||||
const displayAgentName = computed(() => props.agentName || '在途仓自动调拨');
|
||||
|
||||
/** 非 home 视图把当前入口透传给自驱动的 TransferMessageView(决定 source-select 或 backlog)。 */
|
||||
const childPayload = computed(() => (
|
||||
view.value === 'source-select'
|
||||
? { kind: 'source-select' }
|
||||
: { kind: 'backlog' }
|
||||
));
|
||||
|
||||
function goBack() {
|
||||
view.value = 'home';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="flex w-full flex-col items-center px-4 pb-2 pt-6 md:pb-4">
|
||||
<!-- home:标题 + 今日/历史待办入口 -->
|
||||
<template v-if="view === 'home'">
|
||||
<h2 data-testid="transfer-home" class="mb-8 mt-6 shrink-0 text-center text-2xl font-bold text-primary md:mt-10 md:text-3xl">
|
||||
{{ $t('chat.transfer.homeWelcome') }}
|
||||
<span class="mx-1 text-brand-600">{{ displayAgentName }}</span>
|
||||
</h2>
|
||||
|
||||
<div class="w-full max-w-3xl space-y-4">
|
||||
<!-- 今日待办 -->
|
||||
<section aria-label="今日待办">
|
||||
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeTodayLabel') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="transfer-home-today"
|
||||
class="flex w-full items-center gap-3 rounded-2xl border border-brand-200 bg-brand-50 p-4 text-left transition-colors hover:bg-brand-100"
|
||||
@click="view = 'source-select'"
|
||||
>
|
||||
<span class="grid h-10 w-10 shrink-0 place-items-center rounded-xl bg-brand-600 text-lg font-bold text-white">+</span>
|
||||
<span class="min-w-0 flex-1">
|
||||
<b class="block text-sm font-bold text-brand-700">{{ $t('chat.transfer.homeTodayAction') }}</b>
|
||||
<span class="mt-1 block text-xs text-brand-600/80">{{ $t('chat.transfer.homeTodayHint') }}</span>
|
||||
</span>
|
||||
<span class="shrink-0 text-xl text-brand-600">›</span>
|
||||
</button>
|
||||
</section>
|
||||
|
||||
<!-- 历史待办 -->
|
||||
<section aria-label="历史待办">
|
||||
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeHistoryLabel') }}</p>
|
||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
||||
<button
|
||||
type="button"
|
||||
data-testid="transfer-home-recoverable"
|
||||
class="rounded-2xl border border-brand-200 bg-brand-50 p-4 text-left transition-colors hover:bg-brand-100"
|
||||
@click="view = 'backlog'"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-brand-600">{{ transfer.backlogSummary.value?.recoverable ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeRecoverable') }}</b>
|
||||
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeRecoverableHint') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
data-testid="transfer-home-closed"
|
||||
class="rounded-2xl border border-slate-200 bg-surface p-4 text-left transition-colors hover:border-brand-200 hover:bg-brand-50"
|
||||
@click="view = 'backlog'"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-slate-600">{{ transfer.backlogSummary.value?.closed ?? 0 }}</b>
|
||||
<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="view = 'backlog'"
|
||||
>
|
||||
<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>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 子流程:复用自驱动的 TransferMessageView -->
|
||||
<div v-else class="w-full max-w-4xl pr-2">
|
||||
<button
|
||||
type="button"
|
||||
data-testid="transfer-home-back"
|
||||
class="mb-2 rounded-lg px-2 py-1 text-sm font-bold text-brand-600 transition-colors hover:bg-brand-50"
|
||||
@click="goBack"
|
||||
>
|
||||
← {{ $t('chat.transfer.homeBack') }}
|
||||
</button>
|
||||
<TransferMessageView :payload="childPayload" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,67 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferManualCloseDialog.vue
|
||||
用途:人工关闭弹窗(原因必填;关闭后永久排除,历史保留)。
|
||||
依赖:props(open/invoiceNo)、i18n chat.transfer.*。
|
||||
逻辑:原因为空时确认按钮禁用;确认时 emit confirm(reason)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
invoiceNo: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
confirm: [reason: string];
|
||||
cancel: [];
|
||||
}>();
|
||||
|
||||
const reason = ref('');
|
||||
|
||||
watch(
|
||||
() => props.open,
|
||||
(open) => {
|
||||
if (open) reason.value = '';
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
data-testid="transfer-manual-close-dialog"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-white p-5 shadow-xl">
|
||||
<h3 class="text-base font-bold text-slate-800">{{ $t('chat.transfer.manualCloseTitle') }}</h3>
|
||||
<p class="mt-1 text-xs text-slate-500">{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</p>
|
||||
<textarea
|
||||
v-model="reason"
|
||||
rows="3"
|
||||
class="mt-3 w-full rounded-lg border border-slate-200 p-2 text-sm"
|
||||
:placeholder="$t('chat.transfer.closeReasonPlaceholder')"
|
||||
data-testid="transfer-close-reason"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-slate-200 px-4 py-1.5 text-sm text-slate-600 hover:bg-slate-50"
|
||||
data-testid="transfer-close-cancel"
|
||||
@click="emit('cancel')"
|
||||
>
|
||||
{{ $t('chat.transfer.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="!reason.trim()"
|
||||
data-testid="transfer-close-confirm"
|
||||
@click="emit('confirm', reason.trim())"
|
||||
>
|
||||
{{ $t('chat.transfer.confirmClose') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,173 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferMessageView.spec.ts
|
||||
* 用途:验证卡片自驱动接线——预检卡渲染、点“直接生成调拨单”真实调 API 并切换结果卡、
|
||||
* 下载按钮调 requestBlob 封装、结果页无审计入口。
|
||||
* 依赖:vi.mock(transfer.api)、@vue/test-utils、i18n。
|
||||
* 逻辑:Mock API 断言调用参数与状态切换(对应后端 197 项测试的契约面)。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferPrecheck: vi.fn(),
|
||||
getTransferPrecheck: vi.fn(),
|
||||
executeTransferPrecheck: vi.fn(),
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
listTransferBacklog: vi.fn(),
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
|
||||
const payload = {
|
||||
kind: 'precheck',
|
||||
summary: {
|
||||
precheck_id: 'TPC-1',
|
||||
status: 'ready_to_execute',
|
||||
business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05',
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 1, not_matured_count: 0, prechecked_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200',
|
||||
estimated_erp_write_count: 1,
|
||||
precheck_hash: 'sha256:x',
|
||||
},
|
||||
items: [{
|
||||
source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器组件', specification: 'A',
|
||||
invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200',
|
||||
to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable',
|
||||
}],
|
||||
sources: [{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1' }],
|
||||
};
|
||||
|
||||
const runPayload = {
|
||||
kind: 'result',
|
||||
run_no: 'RUN-1',
|
||||
status: 'success',
|
||||
run: {
|
||||
run_no: 'RUN-1',
|
||||
status: 'success',
|
||||
result: {
|
||||
erp_documents: [{
|
||||
document_no: 'TRF-10001', from_warehouse: 'DBS-TRANSIT', to_warehouse: 'HUB-CN01',
|
||||
material_count: 1, total_quantity: '1200', posting_status: 'posted',
|
||||
lines: [{ material_no: 'MAT-1', material_name: '连接器组件', specification: 'A', invoice_no: 'INV-001', quantity: '1200' }],
|
||||
}],
|
||||
exceptions: [],
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe('TransferMessageView self-driving wiring', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.executeTransferPrecheck.mockResolvedValue({ run_no: 'RUN-1', status: 'success' });
|
||||
api.getTransferRun.mockResolvedValue(runPayload.run);
|
||||
api.downloadTransferReceiptFiles.mockResolvedValue({ blob: new Blob(['z']), filename: 'r.zip' });
|
||||
api.downloadTransferErpInventory.mockResolvedValue({ blob: new Blob(['c']), filename: 'e.csv' });
|
||||
});
|
||||
|
||||
it('预检 payload 渲染预检卡,且默认勾选可执行项', () => {
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-check-INV-001"]').element as HTMLInputElement).checked).toBe(true);
|
||||
});
|
||||
|
||||
it('点击“直接生成调拨单”调用 execute API 并切换为结果卡', async () => {
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.executeTransferPrecheck).toHaveBeenCalledWith('TPC-1', ['INV-001']);
|
||||
expect(wrapper.find('[data-testid="transfer-result-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('结果卡下载按钮调用下载 API(收料来源文件 + ERP 库存表)', async () => {
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: runPayload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-download-receipt"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.downloadTransferReceiptFiles).toHaveBeenCalledWith('RUN-1');
|
||||
expect(api.downloadTransferErpInventory).toHaveBeenCalledWith('RUN-1');
|
||||
});
|
||||
|
||||
it('结果卡不出现执行审计入口(决策 19)', () => {
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: runPayload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).not.toContain('审计');
|
||||
});
|
||||
|
||||
it('backlog 视图拉取待处理列表,重试/关闭调用对应 API', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([{
|
||||
item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
|
||||
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal',
|
||||
}]);
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 1, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
api.retryTransferItem.mockResolvedValue({ item_id: 7, status: 'ready_to_execute', attempt_no: 2 });
|
||||
api.manualCloseTransferItem.mockResolvedValue({ item_id: 7, status: 'manually_closed' });
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'backlog' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('INV-001');
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-retry"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.retryTransferItem).toHaveBeenCalledWith(7);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-close"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('线下已处理');
|
||||
await wrapper.find('[data-testid="transfer-close-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.manualCloseTransferItem).toHaveBeenCalledWith(7, '线下已处理');
|
||||
});
|
||||
|
||||
it('来源实例选择:加载列表 → 确认范围 → 创建预检并切换预检卡', async () => {
|
||||
api.listTransferSources.mockResolvedValue([
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
]);
|
||||
api.createTransferPrecheck.mockResolvedValue(payload.summary);
|
||||
api.getTransferPrecheck.mockResolvedValue({
|
||||
summary: payload.summary,
|
||||
items: payload.items,
|
||||
sources: payload.sources,
|
||||
});
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'source-select' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-source-select-card"]').exists()).toBe(true);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.createTransferPrecheck).toHaveBeenCalledWith({ source_codes: ['DBS-AWSBI'] });
|
||||
expect(wrapper.find('[data-testid="transfer-precheck-card"]').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,243 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferMessageView.vue
|
||||
用途:在途调拨消息卡片的自驱动挂载视图——按 payload 形态渲染卡片,并把卡片按钮
|
||||
(直接生成调拨单 / 下载 / 重试 / 关闭)经 useChatTransfer 真实调用 API。
|
||||
依赖:Transfer*Card、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:payload 作为初始状态(ChatLog 回放);执行后切换为结果卡;下载走 requestBlob;
|
||||
不展示执行审计入口(决策 19)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import TransferPrecheckCard from './TransferPrecheckCard.vue';
|
||||
import TransferFileProgressCard from './TransferFileProgressCard.vue';
|
||||
import TransferProgressCard from './TransferProgressCard.vue';
|
||||
import TransferResultCard from './TransferResultCard.vue';
|
||||
import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
|
||||
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
|
||||
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type {
|
||||
TransferBacklogItem,
|
||||
TransferPrecheckItem,
|
||||
TransferPrecheckSummary,
|
||||
TransferRunResult,
|
||||
TransferSourceProgress,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
payload?: Record<string, unknown> | null;
|
||||
}>();
|
||||
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
/** 统一错误提示:BusinessError 带本地化 message,其余回退到 String(e)。 */
|
||||
function reportError(e: unknown) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
|
||||
const kind = computed(() => String(props.payload?.kind ?? 'precheck'));
|
||||
const mode = ref(kind.value);
|
||||
const summaryRef = ref<TransferPrecheckSummary | null>((props.payload?.summary as TransferPrecheckSummary) ?? null);
|
||||
const items = ref<TransferPrecheckItem[]>((props.payload?.items as TransferPrecheckItem[]) ?? []);
|
||||
const runNo = ref(String(props.payload?.run_no ?? ''));
|
||||
const status = ref(String(props.payload?.status ?? 'executing'));
|
||||
const run = ref<TransferRunResult | null>((props.payload?.run as TransferRunResult) ?? null);
|
||||
const busy = ref(false);
|
||||
const closeTarget = ref<TransferBacklogItem | null>(null);
|
||||
/** 正在重试收料 RPA 的来源编码集合(按来源独立展示重试中)。 */
|
||||
const retryingSource = ref<Set<string>>(new Set());
|
||||
|
||||
const transfer = useChatTransfer();
|
||||
|
||||
/** 待处理异常视图:进入时拉取列表与汇总 */
|
||||
onMounted(() => {
|
||||
if (kind.value === 'backlog') {
|
||||
void transfer.loadBacklog();
|
||||
}
|
||||
if (kind.value === 'source-select') {
|
||||
void transfer.loadSources();
|
||||
}
|
||||
});
|
||||
|
||||
/** payload 更新时重置本地状态(历史回放/刷新);初始化组合式函数上下文 */
|
||||
function applyPayload(payload?: Record<string, unknown> | null) {
|
||||
if (!payload) return;
|
||||
mode.value = String(payload.kind ?? 'precheck');
|
||||
summaryRef.value = (payload.summary as TransferPrecheckSummary) ?? null;
|
||||
items.value = (payload.items as TransferPrecheckItem[]) ?? [];
|
||||
runNo.value = String(payload.run_no ?? '');
|
||||
status.value = String(payload.status ?? 'executing');
|
||||
run.value = (payload.run as TransferRunResult) ?? null;
|
||||
const summaryValue = (payload.summary as TransferPrecheckSummary) ?? null;
|
||||
if (summaryValue) {
|
||||
transfer.precheckId.value = summaryValue.precheck_id;
|
||||
transfer.selected.value = new Set(
|
||||
(payload.items as TransferPrecheckItem[] ?? [])
|
||||
.filter((item) => item.result === 'executable')
|
||||
.map((item) => item.invoice_no),
|
||||
);
|
||||
}
|
||||
if (runNo.value) {
|
||||
transfer.runNo.value = runNo.value;
|
||||
}
|
||||
}
|
||||
|
||||
applyPayload(props.payload);
|
||||
watch(() => props.payload, applyPayload);
|
||||
|
||||
/** 直接生成调拨单(决策 4/5:无独立确认页) */
|
||||
async function onExecute(invoiceNos: string[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
transfer.selected.value = new Set(invoiceNos);
|
||||
const outcome = await transfer.execute();
|
||||
if (outcome) {
|
||||
mode.value = 'result';
|
||||
runNo.value = outcome.run_no;
|
||||
status.value = outcome.status;
|
||||
run.value = transfer.run.value;
|
||||
}
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function onDownloadReceipt() {
|
||||
try {
|
||||
await transfer.downloadReceiptFiles();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDownloadErp() {
|
||||
try {
|
||||
await transfer.downloadErpInventory();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDownloadExceptions() {
|
||||
try {
|
||||
await transfer.downloadExceptions();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function onBacklogRetry(itemId: number) {
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.retry(itemId);
|
||||
await transfer.loadBacklog();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onBacklogClose(item: TransferBacklogItem) {
|
||||
closeTarget.value = item;
|
||||
}
|
||||
|
||||
async function onCloseConfirm(reason: string) {
|
||||
if (!closeTarget.value) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.manualClose(closeTarget.value.item_id, reason);
|
||||
closeTarget.value = null;
|
||||
await transfer.loadBacklog();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 来源实例选择确认 → 创建预检并切换预检卡(决策 4:两步第一步) */
|
||||
async function onSourceConfirm(sourceCodes: string[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.createPrecheck(sourceCodes);
|
||||
mode.value = 'precheck';
|
||||
summaryRef.value = transfer.precheck.value;
|
||||
items.value = transfer.items.value;
|
||||
run.value = null;
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 对来源(单个或批量)重新触发收料 RPA 抓取,重试期间标记该来源(busy 独立于 confirm busy)。 */
|
||||
async function onSourceRetry(sourceCodes: string[]) {
|
||||
const codes = Array.isArray(sourceCodes) ? sourceCodes : [sourceCodes];
|
||||
retryingSource.value = new Set([...retryingSource.value, ...codes]);
|
||||
try {
|
||||
// 逐来源触发,避免一次并发 EPR/RPA 竞态;失败中断剩余。
|
||||
for (const code of codes) {
|
||||
await transfer.retrySourceRpa(code);
|
||||
}
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
const next = new Set(retryingSource.value);
|
||||
for (const code of codes) next.delete(code);
|
||||
retryingSource.value = next;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<TransferFileProgressCard
|
||||
v-if="mode === 'file-progress'"
|
||||
:sources="(props.payload?.sources as TransferSourceProgress[]) ?? []"
|
||||
/>
|
||||
<TransferSourceSelectCard
|
||||
v-else-if="mode === 'source-select'"
|
||||
:sources="transfer.sourceOptions.value"
|
||||
:busy="busy"
|
||||
:retrying="retryingSource"
|
||||
@confirm="onSourceConfirm"
|
||||
@retry="onSourceRetry"
|
||||
/>
|
||||
<TransferPrecheckCard
|
||||
v-else-if="mode === 'precheck' && summaryRef"
|
||||
:summary="summaryRef"
|
||||
:items="items"
|
||||
:selected="transfer.selected.value"
|
||||
:busy="busy"
|
||||
@toggle="(invoiceNo, checked) => transfer.toggleSelect(invoiceNo, checked)"
|
||||
@execute="onExecute"
|
||||
/>
|
||||
<TransferProgressCard v-else-if="mode === 'progress'" :run-no="runNo" :status="status" :busy="busy" />
|
||||
<TransferResultCard
|
||||
v-else-if="mode === 'result' && run"
|
||||
:run="run"
|
||||
@download-receipt="onDownloadReceipt"
|
||||
@download-erp="onDownloadErp"
|
||||
@download-exceptions="onDownloadExceptions"
|
||||
/>
|
||||
<TransferBacklogSummaryCard
|
||||
v-else-if="mode === 'backlog'"
|
||||
:items="transfer.backlog.value"
|
||||
@retry="onBacklogRetry"
|
||||
@close="onBacklogClose"
|
||||
@refresh="() => transfer.loadBacklog()"
|
||||
/>
|
||||
<TransferManualCloseDialog
|
||||
v-if="closeTarget"
|
||||
:open="Boolean(closeTarget)"
|
||||
:invoice-no="closeTarget.invoice_no"
|
||||
@confirm="onCloseConfirm"
|
||||
@cancel="closeTarget = null"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,157 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferPrecheckCard.vue
|
||||
用途:预检卡——计数 + 调拨明细表(决策 6 十列)+ 勾选 + “直接生成调拨单”按钮。
|
||||
依赖:props(summary/items/selected/busy)、i18n chat.transfer.*。
|
||||
逻辑:阻断/未成熟项 checkbox 禁用;无选择或 busy 时生成按钮禁用;
|
||||
emit execute(invoiceNos)(决策 4/5:无独立确认页)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import type { TransferPrecheckItem, TransferPrecheckSummary } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
summary: TransferPrecheckSummary;
|
||||
items: TransferPrecheckItem[];
|
||||
selected: Set<string>;
|
||||
busy?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
toggle: [invoiceNo: string, checked: boolean];
|
||||
execute: [invoiceNos: string[]];
|
||||
}>();
|
||||
|
||||
const selectedCount = computed(() =>
|
||||
props.items.filter((item) => item.result === 'executable' && props.selected.has(item.invoice_no)).length,
|
||||
);
|
||||
const executeDisabled = computed(() => props.busy || selectedCount.value === 0);
|
||||
|
||||
function isSelectable(item: TransferPrecheckItem): boolean {
|
||||
return item.result === 'executable';
|
||||
}
|
||||
|
||||
function isChecked(item: TransferPrecheckItem): boolean {
|
||||
return props.selected.has(item.invoice_no);
|
||||
}
|
||||
|
||||
function resultLabel(result: string): string {
|
||||
const map: Record<string, string> = {
|
||||
executable: 'chat.transfer.resultExecutable',
|
||||
not_matured: 'chat.transfer.resultNotMatured',
|
||||
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
|
||||
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
|
||||
blocked_future_date: 'chat.transfer.resultBlocked',
|
||||
erp_query_timeout: 'chat.transfer.resultUnknown',
|
||||
result_unknown: 'chat.transfer.resultUnknown',
|
||||
};
|
||||
return map[result] ?? 'chat.transfer.resultBlocked';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm" data-testid="transfer-precheck-card">
|
||||
<div class="mb-3 flex flex-wrap items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-bold text-slate-800">{{ $t('chat.transfer.precheckTitle') }}</h3>
|
||||
<span class="text-xs text-slate-400">{{ $t('chat.transfer.businessDate') }}:{{ summary.business_date }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-5" data-testid="transfer-precheck-counts">
|
||||
<div class="rounded-lg bg-slate-50 p-2 text-center">
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.counts.executable_count }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ $t('chat.transfer.executableCount') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-slate-50 p-2 text-center">
|
||||
<div class="text-lg font-black text-slate-600">{{ summary.counts.not_matured_count }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ $t('chat.transfer.notMaturedCount') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-slate-50 p-2 text-center">
|
||||
<div class="text-lg font-black text-slate-600">{{ summary.counts.blocked_count }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ $t('chat.transfer.blockedCount') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-slate-50 p-2 text-center">
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.estimated_transfer_quantity }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ $t('chat.transfer.estimatedQuantity') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-slate-50 p-2 text-center">
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.estimated_erp_write_count }}</div>
|
||||
<div class="text-[11px] text-slate-500">{{ $t('chat.transfer.estimatedErpWrites') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1100px] text-xs" data-testid="transfer-precheck-table">
|
||||
<thead>
|
||||
<tr class="border-b border-slate-200 bg-slate-50 text-left text-[11px] text-slate-500">
|
||||
<th class="p-2"></th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colSource') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colSpec') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="p-2">{{ $t('chat.transfer.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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in items"
|
||||
:key="item.invoice_no"
|
||||
class="border-b border-slate-100"
|
||||
:class="{ 'bg-slate-50 text-slate-400': !isSelectable(item) }"
|
||||
:data-testid="`transfer-item-${item.invoice_no}`"
|
||||
>
|
||||
<td class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isChecked(item)"
|
||||
:disabled="!isSelectable(item) || busy"
|
||||
:data-testid="`transfer-check-${item.invoice_no}`"
|
||||
@change="emit('toggle', item.invoice_no, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<td class="p-2">{{ item.source_code }}</td>
|
||||
<td class="p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name }}</td>
|
||||
<td class="p-2">{{ item.specification }}</td>
|
||||
<td class="p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="p-2">{{ item.from_warehouse }}</td>
|
||||
<td class="p-2">{{ item.from_quantity ?? '—' }}</td>
|
||||
<td class="p-2">{{ item.to_warehouse }}</td>
|
||||
<td class="p-2">{{ item.to_quantity }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': item.result === 'executable',
|
||||
'bg-amber-50 text-amber-700': item.result === 'not_matured',
|
||||
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'not_matured',
|
||||
}"
|
||||
>
|
||||
{{ $t(resultLabel(item.result)) }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="mt-3 flex items-center justify-end gap-3 border-t border-slate-100 pt-3">
|
||||
<span class="text-xs text-slate-500">
|
||||
{{ $t('chat.transfer.selectedCount', { count: selectedCount }) }} ·
|
||||
{{ $t('chat.transfer.estimatedErpWrites') }}:{{ summary.estimated_erp_write_count }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="executeDisabled"
|
||||
:data-testid="'transfer-generate-button'"
|
||||
@click="emit('execute', items.filter(isSelectable).filter(isChecked).map((item) => item.invoice_no))"
|
||||
>
|
||||
{{ $t('chat.transfer.generateTransfer') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,60 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferProgressCard.vue
|
||||
用途:Run 执行进度卡(页面关闭/刷新后经 run_no 恢复)。
|
||||
依赖:props(runNo/status/busy)、i18n chat.transfer.*。
|
||||
逻辑:展示 Run 编号与状态,提供刷新按钮;页面刷新不取消后台 Run。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
defineProps<{
|
||||
runNo: string;
|
||||
status: string;
|
||||
busy?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
function statusLabel(status: string): string {
|
||||
const map: Record<string, string> = {
|
||||
executing: 'chat.transfer.runExecuting',
|
||||
success: 'chat.transfer.runSuccess',
|
||||
partial_failed: 'chat.transfer.runPartialFailed',
|
||||
failed: 'chat.transfer.runFailed',
|
||||
cancelled: 'chat.transfer.runCancelled',
|
||||
};
|
||||
return map[status] ?? 'chat.transfer.runExecuting';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm" data-testid="transfer-progress-card">
|
||||
<div class="flex items-center justify-between">
|
||||
<div>
|
||||
<div class="text-sm font-bold text-slate-800">{{ $t('chat.transfer.runProgress') }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ runNo }}</div>
|
||||
</div>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-xs font-bold"
|
||||
:class="{
|
||||
'bg-blue-50 text-blue-700': status === 'executing',
|
||||
'bg-emerald-50 text-emerald-700': status === 'success',
|
||||
'bg-amber-50 text-amber-700': status === 'partial_failed',
|
||||
'bg-red-50 text-red-700': status === 'failed' || status === 'cancelled',
|
||||
}"
|
||||
data-testid="transfer-run-status"
|
||||
>
|
||||
{{ $t(statusLabel(status)) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-slate-200 px-3 py-1 text-xs font-bold text-slate-600 hover:bg-slate-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-run-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,131 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferResultCard.vue
|
||||
用途:结果卡——按 ERP 单号聚合(决策 20)、可展开物料明细、未生成单据异常区、
|
||||
下载收料来源文件 / ERP 库存表(决策 21)。不展示执行审计入口(决策 19)。
|
||||
依赖:props.run、i18n chat.transfer.*。
|
||||
逻辑:<details> 展开/收起物料行;异常单独分区;两个下载按钮 + 异常 Excel。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import type { TransferRunResult } from '../../types/transfer.types';
|
||||
|
||||
defineProps<{
|
||||
run: TransferRunResult;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
downloadReceipt: [];
|
||||
downloadErp: [];
|
||||
downloadExceptions: [];
|
||||
}>();
|
||||
|
||||
function reasonLabel(reason: string): string {
|
||||
const map: Record<string, string> = {
|
||||
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
|
||||
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
|
||||
business_failed: 'chat.transfer.exceptionBusinessFailed',
|
||||
technical_failed: 'chat.transfer.exceptionTechnicalFailed',
|
||||
result_unknown: 'chat.transfer.resultUnknown',
|
||||
precheck_expired: 'chat.transfer.exceptionPrecheckExpired',
|
||||
};
|
||||
return map[reason] ?? 'chat.transfer.resultBlocked';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm" data-testid="transfer-result-card">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h3 class="text-sm font-bold text-slate-800">{{ $t('chat.transfer.resultTitle') }}</h3>
|
||||
<span class="text-xs text-slate-400">{{ run.run_no }}</span>
|
||||
</div>
|
||||
|
||||
<!-- 已生成 ERP 单据:按单号聚合 + 可展开物料明细 -->
|
||||
<div v-if="run.result.erp_documents.length" class="flex flex-col gap-2">
|
||||
<details
|
||||
v-for="doc in run.result.erp_documents"
|
||||
:key="doc.document_no"
|
||||
class="rounded-lg border border-slate-200"
|
||||
data-testid="transfer-erp-document"
|
||||
>
|
||||
<summary class="flex cursor-pointer flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
|
||||
<span class="font-bold text-brand-700">{{ doc.document_no }}</span>
|
||||
<span class="text-slate-600">{{ doc.from_warehouse }} → {{ doc.to_warehouse }}</span>
|
||||
<span class="text-slate-500">{{ $t('chat.transfer.materialCount', { count: doc.material_count }) }}</span>
|
||||
<span class="font-bold text-slate-700">{{ doc.total_quantity }}</span>
|
||||
<span class="rounded-full bg-emerald-50 px-2 py-0.5 font-bold text-emerald-700">
|
||||
{{ $t('chat.transfer.posted') }}
|
||||
</span>
|
||||
</summary>
|
||||
<div class="border-t border-slate-100 px-3 py-2">
|
||||
<table class="w-full text-xs" data-testid="transfer-erp-document-lines">
|
||||
<thead>
|
||||
<tr class="text-left text-[11px] text-slate-500">
|
||||
<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.colSpec') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="line in doc.lines" :key="line.invoice_no" class="border-t border-slate-100">
|
||||
<td class="p-1">{{ line.material_no }}</td>
|
||||
<td class="p-1">{{ line.material_name }}</td>
|
||||
<td class="p-1">{{ line.specification }}</td>
|
||||
<td class="p-1">{{ line.invoice_no }}</td>
|
||||
<td class="p-1">{{ line.quantity }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<div v-else class="mb-3 rounded-lg bg-slate-50 p-3 text-xs text-slate-500">
|
||||
{{ $t('chat.transfer.noDocuments') }}
|
||||
</div>
|
||||
|
||||
<!-- 未生成 ERP 单据的异常区(决策 20 单独展示) -->
|
||||
<div v-if="run.result.exceptions.length" class="mt-3" data-testid="transfer-exceptions-area">
|
||||
<h4 class="mb-1 text-xs font-bold text-slate-600">{{ $t('chat.transfer.exceptionsTitle') }}</h4>
|
||||
<ul class="flex flex-col gap-1">
|
||||
<li
|
||||
v-for="exc in run.result.exceptions"
|
||||
:key="exc.invoice_no"
|
||||
class="rounded-lg bg-red-50 px-3 py-1.5 text-xs text-red-700"
|
||||
data-testid="transfer-exception-item"
|
||||
>
|
||||
<span class="font-bold">{{ exc.invoice_no }}</span>
|
||||
<span class="mx-1 text-red-400">·</span>{{ exc.source_code }} · {{ $t(reasonLabel(exc.reason)) }}
|
||||
<div class="text-[11px] text-red-500">{{ exc.facts }}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- 下载:收料来源文件 + ERP 库存表(决策 21);无审计入口(决策 19) -->
|
||||
<div class="mt-3 flex flex-wrap gap-2 border-t border-slate-100 pt-3" data-testid="transfer-result-downloads">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50"
|
||||
data-testid="transfer-download-receipt"
|
||||
@click="emit('downloadReceipt')"
|
||||
>
|
||||
{{ $t('chat.transfer.downloadReceiptFiles') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50"
|
||||
data-testid="transfer-download-erp"
|
||||
@click="emit('downloadErp')"
|
||||
>
|
||||
{{ $t('chat.transfer.downloadErpInventory') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-bold text-slate-600 hover:bg-slate-50"
|
||||
data-testid="transfer-download-exceptions"
|
||||
@click="emit('downloadExceptions')"
|
||||
>
|
||||
{{ $t('chat.transfer.downloadExceptions') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,89 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferSourceSelectCard.spec.ts
|
||||
* 用途:来源实例选择卡——平台分组、全选已启用、清空、按收料文件状态门禁确认、
|
||||
* 确认提交、重试收料 RPA。
|
||||
* 依赖:@vue/test-utils、i18n。
|
||||
* 逻辑:平台 DBS/Crane 仅分组;实例为选择与执行边界(决策 2/3/4);
|
||||
* 所选来源需至少一个 has_ready_file 才能确认预检(决策:无 ready 文件禁止确认)。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
|
||||
|
||||
const readySources = [
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI 在途仓', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
{ source_code: 'DBS-AWSSG', display_name: 'AWSSG 在途仓', platform: 'dbs', enabled: true, file_status: 'none' },
|
||||
{ source_code: 'CRANE-SZ', display_name: '深圳在途仓', platform: 'crane', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
];
|
||||
|
||||
function mountCard(props = {}, sources = readySources) {
|
||||
return mount(TransferSourceSelectCard, {
|
||||
props: { sources, ...props },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('TransferSourceSelectCard', () => {
|
||||
it('按平台分组展示来源实例', () => {
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"]').text()).toContain('DBS-AWSBI');
|
||||
expect(wrapper.find('[data-testid="transfer-source-option-CRANE-SZ"]').text()).toContain('CRANE-SZ');
|
||||
});
|
||||
|
||||
it('未选任何来源时确认按钮禁用(需至少一个 ready 文件来源)', () => {
|
||||
const wrapper = mountCard();
|
||||
expect((wrapper.find('[data-testid="transfer-source-confirm"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('勾选含 ready 文件来源后确认提交所选来源', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-option-CRANE-SZ"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
expect(wrapper.emitted('confirm')?.[0][0]).toEqual(['DBS-AWSBI', 'CRANE-SZ']);
|
||||
});
|
||||
|
||||
it('仅勾选无 ready 文件来源时不提交(门禁)', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSSG"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('“全选可见”勾选全部启用实例', async () => {
|
||||
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']);
|
||||
});
|
||||
|
||||
it('“清空”清空已选实例', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-select-visible"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-source-clear"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('“只选可重试”勾选无文件/失败来源', async () => {
|
||||
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);
|
||||
});
|
||||
|
||||
it('点击行尾重试图标 emit retry([sourceCode])', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-retry-DBS-AWSSG"]').trigger('click');
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSSG']);
|
||||
});
|
||||
|
||||
it('批量重试仅传可重试来源', 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']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,246 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferSourceSelectCard.vue
|
||||
用途:来源实例选择卡(决策 2/3/4:手工两步第一步)——按平台 DBS/Crane 分组勾选实例,
|
||||
“确认范围并预检”发起预检。
|
||||
依赖:props.sources、i18n chat.transfer.*。
|
||||
逻辑:平台仅分组不可直接执行;未选任何实例时确认按钮禁用。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type { TransferSourceOption } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
sources: TransferSourceOption[];
|
||||
busy?: boolean;
|
||||
/** 正在重试收料 RPA 的来源编码集合 */
|
||||
retrying?: Set<string>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
confirm: [sourceCodes: string[]];
|
||||
/** 批量重试收料 RPA:传来源编码列表 */
|
||||
retry: [sourceCodes: string[]];
|
||||
}>();
|
||||
|
||||
const { warning: notifyWarning } = useMessage();
|
||||
const { t } = useI18n();
|
||||
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
|
||||
const platforms = computed(() => [...new Set(props.sources.map((source) => source.platform))]);
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
|
||||
/** 可重试判定:仅 待抓取(none) / 抓取失败(failed) 的来源可重试(ready/fetching 不重复触发)。 */
|
||||
function isRetryable(source: TransferSourceOption): boolean {
|
||||
return source.file_status === 'none' || source.file_status === 'failed';
|
||||
}
|
||||
|
||||
/** 全部可重试来源。 */
|
||||
const retryableSources = computed(() => props.sources.filter(isRetryable));
|
||||
/** 已选来源中可重试的数量。 */
|
||||
const selectedRetryableCount = computed(() =>
|
||||
[...selected.value].filter((code) => props.sources.some((s) => s.source_code === code && isRetryable(s))).length,
|
||||
);
|
||||
const batchRetryDisabled = computed(() => props.busy || selectedRetryableCount.value === 0);
|
||||
|
||||
/** 已选来源中是否有具备 ready 文件的(门禁:都无 ready 文件则禁止确认预检)。 */
|
||||
const selectedHasReadyFile = computed(() =>
|
||||
[...selected.value].some((code) => props.sources.find((s) => s.source_code === code)?.has_ready_file),
|
||||
);
|
||||
const confirmDisabled = computed(() => props.busy || selectedCount.value === 0 || !selectedHasReadyFile.value);
|
||||
|
||||
function toggle(sourceCode: string, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
if (checked) next.add(sourceCode);
|
||||
else next.delete(sourceCode);
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
function togglePlatform(platform: string, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
for (const source of props.sources) {
|
||||
if (source.platform === platform) {
|
||||
if (checked) next.add(source.source_code);
|
||||
else next.delete(source.source_code);
|
||||
}
|
||||
}
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
/** 全选当前可见来源(已启用实例)。 */
|
||||
function selectVisible() {
|
||||
selected.value = new Set(props.sources.filter((source) => source.enabled).map((source) => source.source_code));
|
||||
}
|
||||
|
||||
/** 只选可重试来源(待抓取/抓取失败),来源多时一键收敛。 */
|
||||
function selectRetryable() {
|
||||
selected.value = new Set(retryableSources.value.map((source) => source.source_code));
|
||||
}
|
||||
|
||||
/** 清空选择。 */
|
||||
function clearSelected() {
|
||||
selected.value = new Set();
|
||||
}
|
||||
|
||||
/** 批量重试收料 RPA:仅触发所选来源中可重试的那部分。 */
|
||||
function batchRetry() {
|
||||
const codes = [...selected.value].filter(
|
||||
(code) => props.sources.some((s) => s.source_code === code && isRetryable(s)),
|
||||
);
|
||||
if (codes.length === 0) {
|
||||
notifyWarning(t('chat.transfer.noRetryable'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
emit('retry', codes);
|
||||
}
|
||||
|
||||
function confirm() {
|
||||
if (selectedCount.value === 0) {
|
||||
notifyWarning(t('chat.transfer.needSelectSource'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
if (!selectedHasReadyFile.value) {
|
||||
notifyWarning(t('chat.transfer.needReadyFile'), t('chat.transfer.sourceSelectTitle'));
|
||||
return;
|
||||
}
|
||||
emit('confirm', [...selected.value]);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-white p-4 shadow-sm" data-testid="transfer-source-select-card">
|
||||
<h3 class="mb-1 text-sm font-bold text-slate-800">{{ $t('chat.transfer.sourceSelectTitle') }}</h3>
|
||||
<p class="mb-3 text-xs text-slate-500">{{ $t('chat.transfer.sourceSelectHint') }}</p>
|
||||
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-select-visible"
|
||||
@click="selectVisible"
|
||||
>
|
||||
{{ $t('chat.transfer.selectVisible') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 px-3 py-1.5 text-xs font-bold text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-select-retryable"
|
||||
@click="selectRetryable"
|
||||
>
|
||||
{{ $t('chat.transfer.selectRetryable') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-3 py-1.5 text-xs font-bold text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="batchRetryDisabled"
|
||||
data-testid="transfer-source-batch-retry"
|
||||
@click="batchRetry"
|
||||
>
|
||||
{{ $t('chat.transfer.batchRetry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-slate-200 px-3 py-1.5 text-xs font-bold text-slate-600 hover:bg-slate-50 disabled:opacity-50"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-source-clear"
|
||||
@click="clearSelected"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSources') }}
|
||||
</button>
|
||||
<span class="ml-auto text-xs text-slate-500">
|
||||
{{ $t('chat.transfer.selectedSourceCount', { count: selectedCount }) }}
|
||||
<span v-if="selectedRetryableCount > 0" class="text-amber-600"> · {{ $t('chat.transfer.selectedRetryableCount', { count: selectedRetryableCount }) }}</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div v-for="platform in platforms" :key="platform" class="mb-3 rounded-lg border border-slate-100">
|
||||
<div class="flex items-center justify-between rounded-t-lg bg-slate-50 px-3 py-1.5">
|
||||
<b class="text-xs text-slate-700">{{ platform.toUpperCase() }}</b>
|
||||
<label class="text-[11px] text-slate-500">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="props.sources.filter((source) => source.platform === platform).every((source) => selected.has(source.source_code))"
|
||||
@change="togglePlatform(platform, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
{{ $t('chat.transfer.selectAll') }}
|
||||
</label>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-1 p-2 sm:grid-cols-2">
|
||||
<div
|
||||
v-for="source in props.sources.filter((item) => item.platform === platform)"
|
||||
:key="source.source_code"
|
||||
class="flex items-center gap-2 rounded-lg px-2 py-1.5 hover:bg-slate-50"
|
||||
:data-testid="`transfer-source-option-${source.source_code}`"
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selected.has(source.source_code)"
|
||||
:disabled="busy"
|
||||
@change="toggle(source.source_code, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
<span class="min-w-0 flex-1">
|
||||
<span class="block truncate text-xs font-semibold text-slate-700">{{ source.source_code }}</span>
|
||||
<span class="block truncate text-[11px] text-slate-400">{{ source.display_name }}</span>
|
||||
</span>
|
||||
<span class="shrink-0">
|
||||
<span
|
||||
v-if="source.has_ready_file"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-emerald-50 px-2 py-0.5 text-[10px] font-bold text-emerald-700"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileReady') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="source.file_status === 'fetching'"
|
||||
class="inline-flex items-center gap-1 rounded-full bg-amber-50 px-2 py-0.5 text-[10px] font-bold text-amber-700"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileFetching') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="source.file_status === '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.fileFailed') }}
|
||||
</span>
|
||||
<span
|
||||
v-else
|
||||
class="inline-flex items-center gap-1 rounded-full bg-slate-100 px-2 py-0.5 text-[10px] font-bold text-slate-500"
|
||||
:data-testid="`transfer-source-status-${source.source_code}`"
|
||||
>
|
||||
{{ t('chat.transfer.fileNone') }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-1 inline-flex h-6 w-6 items-center justify-center rounded-md border border-slate-200 text-sm text-slate-500 hover:border-brand-200 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="busy || !isRetryable(source) || retrying?.has(source.source_code)"
|
||||
:title="t('chat.transfer.retryReceipt')"
|
||||
:data-testid="`transfer-source-retry-${source.source_code}`"
|
||||
@click.stop="emit('retry', [source.source_code])"
|
||||
>
|
||||
<span aria-hidden="true">{{ retrying?.has(source.source_code) ? '…' : '↻' }}</span>
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center justify-end gap-3 border-t border-slate-100 pt-3">
|
||||
<span class="text-xs text-slate-500">{{ $t('chat.transfer.selectedCount', { count: selectedCount }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-brand-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-brand-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="confirmDisabled"
|
||||
data-testid="transfer-source-confirm"
|
||||
@click="confirm"
|
||||
>
|
||||
{{ $t('chat.transfer.confirmScopeAndPrecheck') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferCards.spec.ts
|
||||
* 用途:验证在途调拨三张核心卡片(文件进度/预检/结果)+ 关闭弹窗的交互与禁用语义。
|
||||
* 依赖:@vue/test-utils、i18n、transfer.types。
|
||||
* 逻辑:断言按钮禁用、勾选禁用、ERP 单号展开/收起、异常展示、下载按钮与
|
||||
* 结果页不出现“查看执行审计”入口(决策 19)。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import TransferFileProgressCard from './TransferFileProgressCard.vue';
|
||||
import TransferPrecheckCard from './TransferPrecheckCard.vue';
|
||||
import TransferResultCard from './TransferResultCard.vue';
|
||||
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
|
||||
|
||||
const mountOptions = { global: { plugins: [i18n] } };
|
||||
|
||||
const summary = {
|
||||
precheck_id: 'TPC-1',
|
||||
status: 'ready_to_execute',
|
||||
business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05',
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 3, not_matured_count: 1, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_erp_write_count: 2,
|
||||
precheck_hash: 'sha256:x',
|
||||
};
|
||||
|
||||
const items = [
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器', specification: 'A', invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: '控制器', specification: 'B', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'not_matured' },
|
||||
];
|
||||
|
||||
describe('TransferFileProgressCard', () => {
|
||||
it('按来源显示阶段,不伪造总百分比', () => {
|
||||
const wrapper = mount(TransferFileProgressCard, {
|
||||
props: { sources: [
|
||||
{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1', file_version: 'v3' },
|
||||
{ source_code: 'CRANE-SZ', stage: 'waiting_rpa_callback' },
|
||||
] },
|
||||
...mountOptions,
|
||||
});
|
||||
expect(wrapper.find('[data-testid="transfer-source-DBS-AWSBI"]').text()).toContain('REC-1');
|
||||
expect(wrapper.find('[data-testid="transfer-source-CRANE-SZ"]').text()).toContain('RPA');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferPrecheckCard', () => {
|
||||
it('阻断/未成熟项 checkbox 禁用;可执行项可选', () => {
|
||||
const wrapper = mount(TransferPrecheckCard, {
|
||||
props: { summary, items, selected: new Set(['INV-001']) },
|
||||
...mountOptions,
|
||||
});
|
||||
const executableCheck = wrapper.find('[data-testid="transfer-check-INV-001"]');
|
||||
const maturedCheck = wrapper.find('[data-testid="transfer-check-INV-041"]');
|
||||
expect((executableCheck.element as HTMLInputElement).disabled).toBe(false);
|
||||
expect((maturedCheck.element as HTMLInputElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('未选择任何项时生成按钮禁用', () => {
|
||||
const wrapper = mount(TransferPrecheckCard, {
|
||||
props: { summary, items, selected: new Set() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('busy 时生成按钮禁用', () => {
|
||||
const wrapper = mount(TransferPrecheckCard, {
|
||||
props: { summary, items, selected: new Set(['INV-001']), busy: true },
|
||||
...mountOptions,
|
||||
});
|
||||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('点击生成按钮仅提交可执行勾选项', async () => {
|
||||
const wrapper = mount(TransferPrecheckCard, {
|
||||
props: { summary, items, selected: new Set(['INV-001']) },
|
||||
...mountOptions,
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
expect(wrapper.emitted('execute')?.[0][0]).toEqual(['INV-001']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferResultCard', () => {
|
||||
const run = {
|
||||
run_no: 'RUN-1',
|
||||
status: 'partial_failed',
|
||||
result: {
|
||||
erp_documents: [{
|
||||
document_no: 'TRF-10001',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
material_count: 1,
|
||||
total_quantity: '1200',
|
||||
posting_status: 'posted',
|
||||
lines: [{ material_no: 'MAT-1', material_name: '连接器', specification: 'A', invoice_no: 'INV-001', quantity: '1200' }],
|
||||
}],
|
||||
exceptions: [{ source_code: 'DBS-AWSBI', invoice_no: 'INV-999', material_no: 'MAT-9', reason: 'business_failed', facts: '收料 300 / ERP 280' }],
|
||||
},
|
||||
};
|
||||
|
||||
it('按 ERP 单号聚合展示,物料明细可展开/收起', async () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
const doc = wrapper.find('[data-testid="transfer-erp-document"]');
|
||||
expect(doc.text()).toContain('TRF-10001');
|
||||
expect(doc.attributes('open')).toBeUndefined();
|
||||
await doc.find('summary').trigger('click');
|
||||
expect(doc.attributes('open')).toBeDefined();
|
||||
expect(wrapper.find('[data-testid="transfer-erp-document-lines"]').text()).toContain('INV-001');
|
||||
});
|
||||
|
||||
it('未生成单据异常单独展示', () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
expect(wrapper.find('[data-testid="transfer-exceptions-area"]').text()).toContain('INV-999');
|
||||
});
|
||||
|
||||
it('提供两个下载按钮(收料来源文件 + ERP 库存表)', async () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
await wrapper.find('[data-testid="transfer-download-receipt"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
|
||||
expect(wrapper.emitted('downloadReceipt')).toBeTruthy();
|
||||
expect(wrapper.emitted('downloadErp')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('结果页不出现“查看执行审计”入口(决策 19)', () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
expect(wrapper.text()).not.toContain('审计');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferManualCloseDialog', () => {
|
||||
it('原因为空时确认按钮禁用;填写后可提交', async () => {
|
||||
const wrapper = mount(TransferManualCloseDialog, {
|
||||
props: { open: true, invoiceNo: 'INV-001' },
|
||||
...mountOptions,
|
||||
});
|
||||
const confirm = wrapper.find('[data-testid="transfer-close-confirm"]');
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(true);
|
||||
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('线下已处理');
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(false);
|
||||
await confirm.trigger('click');
|
||||
expect(wrapper.emitted('confirm')?.[0][0]).toBe('线下已处理');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,34 @@
|
||||
/**
|
||||
* features/chat/composables/transferLocales.spec.ts
|
||||
* 用途:四语言 transfer 文案 key 一致性校验(zh-CN/zh-TW/en/th)。
|
||||
* 依赖:locales 四语言 chat.json。
|
||||
* 逻辑:四个语言包的 chat.transfer 键集合必须完全一致(防止漏翻译)。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import zhCN from '@/locales/zh-CN/chat.json';
|
||||
import zhTW from '@/locales/zh-TW/chat.json';
|
||||
import en from '@/locales/en/chat.json';
|
||||
import th from '@/locales/th/chat.json';
|
||||
|
||||
const packages: Record<string, Record<string, unknown>> = { zhCN, zhTW, en, th };
|
||||
|
||||
describe('transfer i18n four-language consistency', () => {
|
||||
it('四个语言包拥有相同的 transfer 键集合', () => {
|
||||
const keys = Object.keys(zhCN.transfer as Record<string, unknown>).sort();
|
||||
expect(keys.length).toBeGreaterThan(30);
|
||||
for (const [name, pack] of Object.entries(packages)) {
|
||||
const transfer = (pack as Record<string, { transfer: Record<string, unknown> }>).transfer;
|
||||
expect(transfer).toBeTruthy();
|
||||
expect(Object.keys(transfer).sort()).toEqual(keys);
|
||||
}
|
||||
});
|
||||
|
||||
it('每个 transfer 文案值非空', () => {
|
||||
for (const [name, pack] of Object.entries(packages)) {
|
||||
const transfer = (pack as Record<string, { transfer: Record<string, unknown> }>).transfer;
|
||||
for (const [key, value] of Object.entries(transfer)) {
|
||||
expect(String(value).trim().length, `${name}.transfer.${key}`).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* features/chat/composables/useChatTransfer.spec.ts
|
||||
* 用途:验证预检创建/恢复、选择范围、直接生成执行 Run、结果恢复与防重复。
|
||||
* 依赖:vi.mock(transfer.api)、useChatTransfer。
|
||||
* 逻辑:用 Mock API 驱动组合式函数,断言状态流转与调用参数。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferPrecheck: vi.fn(),
|
||||
getTransferPrecheck: vi.fn(),
|
||||
executeTransferPrecheck: vi.fn(),
|
||||
getTransferRun: vi.fn(),
|
||||
cancelTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../api/transfer.api', () => api);
|
||||
|
||||
import { useChatTransfer } from './useChatTransfer';
|
||||
|
||||
const summary = {
|
||||
precheck_id: 'TPC-20260806-001',
|
||||
status: 'ready_to_execute',
|
||||
business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05',
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 2, not_matured_count: 0, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_erp_write_count: 2,
|
||||
precheck_hash: 'sha256:abc',
|
||||
};
|
||||
|
||||
const detail = {
|
||||
summary,
|
||||
sources: [{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1' }],
|
||||
items: [
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: 'x', specification: 'y', invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: 'x', specification: 'y', invoice_no: 'INV-002', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-3', material_name: 'x', specification: 'y', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'not_matured' },
|
||||
],
|
||||
};
|
||||
|
||||
describe('useChatTransfer', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.createTransferPrecheck.mockResolvedValue(summary);
|
||||
api.getTransferPrecheck.mockResolvedValue(detail);
|
||||
api.executeTransferPrecheck.mockResolvedValue({ run_no: 'RUN-20260806-1', status: 'success' });
|
||||
api.getTransferRun.mockResolvedValue({
|
||||
run_no: 'RUN-20260806-1',
|
||||
status: 'success',
|
||||
result: { erp_documents: [], exceptions: [] },
|
||||
});
|
||||
});
|
||||
|
||||
it('创建预检后默认勾选全部可执行项,未成熟项不可勾选', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createPrecheck(['DBS-AWSBI'], '2026-08-06');
|
||||
expect(transfer.precheckId.value).toBe('TPC-20260806-001');
|
||||
expect(transfer.executableInvoices.value).toEqual(['INV-001', 'INV-002']);
|
||||
expect(transfer.selected.value.has('INV-001')).toBe(true);
|
||||
expect(transfer.selected.value.has('INV-041')).toBe(false);
|
||||
});
|
||||
|
||||
it('执行时提交勾选范围并恢复 Run', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createPrecheck(['DBS-AWSBI']);
|
||||
transfer.toggleSelect('INV-001', false);
|
||||
await transfer.execute();
|
||||
expect(api.executeTransferPrecheck).toHaveBeenCalledWith('TPC-20260806-001', ['INV-002']);
|
||||
expect(transfer.runNo.value).toBe('RUN-20260806-1');
|
||||
expect(api.getTransferRun).toHaveBeenCalledWith('RUN-20260806-1');
|
||||
});
|
||||
|
||||
it('无选择时执行被拦截(不调用 API)', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createPrecheck(['DBS-AWSBI']);
|
||||
transfer.selected.value = new Set();
|
||||
const result = await transfer.execute().catch(() => null);
|
||||
expect(result).toBeNull();
|
||||
expect(api.executeTransferPrecheck).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('busy 在请求期间置位,完成后复位(防重复点击)', async () => {
|
||||
let resolvePrecheck!: (value: unknown) => void;
|
||||
api.getTransferPrecheck.mockImplementation(
|
||||
() => new Promise((resolve) => { resolvePrecheck = resolve; }),
|
||||
);
|
||||
const transfer = useChatTransfer();
|
||||
const promise = transfer.createPrecheck(['DBS-AWSBI']);
|
||||
// 推进微任务链:createTransferPrecheck → getTransferPrecheck(mock 已执行)
|
||||
await Promise.resolve();
|
||||
await Promise.resolve();
|
||||
expect(transfer.busy.value).toBe(true);
|
||||
resolvePrecheck(detail);
|
||||
await promise;
|
||||
expect(transfer.busy.value).toBe(false);
|
||||
});
|
||||
|
||||
it('reset 清空全部状态', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createPrecheck(['DBS-AWSBI']);
|
||||
transfer.reset();
|
||||
expect(transfer.precheckId.value).toBeNull();
|
||||
expect(transfer.items.value).toHaveLength(0);
|
||||
expect(transfer.run.value).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,259 @@
|
||||
/**
|
||||
* features/chat/composables/useChatTransfer.ts
|
||||
* 用途:在途仓自动调拨聊天编排入口——预检创建/恢复、选择范围、直接生成执行 Run、
|
||||
* Run 进度与结果恢复、人工重试/关闭、下载。
|
||||
* 依赖:transfer.api、transfer.types、useMessage、Vue refs/computed。
|
||||
* 逻辑:前端只消费稳定 DTO;Run 是异步真相源,刷新/重进由 GET 恢复;
|
||||
* 防重复点击(busy);错误统一 useMessage 展示 BusinessError。
|
||||
*/
|
||||
import { computed, ref, type Ref } from 'vue';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
cancelTransferRun,
|
||||
createTransferPrecheck,
|
||||
downloadTransferErpInventory,
|
||||
downloadTransferExceptions,
|
||||
downloadTransferReceiptFiles,
|
||||
executeTransferPrecheck,
|
||||
getTransferBacklogSummary,
|
||||
getTransferPrecheck,
|
||||
getTransferRun,
|
||||
listTransferBacklog,
|
||||
listTransferSources,
|
||||
manualCloseTransferItem,
|
||||
retryTransferItem,
|
||||
retryTransferSourceRpa,
|
||||
} from '../api/transfer.api';
|
||||
import type {
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferPrecheckDetail,
|
||||
TransferPrecheckItem,
|
||||
TransferPrecheckSummary,
|
||||
TransferRunResult,
|
||||
TransferSourceOption,
|
||||
TransferSourceProgress,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
export function useChatTransfer() {
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
const precheckId = ref<string | null>(null);
|
||||
const precheck = ref<TransferPrecheckSummary | null>(null);
|
||||
const items = ref<TransferPrecheckItem[]>([]);
|
||||
const sources = ref<TransferSourceProgress[]>([]);
|
||||
const runNo = ref<string | null>(null);
|
||||
const run = ref<TransferRunResult | null>(null);
|
||||
const backlog = ref<TransferBacklogItem[]>([]);
|
||||
const backlogSummary = ref<TransferBacklogSummary | null>(null);
|
||||
const sourceOptions = ref<TransferSourceOption[]>([]);
|
||||
const selected = ref<Set<string>>(new Set());
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
/** 全部可执行 Invoice(阻断/未成熟不可勾选) */
|
||||
const executableInvoices = computed(() =>
|
||||
items.value.filter((item) => item.result === 'executable').map((item) => item.invoice_no),
|
||||
);
|
||||
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
const estimatedQuantity = computed(() => precheck.value?.estimated_transfer_quantity ?? '0');
|
||||
|
||||
/** 创建预检(缺文件时来源级阶段展示等待/失败) */
|
||||
async function createPrecheck(sourceCodes: string[], businessDate?: string) {
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const summary = await createTransferPrecheck({ source_codes: sourceCodes, business_date: businessDate });
|
||||
precheckId.value = summary.precheck_id;
|
||||
await refreshPrecheck();
|
||||
return summary;
|
||||
} catch (e) {
|
||||
error.value = String(e);
|
||||
throw e;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复预检进度(页面刷新/会话恢复) */
|
||||
async function refreshPrecheck() {
|
||||
if (!precheckId.value) return null;
|
||||
const detail = await getTransferPrecheck(precheckId.value);
|
||||
applyDetail(detail);
|
||||
return detail;
|
||||
}
|
||||
|
||||
function applyDetail(detail: TransferPrecheckDetail) {
|
||||
precheck.value = detail.summary;
|
||||
items.value = detail.items;
|
||||
sources.value = detail.sources;
|
||||
// 默认勾选全部可执行项;阻断/未成熟不可选
|
||||
selected.value = new Set(
|
||||
detail.items.filter((item) => item.result === 'executable').map((item) => item.invoice_no),
|
||||
);
|
||||
}
|
||||
|
||||
function toggleSelect(invoiceNo: string, checked: boolean) {
|
||||
const next = new Set(selected.value);
|
||||
if (checked) next.add(invoiceNo);
|
||||
else next.delete(invoiceNo);
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
/** 直接生成调拨单(决策 4/5:无独立确认页) */
|
||||
async function execute() {
|
||||
if (!precheckId.value) throw new Error('precheck not created');
|
||||
if (selected.value.size === 0) {
|
||||
notifyError('请至少选择一个可执行 Invoice');
|
||||
return null;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const result = await executeTransferPrecheck(precheckId.value, [...selected.value]);
|
||||
runNo.value = result.run_no;
|
||||
await refreshRun();
|
||||
return result;
|
||||
} catch (e) {
|
||||
error.value = String(e);
|
||||
throw e;
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复 Run 最终结果 */
|
||||
async function refreshRun() {
|
||||
if (!runNo.value) return null;
|
||||
const data = await getTransferRun(runNo.value);
|
||||
run.value = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
/** 请求停止剩余任务 */
|
||||
async function cancelRun(reason: string) {
|
||||
if (!runNo.value) return null;
|
||||
const result = await cancelTransferRun(runNo.value, reason);
|
||||
await refreshRun();
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 人工重试异常项 */
|
||||
async function retry(itemId: number) {
|
||||
const result = await retryTransferItem(itemId);
|
||||
await refreshPrecheck();
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 人工关闭异常项 */
|
||||
async function manualClose(itemId: number, reason: string) {
|
||||
const result = await manualCloseTransferItem(itemId, reason);
|
||||
await refreshPrecheck();
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 下载收料来源文件(zip) */
|
||||
async function downloadReceiptFiles() {
|
||||
if (!runNo.value) return null;
|
||||
const result = await downloadTransferReceiptFiles(runNo.value);
|
||||
saveBlob(result.blob, result.filename ?? `receipt-files-${runNo.value}.zip`);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 下载预检冻结的 ERP 库存表(csv) */
|
||||
async function downloadErpInventory() {
|
||||
if (!runNo.value) return null;
|
||||
const result = await downloadTransferErpInventory(runNo.value);
|
||||
saveBlob(result.blob, result.filename ?? `erp-inventory-${runNo.value}.csv`);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 下载七 Sheet 异常 Excel */
|
||||
async function downloadExceptions() {
|
||||
if (!runNo.value) return null;
|
||||
const result = await downloadTransferExceptions(runNo.value);
|
||||
saveBlob(result.blob, result.filename ?? `transfer-exceptions-${runNo.value}.xlsx`);
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 加载来源实例列表(决策 3:平台仅分组,每来源附收料文件状态) */
|
||||
async function loadSources() {
|
||||
sourceOptions.value = await listTransferSources();
|
||||
return sourceOptions.value;
|
||||
}
|
||||
|
||||
/** 对指定来源重新触发收料 RPA 抓取,并刷新来源状态 */
|
||||
async function retrySourceRpa(sourceCode: string) {
|
||||
const status = await retryTransferSourceRpa(sourceCode);
|
||||
await loadSources();
|
||||
return status;
|
||||
}
|
||||
|
||||
/** 加载待处理异常列表与汇总 */
|
||||
async function loadBacklog() {
|
||||
const [items, summary] = await Promise.all([listTransferBacklog(), getTransferBacklogSummary()]);
|
||||
backlog.value = items;
|
||||
backlogSummary.value = summary;
|
||||
return { items, summary };
|
||||
}
|
||||
|
||||
function saveBlob(blob: Blob, filename: string) {
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = filename;
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
}
|
||||
|
||||
function reset() {
|
||||
precheckId.value = null;
|
||||
precheck.value = null;
|
||||
items.value = [];
|
||||
sources.value = [];
|
||||
runNo.value = null;
|
||||
run.value = null;
|
||||
backlog.value = [];
|
||||
backlogSummary.value = null;
|
||||
sourceOptions.value = [];
|
||||
selected.value = new Set();
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
return {
|
||||
precheckId,
|
||||
precheck,
|
||||
items,
|
||||
sources,
|
||||
runNo,
|
||||
run,
|
||||
backlog,
|
||||
backlogSummary,
|
||||
sourceOptions,
|
||||
selected,
|
||||
selectedCount,
|
||||
executableInvoices,
|
||||
estimatedQuantity,
|
||||
busy,
|
||||
error,
|
||||
createPrecheck,
|
||||
refreshPrecheck,
|
||||
toggleSelect,
|
||||
execute,
|
||||
refreshRun,
|
||||
cancelRun,
|
||||
retry,
|
||||
manualClose,
|
||||
loadSources,
|
||||
retrySourceRpa,
|
||||
loadBacklog,
|
||||
downloadReceiptFiles,
|
||||
downloadErpInventory,
|
||||
downloadExceptions,
|
||||
reset,
|
||||
};
|
||||
}
|
||||
|
||||
export type ChatTransfer = ReturnType<typeof useChatTransfer>;
|
||||
export type { Ref };
|
||||
@@ -0,0 +1,117 @@
|
||||
/**
|
||||
* features/chat/e2e/in-transit-transfer.spec.ts
|
||||
* 用途:在途仓自动调拨全链路契约冒烟(对应 TDD §10 主路径)——
|
||||
* 预检 → 选择子集 → 直接生成调拨单 → Run 恢复 → 下载留底。
|
||||
* 依赖:Vitest、vi.mock(transfer.api)、useChatTransfer。
|
||||
* 逻辑:不启浏览器;用组合式函数 + Mock API 断言产品契约,避免 e2e 环境依赖
|
||||
* (与仓库 shipping e2e 约定一致)。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferPrecheck: vi.fn(),
|
||||
getTransferPrecheck: vi.fn(),
|
||||
executeTransferPrecheck: vi.fn(),
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import { useChatTransfer } from '@/features/chat/composables/useChatTransfer';
|
||||
import type { TransferPrecheckDetail } from '@/features/chat/types/transfer.types';
|
||||
|
||||
const detail: TransferPrecheckDetail = {
|
||||
summary: {
|
||||
precheck_id: 'TPC-20260806-001',
|
||||
status: 'ready_to_execute',
|
||||
business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-05',
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 3, not_matured_count: 1, prechecked_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_erp_write_count: 2,
|
||||
precheck_hash: 'sha256:abc',
|
||||
},
|
||||
sources: [{ source_code: 'DBS-AWSBI', stage: 'file_ready', file_no: 'REC-1', file_version: 'v3' }],
|
||||
items: [
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器组件', specification: 'A', invoice_no: 'INV-001', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
|
||||
{ source_code: 'DBS-AWSBI', material_no: 'MAT-2', material_name: '控制器组件', specification: 'B', invoice_no: 'INV-002', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200', to_warehouse: 'HUB-CN01', to_quantity: '1200', result: 'executable' },
|
||||
{ source_code: 'DBS-AWSSG', material_no: 'MAT-41', material_name: '连接器', specification: 'C', invoice_no: 'INV-041', from_warehouse: '', from_quantity: null, to_warehouse: '', to_quantity: '400', result: 'not_matured' },
|
||||
],
|
||||
};
|
||||
|
||||
const runResult = {
|
||||
run_no: 'RUN-20260806-001',
|
||||
status: 'success',
|
||||
result: {
|
||||
erp_documents: [{
|
||||
document_no: 'TRF-10001',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
material_count: 2,
|
||||
total_quantity: '2400',
|
||||
posting_status: 'posted',
|
||||
lines: [
|
||||
{ material_no: 'MAT-1', material_name: '连接器组件', specification: 'A', invoice_no: 'INV-001', quantity: '1200' },
|
||||
{ material_no: 'MAT-2', material_name: '控制器组件', specification: 'B', invoice_no: 'INV-002', quantity: '1200' },
|
||||
],
|
||||
}],
|
||||
exceptions: [],
|
||||
},
|
||||
};
|
||||
|
||||
describe('in-transit-transfer e2e contract', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.createTransferPrecheck.mockResolvedValue(detail.summary);
|
||||
api.getTransferPrecheck.mockResolvedValue(detail);
|
||||
api.executeTransferPrecheck.mockResolvedValue({ run_no: 'RUN-20260806-001', status: 'success' });
|
||||
api.getTransferRun.mockResolvedValue(runResult);
|
||||
api.downloadTransferReceiptFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: 'receipt-files.zip' });
|
||||
api.downloadTransferErpInventory.mockResolvedValue({ blob: new Blob(['csv']), filename: 'erp.csv' });
|
||||
});
|
||||
|
||||
it('主路径:预检 → 只选 INV-001 → 生成调拨单 → 结果按 ERP 单号聚合', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createPrecheck(['DBS-AWSBI', 'DBS-AWSSG'], '2026-08-06');
|
||||
// 未成熟项默认不勾选
|
||||
expect(transfer.selected.value.has('INV-041')).toBe(false);
|
||||
// 取消 INV-002,只执行 INV-001
|
||||
transfer.toggleSelect('INV-002', false);
|
||||
await transfer.execute();
|
||||
expect(api.executeTransferPrecheck).toHaveBeenCalledWith('TPC-20260806-001', ['INV-001']);
|
||||
expect(transfer.run.value?.result.erp_documents[0].document_no).toBe('TRF-10001');
|
||||
});
|
||||
|
||||
it('刷新恢复:重建 composable 后按 run_no 恢复最终结果(决策 17)', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
transfer.runNo.value = 'RUN-20260806-001';
|
||||
await transfer.refreshRun();
|
||||
expect(transfer.run.value?.status).toBe('success');
|
||||
expect(transfer.run.value?.result.erp_documents[0].material_count).toBe(2);
|
||||
});
|
||||
|
||||
it('下载:收料来源文件与 ERP 库存表(决策 21/22 前端入口)', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
transfer.runNo.value = 'RUN-20260806-001';
|
||||
await transfer.downloadReceiptFiles();
|
||||
await transfer.downloadErpInventory();
|
||||
expect(api.downloadTransferReceiptFiles).toHaveBeenCalledWith('RUN-20260806-001');
|
||||
expect(api.downloadTransferErpInventory).toHaveBeenCalledWith('RUN-20260806-001');
|
||||
});
|
||||
|
||||
it('异常处理:人工重试与人工关闭走独立 API', async () => {
|
||||
api.retryTransferItem.mockResolvedValue({ item_id: 1, status: 'ready_to_execute', attempt_no: 2 });
|
||||
api.manualCloseTransferItem.mockResolvedValue({ item_id: 2, status: 'manually_closed' });
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.retry(1);
|
||||
await transfer.manualClose(2, '线下已处理');
|
||||
expect(api.retryTransferItem).toHaveBeenCalledWith(1);
|
||||
expect(api.manualCloseTransferItem).toHaveBeenCalledWith(2, '线下已处理');
|
||||
});
|
||||
});
|
||||
@@ -231,7 +231,7 @@ export interface ChatMessage {
|
||||
content: string;
|
||||
/** 用户提交时固化的附件展示快照;助手消息不使用此字段。 */
|
||||
attachments?: ChatMessageAttachment[];
|
||||
type?: 'text' | 'leave-form' | 'leave-confirmation' | 'leave-result' | 'shipping-inventory-mapping' | 'shipping-parse-review' | 'shipping-match-result' | 'maintenance-device-result' | 'procurement-contract-review';
|
||||
type?: 'text' | 'leave-form' | 'leave-confirmation' | 'leave-result' | 'shipping-inventory-mapping' | 'shipping-parse-review' | 'shipping-match-result' | 'maintenance-device-result' | 'procurement-contract-review' | 'transfer-precheck' | 'transfer-progress' | 'transfer-result';
|
||||
retriever_resources?: RetrieverResource[];
|
||||
attribution_parts?: string[];
|
||||
chat_log_id?: number;
|
||||
|
||||
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* features/chat/types/transfer.types.ts
|
||||
* 用途:在途仓自动调拨前端 DTO 类型(与后端 /api/in-transit-transfer 契约一致)。
|
||||
* 依赖:无。
|
||||
* 逻辑:卡片/组合式函数只消费这些稳定类型;状态与后端 13 状态集对齐。
|
||||
*/
|
||||
|
||||
/** 预检计数 */
|
||||
export interface TransferPrecheckCounts {
|
||||
file_invoice_count: number;
|
||||
not_matured_count: number;
|
||||
prechecked_count: number;
|
||||
executable_count: number;
|
||||
blocked_count: number;
|
||||
}
|
||||
|
||||
/** 原始文件行追溯 */
|
||||
export interface TransferRawLine {
|
||||
sheet: string;
|
||||
row_no: number;
|
||||
file_version: string;
|
||||
}
|
||||
|
||||
/** 预检摘要 */
|
||||
export interface TransferPrecheckSummary {
|
||||
precheck_id: string;
|
||||
status: string;
|
||||
business_date: string;
|
||||
eligible_receipt_date_to: string;
|
||||
expires_at: string;
|
||||
counts: TransferPrecheckCounts;
|
||||
estimated_transfer_quantity: string;
|
||||
estimated_erp_write_count: number;
|
||||
precheck_hash: string;
|
||||
}
|
||||
|
||||
/** 预检明细项(决策 6:十列字段) */
|
||||
export interface TransferPrecheckItem {
|
||||
source_code: string;
|
||||
material_no: string;
|
||||
material_name: string;
|
||||
specification: string;
|
||||
invoice_no: string;
|
||||
receipt_date?: string | null;
|
||||
from_warehouse: string;
|
||||
from_quantity: string | null;
|
||||
to_warehouse: string;
|
||||
to_quantity: string;
|
||||
result: string;
|
||||
reason?: string;
|
||||
erp_document_no?: string | null;
|
||||
raw_lines?: TransferRawLine[];
|
||||
}
|
||||
|
||||
/** 来源实例级进度(决策 18:来源隔离展示) */
|
||||
export interface TransferSourceProgress {
|
||||
source_code: string;
|
||||
stage: string;
|
||||
file_no?: string | null;
|
||||
file_version?: string | null;
|
||||
checksum?: string | null;
|
||||
error_code?: string | null;
|
||||
error_message?: string | null;
|
||||
}
|
||||
|
||||
/** 预检恢复响应 */
|
||||
export interface TransferPrecheckDetail {
|
||||
summary: TransferPrecheckSummary;
|
||||
items: TransferPrecheckItem[];
|
||||
sources: TransferSourceProgress[];
|
||||
}
|
||||
|
||||
/** ERP 单据内物料明细 */
|
||||
export interface ErpDocumentLine {
|
||||
material_no: string;
|
||||
material_name: string;
|
||||
specification: string;
|
||||
invoice_no: string;
|
||||
quantity: string;
|
||||
}
|
||||
|
||||
/** 按 ERP 单号聚合的结果项(决策 20) */
|
||||
export interface ErpDocument {
|
||||
document_no: string;
|
||||
from_warehouse: string;
|
||||
to_warehouse: string;
|
||||
material_count: number;
|
||||
total_quantity: string;
|
||||
posting_status: string;
|
||||
lines: ErpDocumentLine[];
|
||||
}
|
||||
|
||||
/** 未生成 ERP 单据的异常项 */
|
||||
export interface TransferExceptionItem {
|
||||
source_code: string;
|
||||
invoice_no: string;
|
||||
material_no: string;
|
||||
reason: string;
|
||||
facts: string;
|
||||
}
|
||||
|
||||
/** Run 结果投影 */
|
||||
export interface TransferRunResult {
|
||||
run_no: string;
|
||||
status: string;
|
||||
result: {
|
||||
erp_documents: ErpDocument[];
|
||||
exceptions: TransferExceptionItem[];
|
||||
};
|
||||
}
|
||||
|
||||
/** 执行响应 */
|
||||
export interface TransferExecuteResponse {
|
||||
run_no: string;
|
||||
status: string;
|
||||
result?: TransferRunResult['result'];
|
||||
}
|
||||
|
||||
/** 待处理池项 */
|
||||
export interface TransferBacklogItem {
|
||||
item_id: number;
|
||||
source_code: string;
|
||||
invoice_no: string;
|
||||
material_no: string;
|
||||
status: string;
|
||||
reason: string;
|
||||
age_days: number;
|
||||
aging_level: string;
|
||||
last_attempt_at?: string | null;
|
||||
}
|
||||
|
||||
/** 操作结果(重试/关闭/取消) */
|
||||
export interface TransferActionResult {
|
||||
item_id?: number;
|
||||
status?: string;
|
||||
attempt_no?: number;
|
||||
run_no?: string;
|
||||
cancelled_count?: number;
|
||||
}
|
||||
|
||||
/** 待处理池汇总 */
|
||||
export interface TransferBacklogSummary {
|
||||
recoverable: number;
|
||||
closed: number;
|
||||
unknown: number;
|
||||
aging: {
|
||||
warn_3d: number;
|
||||
escalate_5d: number;
|
||||
critical_7d: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** 来源实例选项(决策 3:平台仅分组,实例为执行边界) */
|
||||
export interface TransferSourceOption {
|
||||
source_code: string;
|
||||
display_name: string;
|
||||
platform: string;
|
||||
enabled: boolean;
|
||||
/** 收料文件状态:ready / fetching / failed / none(只读投影货代收料事实) */
|
||||
file_status?: 'ready' | 'fetching' | 'failed' | 'none';
|
||||
/** 是否已有当前可用的收料文件(门禁:无 ready 文件禁止确认预检) */
|
||||
has_ready_file?: boolean;
|
||||
file_no?: string | null;
|
||||
file_sha256?: string | null;
|
||||
}
|
||||
|
||||
/** 来源收料文件状态(门禁 + 状态标识 + 重试返回) */
|
||||
export interface TransferSourceFileStatus {
|
||||
source_code: string;
|
||||
file_status: 'ready' | 'fetching' | 'failed' | 'none';
|
||||
has_ready_file: boolean;
|
||||
file_no?: string | null;
|
||||
file_sha256?: string | null;
|
||||
}
|
||||
@@ -3427,5 +3427,100 @@
|
||||
"skipped": "Skipped",
|
||||
"complete": "Complete",
|
||||
"missing": "Missing"
|
||||
},
|
||||
|
||||
"transfer": {
|
||||
"fileProgressTitle": "Receipt file preparation",
|
||||
"stageFileReady": "File ready",
|
||||
"stageWaitingRpa": "RPA fetching",
|
||||
"stageFailed": "Failed",
|
||||
"precheckTitle": "Transfer precheck",
|
||||
"businessDate": "Business date",
|
||||
"executableCount": "Executable",
|
||||
"notMaturedCount": "Same-day receipt",
|
||||
"blockedCount": "Blocked",
|
||||
"estimatedQuantity": "Est. transfer qty",
|
||||
"estimatedErpWrites": "Est. ERP documents",
|
||||
"selectedCount": "{count} selected",
|
||||
"generateTransfer": "Generate transfer order",
|
||||
"colSource": "Source",
|
||||
"colMaterial": "Material",
|
||||
"colName": "Name",
|
||||
"colSpec": "Spec",
|
||||
"colInvoice": "Invoice",
|
||||
"colFromWarehouse": "From warehouse",
|
||||
"colFromQty": "From qty",
|
||||
"colToWarehouse": "To warehouse",
|
||||
"colToQty": "To qty",
|
||||
"colResult": "Result",
|
||||
"resultExecutable": "Executable",
|
||||
"resultNotMatured": "Same-day receipt",
|
||||
"resultBlocked": "Blocked",
|
||||
"resultUnknown": "Result unknown",
|
||||
"runProgress": "Transfer run progress",
|
||||
"runExecuting": "Executing",
|
||||
"runSuccess": "Completed",
|
||||
"runPartialFailed": "Partially failed",
|
||||
"runFailed": "Failed",
|
||||
"runCancelled": "Cancelled",
|
||||
"refreshProgress": "Refresh",
|
||||
"resultTitle": "Transfer result",
|
||||
"materialCount": "{count} materials",
|
||||
"posted": "Posted",
|
||||
"noDocuments": "No ERP document generated",
|
||||
"exceptionsTitle": "No ERP document generated",
|
||||
"exceptionBusinessFailed": "Business failed",
|
||||
"exceptionTechnicalFailed": "Technical failed",
|
||||
"exceptionPrecheckExpired": "Precheck expired",
|
||||
"downloadReceiptFiles": "Download receipt files",
|
||||
"downloadErpInventory": "Download ERP inventory",
|
||||
"downloadExceptions": "Download exceptions Excel",
|
||||
"backlogTitle": "Backlog exceptions",
|
||||
"retryErp": "Re-query ERP",
|
||||
"manualClose": "Mark as no further action",
|
||||
"manualCloseTitle": "Mark as no further action",
|
||||
"manualCloseHint": "Auto schedule will skip it; history and audit are kept permanently.",
|
||||
"closeReasonPlaceholder": "Enter a reason (required)",
|
||||
"confirmClose": "Confirm close",
|
||||
"cancel": "Cancel",
|
||||
"agingNormal": "Normal",
|
||||
"agingWarn": "Due soon (3d)",
|
||||
"agingEscalate": "Escalated (5d)",
|
||||
"agingCritical": "Critical backlog (7d+)",
|
||||
"statusClosed": "Manually closed",
|
||||
"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.",
|
||||
"selectAll": "Select all",
|
||||
"selectEnabledAll": "Select all enabled",
|
||||
"clearSources": "Clear",
|
||||
"selectedSourceCount": "Selected {count} source instances",
|
||||
"needSelectSource": "Select at least one enabled source instance",
|
||||
"confirmScopeAndPrecheck": "Confirm scope & precheck",
|
||||
"homeWelcome": "Hello, you are in",
|
||||
"homeTodayLabel": "Today's tasks",
|
||||
"homeTodayAction": "Start today's transfer precheck",
|
||||
"homeTodayHint": "After selecting source instances, the system uses yesterday as the business date by default.",
|
||||
"homeHistoryLabel": "Pending tasks",
|
||||
"homeRecoverable": "Recoverable exceptions",
|
||||
"homeRecoverableHint": "Re-query ERP stock before continuing",
|
||||
"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…",
|
||||
"fileReady": "File ready",
|
||||
"fileFetching": "Fetching",
|
||||
"fileFailed": "Fetch failed",
|
||||
"fileNone": "Pending",
|
||||
"needReadyFile": "A selected source has no receipt file / is fetching / failed. Retry receipt RPA first.",
|
||||
"selectVisible": "Select visible",
|
||||
"selectRetryable": "Select retryable",
|
||||
"batchRetry": "Batch retry RPA",
|
||||
"selectedRetryableCount": "{count} retryable",
|
||||
"noRetryable": "No selected source needs retry (already ready or fetching)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"generic": "Request failed.",
|
||||
"codes": {
|
||||
"SHIPPING.FULFILLMENT_POLICY_INVALID": "The fulfillment policy or field capability binding is invalid.",
|
||||
@@ -521,6 +521,27 @@
|
||||
"VOUCHER_CHECK_SHARE_UNAVAILABLE": "Shared folder is unavailable. Check the mount and health marker.",
|
||||
"VOUCHER_CHECK_ERP_UNAVAILABLE": "ERP (Oracle) is unavailable. Please try again later.",
|
||||
"VOUCHER_CHECK_RUN_NOT_FOUND": "Voucher check run or invoice state was not found.",
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "Failed to persist voucher check results."
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "Failed to persist voucher check results.",
|
||||
"TRANSFER_PERMISSION_DENIED": "No in-transit transfer permission.",
|
||||
"TRANSFER_RECEIPT_NOT_MATURED": "Same-day receipt is not matured yet.",
|
||||
"TRANSFER_FILE_NOT_READY": "Receipt file is not ready.",
|
||||
"TRANSFER_FILE_SCHEMA_INVALID": "Receipt file schema or field validation failed.",
|
||||
"TRANSFER_INVOICE_CONFLICT": "Invoice conflict (multiple materials or dates).",
|
||||
"TRANSFER_QUANTITY_MISMATCH": "Receipt quantity does not equal ERP inventory; blocked.",
|
||||
"TRANSFER_ERP_INVENTORY_NOT_FOUND": "ERP inventory not found for this invoice.",
|
||||
"TRANSFER_PRECHECK_EXPIRED": "Precheck expired or snapshot changed; re-run precheck.",
|
||||
"TRANSFER_CONFIRMATION_REQUIRED": "Precheck is not ready for execution.",
|
||||
"TRANSFER_DUPLICATE_NOT_VERIFIED": "Duplicate invoice cannot be verified as posted.",
|
||||
"TRANSFER_RESULT_UNKNOWN": "ERP result unknown; read-only, verify per SOP.",
|
||||
"TRANSFER_MANUAL_CLOSE_REASON_REQUIRED": "Manual close requires a reason.",
|
||||
"TRANSFER_CONFIG_PUBLISH_BLOCKED": "Transfer config publish gate failed.",
|
||||
"TRANSFER_SECRET_NOT_EXPOSED": "Sensitive credentials must not be exposed.",
|
||||
"TRANSFER_NOTIFICATION_FAILED": "Notification failed; ERP result is unaffected.",
|
||||
"TRANSFER.ROUTE_NOT_RESOLVED": "Route mapping is not configured for this source.",
|
||||
"TRANSFER.ERP_NOT_FROZEN": "ERP contract is not frozen; call forbidden.",
|
||||
"TRANSFER.ERP_QUERY_TIMEOUT": "ERP query timed out; retry.",
|
||||
"TRANSFER.PRECHECK_ALREADY_EXECUTED": "This precheck was already executed.",
|
||||
"TRANSFER.SELECTION_INVALID": "Selection contains non-executable invoices.",
|
||||
"TRANSFER.INVALID_STATE_TRANSITION": "Invalid state transition."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3427,5 +3427,100 @@
|
||||
"skipped": "ข้าม",
|
||||
"complete": "ครบ",
|
||||
"missing": "ขาดเอกสาร"
|
||||
},
|
||||
|
||||
"transfer": {
|
||||
"fileProgressTitle": "การเตรียมไฟล์รับของ",
|
||||
"stageFileReady": "ไฟล์พร้อม",
|
||||
"stageWaitingRpa": "RPA กำลังดึงข้อมูล",
|
||||
"stageFailed": "ล้มเหลว",
|
||||
"precheckTitle": "ตรวจสอบก่อนโอน",
|
||||
"businessDate": "วันที่ธุรกิจ",
|
||||
"executableCount": "ดำเนินการได้",
|
||||
"notMaturedCount": "รับของวันนี้",
|
||||
"blockedCount": "ถูกบล็อก",
|
||||
"estimatedQuantity": "จำนวนโอนโดยประมาณ",
|
||||
"estimatedErpWrites": "เอกสาร ERP โดยประมาณ",
|
||||
"selectedCount": "เลือก {count} รายการ",
|
||||
"generateTransfer": "สร้างใบโอนทันที",
|
||||
"colSource": "แหล่งรับของ",
|
||||
"colMaterial": "รหัสวัสดุ",
|
||||
"colName": "ชื่อ",
|
||||
"colSpec": "สเปก",
|
||||
"colInvoice": "Invoice",
|
||||
"colFromWarehouse": "คลังต้นทาง",
|
||||
"colFromQty": "จำนวนต้นทาง",
|
||||
"colToWarehouse": "คลังปลายทาง",
|
||||
"colToQty": "จำนวนปลายทาง",
|
||||
"colResult": "ผลตรวจ",
|
||||
"resultExecutable": "ดำเนินการได้",
|
||||
"resultNotMatured": "รับของวันนี้",
|
||||
"resultBlocked": "ถูกบล็อก",
|
||||
"resultUnknown": "ผลไม่ทราบ",
|
||||
"runProgress": "ความคืบหน้าการโอน",
|
||||
"runExecuting": "กำลังดำเนินการ",
|
||||
"runSuccess": "เสร็จสิ้น",
|
||||
"runPartialFailed": "ล้มเหลวบางส่วน",
|
||||
"runFailed": "ล้มเหลว",
|
||||
"runCancelled": "ยกเลิกแล้ว",
|
||||
"refreshProgress": "รีเฟรช",
|
||||
"resultTitle": "ผลการโอน",
|
||||
"materialCount": "{count} รายการวัสดุ",
|
||||
"posted": "ผ่านรายการแล้ว",
|
||||
"noDocuments": "ไม่มีการสร้างเอกสาร ERP",
|
||||
"exceptionsTitle": "ไม่มีการสร้างเอกสาร ERP",
|
||||
"exceptionBusinessFailed": "ธุรกิจล้มเหลว",
|
||||
"exceptionTechnicalFailed": "เทคนิคล้มเหลว",
|
||||
"exceptionPrecheckExpired": "ตรวจสอบหมดอายุ",
|
||||
"downloadReceiptFiles": "ดาวน์โหลดไฟล์รับของ",
|
||||
"downloadErpInventory": "ดาวน์โหลดสต็อก ERP",
|
||||
"downloadExceptions": "ดาวน์โหลด Excel ข้อผิดพลาด",
|
||||
"backlogTitle": "รายการค้างดำเนินการ",
|
||||
"retryErp": "สอบถาม ERP อีกครั้ง",
|
||||
"manualClose": "ทำเครื่องหมายไม่ต้องดำเนินการ",
|
||||
"manualCloseTitle": "ทำเครื่องหมายไม่ต้องดำเนินการ",
|
||||
"manualCloseHint": "หลังปิดระบบอัตโนมัติจะไม่ประมวลผลอีก ประวัติและการตรวจสอบคงอยู่ถาวร",
|
||||
"closeReasonPlaceholder": "กรอกเหตุผล (จำเป็น)",
|
||||
"confirmClose": "ยืนยันการปิด",
|
||||
"cancel": "ยกเลิก",
|
||||
"agingNormal": "ปกติ",
|
||||
"agingWarn": "ใกล้ครบกำหนด (3 วัน)",
|
||||
"agingEscalate": "ยกระดับ (5 วัน)",
|
||||
"agingCritical": "ค้างสะสมรุนแรง (7 วัน+)",
|
||||
"statusClosed": "ปิดด้วยมือแล้ว",
|
||||
"resultUnknownReadonly": "อ่านอย่างเดียว ตรวจตาม SOP",
|
||||
"noBacklog": "ไม่มีรายการค้างดำเนินการ",
|
||||
"sourceSelectTitle": "เลือกแหล่งรับของ",
|
||||
"sourceSelectHint": "DBS / Crane เป็นเพียงกลุ่มแพลตฟอร์ม กรุณาเลือกแหล่งรับของจริงที่ต้องการดำเนินการ",
|
||||
"selectAll": "เลือกทั้งหมด",
|
||||
"selectEnabledAll": "เลือกที่เปิดใช้งานทั้งหมด",
|
||||
"clearSources": "ล้างข้อมูล",
|
||||
"selectedSourceCount": "เลือกแล้ว {count} แหล่งรับ",
|
||||
"needSelectSource": "กรุณาเลือกแหล่งรับที่เปิดใช้งานอย่างน้อยหนึ่งรายการ",
|
||||
"confirmScopeAndPrecheck": "ยืนยันขอบเขตและตรวจสอบ",
|
||||
"homeWelcome": "สวัสดี คุณได้เข้าสู่",
|
||||
"homeTodayLabel": "งานวันนี้",
|
||||
"homeTodayAction": "เริ่มการตรวจสอบการโอนย้ายวันนี้",
|
||||
"homeTodayHint": "หลังจากเลือกแหล่งรับ ระบบจะใช้เมื่อวานเป็นวันที่ทำรายการโดยค่าเริ่มต้น",
|
||||
"homeHistoryLabel": "งานค้าง",
|
||||
"homeRecoverable": "รายการผิดปกติที่กู้คืนได้",
|
||||
"homeRecoverableHint": "สามารถสอบถามสต็อก ERP ใหม่ก่อนดำเนินการต่อ",
|
||||
"homeClosed": "ปิดด้วยตนเองแล้ว",
|
||||
"homeClosedHint": "สามารถดูสาเหตุและกู้คืนการดำเนินการได้",
|
||||
"homeUnknown": "ผลลัพธ์ไม่ทราบ",
|
||||
"homeUnknownHint": "อ่านอย่างเดียว ต้องตรวจสอบข้อเท็จจริง ERP ภายนอก",
|
||||
"homeBack": "กลับหน้าหลัก",
|
||||
"retryReceipt": "ลองใหม่ RPA รับของ",
|
||||
"retrying": "กำลังลองใหม่…",
|
||||
"fileReady": "ไฟล์พร้อมแล้ว",
|
||||
"fileFetching": "กำลังดึง",
|
||||
"fileFailed": "ดึงล้มเหลว",
|
||||
"fileNone": "รอดำเนินการ",
|
||||
"needReadyFile": "แหล่งที่เลือกไม่มีไฟล์รับของ / กำลังดึง / ล้มเหลว โปรดลอง RPA รับของก่อน",
|
||||
"selectVisible": "เลือกที่เห็นทั้งหมด",
|
||||
"selectRetryable": "เลือกที่ลองใหม่ได้",
|
||||
"batchRetry": "ลองใหม่เป็นชุด",
|
||||
"selectedRetryableCount": "ลองใหม่ได้ {count} รายการ",
|
||||
"noRetryable": "ไม่มีแหล่งที่เลือกต้องลองใหม่ (พร้อมแล้วหรือกำลังดึง)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"generic": "คำขอล้มเหลว",
|
||||
"codes": {
|
||||
"SHIPPING.FULFILLMENT_POLICY_INVALID": "นโยบายการปฏิบัติตามหรือการผูกความสามารถของฟิลด์ไม่ถูกต้อง",
|
||||
@@ -521,6 +521,27 @@
|
||||
"VOUCHER_CHECK_SHARE_UNAVAILABLE": "โฟลเดอร์แชร์ใช้ไม่ได้ โปรดตรวจสอบการเมานต์และไฟล์สุขภาพ",
|
||||
"VOUCHER_CHECK_ERP_UNAVAILABLE": "ERP (Oracle) ใช้ไม่ได้ โปรดลองใหม่ภายหลัง",
|
||||
"VOUCHER_CHECK_RUN_NOT_FOUND": "ไม่พบรอบการตรวจหรือสถานะใบแจ้งหนี้",
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "บันทึกผลการตรวจไม่สำเร็จ"
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "บันทึกผลการตรวจไม่สำเร็จ",
|
||||
"TRANSFER_PERMISSION_DENIED": "ไม่มีสิทธิ์โอนระหว่างคลัง",
|
||||
"TRANSFER_RECEIPT_NOT_MATURED": "การรับของวันนี้ยังไม่พร้อมดำเนินการ",
|
||||
"TRANSFER_FILE_NOT_READY": "ไฟล์รับของยังไม่พร้อม",
|
||||
"TRANSFER_FILE_SCHEMA_INVALID": "โครงสร้างหรือฟิลด์ไฟล์รับของไม่ถูกต้อง",
|
||||
"TRANSFER_INVOICE_CONFLICT": "Invoice ขัดแย้ง (หลายรหัสวัสดุหรือหลายวันที่)",
|
||||
"TRANSFER_QUANTITY_MISMATCH": "จำนวนรับของไม่เท่ากับสต็อก ERP ถูกบล็อก",
|
||||
"TRANSFER_ERP_INVENTORY_NOT_FOUND": "ไม่พบสต็อก ERP สำหรับ Invoice นี้",
|
||||
"TRANSFER_PRECHECK_EXPIRED": "การตรวจสอบหมดอายุหรือข้อมูลเปลี่ยน กรุณาตรวจใหม่",
|
||||
"TRANSFER_CONFIRMATION_REQUIRED": "การตรวจสอบยังไม่พร้อมดำเนินการ",
|
||||
"TRANSFER_DUPLICATE_NOT_VERIFIED": "ไม่สามารถยืนยันว่า Invoice ซ้ำผ่านรายการแล้ว",
|
||||
"TRANSFER_RESULT_UNKNOWN": "ผล ERP ไม่ทราบ อ่านอย่างเดียว ตรวจตาม SOP",
|
||||
"TRANSFER_MANUAL_CLOSE_REASON_REQUIRED": "การปิดด้วยมือต้องกรอกเหตุผล",
|
||||
"TRANSFER_CONFIG_PUBLISH_BLOCKED": "การเผยแพร่คอนฟิกโอนไม่ผ่านเกณฑ์",
|
||||
"TRANSFER_SECRET_NOT_EXPOSED": "ห้ามเปิดเผยข้อมูลลับ",
|
||||
"TRANSFER_NOTIFICATION_FAILED": "การแจ้งเตือนล้มเหลว ไม่กระทบผล ERP",
|
||||
"TRANSFER.ROUTE_NOT_RESOLVED": "ยังไม่กำหนดเส้นทางสำหรับแหล่งนี้",
|
||||
"TRANSFER.ERP_NOT_FROZEN": "สัญญา ERP ยังไม่ถูกกำหนด ห้ามเรียก",
|
||||
"TRANSFER.ERP_QUERY_TIMEOUT": "สอบถาม ERP หมดเวลา กรุณาลองใหม่",
|
||||
"TRANSFER.PRECHECK_ALREADY_EXECUTED": "การตรวจสอบนี้ดำเนินการแล้ว",
|
||||
"TRANSFER.SELECTION_INVALID": "รายการที่เลือกมี Invoice ที่ดำเนินการไม่ได้",
|
||||
"TRANSFER.INVALID_STATE_TRANSITION": "การเปลี่ยนสถานะไม่ถูกต้อง"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3501,5 +3501,100 @@
|
||||
"skipped": "跳过",
|
||||
"complete": "齐全",
|
||||
"missing": "缺资料"
|
||||
},
|
||||
|
||||
"transfer": {
|
||||
"fileProgressTitle": "收料文件准备",
|
||||
"stageFileReady": "文件就绪",
|
||||
"stageWaitingRpa": "RPA 抓取中",
|
||||
"stageFailed": "失败",
|
||||
"precheckTitle": "调拨预检",
|
||||
"businessDate": "业务日期",
|
||||
"executableCount": "可执行",
|
||||
"notMaturedCount": "当天收料",
|
||||
"blockedCount": "阻断",
|
||||
"estimatedQuantity": "预计调拨数量",
|
||||
"estimatedErpWrites": "预计 ERP 单据",
|
||||
"selectedCount": "已选 {count} 张",
|
||||
"generateTransfer": "直接生成调拨单",
|
||||
"colSource": "收料来源",
|
||||
"colMaterial": "料号",
|
||||
"colName": "品名",
|
||||
"colSpec": "规格",
|
||||
"colInvoice": "Invoice",
|
||||
"colFromWarehouse": "拨出仓库",
|
||||
"colFromQty": "拨出数量",
|
||||
"colToWarehouse": "拨入仓库",
|
||||
"colToQty": "拨入数量",
|
||||
"colResult": "预检结果",
|
||||
"resultExecutable": "可执行",
|
||||
"resultNotMatured": "当天收料",
|
||||
"resultBlocked": "已阻断",
|
||||
"resultUnknown": "结果未知",
|
||||
"runProgress": "调拨执行进度",
|
||||
"runExecuting": "执行中",
|
||||
"runSuccess": "已完成",
|
||||
"runPartialFailed": "部分失败",
|
||||
"runFailed": "失败",
|
||||
"runCancelled": "已取消",
|
||||
"refreshProgress": "刷新进度",
|
||||
"resultTitle": "调拨结果",
|
||||
"materialCount": "{count} 项物料",
|
||||
"posted": "已过账",
|
||||
"noDocuments": "本次未生成 ERP 单据",
|
||||
"exceptionsTitle": "未生成 ERP 单据",
|
||||
"exceptionBusinessFailed": "业务失败",
|
||||
"exceptionTechnicalFailed": "技术失败",
|
||||
"exceptionPrecheckExpired": "预检失效",
|
||||
"downloadReceiptFiles": "下载收料来源文件",
|
||||
"downloadErpInventory": "下载 ERP 库存表",
|
||||
"downloadExceptions": "下载异常 Excel",
|
||||
"backlogTitle": "待处理异常",
|
||||
"retryErp": "重新查询 ERP",
|
||||
"manualClose": "标记无需继续处理",
|
||||
"manualCloseTitle": "标记无需继续处理",
|
||||
"manualCloseHint": "关闭后自动排程不再处理;历史与审计永久保留。",
|
||||
"closeReasonPlaceholder": "请输入关闭原因(必填)",
|
||||
"confirmClose": "确认关闭",
|
||||
"cancel": "取消",
|
||||
"agingNormal": "普通待办",
|
||||
"agingWarn": "即将超期(3 天)",
|
||||
"agingEscalate": "升级(5 天)",
|
||||
"agingCritical": "严重积压(7 天+)",
|
||||
"statusClosed": "已人工关闭",
|
||||
"resultUnknownReadonly": "只读,按 SOP 人工核实",
|
||||
"noBacklog": "暂无待处理异常",
|
||||
"sourceSelectTitle": "选择收料来源实例",
|
||||
"sourceSelectHint": "DBS、Crane 仅为平台分组;请勾选实际需要处理的来源实例。",
|
||||
"selectAll": "全选",
|
||||
"selectEnabledAll": "全选已启用",
|
||||
"clearSources": "清空",
|
||||
"selectedSourceCount": "已选 {count} 个来源实例",
|
||||
"needSelectSource": "请至少选择一个已启用来源实例",
|
||||
"confirmScopeAndPrecheck": "确认范围并预检",
|
||||
"homeWelcome": "你好,您已进入",
|
||||
"homeTodayLabel": "今日待办",
|
||||
"homeTodayAction": "发起今日调拨预检",
|
||||
"homeTodayHint": "选择来源实例后,系统默认以昨天为业务日期处理可成熟收料。",
|
||||
"homeHistoryLabel": "历史待办",
|
||||
"homeRecoverable": "可恢复异常",
|
||||
"homeRecoverableHint": "可重新查询 ERP 库存后继续处理",
|
||||
"homeClosed": "已人工关闭",
|
||||
"homeClosedHint": "可查看原因并恢复处理",
|
||||
"homeUnknown": "结果未知",
|
||||
"homeUnknownHint": "只读,需线下核实 ERP 事实",
|
||||
"homeBack": "返回首页",
|
||||
"retryReceipt": "重试收料 RPA",
|
||||
"retrying": "重试中…",
|
||||
"fileReady": "文件已就绪",
|
||||
"fileFetching": "抓取中",
|
||||
"fileFailed": "抓取失败",
|
||||
"fileNone": "待抓取",
|
||||
"needReadyFile": "所选来源存在无收料文件/或抓取中/或失败,请先重试收料 RPA",
|
||||
"selectVisible": "全选可见",
|
||||
"selectRetryable": "只选可重试",
|
||||
"batchRetry": "批量重试 RPA",
|
||||
"selectedRetryableCount": "其中 {count} 个可重试",
|
||||
"noRetryable": "所选来源均无需重试(已就绪或抓取中)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"generic": "请求失败。",
|
||||
"codes": {
|
||||
"SHIPPING.FULFILLMENT_POLICY_INVALID": "货代履约策略或字段能力绑定无效。",
|
||||
@@ -521,6 +521,27 @@
|
||||
"VOUCHER_CHECK_SHARE_UNAVAILABLE": "共享盘不可用,请检查挂载与健康标记。",
|
||||
"VOUCHER_CHECK_ERP_UNAVAILABLE": "ERP(Oracle)不可用,请稍后重试。",
|
||||
"VOUCHER_CHECK_RUN_NOT_FOUND": "检核批次或发票状态不存在。",
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "检核结果落库失败。"
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "检核结果落库失败。",
|
||||
"TRANSFER_PERMISSION_DENIED": "无在途调拨权限。",
|
||||
"TRANSFER_RECEIPT_NOT_MATURED": "当天收料尚未成熟,不可查询或调拨。",
|
||||
"TRANSFER_FILE_NOT_READY": "收料文件尚未就绪。",
|
||||
"TRANSFER_FILE_SCHEMA_INVALID": "收料文件结构或字段校验失败。",
|
||||
"TRANSFER_INVOICE_CONFLICT": "同一 Invoice 存在冲突(多料号或多日期)。",
|
||||
"TRANSFER_QUANTITY_MISMATCH": "收料数量与 ERP 库存不相等,已阻断。",
|
||||
"TRANSFER_ERP_INVENTORY_NOT_FOUND": "ERP 未找到该 Invoice 库存。",
|
||||
"TRANSFER_PRECHECK_EXPIRED": "预检已过期或快照变化,请重新预检。",
|
||||
"TRANSFER_CONFIRMATION_REQUIRED": "预检未就绪,无法执行。",
|
||||
"TRANSFER_DUPLICATE_NOT_VERIFIED": "重复 Invoice 无法证明原单已过账。",
|
||||
"TRANSFER_RESULT_UNKNOWN": "ERP 结果未知,只读,请按人工核实 SOP 处理。",
|
||||
"TRANSFER_MANUAL_CLOSE_REASON_REQUIRED": "人工关闭必须填写原因。",
|
||||
"TRANSFER_CONFIG_PUBLISH_BLOCKED": "调拨配置发布门禁未通过。",
|
||||
"TRANSFER_SECRET_NOT_EXPOSED": "不允许暴露敏感凭据。",
|
||||
"TRANSFER_NOTIFICATION_FAILED": "通知发送失败,不影响 ERP 结果。",
|
||||
"TRANSFER.ROUTE_NOT_RESOLVED": "来源实例路由归属未配置。",
|
||||
"TRANSFER.ERP_NOT_FROZEN": "ERP 契约未冻结,禁止调用。",
|
||||
"TRANSFER.ERP_QUERY_TIMEOUT": "ERP 查询超时,请重试。",
|
||||
"TRANSFER.PRECHECK_ALREADY_EXECUTED": "该预检已执行,请勿重复提交。",
|
||||
"TRANSFER.SELECTION_INVALID": "选择范围包含不可执行 Invoice。",
|
||||
"TRANSFER.INVALID_STATE_TRANSITION": "非法状态转换。"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3427,5 +3427,100 @@
|
||||
"skipped": "跳過",
|
||||
"complete": "齊全",
|
||||
"missing": "缺資料"
|
||||
},
|
||||
|
||||
"transfer": {
|
||||
"fileProgressTitle": "收料檔案準備",
|
||||
"stageFileReady": "檔案就緒",
|
||||
"stageWaitingRpa": "RPA 擷取中",
|
||||
"stageFailed": "失敗",
|
||||
"precheckTitle": "調撥預檢",
|
||||
"businessDate": "業務日期",
|
||||
"executableCount": "可執行",
|
||||
"notMaturedCount": "當天收料",
|
||||
"blockedCount": "阻斷",
|
||||
"estimatedQuantity": "預計調撥數量",
|
||||
"estimatedErpWrites": "預計 ERP 單據",
|
||||
"selectedCount": "已選 {count} 張",
|
||||
"generateTransfer": "直接產生調撥單",
|
||||
"colSource": "收料來源",
|
||||
"colMaterial": "料號",
|
||||
"colName": "品名",
|
||||
"colSpec": "規格",
|
||||
"colInvoice": "Invoice",
|
||||
"colFromWarehouse": "撥出倉庫",
|
||||
"colFromQty": "撥出數量",
|
||||
"colToWarehouse": "撥入倉庫",
|
||||
"colToQty": "撥入數量",
|
||||
"colResult": "預檢結果",
|
||||
"resultExecutable": "可執行",
|
||||
"resultNotMatured": "當天收料",
|
||||
"resultBlocked": "已阻斷",
|
||||
"resultUnknown": "結果未知",
|
||||
"runProgress": "調撥執行進度",
|
||||
"runExecuting": "執行中",
|
||||
"runSuccess": "已完成",
|
||||
"runPartialFailed": "部分失敗",
|
||||
"runFailed": "失敗",
|
||||
"runCancelled": "已取消",
|
||||
"refreshProgress": "重新整理進度",
|
||||
"resultTitle": "調撥結果",
|
||||
"materialCount": "{count} 項物料",
|
||||
"posted": "已過帳",
|
||||
"noDocuments": "本次未產生 ERP 單據",
|
||||
"exceptionsTitle": "未產生 ERP 單據",
|
||||
"exceptionBusinessFailed": "業務失敗",
|
||||
"exceptionTechnicalFailed": "技術失敗",
|
||||
"exceptionPrecheckExpired": "預檢失效",
|
||||
"downloadReceiptFiles": "下載收料來源檔案",
|
||||
"downloadErpInventory": "下載 ERP 庫存表",
|
||||
"downloadExceptions": "下載異常 Excel",
|
||||
"backlogTitle": "待處理異常",
|
||||
"retryErp": "重新查詢 ERP",
|
||||
"manualClose": "標記無需繼續處理",
|
||||
"manualCloseTitle": "標記無需繼續處理",
|
||||
"manualCloseHint": "關閉後自動排程不再處理;歷史與稽核永久保留。",
|
||||
"closeReasonPlaceholder": "請輸入關閉原因(必填)",
|
||||
"confirmClose": "確認關閉",
|
||||
"cancel": "取消",
|
||||
"agingNormal": "一般待辦",
|
||||
"agingWarn": "即將逾期(3 天)",
|
||||
"agingEscalate": "升級(5 天)",
|
||||
"agingCritical": "嚴重積壓(7 天+)",
|
||||
"statusClosed": "已人工關閉",
|
||||
"resultUnknownReadonly": "唯讀,依 SOP 人工核實",
|
||||
"noBacklog": "暫無待處理異常",
|
||||
"sourceSelectTitle": "選擇收料來源實例",
|
||||
"sourceSelectHint": "DBS、Crane 僅為平台分組;請勾選實際需要處理的來源實例。",
|
||||
"selectAll": "全選",
|
||||
"selectEnabledAll": "全選已啟用",
|
||||
"clearSources": "清空",
|
||||
"selectedSourceCount": "已選 {count} 個來源實例",
|
||||
"needSelectSource": "請至少選擇一個已啟用來源實例",
|
||||
"confirmScopeAndPrecheck": "確認範圍並預檢",
|
||||
"homeWelcome": "你好,您已進入",
|
||||
"homeTodayLabel": "今日待辦",
|
||||
"homeTodayAction": "發起今日調撥預檢",
|
||||
"homeTodayHint": "選擇來源實例後,系統預設以昨天為業務日期處理可成熟收料。",
|
||||
"homeHistoryLabel": "歷史待辦",
|
||||
"homeRecoverable": "可恢復異常",
|
||||
"homeRecoverableHint": "可重新查詢 ERP 庫存後繼續處理",
|
||||
"homeClosed": "已人工關閉",
|
||||
"homeClosedHint": "可查看原因並恢復處理",
|
||||
"homeUnknown": "結果未知",
|
||||
"homeUnknownHint": "唯讀,需線下核實 ERP 事實",
|
||||
"homeBack": "返回首頁",
|
||||
"retryReceipt": "重試收料 RPA",
|
||||
"retrying": "重試中…",
|
||||
"fileReady": "檔案已就緒",
|
||||
"fileFetching": "抓取中",
|
||||
"fileFailed": "抓取失敗",
|
||||
"fileNone": "待抓取",
|
||||
"needReadyFile": "所選來源存在無收料檔案/或抓取中/或失敗,請先重試收料 RPA",
|
||||
"selectVisible": "全選可見",
|
||||
"selectRetryable": "只選可重試",
|
||||
"batchRetry": "批次重試 RPA",
|
||||
"selectedRetryableCount": "其中 {count} 個可重試",
|
||||
"noRetryable": "所選來源均無需重試(已就緒或抓取中)"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
{
|
||||
"generic": "請求失敗。",
|
||||
"codes": {
|
||||
"SHIPPING.FULFILLMENT_POLICY_INVALID": "貨代履約策略或欄位能力綁定無效。",
|
||||
@@ -521,6 +521,27 @@
|
||||
"VOUCHER_CHECK_SHARE_UNAVAILABLE": "共用磁碟不可用,請檢查掛載與健康標記。",
|
||||
"VOUCHER_CHECK_ERP_UNAVAILABLE": "ERP(Oracle)不可用,請稍後重試。",
|
||||
"VOUCHER_CHECK_RUN_NOT_FOUND": "檢核批次或發票狀態不存在。",
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "檢核結果寫入失敗。"
|
||||
"VOUCHER_CHECK_PERSIST_FAILED": "檢核結果寫入失敗。",
|
||||
"TRANSFER_PERMISSION_DENIED": "無在途調撥權限。",
|
||||
"TRANSFER_RECEIPT_NOT_MATURED": "當天收料尚未成熟,不可查詢或調撥。",
|
||||
"TRANSFER_FILE_NOT_READY": "收料檔案尚未就緒。",
|
||||
"TRANSFER_FILE_SCHEMA_INVALID": "收料檔案結構或欄位驗證失敗。",
|
||||
"TRANSFER_INVOICE_CONFLICT": "同一 Invoice 存在衝突(多料號或多日期)。",
|
||||
"TRANSFER_QUANTITY_MISMATCH": "收料數量與 ERP 庫存不相等,已阻斷。",
|
||||
"TRANSFER_ERP_INVENTORY_NOT_FOUND": "ERP 未找到該 Invoice 庫存。",
|
||||
"TRANSFER_PRECHECK_EXPIRED": "預檢已過期或快照變更,請重新預檢。",
|
||||
"TRANSFER_CONFIRMATION_REQUIRED": "預檢未就緒,無法執行。",
|
||||
"TRANSFER_DUPLICATE_NOT_VERIFIED": "重複 Invoice 無法證明原單已過帳。",
|
||||
"TRANSFER_RESULT_UNKNOWN": "ERP 結果未知,唯讀,請依人工核實 SOP 處理。",
|
||||
"TRANSFER_MANUAL_CLOSE_REASON_REQUIRED": "人工關閉必須填寫原因。",
|
||||
"TRANSFER_CONFIG_PUBLISH_BLOCKED": "調撥設定發布門禁未通過。",
|
||||
"TRANSFER_SECRET_NOT_EXPOSED": "不允許暴露敏感憑證。",
|
||||
"TRANSFER_NOTIFICATION_FAILED": "通知傳送失敗,不影響 ERP 結果。",
|
||||
"TRANSFER.ROUTE_NOT_RESOLVED": "來源實例路由歸屬未設定。",
|
||||
"TRANSFER.ERP_NOT_FROZEN": "ERP 契約未凍結,禁止呼叫。",
|
||||
"TRANSFER.ERP_QUERY_TIMEOUT": "ERP 查詢逾時,請重試。",
|
||||
"TRANSFER.PRECHECK_ALREADY_EXECUTED": "該預檢已執行,請勿重複提交。",
|
||||
"TRANSFER.SELECTION_INVALID": "選擇範圍包含不可執行 Invoice。",
|
||||
"TRANSFER.INVALID_STATE_TRANSITION": "非法狀態轉換。"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ export const AGENT_CODE_GENERIC = 'generic';
|
||||
export const AGENT_CODE_SHIPPING_NOTICE = 'shipping_notice';
|
||||
export const AGENT_CODE_FILE_CHECK = 'file_check';
|
||||
export const AGENT_CODE_PROCUREMENT_CONTRACT_REVIEW = 'procurement_contract_review';
|
||||
export const AGENT_CODE_IN_TRANSIT_TRANSFER = 'in_transit_transfer';
|
||||
|
||||
export interface AgentRegistryCapabilities {
|
||||
streaming?: boolean;
|
||||
|
||||
Reference in new issue
Block a user