Merge branch 'dev' into branch-statement-button
# Conflicts: # docs/funclist.md
This commit is contained in:
commit
97c46625e4
986 files changed
+96142
-38961
No files matched your search
@@ -9,7 +9,7 @@ import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('shipping API runtime entrypoints', () => {
|
||||
it('does not expose direct inventory match or Excel generation actions', () => {
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'matchWorkspaceShippingInventory')).toBe(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'matchWorkspaceShippingOnhand')).toBe(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'generateWorkspaceShippingExcel')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -60,7 +60,7 @@ import type {
|
||||
ShippingOrderReviewLlmSuggestionResponse,
|
||||
ShippingOrderReviewReparseResponse,
|
||||
ShippingOrderReviewRun,
|
||||
ShippingTaskInventoryCandidatesResponse,
|
||||
ShippingTaskOnhandCandidatesResponse,
|
||||
ShippingTaskUiState,
|
||||
} from '../types/shipping.api.types';
|
||||
|
||||
@@ -205,7 +205,7 @@ export const workspaceShippingNoticeExportUrl = (businessNo: string) =>
|
||||
`/api/workspace/shipping-notices/${encodeURIComponent(businessNo)}/export`;
|
||||
|
||||
/** 当前任务已关联库存快照的受控下载 URL;后端会再次校验任务归属与活动 link。 */
|
||||
export const workspaceShippingInventoryFileUrl = (taskNo: string) =>
|
||||
export const workspaceShippingOnhandFileUrl = (taskNo: string) =>
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/inventory-file`;
|
||||
|
||||
/** 当前任务指定明细匹配快照的受控下载 URL;文件号必须由行级投影提供。 */
|
||||
@@ -622,7 +622,7 @@ export const getWorkspaceTaskInventoryCandidates = (
|
||||
if (options?.version != null) params.set('version', String(options.version));
|
||||
if (options?.includeHistory != null) params.set('include_history', String(options.includeHistory));
|
||||
const query = params.toString();
|
||||
return requestJson<ShippingTaskInventoryCandidatesResponse>(
|
||||
return requestJson<ShippingTaskOnhandCandidatesResponse>(
|
||||
`/api/workspace/shipping-notice/tasks/${encodeURIComponent(taskNo)}/inventory-candidates${query ? `?${query}` : ''}`,
|
||||
);
|
||||
};
|
||||
@@ -1348,7 +1348,7 @@ export async function removeWorkspaceShippingNoticeLine(
|
||||
* @param file - 已按库存源发布方案导出的 xls/xlsx/csv 文件
|
||||
* @returns 库存解析与后续匹配结果
|
||||
*/
|
||||
export async function uploadWorkspaceShippingInventory(taskNo: string, file: File) {
|
||||
export async function uploadWorkspaceShippingOnhand(taskNo: string, file: File) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
@@ -1399,6 +1399,19 @@ export async function batchConfirmWorkspaceShippingNoticesUploaded(businessNos:
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动刷新 Crane 分配状态。后端只排队一次状态回查,不重新上传 Excel。
|
||||
* @param businessNo - 对外发货通知单号,同时是 Crane 的 Pull Request #
|
||||
* @returns 已排队的回查结果
|
||||
*/
|
||||
export async function refreshWorkspaceCraneUploadStatus(businessNo: string) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-notices/${encodeURIComponent(businessNo)}/refresh-crane-upload`,
|
||||
jsonPost({}),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/** 按多个发货通知单号批量受理货代 RPA 上传;RPA 成功仍以回调为准。 */
|
||||
export async function batchStartWorkspaceShippingNoticeRpaUpload(businessNos: string[]) {
|
||||
return requestJson<{ results: Array<Record<string, unknown>> }>(
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
* 用途:锁定在途仓自动调拨 JSON POST 请求头契约——必须携带 Content-Type: application/json,
|
||||
* 否则后端 Flask request.get_json 解析不到 body,导致默认 source_codes=[] 返回 400;
|
||||
* 另锁定 D8 异步 202 契约(requestJson 对 200/202 均透传 envelope.data)与
|
||||
* D9 调拨单清单(GET /runs/{run_no} 返回体 orders 数组透传)。
|
||||
* D9 调拨单清单(GET /runs/{run_no} 返回体 orders 数组透传);
|
||||
* 当前归档重解析 POST /sources/{code}/reparse(body 仅 record_kind)。
|
||||
* 依赖:Vitest、vi.mock(@/shared/api/client)、transfer.api、getAuthHeaders。
|
||||
* 逻辑:POST(create/execute/cancel/retry/manual-close)断言 headers 含 application/json,
|
||||
* 且 body 序列化正确;GET/blob 端点不强制 Content-Type;
|
||||
@@ -28,7 +29,14 @@ vi.mock('@/shared/utils/auth', () => ({
|
||||
import {
|
||||
cancelTransferRun,
|
||||
createTransferMatching,
|
||||
downloadTransferInboundFiles,
|
||||
downloadTransferSourceFiles,
|
||||
executeTransferItems,
|
||||
listEvidenceFiles,
|
||||
reparseCurrentFile,
|
||||
downloadEvidenceFile,
|
||||
retryTransferSourceRpa,
|
||||
retryTransferSourcesRpaBatch,
|
||||
getTransferBacklogSummary,
|
||||
getTransferMatching,
|
||||
getTransferRun,
|
||||
@@ -52,6 +60,70 @@ describe('transfer.api JSON request contract', () => {
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], business_date: '2026-08-18' }));
|
||||
});
|
||||
|
||||
it('创建匹配查询范围参数名为 movement_date_from/to(Task 3 契约更名)', () => {
|
||||
// [断言意图] 后端 /matchings 入参更名(Task 3):查询范围参数名为
|
||||
// movement_date_from/to;body 键名必须逐字对齐,错名会被后端当作缺省
|
||||
// (范围不生效)而非报错。
|
||||
createTransferMatching({ source_codes: ['DBS-AWSBI'], movement_date_from: '2026-09-26', movement_date_to: '2026-09-26' });
|
||||
const [, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], movement_date_from: '2026-09-26', movement_date_to: '2026-09-26' }));
|
||||
});
|
||||
|
||||
it('下载出入站来源文件走 GET /runs/{run_no}/inbound-files(Task 3 路由更名)', () => {
|
||||
// [断言意图] Task 3 路由更名(出入站来源文件 inbound-files)后前端 URL 逐字对齐;
|
||||
// blob 端点只需鉴权头(既有契约)。
|
||||
downloadTransferInboundFiles('RUN-1');
|
||||
const [url, init] = requestBlob.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/runs/RUN-1/inbound-files');
|
||||
expect(init.headers).toBeDefined();
|
||||
});
|
||||
|
||||
it('按来源打包下载走 POST /sources/inbound-files,body 含 transfer_type', () => {
|
||||
// [断言意图] 证据打包按所选调拨类型决定打进包的流,body 必须同时有 source_codes 与 transfer_type。
|
||||
downloadTransferSourceFiles(['DBS-AWSBI'], 'in_transit_to_hub');
|
||||
const [url, init] = requestBlob.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/inbound-files');
|
||||
expect(init.method).toBe('POST');
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], transfer_type: 'in_transit_to_hub' }));
|
||||
});
|
||||
|
||||
it('单源重试 POST retry-rpa,body 带 record_kind,缺省 inbound', () => {
|
||||
// [断言意图] 旧调用不传种类时仍提交 inbound;来源卡传 outbound 时 body 必须是该流。
|
||||
retryTransferSourceRpa('DBS-AWSBI');
|
||||
retryTransferSourceRpa('DBS-AWSBI', 'outbound');
|
||||
const calls = requestJson.mock.calls as [string, RequestInit][];
|
||||
expect(calls[0][0]).toBe('/api/in-transit-transfer/sources/DBS-AWSBI/retry-rpa');
|
||||
expect(calls[0][1].body).toBe(JSON.stringify({ record_kind: 'inbound' }));
|
||||
expect(calls[1][1].body).toBe(JSON.stringify({ record_kind: 'outbound' }));
|
||||
});
|
||||
|
||||
it('批量重试 POST retry-rpa-batch,带来源类型时 body 含 transfer_type', () => {
|
||||
retryTransferSourcesRpaBatch(['DBS-AWSBI'], 'hub_to_hub');
|
||||
const [url, init] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/retry-rpa-batch');
|
||||
expect(init.body).toBe(JSON.stringify({ source_codes: ['DBS-AWSBI'], transfer_type: 'hub_to_hub' }));
|
||||
});
|
||||
|
||||
it('列出证据文件走 GET evidence-files 并带 record_kind', () => {
|
||||
listEvidenceFiles('DSV360', 'outbound');
|
||||
const [url] = requestJson.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/DSV360/evidence-files?record_kind=outbound');
|
||||
});
|
||||
|
||||
it('单文件下载走站点 evidence-files/{id},不打开 MinIO 地址', () => {
|
||||
// [断言意图] HTTPS 页面不能直接打开 HTTP MinIO 预签名链接,下载必须走当前站点。
|
||||
downloadEvidenceFile('DSV360', 25, 'outbound');
|
||||
const [url] = requestBlob.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/sources/DSV360/evidence-files/25?record_kind=outbound');
|
||||
});
|
||||
|
||||
it('当前文件重解析 POST reparse,body 只有 record_kind', () => {
|
||||
reparseCurrentFile('DSV360_AWSDU', 'outbound');
|
||||
const calls = requestJson.mock.calls as [string, RequestInit][];
|
||||
expect(calls[0][0]).toBe('/api/in-transit-transfer/sources/DSV360_AWSDU/reparse');
|
||||
expect(JSON.parse(String(calls[0][1].body))).toEqual({ record_kind: 'outbound' });
|
||||
});
|
||||
|
||||
it('按明细行执行调拨 POST /items/execute 带 application/json 与 item_ids 契约', () => {
|
||||
// [断言意图] 行式执行(2026-09-23 item-centric 重构):执行不再挂在旧匹配详情端点下,
|
||||
// 改为独立 items/execute,body 键从 invoice_nos 改为 item_ids;JSON 头契约不变。
|
||||
@@ -88,7 +160,7 @@ describe('transfer.api JSON request contract', () => {
|
||||
// (Task 11)一致,前端只透传不加工;类型层 TransferRunResult 必含 orders: TransferOrder[]。
|
||||
const order: TransferOrder = {
|
||||
doc_no: 'HTT-OR-26092300001',
|
||||
receipt_date: '2026-09-23',
|
||||
movement_date: '2026-09-23',
|
||||
from_warehouse: 'HTT-B25',
|
||||
to_warehouse: 'HTT-B02',
|
||||
status: 'success',
|
||||
@@ -153,7 +225,7 @@ describe('transfer.api D8 异步 202 契约(真实 requestJson:200/202 均
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const order: TransferOrder = {
|
||||
doc_no: 'HTT-OR-26092300002',
|
||||
receipt_date: '2026-09-23',
|
||||
movement_date: '2026-09-23',
|
||||
from_warehouse: 'HTT-B25',
|
||||
to_warehouse: 'HTT-B02',
|
||||
status: 'executing',
|
||||
|
||||
@@ -3,6 +3,11 @@
|
||||
* 用途:在途仓自动调拨 API 客户端(统一 requestJson / requestBlob,不重复造客户端)。
|
||||
* 依赖:@/shared/api/client(requestJson / requestBlob / BusinessError)、getAuthHeaders。
|
||||
* 逻辑:薄封装后端 /api/in-transit-transfer 全部端点;二进制下载走 requestBlob。
|
||||
* 来源重试 body 带 record_kind;批量重试与证据打包在带来源类型时带 transfer_type;
|
||||
* 证据清单走 GET sources/{code}/evidence-files;
|
||||
* 单文件下载走 GET sources/{code}/evidence-files/{fileId},由站点回传,
|
||||
* 不打开 HTTP MinIO 预签名地址;
|
||||
* 当前归档重解析走 POST sources/{code}/reparse(body 仅 record_kind,不触发 RPA)。
|
||||
*/
|
||||
import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
@@ -18,9 +23,14 @@ import type {
|
||||
TransferMatchingItem,
|
||||
TransferMatchingSummary,
|
||||
TransferRunResult,
|
||||
TransferPendingMatchRecord,
|
||||
TransferCurrentReparseResult,
|
||||
TransferEvidenceFile,
|
||||
TransferRecordKind,
|
||||
TransferSourceFileStatus,
|
||||
TransferSourceOption,
|
||||
TransferType,
|
||||
TransferTypeOption,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
const BASE = '/api/in-transit-transfer';
|
||||
@@ -31,12 +41,22 @@ const jsonHeaders = () => ({ 'Content-Type': 'application/json', ...getAuthHeade
|
||||
export interface CreateMatchingPayload {
|
||||
source_codes: string[];
|
||||
business_date?: string;
|
||||
receipt_date_from?: string;
|
||||
receipt_date_to?: string;
|
||||
/** 调拨业务类型;缺省为在途仓至HUB仓 */
|
||||
/** 匹配查询范围(异动日期;Task 3 契约更名后参数名,旧名见 git 历史) */
|
||||
movement_date_from?: string;
|
||||
movement_date_to?: string;
|
||||
/** 调拨业务类型 code(Task 7 接口化:来源选择卡接口选项所选值;缺省行为由后端匹配链路决定) */
|
||||
transfer_type?: TransferType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调拨类型配置列表(仅 enabled、sort_order 升序)。
|
||||
* 每项含 code、names、sort_order、transform_rules,以及由范围规则推导的
|
||||
* record_kinds;不回传 scope_rules / warehouse_config / description。
|
||||
* 配置缺失返回空数组。来源选择卡类型选项的唯一数据源。
|
||||
*/
|
||||
export const fetchTransferTypes = () =>
|
||||
requestJson<TransferTypeOption[]>(`${BASE}/transfer-types`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 创建匹配(只读) */
|
||||
export const createTransferMatching = (payload: CreateMatchingPayload) =>
|
||||
requestJson<TransferMatchingSummary>(BASE + '/matchings', {
|
||||
@@ -166,9 +186,9 @@ export const manualCloseTransferItem = (itemId: number, reason: string) =>
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
/** 下载收料来源文件(zip) */
|
||||
export const downloadTransferReceiptFiles = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/receipt-files`, { headers: getAuthHeaders() });
|
||||
/** 下载出入站来源文件(zip;Task 3 路由更名后端点为 inbound-files) */
|
||||
export const downloadTransferInboundFiles = (runNo: string) =>
|
||||
requestBlob(`${BASE}/runs/${runNo}/inbound-files`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 下载匹配冻结的 ERP 库存表(csv) */
|
||||
export const downloadTransferErpInventory = (runNo: string) =>
|
||||
@@ -201,26 +221,153 @@ export const requeryTransferMatchingItems = (matchingNo: string, invoiceNos?: st
|
||||
{ method: 'POST', body: JSON.stringify(invoiceNos ? { invoice_nos: invoiceNos } : {}), headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' } },
|
||||
);
|
||||
|
||||
/** 按选中来源打包下载各自最新归档收料文件(zip) */
|
||||
export const downloadTransferSourceFiles = (sourceCodes: string[]) =>
|
||||
requestBlob(`${BASE}/sources/receipt-files`, {
|
||||
/**
|
||||
* 按选中来源与调拨类型打包最新可用证据文件。
|
||||
* 核心逻辑:POST /sources/inbound-files,body 为 source_codes + transfer_type;
|
||||
* 压缩包文件名用响应 Content-Disposition(后端 evidence-files-N.zip)。
|
||||
* @param sourceCodes - 要打包的来源编码
|
||||
* @param transferType - 当前所选调拨类型 code,后端据此决定打进包的证据流
|
||||
* @returns zip Blob 与后端给出的文件名
|
||||
*/
|
||||
export const downloadTransferSourceFiles = (sourceCodes: string[], transferType: string) =>
|
||||
requestBlob(`${BASE}/sources/inbound-files`, {
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ source_codes: sourceCodes }),
|
||||
body: JSON.stringify({ source_codes: sourceCodes, transfer_type: transferType }),
|
||||
});
|
||||
|
||||
/** 待处理异常列表(可恢复/已关闭/结果未知 + 老化等级) */
|
||||
export const listTransferBacklog = () =>
|
||||
requestJson<TransferBacklogItem[]>(`${BASE}/backlog`, { headers: getAuthHeaders() });
|
||||
/**
|
||||
* 待处理异常池分页查询(2026-10-16 服务端分页 + 筛选下推:池为无界增长集合,
|
||||
* 全量拉取在千行级放大载荷与老化查询规模;后端不带分页参数时返回全量数组为
|
||||
* 兼容口径,本前端恒走分页)。
|
||||
* keyword/resultFilter 对应后端 keyword/result_filter(筛选在服务端执行,
|
||||
* total=筛选后全量计数);返回 {items=当前页切片, total, page, page_size}。
|
||||
*/
|
||||
export interface TransferBacklogPageQuery {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
keyword?: string;
|
||||
resultFilter?: 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
}
|
||||
|
||||
/** 待处理异常汇总(含 3/5/7 天老化分级) */
|
||||
export const listTransferBacklogPage = (query: TransferBacklogPageQuery) => {
|
||||
const params = new URLSearchParams({
|
||||
page: String(query.page),
|
||||
page_size: String(query.pageSize),
|
||||
});
|
||||
if (query.keyword?.trim()) params.set('keyword', query.keyword.trim());
|
||||
if (query.resultFilter && query.resultFilter !== 'all') params.set('result_filter', query.resultFilter);
|
||||
return requestJson<{ items: TransferBacklogItem[]; total: number; page: number; page_size: number }>(
|
||||
`${BASE}/backlog?${params.toString()}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
};
|
||||
|
||||
/** 待处理异常汇总(含老化分级、待匹配全量 pending_match、可匹配 matchable_count) */
|
||||
export const getTransferBacklogSummary = () =>
|
||||
requestJson<TransferBacklogSummary>(`${BASE}/backlog/summary`, { headers: getAuthHeaders() });
|
||||
|
||||
/** 来源实例列表(平台 DBS/Crane 仅分组,每来源附收料文件状态) */
|
||||
/**
|
||||
* 跨页全选支持(2026-10-22):拉取当前筛选下全部待处理明细 id。
|
||||
* 核心逻辑:GET /backlog/item-ids(keyword/result_filter 与分页接口同口径);
|
||||
* 返回 { ids(item_id 升序,后端上限 5000), total(筛选后全量计数), truncated }——
|
||||
* 供待处理池「选择全部 N 行」合并进勾选集合;批量端点按 item_ids 列表逐行
|
||||
* 校验,直接复用无需新批量契约。
|
||||
*/
|
||||
export const fetchBacklogSelectableItemIds = (
|
||||
query: Pick<TransferBacklogPageQuery, 'keyword' | 'resultFilter'> = {},
|
||||
) => {
|
||||
const params = new URLSearchParams();
|
||||
if (query.keyword?.trim()) params.set('keyword', query.keyword.trim());
|
||||
if (query.resultFilter && query.resultFilter !== 'all') params.set('result_filter', query.resultFilter);
|
||||
const qs = params.toString();
|
||||
return requestJson<{ ids: number[]; total: number; truncated: boolean }>(
|
||||
`${BASE}/backlog/item-ids${qs ? `?${qs}` : ''}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* 分页拉取待匹配清单的一段。
|
||||
* 核心逻辑:拼 page、page_size、segment 后 GET /backlog/pending-match。
|
||||
* 无 item_id,不可勾选执行。
|
||||
* @param query.page - 页码,从 1 起
|
||||
* @param query.pageSize - 每页行数
|
||||
* @param query.segment - matchable=启用类型现在圈得住;outside=其余已落档;缺省 all
|
||||
* @returns 当前页记录与该段总数
|
||||
*/
|
||||
export const listPendingMatchRecordsPage = (query: {
|
||||
page: number;
|
||||
pageSize: number;
|
||||
segment?: 'all' | 'matchable' | 'outside';
|
||||
}) => {
|
||||
const params = new URLSearchParams({
|
||||
page: String(query.page),
|
||||
page_size: String(query.pageSize),
|
||||
});
|
||||
if (query.segment) params.set('segment', query.segment);
|
||||
return requestJson<{ records: TransferPendingMatchRecord[]; total: number; page: number; page_size: number }>(
|
||||
`${BASE}/backlog/pending-match?${params.toString()}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
};
|
||||
|
||||
/** 来源实例列表(平台 DBS/Crane 仅分组,每来源附入站扁平状态与 streams) */
|
||||
export const listTransferSources = () =>
|
||||
requestJson<TransferSourceOption[]>(`${BASE}/sources`, { headers: getAuthHeaders() });
|
||||
|
||||
/**
|
||||
* 列出某来源当天某条证据流的可用文件。
|
||||
* 核心逻辑:GET /sources/{code}/evidence-files?record_kind=,只取元数据与预签地址,不解析 Excel。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound
|
||||
* @returns 当天可用证据文件列表(含 original_filename、created_at、sha256、file_size、presigned_url、download_url)
|
||||
*/
|
||||
export const listEvidenceFiles = (sourceCode: string, recordKind: TransferRecordKind) =>
|
||||
requestJson<TransferEvidenceFile[]>(
|
||||
`${BASE}/sources/${encodeURIComponent(sourceCode)}/evidence-files?record_kind=${encodeURIComponent(recordKind)}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
|
||||
/**
|
||||
* 经当前站点下载一份证据文件。
|
||||
* 核心逻辑:GET /sources/{code}/evidence-files/{fileId},带 record_kind。
|
||||
* 页面是 HTTPS,MinIO 公网地址是 HTTP,直接打开预签名链接会被浏览器拦截。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param fileId - 归档文件主键
|
||||
* @param recordKind - inbound 或 outbound
|
||||
* @returns 文件内容和 Content-Disposition 中的保存名
|
||||
*/
|
||||
export const downloadEvidenceFile = (
|
||||
sourceCode: string,
|
||||
fileId: number,
|
||||
recordKind: TransferRecordKind,
|
||||
) =>
|
||||
requestBlob(
|
||||
`${BASE}/sources/${encodeURIComponent(sourceCode)}/evidence-files/${fileId}?record_kind=${encodeURIComponent(recordKind)}`,
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
|
||||
/**
|
||||
* 对来源当前最新归档文件重新解析(不触发 RPA)。
|
||||
* 核心逻辑:POST /sources/{code}/reparse,body 只带 record_kind,后端重放最新归档 Excel。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound
|
||||
* @returns 重解析统计与来源文件状态投影
|
||||
*/
|
||||
export const reparseCurrentFile = (
|
||||
sourceCode: string,
|
||||
recordKind: TransferRecordKind,
|
||||
) =>
|
||||
requestJson<TransferCurrentReparseResult>(
|
||||
`${BASE}/sources/${encodeURIComponent(sourceCode)}/reparse`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ record_kind: recordKind }),
|
||||
},
|
||||
);
|
||||
|
||||
/** retry-rpa 响应:parse_failed 本地重解析路径返回 {ok, file_status, reparsed};RPA 触发路径返回原状态投影 */
|
||||
export interface TransferRetryRpaReparseResult {
|
||||
source_code: string;
|
||||
@@ -229,12 +376,22 @@ export interface TransferRetryRpaReparseResult {
|
||||
reparsed: true;
|
||||
}
|
||||
|
||||
/** 来源重试(解析失败分层 2026-09-29):parse_failed 先本地重解析返回 200 reparse 结果,
|
||||
* 其余状态重新触发一次收料 RPA 抓取(202 + fetching / 配置缺失 fail-closed) */
|
||||
export const retryTransferSourceRpa = (sourceCode: string) =>
|
||||
/**
|
||||
* 按证据流重试一个来源。
|
||||
* 核心逻辑:POST /sources/{code}/retry-rpa,body 只带 record_kind。
|
||||
* 未传来源种类的旧调用方缺省 inbound;来源卡始终传入该括号对应的流。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound,缺省 inbound
|
||||
* @returns 重解析结果或来源文件状态投影
|
||||
*/
|
||||
export const retryTransferSourceRpa = (
|
||||
sourceCode: string,
|
||||
recordKind: TransferRecordKind = 'inbound',
|
||||
) =>
|
||||
requestJson<TransferRetryRpaReparseResult | TransferSourceFileStatus>(`${BASE}/sources/${encodeURIComponent(sourceCode)}/retry-rpa`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ record_kind: recordKind }),
|
||||
});
|
||||
|
||||
/** 批量来源重试响应:triggered=是否写了 batch trigger;results 逐来源真实结果 */
|
||||
@@ -252,11 +409,22 @@ export interface TransferRetryRpaBatchResult {
|
||||
}>;
|
||||
}
|
||||
|
||||
/** 批量重试(2026-10-09):多来源合并写一个 batch trigger 文件,
|
||||
* Worker 单次浏览器会话串行导出全部来源(逐来源单文件会开/关 N 次浏览器) */
|
||||
export const retryTransferSourcesRpaBatch = (sourceCodes: string[]) =>
|
||||
/**
|
||||
* 批量重试所选来源。
|
||||
* 核心逻辑:POST /sources/retry-rpa-batch。带来源所选调拨类型时 body 为
|
||||
* {source_codes, transfer_type},后端按该类型的证据流分组;不传类型时只发
|
||||
* source_codes,保持旧的整批入站契约。
|
||||
* @param sourceCodes - 要重试的来源编码
|
||||
* @param transferType - 当前调拨类型 code;来源卡批量按钮始终传入
|
||||
* @returns 逐来源(及证据流)的触发结果
|
||||
*/
|
||||
export const retryTransferSourcesRpaBatch = (sourceCodes: string[], transferType?: string) =>
|
||||
requestJson<TransferRetryRpaBatchResult>(`${BASE}/sources/retry-rpa-batch`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ source_codes: sourceCodes }),
|
||||
body: JSON.stringify(
|
||||
transferType
|
||||
? { source_codes: sourceCodes, transfer_type: transferType }
|
||||
: { source_codes: sourceCodes },
|
||||
),
|
||||
});
|
||||
@@ -672,7 +672,7 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
@add-remote-url="page.addRemoteUrlAttachment"
|
||||
|
||||
@shipping-inventory-selected="page.handleShippingInventorySelected"
|
||||
@shipping-inventory-selected="page.handleShippingOnhandSelected"
|
||||
|
||||
@use-shipping-suggested-prompt="page.useShippingSuggestedPrompt"
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
* 依赖:Vue computed、lucide 图标、消息附件/Leave/Shipping 子组件、chat.types 与页面级 handlers。
|
||||
* 逻辑:由 ChatMessageList 按消息逐条挂载;货代履约写按钮不在气泡内渲染,仅展示只读卡与深链通知。
|
||||
* 用户附件区支持 summaryOnly:下方已有抽取进度卡时只显示附件摘要。
|
||||
* 助手 Markdown 排版在本组件内收口:全局 base 只恢复标题字重,列表序号/圆点、
|
||||
* 层级缩进与标题字号层级由 scoped 样式统一补齐,避免回答渲染成无结构平铺文本。
|
||||
* 兼容:同时承接采购合同审查、库存映射、订单提取和 Mermaid 展示。
|
||||
* 知识库未命中兜底回复按原始 content 检测触发标记,在正文下方渲染【知识库内容清单】按钮,
|
||||
* 点击后弹窗展示常用问题「能力清单条目」标准答案。
|
||||
@@ -1223,6 +1225,109 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* ── Markdown 正文排版:标题层级 / 列表序号 / 层级缩进 ─────────────────────
|
||||
背景:Tailwind preflight 会把 ul/ol 重置为无序号、无圆点、无缩进,Dify 返回的
|
||||
结构化回答(### 标题 + 多级列表 + 有序步骤)会被渲染成平铺文本;
|
||||
全局 base 层只恢复了标题字重,这里按聊天回答的高频结构统一补齐排版。 */
|
||||
:deep(.chat-markdown h1),
|
||||
:deep(.chat-markdown h2),
|
||||
:deep(.chat-markdown h3) {
|
||||
margin: 1em 0 0.5em;
|
||||
font-size: 1.125rem;
|
||||
line-height: 1.45;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown h4),
|
||||
:deep(.chat-markdown h5),
|
||||
:deep(.chat-markdown h6) {
|
||||
margin: 0.875em 0 0.375em;
|
||||
font-size: 1rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown p) {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown strong) {
|
||||
font-weight: 600;
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
/* 列表缩进与序号:无序列表逐层 disc/circle/square 区分层级;有序列表(操作步骤)
|
||||
无论嵌套在第几层都保持 1. 2. 3. 数字序号,与回答里“步骤”的业务语义一致 */
|
||||
:deep(.chat-markdown ul),
|
||||
:deep(.chat-markdown ol) {
|
||||
margin: 0.375rem 0;
|
||||
padding-left: 1.375rem;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown ul) {
|
||||
list-style-type: disc;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown ol) {
|
||||
list-style-type: decimal;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown ul ul) {
|
||||
list-style-type: circle;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown ul ul ul) {
|
||||
list-style-type: square;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown li) {
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown li::marker) {
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown li > p) {
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown li > ul),
|
||||
:deep(.chat-markdown li > ol) {
|
||||
margin: 0.25rem 0;
|
||||
}
|
||||
|
||||
/* 气泡内首尾元素贴边,避免首行/末行出现额外空隙 */
|
||||
:deep(.chat-markdown > :first-child) {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
:deep(.chat-markdown > :last-child) {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
/* 链接 / 引用 / 分隔线:颜色走主题令牌,暗色由变量自适应 */
|
||||
:deep(.chat-markdown a) {
|
||||
color: rgb(29 78 216);
|
||||
text-decoration: underline;
|
||||
text-underline-offset: 2px;
|
||||
}
|
||||
|
||||
:deep(.dark .chat-markdown a) {
|
||||
color: rgb(147 197 253);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown blockquote) {
|
||||
margin: 0.5em 0;
|
||||
padding: 0.125rem 0.875rem;
|
||||
border-left: 3px solid var(--border-default);
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown hr) {
|
||||
margin: 1em 0;
|
||||
border: 0;
|
||||
border-top: 1px solid var(--border-default);
|
||||
}
|
||||
|
||||
:deep(.chat-markdown .chat-mermaid-diagram) {
|
||||
max-width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferBacklogSummaryCard.spec.ts
|
||||
* 用途:锁定待处理异常卡「跨页全选」(Gmail 式,2026-10-22)交互契约。
|
||||
* 依赖:@vue/test-utils、i18n、vi.mock transfer.api / useMessage。
|
||||
* 逻辑:服务端分页下表头全选只覆盖当前页——未全选时透出「选择全部 N 行
|
||||
* (按当前筛选)」独立入口(testid=transfer-backlog-select-all-matching,
|
||||
* 与表头全选 checkbox 的 transfer-backlog-select-all 区分),点击按当前
|
||||
* keyword/resultFilter 拉全量 id 合并进勾选集合(批量条计数随之计入
|
||||
* 全量),全选后入口自动隐藏;API 失败经 useMessage 行内报错且不改
|
||||
* 勾选集合。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
|
||||
const fetchIds = vi.fn();
|
||||
const messageMocks = vi.hoisted(() => ({
|
||||
error: vi.fn(),
|
||||
success: vi.fn(),
|
||||
warning: vi.fn(),
|
||||
info: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => messageMocks,
|
||||
}));
|
||||
|
||||
vi.mock('../../api/transfer.api', async (importOriginal) => ({
|
||||
...(await importOriginal<object>()),
|
||||
fetchBacklogSelectableItemIds: (...args: unknown[]) => fetchIds(...args),
|
||||
}));
|
||||
|
||||
import i18n from '@/i18n';
|
||||
import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
|
||||
import type { TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
const mountOptions = { global: { plugins: [i18n] } };
|
||||
|
||||
/** 构造一行可恢复阻断行(status/result_code 决定可勾选与批量可用性)。 */
|
||||
const row = (id: number, invoice: string) => ({
|
||||
item_id: id,
|
||||
invoice_no: invoice,
|
||||
source_code: 'DBS-AWSBI',
|
||||
material_no: 'MAT-1',
|
||||
material_name: '物料',
|
||||
movement_date: '2026-10-01',
|
||||
lot_no: '',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
from_quantity: '1',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
to_quantity: '1',
|
||||
status: 'blocked_recoverable',
|
||||
result_code: 'blocked_quantity_mismatch',
|
||||
result_message: '',
|
||||
aging_level: 'normal',
|
||||
updated_at: '',
|
||||
});
|
||||
|
||||
describe('待处理异常卡跨页全选(Gmail 式)', () => {
|
||||
beforeEach(() => {
|
||||
fetchIds.mockReset();
|
||||
messageMocks.error.mockReset();
|
||||
});
|
||||
|
||||
it('未全选时透出「选择全部 N 行」,点击按当前筛选拉全量 id 合并勾选集合', async () => {
|
||||
// [断言意图] 服务端分页(当前页 2 行/总量 3 行)下表头全选只覆盖当前页;
|
||||
// 独立入口文案带全量计数;点击携带当前 keyword/resultFilter 拉取 id;
|
||||
// 合并后批量条计入全量勾选数,入口因「未选中行=0」自动隐藏(表头全选
|
||||
// checkbox 的 testid 不受影响)。
|
||||
fetchIds.mockResolvedValue({ ids: [11, 12, 13], total: 3, truncated: false });
|
||||
const wrapper = mount(TransferBacklogSummaryCard, {
|
||||
props: { items: [row(11, 'INV-1'), row(12, 'INV-2')], total: 3 },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
const link = wrapper.find('[data-testid="transfer-backlog-select-all-matching"]');
|
||||
expect(link.exists()).toBe(true);
|
||||
expect(link.text()).toContain('3');
|
||||
await link.trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
expect(fetchIds).toHaveBeenCalledWith({ keyword: '', resultFilter: 'all' });
|
||||
expect(
|
||||
wrapper.find('[data-testid="transfer-backlog-selected-count"]').text(),
|
||||
).toContain('3');
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('拉取失败行内报错且不改勾选集合;入口保持可重试', async () => {
|
||||
// [断言意图] API 异常不吞错(useMessage.error 透出)也不部分改写勾选集合
|
||||
//(批量条不出现);入口保留供重试。
|
||||
fetchIds.mockRejectedValue(new Error('backlog ids unavailable'));
|
||||
const wrapper = mount(TransferBacklogSummaryCard, {
|
||||
props: { items: [row(11, 'INV-1')], total: 2 },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
expect(messageMocks.error).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-selected-count"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-select-all-matching"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('调拨类型列显示当前语言名称', async () => {
|
||||
// [断言意图] 待恢复行展示出生匹配的类型名称,而不是只留仓库编码。
|
||||
const types: TransferTypeOption[] = [{
|
||||
code: 'in_transit_to_hub',
|
||||
names: { 'zh-CN': '在途仓至HUB仓', en: 'In-transit to HUB' },
|
||||
sort_order: 1,
|
||||
transform_rules: [],
|
||||
record_kinds: ['inbound'],
|
||||
}];
|
||||
const wrapper = mount(TransferBacklogSummaryCard, {
|
||||
props: {
|
||||
items: [{ ...row(11, 'INV-1'), transfer_type: 'in_transit_to_hub' }],
|
||||
total: 1,
|
||||
transferTypes: types,
|
||||
},
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-type-INV-1"]').text()).toBe('在途仓至HUB仓');
|
||||
});
|
||||
});
|
||||
@@ -1,42 +1,100 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferBacklogSummaryCard.vue
|
||||
用途:待处理异常卡(可恢复/已关闭/结果未知三组)——列与匹配窗口一致,
|
||||
支持关键字/结果筛选、多选批量操作(重查/恢复/关闭)与行级快捷操作。
|
||||
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
|
||||
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
|
||||
支持关键字/结果筛选、多选批量操作(重查库存/关闭)与行级快捷操作。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElSelect/ElOption/ElPagination/
|
||||
ElInput/ElButton/ElTag/ElCheckbox(2026-10-20:勾选列一并 EP;testid 挂
|
||||
el-checkbox,规格经内层 input 读写)、
|
||||
props.items(服务端返回的当前页切片)+ props.total(筛选后全量计数)、
|
||||
i18n chat.transfer.*、transferBatch.deriveBatchNo、transferFormat.formatQuantity。
|
||||
逻辑:2026-10-16 服务端分页 + 筛选下推(后端 GET /backlog page/page_size/
|
||||
keyword/result_filter)——本组件只持有筛选 UI 态并向父级上抛 query-change,
|
||||
由宿主经 useChatTransfer.loadBacklog 拉取当前页;行渲染/勾选/批量语义:
|
||||
仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
|
||||
可恢复行按 result_code 细分徽标(blocked_file_removed=文件已移除);
|
||||
blocked_file_removed 行行内仅留「关闭」(重查不可恢复——消失证据
|
||||
无法由重查翻回,唯一出口=人工关闭或等文件重新同步);
|
||||
批量按钮与行内按钮同用短文案键(重查/恢复/关闭,2026-10-12 文案一致化,
|
||||
完整语义经 title 悬浮),勾选计数保留;
|
||||
勾选集合为卡片本地态,操作经 emit 交父组件调用批量端点并刷新。
|
||||
blocked_file_removed 行行内仅留「关闭」(消失证据无法由重查翻回,
|
||||
唯一出口=人工关闭或等文件重新同步);
|
||||
批量与行内都只有「重查库存」和「关闭」。重查库存与恢复是同一次 ERP 核对,
|
||||
2026-10-22 起不再并列两个按钮。
|
||||
调拨类型列取行上 transfer_type,按启用类型配置显示当前语言名称。
|
||||
勾选集合跨页保留(翻页/筛选不清空;批量计数=勾选总数,后端逐行校验兜底);
|
||||
关键字 300ms 防抖后上抛,筛选/翻页变更即上抛,首挂载上抛初始切片查询
|
||||
(首页计数卡进入时 initialFilter 直接生效)。
|
||||
行定位:el-table 行不支持逐行 attr,行 testid 改经 row-class-name 注入
|
||||
(transfer-backlog-row-<invoice_no>,spec/e2e 用类选择器等价定位)。
|
||||
[2026-10-22 跨页全选] 服务端分页下表头全选只能覆盖当前页——Gmail 式补链:
|
||||
有勾选且未全选时透出「选择全部 N 行(按当前筛选)」,点击经
|
||||
GET /backlog/item-ids 按同一筛选口径拉全量 id 合并进勾选集合(批量端点
|
||||
按 item_ids 列表逐行校验,无需新批量契约);拉取失败经 useMessage 行内报错。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { CheckboxValueType } from 'element-plus';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { fetchBacklogSelectableItemIds } from '../../api/transfer.api';
|
||||
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import { formatQuantity } from './transferFormat';
|
||||
import type { TransferBacklogItem } from '../../types/transfer.types';
|
||||
import { transferTypeDisplay } from './transferTypeLabel';
|
||||
import type { TransferBacklogItem, TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 当前页行切片(服务端分页返回;筛选在服务端执行)。 */
|
||||
items: TransferBacklogItem[];
|
||||
/** 筛选后全量计数(分页器数据源;不传视为 0=隐藏分页条)。 */
|
||||
total?: number;
|
||||
busy?: boolean;
|
||||
/** 初始结果筛选(首页计数卡切片进入:closed 卡落「已关闭」切片等)。 */
|
||||
initialFilter?: 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
}>();
|
||||
/** 启用中的调拨类型。用来把行上的 code 显示成当前语言名称。 */
|
||||
transferTypes?: TransferTypeOption[];
|
||||
}>(), {
|
||||
transferTypes: () => [],
|
||||
});
|
||||
|
||||
const { locale } = useI18n();
|
||||
|
||||
/**
|
||||
* 把待处理行的调拨类型 code 显示成名称。
|
||||
* 核心逻辑:复用 transferTypeDisplay;没有类型时显示 —。
|
||||
* @param code - 行上的 transfer_type
|
||||
* @returns 当前语言名称、编码或占位
|
||||
*/
|
||||
function typeLabel(code: string | null | undefined): string {
|
||||
return transferTypeDisplay(code, props.transferTypes, locale.value);
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
refresh: [];
|
||||
retry: [itemId: number];
|
||||
resume: [itemIds: number[]];
|
||||
/** 行级与批量共用:按明细 id 重查 ERP 库存。 */
|
||||
requery: [itemIds: number[]];
|
||||
close: [item: TransferBacklogItem];
|
||||
batchClose: [itemIds: number[]];
|
||||
/** 查询变更(翻页/筛选/首挂载):宿主据此调用 loadBacklog 拉取对应页。 */
|
||||
'query-change': [query: { page: number; keyword: string; resultFilter: 'all' | 'recoverable' | 'closed' | 'unknown' }];
|
||||
}>();
|
||||
|
||||
/** 勾选集合(本地视图态;仅可恢复行可勾选)。 */
|
||||
/** 每页行数(与组合式函数 loadBacklog 默认 pageSize 同源:TRANSFER_PAGE_SIZE)。 */
|
||||
const PAGE_SIZE = TRANSFER_PAGE_SIZE;
|
||||
|
||||
/** 勾选集合(本地视图态;仅可恢复行可勾选;跨页保留——批量计数=勾选总数,
|
||||
* 行状态变化由后端批量端点逐行校验兜底)。 */
|
||||
const selectedIds = ref<Set<number>>(new Set());
|
||||
const keyword = ref('');
|
||||
const resultFilter = ref<'all' | 'recoverable' | 'closed' | 'unknown'>(props.initialFilter ?? 'all');
|
||||
const currentPage = ref(1);
|
||||
|
||||
function isActionable(item: TransferBacklogItem): boolean {
|
||||
return item.status === 'blocked_recoverable';
|
||||
@@ -50,27 +108,10 @@ function isFileRemoved(item: TransferBacklogItem): boolean {
|
||||
return item.result_code === 'blocked_file_removed';
|
||||
}
|
||||
|
||||
const filtered = computed(() =>
|
||||
props.items.filter((item) => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (kw) {
|
||||
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code]
|
||||
.map((value) => String(value ?? '').toLowerCase());
|
||||
if (!haystack.some((value) => value.includes(kw))) return false;
|
||||
}
|
||||
if (resultFilter.value === 'recoverable' && item.status !== 'blocked_recoverable') return false;
|
||||
if (resultFilter.value === 'closed' && item.status !== 'manually_closed') return false;
|
||||
if (resultFilter.value === 'unknown' && item.status !== 'result_unknown') return false;
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
|
||||
const selectedActionableIds = computed(() =>
|
||||
filtered.value.filter((item) => isActionable(item) && selectedIds.value.has(item.item_id)).map((item) => item.item_id),
|
||||
);
|
||||
const selectedActionableIds = computed(() => [...selectedIds.value]);
|
||||
|
||||
const allFilteredSelected = computed(() => {
|
||||
const actionable = filtered.value.filter(isActionable);
|
||||
const actionable = props.items.filter(isActionable);
|
||||
return actionable.length > 0 && actionable.every((item) => selectedIds.value.has(item.item_id));
|
||||
});
|
||||
|
||||
@@ -83,7 +124,7 @@ function toggleRow(item: TransferBacklogItem, checked: boolean) {
|
||||
|
||||
function toggleAll(checked: boolean) {
|
||||
const next = new Set(selectedIds.value);
|
||||
for (const item of filtered.value.filter(isActionable)) {
|
||||
for (const item of props.items.filter(isActionable)) {
|
||||
if (checked) next.add(item.item_id);
|
||||
else next.delete(item.item_id);
|
||||
}
|
||||
@@ -94,12 +135,68 @@ function clearSelection() {
|
||||
selectedIds.value = new Set();
|
||||
}
|
||||
|
||||
/** 行操作后/刷新后清理已消失行的勾选残留。 */
|
||||
function pruneSelection() {
|
||||
const alive = new Set(props.items.map((item) => item.item_id));
|
||||
selectedIds.value = new Set([...selectedIds.value].filter((id) => alive.has(id)));
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
/** 跨页全选拉取进行中(防重入)。 */
|
||||
const selectAllBusy = ref(false);
|
||||
|
||||
/** 跨页全选入口可见性:有筛选总量且勾选未覆盖全量时透出(选完后自动隐藏)。 */
|
||||
const showSelectAll = computed(() => (props.total ?? 0) > selectedIds.value.size);
|
||||
|
||||
/**
|
||||
* 跨页全选(Gmail 式,2026-10-22):按当前筛选拉取全部待处理明细 id 合并进勾选集合。
|
||||
* 服务端分页下表头全选只覆盖当前页;批量端点按 item_ids 列表逐行校验,全量 id 直接复用
|
||||
* (GET /backlog/item-ids,keyword/result_filter 与当前筛选同源)。
|
||||
*/
|
||||
async function selectAllMatching() {
|
||||
if (selectAllBusy.value) return;
|
||||
selectAllBusy.value = true;
|
||||
try {
|
||||
const data = await fetchBacklogSelectableItemIds({
|
||||
keyword: keyword.value,
|
||||
resultFilter: resultFilter.value,
|
||||
});
|
||||
selectedIds.value = new Set(data.ids.map((id) => Number(id)));
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
selectAllBusy.value = false;
|
||||
}
|
||||
}
|
||||
defineExpose({ pruneSelection });
|
||||
|
||||
// [STEP 1] 查询上抛:翻页/筛选立即上抛,关键字 300ms 防抖(服务端逐次查询防抖动);
|
||||
// 首挂载即上抛初始切片查询(宿主不再兜底首拉,避免双请求)。
|
||||
function emitQuery() {
|
||||
emit('query-change', { page: currentPage.value, keyword: keyword.value.trim(), resultFilter: resultFilter.value });
|
||||
}
|
||||
|
||||
watch(currentPage, () => emitQuery());
|
||||
|
||||
watch(resultFilter, () => {
|
||||
if (currentPage.value !== 1) currentPage.value = 1; // 翻页 watch 负责上抛
|
||||
else emitQuery();
|
||||
});
|
||||
|
||||
let keywordTimer: ReturnType<typeof setTimeout> | undefined;
|
||||
watch(keyword, () => {
|
||||
clearTimeout(keywordTimer);
|
||||
keywordTimer = setTimeout(() => {
|
||||
if (currentPage.value !== 1) currentPage.value = 1;
|
||||
else emitQuery();
|
||||
}, 300);
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => clearTimeout(keywordTimer));
|
||||
|
||||
onMounted(() => emitQuery());
|
||||
|
||||
// [STEP 2] 行操作/刷新后总行数变小:收拢当前页防空白页(越界时回落末页并重查)。
|
||||
watch(() => props.total, (total = 0) => {
|
||||
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
|
||||
if (currentPage.value > maxPage) {
|
||||
currentPage.value = maxPage; // 翻页 watch 负责上抛
|
||||
}
|
||||
});
|
||||
|
||||
function agingLabel(level: string): string {
|
||||
const map: Record<string, string> = {
|
||||
@@ -116,6 +213,16 @@ function rowKey(item: TransferBacklogItem): string {
|
||||
return `${item.item_id}|${item.invoice_no}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* el-table 行类:注入行定位类(替代旧行 testid)+ 不可操作行置灰(同旧行样式)。
|
||||
*/
|
||||
function rowClassName({ row }: { row: TransferBacklogItem }): string {
|
||||
return [
|
||||
`transfer-backlog-row-${row.invoice_no}`,
|
||||
isActionable(row) ? '' : 'bg-surface-soft text-muted',
|
||||
].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
/** 结果徽标文案键:可恢复行按 result_code 细分(blocked_file_removed=文件已移除),其余按状态。 */
|
||||
function resultLabelKey(item: TransferBacklogItem): string {
|
||||
if (item.status === 'result_unknown') return 'chat.transfer.resultUnknown';
|
||||
@@ -130,201 +237,236 @@ function resultLabelKey(item: TransferBacklogItem): string {
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface 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-primary">{{ $t('chat.transfer.backlogTitle') }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-backlog-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区 -->
|
||||
<!-- 跨页全选入口(Gmail 式,2026-10-22):服务端分页下表头全选只覆盖当前页,
|
||||
有未选中行时透出「选择全部 N 行」,按当前筛选拉全量 id 合并进勾选集合
|
||||
(testid 独立于表头全选 checkbox 的 transfer-backlog-select-all) -->
|
||||
<div v-if="showSelectAll" class="mb-2 text-xs">
|
||||
<button
|
||||
type="button"
|
||||
class="text-secondary underline decoration-dotted underline-offset-2 disabled:opacity-50"
|
||||
:disabled="selectAllBusy"
|
||||
data-testid="transfer-backlog-select-all-matching"
|
||||
@click="selectAllMatching"
|
||||
>{{ $t('chat.transfer.selectAllRows', { count: total ?? 0 }) }}</button>
|
||||
</div>
|
||||
|
||||
<!-- 批量操作条:勾选 ≥1 行时原位替换筛选区(跨页勾选同样计入) -->
|
||||
<div v-if="selectedActionableIds.length" class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span class="text-xs font-bold text-secondary" data-testid="transfer-backlog-selected-count">
|
||||
{{ $t('chat.transfer.selectedRows', { count: selectedActionableIds.length }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
data-testid="transfer-backlog-batch-requery"
|
||||
:disabled="busy"
|
||||
@click="emit('requery', selectedActionableIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-backlog-batch-resume"
|
||||
:disabled="busy"
|
||||
:title="$t('chat.transfer.resumeAction')"
|
||||
@click="emit('resume', selectedActionableIds)"
|
||||
>
|
||||
<!-- [2026-10-12 文案一致化] 批量按钮与行内按钮同用短文案键(恢复/关闭),
|
||||
勾选计数保留;完整语义经 title 悬浮透出(与行内按钮同模式) -->
|
||||
{{ $t('chat.transfer.resumeActionShort') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-red-200 bg-red-50 px-3 py-1 text-xs font-bold text-red-600 transition hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
{{ $t('chat.transfer.requeryStock') }}({{ selectedActionableIds.length }})
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
plain
|
||||
data-testid="transfer-backlog-batch-close"
|
||||
:disabled="busy"
|
||||
:title="$t('chat.transfer.manualClose')"
|
||||
@click="emit('batchClose', selectedActionableIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualCloseShort') }}({{ selectedActionableIds.length }})
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-backlog-clear-selection"
|
||||
@click="clearSelection"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSelection') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
<div v-else class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="w-56 rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-backlog-filter"
|
||||
/>
|
||||
<select
|
||||
v-model="resultFilter"
|
||||
class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
data-testid="transfer-backlog-result-filter"
|
||||
>
|
||||
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
|
||||
<option value="recoverable">{{ $t('chat.transfer.homeRecoverable') }}</option>
|
||||
<option value="closed">{{ $t('chat.transfer.homeClosed') }}</option>
|
||||
<option value="unknown">{{ $t('chat.transfer.homeUnknown') }}</option>
|
||||
</select>
|
||||
<div class="w-56 shrink-0">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
size="small"
|
||||
clearable
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-backlog-filter"
|
||||
/>
|
||||
</div>
|
||||
<!-- el-select 默认 width:100%(EP 样式会覆盖工具类),外包定宽容器锁定紧凑尺寸,
|
||||
与关键字输入并排一行,避免筛选区独占两行 -->
|
||||
<div class="w-32 shrink-0">
|
||||
<el-select
|
||||
v-model="resultFilter"
|
||||
size="small"
|
||||
data-testid="transfer-backlog-result-filter"
|
||||
:aria-label="$t('chat.transfer.colResult')"
|
||||
>
|
||||
<el-option value="all" :label="$t('chat.transfer.filterAll')" />
|
||||
<el-option value="recoverable" :label="$t('chat.transfer.homeRecoverable')" />
|
||||
<el-option value="closed" :label="$t('chat.transfer.homeClosed')" />
|
||||
<el-option value="unknown" :label="$t('chat.transfer.homeUnknown')" />
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="filtered.length" class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1360px] text-xs" data-testid="transfer-backlog-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
|
||||
<th class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allFilteredSelected"
|
||||
data-testid="transfer-backlog-select-all"
|
||||
@change="toggleAll(($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</th>
|
||||
<!-- 表头全列 nowrap:防「拨出仓库/匹配结果」等折行;品名列吃剩余宽度 -->
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAging') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAction') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in filtered"
|
||||
:key="rowKey(item)"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': !isActionable(item) }"
|
||||
:data-testid="`transfer-backlog-${item.invoice_no}`"
|
||||
<!-- EP 表格:show-overflow-tooltip;左固定勾选,右固定结果+操作;单号/老化可滚 -->
|
||||
<el-table
|
||||
v-if="items.length"
|
||||
:data="items"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-backlog-table"
|
||||
>
|
||||
<el-table-column fixed width="48">
|
||||
<template #header>
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="allFilteredSelected"
|
||||
data-testid="transfer-backlog-select-all"
|
||||
@change="(val: CheckboxValueType) => toggleAll(Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="selectedIds.has(row.item_id)"
|
||||
:disabled="!isActionable(row as TransferBacklogItem) || busy"
|
||||
:data-testid="`transfer-backlog-check-${row.invoice_no}`"
|
||||
@change="(val: CheckboxValueType) => toggleRow(row as TransferBacklogItem, Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span :data-testid="`transfer-backlog-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
|
||||
prop="invoice_no"
|
||||
min-width="130"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold">{{ row.invoice_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
|
||||
min-width="130"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-backlog-external-doc">{{ row.external_doc_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.material_name || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.from_warehouse || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ deriveBatchNo(row.lot_no ?? '') || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="90" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatQuantity(row.external_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToWarehouse')" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.to_warehouse || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatQuantity(row.movement_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colAging')" min-width="90" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ $t(agingLabel(row.aging_level)) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
:label="$t('chat.transfer.colResult')"
|
||||
width="100"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="light"
|
||||
:type="row.status === 'blocked_recoverable' ? 'danger' : row.status === 'result_unknown' ? 'warning' : 'info'"
|
||||
:title="row.reason || undefined"
|
||||
data-testid="transfer-backlog-result"
|
||||
>
|
||||
<td class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="selectedIds.has(item.item_id)"
|
||||
:disabled="!isActionable(item) || busy"
|
||||
:data-testid="`transfer-backlog-check-${item.invoice_no}`"
|
||||
@change="toggleRow(item, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行;
|
||||
操作列三按钮保持一行 -->
|
||||
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
|
||||
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.from_warehouse || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.external_quantity) }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.to_warehouse || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.receipt_quantity) }}</td>
|
||||
<td class="p-2">
|
||||
<span
|
||||
class="whitespace-nowrap rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-red-50 text-red-700': item.status === 'blocked_recoverable',
|
||||
'bg-amber-50 text-amber-700': item.status === 'result_unknown',
|
||||
'bg-surface-soft text-muted': item.status === 'manually_closed',
|
||||
}"
|
||||
:title="item.reason || undefined"
|
||||
data-testid="transfer-backlog-result"
|
||||
>
|
||||
{{
|
||||
$t(resultLabelKey(item))
|
||||
}}
|
||||
</span>
|
||||
</td>
|
||||
<td class="whitespace-nowrap p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
|
||||
<td class="whitespace-nowrap p-2">
|
||||
<template v-if="isActionable(item)">
|
||||
<!-- 失效行(文件已移除)隐藏重查/恢复处理:重查会被后端拒绝
|
||||
(TRANSFER.RETRY_NOT_ALLOWED),恢复处理也无济于事,只留关闭出口 -->
|
||||
<button
|
||||
v-if="!isFileRemoved(item)"
|
||||
type="button"
|
||||
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-backlog-requery-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('retry', item.item_id)"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="!isFileRemoved(item)"
|
||||
type="button"
|
||||
class="mr-1 rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:title="$t('chat.transfer.resumeAction')"
|
||||
:data-testid="`transfer-backlog-resume-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('resume', [item.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.resumeActionShort') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-1 py-0.5 text-[10px] font-bold text-red-600 transition hover:bg-red-50 disabled:opacity-40"
|
||||
:title="$t('chat.transfer.manualClose')"
|
||||
:data-testid="`transfer-backlog-close-${item.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('close', item)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualCloseShort') }}
|
||||
</button>
|
||||
</template>
|
||||
<span v-else-if="item.status === 'result_unknown'" class="text-[11px] text-muted">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ $t(resultLabelKey(row as TransferBacklogItem)) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
:label="$t('chat.transfer.colAction')"
|
||||
width="150"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<template v-if="isActionable(row as TransferBacklogItem)">
|
||||
<!-- 失效行(文件已移除)只留关闭:重查会被后端拒绝(TRANSFER.RETRY_NOT_ALLOWED)。 -->
|
||||
<el-button
|
||||
v-if="!isFileRemoved(row as TransferBacklogItem)"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:data-testid="`transfer-backlog-requery-${row.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('requery', [row.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryStock') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
size="small"
|
||||
:title="$t('chat.transfer.manualClose')"
|
||||
:data-testid="`transfer-backlog-close-${row.invoice_no}`"
|
||||
:disabled="busy"
|
||||
@click="emit('close', row as TransferBacklogItem)"
|
||||
>
|
||||
{{ $t('chat.transfer.manualCloseShort') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<span v-else-if="row.status === 'result_unknown'" class="text-[11px] text-muted">
|
||||
{{ $t('chat.transfer.resultUnknownReadonly') }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.noBacklog') }}
|
||||
</div>
|
||||
<!-- 服务端分页条(单页时隐藏):total=筛选后全量计数;文案走全局 ElConfigProvider 四语言 -->
|
||||
<el-pagination
|
||||
v-if="(total ?? 0) > PAGE_SIZE"
|
||||
:current-page="currentPage"
|
||||
:total="total ?? 0"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-backlog-pagination"
|
||||
@current-change="(page: number) => { currentPage = page }"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferExecutableCard.spec.ts
|
||||
* 用途:验证可调拨明细卡的客户端分页——50/页切片渲染、翻页余量、
|
||||
* 关键字筛选变更重置回第 1 页(防"停在末页筛选后空白")。
|
||||
* 依赖:@vue/test-utils、i18n、Element Plus(el-table / el-input)。
|
||||
* 逻辑:分页为纯渲染切片,勾选/批量语义不在本套件(由 MessageView 接线覆盖);
|
||||
* EP el-table 行槽位需 flush 后才可数行;筛选经 ElInput setValue。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import TransferExecutableCard from './TransferExecutableCard.vue';
|
||||
import type { TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
// EP el-table 在 jsdom 挂载较重,与 MessageView/Match 同口径放宽到 30s。
|
||||
vi.setConfig({ testTimeout: 30000 });
|
||||
|
||||
function makeItems(count: number) {
|
||||
return Array.from({ length: count }, (_, i) => ({
|
||||
item_id: i + 1,
|
||||
source_code: 'DBS-AWSBI',
|
||||
material_no: `MAT-${i + 1}`,
|
||||
material_name: '物料',
|
||||
specification: '',
|
||||
invoice_no: `INV-${String(i + 1).padStart(3, '0')}`,
|
||||
movement_date: '2026-09-01',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
from_quantity: '1',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
to_quantity: '1',
|
||||
result: 'executable',
|
||||
lot_no: 'LOT-1',
|
||||
}));
|
||||
}
|
||||
|
||||
/** 挂载可调拨卡并 flush:el-table 行槽位在 jsdom 下需等下一拍。 */
|
||||
async function mountCard(items: ReturnType<typeof makeItems>) {
|
||||
const wrapper = mount(TransferExecutableCard, {
|
||||
props: { items },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
function bodyRows(wrapper: Awaited<ReturnType<typeof mountCard>>) {
|
||||
return wrapper.findAll('.el-table__body tbody tr');
|
||||
}
|
||||
|
||||
describe('TransferExecutableCard 客户端分页', () => {
|
||||
it('55 行只渲染首页 50 行,翻页渲染余量 5 行', async () => {
|
||||
const wrapper = await mountCard(makeItems(55));
|
||||
// [断言意图] 首页切片=50 行(非全量 55),DOM 规模被页大小约束。
|
||||
expect(bodyRows(wrapper)).toHaveLength(50);
|
||||
await wrapper.find('.btn-next').trigger('click');
|
||||
await flushPromises();
|
||||
expect(bodyRows(wrapper)).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('关键字筛选变更重置回第 1 页(末页筛选不再空白)', async () => {
|
||||
// [断言意图] 停在第 2 页(余量 5 行)时输入关键字:命中 11 行
|
||||
// (MAT-1、MAT-10~19),若未重置页码则第 2 页切片为空——行数断言同时锁两件事。
|
||||
const wrapper = await mountCard(makeItems(55));
|
||||
await wrapper.find('.btn-next').trigger('click');
|
||||
expect(bodyRows(wrapper)).toHaveLength(5);
|
||||
const filter = wrapper.findComponent({ name: 'ElInput' });
|
||||
expect(filter.exists()).toBe(true);
|
||||
await filter.setValue('MAT-1');
|
||||
await flushPromises();
|
||||
expect(bodyRows(wrapper)).toHaveLength(11);
|
||||
});
|
||||
|
||||
it('调拨类型列显示当前语言名称,没有类型时显示占位', async () => {
|
||||
// [断言意图] 可调拨明细不能只靠仓库编码辨认类别:有 code 且配置里有名称时
|
||||
// 显示中文名;没有 code 时显示 —。
|
||||
const types: TransferTypeOption[] = [{
|
||||
code: 'in_transit_to_hub',
|
||||
names: { 'zh-CN': '在途仓至HUB仓', en: 'In-transit to HUB' },
|
||||
sort_order: 1,
|
||||
transform_rules: [],
|
||||
record_kinds: ['inbound'],
|
||||
}];
|
||||
const items = makeItems(1);
|
||||
items[0].invoice_no = 'INV-TYPE';
|
||||
const typed = { ...items[0], transfer_type: 'in_transit_to_hub' };
|
||||
const blank = { ...makeItems(1)[0], item_id: 2, invoice_no: 'INV-NONE', transfer_type: '' };
|
||||
const wrapper = mount(TransferExecutableCard, {
|
||||
props: { items: [typed, blank], transferTypes: types },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-executable-type-INV-TYPE"]').text()).toBe('在途仓至HUB仓');
|
||||
expect(wrapper.find('[data-testid="transfer-executable-type-INV-NONE"]').text()).toBe('—');
|
||||
});
|
||||
});
|
||||
@@ -1,22 +1,57 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferExecutableCard.vue
|
||||
用途:可调拨明细卡——全局可执行行队列(跨匹配范围):勾选明细行后按行生成调拨单。
|
||||
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
|
||||
逻辑:行由后端按业务稳定键排序(收料日期→Invoice→创建时间);勾选为卡片本地态;
|
||||
stale/file_current 行置灰提示(执行门禁在后端,失败经 BusinessError 展示);
|
||||
无 item_id 的历史回放行禁选。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElInput/ElButton/ElTag/ElPagination/
|
||||
ElCheckbox/ElAlert、props.items、i18n chat.transfer.*、transferBatch /
|
||||
transferItemTable(明细表密度约定)。
|
||||
逻辑:行由后端按业务稳定键排序;勾选本地态;无 item_id 历史行禁选;50/页分页。
|
||||
表格遵循 transferItemTable:show-overflow-tooltip、左固定勾选、右固定结果+操作、
|
||||
单号可滚、库存数量与查询时刻同行、过期用顶栏 el-alert 汇总批量重查。
|
||||
行定位:row-class-name 注入 transfer-executable-<invoice_no>。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElInput,
|
||||
ElPagination,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { CheckboxValueType } from 'element-plus';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import { formatQuantity } from './transferFormat';
|
||||
import { parseApiUtcDate } from '@/shared/utils/dateTime';
|
||||
import type { TransferMatchingItem } from '../../types/transfer.types';
|
||||
import {
|
||||
formatStockQuantityCell,
|
||||
freshnessHint,
|
||||
} from './transferItemTable';
|
||||
import { transferTypeDisplay } from './transferTypeLabel';
|
||||
import type { TransferMatchingItem, TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
const props = defineProps<{
|
||||
const props = withDefaults(defineProps<{
|
||||
items: TransferMatchingItem[];
|
||||
busy?: boolean;
|
||||
}>();
|
||||
/** 启用中的调拨类型。用来把行上的 code 显示成当前语言名称。 */
|
||||
transferTypes?: TransferTypeOption[];
|
||||
}>(), {
|
||||
transferTypes: () => [],
|
||||
});
|
||||
|
||||
const { locale, t } = useI18n();
|
||||
|
||||
/**
|
||||
* 把可执行行的调拨类型 code 显示成名称。
|
||||
* 核心逻辑:复用 transferTypeDisplay;没有类型时显示 —。
|
||||
* @param code - 行上的 transfer_type
|
||||
* @returns 当前语言名称、编码或占位
|
||||
*/
|
||||
function typeLabel(code: string | null | undefined): string {
|
||||
return transferTypeDisplay(code, props.transferTypes, locale.value);
|
||||
}
|
||||
|
||||
const emit = defineEmits<{
|
||||
refresh: [];
|
||||
@@ -24,20 +59,36 @@ const emit = defineEmits<{
|
||||
requery: [itemIds: number[]];
|
||||
}>();
|
||||
|
||||
/** 勾选集合(本地视图态,按明细行 item_id)。 */
|
||||
/** 勾选集合(本地视图态,按明细行 item_id;跨页保留——批量计数按全量过滤行)。 */
|
||||
const selectedIds = ref<Set<number>>(new Set());
|
||||
const keyword = ref('');
|
||||
|
||||
/** 客户端分页(50/页):可执行池量级小但无硬上限,切片渲染防 DOM 失控。 */
|
||||
const PAGE_SIZE = 50;
|
||||
const currentPage = ref(1);
|
||||
|
||||
const filtered = computed(() =>
|
||||
props.items.filter((item) => {
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (!kw) return true;
|
||||
const haystack = [item.invoice_no, item.material_no, item.material_name, item.source_code, item.lot_no]
|
||||
const haystack = [item.invoice_no, item.external_doc_no, item.material_no, item.material_name, item.source_code, item.lot_no]
|
||||
.map((value) => String(value ?? '').toLowerCase());
|
||||
return haystack.some((value) => value.includes(kw));
|
||||
}),
|
||||
);
|
||||
|
||||
const pagedItems = computed(() =>
|
||||
filtered.value.slice((currentPage.value - 1) * PAGE_SIZE, currentPage.value * PAGE_SIZE),
|
||||
);
|
||||
|
||||
watch(keyword, () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
watch(() => filtered.value.length, (len) => {
|
||||
const maxPage = Math.max(1, Math.ceil(len / PAGE_SIZE));
|
||||
if (currentPage.value > maxPage) currentPage.value = maxPage;
|
||||
});
|
||||
|
||||
const checked = computed(() =>
|
||||
filtered.value.filter((item) => item.item_id != null && selectedIds.value.has(item.item_id)),
|
||||
);
|
||||
@@ -46,6 +97,13 @@ const allFilteredSelected = computed(() =>
|
||||
filtered.value.length > 0 && filtered.value.every((item) => item.item_id != null && selectedIds.value.has(item.item_id)),
|
||||
);
|
||||
|
||||
/** 当前筛选下库存已过期且可重查的行 id。 */
|
||||
const staleItemIds = computed(() =>
|
||||
filtered.value
|
||||
.filter((item) => item.stale === true && item.item_id != null)
|
||||
.map((item) => item.item_id as number),
|
||||
);
|
||||
|
||||
function toggleRow(item: TransferMatchingItem, checkedBox: boolean) {
|
||||
if (item.item_id == null) return;
|
||||
const next = new Set(selectedIds.value);
|
||||
@@ -72,12 +130,33 @@ function rowKey(item: TransferMatchingItem): string {
|
||||
return `${item.item_id ?? 'na'}|${item.invoice_no}`;
|
||||
}
|
||||
|
||||
/** 查询时刻展示(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
|
||||
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);无 checked_at 不渲染。 */
|
||||
function checkedTime(item: TransferMatchingItem): string {
|
||||
if (!item.checked_at) return '';
|
||||
const date = parseApiUtcDate(item.checked_at);
|
||||
return Number.isNaN(date.getTime()) ? '' : date.toTimeString().slice(0, 5);
|
||||
/**
|
||||
* el-table 行类:注入行定位类 + stale/文件过期置灰。
|
||||
* @param row 可执行明细行
|
||||
* @returns 空格分隔的 class 串
|
||||
*/
|
||||
function rowClassName({ row }: { row: TransferMatchingItem }): string {
|
||||
return [
|
||||
`transfer-executable-${row.invoice_no}`,
|
||||
row.stale || row.file_current === false ? 'bg-surface-soft text-muted' : '',
|
||||
].filter(Boolean).join(' ');
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存数量单元格:数量与完整查询时刻同一行。
|
||||
* @param item 可执行明细行
|
||||
*/
|
||||
function stockCell(item: TransferMatchingItem): string {
|
||||
return formatStockQuantityCell(formatQuantity(item.from_quantity), item.checked_at);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量重查当前筛选下全部过期行。
|
||||
* 核心逻辑:顶栏汇总入口,避免结果列刷长文案。
|
||||
*/
|
||||
function requeryStaleRows() {
|
||||
if (!staleItemIds.value.length) return;
|
||||
emit('requery', [...staleItemIds.value]);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -85,133 +164,199 @@ function checkedTime(item: TransferMatchingItem): string {
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-executable-card">
|
||||
<div class="mb-2 flex items-center justify-between">
|
||||
<h3 class="text-sm font-bold text-primary">{{ $t('chat.transfer.executableTitle') }}</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-executable-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="staleItemIds.length"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
class="mb-2"
|
||||
data-testid="transfer-executable-stale-banner"
|
||||
>
|
||||
<template #title>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span>{{ $t('chat.transfer.staleBanner', { count: staleItemIds.length }) }}</span>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-executable-requery-stale"
|
||||
@click="requeryStaleRows"
|
||||
>
|
||||
{{ $t('chat.transfer.staleBannerRequery') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="w-56 rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-executable-filter"
|
||||
/>
|
||||
<div class="w-56 shrink-0">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
size="small"
|
||||
clearable
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-executable-filter"
|
||||
/>
|
||||
</div>
|
||||
<span v-if="checked.length" class="text-xs font-bold text-secondary" data-testid="transfer-executable-selected-count">
|
||||
{{ $t('chat.transfer.selectedRows', { count: checked.length }) }}
|
||||
</span>
|
||||
<button
|
||||
<el-button
|
||||
v-if="checked.length"
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 text-xs text-secondary hover-surface-soft"
|
||||
size="small"
|
||||
data-testid="transfer-executable-clear-selection"
|
||||
@click="clearSelection"
|
||||
>
|
||||
{{ $t('chat.transfer.clearSelection') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div v-if="filtered.length" class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1240px] text-xs" data-testid="transfer-executable-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
|
||||
<th class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allFilteredSelected"
|
||||
data-testid="transfer-executable-select-all"
|
||||
@change="toggleAll(($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</th>
|
||||
<!-- 表头全列 nowrap:防「拨出仓库/投入数量」等折行;品名列吃剩余宽度 -->
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colAction') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in filtered"
|
||||
:key="rowKey(item)"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': item.stale || item.file_current === false }"
|
||||
:data-testid="`transfer-executable-${item.invoice_no}`"
|
||||
<el-table
|
||||
v-if="filtered.length"
|
||||
:data="pagedItems"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-executable-table"
|
||||
>
|
||||
<el-table-column fixed width="48">
|
||||
<template #header>
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="allFilteredSelected"
|
||||
data-testid="transfer-executable-select-all"
|
||||
@change="(val: CheckboxValueType) => toggleAll(Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="row.item_id != null && selectedIds.has(row.item_id)"
|
||||
:disabled="row.item_id == null || busy"
|
||||
:data-testid="`transfer-executable-check-${row.invoice_no}`"
|
||||
@change="(val: CheckboxValueType) => toggleRow(row as TransferMatchingItem, Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.transferTypeLabel')" min-width="140" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span :data-testid="`transfer-executable-type-${row.invoice_no}`">{{ typeLabel(row.transfer_type) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
|
||||
prop="invoice_no"
|
||||
min-width="130"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold">{{ row.invoice_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
|
||||
min-width="130"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-executable-external-doc">{{ row.external_doc_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" prop="from_warehouse" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ deriveBatchNo(row.lot_no ?? '') || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="168" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span
|
||||
:class="row.stale ? 'text-amber-700' : undefined"
|
||||
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
|
||||
:data-testid="`transfer-executable-stock-${row.invoice_no}`"
|
||||
>
|
||||
<td class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="item.item_id != null && selectedIds.has(item.item_id)"
|
||||
:disabled="item.item_id == null || busy"
|
||||
:data-testid="`transfer-executable-check-${item.invoice_no}`"
|
||||
@change="toggleRow(item, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行 -->
|
||||
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
|
||||
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.from_warehouse }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no ?? '') || '—' }}</td>
|
||||
<td class="p-2">
|
||||
{{ formatQuantity(item.from_quantity) }}
|
||||
<div v-if="checkedTime(item)" class="text-[10px] text-muted">{{ checkedTime(item) }}</div>
|
||||
</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.to_warehouse }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.to_quantity) }}</td>
|
||||
<td class="p-2">
|
||||
<span class="whitespace-nowrap rounded-full bg-emerald-50 px-2 py-0.5 font-bold text-emerald-700" data-testid="transfer-executable-result">
|
||||
{{ $t('chat.transfer.resultExecutable') }}
|
||||
</span>
|
||||
<div v-if="item.stale" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.staleRow') }}</div>
|
||||
<div v-else-if="item.file_current === false" class="mt-0.5 text-[10px] text-amber-600">{{ $t('chat.transfer.fileChangedRow') }}</div>
|
||||
</td>
|
||||
<td class="p-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-brand-200 px-1 py-0.5 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-executable-requery-${item.invoice_no}`"
|
||||
:disabled="busy || item.item_id == null"
|
||||
@click="item.item_id != null && emit('requery', [item.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div v-else class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-executable-empty">
|
||||
{{ stockCell(row as TransferMatchingItem) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToWarehouse')" prop="to_warehouse" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatQuantity(row.to_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
:label="$t('chat.transfer.colResult')"
|
||||
width="88"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-tag
|
||||
size="small"
|
||||
type="success"
|
||||
effect="light"
|
||||
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
|
||||
data-testid="transfer-executable-result"
|
||||
>
|
||||
{{ $t('chat.transfer.resultExecutable') }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
:label="$t('chat.transfer.colAction')"
|
||||
width="72"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:data-testid="`transfer-executable-requery-${row.invoice_no}`"
|
||||
:disabled="busy || row.item_id == null"
|
||||
@click="row.item_id != null && emit('requery', [row.item_id])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="filtered.length > PAGE_SIZE"
|
||||
v-model:current-page="currentPage"
|
||||
:total="filtered.length"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-executable-pagination"
|
||||
/>
|
||||
<div v-else-if="!filtered.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-executable-empty">
|
||||
{{ $t('chat.transfer.executableEmpty') }}
|
||||
</div>
|
||||
|
||||
<div class="mt-3 flex items-center justify-end gap-3 border-t border-subtle pt-3">
|
||||
<span class="text-xs text-muted">{{ $t('chat.transfer.executableSelectedCount', { count: checked.length }) }}</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"
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="busy || checked.length === 0"
|
||||
data-testid="transfer-executable-generate"
|
||||
@click="emit('execute', checked.map((item) => item.item_id as number))"
|
||||
>
|
||||
{{ $t('chat.transfer.generateTransfer') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -3,13 +3,15 @@
|
||||
|
||||
用途:首页「已执行调拨单」统计卡片入口——四张数字卡片(风格对齐待办看板),
|
||||
点击 emit('open', group) 由首页面板跳转明细列表子视图。
|
||||
依赖:fetchExecutedOrders(transfer.api)、vue-i18n。
|
||||
依赖:Element Plus ElCard(2026-10-20:多行统计卡用 el-card 可点,禁 el-button
|
||||
包多行——内部 flex 会压扁导致重叠)、fetchExecutedOrders、vue-i18n。
|
||||
逻辑:挂载拉取分组计数(pageSize=1,列表不消费);计数恒全量由后端保证;
|
||||
纯入口组件,不含列表/动作。
|
||||
-->
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { ElCard } from 'element-plus';
|
||||
import { fetchExecutedOrders } from '@/features/chat/api/transfer.api';
|
||||
|
||||
type TransferOrderGroups = Record<'success' | 'failed' | 'executing' | 'result_unknown', number>;
|
||||
@@ -19,11 +21,11 @@ const emit = defineEmits<{ (e: 'open', group: 'success' | 'failed' | 'executing'
|
||||
const groups = ref<TransferOrderGroups>({ success: 0, failed: 0, executing: 0, result_unknown: 0 });
|
||||
|
||||
/** 统计卡片定义(键对齐 i18n homeExecuted.group.* 与 groupHint.*;配色对齐待办看板与行级徽标)。 */
|
||||
const GROUP_CARDS: Array<{ key: string; group: keyof TransferOrderGroups; cls: string; numCls: string }> = [
|
||||
{ key: 'success', group: 'success', cls: 'border-emerald-200 bg-emerald-50 hover:bg-emerald-100', numCls: 'text-emerald-600' },
|
||||
{ key: 'failed', group: 'failed', cls: 'border-red-200 bg-red-50 hover:bg-red-100', numCls: 'text-red-600' },
|
||||
{ key: 'executing', group: 'executing', cls: 'border-brand-200 bg-brand-50 hover:bg-brand-100', numCls: 'text-brand-600' },
|
||||
{ key: 'resultUnknown', group: 'result_unknown', cls: 'border-amber-200 bg-amber-50 hover:bg-amber-100', numCls: 'text-amber-600' },
|
||||
const GROUP_CARDS: Array<{ key: string; group: keyof TransferOrderGroups; cardCls: string; numCls: string }> = [
|
||||
{ key: 'success', group: 'success', cardCls: '!border-emerald-200 !bg-emerald-50', numCls: 'text-emerald-600' },
|
||||
{ key: 'failed', group: 'failed', cardCls: '!border-red-200 !bg-red-50', numCls: 'text-red-600' },
|
||||
{ key: 'executing', group: 'executing', cardCls: '!border-brand-200 !bg-brand-50', numCls: 'text-brand-600' },
|
||||
{ key: 'resultUnknown', group: 'result_unknown', cardCls: '!border-amber-200 !bg-amber-50', numCls: 'text-amber-600' },
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -45,18 +47,22 @@ onMounted(() => { void load(); });
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-2 gap-3 lg:grid-cols-4">
|
||||
<button
|
||||
<el-card
|
||||
v-for="card in GROUP_CARDS"
|
||||
:key="card.key"
|
||||
type="button"
|
||||
class="rounded-2xl border p-4 text-left transition-colors"
|
||||
:class="card.cls"
|
||||
shadow="hover"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
class="cursor-pointer !rounded-2xl"
|
||||
:class="card.cardCls"
|
||||
:body-style="{ padding: '1rem' }"
|
||||
:data-testid="`transfer-executed-card-${card.key}`"
|
||||
@click="emit('open', card.group)"
|
||||
@keydown.enter.prevent="emit('open', card.group)"
|
||||
>
|
||||
<b class="block text-2xl leading-none tabular-nums" :class="card.numCls">{{ groups[card.group] }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t(`chat.transfer.homeExecuted.group.${card.key}`) }}</b>
|
||||
<span class="mt-1 block text-xs text-secondary">{{ $t(`chat.transfer.homeExecuted.groupHint.${card.key}`) }}</span>
|
||||
</button>
|
||||
</el-card>
|
||||
</div>
|
||||
</template>
|
||||
@@ -29,7 +29,7 @@ const FAILED_TICKET = {
|
||||
submit_timestamp: '2026-08-06 09:00:00',
|
||||
status: 'business_failed',
|
||||
status_group: 'failed',
|
||||
receipt_date: '2026-08-05',
|
||||
movement_date: '2026-08-05',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
erp_document_no: null,
|
||||
@@ -47,7 +47,7 @@ const UNKNOWN_TICKET = {
|
||||
submit_timestamp: '2026-08-06 10:00:00',
|
||||
status: 'result_unknown',
|
||||
status_group: 'result_unknown',
|
||||
receipt_date: '2026-08-05',
|
||||
movement_date: '2026-08-05',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN02',
|
||||
erp_document_no: null,
|
||||
@@ -97,7 +97,7 @@ describe('TransferExecutedOrders 已执行明细列表子视图', () => {
|
||||
// [断言意图] 单行渲染存在性(排序为后端 created_at 倒序契约)。
|
||||
expect(wrapper.find('[data-testid="transfer-executed-order-D-FAIL-1"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-executed-order-D-UNK-1"]').exists()).toBe(true);
|
||||
});
|
||||
}, 30_000);
|
||||
|
||||
it('initialGroup 初始筛选 + [全部] 清筛选重拉 + [返回] emit back', async () => {
|
||||
const wrapper = mountList('failed');
|
||||
@@ -115,22 +115,24 @@ describe('TransferExecutedOrders 已执行明细列表子视图', () => {
|
||||
// [断言意图] 返回=emit('back'),由首页面板切回卡片视图。
|
||||
await wrapper.find('[data-testid="transfer-executed-back"]').trigger('click');
|
||||
expect(wrapper.emitted('back')).toBeTruthy();
|
||||
});
|
||||
}, 30_000);
|
||||
|
||||
it('日期范围变更带参重拉(dateFrom/dateTo + page=1;仅筛列表,计数恒全量由后端保证)', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-executed-date-from"]').setValue('2026-09-01');
|
||||
const from = wrapper.find('[data-testid="transfer-executed-date-from"]').findComponent({ name: 'ElDatePicker' });
|
||||
const to = wrapper.find('[data-testid="transfer-executed-date-to"]').findComponent({ name: 'ElDatePicker' });
|
||||
await from.setValue('2026-09-01');
|
||||
await flushPromises();
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ dateFrom: '2026-09-01', page: 1 }),
|
||||
);
|
||||
await wrapper.find('[data-testid="transfer-executed-date-to"]').setValue('2026-09-30');
|
||||
await to.setValue('2026-09-30');
|
||||
await flushPromises();
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ dateFrom: '2026-09-01', dateTo: '2026-09-30', page: 1 }),
|
||||
);
|
||||
});
|
||||
}, 30_000);
|
||||
|
||||
it('分页:下一页带 page=2 重拉,首页时上一页禁用', async () => {
|
||||
// 后端契约:page 请求参数原样回显(response.page=请求页),mock 同口径。
|
||||
|
||||
@@ -6,20 +6,33 @@
|
||||
result_unknown 行仅 [重新触发],D11 无关闭入口;动作按钮与状态徽标
|
||||
同簇靠右、紧跟状态展示,2026-09-29 布局调整)+ 上一页/下一页分页;
|
||||
无自动轮询(进入拉一次 + 手动刷新)。
|
||||
依赖:transfer.api(fetchExecutedOrders/closeTransferDocument/retriggerTransferDocument)、
|
||||
依赖:Element Plus ElDialog/ElTable/ElTableColumn/ElButton/ElTag/ElInput/
|
||||
ElDatePicker(2026-10-20:工具条/徽标/行内动作/关闭弹层/日期一并 EP)、
|
||||
transfer.api(fetchExecutedOrders/closeTransferDocument/retriggerTransferDocument)、
|
||||
transferBatch.deriveBatchNo(拨出批号展示侧 WTP→HOW 镜像)、
|
||||
useMessage、i18n chat.transfer.homeExecuted.*。
|
||||
逻辑:props.initialGroup(首页卡片点击带入的初始分组,''=全部)→ mounted→load;
|
||||
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load(后端按收料
|
||||
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load(后端按异动
|
||||
日期过滤);[返回]→emit('back') 由首页面板切回卡片视图;关闭单走 D18
|
||||
原因必填弹窗(同单行影响面 + 「关闭调拨单≠ERP 无单」红线)→close→load。
|
||||
行为与融合卡(TransferResultCard)一致。列表排序(收料日期→数据源→库位
|
||||
弹层壳禁 ESC/遮罩点击/X 关闭(仅收起/确认按钮可关,防误触关闭高危操作)。
|
||||
行为与融合卡(TransferResultCard)一致。列表排序(异动日期→数据源→库位
|
||||
升序)与分组计数恒全量由后端保证,本视图不消费计数
|
||||
(计数展示在首页 TransferExecutedCards)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElButton,
|
||||
ElDatePicker,
|
||||
ElDialog,
|
||||
ElInput,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import { transferDialogShellAttrs } from './transferDialogShell';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
closeTransferDocument,
|
||||
@@ -47,8 +60,9 @@ const total = ref(0);
|
||||
const page = ref(1);
|
||||
/** 当前单分组筛选(''=全部;首页卡片带入,[全部] 清回)。 */
|
||||
const statusGroup = ref(props.initialGroup || '');
|
||||
const dateFrom = ref('');
|
||||
const dateTo = ref('');
|
||||
/** 日期筛(YYYY-MM-DD;空=不限;ElDatePicker clearable 置 null)。 */
|
||||
const dateFrom = ref<string | null>(null);
|
||||
const dateTo = ref<string | null>(null);
|
||||
const loading = ref(false);
|
||||
/** 展开行明细的单(doc_no;单行点击切换,invoice 粒度)。 */
|
||||
const expandedDocNo = ref('');
|
||||
@@ -94,11 +108,16 @@ async function clearGroup() {
|
||||
await load();
|
||||
}
|
||||
|
||||
/** 日期范围变更:仅筛列表(计数恒全量),回第一页。 */
|
||||
async function onDateChange() {
|
||||
/**
|
||||
* 日期范围变更:仅筛列表(计数恒全量),回第一页。
|
||||
* 首挂载完成前跳过:ElDatePicker 初始化可能回写 modelValue,避免与 onMounted load 叠成死循环。
|
||||
*/
|
||||
const dateFilterReady = ref(false);
|
||||
watch([dateFrom, dateTo], () => {
|
||||
if (!dateFilterReady.value) return;
|
||||
page.value = 1;
|
||||
await load();
|
||||
}
|
||||
void load();
|
||||
});
|
||||
|
||||
async function goToPage(next: number) {
|
||||
page.value = next;
|
||||
@@ -200,43 +219,64 @@ async function confirmCloseOrder() {
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => { void load(); });
|
||||
onMounted(async () => {
|
||||
await load();
|
||||
dateFilterReady.value = true;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section :aria-label="$t('chat.transfer.homeExecuted.title')" data-testid="transfer-executed" class="rounded-2xl border border-default bg-surface p-4">
|
||||
<!-- 工具栏:返回(emit back 由首页切视图)+ 全部/日期筛选 + 刷新 -->
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-2 py-1 text-sm font-bold text-brand-600 transition-colors hover:bg-brand-50"
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
class="!px-2 !text-sm !font-bold"
|
||||
data-testid="transfer-executed-back"
|
||||
@click="emit('back')"
|
||||
>
|
||||
← {{ $t('chat.transfer.homeExecuted.back') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border px-3 py-1 text-xs font-bold transition-colors"
|
||||
:class="statusGroup === ''
|
||||
? 'border-brand-500 bg-brand-600 text-white'
|
||||
: 'border-default bg-surface-soft text-secondary hover:bg-brand-50'"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
round
|
||||
:type="statusGroup === '' ? 'primary' : 'default'"
|
||||
data-testid="transfer-executed-all"
|
||||
@click="clearGroup"
|
||||
>
|
||||
{{ $t('chat.transfer.homeExecuted.all') }}
|
||||
</button>
|
||||
</el-button>
|
||||
<span class="ml-auto flex items-center gap-2">
|
||||
<input v-model="dateFrom" type="date" class="rounded-lg border border-default px-2 py-1 text-xs"
|
||||
:aria-label="$t('chat.transfer.homeExecuted.dateFrom')" data-testid="transfer-executed-date-from" @change="onDateChange">
|
||||
<span data-testid="transfer-executed-date-from">
|
||||
<el-date-picker
|
||||
v-model="dateFrom"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
size="small"
|
||||
:clearable="true"
|
||||
:aria-label="$t('chat.transfer.homeExecuted.dateFrom')"
|
||||
/>
|
||||
</span>
|
||||
<span class="text-xs text-muted">→</span>
|
||||
<input v-model="dateTo" type="date" class="rounded-lg border border-default px-2 py-1 text-xs"
|
||||
:aria-label="$t('chat.transfer.homeExecuted.dateTo')" data-testid="transfer-executed-date-to" @change="onDateChange">
|
||||
<button type="button"
|
||||
class="rounded-lg border border-default px-3 py-1 text-xs font-bold text-secondary hover-surface-soft disabled:opacity-40"
|
||||
data-testid="transfer-executed-refresh" :disabled="loading" @click="load">
|
||||
<span data-testid="transfer-executed-date-to">
|
||||
<el-date-picker
|
||||
v-model="dateTo"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
size="small"
|
||||
:clearable="true"
|
||||
:aria-label="$t('chat.transfer.homeExecuted.dateTo')"
|
||||
/>
|
||||
</span>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="loading"
|
||||
data-testid="transfer-executed-refresh"
|
||||
@click="load"
|
||||
>
|
||||
{{ $t('chat.transfer.homeExecuted.refresh') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -256,164 +296,169 @@ onMounted(() => { void load(); });
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
|
||||
<span class="font-semibold text-secondary">
|
||||
{{ order.receipt_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
|
||||
{{ order.movement_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
|
||||
· {{ $t('chat.transfer.materialCount', { count: order.items.length }) }}
|
||||
</span>
|
||||
<!-- 状态徽标与单据级行内动作(D11/D18)同簇靠右:处置动作紧跟状态,扫读动线「状态→处置」 -->
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': order.status_group === 'success',
|
||||
'bg-sky-50 text-sky-700': order.status_group === 'executing',
|
||||
'bg-red-50 text-red-700': order.status_group === 'failed',
|
||||
'bg-amber-50 text-amber-700': order.status_group === 'result_unknown',
|
||||
}"
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="light"
|
||||
round
|
||||
:type="order.status_group === 'success'
|
||||
? 'success'
|
||||
: order.status_group === 'failed'
|
||||
? 'danger'
|
||||
: order.status_group === 'result_unknown'
|
||||
? 'warning'
|
||||
: 'info'"
|
||||
:data-testid="`transfer-executed-status-${order.doc_no}`"
|
||||
>
|
||||
{{ orderBadgeText(order) }}
|
||||
</span>
|
||||
<button
|
||||
</el-tag>
|
||||
<el-button
|
||||
v-if="order.status === 'result_unknown'"
|
||||
type="button"
|
||||
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
|
||||
size="small"
|
||||
type="warning"
|
||||
plain
|
||||
class="!text-[11px]"
|
||||
:data-testid="`transfer-executed-retrigger-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click.stop="onRetrigger(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retrigger') }}
|
||||
</button>
|
||||
</el-button>
|
||||
<template v-if="isFailedOrder(order)">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
class="!text-[11px]"
|
||||
:data-testid="`transfer-executed-retry-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click.stop="onRetry(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
plain
|
||||
class="!text-[11px]"
|
||||
:data-testid="`transfer-executed-close-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click.stop="openCloseDialog(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.closeOrder') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 展开明细(invoice 粒度行集) -->
|
||||
<!-- 展开明细(invoice 粒度行集;EP 表格壳:空态/样式与业务表格一致) -->
|
||||
<div
|
||||
v-if="expandedDocNo === order.doc_no"
|
||||
class="border-t border-subtle px-3 py-2"
|
||||
:data-testid="`transfer-executed-items-${order.doc_no}`"
|
||||
>
|
||||
<table class="w-full text-xs">
|
||||
<thead>
|
||||
<tr class="text-left text-[11px] text-muted">
|
||||
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in order.items" :key="`${order.doc_no}|${item.invoice_no}|${item.material_no}`" class="border-t border-subtle">
|
||||
<td class="p-1">{{ item.invoice_no }}</td>
|
||||
<td class="p-1">{{ item.material_no }}</td>
|
||||
<td class="p-1">{{ item.material_name }}</td>
|
||||
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
|
||||
行上数据保持文件原形态,转换只发生在展示侧) -->
|
||||
<td class="p-1">{{ deriveBatchNo(item.lot_no) || '—' }}</td>
|
||||
<td class="p-1">{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<el-table :data="order.items" size="small" class="text-xs">
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="invoice_no" min-width="120" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.external_doc_no || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="140" />
|
||||
<!-- 拨出批号展示外部形态(WTP→HOW 镜像转换,与匹配卡/可调拨明细/待办池同规则;
|
||||
行上数据保持文件原形态,转换只发生在展示侧) -->
|
||||
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ deriveBatchNo(row.lot_no) || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.quantity }}<template v-if="row.unit"> {{ row.unit }}</template></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- 分页:上一页/下一页(无自动轮询,手动翻页) -->
|
||||
<!-- 分页:上一页/下一页(保留 testid;无自动轮询,手动翻页) -->
|
||||
<div class="mt-3 flex items-center justify-end gap-2 border-t border-subtle pt-3 text-xs">
|
||||
<span class="text-muted" data-testid="transfer-executed-pageinfo">
|
||||
{{ $t('chat.transfer.homeExecuted.pageInfo', { page, total }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1 font-bold text-secondary hover-surface-soft disabled:opacity-40"
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-executed-prev"
|
||||
:disabled="!hasPrev || loading"
|
||||
@click="goToPage(page - 1)"
|
||||
>
|
||||
←
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1 font-bold text-secondary hover-surface-soft disabled:opacity-40"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-executed-next"
|
||||
:disabled="!hasNext || loading"
|
||||
@click="goToPage(page + 1)"
|
||||
>
|
||||
→
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线) -->
|
||||
<div
|
||||
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线)。
|
||||
v-if + model-value=true:打开即渲染、关闭即卸载(无过渡等待,测试语义同旧行为) -->
|
||||
<el-dialog
|
||||
v-if="closeTarget"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
data-testid="transfer-executed-close-dialog"
|
||||
:model-value="true"
|
||||
v-bind="transferDialogShellAttrs"
|
||||
width="28rem"
|
||||
class="rounded-2xl bg-surface"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<h3 class="text-base font-bold text-primary">
|
||||
<template #header>
|
||||
<h3
|
||||
class="text-base font-bold text-primary"
|
||||
data-testid="transfer-executed-close-dialog"
|
||||
>
|
||||
{{ $t('chat.transfer.homeExecuted.closeDialog.title', { docNo: closeTarget.doc_no }) }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
{{ $t('chat.transfer.homeExecuted.closeDialog.redlineReopen') }}
|
||||
</p>
|
||||
<ul class="mt-2 max-h-32 overflow-y-auto rounded-lg bg-surface-soft p-2 text-[11px] text-secondary">
|
||||
<li v-for="item in closeTarget.items" :key="`${item.invoice_no}|${item.material_no}`">
|
||||
{{ item.invoice_no }} · {{ item.material_no }} {{ item.material_name }} ·
|
||||
{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="mt-2 list-disc pl-4 text-xs font-bold text-red-600">
|
||||
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineWhole') }}</li>
|
||||
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineResidue') }}</li>
|
||||
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineErpCheck') }}</li>
|
||||
</ul>
|
||||
<textarea
|
||||
v-model="closeDialog.reason"
|
||||
rows="3"
|
||||
class="mt-3 w-full rounded-lg border border-default p-2 text-sm"
|
||||
:placeholder="$t('chat.transfer.homeExecuted.closeDialog.reasonRequired')"
|
||||
data-testid="transfer-executed-close-reason"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
|
||||
data-testid="transfer-executed-close-dismiss"
|
||||
@click="closeDialog = { docNo: '', reason: '' }"
|
||||
>
|
||||
{{ $t('chat.transfer.orderClose.dismiss') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-red-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-executed-close-confirm"
|
||||
:disabled="!closeDialog.reason.trim() || actionBusy"
|
||||
@click="confirmCloseOrder"
|
||||
>
|
||||
{{ $t('chat.transfer.homeExecuted.closeDialog.confirm') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<p class="text-xs text-muted">
|
||||
{{ $t('chat.transfer.homeExecuted.closeDialog.redlineReopen') }}
|
||||
</p>
|
||||
<ul class="mt-2 max-h-32 overflow-y-auto rounded-lg bg-surface-soft p-2 text-[11px] text-secondary">
|
||||
<li v-for="item in closeTarget.items" :key="`${item.invoice_no}|${item.material_no}`">
|
||||
{{ item.invoice_no }} · {{ item.material_no }} {{ item.material_name }} ·
|
||||
{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="mt-2 list-disc pl-4 text-xs font-bold text-red-600">
|
||||
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineWhole') }}</li>
|
||||
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineResidue') }}</li>
|
||||
<li>{{ $t('chat.transfer.homeExecuted.closeDialog.redlineErpCheck') }}</li>
|
||||
</ul>
|
||||
<el-input
|
||||
v-model="closeDialog.reason"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
class="mt-3"
|
||||
:placeholder="$t('chat.transfer.homeExecuted.closeDialog.reasonRequired')"
|
||||
data-testid="transfer-executed-close-reason"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<el-button
|
||||
data-testid="transfer-executed-close-dismiss"
|
||||
@click="closeDialog = { docNo: '', reason: '' }"
|
||||
>
|
||||
{{ $t('chat.transfer.orderClose.dismiss') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
data-testid="transfer-executed-close-confirm"
|
||||
:disabled="!closeDialog.reason.trim() || actionBusy"
|
||||
@click="confirmCloseOrder"
|
||||
>
|
||||
{{ $t('chat.transfer.homeExecuted.closeDialog.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,15 +1,28 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferFileProgressCard.vue
|
||||
用途:来源实例级收料文件准备进度(决策 18:来源隔离展示,不伪造总百分比)。
|
||||
依赖:props.sources、i18n chat.transfer.*。
|
||||
用途:来源实例级入站文件准备进度(决策 18:来源隔离展示,不伪造总百分比)。
|
||||
依赖:Element Plus ElTag(2026-10-20 EP 组件化:阶段徽标迁 el-tag)、
|
||||
props.sources、i18n chat.transfer.*。
|
||||
逻辑:按来源显示 file_ready / waiting_rpa_callback / failed 阶段与文件信息。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ElTag } from 'element-plus';
|
||||
import type { TransferSourceProgress } from '../../types/transfer.types';
|
||||
|
||||
defineProps<{
|
||||
sources: TransferSourceProgress[];
|
||||
}>();
|
||||
|
||||
/**
|
||||
* 来源阶段 → el-tag type。
|
||||
* @param stage 来源进度阶段(file_ready / waiting_rpa_callback / failed)
|
||||
* @returns el-tag type
|
||||
*/
|
||||
function stageTagType(stage: string): 'success' | 'warning' | 'danger' {
|
||||
if (stage === 'file_ready') return 'success';
|
||||
if (stage === 'waiting_rpa_callback') return 'warning';
|
||||
return 'danger';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -32,18 +45,11 @@ defineProps<{
|
||||
</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',
|
||||
}"
|
||||
>
|
||||
<el-tag size="small" effect="light" :type="stageTagType(source.stage)" class="shrink-0">
|
||||
<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>
|
||||
</el-tag>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -11,6 +11,9 @@ import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
// EP el-table/el-input 在 jsdom 挂载较重(backlog 子视图连跑易超默认 5s)。
|
||||
vi.setConfig({ testTimeout: 30000 });
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferMatching: vi.fn(),
|
||||
getTransferMatching: vi.fn(),
|
||||
@@ -18,12 +21,14 @@ const api = vi.hoisted(() => ({
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferInboundFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
listTransferBacklog: vi.fn(),
|
||||
listTransferBacklogPage: vi.fn(),
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listPendingMatchRecordsPage: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
fetchTransferTypes: vi.fn(),
|
||||
listExecutableTransferItems: vi.fn(),
|
||||
fetchExecutedOrders: vi.fn(),
|
||||
}));
|
||||
@@ -31,6 +36,7 @@ const api = vi.hoisted(() => ({
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import TransferHomePanel from './TransferHomePanel.vue';
|
||||
import TransferBacklogSummaryCard from './TransferBacklogSummaryCard.vue';
|
||||
|
||||
function mountHome() {
|
||||
return mount(TransferHomePanel, {
|
||||
@@ -43,13 +49,21 @@ 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 },
|
||||
recoverable: 6, closed: 2, unknown: 1, pending_match: 3, matchable_count: 5,
|
||||
aging: { warn_3d: 3, escalate_5d: 2, critical_7d: 1 },
|
||||
});
|
||||
api.listTransferBacklog.mockResolvedValue([]);
|
||||
api.listTransferBacklogPage.mockResolvedValue({ items: [], total: 0, page: 1, page_size: 20 });
|
||||
api.listExecutableTransferItems.mockResolvedValue({ items: [], counts: { executable_count: 0 } });
|
||||
// 「待匹配」桶只读清单(D16 第 4 卡抽屉数据源;默认空,专项用例自行覆盖)。
|
||||
api.listPendingMatchRecordsPage.mockResolvedValue({ records: [], total: 0, page: 1, page_size: 20 });
|
||||
api.listExecutableTransferItems.mockResolvedValue({ items: [], counts: { executable_count: 0 } });
|
||||
api.listTransferSources.mockResolvedValue([
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
]);
|
||||
// 调拨类型配置(Task 7 接口化):source-select 子视图挂载时并行拉取,不 mock 会成未处理 rejection。
|
||||
api.fetchTransferTypes.mockResolvedValue([
|
||||
{ code: 'in_transit_to_hub', names: { 'zh-CN': '在途仓至HUB仓' }, sort_order: 10, transform_rules: [] },
|
||||
]);
|
||||
// 已执行卡片入口挂载拉分组计数(pageSize=1);不 mock 会因组件静默失败成为未处理 rejection。
|
||||
api.fetchExecutedOrders.mockResolvedValue({
|
||||
groups: { success: 0, failed: 0, executing: 0, result_unknown: 0 },
|
||||
@@ -70,21 +84,21 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
expect(api.getTransferBacklogSummary).toHaveBeenCalled();
|
||||
// [断言意图] 首屏只取计数:计数卡不消费全量待办列表(68.5kB 级),
|
||||
// /backlog 全量列表延迟到切片子视图(TransferMessageView backlog 挂载)自行加载。
|
||||
expect(api.listTransferBacklog).not.toHaveBeenCalled();
|
||||
expect(api.listTransferBacklogPage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('点击“匹配可调拨库存”今日待办入口独立触发来源选择卡(复用 TransferMessageView)', async () => {
|
||||
api.createTransferMatching.mockResolvedValue({
|
||||
matching_id: 'MTG-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, matched_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 1, matched_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200', estimated_external_write_count: 1, matching_hash: 'sha256:x',
|
||||
});
|
||||
api.getTransferMatching.mockResolvedValue({
|
||||
summary: {
|
||||
matching_id: 'MTG-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, matched_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
expires_at: '',
|
||||
counts: { file_invoice_count: 1, matched_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200', estimated_external_write_count: 1, matching_hash: 'sha256:x',
|
||||
},
|
||||
items: [{
|
||||
@@ -105,16 +119,27 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
|
||||
it('点击历史待办计数卡独立触发 backlog 卡片,并按计数卡切片初始筛选', async () => {
|
||||
// [断言意图] 两张计数卡不再落入同一份全量列表:可恢复/已关闭
|
||||
// 各自带对应 resultFilter 打开待处理池(否则 0 行的已关闭被 50 行可恢复淹没);
|
||||
// 各自携带对应 resultFilter 打开待处理池(否则 0 行的已关闭被 50 行可恢复淹没);
|
||||
// 结果未知无首页卡(2026-09-29),unknown 切片仅池内筛选可达。
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
// 2026-10-16 服务端分页+筛选下推:mock 按查询参数返回对应切片,
|
||||
// 同时验证切片条件真实透传到 API(query-change 接线端到端)。
|
||||
const poolItems = [
|
||||
{ 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' },
|
||||
status: 'blocked_recoverable', reason: '异动 1200 / ERP 1000', age_days: 1, aging_level: 'normal' },
|
||||
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2',
|
||||
status: 'manually_closed', reason: '线下处理', age_days: 2, aging_level: 'closed' },
|
||||
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-003', material_no: 'MAT-3',
|
||||
status: 'result_unknown', reason: '待人工核实', age_days: 3, aging_level: 'result_unknown' },
|
||||
]);
|
||||
];
|
||||
const filterStatus: Record<string, string> = {
|
||||
recoverable: 'blocked_recoverable', closed: 'manually_closed', unknown: 'result_unknown',
|
||||
};
|
||||
api.listTransferBacklogPage.mockImplementation((query: { resultFilter?: string }) => {
|
||||
const items = query.resultFilter && query.resultFilter !== 'all'
|
||||
? poolItems.filter((entry) => entry.status === filterStatus[query.resultFilter as string])
|
||||
: poolItems;
|
||||
return Promise.resolve({ items, total: items.length, page: 1, page_size: 20 });
|
||||
});
|
||||
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
@@ -122,8 +147,10 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
await wrapper.find('[data-testid="transfer-home-recoverable"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
expect(api.listTransferBacklog).toHaveBeenCalled();
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('recoverable');
|
||||
expect(api.listTransferBacklogPage).toHaveBeenCalled();
|
||||
// [断言意图] 结果筛选迁 EP el-select(非原生 select),初始切片断言改走组件 prop
|
||||
// (等价语义:计数卡切片落入对应 resultFilter)。
|
||||
expect(wrapper.findComponent(TransferBacklogSummaryCard).props('initialFilter')).toBe('recoverable');
|
||||
// 切片后仅可见对应状态行。
|
||||
expect(wrapper.text()).toContain('INV-001');
|
||||
expect(wrapper.text()).not.toContain('INV-002');
|
||||
@@ -132,11 +159,58 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-closed"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-result-filter"]').element as HTMLSelectElement).value).toBe('closed');
|
||||
expect(wrapper.findComponent(TransferBacklogSummaryCard).props('initialFilter')).toBe('closed');
|
||||
expect(wrapper.text()).toContain('INV-002');
|
||||
expect(wrapper.text()).not.toContain('INV-001');
|
||||
});
|
||||
|
||||
it('待办看板渲染第 4 张「待匹配」卡(计数=summary.pending_match)', async () => {
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
// [断言意图] D16 第 4 卡:计数消费 backlogSummary.pending_match(不额外拉清单)。
|
||||
expect(wrapper.find('[data-testid="transfer-home-pending-match"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-home-pending-match"]').text()).toContain('3');
|
||||
// [断言意图] 库存匹配卡显示启用类型现在圈得住的行数,不占用待匹配卡的全量。
|
||||
expect(wrapper.find('[data-testid="transfer-home-matchable-count"]').text()).toContain('5');
|
||||
// 首屏只取计数:抽屉清单延迟到进入子视图才拉。
|
||||
expect(api.listPendingMatchRecordsPage).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('点击「待匹配」卡进只读抽屉:清单渲染、无勾选/执行入口,「去匹配」切来源选择卡', async () => {
|
||||
api.listPendingMatchRecordsPage.mockImplementation(async (query: { segment?: string }) => {
|
||||
if (query?.segment === 'matchable') {
|
||||
return { records: [], total: 0, page: 1, page_size: 20 };
|
||||
}
|
||||
return {
|
||||
records: [
|
||||
{ ledger_record_id: 101, doc_no: 'HOM-901', material_code: 'MAT-9', material_name: '未匹配物料',
|
||||
movement_date: '2026-08-04', source_code: 'DBS-AWSBI', quantity: '55' },
|
||||
],
|
||||
total: 1, page: 1, page_size: 20,
|
||||
};
|
||||
});
|
||||
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-home-pending-match"]').trigger('click');
|
||||
await flushPromises();
|
||||
// [断言意图] 抽屉=只读清单:进入子视图才拉清单,行字段可见。
|
||||
expect(api.listPendingMatchRecordsPage).toHaveBeenCalledWith(expect.objectContaining({ segment: 'outside', page: 1 }));
|
||||
expect(api.listPendingMatchRecordsPage).toHaveBeenCalledWith(expect.objectContaining({ segment: 'matchable', page: 1 }));
|
||||
expect(wrapper.find('[data-testid="transfer-pending-match-panel"]').exists()).toBe(true);
|
||||
// [断言意图] 行定位:el-table 行类 transfer-pending-match-row-<doc_no>(EP 化后行无逐行 attr)。
|
||||
expect(wrapper.find('.transfer-pending-match-row-HOM-901').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('MAT-9');
|
||||
// [断言意图] 不可勾选执行:抽屉内无任何复选框与「生成调拨单」按钮(记录尚未匹配/未库存核对)。
|
||||
expect(wrapper.find('[data-testid="transfer-pending-match-panel"]').find('input[type="checkbox"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-executable-generate"]').exists()).toBe(false);
|
||||
|
||||
// [断言意图] 「去匹配」=现有库存匹配入口(来源选择卡),非行执行。
|
||||
await wrapper.find('[data-testid="transfer-pending-match-go"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-source-select-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('点击已执行统计卡片进入明细列表子视图:initial-group 透传且 flow-active=true', async () => {
|
||||
// 卡片分组计数非零(入口可见);列表 mock 返回空单(本例只验证接线,不验证行渲染)。
|
||||
api.fetchExecutedOrders.mockResolvedValue({
|
||||
|
||||
@@ -1,23 +1,29 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferHomePanel.vue
|
||||
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——上区「库存匹配」动作入口,
|
||||
中区「待办看板」三队列(可调拨明细/待恢复异常/已人工关闭;结果未知行
|
||||
2026-09-29 起不再设首页卡——行级在待办池只读且无独立出口,统一走下方
|
||||
执行看板的结果未知单据 [重新触发],池内仍可经结果筛选查看),
|
||||
中区「待办看板」四队列(待匹配/可调拨明细/待恢复异常/已人工关闭)。
|
||||
「待匹配」是已落档尚未匹配的成熟出入站全量;库存匹配卡另显示启用类型
|
||||
现在圈得住的可匹配数。结果未知行不再设首页卡,统一走执行看板的结果未知单据。
|
||||
下区「执行看板」统计卡片入口(四张分组计数卡,点击跳转明细列表子视图),
|
||||
点击进入对应处理视图(复用自驱动的 TransferMessageView / TransferExecutedOrders)。
|
||||
依赖:TransferMessageView(复用自驱动卡片)、TransferExecutedCards(已执行卡片入口)、
|
||||
TransferExecutedOrders(已执行明细列表子视图)、useChatTransfer、i18n chat.transfer.*。
|
||||
依赖:Element Plus ElCard(首页统计/匹配入口多行卡,可点且不压扁布局)、
|
||||
ElButton(仅「返回」链钮;禁 el-button 包多行统计——2026-10-20 重叠教训)、
|
||||
TransferMessageView、TransferExecutedCards、TransferExecutedOrders、
|
||||
TransferPendingMatchPanel、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:home 时仅拉待办汇总计数与可调拨明细(首屏不拉全量待办列表,命中
|
||||
首页预取单飞);'executed' 子视图由 openExecuted(group) 进入(卡片带入
|
||||
初始分组)并挂载列表组件;其余非 home 视图渲染 TransferMessageView
|
||||
首页预取单飞);'pending-match' 子视图挂载时现拉只读清单(计数卡消费
|
||||
backlogSummary.pending_match,可匹配数消费 matchable_count);
|
||||
'executed' 子视图由 openExecuted(group) 进入
|
||||
(卡片带入初始分组)并挂载列表组件;其余非 home 视图渲染 TransferMessageView
|
||||
(backlog 切片在其挂载时自拉全量列表)。卡片不注入消息流,因此无需后端 ChatLog 消息。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { ElButton, ElCard } from 'element-plus';
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
import TransferExecutedCards from './TransferExecutedCards.vue';
|
||||
import TransferExecutedOrders from './TransferExecutedOrders.vue';
|
||||
import TransferPendingMatchPanel from './TransferPendingMatchPanel.vue';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -29,7 +35,7 @@ const emit = defineEmits<{
|
||||
'flow-active': [active: boolean];
|
||||
}>();
|
||||
|
||||
type HomeView = 'home' | 'source-select' | 'backlog' | 'executable' | 'executed';
|
||||
type HomeView = 'home' | 'source-select' | 'backlog' | 'executable' | 'executed' | 'pending-match';
|
||||
/** 待处理池结果筛选(与 TransferBacklogSummaryCard 的筛选选项一致)。 */
|
||||
type BacklogFilter = 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
|
||||
@@ -53,13 +59,19 @@ function openExecuted(group: 'success' | 'failed' | 'executing' | 'result_unknow
|
||||
}
|
||||
|
||||
/** home 视图仅拉待办汇总计数与可调拨明细——计数卡只消费计数,
|
||||
* 68.5kB 级全量待办列表延迟到切片子视图(TransferMessageView backlog)自行加载 */
|
||||
* 68.5kB 级全量待办列表延迟到切片子视图(TransferMessageView backlog)自行加载;
|
||||
* 'pending-match' 子视图现拉只读清单(D16:不做缓存,匹配后数据即变) */
|
||||
async function loadHomeSummary() {
|
||||
if (view.value !== 'home') return;
|
||||
await Promise.all([
|
||||
transfer.loadBacklogSummary().catch(() => undefined),
|
||||
transfer.loadExecutableItems().catch(() => undefined),
|
||||
]);
|
||||
if (view.value === 'home') {
|
||||
await Promise.all([
|
||||
transfer.loadBacklogSummary().catch(() => undefined),
|
||||
transfer.loadExecutableItems().catch(() => undefined),
|
||||
]);
|
||||
}
|
||||
if (view.value === 'pending-match') {
|
||||
// 服务端分页(2026-10-16):每次进入抽屉回到第 1 页(D16 不做缓存,匹配后数据即变)
|
||||
await transfer.loadPendingMatchRecords({ page: 1 }).catch(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => { void loadHomeSummary(); });
|
||||
@@ -92,58 +104,91 @@ function goBack() {
|
||||
</h2>
|
||||
|
||||
<div class="w-full max-w-3xl space-y-4">
|
||||
<!-- 库存匹配 -->
|
||||
<!-- 库存匹配:el-card 承载多行入口(勿用 el-button,见文件头) -->
|
||||
<section aria-label="库存匹配">
|
||||
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeMatchLabel') }}</p>
|
||||
<button
|
||||
type="button"
|
||||
<el-card
|
||||
shadow="hover"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
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"
|
||||
class="cursor-pointer !rounded-2xl !border-brand-200 !bg-brand-50"
|
||||
:body-style="{ padding: '1rem' }"
|
||||
@click="view = 'source-select'"
|
||||
@keydown.enter.prevent="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>
|
||||
<div class="flex items-center gap-3 text-left">
|
||||
<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 font-medium text-brand-700" data-testid="transfer-home-matchable-count">{{ $t('chat.transfer.homeMatchablePrefix') }}{{ transfer.backlogSummary.value?.matchable_count ?? 0 }}{{ $t('chat.transfer.homeMatchableSuffix') }}</span>
|
||||
<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>
|
||||
</div>
|
||||
</el-card>
|
||||
</section>
|
||||
|
||||
<!-- 待办看板 -->
|
||||
<!-- 待办看板(D16:第 1 张=待匹配·靛蓝;其余三卡样式与语义不变) -->
|
||||
<section aria-label="待办看板">
|
||||
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeBoardLabel') }}</p>
|
||||
<div class="grid grid-cols-2 gap-3 lg:grid-cols-3">
|
||||
<button
|
||||
type="button"
|
||||
<div class="grid grid-cols-2 gap-3 lg:grid-cols-4">
|
||||
<el-card
|
||||
shadow="hover"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
data-testid="transfer-home-pending-match"
|
||||
class="cursor-pointer !rounded-2xl !border-indigo-200 !bg-indigo-50"
|
||||
:body-style="{ padding: '1rem' }"
|
||||
@click="view = 'pending-match'"
|
||||
@keydown.enter.prevent="view = 'pending-match'"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-indigo-600">{{ transfer.backlogSummary.value?.pending_match ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.transferPendingMatch') }}</b>
|
||||
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.transferPendingMatchHint') }}</span>
|
||||
</el-card>
|
||||
<el-card
|
||||
shadow="hover"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
data-testid="transfer-home-executable"
|
||||
class="rounded-2xl border border-emerald-200 bg-emerald-50 p-4 text-left transition-colors hover:bg-emerald-100"
|
||||
class="cursor-pointer !rounded-2xl !border-emerald-200 !bg-emerald-50"
|
||||
:body-style="{ padding: '1rem' }"
|
||||
@click="view = 'executable'"
|
||||
@keydown.enter.prevent="view = 'executable'"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-emerald-600">{{ transfer.executableItems.value.length }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeExecutable') }}</b>
|
||||
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeExecutableHint') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
</el-card>
|
||||
<el-card
|
||||
shadow="hover"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
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"
|
||||
class="cursor-pointer !rounded-2xl !border-brand-200 !bg-brand-50"
|
||||
:body-style="{ padding: '1rem' }"
|
||||
@click="openBacklog('recoverable')"
|
||||
@keydown.enter.prevent="openBacklog('recoverable')"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-brand-600">{{ transfer.backlogSummary.value?.recoverable ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeRecoverable') }}</b>
|
||||
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeRecoverableHint') }}</span>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
</el-card>
|
||||
<el-card
|
||||
shadow="hover"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
data-testid="transfer-home-closed"
|
||||
class="rounded-2xl border border-default bg-surface p-4 text-left transition-colors hover:border-brand-200 hover:bg-brand-50"
|
||||
class="cursor-pointer !rounded-2xl !border-default !bg-surface"
|
||||
:body-style="{ padding: '1rem' }"
|
||||
@click="openBacklog('closed')"
|
||||
@keydown.enter.prevent="openBacklog('closed')"
|
||||
>
|
||||
<b class="block text-2xl leading-none text-secondary">{{ transfer.backlogSummary.value?.closed ?? 0 }}</b>
|
||||
<b class="mt-2 block text-sm font-bold text-primary">{{ $t('chat.transfer.homeClosed') }}</b>
|
||||
<span class="mt-1 block text-xs text-secondary">{{ $t('chat.transfer.homeClosedHint') }}</span>
|
||||
</button>
|
||||
</el-card>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -160,16 +205,40 @@ function goBack() {
|
||||
<TransferExecutedOrders :initial-group="executedGroup" @back="goBack" />
|
||||
</div>
|
||||
|
||||
<!-- 子流程:复用自驱动的 TransferMessageView(宽表格需要全宽,上限对齐消息气泡宽布局) -->
|
||||
<div v-else class="w-full max-w-[min(96vw,1500px)] pr-2">
|
||||
<button
|
||||
type="button"
|
||||
<!-- 「待匹配」只读抽屉(D16:清单 + 去匹配引导;无勾选/执行入口) -->
|
||||
<div v-else-if="view === 'pending-match'" class="w-full max-w-[min(96vw,1500px)] pr-2">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
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"
|
||||
class="mb-2 !font-bold"
|
||||
@click="goBack"
|
||||
>
|
||||
← {{ $t('chat.transfer.homeBack') }}
|
||||
</button>
|
||||
</el-button>
|
||||
<TransferPendingMatchPanel
|
||||
:records="transfer.pendingMatchRecords.value"
|
||||
:total="transfer.pendingMatchTotal.value"
|
||||
:matchable-records="transfer.matchableRecords.value"
|
||||
:matchable-total="transfer.matchableTotal.value"
|
||||
@go-match="view = 'source-select'"
|
||||
@page-change="(query) => transfer.loadPendingMatchRecords({ ...query, segment: 'outside' })"
|
||||
@matchable-page-change="(query) => transfer.loadPendingMatchRecords({ ...query, segment: 'matchable' })"
|
||||
@refresh="() => transfer.loadPendingMatchRecords()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<!-- 子流程:复用自驱动的 TransferMessageView(宽表格需要全宽,上限对齐消息气泡宽布局) -->
|
||||
<div v-else class="w-full max-w-[min(96vw,1500px)] pr-2">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
data-testid="transfer-home-back"
|
||||
class="mb-2 !font-bold"
|
||||
@click="goBack"
|
||||
>
|
||||
← {{ $t('chat.transfer.homeBack') }}
|
||||
</el-button>
|
||||
<TransferMessageView :payload="childPayload" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferManualCloseDialog.vue
|
||||
用途:人工关闭弹窗(原因必填;关闭后永久排除,历史保留);count>1 时按批量文案展示。
|
||||
依赖:props(open/invoiceNo/count)、i18n chat.transfer.*。
|
||||
依赖:Element Plus ElDialog/ElInput/ElButton(2026-10-20:弹层内控件迁 EP)、
|
||||
props(open/invoiceNo/count)、i18n chat.transfer.*。
|
||||
逻辑:原因为空时确认按钮禁用;确认时 emit confirm(reason)。
|
||||
弹层壳 2026-10-16 由原生 fixed 遮罩迁 EP el-dialog(视觉与交互不变:
|
||||
禁 ESC/遮罩点击关闭与右上角 X,仅取消/确认按钮可关,防止误触关闭危险操作);
|
||||
v-if+model-value=true 挂载即渲染(EP onMounted 对初值 true 同步置 rendered)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { ElButton, ElDialog, ElInput } from 'element-plus';
|
||||
import { transferDialogShellAttrs } from './transferDialogShell';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
@@ -30,45 +36,48 @@ watch(
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
<el-dialog
|
||||
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"
|
||||
:model-value="true"
|
||||
v-bind="transferDialogShellAttrs"
|
||||
width="28rem"
|
||||
class="rounded-2xl bg-surface"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<h3 class="text-base font-bold text-primary">
|
||||
<template #header>
|
||||
<h3
|
||||
class="text-base font-bold text-primary"
|
||||
data-testid="transfer-manual-close-dialog"
|
||||
>
|
||||
{{ $t(count && count > 1 ? 'chat.transfer.batchCloseTitle' : 'chat.transfer.manualCloseTitle', count && count > 1 ? { count } : {}) }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
<template v-if="count && count > 1">{{ $t('chat.transfer.manualCloseHint') }}</template>
|
||||
<template v-else>{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</template>
|
||||
</p>
|
||||
<textarea
|
||||
v-model="reason"
|
||||
rows="3"
|
||||
class="mt-3 w-full rounded-lg border border-default 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-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
|
||||
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>
|
||||
</template>
|
||||
<p class="text-xs text-muted">
|
||||
<template v-if="count && count > 1">{{ $t('chat.transfer.manualCloseHint') }}</template>
|
||||
<template v-else>{{ invoiceNo }} · {{ $t('chat.transfer.manualCloseHint') }}</template>
|
||||
</p>
|
||||
<el-input
|
||||
v-model="reason"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
class="mt-3"
|
||||
:placeholder="$t('chat.transfer.closeReasonPlaceholder')"
|
||||
data-testid="transfer-close-reason"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<el-button
|
||||
data-testid="transfer-close-cancel"
|
||||
@click="emit('cancel')"
|
||||
>
|
||||
{{ $t('chat.transfer.cancel') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="!reason.trim()"
|
||||
data-testid="transfer-close-confirm"
|
||||
@click="emit('confirm', reason.trim())"
|
||||
>
|
||||
{{ $t('chat.transfer.confirmClose') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</template>
|
||||
@@ -2,7 +2,7 @@
|
||||
* features/chat/components/messages/TransferMatchCard.spec.ts
|
||||
* 用途:匹配卡顶栏「来源失败」横幅过滤——路由未解析失败只行内展示,不进顶栏。
|
||||
* 依赖:@vue/test-utils、i18n。
|
||||
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”;
|
||||
* 逻辑:来源失败顶栏(sources[].error_code/error_message)防止“安静全 0”。
|
||||
* 后端分层后路由失败保持行级(result=blocked_route_not_resolved),
|
||||
* 顶栏需按 error_code 客户端排除(历史卡片回放同样生效)。
|
||||
*/
|
||||
@@ -18,11 +18,9 @@ function buildSummary(): TransferMatchingSummary {
|
||||
matching_id: 'MTG-T',
|
||||
status: 'completed',
|
||||
business_date: '2026-08-06',
|
||||
eligible_receipt_date_to: '2026-08-06',
|
||||
expires_at: '2026-08-06T23:59:59',
|
||||
counts: {
|
||||
file_invoice_count: 0,
|
||||
not_matured_count: 0,
|
||||
matched_count: 0,
|
||||
executable_count: 0,
|
||||
blocked_count: 0,
|
||||
@@ -72,7 +70,7 @@ describe('TransferMatchCard 来源失败顶栏', () => {
|
||||
});
|
||||
|
||||
/** [2026-10-12 单据数口径修正] 预计 ERP 单据数按执行建单五元组去重。
|
||||
* 行分组键 = (external_org, source_code, receipt_date, from_warehouse,
|
||||
* 行分组键 = (external_org, source_code, movement_date, from_warehouse,
|
||||
* to_warehouse),与后端 execution_service.prepare_execution 同口径:
|
||||
* 同组多行执行期合并一张 ERP 单,预估数不得等于可执行行数。 */
|
||||
function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingItem {
|
||||
@@ -83,7 +81,7 @@ function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingIt
|
||||
material_name: '连接器组件',
|
||||
specification: 'A 型',
|
||||
invoice_no: 'HOM-001',
|
||||
receipt_date: '2026-08-05',
|
||||
movement_date: '2026-08-05',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
from_quantity: '100',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
@@ -94,19 +92,19 @@ function buildItem(overrides: Partial<TransferMatchingItem>): TransferMatchingIt
|
||||
};
|
||||
}
|
||||
|
||||
/** 计数卡第 5 格 = 预计 ERP 单据(可执行/未成熟/阻断/数量/单据/待查/失效)。 */
|
||||
/** 计数卡第 4 格 = 预计 ERP 单据(可执行/阻断/数量/单据/待查/失效)。 */
|
||||
function estimateCardText(wrapper: ReturnType<typeof mount>): string {
|
||||
const cells = wrapper.find('[data-testid="transfer-match-counts"]').findAll('div.rounded-lg');
|
||||
return cells[4]?.text() ?? '';
|
||||
return cells[3]?.text() ?? '';
|
||||
}
|
||||
|
||||
describe('TransferMatchCard 预计 ERP 单据数(五元组去重)', () => {
|
||||
const sameGroupA = buildItem({ item_id: 1, invoice_no: 'HOM-001' });
|
||||
const sameGroupB = buildItem({ item_id: 2, invoice_no: 'HOX-002' });
|
||||
const crossDate = buildItem({ item_id: 3, invoice_no: 'HOM-003', receipt_date: '2026-08-04' });
|
||||
const crossDate = buildItem({ item_id: 3, invoice_no: 'HOM-003', movement_date: '2026-08-04' });
|
||||
|
||||
it('计数卡:同组两行 + 跨日一行 → 预估 2(不等于可执行行数 3)', () => {
|
||||
// [断言意图] 锁定五元组去重口径:receipt_date 入键,同组合并、跨组拆分,
|
||||
// [断言意图] 锁定五元组去重口径:movement_date 入键,同组合并、跨组拆分,
|
||||
// 历史快照旧口径(=行数)持久值不再上屏。
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: {
|
||||
|
||||
@@ -1,33 +1,49 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferMatchCard.vue
|
||||
用途:匹配卡——计数 + 来源失败提示 + 调拨明细表(含筛选)+ 勾选 + “直接生成调拨单”按钮。
|
||||
依赖:props(summary/items/sources/selected/busy)、i18n chat.transfer.*。
|
||||
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断/未成熟项 checkbox 禁用;
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElInput/ElSelect/ElOption/ElButton/ElTag/
|
||||
ElAlert/ElCheckbox/ElPagination(2026-10-20:勾选列一并 EP;testid 挂
|
||||
el-checkbox,规格经内层 input 读写)、props(summary/items/sources/selected/
|
||||
busy)、i18n chat.transfer.*。
|
||||
逻辑:明细表渲染 pagedItems(filtered 经客户端分页切片);阻断项 checkbox 禁用;
|
||||
勾选键 = 明细行 item_id(历史回放行无 item_id 禁用防误选);
|
||||
库存数量下方小字透出查询时刻(checked_at);stale 行置灰 + 重查提示;
|
||||
file_current=false 行提示文件已更新(自动对齐语义);blocked_file_removed
|
||||
徽标独立文案;pending_stock_check 行徽标「待查库存」(amber 与未成熟同色系);
|
||||
计数卡透出待查库存(pending_stock_check_count)/已失效(invalid_count),
|
||||
历史回放缺省按 0 展示;blocked_file_removed 行退出主视图(表格不渲染),
|
||||
表格下方折叠提示去待处理异常池处理——重查救不了已消失的行,主清单只留
|
||||
可行动项;重查范围含可恢复阻断与可执行行(重查仍按 invoice_no 提交);
|
||||
阻断原因经结果徽标 title 悬浮透出不占行高;无选择或 busy 时生成按钮禁用;
|
||||
emit execute(itemIds);来源级解析/文件失败经 sources.error_code 透出
|
||||
(防"安静全 0"),但路由未解析失败(TRANSFER.ROUTE_NOT_RESOLVED)不进顶栏
|
||||
——路由失败保持行级(result=blocked_route_not_resolved 行内展示),
|
||||
顶栏按 error_code 客户端排除,历史卡片回放同样生效;
|
||||
明细表遵循 transferItemTable(EP show-overflow-tooltip、左固定勾选、
|
||||
右固定结果/重查、单号可滚、库存数量与查询时刻同行、过期顶栏 el-alert 汇总);
|
||||
blocked_file_removed 退出主视图;重查仍按 invoice_no;emit execute(itemIds);
|
||||
来源失败顶栏排除 TRANSFER.ROUTE_NOT_RESOLVED;行定位经 row-class-name
|
||||
注入 transfer-item-<invoice_no>;
|
||||
[2026-10-12 单据数口径修正] 预计 ERP 单据数(计数卡=全部可执行行、
|
||||
生成按钮旁=勾选可执行行)按执行建单五元组 (external_org, source_code,
|
||||
receipt_date, from_warehouse, to_warehouse) 去重实时计算(与后端
|
||||
movement_date, from_warehouse, to_warehouse) 去重实时计算(与后端
|
||||
execution_service 同键),同组多行合并一张单——原「=可执行行数」口径
|
||||
高估单据数误导用户。
|
||||
[2026-10-22 分页] 客户端分页 50/页:items=整包匹配明细(含阻断行),积压
|
||||
日可达数百行(557 行实测全量直染卡顿),切片渲染防 DOM 失控;关键字/结果
|
||||
筛选变更回第 1 页,行数减少收拢当前页防空白页;勾选集合跨页保留
|
||||
(全选/计数仍按 filtered 全量口径,与 ExecutableCard 同模式)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
ElAlert,
|
||||
ElButton,
|
||||
ElCheckbox,
|
||||
ElInput,
|
||||
ElOption,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
ElTableColumn,
|
||||
ElTag,
|
||||
} from 'element-plus';
|
||||
import type { CheckboxValueType } from 'element-plus';
|
||||
import { deriveBatchNo } from './transferBatch';
|
||||
import { formatQuantity } from './transferFormat';
|
||||
import { parseApiUtcDate } from '@/shared/utils/dateTime';
|
||||
import {
|
||||
formatStockQuantityCell,
|
||||
freshnessHint,
|
||||
} from './transferItemTable';
|
||||
import type { TransferMatchingItem, TransferMatchingSummary, TransferSourceProgress } from '../../types/transfer.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -74,7 +90,7 @@ const failedSources = computed(() =>
|
||||
|
||||
/** 筛选与全选状态(表格交互本地态,勾选集合仍由父级持有)。 */
|
||||
const keyword = ref('');
|
||||
const resultFilter = ref<'all' | 'executable' | 'blocked' | 'not_matured'>('all');
|
||||
const resultFilter = ref<'all' | 'executable' | 'blocked'>('all');
|
||||
|
||||
function isBlocked(item: TransferMatchingItem): boolean {
|
||||
return String(item.result).startsWith('blocked_');
|
||||
@@ -107,17 +123,34 @@ const filtered = computed(() =>
|
||||
if (isFileRemoved(item)) return false;
|
||||
const kw = keyword.value.trim().toLowerCase();
|
||||
if (kw) {
|
||||
const haystack = [item.material_no, item.material_name, item.invoice_no, item.lot_no]
|
||||
const haystack = [item.material_no, item.material_name, item.invoice_no, item.external_doc_no, item.lot_no]
|
||||
.map((value) => String(value ?? '').toLowerCase());
|
||||
if (!haystack.some((value) => value.includes(kw))) return false;
|
||||
}
|
||||
if (resultFilter.value === 'executable' && item.result !== 'executable') return false;
|
||||
if (resultFilter.value === 'blocked' && !isBlocked(item)) return false;
|
||||
if (resultFilter.value === 'not_matured' && item.result !== 'not_matured') return false;
|
||||
return true;
|
||||
}),
|
||||
);
|
||||
|
||||
/** 客户端分页(2026-10-22,50/页):items=整包匹配明细(含阻断行),积压日数百行
|
||||
* 全量直染卡顿;切片渲染防 DOM 失控。勾选集合跨页保留,全选/计数按 filtered 全量。 */
|
||||
const PAGE_SIZE = 50;
|
||||
const currentPage = ref(1);
|
||||
|
||||
const pagedItems = computed(() =>
|
||||
filtered.value.slice((currentPage.value - 1) * PAGE_SIZE, currentPage.value * PAGE_SIZE),
|
||||
);
|
||||
|
||||
// 筛选变更回第 1 页;刷新后行数减少时收拢当前页防空白页(与 ExecutableCard 同模式)。
|
||||
watch([keyword, resultFilter], () => {
|
||||
currentPage.value = 1;
|
||||
});
|
||||
watch(() => filtered.value.length, (len) => {
|
||||
const maxPage = Math.max(1, Math.ceil(len / PAGE_SIZE));
|
||||
if (currentPage.value > maxPage) currentPage.value = maxPage;
|
||||
});
|
||||
|
||||
/** 全选/批量提交范围:仅含拥有 item_id 的行(历史回放行无键不可参与)。 */
|
||||
const filteredItemIds = computed(() =>
|
||||
filtered.value.filter(hasSelectionKey).map((item) => item.item_id as number),
|
||||
@@ -140,6 +173,22 @@ function requerySelected(): void {
|
||||
if (nos.length) emit('requery', nos);
|
||||
}
|
||||
|
||||
/** 当前筛选下库存已过期且可重查的单号。 */
|
||||
const staleInvoiceNos = computed(() =>
|
||||
filtered.value
|
||||
.filter((item) => item.stale === true && isRequeryable(item))
|
||||
.map((item) => item.invoice_no),
|
||||
);
|
||||
|
||||
/**
|
||||
* 批量重查当前筛选下全部过期行。
|
||||
* 核心逻辑:顶栏汇总入口,避免结果列刷长文案。
|
||||
*/
|
||||
function requeryStaleRows(): void {
|
||||
if (!staleInvoiceNos.value.length) return;
|
||||
emit('requery', [...staleInvoiceNos.value]);
|
||||
}
|
||||
|
||||
function isChecked(item: TransferMatchingItem): boolean {
|
||||
return item.item_id != null && props.selected.has(item.item_id);
|
||||
}
|
||||
@@ -151,13 +200,13 @@ const executableCheckedItemIds = computed(() =>
|
||||
|
||||
/** [2026-10-12 单据数口径修正] 执行建单五元组键(与后端 execution_service.
|
||||
* prepare_execution 分组建单同键同 .trim() 规范化):(external_org, source_code,
|
||||
* receipt_date, from_warehouse, to_warehouse),同组多行执行期合并一张 ERP 单。
|
||||
* movement_date, from_warehouse, to_warehouse),同组多行执行期合并一张 ERP 单。
|
||||
* 老卡片行缺 external_org 按 '' 参与(分组退化为四元组,仅跨组织同仓库配置下有差异)。 */
|
||||
function documentGroupKey(item: TransferMatchingItem): string {
|
||||
return [
|
||||
(item.external_org ?? '').trim(),
|
||||
(item.source_code ?? '').trim(),
|
||||
(item.receipt_date ?? '').trim(),
|
||||
(item.movement_date ?? '').trim(),
|
||||
(item.from_warehouse ?? '').trim(),
|
||||
(item.to_warehouse ?? '').trim(),
|
||||
].join('\u001f');
|
||||
@@ -178,24 +227,16 @@ const estimatedDocumentCountSelected = computed(
|
||||
);
|
||||
|
||||
/**
|
||||
* 库存查询时刻小字(HH:mm);后端 naive ISO 按 UTC 解析后转浏览器本地时区
|
||||
* (仓库约定 parseApiUtcDate,2026-09-29 修复 UTC+8 展示异常);
|
||||
* 无效/缺省 checked_at 返回 null 不渲染。
|
||||
* @param item 匹配明细行;checked_at 为后端 ISO 时间
|
||||
* 库存数量单元格:数量与完整查询时刻同一行。
|
||||
* @param item 匹配明细行
|
||||
*/
|
||||
function checkedAtLabel(item: TransferMatchingItem): string | null {
|
||||
if (!item.checked_at) return null;
|
||||
const date = parseApiUtcDate(item.checked_at);
|
||||
if (Number.isNaN(date.getTime())) return null;
|
||||
const hh = String(date.getHours()).padStart(2, '0');
|
||||
const mm = String(date.getMinutes()).padStart(2, '0');
|
||||
return `${hh}:${mm}`;
|
||||
function stockCell(item: TransferMatchingItem): string {
|
||||
return formatStockQuantityCell(formatQuantity(item.from_quantity), item.checked_at);
|
||||
}
|
||||
|
||||
function resultLabel(result: string): string {
|
||||
const map: Record<string, string> = {
|
||||
executable: 'chat.transfer.resultExecutable',
|
||||
not_matured: 'chat.transfer.resultNotMatured',
|
||||
pending_stock_check: 'chat.transfer.resultPendingStockCheck',
|
||||
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
|
||||
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
|
||||
@@ -207,6 +248,17 @@ function resultLabel(result: string): string {
|
||||
return map[result] ?? 'chat.transfer.resultBlocked';
|
||||
}
|
||||
|
||||
/**
|
||||
* 结果徽标 EP type:可执行 success / 待查库存 warning / 其余阻断 danger。
|
||||
* @param result 行 result 码(executable / pending_stock_check / blocked_* …)
|
||||
* @returns el-tag type
|
||||
*/
|
||||
function resultTagType(result: string): 'success' | 'warning' | 'danger' {
|
||||
if (result === 'executable') return 'success';
|
||||
if (result === 'pending_stock_check') return 'warning';
|
||||
return 'danger';
|
||||
}
|
||||
|
||||
/** 阻断原因悬浮文案:已知结果码走 i18n 本地化;带明细后缀(如查询失败的底层原因)原样保留追加。 */
|
||||
const REASON_I18N_KEYS: Record<string, string> = {
|
||||
blocked_quantity_mismatch: 'chat.transfer.reasonQuantityMismatch',
|
||||
@@ -226,6 +278,24 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
: '';
|
||||
return detail ? `${base}:${detail}` : base;
|
||||
}
|
||||
|
||||
/** el-table 行键:与筛选回归同粒度(来源+Invoice+料号+异动日期),防拆单重复 key。 */
|
||||
function rowKey(item: TransferMatchingItem): string {
|
||||
return `${item.source_code}|${item.invoice_no}|${item.material_no}|${item.movement_date ?? ''}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* el-table 行类:注入行定位类(替代旧行 testid)+ 不可执行置灰 + stale 半透明。
|
||||
* @param row 当前匹配明细行
|
||||
* @returns 空格分隔的 class 串(含 transfer-item-<invoice_no>)
|
||||
*/
|
||||
function rowClassName({ row }: { row: TransferMatchingItem }): string {
|
||||
return [
|
||||
`transfer-item-${row.invoice_no}`,
|
||||
isSelectable(row) ? '' : 'bg-surface-soft text-muted',
|
||||
row.stale === true ? 'opacity-60' : '',
|
||||
].filter(Boolean).join(' ');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -235,15 +305,11 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
<span class="text-xs text-muted">{{ $t('chat.transfer.businessDate') }}:{{ summary.business_date }}</span>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-7" data-testid="transfer-match-counts">
|
||||
<div class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-6" data-testid="transfer-match-counts">
|
||||
<div class="rounded-lg bg-surface-soft p-2 text-center">
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.counts.executable_count }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.executableCount') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft p-2 text-center">
|
||||
<div class="text-lg font-black text-secondary">{{ summary.counts.not_matured_count }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.notMaturedCount') }}</div>
|
||||
</div>
|
||||
<div class="rounded-lg bg-surface-soft p-2 text-center">
|
||||
<div class="text-lg font-black text-secondary">{{ summary.counts.blocked_count }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.blockedCount') }}</div>
|
||||
@@ -270,153 +336,217 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
<el-alert
|
||||
v-if="failedSources.length"
|
||||
class="mb-3 rounded-lg border border-red-200 bg-red-50 p-3 text-xs text-red-700"
|
||||
type="error"
|
||||
:closable="false"
|
||||
class="mb-3"
|
||||
data-testid="transfer-match-failed-sources"
|
||||
>
|
||||
<div class="mb-1 font-bold">{{ $t('chat.transfer.sourceErrorTitle') }}</div>
|
||||
<div v-for="source in failedSources" :key="source.source_code" class="leading-5">
|
||||
<template #title>
|
||||
<div class="font-bold">{{ $t('chat.transfer.sourceErrorTitle') }}</div>
|
||||
</template>
|
||||
<div v-for="source in failedSources" :key="source.source_code" class="leading-5 text-xs">
|
||||
{{ source.source_code }}:{{ source.error_message || source.error_code }}
|
||||
</div>
|
||||
</div>
|
||||
</el-alert>
|
||||
|
||||
<el-alert
|
||||
v-if="staleInvoiceNos.length"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
class="mb-3"
|
||||
data-testid="transfer-match-stale-banner"
|
||||
>
|
||||
<template #title>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span>{{ $t('chat.transfer.staleBanner', { count: staleInvoiceNos.length }) }}</span>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="props.requeryBusy"
|
||||
data-testid="transfer-match-requery-stale"
|
||||
@click="requeryStaleRows"
|
||||
>
|
||||
{{ $t('chat.transfer.staleBannerRequery') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-alert>
|
||||
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<input
|
||||
<div class="w-56 shrink-0">
|
||||
<el-input
|
||||
v-model="keyword"
|
||||
type="text"
|
||||
class="w-56 rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary"
|
||||
size="small"
|
||||
clearable
|
||||
:placeholder="$t('chat.transfer.filterPlaceholder')"
|
||||
data-testid="transfer-match-filter"
|
||||
/>
|
||||
<select v-model="resultFilter" class="rounded-lg border border-default bg-surface px-2 py-1 text-xs text-primary" data-testid="transfer-match-result-filter">
|
||||
<option value="all">{{ $t('chat.transfer.filterAll') }}</option>
|
||||
<option value="executable">{{ $t('chat.transfer.resultExecutable') }}</option>
|
||||
<option value="blocked">{{ $t('chat.transfer.resultBlocked') }}</option>
|
||||
<option value="not_matured">{{ $t('chat.transfer.resultNotMatured') }}</option>
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-brand-200 bg-brand-50 px-3 py-1 text-xs font-bold text-brand-700 transition hover:bg-brand-100 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
:disabled="props.requeryBusy || selectedRequeryableCount === 0"
|
||||
data-testid="transfer-match-requery-selected"
|
||||
@click="requerySelected"
|
||||
>
|
||||
{{ $t('chat.transfer.requerySelected') }}{{ selectedRequeryableCount ? `(${selectedRequeryableCount})` : '' }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full min-w-[1240px] text-xs" data-testid="transfer-match-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft text-left text-[11px] text-muted">
|
||||
<th class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allFilteredSelected"
|
||||
data-testid="transfer-match-select-all"
|
||||
@change="toggleAll"
|
||||
/>
|
||||
</th>
|
||||
<!-- 表头全列 nowrap:防「拨出仓库/投入数量」等折行;品名列吃剩余宽度 -->
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colSource') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colReceiptDate') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colFromQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToWarehouse') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
<th class="whitespace-nowrap p-2">{{ $t('chat.transfer.colResult') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in filtered"
|
||||
:key="`${item.source_code}|${item.invoice_no}|${item.material_no}|${item.receipt_date ?? ''}`"
|
||||
class="border-b border-subtle"
|
||||
:class="{ 'bg-surface-soft text-muted': !isSelectable(item), 'opacity-60': item.stale === true }"
|
||||
:data-testid="`transfer-item-${item.invoice_no}`"
|
||||
>
|
||||
<td class="p-2">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="isChecked(item)"
|
||||
:disabled="!isCheckable(item) || busy"
|
||||
:data-testid="`transfer-check-${item.invoice_no}`"
|
||||
@change="emit('toggle', item.item_id as number, ($event.target as HTMLInputElement).checked)"
|
||||
/>
|
||||
</td>
|
||||
<!-- 除品名外全列 nowrap:日期/仓库/料号带连字符,列宽不足时从连字符处折行 -->
|
||||
<td class="whitespace-nowrap p-2">{{ item.source_code }}</td>
|
||||
<td class="whitespace-nowrap p-2 font-semibold">{{ item.invoice_no }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.receipt_date || '—' }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.material_no }}</td>
|
||||
<td class="p-2">{{ item.material_name }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.from_warehouse }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ deriveBatchNo(item.lot_no) }}</td>
|
||||
<td class="p-2">
|
||||
<div>{{ formatQuantity(item.from_quantity) }}</div>
|
||||
<!-- 库存查询时刻小字:数据新鲜度溯源(stale 门禁的可见依据) -->
|
||||
<div
|
||||
v-if="checkedAtLabel(item)"
|
||||
class="text-[10px] text-muted"
|
||||
:title="$t('chat.transfer.stockCheckedAtTitle', { time: checkedAtLabel(item) })"
|
||||
:data-testid="`transfer-checked-at-${item.invoice_no}`"
|
||||
>
|
||||
{{ checkedAtLabel(item) }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="whitespace-nowrap p-2">{{ item.to_warehouse }}</td>
|
||||
<td class="whitespace-nowrap p-2">{{ formatQuantity(item.to_quantity) }}</td>
|
||||
<td class="p-2">
|
||||
<div class="flex flex-wrap items-center gap-1">
|
||||
<!-- 阻断原因经悬浮提示(title)透出:不占行高;可执行行也提供重查入口 -->
|
||||
<span
|
||||
class="whitespace-nowrap rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': item.result === 'executable',
|
||||
'bg-amber-50 text-amber-700': item.result === 'not_matured' || item.result === 'pending_stock_check',
|
||||
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'not_matured' && item.result !== 'pending_stock_check',
|
||||
}"
|
||||
:title="reasonTitle(item)"
|
||||
data-testid="transfer-item-result"
|
||||
>
|
||||
{{ $t(resultLabel(item.result)) }}
|
||||
</span>
|
||||
<!-- 行级警示小标:stale(仅展示提示,不拦截执行——2026-09-25 TTL 退役)/ 文件版本已过期 -->
|
||||
<span
|
||||
v-if="item.stale === true"
|
||||
class="rounded border border-amber-300 px-1 py-0.5 text-[10px] text-amber-700"
|
||||
data-testid="transfer-item-stale"
|
||||
>
|
||||
{{ $t('chat.transfer.staleRow') }}
|
||||
</span>
|
||||
<span
|
||||
v-if="item.file_current === false"
|
||||
class="rounded border border-amber-300 px-1 py-0.5 text-[10px] text-amber-700"
|
||||
data-testid="transfer-item-file-changed"
|
||||
>
|
||||
{{ $t('chat.transfer.fileChangedRow') }}
|
||||
</span>
|
||||
<button
|
||||
v-if="isRequeryable(item)"
|
||||
type="button"
|
||||
class="ml-1 rounded border border-brand-200 px-1 text-[10px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:disabled="props.requeryBusy"
|
||||
:data-testid="`transfer-requery-${item.invoice_no}`"
|
||||
@click="emit('requery', [item.invoice_no])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<!-- el-select 默认 width:100%,外包定宽容器与关键字输入并排 -->
|
||||
<div class="w-32 shrink-0">
|
||||
<el-select
|
||||
v-model="resultFilter"
|
||||
size="small"
|
||||
data-testid="transfer-match-result-filter"
|
||||
:aria-label="$t('chat.transfer.colResult')"
|
||||
>
|
||||
<el-option value="all" :label="$t('chat.transfer.filterAll')" />
|
||||
<el-option value="executable" :label="$t('chat.transfer.resultExecutable')" />
|
||||
<el-option value="blocked" :label="$t('chat.transfer.resultBlocked')" />
|
||||
</el-select>
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
size="small"
|
||||
:disabled="props.requeryBusy || selectedRequeryableCount === 0"
|
||||
data-testid="transfer-match-requery-selected"
|
||||
@click="requerySelected"
|
||||
>
|
||||
{{ $t('chat.transfer.requerySelected') }}{{ selectedRequeryableCount ? `(${selectedRequeryableCount})` : '' }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- EP 表格:show-overflow-tooltip + 左右固定列;表体仅当前页切片 -->
|
||||
<el-table
|
||||
v-if="filtered.length"
|
||||
:data="pagedItems"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-match-table"
|
||||
>
|
||||
<el-table-column fixed width="48">
|
||||
<template #header>
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="allFilteredSelected"
|
||||
data-testid="transfer-match-select-all"
|
||||
@change="toggleAll"
|
||||
/>
|
||||
</template>
|
||||
<template #default="{ row }">
|
||||
<el-checkbox
|
||||
size="small"
|
||||
:model-value="isChecked(row as TransferMatchingItem)"
|
||||
:disabled="!isCheckable(row as TransferMatchingItem) || busy"
|
||||
:data-testid="`transfer-check-${row.invoice_no}`"
|
||||
@change="(val: CheckboxValueType) => emit('toggle', row.item_id as number, Boolean(val))"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colSource')" prop="source_code" min-width="120" show-overflow-tooltip />
|
||||
<el-table-column
|
||||
:label="$t('chat.transfer.transferPendingMatchColDocNo')"
|
||||
prop="invoice_no"
|
||||
min-width="130"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold">{{ row.invoice_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
:label="$t('chat.transfer.transferPendingMatchColExternalDoc')"
|
||||
min-width="130"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-match-external-doc">{{ row.external_doc_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMovementDate')" min-width="110" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="140" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="160" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colFromWarehouse')" prop="from_warehouse" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="120" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ deriveBatchNo(row.lot_no) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colFromQty')" min-width="168" show-overflow-tooltip>
|
||||
<template #default="{ row }">
|
||||
<span
|
||||
:class="row.stale === true ? 'text-amber-700' : undefined"
|
||||
:title="freshnessHint(row as TransferMatchingItem, t) || undefined"
|
||||
:data-testid="`transfer-checked-at-${row.invoice_no}`"
|
||||
>
|
||||
{{ stockCell(row as TransferMatchingItem) }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToWarehouse')" prop="to_warehouse" min-width="110" show-overflow-tooltip />
|
||||
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90" show-overflow-tooltip>
|
||||
<template #default="{ row }">{{ formatQuantity(row.to_quantity) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
:label="$t('chat.transfer.colResult')"
|
||||
width="200"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="flex flex-nowrap items-center gap-1">
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="light"
|
||||
:type="resultTagType(row.result)"
|
||||
:title="reasonTitle(row as TransferMatchingItem)"
|
||||
data-testid="transfer-item-result"
|
||||
>
|
||||
{{ $t(resultLabel(row.result)) }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="row.stale === true"
|
||||
size="small"
|
||||
type="warning"
|
||||
effect="plain"
|
||||
:title="$t('chat.transfer.staleRow')"
|
||||
data-testid="transfer-item-stale"
|
||||
>
|
||||
{{ $t('chat.transfer.staleShort') }}
|
||||
</el-tag>
|
||||
<el-tag
|
||||
v-if="row.file_current === false"
|
||||
size="small"
|
||||
type="warning"
|
||||
effect="plain"
|
||||
:title="$t('chat.transfer.fileChangedRow')"
|
||||
data-testid="transfer-item-file-changed"
|
||||
>
|
||||
{{ $t('chat.transfer.fileChangedShort') }}
|
||||
</el-tag>
|
||||
<el-button
|
||||
v-if="isRequeryable(row as TransferMatchingItem)"
|
||||
link
|
||||
type="primary"
|
||||
size="small"
|
||||
:disabled="props.requeryBusy"
|
||||
:data-testid="`transfer-requery-${row.invoice_no}`"
|
||||
@click="emit('requery', [row.invoice_no])"
|
||||
>
|
||||
{{ $t('chat.transfer.requeryRow') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 客户端分页(单页时隐藏):文案走全局 ElConfigProvider 四语言 locale -->
|
||||
<el-pagination
|
||||
v-if="filtered.length > PAGE_SIZE"
|
||||
v-model:current-page="currentPage"
|
||||
:total="filtered.length"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-match-pagination"
|
||||
/>
|
||||
|
||||
<!-- 已失效行折叠提示:文件移除的行退出主视图(证据已失效不可行动),
|
||||
引导去待处理异常池处理(可「标记无需继续处理」),不在主清单占位。 -->
|
||||
<div
|
||||
@@ -433,15 +563,14 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
<!-- [2026-10-12 单据数口径修正] 随勾选联动:按勾选可执行行五元组分组计数 -->
|
||||
{{ $t('chat.transfer.estimatedExternalWrites') }}:{{ estimatedDocumentCountSelected }}
|
||||
</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"
|
||||
<el-button
|
||||
type="primary"
|
||||
:disabled="executeDisabled"
|
||||
:data-testid="'transfer-generate-button'"
|
||||
data-testid="transfer-generate-button"
|
||||
@click="emit('execute', executableCheckedItemIds)"
|
||||
>
|
||||
{{ $t('chat.transfer.generateTransfer') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferMessageView.spec.ts
|
||||
* 用途:验证卡片自驱动接线——匹配卡渲染(勾选键 = 明细 item_id)、点“生成调拨单”
|
||||
* 真实调 /items/execute 并切换结果卡、恢复处理 = 批量重查(不跳匹配卡)、
|
||||
* 真实调 /items/execute 并切换结果卡、待处理异常只保留重查库存(不跳匹配卡)、
|
||||
* 下载按钮调 requestBlob 封装、结果页无审计入口。
|
||||
* 依赖:vi.mock(transfer.api)、vi.mock(useMessage)、@vue/test-utils、i18n。
|
||||
* 逻辑:Mock API 断言调用参数与状态切换(对应后端 197 项测试的契约面)。
|
||||
@@ -10,6 +10,9 @@ import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
// EP el-table 在 jsdom 挂载较重(整文件连跑时部分用例超默认 5s),本 spec 放宽到 30s。
|
||||
vi.setConfig({ testTimeout: 30000 });
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferMatching: vi.fn(),
|
||||
getTransferMatching: vi.fn(),
|
||||
@@ -21,12 +24,13 @@ const api = vi.hoisted(() => ({
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
batchRequeryTransferItems: vi.fn(),
|
||||
batchManualCloseTransferItems: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferInboundFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
listTransferBacklog: vi.fn(),
|
||||
listTransferBacklogPage: vi.fn(),
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
fetchTransferTypes: vi.fn(),
|
||||
retriggerTransferDocument: vi.fn(),
|
||||
closeTransferDocument: vi.fn(),
|
||||
}));
|
||||
@@ -45,7 +49,14 @@ vi.mock('@/shared/composables/useMessage', () => ({
|
||||
}));
|
||||
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
import { eligibleReceiptDateTo } from './transferDate';
|
||||
import { defaultMovementDate } from './transferDate';
|
||||
|
||||
/**
|
||||
* 待处理池服务端分页 envelope(2026-10-16):items=当前页切片,total=筛选后全量计数。
|
||||
*/
|
||||
function backlogPage(items: unknown[], total = items.length) {
|
||||
return { items, total, page: 1, page_size: 20 };
|
||||
}
|
||||
|
||||
const payload = {
|
||||
kind: 'match',
|
||||
@@ -53,9 +64,8 @@ const payload = {
|
||||
matching_id: 'MTG-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, matched_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
counts: { file_invoice_count: 1, matched_count: 1, executable_count: 1, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '1200',
|
||||
estimated_external_write_count: 1,
|
||||
matching_hash: 'sha256:x',
|
||||
@@ -63,7 +73,7 @@ const payload = {
|
||||
items: [{
|
||||
item_id: 101,
|
||||
source_code: 'DBS-AWSBI', material_no: 'MAT-1', material_name: '连接器组件', specification: 'A',
|
||||
invoice_no: 'INV-001', receipt_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', from_quantity: '1200',
|
||||
invoice_no: 'INV-001', movement_date: '2026-08-05', 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' }],
|
||||
@@ -90,19 +100,22 @@ const runPayload = {
|
||||
describe('TransferMessageView self-driving wiring', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.batchRequeryTransferItems.mockResolvedValue({ total: 0, results: [] });
|
||||
api.executeTransferItems.mockResolvedValue({ run_no: 'RUN-1', status: 'success' });
|
||||
api.getTransferRun.mockResolvedValue(runPayload.run);
|
||||
api.downloadTransferReceiptFiles.mockResolvedValue({ blob: new Blob(['z']), filename: 'r.zip' });
|
||||
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['z']), filename: 'r.zip' });
|
||||
api.downloadTransferErpInventory.mockResolvedValue({ blob: new Blob(['c']), filename: 'e.csv' });
|
||||
});
|
||||
|
||||
it('匹配 payload 渲染匹配卡,且默认按 item_id 勾选可执行行', () => {
|
||||
it('匹配 payload 渲染匹配卡,且默认按 item_id 勾选可执行行', async () => {
|
||||
// [断言意图] 匹配卡 EP el-table 行槽位需 flush 后才渲染出 checkbox。
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-match-card"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-check-INV-001"]').element as HTMLInputElement).checked).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-check-INV-001"] input').element as HTMLInputElement).checked).toBe(true);
|
||||
});
|
||||
|
||||
it('点击“生成调拨单”按明细行 id 调 /items/execute 并切换为结果卡', async () => {
|
||||
@@ -110,21 +123,22 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
props: { payload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.executeTransferItems).toHaveBeenCalledWith([101]);
|
||||
expect(wrapper.find('[data-testid="transfer-result-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('结果卡下载按钮调用下载 API(收料来源文件 + ERP 库存表)', async () => {
|
||||
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-inbound"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.downloadTransferReceiptFiles).toHaveBeenCalledWith('RUN-1');
|
||||
expect(api.downloadTransferInboundFiles).toHaveBeenCalledWith('RUN-1');
|
||||
expect(api.downloadTransferErpInventory).toHaveBeenCalledWith('RUN-1');
|
||||
});
|
||||
|
||||
@@ -137,16 +151,19 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
});
|
||||
|
||||
it('backlog 视图拉取待处理列表,行级重查/关闭调用对应 API', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([{
|
||||
api.listTransferBacklogPage.mockResolvedValue(backlogPage([{
|
||||
item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1',
|
||||
status: 'blocked_recoverable', reason: '收料 1200 / ERP 1000', age_days: 1, aging_level: 'normal',
|
||||
receipt_date: '2026-08-05', material_name: '连接器组件', from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01', lot_no: 'LOT-10', receipt_quantity: '1200', external_quantity: '1000',
|
||||
}]);
|
||||
status: 'blocked_recoverable', reason: '异动 1200 / ERP 1000', age_days: 1, aging_level: 'normal',
|
||||
movement_date: '2026-08-05', material_name: '连接器组件', from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01', lot_no: 'LOT-10', movement_quantity: '1200', external_quantity: '1000',
|
||||
}]));
|
||||
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.batchRequeryTransferItems.mockResolvedValue({
|
||||
total: 1,
|
||||
results: [{ item_id: 7, ok: true, status: 'ready_to_execute' }],
|
||||
});
|
||||
api.manualCloseTransferItem.mockResolvedValue({ item_id: 7, status: 'manually_closed' });
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
@@ -157,10 +174,13 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('INV-001');
|
||||
|
||||
// 行级重查(原「重新查询 ERP」改名「重查」,复用单行端点)。
|
||||
// [断言意图] 行上只有重查库存,没有恢复;行级与批量走同一批量重查。
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-resume-INV-001"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain(i18n.global.t('chat.transfer.requeryStock'));
|
||||
await wrapper.find('[data-testid="transfer-backlog-requery-INV-001"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.retryTransferItem).toHaveBeenCalledWith(7);
|
||||
expect(api.retryTransferItem).not.toHaveBeenCalled();
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7]);
|
||||
|
||||
// 行级关闭:弹窗原因必填后提交。
|
||||
await wrapper.find('[data-testid="transfer-backlog-close-INV-001"]').trigger('click');
|
||||
@@ -170,11 +190,11 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
expect(api.manualCloseTransferItem).toHaveBeenCalledWith(7, '线下已处理');
|
||||
});
|
||||
|
||||
it('backlog 批量:勾选后操作条出现,重查/恢复/批量关闭调用对应端点', async () => {
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
it('backlog 批量:勾选后操作条出现,重查库存与批量关闭调用对应端点', async () => {
|
||||
api.listTransferBacklogPage.mockResolvedValue(backlogPage([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
|
||||
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2', status: 'result_unknown', reason: '', age_days: 2, aging_level: 'result_unknown' },
|
||||
]);
|
||||
]));
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 1, closed: 0, unknown: 1, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
@@ -188,24 +208,19 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
await flushPromises();
|
||||
|
||||
// result_unknown 行 checkbox 禁用(只读隔离)。
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-check-INV-002"]').element as HTMLInputElement).disabled).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-backlog-check-INV-002"] input').element as HTMLInputElement).disabled).toBe(true);
|
||||
// 未勾选时批量操作条不存在。
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-batch-requery"]').exists()).toBe(false);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"] input').setValue(true);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-batch-requery"]').exists()).toBe(true);
|
||||
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-batch-resume"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-requery"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7]);
|
||||
|
||||
// 恢复处理(批量)= 同一批量重查端点(恢复的唯一后端)。
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-resume"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7]);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-close"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-close-reason"]').setValue('整批线下处理');
|
||||
await wrapper.find('[data-testid="transfer-close-confirm"]').trigger('click');
|
||||
@@ -215,11 +230,11 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
|
||||
it('backlog 结果徽标:blocked_file_removed 行显示「文件已移除」,普通阻断仍为「已阻断」', async () => {
|
||||
// [断言意图] F1(2026-09-23 评审修复):backlog 行带 result_code 后,
|
||||
// 收料行已从最新文件移除(blocked_file_removed)的行必须与普通数量阻断区分展示。
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-009', material_no: 'MAT-9', status: 'blocked_recoverable', result_code: 'blocked_file_removed', reason: '收料行已从最新文件移除', age_days: 0, aging_level: 'normal' },
|
||||
{ item_id: 10, source_code: 'DBS-AWSBI', invoice_no: 'INV-010', material_no: 'MAT-10', status: 'blocked_recoverable', result_code: 'blocked_quantity_mismatch', reason: '收料 300 / ERP 280', age_days: 0, aging_level: 'normal' },
|
||||
]);
|
||||
// 入站行已从最新文件移除(blocked_file_removed)的行必须与普通数量阻断区分展示。
|
||||
api.listTransferBacklogPage.mockResolvedValue(backlogPage([
|
||||
{ item_id: 9, source_code: 'DBS-AWSBI', invoice_no: 'INV-009', material_no: 'MAT-9', status: 'blocked_recoverable', result_code: 'blocked_file_removed', reason: '入站行已从最新文件移除', age_days: 0, aging_level: 'normal' },
|
||||
{ item_id: 10, source_code: 'DBS-AWSBI', invoice_no: 'INV-010', material_no: 'MAT-10', status: 'blocked_recoverable', result_code: 'blocked_quantity_mismatch', reason: '异动 300 / ERP 280', age_days: 0, aging_level: 'normal' },
|
||||
]));
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 2, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
@@ -229,20 +244,110 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
const removedBadge = wrapper.find('[data-testid="transfer-backlog-INV-009"] [data-testid="transfer-backlog-result"]');
|
||||
const normalBadge = wrapper.find('[data-testid="transfer-backlog-INV-010"] [data-testid="transfer-backlog-result"]');
|
||||
// [断言意图] EP el-table 行不支持逐行 attr,行定位改经 row-class-name 注入的
|
||||
// transfer-backlog-row-<invoice_no> 类(等价定位同一行),徽标 testid 不变。
|
||||
const removedBadge = wrapper.find('.transfer-backlog-row-INV-009 [data-testid="transfer-backlog-result"]');
|
||||
const normalBadge = wrapper.find('.transfer-backlog-row-INV-010 [data-testid="transfer-backlog-result"]');
|
||||
expect(removedBadge.text()).toContain('文件已移除');
|
||||
expect(normalBadge.text()).toContain('已阻断');
|
||||
expect(normalBadge.text()).not.toContain('文件已移除');
|
||||
});
|
||||
|
||||
it('backlog 服务端分页:翻页携带 page 参数重查,当前页渲染切片', async () => {
|
||||
// [断言意图] 大池(现网 951/324 行级)走服务端分页(2026-10-16):待办卡
|
||||
// 翻页上抛 query-change → loadBacklog 合并页码重查;首拉由卡片挂载
|
||||
// query-change 触发且携带默认切片查询(page=1)。
|
||||
api.listTransferBacklogPage
|
||||
.mockResolvedValue(backlogPage(
|
||||
Array.from({ length: 20 }, (_, i) => ({
|
||||
item_id: 100 + i,
|
||||
source_code: 'DBS-AWSBI',
|
||||
invoice_no: `INV-${String(i + 1).padStart(3, '0')}`,
|
||||
material_no: `MAT-${i + 1}`,
|
||||
status: 'blocked_recoverable',
|
||||
reason: '异动 300 / ERP 280',
|
||||
age_days: 0,
|
||||
aging_level: 'normal',
|
||||
})),
|
||||
25,
|
||||
))
|
||||
.mockResolvedValueOnce(backlogPage(
|
||||
Array.from({ length: 20 }, (_, i) => ({
|
||||
item_id: 100 + i,
|
||||
source_code: 'DBS-AWSBI',
|
||||
invoice_no: `INV-${String(i + 1).padStart(3, '0')}`,
|
||||
material_no: `MAT-${i + 1}`,
|
||||
status: 'blocked_recoverable',
|
||||
reason: '异动 300 / ERP 280',
|
||||
age_days: 0,
|
||||
aging_level: 'normal',
|
||||
})),
|
||||
25,
|
||||
))
|
||||
.mockResolvedValueOnce(backlogPage(
|
||||
[{
|
||||
item_id: 120,
|
||||
source_code: 'DBS-AWSBI',
|
||||
invoice_no: 'INV-021',
|
||||
material_no: 'MAT-21',
|
||||
status: 'blocked_recoverable',
|
||||
reason: '异动 300 / ERP 280',
|
||||
age_days: 0,
|
||||
aging_level: 'normal',
|
||||
}],
|
||||
25,
|
||||
));
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 25, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'backlog' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
// [断言意图] 首拉=卡片挂载上抛的默认查询(page=1)。
|
||||
expect(api.listTransferBacklogPage).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ page: 1, pageSize: 20, resultFilter: 'all' }),
|
||||
);
|
||||
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(20);
|
||||
// 翻页:query-change(page=2) → 服务端重查,渲染第 2 页切片。
|
||||
await wrapper.find('.btn-next').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.listTransferBacklogPage).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ page: 2, pageSize: 20 }),
|
||||
);
|
||||
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(1);
|
||||
expect(wrapper.find('.transfer-backlog-row-INV-021').exists()).toBe(true);
|
||||
// [断言意图] 勾选跨页保留:第 2 页勾选 INV-021,翻页/刷新后批量条计数不丢。
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-021"] input').setValue(true);
|
||||
// [断言意图] 操作后无参重拉沿用最近查询(page=2,不跳回第 1 页)。
|
||||
await wrapper.find('[data-testid="transfer-backlog-requery-INV-021"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.listTransferBacklogPage).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ page: 2, pageSize: 20 }),
|
||||
);
|
||||
await wrapper.find('.btn-prev').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-selected-count"]').text()).toContain('1');
|
||||
});
|
||||
|
||||
it('可调拨明细视图:加载全局可执行行,勾选后按行生成调拨单', async () => {
|
||||
// [断言意图] 行归属解耦后的执行入口:executable 视图聚合全部可执行行,
|
||||
// 勾选(item_id)→ /items/execute → 结果卡,恢复后的行在此闭环。
|
||||
// 挂载时拉 GET /transfer-types,调拨类型列显示 names 多语言名而不是 code。
|
||||
api.fetchTransferTypes.mockResolvedValue([{
|
||||
code: 'in_transit_to_hub',
|
||||
names: { 'zh-CN': '在途仓至HUB仓', en: 'In-transit to HUB' },
|
||||
sort_order: 1,
|
||||
transform_rules: [],
|
||||
record_kinds: ['inbound'],
|
||||
}]);
|
||||
api.listExecutableTransferItems.mockResolvedValue({ items: [{
|
||||
item_id: 77, 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',
|
||||
transfer_type: 'in_transit_to_hub',
|
||||
checked_at: '2026-09-23T10:21:00', stale: false, file_current: true,
|
||||
}], counts: { executable_count: 1 } });
|
||||
api.executeTransferItems.mockResolvedValue({ run_no: 'RUN-9', status: 'success' });
|
||||
@@ -254,23 +359,24 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
});
|
||||
await flushPromises();
|
||||
expect(api.listExecutableTransferItems).toHaveBeenCalled();
|
||||
expect(api.fetchTransferTypes).toHaveBeenCalled();
|
||||
expect(wrapper.find('[data-testid="transfer-executable-card"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-executable-type-INV-001"]').text()).toBe('在途仓至HUB仓');
|
||||
|
||||
await wrapper.find('[data-testid="transfer-executable-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-executable-check-INV-001"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-executable-generate"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.executeTransferItems).toHaveBeenCalledWith([77]);
|
||||
expect(wrapper.find('[data-testid="transfer-result-card"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('恢复处理(恢复=重查):按明细 id 调 batch-requery,留在待处理池并统计提示', async () => {
|
||||
// [断言意图] 行式执行重构(2026-09-23):恢复处理不再重建/打开匹配卡,
|
||||
// 语义收敛为按明细 id 重查库存;结果按 status 统计(ready_to_execute=已恢复),
|
||||
// 完成后留在待处理池(fail-closed),toast 汇总 recovered/blocked。
|
||||
api.listTransferBacklog.mockResolvedValue([
|
||||
it('重查库存:按明细 id 调 batch-requery,留在待处理池并报出可执行、仍阻断、失败', async () => {
|
||||
// [断言意图] 待处理异常只有一次库存重查。完成后不打开匹配卡,
|
||||
// toast 同时报出已可执行、仍阻断、失败三笔数。
|
||||
api.listTransferBacklogPage.mockResolvedValue(backlogPage([
|
||||
{ item_id: 7, source_code: 'DBS-AWSBI', invoice_no: 'INV-001', material_no: 'MAT-1', status: 'blocked_recoverable', reason: '', age_days: 0, aging_level: 'normal' },
|
||||
{ item_id: 8, source_code: 'DBS-AWSBI', invoice_no: 'INV-002', material_no: 'MAT-2', status: 'blocked_recoverable', reason: '', age_days: 1, aging_level: 'normal' },
|
||||
]);
|
||||
]));
|
||||
api.getTransferBacklogSummary.mockResolvedValue({
|
||||
recoverable: 2, closed: 0, unknown: 0, aging: { warn_3d: 0, escalate_5d: 0, critical_7d: 0 },
|
||||
});
|
||||
@@ -278,7 +384,7 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
total: 2,
|
||||
results: [
|
||||
{ item_id: 7, invoice_no: 'INV-001', ok: true, status: 'ready_to_execute' },
|
||||
{ item_id: 8, invoice_no: 'INV-002', ok: true, status: 'blocked_recoverable' },
|
||||
{ item_id: 8, invoice_no: 'INV-002', ok: false, error: 'route missing' },
|
||||
],
|
||||
});
|
||||
|
||||
@@ -287,24 +393,31 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"]').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-resume"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-001"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-check-INV-002"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-backlog-batch-requery"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7]);
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7, 8]);
|
||||
expect(api.getTransferMatching).not.toHaveBeenCalled();
|
||||
expect(wrapper.find('[data-testid="transfer-match-card"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-backlog-card"]').exists()).toBe(true);
|
||||
// 恢复统计 toast:1 笔已可执行 · 1 笔仍阻断。
|
||||
// [断言意图] 一句结果同时覆盖三种结局:1 可执行、0 仍阻断、1 失败。
|
||||
expect(messageMocks.success).toHaveBeenCalledTimes(1);
|
||||
const toastText = String(messageMocks.success.mock.calls[0][0]);
|
||||
expect(toastText).toContain('可执行');
|
||||
expect(toastText).toContain('仍阻断');
|
||||
expect(toastText).toContain('1');
|
||||
expect(toastText).toContain(i18n.global.t('chat.transfer.toastRequeryOutcome', { ready: 1, blocked: 0, failed: 1 }));
|
||||
});
|
||||
|
||||
it('来源实例选择:加载列表 → 确认范围 → 创建匹配并切换匹配卡(默认携带 D+1 日期范围)', async () => {
|
||||
it('来源实例选择:加载列表与类型配置 → 确认范围 → 创建匹配并切换匹配卡(默认携带 T−2 日期范围)', async () => {
|
||||
// [断言意图] Task 7 接口化:挂载时并行拉取来源列表与调拨类型配置(fetchTransferTypes),
|
||||
// 类型选项=接口数据渲染进来源卡;确认仍携带缺省(首项)类型 code。
|
||||
api.listTransferSources.mockResolvedValue([
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
]);
|
||||
api.fetchTransferTypes.mockResolvedValue([
|
||||
{ code: 'in_transit_to_hub', names: { 'zh-CN': '在途仓至HUB仓' }, sort_order: 10, transform_rules: [] },
|
||||
{ code: 'hub_to_hub', names: { 'zh-CN': 'HUB仓间调拨' }, sort_order: 30, transform_rules: [] },
|
||||
]);
|
||||
api.createTransferMatching.mockResolvedValue(payload.summary);
|
||||
api.getTransferMatching.mockResolvedValue({
|
||||
summary: payload.summary,
|
||||
@@ -317,15 +430,20 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(api.listTransferSources).toHaveBeenCalled();
|
||||
expect(api.fetchTransferTypes).toHaveBeenCalled();
|
||||
expect(wrapper.find('[data-testid="transfer-source-select-card"]').exists()).toBe(true);
|
||||
// 类型选项=接口下发数据渲染(Task 7 接口化)
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').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();
|
||||
const cutoff = eligibleReceiptDateTo();
|
||||
const defaultDate = defaultMovementDate();
|
||||
expect(api.createTransferMatching).toHaveBeenCalledWith({
|
||||
source_codes: ['DBS-AWSBI'], business_date: undefined,
|
||||
receipt_date_from: cutoff, receipt_date_to: cutoff,
|
||||
movement_date_from: defaultDate, movement_date_to: defaultDate,
|
||||
transfer_type: 'in_transit_to_hub',
|
||||
});
|
||||
expect(wrapper.find('[data-testid="transfer-match-card"]').exists()).toBe(true);
|
||||
@@ -355,12 +473,12 @@ function t13Run(status: string, orders: Array<Record<string, unknown>>) {
|
||||
/** T0:提交后立即(单已建好,全部待处理)。 */
|
||||
const t13Pending = t13Run('queued', [
|
||||
{
|
||||
doc_no: 'HTT-OR-1', receipt_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'HTT-OR-1', movement_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'pending', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M001', '材料甲', 'V1', '100.000000'), t13Line('M002', '材料乙', 'V2', '500.000000')],
|
||||
},
|
||||
{
|
||||
doc_no: 'HTT-OR-2', receipt_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'HTT-OR-2', movement_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'pending', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M003', '材料丙', 'V3', '55.000000')],
|
||||
},
|
||||
@@ -369,16 +487,16 @@ const t13Pending = t13Run('queued', [
|
||||
/** T1:执行中(轮询刷新,逐单亮结果)。 */
|
||||
const t13Executing = t13Run('executing', [
|
||||
{
|
||||
doc_no: 'D-EXE', receipt_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'D-EXE', movement_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'executing', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M001', '材料甲', 'V1', '100.000000')],
|
||||
},
|
||||
{
|
||||
doc_no: 'D-OK', receipt_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'D-OK', movement_date: '2026-09-19', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'success', erp_document_no: '1401-2609230008', error_message: null, lines: [],
|
||||
},
|
||||
{
|
||||
doc_no: 'D-BUS', receipt_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'D-BUS', movement_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'business_failed', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M003', '材料丙', 'V3', '55.000000')],
|
||||
},
|
||||
@@ -387,17 +505,17 @@ const t13Executing = t13Run('executing', [
|
||||
/** T2:终态部分失败(成功 + 结果未知 + 业务失败)。 */
|
||||
const t13Partial = t13Run('partial_failed', [
|
||||
{
|
||||
doc_no: 'D-OK', receipt_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'D-OK', movement_date: '2026-09-23', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'success', erp_document_no: '1401-2609230007', error_message: null,
|
||||
lines: [t13Line('M001', '材料甲', 'V1', '100.000000')],
|
||||
},
|
||||
{
|
||||
doc_no: 'D-UNK', receipt_date: '2026-09-20', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'D-UNK', movement_date: '2026-09-20', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'result_unknown', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M002', '材料乙', 'V2', '500.000000')],
|
||||
},
|
||||
{
|
||||
doc_no: 'D-FAIL', receipt_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
doc_no: 'D-FAIL', movement_date: '2026-09-21', from_warehouse: 'B25', to_warehouse: 'B02',
|
||||
status: 'business_failed', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('MAT-1', '连接器组件', 'LOT-10', '1200.000000', '料号无有效成本')],
|
||||
},
|
||||
@@ -421,7 +539,7 @@ describe('融合卡(Task 13):调拨单清单=进度=结果', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('T0 全待处理:卡顶「排队中」,单行=收料日期·仓库·物料数·合计+待处理徽标,行明细常驻展开,非终态无下载区', async () => {
|
||||
it('T0 全待处理:卡顶「排队中」,单行=异动日期·仓库·物料数·合计+待处理徽标,行明细常驻展开,非终态无下载区', async () => {
|
||||
api.getTransferRun.mockResolvedValue(t13Pending);
|
||||
const wrapper = mountRunView();
|
||||
await flushPromises();
|
||||
@@ -538,7 +656,7 @@ describe('融合卡(Task 13):调拨单清单=进度=结果', () => {
|
||||
// POST /documents/{doc_no}/retry(按单圈行重查+自动重跑)。
|
||||
api.getTransferRun.mockResolvedValue(t13Run('failed', [
|
||||
{
|
||||
doc_no: 'D-FAIL', receipt_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', to_warehouse: 'HUB-CN01',
|
||||
doc_no: 'D-FAIL', movement_date: '2026-08-05', from_warehouse: 'DBS-TRANSIT', to_warehouse: 'HUB-CN01',
|
||||
status: 'business_failed', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('MAT-1', '连接器组件', '', '1200.000000')],
|
||||
},
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferMessageView.vue
|
||||
用途:在途调拨消息卡片的自驱动挂载视图——按 payload 形态渲染卡片,并把卡片按钮
|
||||
(生成调拨单 / 下载 / 重查 / 恢复处理 / 关闭 / 重新触发 / 关闭单)经 useChatTransfer 真实调用 API。
|
||||
(生成调拨单 / 下载 / 重查库存 / 关闭 / 重新触发 / 关闭单)经 useChatTransfer 真实调用 API。
|
||||
依赖:Transfer*Card、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:payload 作为初始状态(ChatLog 回放;历史行无 item_id 仅展示不可选);仅携带
|
||||
matching_id 时按 ID 恢复匹配卡(最近匹配入口);勾选/执行按明细 item_id;
|
||||
来源选择卡重试收料 RPA 为 202 异步——存在抓取中来源时组合式函数自动轮询
|
||||
来源选择卡重试入站 RPA 为 202 异步——存在抓取中来源时组合式函数自动轮询
|
||||
GET /sources,RPA 回调收口后状态自动刷新,离开来源卡即停轮询;
|
||||
恢复处理 = 按明细 id 重查库存(batch-requery 唯一后端),完成后刷新待处理池并
|
||||
统计提示,不再跳转匹配卡;预检卡提交 202(D8)→ 切融合卡 kind='run'(run_no 传卡,
|
||||
来源卡证据清单「重新解析」完成 emit reparsed → loadSources 同步芯片(不走路由 retry);
|
||||
来源选择卡挂载时并行拉取来源列表与调拨类型配置(Task 7 接口化,
|
||||
类型选项=GET /transfer-types 接口下发);
|
||||
可调拨明细/待处理异常挂载时也拉类型配置,表格「调拨类型」列按 names 多语言显示;
|
||||
待处理异常的重查库存(行级与批量)都走 batch-requery,完成后刷新待处理池,
|
||||
并用一句结果报出已可执行、仍阻断、失败;预检卡提交 202(D8)→ 切融合卡 kind='run'(run_no 传卡,
|
||||
轮询由融合卡自驱动,父级停自身轮询),门禁 4xx → useMessage 行内报错 + 预检状态刷新;
|
||||
融合卡失败单「重查库存」复用 batch-requery(会话明细行关联 item_id)、「关闭单」
|
||||
上抛 closed 事件后刷新 run 调拨单清单与可执行池(D18 行脱离回 ready_to_execute);
|
||||
@@ -68,26 +72,34 @@ const busy = ref(false);
|
||||
const closeTarget = ref<TransferBacklogItem | null>(null);
|
||||
/** 批量标记无需处理的明细 id 集合(与单行关闭共用同一弹窗)。 */
|
||||
const batchCloseIds = ref<number[]>([]);
|
||||
/** 正在重试收料 RPA 的来源编码集合(按来源独立展示重试中)。 */
|
||||
/** 正在重试入站 RPA 的来源编码集合(按来源独立展示重试中)。 */
|
||||
const retryingSource = ref<Set<string>>(new Set());
|
||||
/** 上次提交执行的明细行快照(失败单「重查库存」按物料/收料日期关联 item_id 用)。 */
|
||||
/** 上次提交执行的明细行快照(失败单「重查库存」按物料/异动日期关联 item_id 用)。 */
|
||||
const lastExecutedItems = ref<TransferMatchingItem[]>([]);
|
||||
|
||||
const transfer = useChatTransfer();
|
||||
|
||||
/** 待处理异常视图:进入时拉取列表与汇总 */
|
||||
/** 待处理异常视图:进入时拉取列表与汇总(2026-10-16 服务端分页:首拉由
|
||||
* 待办卡挂载时上抛 query-change 触发(携带计数卡切片 initialFilter),
|
||||
* 此处不再兜底首拉避免双请求)。 */
|
||||
onMounted(() => {
|
||||
if (kind.value === 'backlog') {
|
||||
void transfer.loadBacklog();
|
||||
}
|
||||
if (kind.value === 'source-select') {
|
||||
void transfer.loadSources();
|
||||
}
|
||||
// 来源选择、可调拨明细、待处理异常都要类型配置:表格「调拨类型」列按 names 显示名称。
|
||||
if (kind.value === 'source-select' || kind.value === 'executable' || kind.value === 'backlog') {
|
||||
void transfer.loadTransferTypes();
|
||||
}
|
||||
if (kind.value === 'executable') {
|
||||
void transfer.loadExecutableItems();
|
||||
}
|
||||
});
|
||||
|
||||
/** 待办卡查询变更(翻页/筛选/首挂载):转调组合式函数按服务端分页拉取。 */
|
||||
function onBacklogQueryChange(query: { page: number; keyword: string; resultFilter: 'all' | 'recoverable' | 'closed' | 'unknown' }) {
|
||||
void transfer.loadBacklog(query);
|
||||
}
|
||||
|
||||
/** payload 更新时重置本地状态(历史回放/刷新);初始化组合式函数上下文 */
|
||||
function applyPayload(payload?: Record<string, unknown> | null) {
|
||||
if (!payload) return;
|
||||
@@ -121,13 +133,19 @@ watch(mode, (value) => {
|
||||
if (value !== 'source-select') transfer.stopSourcePolling();
|
||||
});
|
||||
|
||||
/** 打包下载选中来源的最新归档收料文件 */
|
||||
async function onDownloadSources(sourceCodes: string[]) {
|
||||
if (!sourceCodes.length) return;
|
||||
/**
|
||||
* 打包下载选中来源的证据文件。
|
||||
* 核心逻辑:把来源卡传来的调拨类型一并 POST;保存名用后端 Content-Disposition
|
||||
* (evidence-files-N.zip),响应没给文件名时才用同一前缀兜底。
|
||||
* @param sourceCodes - 来源编码
|
||||
* @param transferType - 当前所选调拨类型
|
||||
*/
|
||||
async function onDownloadSources(sourceCodes: string[], transferType?: string) {
|
||||
if (!sourceCodes.length || !transferType) return;
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await downloadTransferSourceFiles(sourceCodes);
|
||||
triggerBlobDownload(result.blob, result.filename ?? `receipt-files-${sourceCodes.length}.zip`);
|
||||
const result = await downloadTransferSourceFiles(sourceCodes, transferType);
|
||||
triggerBlobDownload(result.blob, result.filename ?? `evidence-files-${sourceCodes.length}.zip`);
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
@@ -257,9 +275,9 @@ async function onOrderClosed() {
|
||||
}
|
||||
}
|
||||
|
||||
async function onDownloadReceipt() {
|
||||
async function onDownloadInbound() {
|
||||
try {
|
||||
await transfer.downloadReceiptFiles();
|
||||
await transfer.downloadInboundFiles();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
}
|
||||
@@ -281,25 +299,19 @@ async function onDownloadExceptions() {
|
||||
}
|
||||
}
|
||||
|
||||
async function onBacklogRetry(itemId: number) {
|
||||
busy.value = true;
|
||||
try {
|
||||
await transfer.retry(itemId);
|
||||
await transfer.loadBacklog();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 批量重查(待处理池多选):逐行隔离,完成后刷新列表并弹汇总。 */
|
||||
/**
|
||||
* 待处理异常重查库存(行级与批量同一入口)。
|
||||
* 核心逻辑:调 batch-requery,按返回行分成已可执行、仍阻断、失败后提示,再刷新本列表。
|
||||
* @param itemIds - 要重查的明细 id
|
||||
*/
|
||||
async function onBacklogRequery(itemIds: number[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await transfer.batchRequery(itemIds);
|
||||
const ok = result.results.filter((entry) => entry.ok).length;
|
||||
notifySuccess(t('chat.transfer.toastRequeryDone', { ok, failed: result.total - ok }));
|
||||
const ready = result.results.filter((entry) => entry.ok && entry.status === 'ready_to_execute').length;
|
||||
const failed = result.results.filter((entry) => !entry.ok).length;
|
||||
const blocked = result.results.length - ready - failed;
|
||||
notifySuccess(t('chat.transfer.toastRequeryOutcome', { ready, blocked, failed }));
|
||||
await transfer.loadBacklog();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
@@ -308,24 +320,6 @@ async function onBacklogRequery(itemIds: number[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复处理(行级/多选):恢复语义 = 按明细 id 重查库存(batch-requery 唯一后端);
|
||||
* 完成后刷新待处理池,并按结果统计提示(ready_to_execute 计为已可执行,其余仍阻断);
|
||||
* 不再跳转匹配卡(行式执行重构后恢复与匹配卡解耦)。 */
|
||||
async function onBacklogResume(itemIds: number[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await transfer.resume(itemIds);
|
||||
await transfer.loadBacklog();
|
||||
const recovered = result.results.filter((entry) => entry.status === 'ready_to_execute').length;
|
||||
const still = result.total - recovered;
|
||||
notifySuccess(t('chat.transfer.toastRequeryRecovered', { recovered, blocked: still }));
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function onBacklogClose(item: TransferBacklogItem) {
|
||||
closeTarget.value = item;
|
||||
}
|
||||
@@ -360,7 +354,7 @@ async function onCloseConfirm(reason: string) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 来源实例选择确认 → 创建匹配并切换匹配卡(决策 4:两步第一步;收料日期范围为查询范围;调拨类型决定数据范围) */
|
||||
/** 来源实例选择确认 → 创建匹配并切换匹配卡(决策 4:两步第一步;异动日期范围为查询范围;调拨类型决定数据范围) */
|
||||
async function onSourceConfirm(
|
||||
sourceCodes: string[],
|
||||
dateRange?: { from?: string; to?: string },
|
||||
@@ -380,18 +374,25 @@ async function onSourceConfirm(
|
||||
}
|
||||
}
|
||||
|
||||
/** 对来源(单个或批量)重新触发收料 RPA 抓取,重试期间标记该来源(busy 独立于 confirm busy)。 */
|
||||
async function onSourceRetry(sourceCodes: string[]) {
|
||||
/**
|
||||
* 对来源重试证据流,重试期间标记该来源(busy 独立于 confirm busy)。
|
||||
* 核心逻辑:批量按钮无论选中几个来源都走 retry-rpa-batch,body 由组合式函数写成
|
||||
* { source_codes, transfer_type }。只有行内 ↻(detail.recordKind)走单源重试,body 为 { record_kind }。
|
||||
* @param sourceCodes - 来源编码
|
||||
* @param detail - 行内 ↻ 带 recordKind;批量按钮只带 transferType
|
||||
*/
|
||||
async function onSourceRetry(
|
||||
sourceCodes: string[],
|
||||
detail?: { recordKind?: 'inbound' | 'outbound'; transferType?: string },
|
||||
) {
|
||||
const codes = Array.isArray(sourceCodes) ? sourceCodes : [sourceCodes];
|
||||
retryingSource.value = new Set([...retryingSource.value, ...codes]);
|
||||
try {
|
||||
// 多来源一次批量端点(合并单 batch trigger,Worker 单次浏览器会话串行导出);
|
||||
// 单来源沿用原接口(行级 ↻ 一源一文件语义不变)。
|
||||
const [first, ...rest] = codes;
|
||||
if (rest.length > 0) {
|
||||
await transfer.retrySourcesRpaBatch(codes);
|
||||
} else if (first !== undefined) {
|
||||
await transfer.retrySourceRpa(first);
|
||||
const [first] = codes;
|
||||
if (detail?.recordKind && first !== undefined && codes.length === 1) {
|
||||
await transfer.retrySourceRpa(first, detail.recordKind);
|
||||
} else if (codes.length > 0) {
|
||||
await transfer.retrySourcesRpaBatch(codes, detail?.transferType);
|
||||
}
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
@@ -412,11 +413,13 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
<TransferSourceSelectCard
|
||||
v-else-if="mode === 'source-select'"
|
||||
:sources="transfer.sourceOptions.value"
|
||||
:transfer-types="transfer.transferTypes.value"
|
||||
:busy="busy"
|
||||
:retrying="retryingSource"
|
||||
@confirm="onSourceConfirm"
|
||||
@download="onDownloadSources"
|
||||
@retry="onSourceRetry"
|
||||
@reparsed="transfer.loadSources()"
|
||||
/>
|
||||
<TransferMatchCard
|
||||
v-else-if="mode === 'match' && summaryRef"
|
||||
@@ -434,6 +437,7 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
<TransferExecutableCard
|
||||
v-else-if="mode === 'executable'"
|
||||
:items="transfer.executableItems.value"
|
||||
:transfer-types="transfer.transferTypes.value"
|
||||
:busy="busy"
|
||||
@refresh="() => transfer.loadExecutableItems()"
|
||||
@requery="onExecutableRequery"
|
||||
@@ -445,7 +449,7 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
v-else-if="(mode === 'run' || mode === 'result') && (runNo || run?.run_no)"
|
||||
:run-no="runNo || String(run?.run_no ?? '')"
|
||||
:initial-run="run"
|
||||
@download-receipt="onDownloadReceipt"
|
||||
@download-inbound="onDownloadInbound"
|
||||
@download-erp="onDownloadErp"
|
||||
@download-exceptions="onDownloadExceptions"
|
||||
@retry="onOrderRetry"
|
||||
@@ -454,11 +458,12 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
<TransferBacklogSummaryCard
|
||||
v-else-if="mode === 'backlog'"
|
||||
:items="transfer.backlog.value"
|
||||
:total="transfer.backlogTotal.value"
|
||||
:transfer-types="transfer.transferTypes.value"
|
||||
:busy="busy"
|
||||
:initial-filter="backlogInitialFilter"
|
||||
@retry="onBacklogRetry"
|
||||
@query-change="onBacklogQueryChange"
|
||||
@requery="onBacklogRequery"
|
||||
@resume="onBacklogResume"
|
||||
@close="onBacklogClose"
|
||||
@batch-close="onBacklogBatchClose"
|
||||
@refresh="() => transfer.loadBacklog()"
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferPendingMatchPanel.spec.ts
|
||||
* 用途:验证待匹配清单展示外部单号与合计数量,且不再提供清空重解析入口。
|
||||
* 依赖:@vue/test-utils、i18n。
|
||||
* 逻辑:两段表格都渲染外部单号,不渲染外部项次;空白显示占位;翻页只上抛页码。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import TransferPendingMatchPanel from './TransferPendingMatchPanel.vue';
|
||||
import type { TransferPendingMatchRecord } from '../../types/transfer.types';
|
||||
|
||||
const records: TransferPendingMatchRecord[] = [
|
||||
{
|
||||
ledger_record_id: 101,
|
||||
doc_no: 'HOM-901',
|
||||
external_doc_no: 'ASN-100',
|
||||
material_code: 'MAT-9',
|
||||
material_name: '未匹配物料',
|
||||
movement_date: '2026-08-04',
|
||||
source_code: 'DBS-AWSBI',
|
||||
record_kind: 'inbound',
|
||||
quantity: '55',
|
||||
},
|
||||
{
|
||||
ledger_record_id: 102,
|
||||
doc_no: 'HOM-901',
|
||||
external_doc_no: '',
|
||||
material_code: 'MAT-8',
|
||||
material_name: '未匹配物料二',
|
||||
movement_date: '2026-08-05',
|
||||
source_code: 'DBS-AWSBI',
|
||||
record_kind: 'inbound',
|
||||
quantity: '12',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* 挂载面板并等到表格行上屏。
|
||||
* @param customRecords - 下段「其余已落档」当前页
|
||||
* @param matchableRecords - 上段「当前可匹配」当前页
|
||||
*/
|
||||
async function mountFlushedPanel(
|
||||
customRecords: TransferPendingMatchRecord[] = records,
|
||||
matchableRecords: TransferPendingMatchRecord[] = [],
|
||||
) {
|
||||
const wrapper = mount(TransferPendingMatchPanel, {
|
||||
props: { records: customRecords, matchableRecords },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
describe('TransferPendingMatchPanel 外部单号列', () => {
|
||||
it('两段清单都显示外部单号和总数量,不显示项次,且没有清空重解析', async () => {
|
||||
const wrapper = await mountFlushedPanel(records, [records[0]]);
|
||||
const docs = wrapper.findAll('[data-testid="transfer-pending-match-external-doc"]').map((node) => node.text());
|
||||
// [断言意图] 上段与下段都渲染外部单号;空白显示占位。项次列已取消。
|
||||
expect(docs).toEqual(['ASN-100', 'ASN-100', '—']);
|
||||
expect(wrapper.find('[data-testid="transfer-pending-match-external-line"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain(i18n.global.t('chat.transfer.transferPendingMatchColExternalDoc'));
|
||||
expect(wrapper.text()).toContain(i18n.global.t('chat.transfer.transferPendingMatchColQuantity'));
|
||||
expect(wrapper.text()).toContain('55');
|
||||
// [断言意图] 整桶重解析入口已下线,行上不再出现该按钮。
|
||||
expect(wrapper.find('[data-testid="transfer-pending-match-reparse"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('待匹配清单服务端分页:翻页上抛 page-change 由宿主拉取对应页', async () => {
|
||||
const pageRecords = Array.from({ length: 20 }, (_, i) => ({
|
||||
ledger_record_id: 200 + i,
|
||||
doc_no: `HOM-${900 + i}`,
|
||||
external_doc_no: `EXT-${i}`,
|
||||
material_code: `MAT-${i}`,
|
||||
material_name: '未匹配物料',
|
||||
movement_date: '2026-08-05',
|
||||
source_code: 'DBS-AWSBI',
|
||||
quantity: '1',
|
||||
}));
|
||||
const wrapper = await mountFlushedPanel(pageRecords);
|
||||
await wrapper.setProps({ total: 25 });
|
||||
expect(wrapper.findAll('tr.el-table__row')).toHaveLength(20);
|
||||
await wrapper.find('.btn-next').trigger('click');
|
||||
// [断言意图] 组件不自行改数据:翻页仅上抛 page-change({page:2})。
|
||||
expect(wrapper.emitted('page-change')?.[0][0]).toEqual({ page: 2 });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,243 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferPendingMatchPanel.vue
|
||||
用途:「待匹配」桶只读清单。上段是启用类型现在圈得住的行,带「去匹配」;
|
||||
下段是其余已落档。两段都按外部单号展示,数量是该单号的合计。
|
||||
依赖:Element Plus ElTable/ElTableColumn/ElButton/ElPagination、props.records、i18n。
|
||||
逻辑:清单不提供重解析。重解析在来源卡,只重放当天最新一份归档。
|
||||
2026-10-22 起移除行上「清空并重新解析」,并不再展示外部项次。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElPagination, ElTable, ElTableColumn } from 'element-plus';
|
||||
import { TRANSFER_PAGE_SIZE } from '../../composables/useChatTransfer';
|
||||
import type {
|
||||
TransferPendingMatchRecord,
|
||||
TransferRecordKind,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 其余已落档的当前页(segment=outside)。 */
|
||||
records: TransferPendingMatchRecord[];
|
||||
/** 其余已落档的全量计数。 */
|
||||
total?: number;
|
||||
/** 当前可匹配的当前页(segment=matchable)。 */
|
||||
matchableRecords?: TransferPendingMatchRecord[];
|
||||
/** 当前可匹配的全量计数。 */
|
||||
matchableTotal?: number;
|
||||
busy?: boolean;
|
||||
}>(), {
|
||||
total: 0,
|
||||
matchableRecords: () => [],
|
||||
matchableTotal: 0,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 「去匹配」引导:切到现有库存匹配入口(来源选择卡),清单本身不提供执行动作。 */
|
||||
'go-match': [];
|
||||
refresh: [];
|
||||
/** 其余已落档翻页。 */
|
||||
'page-change': [query: { page: number }];
|
||||
/** 当前可匹配翻页。 */
|
||||
'matchable-page-change': [query: { page: number }];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
/** 分页页码(本地 UI 态;数据由父级按 page-change 拉取后经 props 回流)。
|
||||
* 翻页/收拢统一经 watch(currentPage) 上抛(单一出口,收拢也通知宿主重拉)。 */
|
||||
const PAGE_SIZE = TRANSFER_PAGE_SIZE;
|
||||
const currentPage = ref(1);
|
||||
const matchablePage = ref(1);
|
||||
|
||||
watch(currentPage, (page) => emit('page-change', { page }));
|
||||
watch(matchablePage, (page) => emit('matchable-page-change', { page }));
|
||||
|
||||
/**
|
||||
* 桶变小后把页码收回最后一页,避免停在空白页。
|
||||
* @param page - 当前页码 ref
|
||||
* @param total - 该段全量计数
|
||||
*/
|
||||
function clampPage(page: typeof currentPage, total: number) {
|
||||
const maxPage = Math.max(1, Math.ceil(total / PAGE_SIZE));
|
||||
if (page.value > maxPage) page.value = maxPage;
|
||||
}
|
||||
|
||||
watch(() => props.total, (total = 0) => clampPage(currentPage, total));
|
||||
watch(() => props.matchableTotal, (total = 0) => clampPage(matchablePage, total));
|
||||
|
||||
/**
|
||||
* 表格行键:合并后的代表档 id 加内部单号,避免同一单号多行撞键。
|
||||
* @param record - 待匹配清单行(可能已按外部单号合计)
|
||||
* @returns 行键
|
||||
*/
|
||||
function rowKey(record: TransferPendingMatchRecord): string {
|
||||
return `${record.ledger_record_id}|${record.doc_no}`;
|
||||
}
|
||||
|
||||
/** el-table 行类:注入行定位类(替代旧行 testid)。 */
|
||||
function rowClassName({ row }: { row: TransferPendingMatchRecord }): string {
|
||||
return `transfer-pending-match-row-${row.doc_no}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 行上记录类型展示文案(入站/出站)。
|
||||
* @param kind - 档记录类型;缺省按入站
|
||||
*/
|
||||
function recordKindLabel(kind?: TransferRecordKind | null): string {
|
||||
return kind === 'outbound'
|
||||
? t('chat.transfer.streamOutbound')
|
||||
: t('chat.transfer.streamInbound');
|
||||
}
|
||||
|
||||
/**
|
||||
* 清单单元格展示:空白外部单号显示占位。
|
||||
* @param value - 档上的文本;null、undefined、纯空白都视为没有值
|
||||
* @returns 去空白后的原文,或占位符
|
||||
*/
|
||||
function displayCell(value?: string | null): string {
|
||||
const text = (value ?? '').trim();
|
||||
return text || '—';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-pending-match-panel">
|
||||
<div class="mb-2 flex items-center justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<h3 class="text-sm font-bold text-primary">{{ $t('chat.transfer.transferPendingMatchTitle') }}</h3>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ $t('chat.transfer.transferPendingMatchReadOnlyHint') }}</p>
|
||||
</div>
|
||||
<el-button
|
||||
size="small"
|
||||
data-testid="transfer-pending-match-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<section class="mb-4" data-testid="transfer-pending-match-matchable">
|
||||
<div class="mb-2 flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<h4 class="text-sm font-bold text-primary">{{ $t('chat.transfer.pendingMatchMatchableTitle') }} · {{ matchableTotal }}</h4>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ $t('chat.transfer.pendingMatchMatchableHint') }}</p>
|
||||
</div>
|
||||
<el-button
|
||||
type="primary"
|
||||
color="#4f46e5"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-pending-match-go"
|
||||
@click="emit('go-match')"
|
||||
>
|
||||
{{ $t('chat.transfer.transferPendingMatchGoMatch') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="matchableRecords.length"
|
||||
:data="matchableRecords"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-pending-match-matchable-table"
|
||||
>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColRecordKind')" min-width="72" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ recordKindLabel(row.record_kind) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="doc_no" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }"><span class="font-semibold">{{ row.doc_no || '—' }}</span></template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-pending-match-external-doc">{{ displayCell(row.external_doc_no) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColMaterial')" min-width="110" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.material_code || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColName')" min-width="140">
|
||||
<template #default="{ row }">{{ row.material_name || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDate')" min-width="100" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColQuantity')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.quantity ?? '—' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination
|
||||
v-if="matchableTotal > PAGE_SIZE"
|
||||
v-model:current-page="matchablePage"
|
||||
:total="matchableTotal"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-pending-match-matchable-pagination"
|
||||
/>
|
||||
<div v-else-if="!matchableRecords.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.pendingMatchMatchableEmpty') }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section data-testid="transfer-pending-match-outside">
|
||||
<div class="mb-2">
|
||||
<h4 class="text-sm font-bold text-primary">{{ $t('chat.transfer.pendingMatchOutsideTitle') }}</h4>
|
||||
<p class="mt-0.5 text-xs text-muted">{{ $t('chat.transfer.pendingMatchOutsideHint') }}</p>
|
||||
</div>
|
||||
<el-table
|
||||
v-if="records.length"
|
||||
:data="records"
|
||||
:row-key="rowKey"
|
||||
:row-class-name="rowClassName"
|
||||
size="small"
|
||||
class="text-xs"
|
||||
data-testid="transfer-pending-match-table"
|
||||
>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColSource')" prop="source_code" min-width="110" class-name="whitespace-nowrap" />
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColRecordKind')" min-width="72" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ recordKindLabel(row.record_kind) }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" prop="doc_no" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span class="font-semibold">{{ row.doc_no || '—' }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">
|
||||
<span data-testid="transfer-pending-match-external-doc">{{ displayCell(row.external_doc_no) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColMaterial')" min-width="110" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.material_code || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColName')" min-width="140">
|
||||
<template #default="{ row }">{{ row.material_name || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDate')" min-width="100" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.movement_date || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColQuantity')" min-width="90" class-name="whitespace-nowrap">
|
||||
<template #default="{ row }">{{ row.quantity ?? '—' }}</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 服务端分页条(单页时隐藏):total=桶全量计数,页码变化统一经 watch 上抛;
|
||||
文案走全局 ElConfigProvider 四语言 locale -->
|
||||
<el-pagination
|
||||
v-if="(total ?? 0) > PAGE_SIZE"
|
||||
v-model:current-page="currentPage"
|
||||
:total="total ?? 0"
|
||||
:page-size="PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-pending-match-pagination"
|
||||
/>
|
||||
<div v-else-if="!records.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-pending-match-empty">
|
||||
{{ $t('chat.transfer.pendingMatchOutsideEmpty') }}
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,10 +1,13 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferProgressCard.vue
|
||||
用途:Run 执行进度卡(页面关闭/刷新后经 run_no 恢复)。
|
||||
依赖:props(runNo/status/busy)、i18n chat.transfer.*。
|
||||
依赖:Element Plus ElTag/ElButton(2026-10-20 EP 组件化)、props(runNo/status/busy)、
|
||||
i18n chat.transfer.*。
|
||||
逻辑:展示 Run 编号与状态,提供刷新按钮;页面刷新不取消后台 Run。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { ElButton, ElTag } from 'element-plus';
|
||||
|
||||
defineProps<{
|
||||
runNo: string;
|
||||
status: string;
|
||||
@@ -25,36 +28,43 @@ function statusLabel(status: string): string {
|
||||
};
|
||||
return map[status] ?? 'chat.transfer.runExecuting';
|
||||
}
|
||||
|
||||
/**
|
||||
* Run 状态 → el-tag type。
|
||||
* @param status Run 状态码(executing / success / partial_failed / failed / cancelled)
|
||||
* @returns el-tag type
|
||||
*/
|
||||
function statusTagType(status: string): 'primary' | 'success' | 'warning' | 'danger' {
|
||||
if (status === 'executing') return 'primary';
|
||||
if (status === 'success') return 'success';
|
||||
if (status === 'partial_failed') return 'warning';
|
||||
return 'danger';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-progress-card">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div>
|
||||
<div class="text-sm font-bold text-primary">{{ $t('chat.transfer.runProgress') }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ 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',
|
||||
}"
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="light"
|
||||
:type="statusTagType(status)"
|
||||
data-testid="transfer-run-status"
|
||||
>
|
||||
{{ $t(statusLabel(status)) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1 text-xs font-bold text-secondary hover-surface-soft"
|
||||
</el-tag>
|
||||
<el-button
|
||||
size="small"
|
||||
:disabled="busy"
|
||||
data-testid="transfer-run-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ $t('chat.transfer.refreshProgress') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,13 +1,15 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferResultCard.vue
|
||||
用途:融合卡(D9:调拨单清单=进度=结果)——props { run_no } 自驱动轮询 GET /runs/{run_no},
|
||||
逐单展示「收料日期 · 拨出→拨入 · N 物料 · 合计」与状态徽标(待处理/执行中/ERP 单号/失败),
|
||||
逐单展示「异动日期 · 拨出→拨入 · N 物料 · 合计」与状态徽标(待处理/执行中/ERP 单号/失败),
|
||||
行明细常驻展开(Invoice | 料号 | 品名 | 拨出批号 | 投入数量,列序对齐可调拨明细);
|
||||
单据级动作与状态徽标同排头部右侧(2026-09-29 方案A):result_unknown [重新触发]
|
||||
(D11 唯一出口,幂等只触发末步);失败行 [重试](emit 上抛,复用既有 batch-requery)+
|
||||
[关闭单](D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线确认);
|
||||
终态出下载区。无取消执行入口(D9)。
|
||||
依赖:props.runNo/initialRun、useChatTransfer(自有实例轮询:startRunPolling/refreshRun)、
|
||||
依赖:Element Plus ElTag/ElButton/ElTable/ElTableColumn/ElDialog/ElInput
|
||||
(2026-10-20 EP 组件化:徽标/动作/行表明细/确认弹层迁 EP)、
|
||||
props.runNo/initialRun、useChatTransfer(自有实例轮询:startRunPolling/refreshRun)、
|
||||
transfer.api(retriggerTransferDocument/closeTransferDocument)、useMessage、i18n chat.transfer.*。
|
||||
逻辑:挂载即拉取打底一帧并按 4s 轮询直至 run 终态(onUnmounted 停止);单次失败保留旧值并显示
|
||||
「连接中…」;卡顶徽标按单汇总(全成功→成功/混合→部分失败/全失败→失败/全待处理→排队中/其余→执行中);
|
||||
@@ -18,12 +20,16 @@
|
||||
行文案优先行级 message(人话原因)、状态码标签兜底。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ElButton, ElDialog, ElInput, ElPagination, ElTable, ElTableColumn, ElTag } from 'element-plus';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { isTerminalRunStatus, useChatTransfer } from '../../composables/useChatTransfer';
|
||||
import { closeTransferDocument, retriggerTransferDocument } from '../../api/transfer.api';
|
||||
import type { TransferRunResult, TransferOrder, TransferOrderLine, TransferExceptionItem } from '../../types/transfer.types';
|
||||
import { transferDialogShellAttrs } from './transferDialogShell';
|
||||
import type { TransferRunResult, TransferOrder, TransferExceptionItem } from '../../types/transfer.types';
|
||||
|
||||
type TagType = 'info' | 'success' | 'danger' | 'primary' | 'warning';
|
||||
|
||||
const props = defineProps<{
|
||||
/** Run 编号(必传):自驱动轮询与重新触发的目标 Run。 */
|
||||
@@ -33,7 +39,7 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
downloadReceipt: [];
|
||||
downloadInbound: [];
|
||||
downloadErp: [];
|
||||
downloadExceptions: [];
|
||||
/** 失败单 [重试]:上抛父级调 POST /documents/{doc_no}/retry(一键重查+自动重跑)。 */
|
||||
@@ -67,7 +73,7 @@ const orders = computed<TransferOrder[]>(() => {
|
||||
if (Array.isArray(data.orders) && data.orders.length) return data.orders;
|
||||
return (data.result?.external_documents ?? []).map((doc) => ({
|
||||
doc_no: doc.document_no,
|
||||
receipt_date: '',
|
||||
movement_date: '',
|
||||
from_warehouse: doc.from_warehouse,
|
||||
to_warehouse: doc.to_warehouse,
|
||||
status: 'success' as const,
|
||||
@@ -83,29 +89,41 @@ const orders = computed<TransferOrder[]>(() => {
|
||||
}));
|
||||
});
|
||||
|
||||
/** 客户端分页(2026-10-22,50/页):积压日建单可达数百张、行明细常驻展开,
|
||||
* 全量直染 DOM 失控;切片渲染 + 单量减少收拢当前页防空白页。 */
|
||||
const ORDER_PAGE_SIZE = 50;
|
||||
const orderPage = ref(1);
|
||||
const pagedOrders = computed(() =>
|
||||
orders.value.slice((orderPage.value - 1) * ORDER_PAGE_SIZE, orderPage.value * ORDER_PAGE_SIZE),
|
||||
);
|
||||
watch(() => orders.value.length, (len) => {
|
||||
const maxPage = Math.max(1, Math.ceil(len / ORDER_PAGE_SIZE));
|
||||
if (orderPage.value > maxPage) orderPage.value = maxPage;
|
||||
});
|
||||
|
||||
/** 卡顶徽标(按单汇总):全成功族→成功;全失败族→失败;全待处理→排队中;
|
||||
* 仍有在飞单→执行中;其余混合→部分失败。
|
||||
* [P2-5 计划字面偏差说明] 全 result_unknown 均质单组归「部分失败」而非计划字面的
|
||||
* 「其余→执行中」:finalize_run 语义下 result_unknown 属「未成单」,该单组的 run 终态
|
||||
* 只会落 partial_failed/failed(口径见 useChatTransfer.TERMINAL_RUN_STATUSES 注释),
|
||||
* 徽标跟随 run 级收尾口径,避免把已成定局的未成单组误标为仍在执行。 */
|
||||
const runBadge = computed<{ key: string; cls: string }>(() => {
|
||||
const runBadge = computed<{ key: string; type: TagType }>(() => {
|
||||
const list = orders.value;
|
||||
const successFamily = (s: string) => s === 'success' || s === 'duplicate_success';
|
||||
const failedFamily = (s: string) => s === 'business_failed' || s === 'technical_failed';
|
||||
if (!list.length || list.every((item) => item.status === 'pending')) {
|
||||
return { key: 'chat.transfer.runBadge.queued', cls: 'bg-slate-100 text-slate-600' };
|
||||
return { key: 'chat.transfer.runBadge.queued', type: 'info' };
|
||||
}
|
||||
if (list.every((item) => successFamily(item.status))) {
|
||||
return { key: 'chat.transfer.runBadge.success', cls: 'bg-emerald-50 text-emerald-700' };
|
||||
return { key: 'chat.transfer.runBadge.success', type: 'success' };
|
||||
}
|
||||
if (list.every((item) => failedFamily(item.status))) {
|
||||
return { key: 'chat.transfer.runBadge.failed', cls: 'bg-red-50 text-red-700' };
|
||||
return { key: 'chat.transfer.runBadge.failed', type: 'danger' };
|
||||
}
|
||||
if (list.some((item) => item.status === 'pending' || item.status === 'executing')) {
|
||||
return { key: 'chat.transfer.runBadge.executing', cls: 'bg-sky-50 text-sky-700' };
|
||||
return { key: 'chat.transfer.runBadge.executing', type: 'primary' };
|
||||
}
|
||||
return { key: 'chat.transfer.runBadge.partialFailed', cls: 'bg-amber-50 text-amber-700' };
|
||||
return { key: 'chat.transfer.runBadge.partialFailed', type: 'warning' };
|
||||
});
|
||||
|
||||
/** 单据级状态徽标(成功族亮 ERP 单号;无单号回退状态文案,禁止出现 undefined/null)。 */
|
||||
@@ -131,20 +149,24 @@ function orderBadgeText(order: TransferOrder): string {
|
||||
}
|
||||
}
|
||||
|
||||
function orderBadgeCls(order: TransferOrder): string {
|
||||
/**
|
||||
* 单据状态 → el-tag type。
|
||||
* @param order 调拨单投影
|
||||
*/
|
||||
function orderBadgeType(order: TransferOrder): TagType {
|
||||
switch (order.status) {
|
||||
case 'success':
|
||||
case 'duplicate_success':
|
||||
return 'bg-emerald-50 text-emerald-700';
|
||||
return 'success';
|
||||
case 'executing':
|
||||
return 'bg-sky-50 text-sky-700';
|
||||
return 'primary';
|
||||
case 'business_failed':
|
||||
case 'technical_failed':
|
||||
return 'bg-red-50 text-red-700';
|
||||
return 'danger';
|
||||
case 'result_unknown':
|
||||
return 'bg-amber-50 text-amber-700';
|
||||
return 'warning';
|
||||
default:
|
||||
return 'bg-slate-100 text-slate-600';
|
||||
return 'info';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,11 +204,6 @@ function isFailedOrder(order: TransferOrder): boolean {
|
||||
return order.status === 'business_failed' || order.status === 'technical_failed';
|
||||
}
|
||||
|
||||
/** 行明细键(同单内物料+批号唯一)。 */
|
||||
function lineKey(order: TransferOrder, line: TransferOrderLine, index: number): string {
|
||||
return `${order.doc_no}|${line.material_no}|${line.lot_no}|${index}`;
|
||||
}
|
||||
|
||||
/** 未入单异常行文案:行级 message(人话原因,如分组阻断单号)优先;无则回落
|
||||
* 状态码标签映射(blocked/business/technical/unknown/matching_expired)。 */
|
||||
function exceptionReasonText(exc: TransferExceptionItem): string {
|
||||
@@ -292,16 +309,18 @@ async function confirmCloseOrder() {
|
||||
<span class="ml-1 text-xs text-muted">{{ runNo }}</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
<el-tag
|
||||
v-if="pollConnecting"
|
||||
class="rounded-full bg-slate-100 px-2 py-0.5 text-[11px] text-slate-500"
|
||||
size="small"
|
||||
type="info"
|
||||
effect="plain"
|
||||
data-testid="transfer-poll-connecting"
|
||||
>
|
||||
{{ $t('chat.transfer.poll.connecting') }}
|
||||
</span>
|
||||
<span class="rounded-full px-2 py-0.5 text-xs font-bold" :class="runBadge.cls" data-testid="transfer-run-badge">
|
||||
</el-tag>
|
||||
<el-tag size="small" effect="light" :type="runBadge.type" data-testid="transfer-run-badge">
|
||||
{{ $t(runBadge.key) }}
|
||||
</span>
|
||||
</el-tag>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -309,17 +328,18 @@ async function confirmCloseOrder() {
|
||||
{{ $t('chat.transfer.runBadge.queued') }}
|
||||
</div>
|
||||
|
||||
<!-- 调拨单清单(D9:调拨单清单=进度=结果):行明细常驻展开,无取消执行入口 -->
|
||||
<!-- 调拨单清单(D9:调拨单清单=进度=结果):行明细常驻展开,无取消执行入口;
|
||||
表体只挂当前页切片(pagedOrders),分页器单页时隐藏 -->
|
||||
<ul v-else class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="order in orders"
|
||||
v-for="order in pagedOrders"
|
||||
:key="order.doc_no"
|
||||
class="rounded-lg border border-default"
|
||||
:data-testid="`transfer-order-${order.doc_no}`"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
|
||||
<span class="font-semibold text-secondary" :data-testid="`transfer-order-summary-${order.doc_no}`">
|
||||
{{ order.receipt_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
|
||||
{{ order.movement_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
|
||||
· {{ $t('chat.transfer.materialCount', { count: order.lines.length }) }}
|
||||
<template v-if="order.lines.length"> · {{ orderTotalQuantity(order) }} {{ orderUnit(order) }}</template>
|
||||
</span>
|
||||
@@ -327,42 +347,46 @@ async function confirmCloseOrder() {
|
||||
一眼完成,卡片主体回归纯信息展示;动作为单据级(D11 重新触发 / D18 重试+关闭单),
|
||||
testid 不变供规格定位。 -->
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="orderBadgeCls(order)"
|
||||
<el-tag
|
||||
size="small"
|
||||
effect="light"
|
||||
:type="orderBadgeType(order)"
|
||||
:data-testid="`transfer-order-status-${order.doc_no}`"
|
||||
>
|
||||
{{ orderBadgeText(order) }}
|
||||
</span>
|
||||
<button
|
||||
</el-tag>
|
||||
<el-button
|
||||
v-if="order.status === 'result_unknown'"
|
||||
type="button"
|
||||
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
|
||||
size="small"
|
||||
type="warning"
|
||||
plain
|
||||
:data-testid="`transfer-order-retrigger-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click="retriggerTarget = order"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retrigger') }}
|
||||
</button>
|
||||
</el-button>
|
||||
<template v-if="isFailedOrder(order)">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
:data-testid="`transfer-order-retry-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click="emit('retry', order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
type="danger"
|
||||
plain
|
||||
:data-testid="`transfer-order-close-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click="openCloseDialog(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.closeOrder') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -378,29 +402,36 @@ async function confirmCloseOrder() {
|
||||
|
||||
<!-- 行明细常驻展开(物料 × 批号聚合行;Invoice 首列对齐可调拨明细列序) -->
|
||||
<div class="border-t border-subtle px-3 py-2" :data-testid="`transfer-order-lines-${order.doc_no}`">
|
||||
<table class="w-full text-xs">
|
||||
<thead>
|
||||
<tr class="text-left text-[11px] text-muted">
|
||||
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colMaterial') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(line, index) in order.lines" :key="lineKey(order, line, index)" class="border-t border-subtle">
|
||||
<td class="p-1">{{ line.invoice_no || '—' }}</td>
|
||||
<td class="p-1">{{ line.material_no }}</td>
|
||||
<td class="p-1">{{ line.material_name }}</td>
|
||||
<td class="p-1">{{ line.lot_no || '—' }}</td>
|
||||
<td class="p-1">{{ line.quantity }}<template v-if="line.unit"> {{ line.unit }}</template></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<el-table :data="order.lines" size="small" class="text-xs">
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColDocNo')" min-width="110">
|
||||
<template #default="{ row }">{{ row.invoice_no || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.transferPendingMatchColExternalDoc')" min-width="120">
|
||||
<template #default="{ row }">{{ row.external_doc_no || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colMaterial')" prop="material_no" min-width="110" />
|
||||
<el-table-column :label="$t('chat.transfer.colName')" prop="material_name" min-width="120" />
|
||||
<el-table-column :label="$t('chat.transfer.colFromBatch')" min-width="100">
|
||||
<template #default="{ row }">{{ row.lot_no || '—' }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('chat.transfer.colToQty')" min-width="90">
|
||||
<template #default="{ row }">{{ row.quantity }}<template v-if="row.unit"> {{ row.unit }}</template></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- 客户端分页(单页时隐藏):文案走全局 ElConfigProvider 四语言 locale -->
|
||||
<el-pagination
|
||||
v-if="orders.length > ORDER_PAGE_SIZE"
|
||||
v-model:current-page="orderPage"
|
||||
:total="orders.length"
|
||||
:page-size="ORDER_PAGE_SIZE"
|
||||
layout="total, prev, pager, next, jumper"
|
||||
size="small"
|
||||
class="mt-2 justify-end"
|
||||
data-testid="transfer-order-pagination"
|
||||
/>
|
||||
|
||||
<!-- 未入单异常区(2026-09-29 收窄:仅未建单被阻断的行——已建单失败行不重复展示;
|
||||
文案行级 message 优先、状态码标签兜底) -->
|
||||
@@ -423,113 +454,93 @@ async function confirmCloseOrder() {
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- 终态动作:下载异常清单 / 收料文件 / ERP 库存表(父级经 useChatTransfer 真实下载) -->
|
||||
<!-- 终态动作:下载异常清单 / 入站文件 / ERP 库存表(父级经 useChatTransfer 真实下载) -->
|
||||
<div v-if="terminal" class="mt-3 flex flex-wrap gap-2 border-t border-subtle pt-3" data-testid="transfer-result-downloads">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-3 py-1.5 text-xs font-bold text-secondary hover-surface-soft"
|
||||
data-testid="transfer-download-exceptions"
|
||||
@click="emit('downloadExceptions')"
|
||||
>
|
||||
<el-button size="small" data-testid="transfer-download-exceptions" @click="emit('downloadExceptions')">
|
||||
{{ $t('chat.transfer.downloadExceptions') }}
|
||||
</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-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')"
|
||||
>
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" plain data-testid="transfer-download-inbound" @click="emit('downloadInbound')">
|
||||
{{ $t('chat.transfer.downloadInboundFiles') }}
|
||||
</el-button>
|
||||
<el-button size="small" type="primary" plain data-testid="transfer-download-erp" @click="emit('downloadErp')">
|
||||
{{ $t('chat.transfer.downloadErpInventory') }}
|
||||
</button>
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 重新触发确认弹层(D11:说明幂等复用原单只触发末步;无取消执行语义) -->
|
||||
<div
|
||||
<el-dialog
|
||||
v-if="retriggerTarget"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
:model-value="true"
|
||||
v-bind="transferDialogShellAttrs"
|
||||
width="28rem"
|
||||
class="rounded-2xl bg-surface"
|
||||
data-testid="transfer-retrigger-dialog"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<template #header>
|
||||
<h3 class="text-base font-bold text-primary">
|
||||
{{ $t('chat.transfer.retriggerDialog.title', { docNo: retriggerTarget.doc_no }) }}
|
||||
</h3>
|
||||
<p class="mt-2 text-xs text-secondary">{{ $t('chat.transfer.retriggerDialog.body') }}</p>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
|
||||
data-testid="transfer-retrigger-dismiss"
|
||||
@click="retriggerTarget = null"
|
||||
>
|
||||
{{ $t('chat.transfer.retriggerDialog.dismiss') }}
|
||||
</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"
|
||||
data-testid="transfer-retrigger-confirm"
|
||||
:disabled="actionBusy"
|
||||
@click="confirmRetrigger"
|
||||
>
|
||||
{{ $t('chat.transfer.retriggerDialog.confirm') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<p class="text-xs text-secondary">{{ $t('chat.transfer.retriggerDialog.body') }}</p>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<el-button data-testid="transfer-retrigger-dismiss" @click="retriggerTarget = null">
|
||||
{{ $t('chat.transfer.retriggerDialog.dismiss') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
data-testid="transfer-retrigger-confirm"
|
||||
:disabled="actionBusy"
|
||||
@click="confirmRetrigger"
|
||||
>
|
||||
{{ $t('chat.transfer.retriggerDialog.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线) -->
|
||||
<div
|
||||
<el-dialog
|
||||
v-if="closeTarget"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
:model-value="true"
|
||||
v-bind="transferDialogShellAttrs"
|
||||
width="28rem"
|
||||
class="rounded-2xl bg-surface"
|
||||
data-testid="transfer-order-close-dialog"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<template #header>
|
||||
<h3 class="text-base font-bold text-primary">
|
||||
{{ $t('chat.transfer.orderClose.title', { docNo: closeTarget.doc_no }) }}
|
||||
</h3>
|
||||
<p class="mt-1 text-xs text-muted">
|
||||
{{ $t('chat.transfer.orderClose.impactHint', { count: closeTarget.lines.length }) }}
|
||||
</p>
|
||||
<ul class="mt-2 max-h-32 overflow-y-auto rounded-lg bg-surface-soft p-2 text-[11px] text-secondary">
|
||||
<li v-for="(line, index) in closeTarget.lines" :key="`${line.material_no}|${line.lot_no}|${index}`">
|
||||
{{ line.material_no }} {{ line.material_name }} · {{ line.quantity }}<template v-if="line.unit"> {{ line.unit }}</template>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-2 text-xs font-bold text-red-600">{{ $t('chat.transfer.orderClose.redline') }}</p>
|
||||
<textarea
|
||||
v-model="closeReason"
|
||||
rows="3"
|
||||
class="mt-3 w-full rounded-lg border border-default p-2 text-sm"
|
||||
:placeholder="$t('chat.transfer.orderClose.reasonPlaceholder')"
|
||||
data-testid="transfer-order-close-reason"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-4 py-1.5 text-sm text-secondary hover-surface-soft"
|
||||
data-testid="transfer-order-close-dismiss"
|
||||
@click="closeTarget = null"
|
||||
>
|
||||
{{ $t('chat.transfer.orderClose.dismiss') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-red-600 px-4 py-1.5 text-sm font-bold text-white hover:bg-red-700 disabled:cursor-not-allowed disabled:opacity-40"
|
||||
data-testid="transfer-order-close-confirm"
|
||||
:disabled="!closeReason.trim() || actionBusy"
|
||||
@click="confirmCloseOrder"
|
||||
>
|
||||
{{ $t('chat.transfer.orderClose.confirm') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<p class="text-xs text-muted">
|
||||
{{ $t('chat.transfer.orderClose.impactHint', { count: closeTarget.lines.length }) }}
|
||||
</p>
|
||||
<ul class="mt-2 max-h-32 overflow-y-auto rounded-lg bg-surface-soft p-2 text-[11px] text-secondary">
|
||||
<li v-for="(line, index) in closeTarget.lines" :key="`${line.material_no}|${line.lot_no}|${index}`">
|
||||
{{ line.material_no }} {{ line.material_name }} · {{ line.quantity }}<template v-if="line.unit"> {{ line.unit }}</template>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-2 text-xs font-bold text-red-600">{{ $t('chat.transfer.orderClose.redline') }}</p>
|
||||
<el-input
|
||||
v-model="closeReason"
|
||||
type="textarea"
|
||||
:rows="3"
|
||||
class="mt-3"
|
||||
:placeholder="$t('chat.transfer.orderClose.reasonPlaceholder')"
|
||||
data-testid="transfer-order-close-reason"
|
||||
/>
|
||||
<div class="mt-4 flex justify-end gap-2">
|
||||
<el-button data-testid="transfer-order-close-dismiss" @click="closeTarget = null">
|
||||
{{ $t('chat.transfer.orderClose.dismiss') }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
data-testid="transfer-order-close-confirm"
|
||||
:disabled="!closeReason.trim() || actionBusy"
|
||||
@click="confirmCloseOrder"
|
||||
>
|
||||
{{ $t('chat.transfer.orderClose.confirm') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,18 +1,43 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferSourceSelectCard.spec.ts
|
||||
* 用途:来源实例选择卡——平台分组、全选已启用、清空、按收料文件状态门禁确认、
|
||||
* 确认提交、重试收料 RPA。
|
||||
* 用途:来源实例选择卡——平台分组、全选已启用、清空、按所选类型证据流门禁确认、
|
||||
* 确认提交、按流重试;调拨类型选项=接口下发(含 record_kinds):
|
||||
* 选项渲染/名称多语言回退/空配置空态/确认禁用,「即将上线」占位不再出现;
|
||||
* 括号只画当前类型的 record_kinds,抓取中不渲染重试。
|
||||
* 依赖:@vue/test-utils、i18n。
|
||||
* 逻辑:平台 DBS/Crane 仅分组;实例为选择与执行边界(决策 2/3/4);
|
||||
* 确认需至少一个 has_ready_file(兜底告警);混合选择(含非就绪项)先披露范围
|
||||
* 再确认(知情部分确认 2026-10-09,替代历史静默剔除),提交范围 ready-only;
|
||||
* 重试门禁=仅 fetching 在途不可重试(ready 亦可强制重抓,2026-09-29 去管控)。
|
||||
* 确认门禁=所选类型每条流都是 ready 或 no_data;混合选择先披露未就绪流再确认;
|
||||
* 抓取中与未配置不渲染重试,其余状态可重试(ready 亦可强制重抓);
|
||||
* 证据清单默认只显示最新一份,更早点开后才列出;首行「重新解析」走 reparseCurrentFile,不 emit retry;
|
||||
单文件下载走 downloadEvidenceFile,不再把预签名地址放进 href;
|
||||
* 类型选项=props.transferTypes 接口真相(enabled 过滤与排序在后端契约内,
|
||||
* 前端不过滤),名称 names[locale]→zh-CN→en→code 回退,空列表空态+确认禁用。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const transferApiMocks = vi.hoisted(() => ({
|
||||
listEvidenceFiles: vi.fn(),
|
||||
downloadEvidenceFile: vi.fn(),
|
||||
reparseCurrentFile: vi.fn(),
|
||||
}));
|
||||
vi.mock('../../api/transfer.api', () => transferApiMocks);
|
||||
|
||||
const messageMocks = vi.hoisted(() => ({
|
||||
warning: vi.fn(),
|
||||
error: vi.fn(),
|
||||
success: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
}));
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => messageMocks,
|
||||
}));
|
||||
|
||||
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
|
||||
import { eligibleReceiptDateTo } from './transferDate';
|
||||
import { defaultMovementDate, shanghaiBusinessDate } from './transferDate';
|
||||
import type { TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
const readySources = [
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI 在途仓', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
@@ -20,19 +45,65 @@ const readySources = [
|
||||
{ source_code: 'CRANE-SZ', display_name: '深圳在途仓', platform: 'crane', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
];
|
||||
|
||||
function mountCard(props = {}, sources = readySources) {
|
||||
/** 接口下发的调拨类型选项(GET /transfer-types;record_kinds 由范围规则推导,不落库)。 */
|
||||
const defaultTransferTypes: TransferTypeOption[] = [
|
||||
{
|
||||
code: 'in_transit_to_hub',
|
||||
names: { 'zh-CN': '在途仓至HUB仓', 'en': 'In-transit to HUB' },
|
||||
sort_order: 10,
|
||||
transform_rules: [{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' }],
|
||||
record_kinds: ['inbound'],
|
||||
},
|
||||
{
|
||||
code: 'hub_to_hub',
|
||||
names: { 'zh-CN': 'HUB仓间调拨' },
|
||||
sort_order: 30,
|
||||
transform_rules: [],
|
||||
record_kinds: ['inbound', 'outbound'],
|
||||
},
|
||||
];
|
||||
|
||||
/** 双证据流来源:入站就绪、出站抓取中。括号只画当前类型 record_kinds 里的流。 */
|
||||
const hubSource = {
|
||||
source_code: 'DSV360_AWSBI_BYAWSCMH01',
|
||||
display_name: 'CMH01',
|
||||
platform: 'crane',
|
||||
enabled: true,
|
||||
has_ready_file: true,
|
||||
file_status: 'ready' as const,
|
||||
streams: [
|
||||
{ record_kind: 'inbound' as const, file_status: 'ready' as const, has_ready_file: true },
|
||||
{ record_kind: 'outbound' as const, file_status: 'fetching' as const, has_ready_file: false },
|
||||
],
|
||||
};
|
||||
|
||||
function mountCard(props = {}, sources = readySources, transferTypes: TransferTypeOption[] = defaultTransferTypes) {
|
||||
return mount(TransferSourceSelectCard, {
|
||||
props: { sources, ...props },
|
||||
props: { sources, transferTypes, ...props },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
/** 按外壳 data-testid 定位内部 ElDatePicker。 */
|
||||
function datePicker(wrapper: ReturnType<typeof mountCard>, testId: string) {
|
||||
const shell = wrapper.find(`[data-testid="${testId}"]`);
|
||||
const found = shell.findComponent({ name: 'ElDatePicker' });
|
||||
if (!found.exists()) throw new Error(`ElDatePicker ${testId} not found`);
|
||||
return found;
|
||||
}
|
||||
|
||||
/** 切换调拨类型(ElRadioGroup.setValue;裸 click 不一定落到 is-active)。 */
|
||||
async function selectTransferType(wrapper: ReturnType<typeof mountCard>, code: string) {
|
||||
await wrapper.findComponent({ name: 'ElRadioGroup' }).setValue(code);
|
||||
}
|
||||
|
||||
describe('TransferSourceSelectCard', () => {
|
||||
// EP DatePicker/Radio 首挂较重,并行套件下偶发超默认 5s。
|
||||
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');
|
||||
});
|
||||
}, 30_000);
|
||||
|
||||
it('未选任何来源时确认按钮禁用(需至少一个 ready 文件来源)', () => {
|
||||
const wrapper = mountCard();
|
||||
@@ -54,6 +125,23 @@ describe('TransferSourceSelectCard', () => {
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('只选抓取中来源时确认仍可点,警告点名该流且不提交', async () => {
|
||||
// [断言意图] 全部被挡住时确认按钮不静默禁用;点击后提示「来源编码 + 入站 + 抓取中」,不提交。
|
||||
const wrapper = mountCard({}, [
|
||||
{ source_code: 'DSV-FETCH', display_name: 'fetching', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'fetching' as const },
|
||||
]);
|
||||
await wrapper.find('[data-testid="transfer-source-option-DSV-FETCH"] input').setValue(true);
|
||||
const confirm = wrapper.find('[data-testid="transfer-source-confirm"]');
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(false);
|
||||
await confirm.trigger('click');
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
const warning = String(messageMocks.warning.mock.calls.at(-1)?.[0] ?? '');
|
||||
expect(warning).toContain('DSV-FETCH');
|
||||
expect(warning).toContain('入站');
|
||||
expect(warning).toContain('抓取中');
|
||||
expect(warning).not.toContain('请先重试入站 RPA');
|
||||
});
|
||||
|
||||
it('“全选可见”勾选全部启用实例,混合选择先披露再确认 ready-only', async () => {
|
||||
// [断言意图] 知情部分确认(2026-10-09):混合选择(2 ready + 1 none)点确认先出现
|
||||
// 披露条且不提交;披露后确认只携带具备 ready 文件的来源码。
|
||||
@@ -136,12 +224,14 @@ describe('TransferSourceSelectCard', () => {
|
||||
});
|
||||
|
||||
it('parse_failed 显示解析失败徽标且可重试', async () => {
|
||||
// [断言意图] 当日收料文件解析失败(file_status=parse_failed)不得误报就绪;
|
||||
// 与 none/failed/expired 一样允许重新触发收料 RPA。
|
||||
// [断言意图] 当日入站文件解析失败(file_status=parse_failed)不得误报就绪;
|
||||
// 与 none/failed/expired 一样允许重新触发入站 RPA。
|
||||
const wrapper = mountCard({}, [
|
||||
{ source_code: 'DSV-BAD', display_name: 'bad', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'parse_failed' as const },
|
||||
]);
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-DSV-BAD"]').text()).toBe('解析失败');
|
||||
// [断言意图] 方案 A:状态芯片与重试钮分离;芯片含 ▾,↻ 不在芯片文案里。
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-DSV-BAD"]').text()).toBe('入站 !解析失败 ▾');
|
||||
expect(wrapper.find('[data-testid="transfer-source-retry-DSV-BAD"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-source-retry-DSV-BAD"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
|
||||
@@ -169,35 +259,44 @@ describe('TransferSourceSelectCard', () => {
|
||||
expect(wrapper.emitted('confirm')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('D+1 规则提示收进 ⓘ 悬浮(title),不再平铺占宽', () => {
|
||||
it('日期默认值提示收进 ⓘ 悬浮(title),不再平铺占宽', () => {
|
||||
// [断言意图] 长规则文案通过原生 title 渐进披露,紧凑日期行不换行错位。
|
||||
const wrapper = mountCard();
|
||||
const title = wrapper.find('[data-testid="transfer-source-date-hint"]').attributes('title') ?? '';
|
||||
expect(title).toContain('D+1 规则');
|
||||
expect(title).toContain('业务日期前一天');
|
||||
expect(title).toContain('T−2');
|
||||
expect(title).toContain('业务日期');
|
||||
});
|
||||
|
||||
it('收料日期默认为 D+1 规则日期(T-1)且上限锁定(输入期限制)', () => {
|
||||
// [断言意图] 默认值与 max 均为上海口径 T-1,未来日期在选择器层面不可选。
|
||||
it('异动日期默认与上限同为 T−2 可匹配截止日(T−2 管控恢复),movementDateLabel 文案渲染', () => {
|
||||
// [断言意图] 默认值=T−2 产品默认作业点;disabled-date 卡 T−2 之后(T−1/当天/
|
||||
// 未来均无成熟数据,不可选;越界另由后端 MOVEMENT_DATE_RANGE_INVALID 兜底);
|
||||
// 日期标签 i18n 键 chat.transfer.movementDateLabel(Task 5,值=异动日期)。
|
||||
const wrapper = mountCard();
|
||||
const from = wrapper.find('[data-testid="transfer-source-date-from"]').element as HTMLInputElement;
|
||||
const to = wrapper.find('[data-testid="transfer-source-date-to"]').element as HTMLInputElement;
|
||||
const cutoff = eligibleReceiptDateTo();
|
||||
expect(from.value).toBe(cutoff);
|
||||
expect(to.value).toBe(cutoff);
|
||||
expect(from.max).toBe(cutoff);
|
||||
expect(to.max).toBe(cutoff);
|
||||
const from = datePicker(wrapper, 'transfer-source-date-from');
|
||||
const to = datePicker(wrapper, 'transfer-source-date-to');
|
||||
const today = shanghaiBusinessDate();
|
||||
expect(from.props('modelValue')).toBe(defaultMovementDate());
|
||||
expect(to.props('modelValue')).toBe(defaultMovementDate());
|
||||
const [y, m, d] = today.split('-').map(Number);
|
||||
const [maxY, maxM, maxD] = defaultMovementDate().split('-').map(Number);
|
||||
const disabledFrom = from.props('disabledDate') as (date: Date) => boolean;
|
||||
// [边界] T−2 恰好可选;T(当天)与未来日都晚于截止 → 禁用。
|
||||
expect(disabledFrom(new Date(maxY, maxM - 1, maxD))).toBe(false);
|
||||
expect(disabledFrom(new Date(y, m - 1, d))).toBe(true);
|
||||
expect(disabledFrom(new Date(y, m - 1, d + 1))).toBe(true);
|
||||
// i18n 键更名后标签正常解析(深层嵌套纯文本键,不依赖命名插值)。
|
||||
expect(wrapper.find('[data-testid="transfer-source-params"]').text()).toContain('异动日期');
|
||||
});
|
||||
|
||||
it('起始晚于截止时行内提示并禁用确认(不等提交报错)', async () => {
|
||||
// [断言意图] 日期维护期即时卡控:非法区间直接禁用确认并显示行内红字。
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-date-from"]').setValue('2026-09-20');
|
||||
await wrapper.find('[data-testid="transfer-source-date-to"]').setValue('2026-09-10');
|
||||
await datePicker(wrapper, 'transfer-source-date-from').setValue('2026-09-20');
|
||||
await datePicker(wrapper, 'transfer-source-date-to').setValue('2026-09-10');
|
||||
expect(wrapper.find('[data-testid="transfer-source-date-invalid"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-source-confirm"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
await wrapper.find('[data-testid="transfer-source-date-to"]').setValue('2026-09-22');
|
||||
await datePicker(wrapper, 'transfer-source-date-to').setValue('2026-09-22');
|
||||
expect(wrapper.find('[data-testid="transfer-source-date-invalid"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
@@ -208,21 +307,28 @@ describe('TransferSourceSelectCard', () => {
|
||||
expect((wrapper.find('[data-testid="transfer-source-retry-DBS-AWSBI"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-source-retry-DBS-AWSBI"]').trigger('click');
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSBI']);
|
||||
expect(wrapper.emitted('retry')?.[0][1]).toMatchObject({ recordKind: 'inbound' });
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-DBS-AWSBI"]').text()).toBe('入站 √就绪 ▾');
|
||||
expect(wrapper.find('[data-testid="transfer-source-retry-DBS-AWSBI"]').text()).toBe('↻');
|
||||
});
|
||||
|
||||
it('抓取中来源重试图标保持禁用(在途去重防并发双跑)', async () => {
|
||||
it('抓取中来源不渲染重试按钮(在途去重,状态字只表示抓取中)', async () => {
|
||||
// [断言意图] fetching 无独立重试钮;芯片只显示 ⟳抓取中 + ▾。
|
||||
const wrapper = mountCard({}, [
|
||||
{ source_code: 'DSV-FETCH', display_name: 'fetching', platform: 'dbs', enabled: true, has_ready_file: false, file_status: 'fetching' },
|
||||
]);
|
||||
expect((wrapper.find('[data-testid="transfer-source-retry-DSV-FETCH"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-source-retry-DSV-FETCH"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-DSV-FETCH"]').text()).toBe('入站 ⟳抓取中 ▾');
|
||||
});
|
||||
|
||||
it('“只选可重试”包含 ready 来源(ready 亦可强制重抓)', async () => {
|
||||
// [断言意图] 2026-09-29 去管控:可重试=除 fetching 外全部状态;全选可重试后
|
||||
// 因含 ready 文件来源,确认按钮不再被「至少一 ready」门禁禁用。
|
||||
it('“只选可重试”不把仅就绪来源算进批量', async () => {
|
||||
// [断言意图] 批量只收非 ready、非 fetching、非 unconfigured 的流。
|
||||
// ready 来源不勾上;无文件来源勾上后批量按钮可用。
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-select-retryable"]').trigger('click');
|
||||
expect((wrapper.find('[data-testid="transfer-source-confirm"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
expect((wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').element as HTMLInputElement).checked).toBe(false);
|
||||
expect((wrapper.find('[data-testid="transfer-source-option-DBS-AWSSG"] input').element as HTMLInputElement).checked).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-source-batch-retry"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('点击行尾重试图标 emit retry([sourceCode])', async () => {
|
||||
@@ -231,49 +337,174 @@ describe('TransferSourceSelectCard', () => {
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSSG']);
|
||||
});
|
||||
|
||||
it('批量重试传所选全部可重试来源(含 ready)', async () => {
|
||||
it('单个非就绪来源点批量重试不带 recordKind,只带 transferType', async () => {
|
||||
// [断言意图] 批量按钮即使只选一个来源,emit 也不带 recordKind,避免被当成入站单源重试。
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-source-select-retryable"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSSG"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-batch-retry"]').trigger('click');
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSBI', 'DBS-AWSSG', 'CRANE-SZ']);
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['DBS-AWSSG']);
|
||||
expect(wrapper.emitted('retry')?.[0][1]).toEqual({ transferType: 'in_transit_to_hub' });
|
||||
});
|
||||
|
||||
it('空数据来源显示「无收料数据」徽标而非抓取失败', async () => {
|
||||
// [断言意图] 抓取成功但当日无收料记录(file_status=no_data)属业务结果,
|
||||
// 必须如实展示"无收料数据",不得与"抓取失败"混淆(2026-10-08 PRD01 误标事故)。
|
||||
it('空数据来源显示「无入站数据」徽标而非抓取失败', async () => {
|
||||
// [断言意图] 抓取成功但当日无入站记录(file_status=no_data)属业务结果,
|
||||
// 必须如实展示"无入站数据",不得与"抓取失败"混淆(2026-10-08 PRD01 误标事故)。
|
||||
const wrapper = mountCard({}, [
|
||||
{ source_code: 'CRANE-NODATA', display_name: '空数据在途仓', platform: 'crane', enabled: true, has_ready_file: false, file_status: 'no_data' },
|
||||
]);
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-NODATA"]').text()).toBe('无收料数据');
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-NODATA"]').text()).toBe('入站 —无数据 ▾');
|
||||
expect(wrapper.find('[data-testid="transfer-source-retry-CRANE-NODATA"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-source-retry-CRANE-NODATA"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('已过期来源显示「文件已过期」徽标且可重试', async () => {
|
||||
// [断言意图] 保留期已到的来源不得误报就绪(has_ready_file=false);
|
||||
// expired 状态与 none/failed 一样允许重新触发收料 RPA。
|
||||
// expired 状态与 none/failed 一样允许重新触发入站 RPA。
|
||||
const wrapper = mountCard({}, [
|
||||
{ source_code: 'CRANE-EXP', display_name: '过期在途仓', platform: 'crane', enabled: true, has_ready_file: false, file_status: 'expired' },
|
||||
]);
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-EXP"]').text()).toBe('文件已过期');
|
||||
expect(wrapper.find('[data-testid="transfer-source-status-CRANE-EXP"]').text()).toBe('入站 !已过期 ▾');
|
||||
expect(wrapper.find('[data-testid="transfer-source-retry-CRANE-EXP"]').exists()).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-source-retry-CRANE-EXP"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-source-option-CRANE-EXP"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-batch-retry"]').trigger('click');
|
||||
expect(wrapper.emitted('retry')?.[0][0]).toEqual(['CRANE-EXP']);
|
||||
});
|
||||
|
||||
it('确认默认携带调拨类型 in_transit_to_hub', async () => {
|
||||
// [断言意图] 类型 1 为缺省选中值,确认事件第三参回传类型。
|
||||
it('确认默认携带首个接口选项的调拨类型 code(缺省选中第一项)', async () => {
|
||||
// [断言意图] 类型选项接口化(Task 7)后缺省选中不再是写死字面量,
|
||||
// 而是接口下发列表的首项(现行配置首项= in_transit_to_hub),确认事件第三参回传。
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').classes()).toContain('is-active');
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
expect(wrapper.emitted('confirm')?.[0][2]).toBe('in_transit_to_hub');
|
||||
});
|
||||
|
||||
it('调拨类型 2/3 占位禁用且不可选中', async () => {
|
||||
// [断言意图] 一期仅开放类型 1;占位类型按钮 disabled,防止发起未支持链路。
|
||||
it('调拨类型选项=接口下发数据逐项渲染,名称按 names 多语言显示,「即将上线」占位不再出现', () => {
|
||||
// [断言意图] 选项即接口真相:props 给几个渲染几个(enabled 过滤与排序在后端契约内),
|
||||
// 名称取 names[locale];写死三选项数组与「即将上线」徽标必须彻底消失。
|
||||
const wrapper = mountCard();
|
||||
expect((wrapper.find('[data-testid="transfer-type-option-hub_repair_out"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
expect((wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
const options = wrapper.findAll('[data-testid^="transfer-type-option-"]');
|
||||
expect(options).toHaveLength(2);
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-in_transit_to_hub"]').text()).toContain('在途仓至HUB仓');
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').text()).toContain('HUB仓间调拨');
|
||||
expect(wrapper.text()).not.toContain('即将上线');
|
||||
});
|
||||
|
||||
it('类型名称回退:names 缺当前 locale 时依次回退 zh-CN → en → code', () => {
|
||||
// [断言意图] 规格 §12.2 名称回退链:locale → zh-CN → en → code(code 是终极兜底,
|
||||
// 未配置任何名称也不出现空白按钮)。
|
||||
const types: TransferTypeOption[] = [
|
||||
{ code: 'only_en', names: { en: 'Only EN' }, sort_order: 1, transform_rules: [], record_kinds: ['inbound'] },
|
||||
{ code: 'no_names', names: {}, sort_order: 2, transform_rules: [], record_kinds: ['inbound'] },
|
||||
];
|
||||
const wrapper = mountCard({}, readySources, types);
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-only_en"]').text()).toContain('Only EN');
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-no_names"]').text()).toContain('no_names');
|
||||
});
|
||||
|
||||
it('点击类型按钮切换选中(选中态高亮),确认携带所选 code', async () => {
|
||||
// [断言意图] 选中类型 code 随 confirm 事件上抛(现有签名不变):
|
||||
// 点击第二项后确认,第三参必须是其 code 而非缺省首项。
|
||||
const wrapper = mountCard();
|
||||
await selectTransferType(wrapper, 'hub_to_hub');
|
||||
expect(wrapper.find('[data-testid="transfer-type-option-hub_to_hub"]').classes()).toContain('is-active');
|
||||
await wrapper.find('[data-testid="transfer-source-option-DBS-AWSBI"] input').setValue(true);
|
||||
await wrapper.find('[data-testid="transfer-source-confirm"]').trigger('click');
|
||||
expect(wrapper.emitted('confirm')?.[0][2]).toBe('hub_to_hub');
|
||||
});
|
||||
|
||||
it('类型配置为空:渲染空态文案,确认按钮禁用且 title 说明原因', () => {
|
||||
// [断言意图] 空配置空态(规格 §12.2):空态文案 chat.transfer.transferTypeEmpty +
|
||||
// 确认禁用(disabled + tooltip 说明原因),防止用户在无类型可配时发起匹配。
|
||||
const wrapper = mountCard({}, readySources, []);
|
||||
const empty = wrapper.find('[data-testid="transfer-type-empty"]');
|
||||
expect(empty.exists()).toBe(true);
|
||||
expect(empty.text()).toContain('暂无可用调拨类型');
|
||||
const confirm = wrapper.find('[data-testid="transfer-source-confirm"]');
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(true);
|
||||
expect(confirm.attributes('title') ?? '').toContain('暂无可用调拨类型');
|
||||
// 空态下不再渲染任何类型选项,也不出现「即将上线」历史占位。
|
||||
expect(wrapper.find('[data-testid^="transfer-type-option-"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('即将上线');
|
||||
});
|
||||
|
||||
it('只在清单第一行显示重新解析,点击不发出 retry', async () => {
|
||||
transferApiMocks.listEvidenceFiles.mockResolvedValue([
|
||||
{ file_id: 25, original_filename: 'outbound_TRIG-BATCH-A629464D_DBS-AWSBI_NA_20261021101739.xlsx', created_at: '2026-10-21T10:00:00', sha256: 'abc', file_size: 10, presigned_url: 'https://files.example/current', download_url: 'https://files.example/current?filename=DBS-AWSBI_20261021_1800.xlsx' },
|
||||
{ file_id: 9, original_filename: 'older.xlsx', created_at: '2026-10-20T10:00:00', sha256: 'def', file_size: 10, presigned_url: 'https://files.example/older', download_url: 'https://files.example/older?filename=DBS-AWSBI_20261020_1800.xlsx' },
|
||||
]);
|
||||
transferApiMocks.reparseCurrentFile.mockResolvedValue({
|
||||
source_code: 'DBS-AWSBI', record_kind: 'inbound', ok: true, file_status: 'ready',
|
||||
file_id: 25, inserted: 2, updated: 0, skipped: 0, sealed_skipped: 0,
|
||||
error_code: null, error_message: null,
|
||||
});
|
||||
const wrapper = mount(TransferSourceSelectCard, {
|
||||
props: { sources: readySources, transferTypes: defaultTransferTypes },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-source-status-DBS-AWSBI"]').trigger('click');
|
||||
await flushPromises();
|
||||
// [断言意图] 行内对齐排程包的来源名,不展示 Worker 落盘名;完整原名在 title。
|
||||
const list = wrapper.get('[data-testid="transfer-evidence-list-DBS-AWSBI-inbound"]');
|
||||
expect(list.text()).toContain('DBS-AWSBI.xlsx');
|
||||
expect(list.text()).toContain('10-21 18:00');
|
||||
expect(list.text()).not.toContain('10-21 10:00');
|
||||
expect(list.text()).not.toContain('TRIG-BATCH');
|
||||
expect(list.get('p').attributes('title')).toContain('outbound_TRIG-BATCH-A629464D_DBS-AWSBI_NA_20261021101739.xlsx');
|
||||
expect(list.get('p').attributes('title')).toContain('2026-10-21 18:00');
|
||||
expect(wrapper.get('[data-testid="transfer-evidence-download-25"]').attributes('href')).toBeUndefined();
|
||||
expect(wrapper.text()).not.toContain('older.xlsx');
|
||||
expect(wrapper.text()).not.toContain('abc');
|
||||
const buttons = wrapper.findAll('[data-testid="transfer-evidence-reparse-DBS-AWSBI-inbound"]');
|
||||
expect(buttons).toHaveLength(1);
|
||||
expect(list.findAll('p')).toHaveLength(1);
|
||||
await wrapper.find('[data-testid="transfer-evidence-earlier-DBS-AWSBI-inbound"]').trigger('click');
|
||||
expect(list.findAll('p')).toHaveLength(2);
|
||||
expect(list.text()).not.toContain('older.xlsx');
|
||||
expect(wrapper.findAll('[data-testid="transfer-evidence-reparse-DBS-AWSBI-inbound"]')).toHaveLength(1);
|
||||
await buttons[0].trigger('click');
|
||||
expect(transferApiMocks.reparseCurrentFile).toHaveBeenCalledWith('DBS-AWSBI', 'inbound');
|
||||
expect(wrapper.emitted('retry')).toBeUndefined();
|
||||
expect(wrapper.emitted('reparsed')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('点击下载走站点接口,不打开预签名地址', async () => {
|
||||
// [断言意图] 下载按钮不再带 MinIO href;点击后按来源、文件和记录类型请求当前站点。
|
||||
transferApiMocks.listEvidenceFiles.mockResolvedValue([
|
||||
{ file_id: 25, original_filename: 'CRANE.xlsx', created_at: '2026-10-26T07:00:00', sha256: 'abc', file_size: 10, presigned_url: 'http://192.168.100.192:9000/file', download_url: 'http://192.168.100.192:9000/file?filename=CRANE.xlsx' },
|
||||
]);
|
||||
transferApiMocks.downloadEvidenceFile.mockResolvedValue({ blob: new Blob(['xlsx']), filename: 'DBS-AWSBI_20261026_1500.xlsx' });
|
||||
const wrapper = mount(TransferSourceSelectCard, {
|
||||
props: { sources: readySources, transferTypes: defaultTransferTypes },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-source-status-DBS-AWSBI"]').trigger('click');
|
||||
await flushPromises();
|
||||
await wrapper.get('[data-testid="transfer-evidence-download-25"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(transferApiMocks.downloadEvidenceFile).toHaveBeenCalledWith('DBS-AWSBI', 25, 'inbound');
|
||||
});
|
||||
|
||||
it('按所选类型的 record_kinds 绘制证据流芯片,抓取中无重试,下载按钮为证据文件', async () => {
|
||||
// [断言意图] 方案 A:状态芯片与重试钮分离。hub_to_hub 两种流各一枚芯片;
|
||||
// 出站抓取中无 ↻;入站 ↻ 的 aria-label 为「重试入站」。切回只含 inbound 时不出现「出站」。
|
||||
const wrapper = mountCard({}, [hubSource]);
|
||||
const row = () => wrapper.find('[data-testid="transfer-source-option-DSV360_AWSBI_BYAWSCMH01"]');
|
||||
expect(row().text()).not.toContain('出站');
|
||||
await selectTransferType(wrapper, 'hub_to_hub');
|
||||
expect(row().find('[data-testid="transfer-source-status-DSV360_AWSBI_BYAWSCMH01"]').text()).toBe('入站 √就绪 ▾');
|
||||
expect(row().find('[data-testid="transfer-source-status-DSV360_AWSBI_BYAWSCMH01-outbound"]').text()).toBe('出站 ⟳抓取中 ▾');
|
||||
expect(row().find('[aria-label="重试出站"]').exists()).toBe(false);
|
||||
expect(row().find('[aria-label="重试入站"]').exists()).toBe(true);
|
||||
// [断言意图] 重试/状态芯片已迁 el-button(2026-10-20),不再断言手写 border 类。
|
||||
expect(row().find('[aria-label="重试入站"]').classes()).toContain('el-button');
|
||||
expect(row().find('[data-testid="transfer-source-status-DSV360_AWSBI_BYAWSCMH01"]').classes()).toContain('el-button');
|
||||
expect(wrapper.findAll('button').some((button) => button.text().trim() === '文件')).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-source-option-DSV360_AWSBI_BYAWSCMH01"] input').setValue(true);
|
||||
expect(wrapper.find('[data-testid="transfer-source-download"]').text()).toContain('下载证据文件');
|
||||
await selectTransferType(wrapper, 'in_transit_to_hub');
|
||||
expect(row().text()).not.toContain('出站');
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferBatch.spec.ts
|
||||
* 用途:覆盖批号转换规则。
|
||||
* 用途:覆盖批号转换规则(Task 7 接口化:deriveBatchNo 支持 TransformRule 形参)。
|
||||
* 依赖:transferBatch、vitest。
|
||||
* 逻辑:WTP 前缀替换为 HOW;其余原样;空值安全。
|
||||
* 逻辑:三态契约——未传 rules(旧调用点/过渡期)保持现行 WTP→HOW 兼容行为;
|
||||
* 显式传 rules=[] 恒等不转换(类型未配置=恒等);传规则按序链式前缀替换
|
||||
* (与后端 field_transforms 引擎同语义,仅 lot_no 字段命中)。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -25,3 +27,39 @@ describe('transferBatch', () => {
|
||||
expect(deriveBatchNo(undefined)).toBe('');
|
||||
});
|
||||
});
|
||||
|
||||
describe('transferBatch deriveBatchNo 规则三态(Task 7 接口化)', () => {
|
||||
const wtpToHow = [{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' }];
|
||||
|
||||
it('未传 rules(旧调用点兼容窗):保持现行 WTP→HOW 行为', () => {
|
||||
// [断言意图] 既有调用点(匹配卡/可执行卡/待处理池/已执行单)未传规则时
|
||||
// 行为必须与改造前逐字节一致——迁移期兼容窗的回归锁。
|
||||
expect(deriveBatchNo('WTP26082728')).toBe('HOW26082728');
|
||||
expect(deriveBatchNo('wtp26082728')).toBe('HOW26082728');
|
||||
expect(deriveBatchNo('HS000131')).toBe('HS000131');
|
||||
expect(deriveBatchNo('')).toBe('');
|
||||
expect(deriveBatchNo(null)).toBe('');
|
||||
});
|
||||
|
||||
it('显式传空数组 rules=[]:恒等不转换(类型未配置=恒等)', () => {
|
||||
// [断言意图] 空规则是显式「该类型不做字段转换」的契约(与后端 parse_transform_rules
|
||||
// 空=恒等同口径),不得回落 WTP→HOW 缺省。
|
||||
expect(deriveBatchNo('WTP26082728', [])).toBe('WTP26082728');
|
||||
expect(deriveBatchNo('HS000131', [])).toBe('HS000131');
|
||||
});
|
||||
|
||||
it('传规则:按序链式前缀替换(与后端 field_transforms 同语义),非 lot_no 字段规则不命中', () => {
|
||||
// [断言意图] 规则引擎展示侧镜像:仅 lot_no 规则生效;前缀匹配大小写不敏感
|
||||
// (result 大写判 startsWith,替换拼接按原值切片);多条规则按配置序链式派生。
|
||||
expect(deriveBatchNo('WTP1', wtpToHow)).toBe('HOW1');
|
||||
expect(deriveBatchNo('wtp1', wtpToHow)).toBe('HOW1');
|
||||
expect(deriveBatchNo('HS000131', wtpToHow)).toBe('HS000131');
|
||||
// 非 lot_no 字段的规则不得影响批号展示。
|
||||
expect(deriveBatchNo('WTP1', [{ field: 'material_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' }])).toBe('WTP1');
|
||||
// 链式:WTP→HOW 后继续 HOW→HOWX(WTP1 → HOW1 → HOWX1)。
|
||||
expect(deriveBatchNo('WTP1', [
|
||||
{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' },
|
||||
{ field: 'lot_no', op: 'prefix_replace', source: 'HOW', target: 'HOWX' },
|
||||
])).toBe('HOWX1');
|
||||
});
|
||||
});
|
||||
@@ -1,16 +1,56 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferBatch.ts
|
||||
* 用途:在途调拨批号转换规则(拨出/拨入批号展示)。
|
||||
* 依赖:无。
|
||||
* 逻辑:原批号以 WTP 开头时替换前缀为 HOW 获得真实批号;其余规则不变、原样展示。
|
||||
* 本函数是后端 movement_contract.external_lot_no(库存查询/建单下传侧唯一实现)
|
||||
* 的展示侧镜像,两侧行为须逐字节一致,改动必须双侧同步。
|
||||
* 用途:在途调拨批号转换规则(拨出/拨入批号展示)——Task 7 接口化后由所选调拨
|
||||
* 类型的 transform_rules 驱动;本函数是后端 field_transforms.apply_field_transforms
|
||||
* (库存查询/建单下传侧唯一实现)的展示侧镜像,两侧行为须逐字节一致,改动必须双侧同步。
|
||||
* 依赖:../types/transfer.types(TransferTransformRule)。
|
||||
* 逻辑:三态契约——未传 rules(旧调用点/过渡期兼容窗)保持现行 WTP→HOW 缺省行为;
|
||||
* 显式传 rules=[] 恒等不转换(类型未配置=恒等,与后端 parse_transform_rules 空规则同口径);
|
||||
* 传规则按序链式前缀替换(仅 lot_no 字段命中,前缀大小写不敏感)。
|
||||
*/
|
||||
import type { TransferTransformRule } from '../../types/transfer.types';
|
||||
|
||||
/** 原批号(如 WMS 的 WTP26082728)→ 真实批号(HOW26082728);空值/非 WTP 原样返回。 */
|
||||
export function deriveBatchNo(lotNo: string | null | undefined): string {
|
||||
/**
|
||||
* 旧调用点兼容缺省规则(未传 rules 时生效):现行 WTP→HOW 前缀替换。
|
||||
* 过渡期兼容窗(Task 7 裁定):待调用方全部改为按所选类型显式传规则后可移除。
|
||||
*/
|
||||
const LEGACY_LOT_NO_RULES: TransferTransformRule[] = [
|
||||
{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' },
|
||||
];
|
||||
|
||||
/**
|
||||
* 原批号 → 派生批号(展示侧)。
|
||||
*
|
||||
* 【AI 触发时机】:卡片渲染批号列(匹配卡/可执行卡/待处理池/已执行单)时调用,
|
||||
* 把 WMS 原批号(如 WTP26082728)按所选调拨类型的转换规则派生为真实批号(HOW26082728)。
|
||||
*
|
||||
* 核心逻辑:[STEP 1] 空值清洗(null/空串/纯空白 → 空串原样返回);
|
||||
* [STEP 2] rules 缺省回落 LEGACY_LOT_NO_RULES(兼容窗),显式 [] 为恒等(无转换);
|
||||
* [STEP 3] 按规则序链式求值(applyLotNoTransforms,与后端引擎同语义)。
|
||||
*
|
||||
* @param lotNo - 原批号(行上 lot_no 原值,永不被改写,只返回派生新值)
|
||||
* @param rules - 所选调拨类型的 transform_rules(GET /transfer-types 下发);
|
||||
* 业务约束:调用方未升级传参时保持缺省(兼容窗),显式传 [] 表示该类型不做转换
|
||||
* @returns 派生后的批号;空输入返回空串
|
||||
*/
|
||||
export function deriveBatchNo(lotNo: string | null | undefined, rules?: TransferTransformRule[]): string {
|
||||
const value = String(lotNo ?? '').trim();
|
||||
if (!value) return '';
|
||||
if (value.toUpperCase().startsWith('WTP')) return `HOW${value.slice(3)}`;
|
||||
return value;
|
||||
return applyLotNoTransforms(value, rules ?? LEGACY_LOT_NO_RULES);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按规则序链式派生 lot_no 展示值(后端 apply_field_transforms('lot_no', …) 的镜像)。
|
||||
* 核心逻辑:仅 field=lot_no 的规则命中;op=prefix_replace 且当前值前缀匹配(大小写
|
||||
* 不敏感)时替换前缀,未命中规则恒等;空值短路透传。
|
||||
*/
|
||||
function applyLotNoTransforms(value: string, rules: TransferTransformRule[]): string {
|
||||
let result = value;
|
||||
for (const rule of rules) {
|
||||
if (rule.field !== 'lot_no' || !result) continue;
|
||||
if (rule.op === 'prefix_replace' && result.toUpperCase().startsWith(rule.source.toUpperCase())) {
|
||||
result = rule.target + result.slice(rule.source.length);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -1,29 +1,42 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferCards.spec.ts
|
||||
* 用途:验证在途调拨核心卡片(文件进度/匹配/融合结果卡)+ 关闭弹窗的交互与禁用语义。
|
||||
* 依赖:@vue/test-utils、i18n、transfer.types。
|
||||
* 依赖:@vue/test-utils、i18n、transfer.types、Element Plus(匹配卡 EP 壳)。
|
||||
* 逻辑:断言按钮禁用、勾选禁用、融合卡单行常驻展开(历史回放旧 result 投影兼容)、
|
||||
* 异常展示、下载按钮与结果页不出现“查看执行审计”入口(决策 19);
|
||||
* 计数卡新字段(待查库存/已失效,历史缺省按 0)与 pending 徽标
|
||||
* (evidence-sync,2026-09-25)。
|
||||
* (evidence-sync,2026-09-25;EP 化后 el-tag warning);匹配卡批号列
|
||||
* deriveBatchNo 旧路径兼容(Task 7 规则化后未传规则仍 WTP→HOW);
|
||||
* 匹配卡行定位经 el-table row-class-name(transfer-item-<invoice>)。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import TransferFileProgressCard from './TransferFileProgressCard.vue';
|
||||
import TransferMatchCard from './TransferMatchCard.vue';
|
||||
import TransferResultCard from './TransferResultCard.vue';
|
||||
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
|
||||
|
||||
// EP el-table 在 jsdom 挂载较重(与 TransferMessageView.spec 同口径),本文件放宽到 30s。
|
||||
vi.setConfig({ testTimeout: 30000 });
|
||||
|
||||
const mountOptions = { global: { plugins: [i18n] } };
|
||||
|
||||
/**
|
||||
* 挂载匹配卡并 flush:el-table 行槽位在 jsdom 下需等下一拍才渲染出 checkbox/行类。
|
||||
*/
|
||||
async function mountMatchCard(props: Record<string, unknown>) {
|
||||
const wrapper = mount(TransferMatchCard, { props, ...mountOptions });
|
||||
await flushPromises();
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
const summary = {
|
||||
matching_id: 'MTG-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, matched_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
counts: { file_invoice_count: 3, matched_count: 3, executable_count: 2, blocked_count: 1 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_external_write_count: 2,
|
||||
matching_hash: 'sha256:x',
|
||||
@@ -31,7 +44,7 @@ const summary = {
|
||||
|
||||
const items = [
|
||||
{ item_id: 101, 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', checked_at: '2026-09-23T09:05:00+08:00' },
|
||||
{ item_id: 102, 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' },
|
||||
{ item_id: 102, 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: 'result_unknown' },
|
||||
];
|
||||
|
||||
describe('TransferFileProgressCard', () => {
|
||||
@@ -49,81 +62,79 @@ describe('TransferFileProgressCard', () => {
|
||||
});
|
||||
|
||||
describe('TransferMatchCard', () => {
|
||||
it('勾选键为明细行 item_id:阻断/未成熟项 checkbox 禁用,可执行项可选', () => {
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items, selected: new Set<number>([101]) },
|
||||
...mountOptions,
|
||||
});
|
||||
const executableCheck = wrapper.find('[data-testid="transfer-check-INV-001"]');
|
||||
const maturedCheck = wrapper.find('[data-testid="transfer-check-INV-041"]');
|
||||
it('勾选键为明细行 item_id:可执行项可选,终态行(result_unknown)checkbox 禁用', async () => {
|
||||
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>([101]) });
|
||||
// [断言意图] EP el-checkbox:testid 挂根,读写走内层 input。
|
||||
const executableCheck = wrapper.find('[data-testid="transfer-check-INV-001"] input');
|
||||
const terminalCheck = wrapper.find('[data-testid="transfer-check-INV-041"] input');
|
||||
expect((executableCheck.element as HTMLInputElement).disabled).toBe(false);
|
||||
expect((executableCheck.element as HTMLInputElement).checked).toBe(true);
|
||||
expect((maturedCheck.element as HTMLInputElement).disabled).toBe(true);
|
||||
// [断言意图] blocked 行可勾(供重查),终态行(result_unknown,不可执行不可重查)禁用。
|
||||
expect((terminalCheck.element as HTMLInputElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('历史回放行(无 item_id)checkbox 禁用,防误选', () => {
|
||||
it('历史回放行(无 item_id)checkbox 禁用,防误选', async () => {
|
||||
// [断言意图] 行式执行重构(2026-09-23):chat 消息流回放的旧 payload 行没有
|
||||
// item_id,不能作为执行勾选键;这类行必须禁选(防误选后 400)。
|
||||
const legacyItems = [{ ...items[0], item_id: undefined }];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: legacyItems, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect((wrapper.find('[data-testid="transfer-check-INV-001"]').element as HTMLInputElement).disabled).toBe(true);
|
||||
const wrapper = await mountMatchCard({ summary, items: legacyItems, selected: new Set<number>() });
|
||||
expect((wrapper.find('[data-testid="transfer-check-INV-001"] input').element as HTMLInputElement).disabled).toBe(true);
|
||||
// [断言意图] EP el-button 禁用态挂在 button 元素上,testid 仍可定位。
|
||||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('未选择任何项时生成按钮禁用', () => {
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
it('未选择任何项时生成按钮禁用', async () => {
|
||||
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>() });
|
||||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('busy 时生成按钮禁用', () => {
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items, selected: new Set<number>([101]), busy: true },
|
||||
...mountOptions,
|
||||
});
|
||||
it('busy 时生成按钮禁用', async () => {
|
||||
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>([101]), busy: true });
|
||||
expect((wrapper.find('[data-testid="transfer-generate-button"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
});
|
||||
|
||||
it('点击生成按钮提交可执行勾选行的 item_id 数组', async () => {
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items, selected: new Set<number>([101]) },
|
||||
...mountOptions,
|
||||
});
|
||||
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>([101]) });
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
expect(wrapper.emitted('execute')?.[0][0]).toEqual([101]);
|
||||
});
|
||||
|
||||
it('库存数量下方小字展示查询时刻(HH:mm)', () => {
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const cell = wrapper.find('[data-testid="transfer-checked-at-INV-001"]');
|
||||
expect(cell.exists()).toBe(true);
|
||||
expect(cell.text()).toMatch(/^\d{2}:\d{2}$/);
|
||||
expect(wrapper.find('[data-testid="transfer-checked-at-INV-041"]').exists()).toBe(false);
|
||||
it('批号列展示派生批号:未传规则走 transferBatch 旧路径(WTP→HOW 兼容行为)', async () => {
|
||||
// [断言意图] Task 7 deriveBatchNo 规则化后的调用方回归锁:匹配卡批号列
|
||||
// 不传规则(过渡期兼容窗),WTP 批号必须仍派生为 HOW 真实批号。
|
||||
// 行定位:el-table 经 row-class-name 注入 transfer-item-<invoice_no>。
|
||||
const itemsWithLot = [{ ...items[0], lot_no: 'WTP26082728' }];
|
||||
const wrapper = await mountMatchCard({ summary, items: itemsWithLot, selected: new Set<number>() });
|
||||
expect(wrapper.find('.transfer-item-INV-001').text()).toContain('HOW26082728');
|
||||
});
|
||||
|
||||
it('stale 行置灰 + 重查小标;file_current=false 行展示文件更新小标', () => {
|
||||
it('库存数量与完整查询时刻同一行(数量 · YYYY-MM-DD HH:mm)', async () => {
|
||||
// [断言意图] 数量与时刻同行,避免第二行撑高整表;完整日期才能判断新旧。
|
||||
const wrapper = await mountMatchCard({ summary, items, selected: new Set<number>() });
|
||||
const cell = wrapper.find('[data-testid="transfer-checked-at-INV-001"]');
|
||||
expect(cell.exists()).toBe(true);
|
||||
expect(cell.text()).toBe('1200 · 2026-09-23 09:05');
|
||||
// [断言意图] 无查询时刻时仍单行只显示数量,不拆第二行。
|
||||
expect(wrapper.find('[data-testid="transfer-checked-at-INV-041"]').text()).not.toContain('·');
|
||||
});
|
||||
|
||||
it('stale 行置灰 + 短徽标;file_current=false 行展示文件更新短徽标;顶栏汇总过期', async () => {
|
||||
const flaggedItems = [
|
||||
{ ...items[0], stale: true, file_current: false },
|
||||
];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: flaggedItems, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const row = wrapper.find('[data-testid="transfer-item-INV-001"]');
|
||||
const wrapper = await mountMatchCard({ summary, items: flaggedItems, selected: new Set<number>() });
|
||||
// [断言意图] el-table 行类经 row-class-name 注入 opacity-60。
|
||||
const row = wrapper.find('.transfer-item-INV-001');
|
||||
expect(row.classes()).toContain('opacity-60');
|
||||
expect(wrapper.find('[data-testid="transfer-item-stale"]').text()).toContain('重查');
|
||||
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('自动对齐');
|
||||
// [断言意图] 长句只放悬停;行内只留短徽标;顶栏 el-alert 汇总可批量重查。
|
||||
expect(wrapper.find('[data-testid="transfer-item-stale"]').text()).toContain('已过期');
|
||||
expect(wrapper.find('[data-testid="transfer-item-stale"]').attributes('title')).toContain('重查');
|
||||
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('文件更新');
|
||||
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').attributes('title')).toContain('自动对齐');
|
||||
expect(wrapper.find('[data-testid="transfer-match-stale-banner"]').text()).toContain('1');
|
||||
});
|
||||
|
||||
it('计数卡透出待查库存/已失效计数;历史 payload 缺省按 0 展示', () => {
|
||||
it('计数卡透出待查库存/已失效计数;历史 payload 缺省按 0 展示', async () => {
|
||||
// [断言意图] evidence-sync(2026-09-25):后端 counts 新增 pending_stock_check_count /
|
||||
// invalid_count(历史数据可缺省);卡片须原样透出数值,缺省回退 0,
|
||||
// 已失效标签经 {count} 插值渲染(「已失效 N 行」)。
|
||||
@@ -131,34 +142,29 @@ describe('TransferMatchCard', () => {
|
||||
...summary,
|
||||
counts: { ...summary.counts, pending_stock_check_count: 5, invalid_count: 2 },
|
||||
};
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary: summaryWithNewCounts, items, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const wrapper = await mountMatchCard({ summary: summaryWithNewCounts, items, selected: new Set<number>() });
|
||||
const counts = wrapper.find('[data-testid="transfer-match-counts"]');
|
||||
expect(counts.text()).toContain('待查库存');
|
||||
expect(counts.text()).toContain('已失效 2 行');
|
||||
const legacyWrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const legacyWrapper = await mountMatchCard({ summary, items, selected: new Set<number>() });
|
||||
expect(legacyWrapper.find('[data-testid="transfer-match-counts"]').text()).toContain('已失效 0 行');
|
||||
});
|
||||
|
||||
it('pending_stock_check 行徽标展示「待查库存」(amber 同未成熟色系)', () => {
|
||||
it('pending_stock_check 行徽标展示「待查库存」(warning 提示色)', async () => {
|
||||
// [断言意图] evidence-sync(2026-09-25):文件已落地未查 ERP 的行为
|
||||
// pending_stock_check,徽标须用独立文案且为 amber 族(非阻断红)。
|
||||
// pending_stock_check,徽标须用独立文案且为 warning 族(非阻断 danger)。
|
||||
// EP 化后走 el-tag type=warning(替代旧 bg-amber-50 手写类)。
|
||||
const pendingItems = [{ ...items[0], result: 'pending_stock_check' }];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: pendingItems, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const wrapper = await mountMatchCard({ summary, items: pendingItems, selected: new Set<number>() });
|
||||
// [断言意图] EP el-tag type=warning;testid 可能落在组件包装层,type 经 props 断言。
|
||||
const badge = wrapper.find('[data-testid="transfer-item-result"]');
|
||||
expect(badge.text()).toContain('待查库存');
|
||||
expect(badge.classes()).toContain('bg-amber-50');
|
||||
const tag = wrapper.findComponent({ name: 'ElTag' });
|
||||
expect(tag.exists()).toBe(true);
|
||||
expect(tag.props('type')).toBe('warning');
|
||||
});
|
||||
|
||||
it('blocked_file_removed 行退出主视图:表格不渲染,仅折叠提示计数并引导去待处理池', () => {
|
||||
it('blocked_file_removed 行退出主视图:表格不渲染,仅折叠提示计数并引导去待处理池', async () => {
|
||||
// [断言意图] 回归防线(2026-09-24):文件移除的行证据已失效,重查/重新匹配
|
||||
// 都救不了——留驻主清单只会提示做不到的动作(死锁观感)。主视图只渲染
|
||||
// 可行动行;失效行以折叠提示计数承载,处理入口在待处理异常池。
|
||||
@@ -166,14 +172,11 @@ describe('TransferMatchCard', () => {
|
||||
{ ...items[0] },
|
||||
{ item_id: 103, source_code: 'DBS-AWSBI', material_no: 'MAT-3', material_name: '线缆', specification: 'C', invoice_no: 'INV-077', from_warehouse: 'DBS-TRANSIT', from_quantity: '50', to_warehouse: 'HUB-CN01', to_quantity: '50', result: 'blocked_file_removed' },
|
||||
];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: mixedItems, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const wrapper = await mountMatchCard({ summary, items: mixedItems, selected: new Set<number>() });
|
||||
// 失效行不出现在表格(含其重查按钮/勾选框),可行动行照常渲染。
|
||||
expect(wrapper.find('[data-testid="transfer-item-INV-077"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-executable-check-INV-077"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-item-INV-001"]').exists()).toBe(true);
|
||||
expect(wrapper.find('.transfer-item-INV-077').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-check-INV-077"]').exists()).toBe(false);
|
||||
expect(wrapper.find('.transfer-item-INV-001').exists()).toBe(true);
|
||||
// 折叠提示透出失效行数与去处理池的引导。
|
||||
const hint = wrapper.find('[data-testid="transfer-file-removed-hint"]');
|
||||
expect(hint.exists()).toBe(true);
|
||||
@@ -181,38 +184,75 @@ describe('TransferMatchCard', () => {
|
||||
expect(hint.text()).toContain('待处理异常');
|
||||
});
|
||||
|
||||
it('全部行均文件移除时表格为空,仅剩折叠提示', () => {
|
||||
it('全部行均文件移除时表格为空,仅剩折叠提示', async () => {
|
||||
const removedOnly = [
|
||||
{ item_id: 103, source_code: 'DBS-AWSBI', material_no: 'MAT-3', material_name: '线缆', specification: 'C', invoice_no: 'INV-077', from_warehouse: 'DBS-TRANSIT', from_quantity: '50', to_warehouse: 'HUB-CN01', to_quantity: '50', result: 'blocked_file_removed' },
|
||||
];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: removedOnly, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect(wrapper.find('tbody tr').exists()).toBe(false);
|
||||
const wrapper = await mountMatchCard({ summary, items: removedOnly, selected: new Set<number>() });
|
||||
// [断言意图] 无行动行时不挂 el-table,避免空壳表;仅折叠提示。
|
||||
expect(wrapper.find('[data-testid="transfer-match-table"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-file-removed-hint"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('同 Invoice 跨收料日期拆单(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||||
it('同 Invoice 跨异动日期拆单(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||||
// [断言意图] 回归防线(2026-09-21):拆单设计下 invoice_no 不再唯一,
|
||||
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
|
||||
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
|
||||
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
|
||||
// 行身份 = (来源, Invoice, 料号, 异动日期),key 必须用同一粒度。
|
||||
const dupItems = [
|
||||
{ item_id: 201, source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', receipt_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ item_id: 202, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ item_id: 203, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', receipt_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ item_id: 201, source_code: 'CRANE', material_no: 'M-1', material_name: '机框', specification: '', invoice_no: 'HOX-1', movement_date: '2026-09-11', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ item_id: 202, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', movement_date: '2026-09-03', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
{ item_id: 203, source_code: 'CRANE', material_no: 'M-2', material_name: '护罩', specification: '', invoice_no: 'DUP-1', movement_date: '2026-09-04', from_warehouse: 'HTP-D43', from_quantity: null, to_warehouse: 'HTP-D49', to_quantity: '36', result: 'blocked_quantity_mismatch' },
|
||||
];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: dupItems, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect(wrapper.findAll('tbody tr').length).toBe(3);
|
||||
await wrapper.find('[data-testid="transfer-match-filter"]').setValue('HOX');
|
||||
const rows = wrapper.findAll('tbody tr');
|
||||
const wrapper = await mountMatchCard({ summary, items: dupItems, selected: new Set<number>() });
|
||||
expect(wrapper.findAll('.el-table__body tbody tr').length).toBe(3);
|
||||
// el-input:testid 落在 .el-input 根上;经组件 setValue 触发 v-model(勿直接找嵌套 input,
|
||||
// VTU 对 EP 内部 input 偶发空包装)。
|
||||
const filter = wrapper.findComponent({ name: 'ElInput' });
|
||||
expect(filter.exists()).toBe(true);
|
||||
await filter.setValue('HOX');
|
||||
await flushPromises();
|
||||
const rows = wrapper.findAll('.el-table__body tbody tr');
|
||||
expect(rows.length).toBe(1);
|
||||
expect(rows[0].text()).toContain('HOX-1');
|
||||
});
|
||||
|
||||
it('可调拨清单客户端分页 50/页:>50 行只渲染当前页切片,筛选变更回第 1 页', async () => {
|
||||
// [断言意图] 积压日 items 可达数百行(557 行实测全量直染卡顿):表体只挂
|
||||
// 50 行切片 + 分页器出现;翻页渲染下一批;关键字筛选变更回第 1 页;
|
||||
// 全选/计数语义仍按 filtered 全量(不在本用例展开,由交互用例覆盖小数据量)。
|
||||
const bulk = Array.from({ length: 120 }, (_, index) => ({
|
||||
item_id: 1000 + index,
|
||||
source_code: 'DBS-AWSBI',
|
||||
material_no: `MAT-${index}`,
|
||||
material_name: '物料',
|
||||
specification: '',
|
||||
invoice_no: `INV-${String(index).padStart(4, '0')}`,
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
from_quantity: '1',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
to_quantity: '1',
|
||||
result: 'blocked_quantity_mismatch',
|
||||
}));
|
||||
const wrapper = await mountMatchCard({ summary, items: bulk, selected: new Set<number>() });
|
||||
const bodyRows = () => wrapper.findAll('.el-table__body tbody tr');
|
||||
expect(bodyRows().length).toBe(50); // [断言意图] 第 1 页只渲染切片
|
||||
const pagination = wrapper.find('[data-testid="transfer-match-pagination"]');
|
||||
expect(pagination.exists()).toBe(true); // [断言意图] 分页器出现
|
||||
// 翻到第 2 页:渲染第 51-100 行(首行 INV-0050)。
|
||||
const pager = wrapper.findComponent({ name: 'ElPagination' });
|
||||
expect(pager.exists()).toBe(true);
|
||||
await pager.vm.$emit('update:current-page', 2);
|
||||
await flushPromises();
|
||||
expect(bodyRows().length).toBe(50);
|
||||
expect(bodyRows()[0].text()).toContain('INV-0050');
|
||||
// 关键字筛选变更回第 1 页:只剩命中的 1 行。
|
||||
const filter = wrapper.findComponent({ name: 'ElInput' });
|
||||
await filter.setValue('INV-0119');
|
||||
await flushPromises();
|
||||
expect(wrapper.findAll('.el-table__body tbody tr').length).toBe(1);
|
||||
expect(wrapper.text()).toContain('INV-0119');
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferResultCard(Task 13 融合卡)', () => {
|
||||
@@ -230,13 +270,15 @@ describe('TransferResultCard(Task 13 融合卡)', () => {
|
||||
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' }],
|
||||
exceptions: [{ source_code: 'DBS-AWSBI', invoice_no: 'INV-999', material_no: 'MAT-9', reason: 'business_failed', facts: '异动 300 / ERP 280' }],
|
||||
},
|
||||
};
|
||||
const mountCard = () => mount(TransferResultCard, { props: { runNo: 'RUN-1', initialRun: run }, ...mountOptions });
|
||||
|
||||
it('历史回放(旧 result 投影):按单号展示单行,行明细常驻展开无需点击', async () => {
|
||||
const wrapper = mountCard();
|
||||
// [断言意图] 行明细已迁 el-table,jsdom 下需 flush 后槽位才渲染物料文本。
|
||||
await flushPromises();
|
||||
const order = wrapper.find('[data-testid="transfer-order-TRF-10001"]');
|
||||
expect(order.exists()).toBe(true);
|
||||
expect(order.text()).toContain('TRF-10001');
|
||||
@@ -252,12 +294,12 @@ describe('TransferResultCard(Task 13 融合卡)', () => {
|
||||
expect(wrapper.find('[data-testid="transfer-exceptions-area"]').text()).toContain('INV-999');
|
||||
});
|
||||
|
||||
it('提供下载按钮(收料来源文件 + ERP 库存表 + 异常清单)', async () => {
|
||||
it('提供下载按钮(出入站来源文件 + ERP 库存表 + 异常清单)', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-download-receipt"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-download-inbound"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-download-erp"]').trigger('click');
|
||||
await wrapper.find('[data-testid="transfer-download-exceptions"]').trigger('click');
|
||||
expect(wrapper.emitted('downloadReceipt')).toBeTruthy();
|
||||
expect(wrapper.emitted('downloadInbound')).toBeTruthy();
|
||||
expect(wrapper.emitted('downloadErp')).toBeTruthy();
|
||||
expect(wrapper.emitted('downloadExceptions')).toBeTruthy();
|
||||
});
|
||||
@@ -274,9 +316,15 @@ describe('TransferManualCloseDialog', () => {
|
||||
props: { open: true, invoiceNo: 'INV-001' },
|
||||
...mountOptions,
|
||||
});
|
||||
// [断言意图] EP el-dialog 挂载后下一 tick 才渲染弹层内容,先 flush 再断言。
|
||||
await flushPromises();
|
||||
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('线下已处理');
|
||||
// el-input textarea:经组件 setValue 触发 v-model(勿对包装节点直接 setValue)。
|
||||
const reason = wrapper.findComponent({ name: 'ElInput' });
|
||||
expect(reason.exists()).toBe(true);
|
||||
await reason.setValue('线下已处理');
|
||||
await flushPromises();
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(false);
|
||||
await confirm.trigger('click');
|
||||
expect(wrapper.emitted('confirm')?.[0][0]).toBe('线下已处理');
|
||||
|
||||
@@ -1,24 +1,40 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferDate.spec.ts
|
||||
* 用途:锁定 T+2 成熟口径的截止日计算(与后端 date_policy 同口径,默认 lag=2)。
|
||||
* 用途:锁定匹配日期默认值(T−2 产品默认作业点)、上海业务日计算(与后端
|
||||
* date_policy 同口径),以及证据抓取时间的东八区展示。
|
||||
* 依赖:被测纯函数 transferDate.ts。
|
||||
* 逻辑:直接注入 UTC 时刻构造上海业务日,断言跨日/跨月边界不漂移。
|
||||
* 【T−2 管控恢复 2026-10-21】T−2 同时是默认值与选择器上限(T−2 之前数据
|
||||
* 全部成熟;2026-10-16 曾随成熟规则退役放开到 T 当天,本次收回)。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { eligibleReceiptDateTo, shanghaiBusinessDate } from './transferDate';
|
||||
import { defaultMovementDate, formatShanghaiDateTime, formatShanghaiMonthDayTime, shanghaiBusinessDate } from './transferDate';
|
||||
|
||||
describe('eligibleReceiptDateTo(T+2 口径)', () => {
|
||||
it('T=2026-09-28 → 截止 2026-09-26(T-2,海外时差)', () => {
|
||||
describe('defaultMovementDate(T−2 默认作业点)', () => {
|
||||
it('T=2026-09-28 → 默认 2026-09-26(T-2)', () => {
|
||||
// 上海 9-28 13:00 = UTC 05:00。
|
||||
expect(eligibleReceiptDateTo(new Date('2026-09-28T05:00:00Z'))).toBe('2026-09-26');
|
||||
expect(defaultMovementDate(new Date('2026-09-28T05:00:00Z'))).toBe('2026-09-26');
|
||||
});
|
||||
|
||||
it('UTC 月末跨界仍按上海业务日回退 2 天', () => {
|
||||
// 上海 10-01 00:30 = UTC 9-30 16:30 → T=10-01,截止 09-29。
|
||||
expect(eligibleReceiptDateTo(new Date('2026-09-30T16:30:00Z'))).toBe('2026-09-29');
|
||||
// 上海 10-01 00:30 = UTC 9-30 16:30 → T=10-01,默认 09-29。
|
||||
expect(defaultMovementDate(new Date('2026-09-30T16:30:00Z'))).toBe('2026-09-29');
|
||||
});
|
||||
|
||||
it('shanghaiBusinessDate 返回上海业务日(UTC 17:00 = 上海次日)', () => {
|
||||
expect(shanghaiBusinessDate(new Date('2026-08-05T17:00:00Z'))).toBe('2026-08-06');
|
||||
});
|
||||
});
|
||||
|
||||
describe('证据抓取时间按东八区展示', () => {
|
||||
it('无时区的 UTC 时刻加 8 小时,不把 02:57 原样显示', () => {
|
||||
// [断言意图] 后端 naive ISO 是 UTC。02:57Z 在上海是当天 10:57。
|
||||
expect(formatShanghaiMonthDayTime('2026-10-22T02:57:00')).toBe('10-22 10:57');
|
||||
expect(formatShanghaiDateTime('2026-10-22T02:57:00')).toBe('2026-10-22 10:57');
|
||||
});
|
||||
|
||||
it('跨过上海零点时月日跟着东八区走', () => {
|
||||
// [断言意图] 16:30Z 已是上海次日 00:30,下载名用的日期必须跟这一天,而不是 UTC 日期。
|
||||
expect(formatShanghaiMonthDayTime('2026-10-21T16:30:00Z')).toBe('10-22 00:30');
|
||||
});
|
||||
});
|
||||
@@ -1,15 +1,23 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferDate.ts
|
||||
* 用途:在途调拨业务日期工具——按 Asia/Shanghai 计算业务日期(T)与
|
||||
* T+lag 成熟规则的可匹配截止日(T - lag,lag 默认 2 即 T+2),
|
||||
* 与后端 date_policy 完全同口径。
|
||||
* 依赖:无(纯函数,便于单测)。
|
||||
* 用途:在途调拨业务日期工具——按 Asia/Shanghai 计算业务日期(T)、
|
||||
* 匹配日期默认值与输入上限(两者同为 T−2 可匹配截止日),
|
||||
* 以及证据清单抓取时间的东八区展示。
|
||||
* 依赖:shared/utils/dateTime.parseApiUtcDate(无时区 ISO 按 UTC 解析)。
|
||||
* 逻辑:浏览器本地时区不可靠(部署/用户时区任意),必须固定上海时区口径,
|
||||
* 否则前端日期上限与后端 TRANSFER.RECEIPT_DATE_RANGE_INVALID 卡控会漂移。
|
||||
* 否则前端日期默认/上限与后端 TRANSFER.MOVEMENT_DATE_RANGE_INVALID
|
||||
* 卡控会漂移,证据行也会把 UTC 时刻原样显示。
|
||||
* 【T−2 管控恢复 2026-10-21】T−2 之前的数据全部成熟,T−2 之后(T−1/
|
||||
* 当天/未来)无成熟数据不可选——默认值与选择器上限同为 T−2;越界由
|
||||
* 后端 MOVEMENT_DATE_RANGE_INVALID 兜底卡控。(2026-10-16 曾随成熟
|
||||
* 规则退役放开到 T 当天,本次按业务口径收回。)
|
||||
*/
|
||||
|
||||
/** 成熟滞后天数:与后端 IN_TRANSIT_TRANSFER_MATURITY_LAG_DAYS 默认值一致(T+2,海外时差余量)。 */
|
||||
const MATURITY_LAG_DAYS = 2;
|
||||
import { parseApiUtcDate } from '@/shared/utils/dateTime';
|
||||
|
||||
/** 匹配日期默认回看天数=可匹配截止滞后:T−2 之前数据全部成熟(与后端
|
||||
* date_policy.MOVEMENT_DATE_MAX_LAG_DAYS 同口径)。 */
|
||||
const DEFAULT_LOOKBACK_DAYS = 2;
|
||||
|
||||
/** Asia/Shanghai 当前业务日期(YYYY-MM-DD)。 */
|
||||
export function shanghaiBusinessDate(now: Date = new Date()): string {
|
||||
@@ -22,9 +30,70 @@ export function shanghaiBusinessDate(now: Date = new Date()): string {
|
||||
}).format(now);
|
||||
}
|
||||
|
||||
/** T+lag 规则可匹配截止日(业务日期 T - lag 天,默认 T-2,YYYY-MM-DD)。 */
|
||||
export function eligibleReceiptDateTo(now: Date = new Date()): string {
|
||||
interface ShanghaiClock {
|
||||
year: string;
|
||||
month: string;
|
||||
day: string;
|
||||
hour: string;
|
||||
minute: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把接口时间拆成上海时区的年月日时分。
|
||||
* 核心逻辑:无时区后缀的 ISO 先按 UTC 解析,再用 Asia/Shanghai 取墙钟,
|
||||
* 避免把 02:57 UTC 显示成 02:57。
|
||||
* @param iso - 后端 created_at 等时间字符串
|
||||
* @returns 拆开的两位字段;无法解析时返回 null
|
||||
*/
|
||||
function shanghaiClock(iso: string): ShanghaiClock | null {
|
||||
const date = parseApiUtcDate(iso);
|
||||
if (!iso || Number.isNaN(date.getTime())) return null;
|
||||
const parts = new Intl.DateTimeFormat('en-GB', {
|
||||
timeZone: 'Asia/Shanghai',
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hourCycle: 'h23',
|
||||
}).formatToParts(date);
|
||||
const pick = (type: Intl.DateTimeFormatPartTypes) => parts.find((part) => part.type === type)?.value ?? '';
|
||||
const clock = {
|
||||
year: pick('year'),
|
||||
month: pick('month'),
|
||||
day: pick('day'),
|
||||
hour: pick('hour'),
|
||||
minute: pick('minute'),
|
||||
};
|
||||
if (!clock.year || !clock.month || !clock.day || clock.hour === '' || clock.minute === '') return null;
|
||||
return clock;
|
||||
}
|
||||
|
||||
/**
|
||||
* 证据行短时间:上海时区的月日和时分。
|
||||
* @param iso - 后端 naive UTC 或带时区的 ISO 时间
|
||||
* @returns `MM-DD HH:mm`;无法解析时退回原字符串
|
||||
*/
|
||||
export function formatShanghaiMonthDayTime(iso: string): string {
|
||||
const clock = shanghaiClock(iso);
|
||||
if (!clock) return iso;
|
||||
return `${clock.month}-${clock.day} ${clock.hour}:${clock.minute}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 悬停用的完整上海时间,不含秒。
|
||||
* @param iso - 后端 naive UTC 或带时区的 ISO 时间
|
||||
* @returns `YYYY-MM-DD HH:mm`;无法解析时退回原字符串
|
||||
*/
|
||||
export function formatShanghaiDateTime(iso: string): string {
|
||||
const clock = shanghaiClock(iso);
|
||||
if (!clock) return iso;
|
||||
return `${clock.year}-${clock.month}-${clock.day} ${clock.hour}:${clock.minute}`;
|
||||
}
|
||||
|
||||
/** 匹配日期默认值=可匹配截止日(业务日期 T − 2 天,YYYY-MM-DD)。 */
|
||||
export function defaultMovementDate(now: Date = new Date()): string {
|
||||
const business = new Date(`${shanghaiBusinessDate(now)}T00:00:00Z`);
|
||||
business.setUTCDate(business.getUTCDate() - MATURITY_LAG_DAYS);
|
||||
business.setUTCDate(business.getUTCDate() - DEFAULT_LOOKBACK_DAYS);
|
||||
return business.toISOString().slice(0, 10);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferDialogShell.ts
|
||||
* 用途:在途调拨确认弹层壳(ElDialog)共享配置——人工关闭/清空重解析/关闭单
|
||||
* 三处高危确认弹窗统一的防误触语义与居中形态。
|
||||
* 依赖:无(纯常量,供组件模板 v-bind 展开)。
|
||||
* 逻辑:禁 ESC / 遮罩点击 / 右上角 X 关闭——确认类危险操作仅经取消/确认按钮关闭,
|
||||
* 与 EP 化前原生遮罩层行为一致;alignCenter 对齐原 fixed 居中布局。
|
||||
*/
|
||||
|
||||
/** ElDialog 防误触共享配置:`v-bind="transferDialogShellAttrs"` 展开到组件标签。 */
|
||||
export const transferDialogShellAttrs = {
|
||||
alignCenter: true,
|
||||
closeOnClickModal: false,
|
||||
closeOnPressEscape: false,
|
||||
showClose: false,
|
||||
} as const;
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferItemTable.spec.ts
|
||||
* 用途:锁住明细表库存单元格与新鲜度提示的统一格式。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
formatStockCheckedAt,
|
||||
formatStockQuantityCell,
|
||||
freshnessHint,
|
||||
} from './transferItemTable';
|
||||
|
||||
describe('transferItemTable', () => {
|
||||
it('完整查询时刻为上海时区 YYYY-MM-DD HH:mm', () => {
|
||||
// [断言意图] +08:00 墙钟原样保留;无时区 naive 按 UTC 再转上海。
|
||||
expect(formatStockCheckedAt('2026-09-23T09:05:00+08:00')).toBe('2026-09-23 09:05');
|
||||
expect(formatStockCheckedAt('2026-10-22T02:57:00')).toBe('2026-10-22 10:57');
|
||||
expect(formatStockCheckedAt('')).toBe('');
|
||||
});
|
||||
|
||||
it('库存单元格数量与时刻同一行', () => {
|
||||
// [断言意图] 禁止拆成两行撑高表格。
|
||||
expect(formatStockQuantityCell('30', '2026-10-20T10:38:00+08:00')).toBe('30 · 2026-10-20 10:38');
|
||||
expect(formatStockQuantityCell('30', null)).toBe('30');
|
||||
});
|
||||
|
||||
it('新鲜度悬停过期优先于文件更新', () => {
|
||||
const t = (key: string) => key;
|
||||
expect(freshnessHint({ stale: true, file_current: false }, t)).toBe('chat.transfer.staleRow');
|
||||
expect(freshnessHint({ stale: false, file_current: false }, t)).toBe('chat.transfer.fileChangedRow');
|
||||
expect(freshnessHint({}, t)).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferItemTable.ts
|
||||
* 用途:在途调拨明细表(可调拨 / 匹配 / 待恢复)的统一展示约定与单元格格式化。
|
||||
* 依赖:transferDate.formatShanghaiDateTime、i18n chat.transfer.*。
|
||||
* 逻辑:三卡共用 Element Plus 密度规则,禁止各卡各自叠第二行或放任折行。
|
||||
*
|
||||
* Element Plus 约定:
|
||||
* 1. 长文本列 show-overflow-tooltip;不够宽就横向滚,不折行。
|
||||
* 2. 左只固定勾选,右固定结果/操作;单号随表横滚(不钉死,避免挤窄中间区)。
|
||||
* 3. 库存数量与查询时刻同一行:「数量 · YYYY-MM-DD HH:mm」。
|
||||
* 4. 过期不占结果列长文;顶栏 el-alert 汇总 + 批量重查。
|
||||
*/
|
||||
|
||||
import { formatShanghaiDateTime } from './transferDate';
|
||||
|
||||
const CHECKED_AT_RE = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}$/;
|
||||
|
||||
/**
|
||||
* 把后端库存查得时刻格式成上海时区完整墙钟。
|
||||
* @param checkedAt - 后端 ISO(可空)
|
||||
* @returns `YYYY-MM-DD HH:mm`;无法解析则空串
|
||||
*/
|
||||
export function formatStockCheckedAt(checkedAt: string | null | undefined): string {
|
||||
if (!checkedAt) return '';
|
||||
const label = formatShanghaiDateTime(checkedAt);
|
||||
return CHECKED_AT_RE.test(label) ? label : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 库存数量单元格主文案:数量与查询时刻同一行。
|
||||
* @param quantityLabel - 已格式化的数量文本
|
||||
* @param checkedAt - 后端 ISO
|
||||
* @returns 如 `30 · 2026-10-20 18:38`;无时刻则仅数量
|
||||
*/
|
||||
export function formatStockQuantityCell(
|
||||
quantityLabel: string,
|
||||
checkedAt: string | null | undefined,
|
||||
): string {
|
||||
const when = formatStockCheckedAt(checkedAt);
|
||||
return when ? `${quantityLabel} · ${when}` : quantityLabel;
|
||||
}
|
||||
|
||||
export interface TransferFreshnessRow {
|
||||
stale?: boolean;
|
||||
file_current?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 行新鲜度悬停说明(过期优先于文件更新)。
|
||||
* @param row - 带 stale / file_current 的明细行
|
||||
* @param t - vue-i18n t
|
||||
* @returns 悬停全文;无提示时空串
|
||||
*/
|
||||
export function freshnessHint(
|
||||
row: TransferFreshnessRow,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
if (row.stale) return t('chat.transfer.staleRow');
|
||||
if (row.file_current === false) return t('chat.transfer.fileChangedRow');
|
||||
return '';
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferTypeLabel.ts
|
||||
* 用途:把调拨类型 code 显示成当前语言的类型名称。
|
||||
* 依赖:TransferTypeOption。
|
||||
* 逻辑:与来源选择卡同一回退链 names[locale] → zh-CN → en → code。
|
||||
* 可调拨明细卡与待处理异常卡共用。停用类型不在启用列表里时回退显示 code;
|
||||
* 没有 code 时返回占位。
|
||||
*/
|
||||
import type { TransferTypeOption } from '../../types/transfer.types';
|
||||
|
||||
/**
|
||||
* 解析一行要展示的调拨类型名称。
|
||||
* 核心逻辑:先按 code 找启用类型配置,再按当前语言回退;找不到配置时直接显示 code。
|
||||
* @param code - 行上的调拨类型编码;空值表示这行没有匹配类型
|
||||
* @param types - GET /transfer-types 的启用类型列表
|
||||
* @param locale - 当前界面语言
|
||||
* @param fallback - 没有编码时的占位,默认 —
|
||||
* @returns 类型名称、编码或占位
|
||||
*/
|
||||
export function transferTypeDisplay(
|
||||
code: string | null | undefined,
|
||||
types: TransferTypeOption[],
|
||||
locale: string,
|
||||
fallback = '—',
|
||||
): string {
|
||||
const cleaned = (code || '').trim();
|
||||
if (!cleaned) return fallback;
|
||||
const option = types.find((item) => item.code === cleaned);
|
||||
if (!option) return cleaned;
|
||||
return option.names?.[locale] ?? option.names?.['zh-CN'] ?? option.names?.en ?? cleaned;
|
||||
}
|
||||
+22
-22
@@ -15,13 +15,13 @@ const i18n = createI18n({
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
'chat.shippingOrderReview.processGate.actionCodes.retry_inventory_matching': '重新库存匹配',
|
||||
'chat.shippingOrderReview.processGate.actionCodes.retry_onhand_matching': '重新库存匹配',
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
processGate: {
|
||||
actionCodes: {
|
||||
reload_inventory_result: '重新读取库存结果',
|
||||
retry_inventory_preparation: '重新获取库存',
|
||||
reload_onhand_result: '重新读取库存结果',
|
||||
retry_onhand_preparation: '重新获取库存',
|
||||
confirm_customer: '确认客户',
|
||||
},
|
||||
inventoryActions: {
|
||||
@@ -76,7 +76,7 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
it('hides a legacy primary action while inventory preparation is running', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_preparation',
|
||||
stageCode: 'onhand_preparation',
|
||||
userStatus: 'running',
|
||||
primaryAction: { code: 'edit_formal_task', i18nKey: 'edit_formal_task' },
|
||||
},
|
||||
@@ -90,8 +90,8 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
it('keeps the retry action for retryable states', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_preparation', userStatus: 'retryable', retryable: true,
|
||||
primaryAction: { code: 'retry_inventory_preparation', i18nKey: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation' },
|
||||
stageCode: 'onhand_preparation', userStatus: 'retryable', retryable: true,
|
||||
primaryAction: { code: 'retry_onhand_preparation', i18nKey: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -105,8 +105,8 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
// 此用例用 reload_inventory_result(仍为写契约有效码)验证卡片对库存动作文案的渲染。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_preparation', userStatus: 'retryable', retryable: true,
|
||||
primaryAction: { code: 'reload_inventory_result' },
|
||||
stageCode: 'onhand_preparation', userStatus: 'retryable', retryable: true,
|
||||
primaryAction: { code: 'reload_onhand_result' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
@@ -131,11 +131,11 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
it('renders Gate label_key for every primary action presentation', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_matching',
|
||||
stageCode: 'onhand_matching',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: {
|
||||
code: 'retry_inventory_matching',
|
||||
label_key: 'chat.shippingOrderReview.processGate.actionCodes.retry_inventory_matching',
|
||||
code: 'retry_onhand_matching',
|
||||
label_key: 'chat.shippingOrderReview.processGate.actionCodes.retry_onhand_matching',
|
||||
} as any,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
@@ -220,7 +220,7 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
it('renders a localized reason instead of an internal blocking code in the next step', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_matching',
|
||||
stageCode: 'onhand_matching',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: { code: 'inventory_shortage_review_required' },
|
||||
},
|
||||
@@ -235,18 +235,18 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
it('hides internal inventory recovery targets while retaining the stable primary action', async () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'inventory_matching',
|
||||
stageCode: 'onhand_matching',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: { code: 'retry_inventory_matching', i18nKey: 'retry_inventory_matching' },
|
||||
primaryAction: { code: 'retry_onhand_matching', i18nKey: 'retry_onhand_matching' },
|
||||
recoveryActions: [{
|
||||
code: 'retry_inventory_from_preparation',
|
||||
i18nKey: 'chat.shippingOrderReview.processGate.actionCodes.retry_inventory_matching',
|
||||
code: 'retry_onhand_from_preparation',
|
||||
i18nKey: 'chat.shippingOrderReview.processGate.actionCodes.retry_onhand_matching',
|
||||
}],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-recovery-retry_inventory_from_preparation"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-task-recovery-retry_onhand_from_preparation"]').exists()).toBe(false);
|
||||
expect(wrapper.findAll('button').length).toBe(1);
|
||||
});
|
||||
|
||||
@@ -255,19 +255,19 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
props: {
|
||||
stageCode: 'fulfillment_prep',
|
||||
userStatus: 'waiting_human',
|
||||
primaryAction: { code: 'retry_inventory_matching' },
|
||||
recoveryActions: [{ code: 'retry_inventory_preparation' }],
|
||||
primaryAction: { code: 'retry_onhand_matching' },
|
||||
recoveryActions: [{ code: 'retry_onhand_preparation' }],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="review-current-processing-retry"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-current-task-recovery-retry_onhand_preparation"]').trigger('click');
|
||||
|
||||
// 两个稳定 action 码分别进入 Gate API:重匹配不可误触 RPA,重新获取库存才会触发 RPA。
|
||||
expect(wrapper.emitted('action')).toEqual([
|
||||
['retry_inventory_matching', {}],
|
||||
['retry_inventory_preparation', {}],
|
||||
['retry_onhand_matching', {}],
|
||||
['retry_onhand_preparation', {}],
|
||||
]);
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -317,7 +317,7 @@ const businessActionTitle = computed(() => {
|
||||
});
|
||||
|
||||
const actionIsRetry = computed(() => String(props.primaryAction?.code || '').trim().startsWith('retry_'));
|
||||
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_inventory_preparation');
|
||||
const actionIsInventoryRpa = computed(() => String(props.primaryAction?.code || '').trim() === 'retry_onhand_preparation');
|
||||
|
||||
/**
|
||||
* 阶段能力禁用态裁决:与视图层 submitFormalGateAction 的点击拦截同源(展示=执行同源)。
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ const { t, te } = useI18n();
|
||||
|
||||
const visible = computed(() => {
|
||||
const actions = props.fallback?.allowed_actions || [];
|
||||
return Boolean(props.fallback && actions.includes('retry_inventory_preparation'));
|
||||
return Boolean(props.fallback && actions.includes('retry_onhand_preparation'));
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -71,7 +71,7 @@ const reasonLabel = computed(() => {
|
||||
:disabled="busy"
|
||||
@click="emit('retry-preparation')"
|
||||
>
|
||||
{{ t(inventoryActionLabelKey('retry_inventory_preparation')!) }}
|
||||
{{ t(inventoryActionLabelKey('retry_onhand_preparation')!) }}
|
||||
</button>
|
||||
</section>
|
||||
</template>
|
||||
+1
-1
@@ -55,7 +55,7 @@ describe('ReviewLineInventoryOps', () => {
|
||||
it('keeps inventory actions out of the line even when present', () => {
|
||||
const wrapper = mountOps({
|
||||
retryable: false,
|
||||
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
|
||||
inventory_allowed_actions: ['retry_onhand_preparation', 'retry_onhand_matching'],
|
||||
line_allowed_actions: ['close_unfulfillable'],
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-line-retry"]').exists()).toBe(false);
|
||||
|
||||
+7
-7
@@ -474,7 +474,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
customerName: null, poNumber: 'PO-FIRST',
|
||||
},
|
||||
childOrderTasks: [{
|
||||
orderTaskNo: 'OT-EML-WITH-CHILD-OT-C1', status: 'blocked', stage: 'inventory_matching',
|
||||
orderTaskNo: 'OT-EML-WITH-CHILD-OT-C1', status: 'blocked', stage: 'onhand_matching',
|
||||
customerName: null, poNumber: 'PO-SECOND', lastActivityAt: null,
|
||||
}],
|
||||
});
|
||||
@@ -976,23 +976,23 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
currentGate: {
|
||||
gateCode: 'inventory_matching',
|
||||
nextActionCode: 'open_inventory_match_review',
|
||||
gateCode: 'onhand_matching',
|
||||
nextActionCode: 'open_onhand_match_review',
|
||||
blockingReasonCode: 'inventory_match_not_ready',
|
||||
},
|
||||
availableActions: ['open_inventory_match_review'],
|
||||
availableActions: ['open_onhand_match_review'],
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'waiting_review',
|
||||
lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [],
|
||||
blocking_reason: { code: 'inventory_match_not_ready' },
|
||||
primary_action: { code: 'open_inventory_match_review', i18nKey: null, parameters: {}, executionMode: 'immediate' },
|
||||
primary_action: { code: 'open_onhand_match_review', i18nKey: null, parameters: {}, executionMode: 'immediate' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
}),
|
||||
buildWorkItem('OT-PROC', {
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
}),
|
||||
],
|
||||
},
|
||||
@@ -1006,7 +1006,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
|
||||
const task = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
|
||||
expect(task.find('[data-testid="unified-action-primary"]').exists()).toBe(true);
|
||||
expect(task.find('[data-testid="unified-action-primary"]').text()).toContain('open_inventory_match_review');
|
||||
expect(task.find('[data-testid="unified-action-primary"]').text()).toContain('open_onhand_match_review');
|
||||
|
||||
await task.find('button').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
+1
-1
@@ -775,7 +775,7 @@ function currentNeedLabel(task: ConversationProcessingUserTask): string {
|
||||
const labels: Record<string, string> = {
|
||||
confirm_customer: 'chat.shippingProcessing.currentNeed.confirmCustomer',
|
||||
resolve_field_conflicts: 'chat.shippingProcessing.currentNeed.resolveFieldConflicts',
|
||||
open_inventory_match_review: 'chat.shippingProcessing.currentNeed.inventoryMatch',
|
||||
open_onhand_match_review: 'chat.shippingProcessing.currentNeed.inventoryMatch',
|
||||
open_order_processing: 'chat.shippingProcessing.currentNeed.orderDraft',
|
||||
retry: 'chat.shippingProcessing.currentNeed.retry',
|
||||
retry_parse: 'chat.shippingProcessing.currentNeed.retry',
|
||||
|
||||
@@ -280,7 +280,7 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
it('uses the clicked secondary action lifecycle target instead of falling back to view-result handling', async () => {
|
||||
const file = fileProjection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'inventory_matching', lifecycleStage: 'fulfillment_prep',
|
||||
status: 'waiting_human', stage: 'onhand_matching', lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [], blocking_reason: null, primary_action: null,
|
||||
secondary_actions: [{
|
||||
code: 'view_result', enabled: true, executionMode: 'navigate',
|
||||
|
||||
@@ -24,9 +24,14 @@ describe('transfer i18n four-language consistency', () => {
|
||||
});
|
||||
|
||||
it('每个 transfer 文案值非空', () => {
|
||||
// 允许为空白名单:en.reparseFilesSuffix 有意置空——前缀 "Archived files: "
|
||||
// 已表义,再拼 " archived" 会重复("Archived files: 3 archived");
|
||||
// zh-CN/zh-TW/th 的计数词(" 份"/" ไฟล์")语义必需,仍须非空。
|
||||
const allowEmpty = new Set(['en.reparseFilesSuffix']);
|
||||
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)) {
|
||||
if (allowEmpty.has(`${name}.${key}`)) continue;
|
||||
expect(String(value).trim().length, `${name}.transfer.${key}`).toBeGreaterThan(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ export function useChatPage() {
|
||||
const leaveMessageHandlers = createLeaveMessageHandlers(leave);
|
||||
const shippingMessageHandlers = createShippingMessageHandlers(shipping);
|
||||
const trainingHandlers = createTrainingHandlers(training);
|
||||
const shippingPickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingInventoryPickerRef));
|
||||
const shippingPickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingOnhandPickerRef));
|
||||
const shippingNoticePickerRefHolder = markRaw(createShippingPickerRefHolder(shipping.shippingNoticePickerRef));
|
||||
|
||||
const showChatRating = ref(false);
|
||||
@@ -627,13 +627,13 @@ export function useChatPage() {
|
||||
bumpWorkflowRefresh: shipping.bumpWorkflowRefresh,
|
||||
focusedConversationTaskNo: shipping.focusedConversationTaskNo,
|
||||
setFocusedConversationTaskNo: shipping.setFocusedConversationTaskNo,
|
||||
shippingInventorySelectionActive: shipping.shippingInventorySelectionActive,
|
||||
shippingInventorySelectionTaskId: shipping.shippingInventorySelectionTaskId,
|
||||
shippingOnhandSelectionActive: shipping.shippingOnhandSelectionActive,
|
||||
shippingOnhandSelectionTaskId: shipping.shippingOnhandSelectionTaskId,
|
||||
queryShippingShortageDetails: shipping.queryShippingShortageDetails,
|
||||
selectShippingInventoryUploadTask: shipping.selectShippingInventoryUploadTask,
|
||||
cancelShippingInventoryTaskSelection: shipping.cancelShippingInventoryTaskSelection,
|
||||
selectShippingOnhandUploadTask: shipping.selectShippingOnhandUploadTask,
|
||||
cancelShippingOnhandTaskSelection: shipping.cancelShippingOnhandTaskSelection,
|
||||
shippingSuggestedPrompt: shipping.shippingSuggestedPrompt,
|
||||
handleShippingInventorySelected: shipping.handleShippingInventorySelected,
|
||||
handleShippingOnhandSelected: shipping.handleShippingOnhandSelected,
|
||||
useShippingSuggestedPrompt: shipping.useShippingSuggestedPrompt,
|
||||
handleSidebarNewChat,
|
||||
goToWorkspace: routeSync.goToWorkspace,
|
||||
|
||||
@@ -187,13 +187,13 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
() => isShippingNoticeAgent.value && attachments.value.length > 0,
|
||||
);
|
||||
const shippingAutoFlowRequested = ref(false);
|
||||
const shippingInventoryPickerRef = ref<HTMLInputElement | null>(null);
|
||||
const shippingOnhandPickerRef = ref<HTMLInputElement | null>(null);
|
||||
const shippingNoticePickerRef = ref<HTMLInputElement | null>(null);
|
||||
const pendingShippingUploadTaskId = ref('');
|
||||
const pendingShippingNoticeTaskId = ref('');
|
||||
const pendingShippingInventoryFile = ref<File | null>(null);
|
||||
const shippingInventorySelectionActive = ref(false);
|
||||
const shippingInventorySelectionTaskId = ref('');
|
||||
const pendingShippingOnhandFile = ref<File | null>(null);
|
||||
const shippingOnhandSelectionActive = ref(false);
|
||||
const shippingOnhandSelectionTaskId = ref('');
|
||||
|
||||
const prepareMarkdownDisplayText = (text: string) => {
|
||||
return sanitizeShippingConversationText(stripReasoningPrelude(text), isShippingNoticeAgent.value);
|
||||
@@ -264,9 +264,9 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingAutoFlowRequested.value = false;
|
||||
pendingShippingUploadTaskId.value = '';
|
||||
pendingShippingNoticeTaskId.value = '';
|
||||
pendingShippingInventoryFile.value = null;
|
||||
shippingInventorySelectionActive.value = false;
|
||||
shippingInventorySelectionTaskId.value = '';
|
||||
pendingShippingOnhandFile.value = null;
|
||||
shippingOnhandSelectionActive.value = false;
|
||||
shippingOnhandSelectionTaskId.value = '';
|
||||
resolvedShippingTaskId.value = '';
|
||||
activeShippingTaskDetail.value = null;
|
||||
lastConversationSyncKey.value = '';
|
||||
@@ -667,11 +667,11 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const {
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
openShippingInventoryPicker,
|
||||
openShippingOnhandPicker,
|
||||
openShippingNoticePicker,
|
||||
selectShippingInventoryUploadTask,
|
||||
cancelShippingInventoryTaskSelection,
|
||||
handleShippingInventorySelected,
|
||||
selectShippingOnhandUploadTask,
|
||||
cancelShippingOnhandTaskSelection,
|
||||
handleShippingOnhandSelected,
|
||||
shippingSuggestedPrompt,
|
||||
useShippingSuggestedPrompt,
|
||||
isShippingNoticeBatchSubmitting,
|
||||
@@ -681,14 +681,14 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
attachments,
|
||||
input,
|
||||
shippingAutoFlowRequested,
|
||||
shippingInventoryPickerRef,
|
||||
shippingOnhandPickerRef,
|
||||
shippingNoticePickerRef,
|
||||
pendingShippingUploadTaskId,
|
||||
pendingShippingNoticeTaskId,
|
||||
pendingShippingInventoryFile,
|
||||
pendingShippingOnhandFile,
|
||||
resolvedShippingTaskId,
|
||||
shippingInventorySelectionActive,
|
||||
shippingInventorySelectionTaskId,
|
||||
shippingOnhandSelectionActive,
|
||||
shippingOnhandSelectionTaskId,
|
||||
getActiveShippingTaskId,
|
||||
startChatTurn,
|
||||
refreshShippingActions,
|
||||
@@ -716,7 +716,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
getActiveShippingTaskId,
|
||||
messages,
|
||||
sendShippingMenuMessage,
|
||||
openShippingInventoryPicker,
|
||||
openShippingOnhandPicker,
|
||||
openShippingNoticePicker,
|
||||
openShippingCustomerDialog,
|
||||
executeShippingDecision,
|
||||
@@ -943,11 +943,11 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
isShippingNoticeAgent,
|
||||
prepareMarkdownDisplayText,
|
||||
shippingAutoFlowRequested,
|
||||
shippingInventoryPickerRef,
|
||||
shippingOnhandPickerRef,
|
||||
shippingNoticePickerRef,
|
||||
pendingShippingUploadTaskId,
|
||||
shippingInventorySelectionActive,
|
||||
shippingInventorySelectionTaskId,
|
||||
shippingOnhandSelectionActive,
|
||||
shippingOnhandSelectionTaskId,
|
||||
allowsSendWithAttachmentsOnly,
|
||||
shippingTaskIdFromQuery,
|
||||
isShippingActionBusy,
|
||||
@@ -963,10 +963,10 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
addShippingParseReviewLine,
|
||||
removeShippingParseReviewLine,
|
||||
handleShippingActionClick,
|
||||
handleShippingInventorySelected,
|
||||
handleShippingOnhandSelected,
|
||||
finalizeShippingAssistantMessage,
|
||||
selectShippingInventoryUploadTask,
|
||||
cancelShippingInventoryTaskSelection,
|
||||
selectShippingOnhandUploadTask,
|
||||
cancelShippingOnhandTaskSelection,
|
||||
shippingSuggestedPrompt,
|
||||
useShippingSuggestedPrompt,
|
||||
enqueueShippingNoticeFiles: shippingIntakes.enqueueNoticeFiles,
|
||||
|
||||
@@ -19,14 +19,16 @@ const api = vi.hoisted(() => ({
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
batchRequeryTransferItems: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferInboundFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
fetchTransferTypes: vi.fn(),
|
||||
retryTransferSourceRpa: vi.fn(),
|
||||
listTransferBacklog: vi.fn(),
|
||||
listTransferBacklogPage: vi.fn(),
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listExecutableTransferItems: vi.fn(),
|
||||
listPendingMatchRecordsPage: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../api/transfer.api', () => api);
|
||||
@@ -37,9 +39,8 @@ const summary = {
|
||||
matching_id: 'MTG-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, matched_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
counts: { file_invoice_count: 2, matched_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_external_write_count: 2,
|
||||
matching_hash: 'sha256:abc',
|
||||
@@ -51,7 +52,7 @@ const detail = {
|
||||
items: [
|
||||
{ item_id: 11, 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' },
|
||||
{ item_id: 12, 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' },
|
||||
{ item_id: 13, 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' },
|
||||
{ item_id: 13, 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: 'blocked_quantity_mismatch' },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -68,7 +69,7 @@ describe('useChatTransfer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('创建匹配后默认按 item_id 勾选全部可执行行,未成熟项不可勾选', async () => {
|
||||
it('创建匹配后默认按 item_id 勾选全部可执行行,阻断项不可勾选', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createMatching(['DBS-AWSBI'], '2026-08-06');
|
||||
expect(transfer.matchingId.value).toBe('MTG-20260806-001');
|
||||
@@ -77,6 +78,30 @@ describe('useChatTransfer', () => {
|
||||
expect(transfer.selected.value.has(13)).toBe(false);
|
||||
});
|
||||
|
||||
it('创建匹配携带异动日期范围:参数名 movement_date_from/to(Task 3 契约更名)', async () => {
|
||||
// [断言意图] 匹配查询范围参数对齐后端 /matchings 新契约(Task 3 更名):
|
||||
// 参数名为 movement_date_from/to;日期值透传来源选择卡的 D+1 规则区间。
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createMatching(['DBS-AWSBI'], undefined, { from: '2026-09-26', to: '2026-09-26' });
|
||||
expect(api.createTransferMatching).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ movement_date_from: '2026-09-26', movement_date_to: '2026-09-26' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('downloadInboundFiles 按 run_no 调下载 API,文件名缺省回退 inbound-files-<run_no>.zip', async () => {
|
||||
// [断言意图] 下载出入站来源文件走 /runs/{run_no}/inbound-files(Task 3 路由更名):
|
||||
// 组合式函数按 run_no 调 API;后端未回 filename 时前端回退 inbound-files- 前缀命名。
|
||||
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: 'inbound-files.zip' });
|
||||
const transfer = useChatTransfer();
|
||||
transfer.runNo.value = 'RUN-20260806-001';
|
||||
await transfer.downloadInboundFiles();
|
||||
expect(api.downloadTransferInboundFiles).toHaveBeenCalledWith('RUN-20260806-001');
|
||||
|
||||
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: null });
|
||||
await transfer.downloadInboundFiles();
|
||||
expect(api.downloadTransferInboundFiles).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('执行时按明细行 id 提交勾选范围并恢复 Run', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createMatching(['DBS-AWSBI']);
|
||||
@@ -96,22 +121,6 @@ describe('useChatTransfer', () => {
|
||||
expect(api.executeTransferItems).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('resume 是批量重查的语义别名:按明细 id 直调 batch-requery', async () => {
|
||||
// [断言意图] 行式执行重构(2026-09-23):恢复处理不再重建匹配,
|
||||
// 前端 resume 与 batchRequery 同源(batch-requery 是恢复的唯一后端)。
|
||||
api.batchRequeryTransferItems.mockResolvedValue({
|
||||
total: 2,
|
||||
results: [
|
||||
{ item_id: 7, ok: true, status: 'ready_to_execute' },
|
||||
{ item_id: 8, ok: false, error: 'blocked' },
|
||||
],
|
||||
});
|
||||
const transfer = useChatTransfer();
|
||||
const result = await transfer.resume([7, 8]);
|
||||
expect(api.batchRequeryTransferItems).toHaveBeenCalledWith([7, 8]);
|
||||
expect(result.results.filter((entry) => entry.status === 'ready_to_execute')).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('busy 在请求期间置位,完成后复位(防重复点击)', async () => {
|
||||
let resolveMatching!: (value: unknown) => void;
|
||||
api.getTransferMatching.mockImplementation(
|
||||
@@ -284,7 +293,7 @@ describe('useChatTransfer Run 轮询(D8 异步 202 / D9 融合卡数据源)'
|
||||
});
|
||||
});
|
||||
|
||||
describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)', () => {
|
||||
describe('useChatTransfer 来源状态轮询(入站 RPA 202 异步收口)', () => {
|
||||
/** 来源选择卡轮询用例的标准来源载荷(file_status 可变,驱动 fetching→终态分支) */
|
||||
const sourceOptionsWith = (file_status: string) => [
|
||||
{
|
||||
@@ -306,7 +315,7 @@ describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)',
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('重试收料 RPA 后来源处于抓取中即自动轮询,收口(ready)后停止', async () => {
|
||||
it('重试入站 RPA 后来源处于抓取中即自动轮询,收口(ready)后停止', async () => {
|
||||
// [断言意图] 重试 202 返回后 loadSources 首帧仍是 fetching(RPA 回调未到),
|
||||
// 轮询必须自动接管:收口帧把 抓取中→ready 投影进 sourceOptions(修复状态卡死),
|
||||
// 全部来源脱离 fetching 即停——再推进 20s 也不产生新请求。
|
||||
@@ -382,10 +391,61 @@ describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)',
|
||||
});
|
||||
});
|
||||
|
||||
describe('useChatTransfer 调拨类型加载(Task 7 接口化,模块级单飞)', () => {
|
||||
/** GET /transfer-types data 形状(含 record_kinds;enabled 过滤与排序在后端契约内) */
|
||||
const typesPayload = [
|
||||
{ code: 'in_transit_to_hub', names: { 'zh-CN': '在途仓至HUB仓' }, sort_order: 10, transform_rules: [{ field: 'lot_no', op: 'prefix_replace', source: 'WTP', target: 'HOW' }] },
|
||||
{ code: 'hub_to_hub', names: { 'zh-CN': 'HUB仓间调拨' }, sort_order: 30, transform_rules: [] },
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('loadTransferTypes 拉取并写入 transferTypes(选项即接口真相,前端不加工)', async () => {
|
||||
// [断言意图] 接口返回逐键透传进 transferTypes ref——前端不做类型白名单过滤
|
||||
// (开发期窗口:新建自定义类型提交匹配由后端枚举校验兜底)。
|
||||
api.fetchTransferTypes.mockResolvedValue(typesPayload);
|
||||
const transfer = useChatTransfer();
|
||||
const types = await transfer.loadTransferTypes();
|
||||
expect(api.fetchTransferTypes).toHaveBeenCalledTimes(1);
|
||||
expect(transfer.transferTypes.value).toEqual(typesPayload);
|
||||
expect(types).toEqual(typesPayload);
|
||||
});
|
||||
|
||||
it('模块级单飞:多实例并发调用共享同一在途请求,只打一次点', async () => {
|
||||
// [断言意图] 会话内多条来源选择消息/重复进入卡片并发挂载时共享同一 Promise,
|
||||
// 防止并发重复请求(与首页看板预取单飞同模式)。
|
||||
api.fetchTransferTypes.mockResolvedValue(typesPayload);
|
||||
const a = useChatTransfer();
|
||||
const b = useChatTransfer();
|
||||
await Promise.all([a.loadTransferTypes(), b.loadTransferTypes()]);
|
||||
expect(api.fetchTransferTypes).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('请求落定清槽:下次调用现发拿新鲜配置(不做长缓存)', async () => {
|
||||
// [断言意图] 类型配置可能被管理员调整:单飞只去重「在途」并发,
|
||||
// 落定后清槽,顺序调用各自现发(与来源列表拉取的新鲜度口径一致)。
|
||||
api.fetchTransferTypes.mockResolvedValue(typesPayload);
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.loadTransferTypes();
|
||||
await transfer.loadTransferTypes();
|
||||
expect(api.fetchTransferTypes).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('reset 清空 transferTypes', async () => {
|
||||
api.fetchTransferTypes.mockResolvedValue(typesPayload);
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.loadTransferTypes();
|
||||
transfer.reset();
|
||||
expect(transfer.transferTypes.value).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
|
||||
describe('useChatTransfer 首页看板预取(会话引导期单飞)', () => {
|
||||
/** 标准看板载荷(供预取槽位消费;单飞槽位是模块级状态,用例结束前必须双槽消费完) */
|
||||
const backlogSummaryPayload = {
|
||||
recoverable: 3, closed: 1, unknown: 0,
|
||||
recoverable: 3, closed: 1, unknown: 0, pending_match: 2,
|
||||
aging: { warn_3d: 1, escalate_5d: 0, critical_7d: 0 },
|
||||
};
|
||||
const executablePayload = { items: [{ item_id: 21 }], counts: { executable_count: 1 } };
|
||||
|
||||
@@ -2,14 +2,17 @@
|
||||
* features/chat/composables/useChatTransfer.ts
|
||||
* 用途:在途仓自动调拨聊天编排入口——匹配创建/恢复、选择范围(按明细 item_id)、
|
||||
* 按行直接生成执行 Run(D8 异步 202)、Run 轮询与结果恢复(D9 调拨单清单)、
|
||||
* 人工重试/关闭、恢复处理(重查)、下载。
|
||||
* 人工重试/关闭、待处理异常重查库存、下载。
|
||||
* 依赖:transfer.api、transfer.types、useMessage、Vue refs/computed/effect scope。
|
||||
* 逻辑:前端只消费稳定 DTO;Run 是异步真相源——提交只拿 {run_no,status:'queued'},
|
||||
* 进度/结果由 4s 轮询 getTransferRun 获取,终态(run.status)即停,刷新/重进由 GET 恢复;
|
||||
* 来源收料 RPA 同为异步收口——重试 202 后投影 fetching,存在 fetching 来源时
|
||||
* 来源 RPA 同为异步收口——单行重试带 record_kind(缺省 inbound),批量重试带
|
||||
* transfer_type;重试 202 后投影 fetching,存在 fetching 来源时
|
||||
* 4s 轮询 GET /sources 直至全部脱离 fetching(ready/failed/expired/none);
|
||||
* 勾选集合以明细行 item_id 为键(历史回放行无 item_id 不可选);
|
||||
* 恢复处理 = 按明细 id 重查库存(batch-requery 是唯一后端);
|
||||
* 待处理异常的重查库存由视图直接调 batchRequery;
|
||||
* 调拨类型配置(Task 7 接口化)= 模块级单飞拉取 GET /transfer-types,
|
||||
* 并发挂载共享同一在途请求,落定清槽不做长缓存;
|
||||
* 防重复点击(busy);错误统一 useMessage 展示 BusinessError;
|
||||
* 首页看板支持会话引导期预取(prefetchTransferHomeBoard 单飞,
|
||||
* loadBacklogSummary/loadExecutableItems 挂载时消费同一 Promise)。
|
||||
@@ -24,19 +27,22 @@ import {
|
||||
createTransferMatching,
|
||||
downloadTransferErpInventory,
|
||||
downloadTransferExceptions,
|
||||
downloadTransferReceiptFiles,
|
||||
downloadTransferInboundFiles,
|
||||
executeTransferItems,
|
||||
fetchTransferTypes,
|
||||
getTransferBacklogSummary,
|
||||
getTransferMatching,
|
||||
getTransferRun,
|
||||
listExecutableTransferItems,
|
||||
listTransferBacklog,
|
||||
listPendingMatchRecordsPage,
|
||||
listTransferBacklogPage,
|
||||
listTransferSources,
|
||||
manualCloseTransferItem,
|
||||
retryTransferItem,
|
||||
retryTransferSourceRpa,
|
||||
retryTransferSourcesRpaBatch,
|
||||
} from '../api/transfer.api';
|
||||
import type { TransferBacklogPageQuery } from '../api/transfer.api';
|
||||
import type {
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
@@ -44,10 +50,12 @@ import type {
|
||||
TransferMatchingDetail,
|
||||
TransferMatchingItem,
|
||||
TransferMatchingSummary,
|
||||
TransferPendingMatchRecord,
|
||||
TransferRunResult,
|
||||
TransferSourceOption,
|
||||
TransferSourceProgress,
|
||||
TransferType,
|
||||
TransferTypeOption,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
/** Run 轮询间隔(ms):D9 融合卡「调拨单清单=进度=结果」按 4s 定时拉取 GET /runs/{run_no} */
|
||||
@@ -73,6 +81,23 @@ const SOURCE_POLL_MAX_CONSECUTIVE_FAILURES = 3;
|
||||
let homeBoardPrefetchSummary: Promise<TransferBacklogSummary> | null = null;
|
||||
let homeBoardPrefetchExecutable: ReturnType<typeof listExecutableTransferItems> | null = null;
|
||||
|
||||
/**
|
||||
* 调拨类型配置拉取(模块级单飞,Task 7 接口化):来源选择卡可能随会话消息多次挂载
|
||||
* (历史回放/刷新),并发调用共享同一在途请求防重复打点;请求落定即清槽
|
||||
* (配置可能被管理员调整,不做长缓存,顺序调用各自现发拿新鲜数据)。
|
||||
*/
|
||||
let transferTypesInFlight: Promise<TransferTypeOption[]> | null = null;
|
||||
|
||||
/** 模块级单飞拉取调拨类型:并发调用共享同一在途 Promise;落定(成功/失败)后清槽。 */
|
||||
function fetchTransferTypesOnce(): Promise<TransferTypeOption[]> {
|
||||
if (!transferTypesInFlight) {
|
||||
transferTypesInFlight = fetchTransferTypes().finally(() => {
|
||||
transferTypesInFlight = null;
|
||||
});
|
||||
}
|
||||
return transferTypesInFlight;
|
||||
}
|
||||
|
||||
/** 提前发起首页看板两请求(幂等:任一槽位在途/未消费时不重复发)。 */
|
||||
export function prefetchTransferHomeBoard(): void {
|
||||
if (homeBoardPrefetchSummary || homeBoardPrefetchExecutable) return;
|
||||
@@ -108,6 +133,9 @@ export function isTerminalRunStatus(status: string | null | undefined): boolean
|
||||
return typeof status === 'string' && TERMINAL_RUN_STATUSES.has(status);
|
||||
}
|
||||
|
||||
/** 调拨列表统一每页行数(待办池/待匹配桶与已执行明细同口径;组件分页条同值引用)。 */
|
||||
export const TRANSFER_PAGE_SIZE = 20;
|
||||
|
||||
export function useChatTransfer() {
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
@@ -119,8 +147,23 @@ export function useChatTransfer() {
|
||||
const run = ref<TransferRunResult | null>(null);
|
||||
const backlog = ref<TransferBacklogItem[]>([]);
|
||||
const backlogSummary = ref<TransferBacklogSummary | null>(null);
|
||||
/** 待处理池服务端分页查询(2026-10-16:组件经 loadBacklog(partial) 更新,
|
||||
* 操作后无参重拉沿用最近查询;total=筛选后全量计数供分页器)。 */
|
||||
const backlogQuery = ref<TransferBacklogPageQuery>({ page: 1, pageSize: TRANSFER_PAGE_SIZE, keyword: '', resultFilter: 'all' });
|
||||
const backlogTotal = ref(0);
|
||||
// 待办池在途请求代数(loadBacklog 竞态守卫:仅最新代响应落地)
|
||||
let backlogLoadGeneration = 0;
|
||||
const executableItems = ref<TransferMatchingItem[]>([]);
|
||||
/** 「待匹配」桶只读清单(D16:已落档尚未匹配的外部入站记录;无 item_id 不可执行)。
|
||||
* 服务端分页(2026-10-16):records=当前页切片,total=桶全量计数。 */
|
||||
const pendingMatchRecords = ref<TransferPendingMatchRecord[]>([]);
|
||||
const pendingMatchTotal = ref(0);
|
||||
const pendingMatchPage = ref(1);
|
||||
const matchableRecords = ref<TransferPendingMatchRecord[]>([]);
|
||||
const matchableTotal = ref(0);
|
||||
const matchablePage = ref(1);
|
||||
const sourceOptions = ref<TransferSourceOption[]>([]);
|
||||
const transferTypes = ref<TransferTypeOption[]>([]);
|
||||
const selected = ref<Set<number>>(new Set());
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
@@ -132,13 +175,13 @@ export function useChatTransfer() {
|
||||
// 轮询连接状态(交互细则 #2:单次失败保留旧值继续轮询,连续失败显示「连接中…」不清空画面)
|
||||
const pollConnecting = ref(false);
|
||||
// 来源状态轮询状态(实例级闭包,generation 语义同 Run 轮询):
|
||||
// 收料 RPA 是异步回调收口(重试 202 后状态先投影 fetching,终态靠后端回调落库),
|
||||
// 入站 RPA 是异步回调收口(重试 202 后状态先投影 fetching,终态靠后端回调落库),
|
||||
// 前端必须轮询 GET /sources 才能把 抓取中→ready/failed 反映到来源选择卡
|
||||
let sourcePollTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let sourcePollGeneration = 0;
|
||||
let sourcePollConsecutiveFailures = 0;
|
||||
|
||||
/** 全部可执行明细行 id(阻断/未成熟/无 item_id 的历史行不可勾选) */
|
||||
/** 全部可执行明细行 id(阻断/无 item_id 的历史行不可勾选) */
|
||||
const executableItemIds = computed(() =>
|
||||
items.value
|
||||
.filter((item) => item.result === 'executable' && item.item_id != null)
|
||||
@@ -148,7 +191,8 @@ export function useChatTransfer() {
|
||||
const selectedCount = computed(() => selected.value.size);
|
||||
const estimatedQuantity = computed(() => matching.value?.estimated_transfer_quantity ?? '0');
|
||||
|
||||
/** 创建匹配(缺文件时来源级阶段展示等待/失败);transferType 决定收料数据范围,缺省在途仓至HUB仓 */
|
||||
/** 创建匹配(缺文件时来源级阶段展示等待/失败);transferType 为所选类型配置 code
|
||||
* (Task 7 接口化,来源选择卡接口选项选定值),决定入站数据范围与字段转换规则。 */
|
||||
async function createMatching(
|
||||
sourceCodes: string[],
|
||||
businessDate?: string,
|
||||
@@ -161,8 +205,8 @@ export function useChatTransfer() {
|
||||
const summary = await createTransferMatching({
|
||||
source_codes: sourceCodes,
|
||||
business_date: businessDate,
|
||||
receipt_date_from: dateRange?.from,
|
||||
receipt_date_to: dateRange?.to,
|
||||
movement_date_from: dateRange?.from,
|
||||
movement_date_to: dateRange?.to,
|
||||
transfer_type: transferType,
|
||||
});
|
||||
matchingId.value = summary.matching_id;
|
||||
@@ -188,7 +232,7 @@ export function useChatTransfer() {
|
||||
matching.value = detail.summary;
|
||||
items.value = detail.items;
|
||||
sources.value = detail.sources;
|
||||
// 默认勾选全部可执行明细行(按 item_id);阻断/未成熟/无 item_id 不可选
|
||||
// 默认勾选全部可执行明细行(按 item_id);阻断/无 item_id 不可选
|
||||
selected.value = new Set(
|
||||
detail.items
|
||||
.filter((item) => item.result === 'executable' && item.item_id != null)
|
||||
@@ -351,11 +395,11 @@ export function useChatTransfer() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 下载收料来源文件(zip) */
|
||||
async function downloadReceiptFiles() {
|
||||
/** 下载出入站来源文件(zip;Task 3 路由更名后端点为 inbound-files) */
|
||||
async function downloadInboundFiles() {
|
||||
if (!runNo.value) return null;
|
||||
const result = await downloadTransferReceiptFiles(runNo.value);
|
||||
saveBlob(result.blob, result.filename ?? `receipt-files-${runNo.value}.zip`);
|
||||
const result = await downloadTransferInboundFiles(runNo.value);
|
||||
saveBlob(result.blob, result.filename ?? `inbound-files-${runNo.value}.zip`);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -375,7 +419,7 @@ export function useChatTransfer() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 加载来源实例列表(决策 3:平台仅分组,每来源附收料文件状态);
|
||||
/** 加载来源实例列表(决策 3:平台仅分组,每来源附入站文件状态);
|
||||
* 载入后按快照同步来源轮询:存在 fetching 来源即自动接管(触发重试后 RPA 异步收口,
|
||||
* 终态 ready/failed 只有重拉 /sources 才可见——否则来源卡永远停在「抓取中」)。 */
|
||||
async function loadSources() {
|
||||
@@ -384,6 +428,18 @@ export function useChatTransfer() {
|
||||
return sourceOptions.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载调拨类型配置(Task 7 接口化:来源选择卡类型选项的唯一数据源)。
|
||||
* 【AI 触发时机】:TransferMessageView 挂载 kind='source-select' 时调用;
|
||||
* 命中模块级单飞则复用在途请求,否则现发 GET /transfer-types 并写入 transferTypes。
|
||||
* 前端不加工不过滤(enabled 过滤/sort_order 排序在后端契约内,选项即接口真相)。
|
||||
*/
|
||||
async function loadTransferTypes() {
|
||||
const types = await fetchTransferTypesOnce();
|
||||
transferTypes.value = types;
|
||||
return types;
|
||||
}
|
||||
|
||||
/**
|
||||
* 停止来源状态轮询(幂等):递增 generation 使在途回调失效并清掉未触发定时器。
|
||||
* 【AI 触发时机】:离开来源选择卡(确认匹配切匹配卡/回放替换 payload)与
|
||||
@@ -422,7 +478,7 @@ export function useChatTransfer() {
|
||||
sourcePollConsecutiveFailures = 0;
|
||||
sourceOptions.value = options;
|
||||
// 直接判服务端快照(不经 syncSourcePolling,防与既有轮询互相顶替)
|
||||
if (!options.some((source) => source.file_status === 'fetching')) {
|
||||
if (!options.some((source) => sourceIsFetching(source))) {
|
||||
stopSourcePolling();
|
||||
return;
|
||||
}
|
||||
@@ -441,39 +497,73 @@ export function useChatTransfer() {
|
||||
scheduleNext();
|
||||
}
|
||||
|
||||
/**
|
||||
* 来源是否还有抓取中的证据流。
|
||||
* 核心逻辑:扁平 file_status 仍是入站投影;streams 里任一条 fetching 也算,出站重试才能轮询收口。
|
||||
* @param source - 来源列表项
|
||||
* @returns 是否应继续轮询
|
||||
*/
|
||||
function sourceIsFetching(source: { file_status?: string; streams?: { file_status: string }[] }): boolean {
|
||||
return source.file_status === 'fetching'
|
||||
|| Boolean(source.streams?.some((stream) => stream.file_status === 'fetching'));
|
||||
}
|
||||
|
||||
/** 按当前来源快照同步轮询启停:有抓取中来源→启动(重复调用先停旧轮),无→停止。 */
|
||||
function syncSourcePolling() {
|
||||
if (sourceOptions.value.some((source) => source.file_status === 'fetching')) {
|
||||
if (sourceOptions.value.some((source) => sourceIsFetching(source))) {
|
||||
startSourcePolling();
|
||||
} else {
|
||||
stopSourcePolling();
|
||||
}
|
||||
}
|
||||
|
||||
/** 对指定来源重试收料,并刷新来源状态(解析失败分层:parse_failed 先本地重解析
|
||||
* 返回 200——ready/parse_failed,无轮询;其余状态仍触发收料 RPA 返回 202 + fetching,
|
||||
* loadSources 观察到 fetching 即自动开始来源轮询,RPA 回调收口后状态自动刷新) */
|
||||
async function retrySourceRpa(sourceCode: string) {
|
||||
const status = await retryTransferSourceRpa(sourceCode);
|
||||
/**
|
||||
* 对指定来源的一条证据流重试,并刷新来源状态。
|
||||
* 核心逻辑:POST retry-rpa,body 带 record_kind。未传种类时 API 缺省 inbound。
|
||||
* parse_failed 入站先本地重解析;其余状态触发对应 RPA。随后 loadSources,
|
||||
* 观察到 fetching(含 streams)即轮询。
|
||||
* @param sourceCode - 来源实例编码
|
||||
* @param recordKind - inbound 或 outbound;来源卡传入括号上的种类,旧调用可不传
|
||||
* @returns 重试响应
|
||||
*/
|
||||
async function retrySourceRpa(sourceCode: string, recordKind: 'inbound' | 'outbound' = 'inbound') {
|
||||
const status = await retryTransferSourceRpa(sourceCode, recordKind);
|
||||
await loadSources();
|
||||
return status;
|
||||
}
|
||||
|
||||
/** 批量来源重试:一次批量端点调用(多来源合并单 batch trigger,Worker 单次浏览器
|
||||
* 会话串行导出;逐来源循环会产生 N 个文件、开/关 N 次浏览器),随后刷新来源状态
|
||||
* (loadSources 观察到 fetching 自动开始轮询)。 */
|
||||
async function retrySourcesRpaBatch(sourceCodes: string[]) {
|
||||
const result = await retryTransferSourcesRpaBatch(sourceCodes);
|
||||
/**
|
||||
* 批量重试所选来源。
|
||||
* 核心逻辑:一次 POST retry-rpa-batch。带来源类型时 body 含 transfer_type,
|
||||
* 后端按该类型的证据流分组;不传类型时保持整批入站。随后刷新来源状态。
|
||||
* @param sourceCodes - 来源编码列表
|
||||
* @param transferType - 当前调拨类型 code;来源卡批量按钮传入
|
||||
* @returns 批量触发结果
|
||||
*/
|
||||
async function retrySourcesRpaBatch(sourceCodes: string[], transferType?: string) {
|
||||
const result = await retryTransferSourcesRpaBatch(sourceCodes, transferType);
|
||||
await loadSources();
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 加载待处理异常列表与汇总 */
|
||||
async function loadBacklog() {
|
||||
const [items, summary] = await Promise.all([listTransferBacklog(), getTransferBacklogSummary()]);
|
||||
backlog.value = items;
|
||||
/**
|
||||
* 加载待处理池(服务端分页 + 筛选下推)与汇总。
|
||||
* 传 partial query(page/keyword/resultFilter)即合并进实例查询态;
|
||||
* 无参调用(操作后刷新/挂载兜底)沿用最近查询,页码与筛选不跳变。
|
||||
* generation 守卫:快速翻页/防抖并发下仅最新在途响应落地(防旧页覆盖新页)。
|
||||
*/
|
||||
async function loadBacklog(query?: Partial<TransferBacklogPageQuery>) {
|
||||
if (query) backlogQuery.value = { ...backlogQuery.value, ...query };
|
||||
const generation = ++backlogLoadGeneration;
|
||||
const [pageData, summary] = await Promise.all([
|
||||
listTransferBacklogPage(backlogQuery.value),
|
||||
getTransferBacklogSummary(),
|
||||
]);
|
||||
if (generation !== backlogLoadGeneration) return { items: [], summary };
|
||||
backlog.value = pageData.items;
|
||||
backlogTotal.value = pageData.total;
|
||||
backlogSummary.value = summary;
|
||||
return { items, summary };
|
||||
return { items: pageData.items, summary };
|
||||
}
|
||||
|
||||
/** 首页看板计数(仅汇总,不拉全量列表——列表延迟到切片子视图加载);
|
||||
@@ -495,14 +585,47 @@ export function useChatTransfer() {
|
||||
return executableItems.value;
|
||||
}
|
||||
|
||||
/** 批量重查库存(单行隔离,结果由调用方刷新列表后展示) */
|
||||
async function batchRequery(itemIds: number[]): Promise<TransferBatchResult> {
|
||||
return batchRequeryTransferItems(itemIds);
|
||||
/**
|
||||
* 加载待匹配清单。无 segment 时同时拉「当前可匹配」和「其余已落档」;
|
||||
* 传 segment 只刷新那一段,翻页不带动另一段。
|
||||
* @param query.page - 目标段的页码;不传则沿用该段最近页
|
||||
* @param query.segment - matchable 或 outside;缺省两段都拉
|
||||
* @returns 其余已落档的当前页;只刷新可匹配段时返回该段当前页
|
||||
*/
|
||||
async function loadPendingMatchRecords(query?: { page?: number; segment?: 'matchable' | 'outside' }) {
|
||||
const loadSegment = async (segment: 'matchable' | 'outside', page: number) =>
|
||||
listPendingMatchRecordsPage({ page, pageSize: TRANSFER_PAGE_SIZE, segment });
|
||||
if (query?.segment === 'matchable') {
|
||||
if (query.page) matchablePage.value = query.page;
|
||||
const data = await loadSegment('matchable', matchablePage.value);
|
||||
matchableRecords.value = data.records;
|
||||
matchableTotal.value = data.total;
|
||||
return matchableRecords.value;
|
||||
}
|
||||
if (query?.segment === 'outside') {
|
||||
if (query.page) pendingMatchPage.value = query.page;
|
||||
const data = await loadSegment('outside', pendingMatchPage.value);
|
||||
pendingMatchRecords.value = data.records;
|
||||
pendingMatchTotal.value = data.total;
|
||||
return pendingMatchRecords.value;
|
||||
}
|
||||
if (query?.page) {
|
||||
matchablePage.value = query.page;
|
||||
pendingMatchPage.value = query.page;
|
||||
}
|
||||
const [matchable, outside] = await Promise.all([
|
||||
loadSegment('matchable', matchablePage.value),
|
||||
loadSegment('outside', pendingMatchPage.value),
|
||||
]);
|
||||
matchableRecords.value = matchable.records;
|
||||
matchableTotal.value = matchable.total;
|
||||
pendingMatchRecords.value = outside.records;
|
||||
pendingMatchTotal.value = outside.total;
|
||||
return pendingMatchRecords.value;
|
||||
}
|
||||
|
||||
/** 恢复处理(行级/多选):恢复语义 = 按明细 id 重查库存(batch-requery 唯一后端);
|
||||
* 返回批量结果,由视图统计 recovered(status=ready_to_execute)与仍阻断数。 */
|
||||
async function resume(itemIds: number[]): Promise<TransferBatchResult> {
|
||||
/** 批量重查库存(单行隔离,结果由调用方刷新列表后展示) */
|
||||
async function batchRequery(itemIds: number[]): Promise<TransferBatchResult> {
|
||||
return batchRequeryTransferItems(itemIds);
|
||||
}
|
||||
|
||||
@@ -532,7 +655,12 @@ export function useChatTransfer() {
|
||||
backlog.value = [];
|
||||
backlogSummary.value = null;
|
||||
executableItems.value = [];
|
||||
pendingMatchRecords.value = [];
|
||||
pendingMatchTotal.value = 0;
|
||||
matchableRecords.value = [];
|
||||
matchableTotal.value = 0;
|
||||
sourceOptions.value = [];
|
||||
transferTypes.value = [];
|
||||
selected.value = new Set();
|
||||
error.value = '';
|
||||
}
|
||||
@@ -547,8 +675,14 @@ export function useChatTransfer() {
|
||||
pollConnecting,
|
||||
backlog,
|
||||
backlogSummary,
|
||||
backlogTotal,
|
||||
executableItems,
|
||||
pendingMatchRecords,
|
||||
pendingMatchTotal,
|
||||
matchableRecords,
|
||||
matchableTotal,
|
||||
sourceOptions,
|
||||
transferTypes,
|
||||
selected,
|
||||
selectedCount,
|
||||
executableItemIds,
|
||||
@@ -568,15 +702,16 @@ export function useChatTransfer() {
|
||||
retry,
|
||||
manualClose,
|
||||
loadSources,
|
||||
loadTransferTypes,
|
||||
retrySourceRpa,
|
||||
retrySourcesRpaBatch,
|
||||
loadBacklog,
|
||||
loadBacklogSummary,
|
||||
loadExecutableItems,
|
||||
loadPendingMatchRecords,
|
||||
batchRequery,
|
||||
resume,
|
||||
batchManualClose,
|
||||
downloadReceiptFiles,
|
||||
downloadInboundFiles,
|
||||
downloadErpInventory,
|
||||
downloadExceptions,
|
||||
reset,
|
||||
|
||||
@@ -15,7 +15,7 @@ const api = vi.hoisted(() => ({
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferInboundFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
}));
|
||||
@@ -30,9 +30,8 @@ const detail: TransferMatchingDetail = {
|
||||
matching_id: 'MTG-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, matched_count: 2, executable_count: 2, blocked_count: 0 },
|
||||
counts: { file_invoice_count: 3, matched_count: 3, executable_count: 2, blocked_count: 1 },
|
||||
estimated_transfer_quantity: '2400',
|
||||
estimated_external_write_count: 2,
|
||||
matching_hash: 'sha256:abc',
|
||||
@@ -41,7 +40,7 @@ const detail: TransferMatchingDetail = {
|
||||
items: [
|
||||
{ item_id: 11, 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' },
|
||||
{ item_id: 12, 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' },
|
||||
{ item_id: 13, 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' },
|
||||
{ item_id: 13, 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: 'blocked_quantity_mismatch' },
|
||||
],
|
||||
};
|
||||
|
||||
@@ -72,14 +71,14 @@ describe('in-transit-transfer e2e contract', () => {
|
||||
api.getTransferMatching.mockResolvedValue(detail);
|
||||
api.executeTransferItems.mockResolvedValue({ run_no: 'RUN-20260806-001', status: 'success' });
|
||||
api.getTransferRun.mockResolvedValue(runResult);
|
||||
api.downloadTransferReceiptFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: 'receipt-files.zip' });
|
||||
api.downloadTransferInboundFiles.mockResolvedValue({ blob: new Blob(['zip']), filename: 'inbound-files.zip' });
|
||||
api.downloadTransferErpInventory.mockResolvedValue({ blob: new Blob(['csv']), filename: 'erp.csv' });
|
||||
});
|
||||
|
||||
it('主路径:匹配 → 只选 item 11 → 按明细行生成调拨单 → 结果按 ERP 单号聚合', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createMatching(['DBS-AWSBI', 'DBS-AWSSG'], '2026-08-06');
|
||||
// 未成熟项默认不勾选
|
||||
// 阻断项默认不勾选
|
||||
expect(transfer.selected.value.has(13)).toBe(false);
|
||||
// 取消 item 12,只执行 item 11
|
||||
transfer.toggleSelect(12, false);
|
||||
@@ -96,12 +95,12 @@ describe('in-transit-transfer e2e contract', () => {
|
||||
expect(transfer.run.value?.result.external_documents[0].material_count).toBe(2);
|
||||
});
|
||||
|
||||
it('下载:收料来源文件与 ERP 库存表(决策 21/22 前端入口)', async () => {
|
||||
it('下载:出入站来源文件与 ERP 库存表(决策 21/22 前端入口)', async () => {
|
||||
const transfer = useChatTransfer();
|
||||
transfer.runNo.value = 'RUN-20260806-001';
|
||||
await transfer.downloadReceiptFiles();
|
||||
await transfer.downloadInboundFiles();
|
||||
await transfer.downloadErpInventory();
|
||||
expect(api.downloadTransferReceiptFiles).toHaveBeenCalledWith('RUN-20260806-001');
|
||||
expect(api.downloadTransferInboundFiles).toHaveBeenCalledWith('RUN-20260806-001');
|
||||
expect(api.downloadTransferErpInventory).toHaveBeenCalledWith('RUN-20260806-001');
|
||||
});
|
||||
|
||||
|
||||
@@ -77,14 +77,14 @@ const createUploadContext = (
|
||||
attachments: ref([]),
|
||||
input: ref(''),
|
||||
shippingAutoFlowRequested: ref(false),
|
||||
shippingInventoryPickerRef: ref({ click: vi.fn() } as unknown as HTMLInputElement),
|
||||
shippingOnhandPickerRef: ref({ click: vi.fn() } as unknown as HTMLInputElement),
|
||||
shippingNoticePickerRef: ref({ click: vi.fn() } as unknown as HTMLInputElement),
|
||||
pendingShippingUploadTaskId: ref(''),
|
||||
pendingShippingNoticeTaskId: ref(''),
|
||||
pendingShippingInventoryFile: ref(null),
|
||||
pendingShippingOnhandFile: ref(null),
|
||||
resolvedShippingTaskId: ref(''),
|
||||
shippingInventorySelectionActive: ref(false),
|
||||
shippingInventorySelectionTaskId: ref(''),
|
||||
shippingOnhandSelectionActive: ref(false),
|
||||
shippingOnhandSelectionTaskId: ref(''),
|
||||
getActiveShippingTaskId: () => '',
|
||||
startChatTurn: vi.fn(async () => true),
|
||||
refreshShippingActions: vi.fn(async () => undefined),
|
||||
|
||||
@@ -244,7 +244,7 @@ describe('useShippingOrderReview historical readonly', () => {
|
||||
it('maps confirmed case to non-closed lifecycle for post-confirm automation', () => {
|
||||
// 关键断言:confirmed 不得映射 closed,否则统一进度轨道会被误判为终态。
|
||||
expect(mapReviewContextLifecycleStatus('confirmed', null)).toBe('building_order');
|
||||
expect(mapReviewContextLifecycleStatus('confirmed', 'inventory_matching')).toBe('inventory_matching');
|
||||
expect(mapReviewContextLifecycleStatus('confirmed', 'onhand_matching')).toBe('onhand_matching');
|
||||
expect(mapReviewContextLifecycleStatus('closed', null)).toBe('closed');
|
||||
expect(mapReviewContextLifecycleStatus('quality_issue', null)).toBe('closed');
|
||||
});
|
||||
@@ -518,7 +518,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
});
|
||||
api.getExtractionRun.mockResolvedValue({ run_no: 'RUN-1', status: 'completed' });
|
||||
api.getProcessingWorkItem.mockResolvedValue({
|
||||
work_item_no: 'OT-1', status: 'processing', stage: 'inventory_preparation',
|
||||
work_item_no: 'OT-1', status: 'processing', stage: 'onhand_preparation',
|
||||
});
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
@@ -1222,8 +1222,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
workItemNo: 'OT-1',
|
||||
status: 'waiting_human',
|
||||
userStatus: 'waiting_human',
|
||||
stage: 'inventory_matching',
|
||||
currentGate: { gateCode: 'inventory_matching', status: 'blocked_manual' },
|
||||
stage: 'onhand_matching',
|
||||
currentGate: { gateCode: 'onhand_matching', status: 'blocked_manual' },
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
@@ -1278,8 +1278,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
api.getProcessingWorkItem.mockResolvedValue({
|
||||
work_item_no: 'OT-1', status: 'processing', stage: 'inventory_preparation',
|
||||
currentGate: { gateCode: 'inventory_preparation', status: 'running' },
|
||||
work_item_no: 'OT-1', status: 'processing', stage: 'onhand_preparation',
|
||||
currentGate: { gateCode: 'onhand_preparation', status: 'running' },
|
||||
});
|
||||
api.confirmCase.mockResolvedValue({
|
||||
task_no: 'SN-1', order_task_no: 'OT-1', shipping_notice_no: 'SN-1', idempotent_replay: false,
|
||||
|
||||
@@ -229,7 +229,7 @@ export function mapReviewContextLifecycleStatus(
|
||||
if (cs === 'closed') return 'closed';
|
||||
// [UI-05] confirmed ? closed
|
||||
if (cs === 'confirmed') {
|
||||
if (['building_order', 'inventory_matching', 'generating_excel'].includes(rs)) return rs;
|
||||
if (['building_order', 'onhand_matching', 'generating_excel'].includes(rs)) return rs;
|
||||
if (['manual_upload_pending', 'upload_rpa_pending', 'upload_rpa_running'].includes(rs)) return rs;
|
||||
return 'building_order';
|
||||
}
|
||||
@@ -240,7 +240,7 @@ export function mapReviewContextLifecycleStatus(
|
||||
if (['layout_parsing', 'waiting_layout'].includes(rs)) return 'layout_parsing';
|
||||
if (['routing', 'matching_profile', 'extracting', 'merging_supplement'].includes(rs)) return 'extracting';
|
||||
if (['review_required', 'partially_completed', 'candidate_ready'].includes(rs)) return 'pending_review';
|
||||
if (['building_order', 'inventory_matching', 'generating_excel'].includes(rs)) return rs;
|
||||
if (['building_order', 'onhand_matching', 'generating_excel'].includes(rs)) return rs;
|
||||
if (['draft', 'ready', 'unreviewed', 'superseded'].includes(cs)) return 'pending_review';
|
||||
return 'pending_review';
|
||||
}
|
||||
|
||||
@@ -296,8 +296,8 @@ export function normalizeLifecycleStatus(
|
||||
const HUMAN_ACTION_CODES = new Set([
|
||||
'confirm_customer', 'resolve_field_conflicts', 'adjudicate_duplicate',
|
||||
'open_order_review', 'open_order_processing', 'enter_manual_review',
|
||||
'open_inventory_match_review', 'rematch', 'match_inventory',
|
||||
'open_shortage_review', 'upload_inventory_file', 'open_manual_upload',
|
||||
'open_onhand_match_review', 'rematch', 'match_inventory',
|
||||
'open_shortage_review', 'upload_onhand_file', 'open_manual_upload',
|
||||
'wait_manual_upload', 'retry', 'retry_parse', 'retry_failed_documents',
|
||||
'retry_failed_attachments', 'open_profile_review',
|
||||
]);
|
||||
@@ -308,7 +308,7 @@ const PROCESSING_LIFECYCLES = new Set([
|
||||
'layout_parsing',
|
||||
'extracting',
|
||||
'building_order',
|
||||
'inventory_matching',
|
||||
'onhand_matching',
|
||||
'generating_excel',
|
||||
'upload_rpa_pending',
|
||||
'upload_rpa_running',
|
||||
@@ -337,7 +337,7 @@ export function mapLifecycleToNodeStatus(
|
||||
status === 'layout_parsing'
|
||||
|| status === 'extracting'
|
||||
|| status === 'building_order'
|
||||
|| status === 'inventory_matching'
|
||||
|| status === 'onhand_matching'
|
||||
|| status === 'generating_excel'
|
||||
) {
|
||||
return 'running';
|
||||
|
||||
@@ -34,15 +34,15 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
process_gate: {
|
||||
execution_no: 'EXE-1',
|
||||
status: 'blocked',
|
||||
current_gate_code: 'inventory_preparation',
|
||||
current_gate_code: 'onhand_preparation',
|
||||
expected_gate_version: 3,
|
||||
current_blocking_gate: {
|
||||
gate_code: 'inventory_preparation',
|
||||
gate_code: 'onhand_preparation',
|
||||
status: 'blocked_manual',
|
||||
evaluation_version: 3,
|
||||
},
|
||||
next_action_code: 'retry_inventory_preparation',
|
||||
allowed_actions: ['retry_inventory_preparation', 'upload_inventory_file'],
|
||||
next_action_code: 'retry_onhand_preparation',
|
||||
allowed_actions: ['retry_onhand_preparation', 'upload_onhand_file'],
|
||||
},
|
||||
available_actions: ['open_review'],
|
||||
ui_state: {
|
||||
@@ -75,9 +75,9 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
expect(normalized!.currentGate?.attemptNo).toBe(1);
|
||||
expect(normalized!.processGate).toMatchObject({
|
||||
execution_no: 'EXE-1',
|
||||
current_gate_code: 'inventory_preparation',
|
||||
current_gate_code: 'onhand_preparation',
|
||||
expected_gate_version: 3,
|
||||
next_action_code: 'retry_inventory_preparation',
|
||||
next_action_code: 'retry_onhand_preparation',
|
||||
});
|
||||
expect(normalized!.sourceSummary.filename).toBe('a.pdf');
|
||||
expect(normalized!.sourceSummary.documentId).toBe(17);
|
||||
@@ -199,7 +199,7 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
submission_no: 'SUB-1',
|
||||
intake_no: 'INT-1',
|
||||
status: 'processing',
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
progress_version: 2,
|
||||
last_activity_at: '2026-08-08T22:00:00',
|
||||
source_summary: {},
|
||||
@@ -259,7 +259,7 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
workItemNo: 'OT-1',
|
||||
workItemType: 'order_task',
|
||||
status: 'waiting_review',
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
userStatus: 'waiting_human',
|
||||
uiState: { status: 'waiting_human', lifecycleStage: 'fulfillment_prep' },
|
||||
})).toBeNull();
|
||||
|
||||
@@ -9,8 +9,8 @@ import type {
|
||||
ConversationProcessingUiState,
|
||||
OrderIntakeSourceType,
|
||||
ProcessGateSummary,
|
||||
ShippingInventoryPerSourceAttempt,
|
||||
ShippingInventoryPreparationSummary,
|
||||
ShippingOnhandPerSourceAttempt,
|
||||
ShippingOnhandPreparationSummary,
|
||||
ShippingOrderTaskSummary,
|
||||
ShippingProcessingBlockingReason,
|
||||
ShippingProcessingFacts,
|
||||
@@ -304,7 +304,7 @@ function normalizeAggregateSummary(
|
||||
* 题4A:规范 inventory_preparation 结构化字段(snake_case → camelCase)。
|
||||
* 注意:只投影当前准备结果;失败后由具体 Gate 动作决定下一步。
|
||||
*/
|
||||
function normalizeInventoryPreparation(raw: unknown): ShippingInventoryPreparationSummary | null {
|
||||
function normalizeInventoryPreparation(raw: unknown): ShippingOnhandPreparationSummary | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const item = raw as Record<string, unknown>;
|
||||
const toStrArr = (value: unknown): string[] => {
|
||||
@@ -322,7 +322,7 @@ function normalizeInventoryPreparation(raw: unknown): ShippingInventoryPreparati
|
||||
const activeAttemptCount = Number(item.active_attempt_count ?? item.activeAttemptCount ?? 0) || 0;
|
||||
const gateAttemptActive = Boolean(item.gate_attempt_active ?? item.gateAttemptActive ?? false);
|
||||
const latestRaw = (item.latest_attempts ?? item.latestAttempts) as Record<string, unknown> | undefined;
|
||||
const latestAttempts: Record<string, ShippingInventoryPerSourceAttempt> = {};
|
||||
const latestAttempts: Record<string, ShippingOnhandPerSourceAttempt> = {};
|
||||
if (latestRaw && typeof latestRaw === 'object') {
|
||||
for (const [key, val] of Object.entries(latestRaw)) {
|
||||
if (!val || typeof val !== 'object') continue;
|
||||
@@ -331,7 +331,7 @@ function normalizeInventoryPreparation(raw: unknown): ShippingInventoryPreparati
|
||||
if (!sourceCode) continue;
|
||||
const attemptNo = Number(row.attempt_no ?? row.attemptNo ?? 0) || 0;
|
||||
const status = String(row.status || '').trim().toLowerCase() || 'unknown';
|
||||
const entry: ShippingInventoryPerSourceAttempt = {
|
||||
const entry: ShippingOnhandPerSourceAttempt = {
|
||||
sourceCode,
|
||||
attemptNo,
|
||||
status,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
downloadWorkspaceShippingExportArchive as requestShippingExportArchive,
|
||||
workspaceShippingNoticeExportUrl,
|
||||
workspaceShippingExportUrl,
|
||||
workspaceShippingInventoryFileUrl,
|
||||
workspaceShippingOnhandFileUrl,
|
||||
workspaceShippingLineInventoryFileUrl,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
@@ -31,8 +31,8 @@ export async function downloadWorkspaceShippingNoticeExcelFile(businessNo: strin
|
||||
* @param taskId - 正式发货任务号,必须来自当前详情快照。
|
||||
* @returns 下载完成后解析并触发浏览器保存。
|
||||
*/
|
||||
export async function downloadWorkspaceShippingInventoryFile(taskId: string): Promise<void> {
|
||||
await downloadWorkspaceShippingFile(workspaceShippingInventoryFileUrl(taskId), `${taskId}-inventory.xlsx`);
|
||||
export async function downloadWorkspaceShippingOnhandFile(taskId: string): Promise<void> {
|
||||
await downloadWorkspaceShippingFile(workspaceShippingOnhandFileUrl(taskId), `${taskId}-inventory.xlsx`);
|
||||
}
|
||||
|
||||
/** 下载某订单行实际匹配的库存快照;后端复核该文件号是否为当前行事实。 */
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
* features/chat/shipping/shippingMapping.ts
|
||||
* 用途:库存列映射消息 payload 读取与字段对齐 Markdown 生成。
|
||||
* 依赖:shippingText.normalizeShippingHeaderForDisplay、chat.types、shipping.types、vue-i18n。
|
||||
* 逻辑:ShippingInventoryMappingMessage 与 useChatShippingMappingForm 读取 mapping 消息数据。
|
||||
* 逻辑:ShippingOnhandMappingFormPayload 与 useChatShippingMappingForm 读取 mapping 消息数据。
|
||||
*/
|
||||
import i18n from '@/i18n';
|
||||
import { normalizeShippingHeaderForDisplay } from './shippingText';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload } from '../types/shipping.types';
|
||||
import type { ShippingOnhandMappingFormPayload } from '../types/shipping.types';
|
||||
|
||||
const tt = (key: string, params?: Record<string, unknown>) =>
|
||||
String(params ? i18n.global.t(key, params) : i18n.global.t(key));
|
||||
@@ -15,24 +15,24 @@ const tt = (key: string, params?: Record<string, unknown>) =>
|
||||
/**
|
||||
* 从 shipping-inventory-mapping 类型消息中提取 taskId、schema_preview 与 form。
|
||||
*/
|
||||
export function getShippingInventoryMappingPayload(chatMsg: ChatMessage): ShippingInventoryMappingFormPayload | null {
|
||||
export function getShippingOnhandMappingPayload(chatMsg: ChatMessage): ShippingOnhandMappingFormPayload | null {
|
||||
if (!chatMsg || chatMsg.type !== 'shipping-inventory-mapping') return null;
|
||||
const payload = chatMsg.payload;
|
||||
if (!payload || typeof payload !== 'object') return null;
|
||||
const taskId = String((payload as ShippingInventoryMappingFormPayload).taskId || '').trim();
|
||||
const schemaPreview = (payload as ShippingInventoryMappingFormPayload).schema_preview;
|
||||
const form = (payload as ShippingInventoryMappingFormPayload).form;
|
||||
const taskId = String((payload as ShippingOnhandMappingFormPayload).taskId || '').trim();
|
||||
const schemaPreview = (payload as ShippingOnhandMappingFormPayload).schema_preview;
|
||||
const form = (payload as ShippingOnhandMappingFormPayload).form;
|
||||
if (!taskId || !schemaPreview || !form) return null;
|
||||
return payload as ShippingInventoryMappingFormPayload;
|
||||
return payload as ShippingOnhandMappingFormPayload;
|
||||
}
|
||||
|
||||
export function hasShippingInventorySampleRows(chatMsg: ChatMessage): boolean {
|
||||
const rows = getShippingInventoryMappingPayload(chatMsg)?.schema_preview?.sample_rows;
|
||||
export function hasShippingOnhandSampleRows(chatMsg: ChatMessage): boolean {
|
||||
const rows = getShippingOnhandMappingPayload(chatMsg)?.schema_preview?.sample_rows;
|
||||
return Array.isArray(rows) && rows.length > 0;
|
||||
}
|
||||
|
||||
export function getShippingInventorySampleRowText(chatMsg: ChatMessage): string {
|
||||
const row = getShippingInventoryMappingPayload(chatMsg)?.schema_preview?.sample_rows?.[0];
|
||||
export function getShippingOnhandSampleRowText(chatMsg: ChatMessage): string {
|
||||
const row = getShippingOnhandMappingPayload(chatMsg)?.schema_preview?.sample_rows?.[0];
|
||||
return Array.isArray(row) ? row.map((cell) => String(cell)).join(' | ') : '';
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
/** 复核/任务台共用的履约四节点 stage 键。 */
|
||||
export const FULFILLMENT_PROGRESS_NODES = [
|
||||
'building_order',
|
||||
'inventory_matching',
|
||||
'onhand_matching',
|
||||
'generating_excel',
|
||||
'freight_uploading',
|
||||
] as const;
|
||||
@@ -116,7 +116,7 @@ export function fulfillmentNodeIndexFromStage(
|
||||
if (st === 'completed' || s === 'completed') return 3;
|
||||
if (s === 'freight_uploading' || st === 'automating') return 3;
|
||||
if (s === 'excel_generating' || s === 'generating_excel') return 2;
|
||||
if (s === 'inventory_matching' || s.startsWith('inventory_')) return 1;
|
||||
if (s === 'onhand_matching' || s.startsWith('inventory_')) return 1;
|
||||
if (
|
||||
s === 'building_order'
|
||||
|| s === 'order_creating'
|
||||
|
||||
@@ -43,7 +43,7 @@ describe('shippingStepper', () => {
|
||||
{ code: 'upload_complete', status: 'pending' },
|
||||
]);
|
||||
const steps = applyShippingProcessingStageToSteps(base, {
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
status: 'running',
|
||||
});
|
||||
expect(steps.map((step) => step.status)).toEqual(['completed', 'completed', 'current', 'pending', 'pending']);
|
||||
|
||||
@@ -86,9 +86,9 @@ const PROCESSING_STAGE_INDEX_MAP: Record<string, number> = {
|
||||
duplicate_checking: 1,
|
||||
waiting_review: 1,
|
||||
order_creating: 1,
|
||||
inventory_source_resolving: 2,
|
||||
inventory_fetching: 2,
|
||||
inventory_matching: 2,
|
||||
onhand_source_resolving: 2,
|
||||
onhand_fetching: 2,
|
||||
onhand_matching: 2,
|
||||
excel_generating: 2,
|
||||
freight_uploading: 3,
|
||||
completed: 4,
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
import { nextTick } from 'vue';
|
||||
import { getWorkspaceShippingTask } from '@/features/chat/api/shipping.api';
|
||||
import { buildShippingApplyMappingTurn } from './shippingTurnActions';
|
||||
import { getShippingInventoryMappingPayload } from './shippingMapping';
|
||||
import { getShippingOnhandMappingPayload } from './shippingMapping';
|
||||
import type { StartChatTurnOptions } from '../types/chat-turn.types';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload } from '../types/shipping.types';
|
||||
import type { ShippingOnhandMappingFormPayload } from '../types/shipping.types';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
export interface ShippingMappingFormContext {
|
||||
messages: Ref<ChatMessage[]>;
|
||||
chatScrollContainer: Ref<HTMLElement | null>;
|
||||
shippingInventorySchemaPreviewCache: Ref<Record<string, unknown>>;
|
||||
shippingInventoryPickerRef: Ref<HTMLInputElement | null>;
|
||||
shippingOnhandSchemaPreviewCache: Ref<Record<string, unknown>>;
|
||||
shippingOnhandPickerRef: Ref<HTMLInputElement | null>;
|
||||
pendingShippingUploadTaskId: Ref<string>;
|
||||
resolvedShippingTaskId: Ref<string>;
|
||||
newLocalMessageId: (prefix: string) => string;
|
||||
@@ -37,7 +37,7 @@ export interface ShippingMappingFormContext {
|
||||
* @returns 打开、应用和重传库存映射表单的处理函数
|
||||
*/
|
||||
export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContext) {
|
||||
const scrollToLastShippingInventoryMapping = async (): Promise<boolean> => {
|
||||
const scrollToLastShippingOnhandMapping = async (): Promise<boolean> => {
|
||||
const container = ctx.chatScrollContainer.value;
|
||||
if (!container) return false;
|
||||
let idx = -1;
|
||||
@@ -56,22 +56,22 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
return true;
|
||||
};
|
||||
|
||||
const openShippingInventoryMappingFormForTask = async (taskId: string): Promise<boolean> => {
|
||||
const openShippingOnhandMappingFormForTask = async (taskId: string): Promise<boolean> => {
|
||||
const id = String(taskId || '').trim().toUpperCase();
|
||||
if (!id) return false;
|
||||
const existingIdx = (() => {
|
||||
for (let i = ctx.messages.value.length - 1; i >= 0; i -= 1) {
|
||||
const chatMsg = ctx.messages.value[i] as ChatMessage;
|
||||
if (chatMsg?.type !== 'shipping-inventory-mapping') continue;
|
||||
const payload = getShippingInventoryMappingPayload(chatMsg);
|
||||
const payload = getShippingOnhandMappingPayload(chatMsg);
|
||||
if (payload?.taskId?.trim().toUpperCase() === id) return i;
|
||||
}
|
||||
return -1;
|
||||
})();
|
||||
if (existingIdx >= 0) {
|
||||
return scrollToLastShippingInventoryMapping();
|
||||
return scrollToLastShippingOnhandMapping();
|
||||
}
|
||||
const schemaPreview = ctx.shippingInventorySchemaPreviewCache.value[id];
|
||||
const schemaPreview = ctx.shippingOnhandSchemaPreviewCache.value[id];
|
||||
if (!schemaPreview || typeof schemaPreview !== 'object') {
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeToast.schemaPreviewMissing'));
|
||||
return false;
|
||||
@@ -101,18 +101,18 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
reservation_id: String(suggested?.reservation_id || '').trim(),
|
||||
},
|
||||
applying: false,
|
||||
} as ShippingInventoryMappingFormPayload,
|
||||
} as ShippingOnhandMappingFormPayload,
|
||||
local_id: ctx.newLocalMessageId('shipping-assistant'),
|
||||
local_only: true,
|
||||
};
|
||||
ctx.messages.value.push(mappingMsg);
|
||||
await ctx.saveLocalMessageToBackend(mappingMsg);
|
||||
await scrollToLastShippingInventoryMapping();
|
||||
await scrollToLastShippingOnhandMapping();
|
||||
return true;
|
||||
};
|
||||
|
||||
const applyShippingInventoryMappingForm = async (msgObj: ChatMessage) => {
|
||||
const payload = getShippingInventoryMappingPayload(msgObj);
|
||||
const applyShippingOnhandMappingForm = async (msgObj: ChatMessage) => {
|
||||
const payload = getShippingOnhandMappingPayload(msgObj);
|
||||
if (!payload) return;
|
||||
if (payload.applying) return;
|
||||
const taskId = String(payload.taskId || '').trim();
|
||||
@@ -159,18 +159,18 @@ export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContex
|
||||
}
|
||||
};
|
||||
|
||||
const reuploadShippingInventoryFromMappingForm = (msgObj: ChatMessage) => {
|
||||
const payload = getShippingInventoryMappingPayload(msgObj);
|
||||
const reuploadShippingOnhandFromMappingForm = (msgObj: ChatMessage) => {
|
||||
const payload = getShippingOnhandMappingPayload(msgObj);
|
||||
if (!payload) return;
|
||||
const taskId = String(payload.taskId || '').trim();
|
||||
if (!taskId) return;
|
||||
ctx.pendingShippingUploadTaskId.value = taskId;
|
||||
ctx.shippingInventoryPickerRef.value?.click();
|
||||
ctx.shippingOnhandPickerRef.value?.click();
|
||||
};
|
||||
|
||||
return {
|
||||
openShippingInventoryMappingFormForTask,
|
||||
applyShippingInventoryMappingForm,
|
||||
reuploadShippingInventoryFromMappingForm,
|
||||
openShippingOnhandMappingFormForTask,
|
||||
applyShippingOnhandMappingForm,
|
||||
reuploadShippingOnhandFromMappingForm,
|
||||
};
|
||||
}
|
||||
@@ -24,7 +24,7 @@ const createContext = (
|
||||
getActiveShippingTaskId: () => 'SN-ACTIVE-001',
|
||||
messages: ref([]),
|
||||
sendShippingMenuMessage: vi.fn(async () => undefined),
|
||||
openShippingInventoryPicker: vi.fn((_taskId?: string) => true),
|
||||
openShippingOnhandPicker: vi.fn((_taskId?: string) => true),
|
||||
openShippingNoticePicker: vi.fn((_taskId?: string) => true),
|
||||
executeShippingDecision: vi.fn(async () => true),
|
||||
executeShippingManualUpload: vi.fn(async () => true),
|
||||
@@ -103,12 +103,12 @@ describe('useChatShippingMenuHandler', () => {
|
||||
const { handleShippingMenuAction } = createShippingMenuHandlers(ctx);
|
||||
|
||||
await handleShippingMenuAction(
|
||||
{ id: 'upload_inventory_file', label: '上传库存文件', message: '请上传库存文件' },
|
||||
{ id: 'upload_onhand_file', label: '上传库存文件', message: '请上传库存文件' },
|
||||
undefined,
|
||||
{ taskId: 'sn-picker-123' },
|
||||
);
|
||||
|
||||
expect(ctx.openShippingInventoryPicker).toHaveBeenCalledWith('SN-PICKER-123');
|
||||
expect(ctx.openShippingOnhandPicker).toHaveBeenCalledWith('SN-PICKER-123');
|
||||
});
|
||||
|
||||
it('passes explicit taskId into notice picker actions', async () => {
|
||||
|
||||
@@ -14,7 +14,7 @@ export interface ShippingMenuHandlerContext {
|
||||
getActiveShippingTaskId: () => string;
|
||||
messages: Ref<ChatMessage[]>;
|
||||
sendShippingMenuMessage: (message: string) => Promise<void>;
|
||||
openShippingInventoryPicker: (taskId?: string) => boolean;
|
||||
openShippingOnhandPicker: (taskId?: string) => boolean;
|
||||
openShippingNoticePicker: (taskId?: string) => boolean;
|
||||
openShippingCustomerDialog: (taskId: string) => Promise<void>;
|
||||
executeShippingDecision: (
|
||||
@@ -77,8 +77,8 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
ctx.openShippingNoticePicker(resolveTaskId());
|
||||
return;
|
||||
}
|
||||
if (action.id === 'upload_inventory_file') {
|
||||
ctx.openShippingInventoryPicker(resolveTaskId());
|
||||
if (action.id === 'upload_onhand_file') {
|
||||
ctx.openShippingOnhandPicker(resolveTaskId());
|
||||
return;
|
||||
}
|
||||
if (action.id && [
|
||||
|
||||
@@ -30,7 +30,7 @@ const createContext = (
|
||||
loadHistory: vi.fn(async () => undefined),
|
||||
sendShippingMenuMessage: vi.fn(async () => undefined),
|
||||
startChatTurn: vi.fn(async () => true),
|
||||
openShippingInventoryPicker: vi.fn(() => true),
|
||||
openShippingOnhandPicker: vi.fn(() => true),
|
||||
executeShippingDecision: vi.fn(async () => true),
|
||||
executeShippingManualUpload: vi.fn(async () => true),
|
||||
handleShippingMenuAction: vi.fn(async () => undefined),
|
||||
|
||||
@@ -39,14 +39,14 @@ const createContext = (
|
||||
attachments: ref([]),
|
||||
input: ref(''),
|
||||
shippingAutoFlowRequested: ref(false),
|
||||
shippingInventoryPickerRef: ref({ click: vi.fn() } as unknown as HTMLInputElement),
|
||||
shippingOnhandPickerRef: ref({ click: vi.fn() } as unknown as HTMLInputElement),
|
||||
shippingNoticePickerRef: ref({ click: vi.fn() } as unknown as HTMLInputElement),
|
||||
pendingShippingUploadTaskId: ref(''),
|
||||
pendingShippingNoticeTaskId: ref(''),
|
||||
pendingShippingInventoryFile: ref(null),
|
||||
pendingShippingOnhandFile: ref(null),
|
||||
resolvedShippingTaskId: ref(''),
|
||||
shippingInventorySelectionActive: ref(false),
|
||||
shippingInventorySelectionTaskId: ref(''),
|
||||
shippingOnhandSelectionActive: ref(false),
|
||||
shippingOnhandSelectionTaskId: ref(''),
|
||||
getActiveShippingTaskId: () => 'SN-ACTIVE-001',
|
||||
startChatTurn: vi.fn(async () => true),
|
||||
refreshShippingActions: vi.fn(async () => undefined),
|
||||
@@ -100,11 +100,11 @@ describe('useChatShippingUploadHandler', () => {
|
||||
it('opens inventory picker for explicit taskId instead of current active task', () => {
|
||||
const inventoryClick = vi.fn();
|
||||
const ctx = createContext({
|
||||
shippingInventoryPickerRef: ref({ click: inventoryClick } as unknown as HTMLInputElement),
|
||||
shippingOnhandPickerRef: ref({ click: inventoryClick } as unknown as HTMLInputElement),
|
||||
});
|
||||
const { openShippingInventoryPicker } = createShippingUploadHandlers(ctx);
|
||||
const { openShippingOnhandPicker } = createShippingUploadHandlers(ctx);
|
||||
|
||||
const ok = openShippingInventoryPicker('sn-target-100');
|
||||
const ok = openShippingOnhandPicker('sn-target-100');
|
||||
|
||||
expect(ok).toBe(true);
|
||||
expect(ctx.pendingShippingUploadTaskId.value).toBe('SN-TARGET-100');
|
||||
@@ -113,11 +113,11 @@ describe('useChatShippingUploadHandler', () => {
|
||||
|
||||
it('uploads a task-selected inventory file through the formal task Chat Turn, not the temporary path', async () => {
|
||||
const ctx = createContext({ pendingShippingUploadTaskId: ref('SN-TASK-001') });
|
||||
const { handleShippingInventorySelected } = createShippingUploadHandlers(ctx);
|
||||
const { handleShippingOnhandSelected } = createShippingUploadHandlers(ctx);
|
||||
const file = new File(['inventory'], 'task-inventory.xls', { type: 'application/vnd.ms-excel' });
|
||||
const event = { target: { files: [file], value: 'chosen' } } as unknown as Event;
|
||||
|
||||
await handleShippingInventorySelected(event);
|
||||
await handleShippingOnhandSelected(event);
|
||||
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(expect.objectContaining({
|
||||
actionType: 'shipping.upload_inventory',
|
||||
|
||||
@@ -35,14 +35,14 @@ export interface ShippingUploadHandlerContext {
|
||||
attachments: Ref<PendingAttachment[]>;
|
||||
input: Ref<string>;
|
||||
shippingAutoFlowRequested: Ref<boolean>;
|
||||
shippingInventoryPickerRef: Ref<HTMLInputElement | null>;
|
||||
shippingOnhandPickerRef: Ref<HTMLInputElement | null>;
|
||||
shippingNoticePickerRef: Ref<HTMLInputElement | null>;
|
||||
pendingShippingUploadTaskId: Ref<string>;
|
||||
pendingShippingNoticeTaskId: Ref<string>;
|
||||
pendingShippingInventoryFile: Ref<File | null>;
|
||||
pendingShippingOnhandFile: Ref<File | null>;
|
||||
resolvedShippingTaskId: Ref<string>;
|
||||
shippingInventorySelectionActive: Ref<boolean>;
|
||||
shippingInventorySelectionTaskId: Ref<string>;
|
||||
shippingOnhandSelectionActive: Ref<boolean>;
|
||||
shippingOnhandSelectionTaskId: Ref<string>;
|
||||
getActiveShippingTaskId: () => string;
|
||||
startChatTurn: (options: StartChatTurnOptions) => Promise<boolean>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
@@ -72,8 +72,8 @@ export interface ShippingUploadHandlerContext {
|
||||
*/
|
||||
export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext) {
|
||||
const resetInventoryTaskSelection = () => {
|
||||
ctx.shippingInventorySelectionActive.value = false;
|
||||
ctx.shippingInventorySelectionTaskId.value = '';
|
||||
ctx.shippingOnhandSelectionActive.value = false;
|
||||
ctx.shippingOnhandSelectionTaskId.value = '';
|
||||
};
|
||||
|
||||
const runInventoryUploadChatTurn = async (taskId: string, file: File) => {
|
||||
@@ -93,7 +93,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!ok) ctx.msg.warning(ctx.t('chat.shippingInventoryUploadFailed'));
|
||||
if (!ok) ctx.msg.warning(ctx.t('chat.shippingOnhandUploadFailed'));
|
||||
return ok;
|
||||
};
|
||||
|
||||
@@ -102,34 +102,34 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
await runInventoryUploadChatTurn(taskId, file);
|
||||
};
|
||||
|
||||
const selectShippingInventoryUploadTask = (taskId: string): boolean => {
|
||||
const selectShippingOnhandUploadTask = (taskId: string): boolean => {
|
||||
const normalizedTaskId = String(taskId || '').trim().toUpperCase();
|
||||
if (!normalizedTaskId) {
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeMissingTaskId'));
|
||||
return false;
|
||||
}
|
||||
ctx.resolvedShippingTaskId.value = normalizedTaskId;
|
||||
ctx.shippingInventorySelectionTaskId.value = normalizedTaskId;
|
||||
ctx.shippingOnhandSelectionTaskId.value = normalizedTaskId;
|
||||
ctx.pendingShippingUploadTaskId.value = normalizedTaskId;
|
||||
ctx.shippingInventorySelectionActive.value = false;
|
||||
ctx.shippingOnhandSelectionActive.value = false;
|
||||
|
||||
const pendingFile = ctx.pendingShippingInventoryFile.value;
|
||||
const pendingFile = ctx.pendingShippingOnhandFile.value;
|
||||
if (pendingFile) {
|
||||
ctx.pendingShippingInventoryFile.value = null;
|
||||
ctx.pendingShippingOnhandFile.value = null;
|
||||
ctx.pendingShippingUploadTaskId.value = '';
|
||||
void uploadInventoryForTask(normalizedTaskId, pendingFile).catch((e: unknown) => {
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingInventoryUploadFailed');
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingOnhandUploadFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
ctx.shippingInventoryPickerRef.value?.click();
|
||||
ctx.shippingOnhandPickerRef.value?.click();
|
||||
return true;
|
||||
};
|
||||
|
||||
const cancelShippingInventoryTaskSelection = () => {
|
||||
ctx.pendingShippingInventoryFile.value = null;
|
||||
const cancelShippingOnhandTaskSelection = () => {
|
||||
ctx.pendingShippingOnhandFile.value = null;
|
||||
ctx.pendingShippingUploadTaskId.value = '';
|
||||
resetInventoryTaskSelection();
|
||||
};
|
||||
@@ -258,13 +258,13 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
await runNoticeBatchChatTurn(noticeFiles);
|
||||
};
|
||||
|
||||
const openShippingInventoryPicker = (taskId?: string): boolean => {
|
||||
const openShippingOnhandPicker = (taskId?: string): boolean => {
|
||||
const resolvedTaskId = String(taskId || ctx.getActiveShippingTaskId() || '').trim().toUpperCase();
|
||||
if (!resolvedTaskId) {
|
||||
ctx.msg.warning(ctx.t('chat.shippingNoticeMissingTaskId'));
|
||||
return false;
|
||||
}
|
||||
return selectShippingInventoryUploadTask(resolvedTaskId);
|
||||
return selectShippingOnhandUploadTask(resolvedTaskId);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -284,23 +284,23 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
return true;
|
||||
};
|
||||
|
||||
const handleShippingInventorySelected = async (event: Event) => {
|
||||
const handleShippingOnhandSelected = async (event: Event) => {
|
||||
const fileInput = event.target as HTMLInputElement;
|
||||
const file = fileInput.files?.[0];
|
||||
fileInput.value = '';
|
||||
const taskId = ctx.pendingShippingUploadTaskId.value;
|
||||
ctx.pendingShippingUploadTaskId.value = '';
|
||||
if (!file || !taskId) {
|
||||
ctx.shippingInventorySelectionTaskId.value = '';
|
||||
ctx.shippingOnhandSelectionTaskId.value = '';
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await uploadInventoryForTask(taskId, file);
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingInventoryUploadFailed');
|
||||
const errorMessage = e instanceof Error ? e.message : ctx.t('chat.shippingOnhandUploadFailed');
|
||||
ctx.msg.warning(errorMessage);
|
||||
} finally {
|
||||
ctx.shippingInventorySelectionTaskId.value = '';
|
||||
ctx.shippingOnhandSelectionTaskId.value = '';
|
||||
}
|
||||
};
|
||||
|
||||
@@ -325,11 +325,11 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
return {
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
openShippingInventoryPicker,
|
||||
openShippingOnhandPicker,
|
||||
openShippingNoticePicker,
|
||||
selectShippingInventoryUploadTask,
|
||||
cancelShippingInventoryTaskSelection,
|
||||
handleShippingInventorySelected,
|
||||
selectShippingOnhandUploadTask,
|
||||
cancelShippingOnhandTaskSelection,
|
||||
handleShippingOnhandSelected,
|
||||
shippingSuggestedPrompt,
|
||||
useShippingSuggestedPrompt,
|
||||
isShippingNoticeBatchSubmitting,
|
||||
|
||||
@@ -35,7 +35,7 @@ describe('useShippingProcessingWorkItem', () => {
|
||||
workItemNo: 'OT-20260905-DAC55F90',
|
||||
sourceType: 'eml',
|
||||
status: 'waiting_review',
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
progressVersion: 24,
|
||||
lastActivityAt: '2026-09-05T11:25:45Z',
|
||||
submissionNo: 'SOS-1',
|
||||
@@ -43,11 +43,11 @@ describe('useShippingProcessingWorkItem', () => {
|
||||
userStatus: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [],
|
||||
blocking_reason: { code: 'inventory_shortage_review_required' },
|
||||
primary_action: { code: 'retry_inventory_matching' },
|
||||
primary_action: { code: 'retry_onhand_matching' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
sourceSummary: {
|
||||
@@ -87,7 +87,7 @@ describe('useShippingProcessingWorkItem', () => {
|
||||
expect(api!.projection.value?.workItemNo).toBe('OT-20260905-DAC55F90');
|
||||
expect(api!.projection.value?.userStatus).toBe('waiting_human');
|
||||
expect(api!.projection.value?.uiState?.lifecycleStage).toBe('fulfillment_prep');
|
||||
expect(api!.projection.value?.uiState?.primary_action?.code).toBe('retry_inventory_matching');
|
||||
expect(api!.projection.value?.uiState?.primary_action?.code).toBe('retry_onhand_matching');
|
||||
expect(api!.error.value).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -50,11 +50,11 @@ export type ShippingProcessingStage =
|
||||
| 'candidate_creating'
|
||||
| 'customer_resolving'
|
||||
| 'duplicate_checking'
|
||||
| 'inventory_source_resolving'
|
||||
| 'onhand_source_resolving'
|
||||
| 'waiting_review'
|
||||
| 'order_creating'
|
||||
| 'inventory_fetching'
|
||||
| 'inventory_matching'
|
||||
| 'onhand_fetching'
|
||||
| 'onhand_matching'
|
||||
| 'excel_generating'
|
||||
| 'freight_uploading'
|
||||
| 'completed';
|
||||
@@ -86,12 +86,12 @@ export type ShippingProcessingActionIntent =
|
||||
| 'confirm_customer'
|
||||
| 'resolve_field_conflicts'
|
||||
| 'adjudicate_duplicate'
|
||||
| 'open_inventory_match_review'
|
||||
| 'open_onhand_match_review'
|
||||
| 'open_shortage_review'
|
||||
| 'upload_inventory_file'
|
||||
| 'reload_inventory_result'
|
||||
| 'retry_inventory_preparation'
|
||||
| 'retry_inventory_matching'
|
||||
| 'upload_onhand_file'
|
||||
| 'reload_onhand_result'
|
||||
| 'retry_onhand_preparation'
|
||||
| 'retry_onhand_matching'
|
||||
| 'retry_parse'
|
||||
| 'retry_failed_documents'
|
||||
| 'retry_failed_attachments'
|
||||
@@ -106,8 +106,8 @@ export type ShippingProcessingActionIntent =
|
||||
| 'retry_with_latest_rules'
|
||||
| 'recheck_freeze_readiness'
|
||||
| 'retry_task_creation'
|
||||
| 'retry_inventory_field_mapping'
|
||||
| 'recheck_inventory_sufficiency'
|
||||
| 'retry_onhand_field_mapping'
|
||||
| 'recheck_onhand_sufficiency'
|
||||
| 'recheck_excel_readiness'
|
||||
| 'retry_stp_auto_create'
|
||||
| 'reparse'
|
||||
@@ -128,11 +128,11 @@ export const SHIPPING_PROCESSING_STAGES: readonly ShippingProcessingStage[] = [
|
||||
'candidate_creating',
|
||||
'customer_resolving',
|
||||
'duplicate_checking',
|
||||
'inventory_source_resolving',
|
||||
'onhand_source_resolving',
|
||||
'waiting_review',
|
||||
'order_creating',
|
||||
'inventory_fetching',
|
||||
'inventory_matching',
|
||||
'onhand_fetching',
|
||||
'onhand_matching',
|
||||
'excel_generating',
|
||||
'freight_uploading',
|
||||
'completed',
|
||||
@@ -252,7 +252,7 @@ export interface ShippingProcessingFacts {
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryCandidateSetSummary {
|
||||
export interface ShippingOnhandCandidateSetSummary {
|
||||
id: number;
|
||||
version: number;
|
||||
status: 'draft' | 'frozen' | 'superseded' | 'invalidated';
|
||||
@@ -262,7 +262,7 @@ export interface ShippingInventoryCandidateSetSummary {
|
||||
manifestSnapshotSha256?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryCandidateSourceDetail {
|
||||
export interface ShippingOnhandCandidateSourceDetail {
|
||||
id: number;
|
||||
candidateSetId: number;
|
||||
sourceCode: string;
|
||||
@@ -273,7 +273,7 @@ export interface ShippingInventoryCandidateSourceDetail {
|
||||
sourceConfigVersion?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryCandidateLineDetail {
|
||||
export interface ShippingOnhandCandidateLineDetail {
|
||||
candidateLineId: number;
|
||||
candidateSetId: number;
|
||||
lineNo: number;
|
||||
@@ -283,12 +283,12 @@ export interface ShippingInventoryCandidateLineDetail {
|
||||
allowedSourceCodes: string[];
|
||||
}
|
||||
|
||||
export interface ShippingTaskInventoryCandidatesResponse {
|
||||
export interface ShippingTaskOnhandCandidatesResponse {
|
||||
taskNo: string;
|
||||
currentSet: ShippingInventoryCandidateSetSummary | null;
|
||||
sources: ShippingInventoryCandidateSourceDetail[];
|
||||
lines: ShippingInventoryCandidateLineDetail[];
|
||||
history: ShippingInventoryCandidateSetSummary[];
|
||||
currentSet: ShippingOnhandCandidateSetSummary | null;
|
||||
sources: ShippingOnhandCandidateSourceDetail[];
|
||||
lines: ShippingOnhandCandidateLineDetail[];
|
||||
history: ShippingOnhandCandidateSetSummary[];
|
||||
blockingReason?: ShippingProcessingBlockingReason | null;
|
||||
primaryAction?: ShippingProcessingPrimaryAction | null;
|
||||
}
|
||||
@@ -400,15 +400,15 @@ export interface ShippingProcessingProjection {
|
||||
* 权威事实源:summarize_inventory_rpa_latest_attempts();
|
||||
* 前端按钮禁用/重试文案/状态徽章全部直接读本对象,禁止继续拼接旧字段合成 running。
|
||||
*/
|
||||
inventoryPreparation?: ShippingInventoryPreparationSummary | null;
|
||||
inventoryPreparation?: ShippingOnhandPreparationSummary | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 题4A & 7A:逐源 inventory 准备状态(ShippingProcessingProjection.inventoryPreparation)。
|
||||
* 按实际冻结源 required_sources 为基准分类并暴露当前成功、等待和失败事实。
|
||||
*/
|
||||
export interface ShippingInventoryPreparationSummary {
|
||||
/** 实际任务级冻结源(task.task_frozen_inventory_source_codes),顺序以冻结记录为准。 */
|
||||
export interface ShippingOnhandPreparationSummary {
|
||||
/** 实际任务级冻结源(task.task_frozen_onhand_source_codes),顺序以冻结记录为准。 */
|
||||
requiredSources: string[];
|
||||
/** 已就绪:有 prepared 状态 Attempt,且存在有效的 InventoryFile / TaskInventoryLink。 */
|
||||
preparedSources: string[];
|
||||
@@ -424,14 +424,14 @@ export interface ShippingInventoryPreparationSummary {
|
||||
* 按冻结源逐源最近 Attempt 摘要(source_code → 结构化记录)。
|
||||
* 用于 UI tooltip/详情;按钮禁用不直接读本字典,读上面的 required/prepared/pending/failed 集合。
|
||||
*/
|
||||
latestAttempts?: Record<string, ShippingInventoryPerSourceAttempt>;
|
||||
latestAttempts?: Record<string, ShippingOnhandPerSourceAttempt>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 逐源最近一次 Inventory RPA Attempt 摘要(inventoryPreparation.latestAttempts[sourceCode])。
|
||||
* 仅用于 UI 展示;业务判定必须走顶层 *_sources 集合。
|
||||
*/
|
||||
export interface ShippingInventoryPerSourceAttempt {
|
||||
export interface ShippingOnhandPerSourceAttempt {
|
||||
sourceCode: string;
|
||||
attemptNo: number;
|
||||
/** queued | running | consumed | failed | skipped */
|
||||
@@ -795,7 +795,7 @@ export type InventorySourceMethod =
|
||||
| 'rule_evaluation_freeze'
|
||||
| 'legacy_migrated';
|
||||
|
||||
export interface ShippingInventorySourceCandidate {
|
||||
export interface ShippingOnhandSourceCandidate {
|
||||
source_code: string;
|
||||
display_name?: string | null;
|
||||
warehouse_id?: string | null;
|
||||
@@ -804,12 +804,12 @@ export interface ShippingInventorySourceCandidate {
|
||||
matched_by?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventorySourceResolution {
|
||||
export interface ShippingOnhandSourceResolution {
|
||||
status?: InventorySourceStatus | null;
|
||||
method?: InventorySourceMethod | null;
|
||||
reason?: string | null;
|
||||
release_field_values?: Record<string, string>;
|
||||
candidates?: ShippingInventorySourceCandidate[];
|
||||
candidates?: ShippingOnhandSourceCandidate[];
|
||||
destination_candidates?: string[];
|
||||
evidence?: Record<string, unknown>[];
|
||||
conflicts?: string[];
|
||||
@@ -817,7 +817,7 @@ export interface ShippingInventorySourceResolution {
|
||||
routing_fingerprint?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventorySnapshot {
|
||||
export interface ShippingOnhandSnapshot {
|
||||
inventory_file_no?: string | null;
|
||||
source_code?: string | null;
|
||||
warehouse_id?: string | null;
|
||||
@@ -893,7 +893,7 @@ export interface ShippingTaskSummary {
|
||||
};
|
||||
rpa_runtime?: ShippingRpaRuntime | null;
|
||||
rpa_inventory_source?: Record<string, unknown> | null;
|
||||
inventory_source_resolution?: ShippingInventorySourceResolution | null;
|
||||
inventory_source_resolution?: ShippingOnhandSourceResolution | null;
|
||||
destination_code?: string | null;
|
||||
destination_city?: string | null;
|
||||
destination_country?: string | null;
|
||||
@@ -904,7 +904,7 @@ export interface ShippingTaskSummary {
|
||||
inventory_source_method?: InventorySourceMethod | null;
|
||||
inventory_source_config_version?: string | null;
|
||||
inventory_routing_fingerprint?: string | null;
|
||||
inventory_snapshot?: ShippingInventorySnapshot | null;
|
||||
onhand_snapshot?: ShippingOnhandSnapshot | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
ui_state?: ShippingTaskUiState;
|
||||
@@ -1033,13 +1033,13 @@ export type ShippingProcessGateCode =
|
||||
| 'customer_resolution'
|
||||
| 'duplicate_detection'
|
||||
| 'field_conflict_resolution'
|
||||
| 'inventory_source_routing'
|
||||
| 'onhand_source_routing'
|
||||
| 'order_freeze_readiness'
|
||||
| 'task_creation'
|
||||
| 'inventory_preparation'
|
||||
| 'inventory_field_mapping'
|
||||
| 'inventory_matching'
|
||||
| 'inventory_sufficiency'
|
||||
| 'onhand_preparation'
|
||||
| 'onhand_field_mapping'
|
||||
| 'onhand_matching'
|
||||
| 'onhand_sufficiency'
|
||||
| 'excel_readiness'
|
||||
| 'artifact_generation'
|
||||
| 'freight_upload_rpa'
|
||||
@@ -1080,17 +1080,17 @@ export type ShippingProcessGateActionCode =
|
||||
| 'retry_with_latest_rules'
|
||||
| 'recheck_freeze_readiness'
|
||||
| 'retry_task_creation'
|
||||
| 'reload_inventory_result'
|
||||
| 'retry_inventory_preparation'
|
||||
| 'poll_inventory_preparation'
|
||||
| 'upload_inventory_file'
|
||||
| 'retry_inventory_field_mapping'
|
||||
| 'retry_inventory_matching'
|
||||
| 'retry_inventory_from_preparation'
|
||||
| 'retry_inventory_from_field_mapping'
|
||||
| 'retry_inventory_from_matching'
|
||||
| 'open_inventory_match_review'
|
||||
| 'recheck_inventory_sufficiency'
|
||||
| 'reload_onhand_result'
|
||||
| 'retry_onhand_preparation'
|
||||
| 'poll_onhand_preparation'
|
||||
| 'upload_onhand_file'
|
||||
| 'retry_onhand_field_mapping'
|
||||
| 'retry_onhand_matching'
|
||||
| 'retry_onhand_from_preparation'
|
||||
| 'retry_onhand_from_field_mapping'
|
||||
| 'retry_onhand_from_matching'
|
||||
| 'open_onhand_match_review'
|
||||
| 'recheck_onhand_sufficiency'
|
||||
| 'open_shortage_review'
|
||||
| 'recheck_excel_readiness'
|
||||
| 'regenerate_excel_artifact'
|
||||
@@ -1354,7 +1354,7 @@ export interface ShippingTaskDetail extends ShippingTaskSummary {
|
||||
order_snapshot_id?: number | null;
|
||||
order_data_version?: number | null;
|
||||
field_conflicts?: ShippingFieldConflict[] | null;
|
||||
inventory_verifications?: ShippingInventoryVerification[];
|
||||
inventory_verifications?: ShippingOnhandVerification[];
|
||||
export_artifacts?: ShippingExportArtifact[];
|
||||
upload_attempts?: ShippingUploadAttempt[];
|
||||
events: ShippingTaskEvent[];
|
||||
@@ -1685,7 +1685,7 @@ export interface ShippingFreightNoticeGroupsResponse {
|
||||
reason?: 'po_missing' | 'no_business_notice' | string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryUploadResponse {
|
||||
export interface ShippingOnhandUploadResponse {
|
||||
status: string;
|
||||
message?: string;
|
||||
task_id?: string;
|
||||
@@ -1779,20 +1779,20 @@ export interface ShippingNoticeLayoutSummary {
|
||||
unsupported: number;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryVerificationLine {
|
||||
export interface ShippingOnhandVerificationLine {
|
||||
reservation_id: string;
|
||||
required_qty: string;
|
||||
available_qty: string;
|
||||
status: 'available' | 'shortage' | 'invalid' | string;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryVerification {
|
||||
export interface ShippingOnhandVerification {
|
||||
id: number;
|
||||
status: string;
|
||||
inventory_snapshot_id?: number | null;
|
||||
source_config_version?: string | null;
|
||||
created_at?: string | null;
|
||||
lines: ShippingInventoryVerificationLine[];
|
||||
lines: ShippingOnhandVerificationLine[];
|
||||
}
|
||||
|
||||
export interface ShippingExportArtifact {
|
||||
@@ -2413,7 +2413,7 @@ export interface ShippingOrderReviewInventoryMatchedRule {
|
||||
* 库存源单源不可用原因码(unavailable_reasons 的值)。
|
||||
* 与 backend error_explainability_contract.INVENTORY_SOURCE_UNAVAILABLE_REASON_CODES_EMITTED 对齐。
|
||||
*/
|
||||
export type ShippingInventorySourceUnavailableReasonCode =
|
||||
export type ShippingOnhandSourceUnavailableReasonCode =
|
||||
| 'source_not_found'
|
||||
| 'source_disabled'
|
||||
| 'source_runtime_unavailable'
|
||||
@@ -2427,7 +2427,7 @@ export type ShippingInventorySourceUnavailableReasonCode =
|
||||
* 特别区分:no_inventory_source_candidates(规则未命中)≠
|
||||
* inventory_source_unavailable(命中但源不可用)≠ require_manual_review(冲突)。
|
||||
*/
|
||||
export type ShippingInventorySourceLineBlockReasonCode =
|
||||
export type ShippingOnhandSourceLineBlockReasonCode =
|
||||
| 'no_inventory_source_candidates'
|
||||
| 'inventory_source_unavailable'
|
||||
| 'require_manual_review'
|
||||
@@ -2435,7 +2435,7 @@ export type ShippingInventorySourceLineBlockReasonCode =
|
||||
| 'manual_inventory_source_invalid'
|
||||
| 'inventory_source_conflicted'
|
||||
| 'inventory_source_changed'
|
||||
| 'inventory_source_identity_mismatch'
|
||||
| 'onhand_source_identity_mismatch'
|
||||
| string;
|
||||
|
||||
/**
|
||||
@@ -2457,7 +2457,7 @@ export interface ShippingOrderReviewInventoryRuleSuggestion {
|
||||
raw_source_codes?: string[];
|
||||
unavailable_source_codes?: string[];
|
||||
/** 不可用源编码 → 稳定原因码(非文案) */
|
||||
unavailable_reasons?: Record<string, ShippingInventorySourceUnavailableReasonCode>;
|
||||
unavailable_reasons?: Record<string, ShippingOnhandSourceUnavailableReasonCode>;
|
||||
routing_status?: string;
|
||||
rule_versions?: ShippingOrderReviewInventoryRuleVersion[];
|
||||
matched_rule_ids?: number[];
|
||||
@@ -2479,7 +2479,7 @@ export interface ShippingOrderReviewBuildEligibilityLineProjection {
|
||||
/** 规则命中但当前不可用的源 */
|
||||
unavailable_source_codes?: string[];
|
||||
/** 不可用源编码 → 稳定原因码(非文案;前端用 i18n 渲染) */
|
||||
unavailable_reasons?: Record<string, ShippingInventorySourceUnavailableReasonCode>;
|
||||
unavailable_reasons?: Record<string, ShippingOnhandSourceUnavailableReasonCode>;
|
||||
matched_rule_ids?: number[];
|
||||
matched_rules?: ShippingOrderReviewInventoryMatchedRule[];
|
||||
rule_versions?: ShippingOrderReviewInventoryRuleVersion[];
|
||||
@@ -2490,7 +2490,7 @@ export interface ShippingOrderReviewBuildEligibilityLineProjection {
|
||||
rule_source_codes?: string[];
|
||||
routing_status?: string;
|
||||
can_build?: boolean;
|
||||
block_reason?: ShippingInventorySourceLineBlockReasonCode | null;
|
||||
block_reason?: ShippingOnhandSourceLineBlockReasonCode | null;
|
||||
selection_mode?: string;
|
||||
manual_reason?: string;
|
||||
}
|
||||
@@ -2510,7 +2510,7 @@ export interface ShippingOrderReviewBuildEligibilityIssue {
|
||||
raw_rule_source_codes?: string[];
|
||||
message?: string | null;
|
||||
unavailable_source_codes?: string[];
|
||||
unavailable_reasons?: Record<string, ShippingInventorySourceUnavailableReasonCode>;
|
||||
unavailable_reasons?: Record<string, ShippingOnhandSourceUnavailableReasonCode>;
|
||||
explainability?: ShippingExplainabilityReason | null;
|
||||
low_confidence_fields?: Array<{
|
||||
field_code: string;
|
||||
@@ -3134,13 +3134,13 @@ export interface ShippingOrderReviewLineFulfillmentDecision {
|
||||
|
||||
/** 行级履约决定码(与后端 ALLOWED_DECISIONS 对齐)。 */
|
||||
export type ShippingOrderReviewLineFulfillmentDecisionCode =
|
||||
| 'wait_inventory'
|
||||
| 'wait_onhand'
|
||||
| 'fulfill_complete_line_now'
|
||||
| 'close_unfulfillable'
|
||||
| 'reopen'
|
||||
| 'use_new_inventory_file'
|
||||
| 'change_inventory_source'
|
||||
| 'release_inventory_shortage';
|
||||
| 'release_onhand_shortage';
|
||||
|
||||
/** 行级履约与库存缺口投影行(含 OT 匹配事实与 allowed_actions)。 */
|
||||
export interface ShippingOrderReviewLineFulfillmentLine {
|
||||
@@ -3195,7 +3195,7 @@ export interface ShippingOrderReviewLineFulfillmentLine {
|
||||
field_id: string;
|
||||
display_name: string;
|
||||
value?: string | null;
|
||||
value_source?: 'inventory_snapshot' | 'manual_required' | string;
|
||||
value_source?: 'onhand_snapshot' | 'manual_required' | string;
|
||||
requires_manual?: boolean;
|
||||
}>;
|
||||
/** 字段无法受控解析时的稳定错误码;UI 必须隐藏放行入口。 */
|
||||
@@ -3300,7 +3300,7 @@ export type ShippingWorkflowItemLifecycleStatus =
|
||||
| 'layout_parsing'
|
||||
| 'extracting'
|
||||
| 'building_order'
|
||||
| 'inventory_matching'
|
||||
| 'onhand_matching'
|
||||
| 'generating_excel'
|
||||
| 'pending_review'
|
||||
| 'reparse_failed'
|
||||
|
||||
@@ -272,7 +272,7 @@ export interface ShippingActionButton {
|
||||
source_code?: string;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryMappingFormPayload {
|
||||
export interface ShippingOnhandMappingFormPayload {
|
||||
taskId: string;
|
||||
schema_preview: {
|
||||
sample_rows?: unknown[][];
|
||||
|
||||
@@ -3,16 +3,43 @@
|
||||
* 用途:在途仓自动调拨前端 DTO 类型(与后端 /api/in-transit-transfer 契约一致)。
|
||||
* 依赖:无。
|
||||
* 逻辑:卡片/组合式函数只消费这些稳定类型;行状态与后端 13 状态集对齐,
|
||||
* 单(TransferDocument)状态八态与 Run 调拨单清单(orders)对齐后端 Task 11 序列化。
|
||||
* 单(TransferDocument)状态八态与 Run 调拨单清单(orders)对齐后端 Task 11 序列化;
|
||||
* 来源 streams 与调拨类型 record_kinds 决定来源卡画几条证据流括号。
|
||||
*/
|
||||
|
||||
/** 调拨业务类型(与后端 TransferType 枚举一致;类型 2/3 一期占位未开放) */
|
||||
export type TransferType = 'in_transit_to_hub' | 'hub_repair_out' | 'hub_to_hub';
|
||||
/**
|
||||
* 调拨业务类型(Task 7 配置化):code 由管理端调拨类型配置定义,前端不再枚举
|
||||
* 三值字面量(选项=GET /transfer-types 接口真相)。既有调用点(confirm 事件 /
|
||||
* createMatching payload)沿用此别名,值为任意配置 code 字符串。
|
||||
*/
|
||||
export type TransferType = string;
|
||||
|
||||
/** 调拨类型字段转换规则(与后端 field_transforms.TransformRule 对齐;一期仅 lot_no/prefix_replace) */
|
||||
export interface TransferTransformRule {
|
||||
field: string;
|
||||
op: string;
|
||||
source: string;
|
||||
target: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调拨类型选项(GET /transfer-types data 逐项;enabled 过滤与 sort_order 升序由
|
||||
* 后端契约保证,前端原样透传不加工)。record_kinds 由范围规则现场推导,不落库,
|
||||
* 也不回传 scope_rules / warehouse_config / description。
|
||||
*/
|
||||
export interface TransferTypeOption {
|
||||
code: string;
|
||||
/** 多语言名称(zh-CN/zh-TW/en/th…);展示回退链 locale → zh-CN → en → code */
|
||||
names: Record<string, string>;
|
||||
sort_order: number;
|
||||
transform_rules: TransferTransformRule[];
|
||||
/** 当前类型要画的证据流,只含 inbound / outbound,顺序由后端 record_kinds_of 决定 */
|
||||
record_kinds: ('inbound' | 'outbound')[];
|
||||
}
|
||||
|
||||
/** 匹配计数 */
|
||||
export interface TransferMatchingCounts {
|
||||
file_invoice_count: number;
|
||||
not_matured_count: number;
|
||||
matched_count: number;
|
||||
executable_count: number;
|
||||
blocked_count: number;
|
||||
@@ -34,7 +61,6 @@ export interface TransferMatchingSummary {
|
||||
matching_id: string;
|
||||
status: string;
|
||||
business_date: string;
|
||||
eligible_receipt_date_to: string;
|
||||
expires_at: string;
|
||||
counts: TransferMatchingCounts;
|
||||
estimated_transfer_quantity: string;
|
||||
@@ -51,7 +77,10 @@ export interface TransferMatchingItem {
|
||||
material_name: string;
|
||||
specification: string;
|
||||
invoice_no: string;
|
||||
receipt_date?: string | null;
|
||||
/** 档上的外部单号;没有则为空,列表显示占位 */
|
||||
external_doc_no?: string;
|
||||
/** 明细异动日期(Task 3 序列化键更名,明细 movement 语义;旧名见 git 历史) */
|
||||
movement_date?: string | null;
|
||||
from_warehouse: string;
|
||||
from_quantity: string | null;
|
||||
to_warehouse: string;
|
||||
@@ -65,11 +94,13 @@ export interface TransferMatchingItem {
|
||||
checked_at?: string | null;
|
||||
/** 匹配新鲜度:超过 TTL(10 分钟)为 true,执行门禁会拦截 */
|
||||
stale?: boolean;
|
||||
/** 行评估所用收料文件版本与来源最新可用文件是否一致;false = 文件已更新需重新匹配 */
|
||||
/** 行评估所用入站文件版本与来源最新可用文件是否一致;false = 文件已更新需重新匹配 */
|
||||
file_current?: boolean;
|
||||
/** [2026-10-12 单据数口径修正] 执行建单五元组首键(路由解析所得外部组织);
|
||||
* 匹配评估路径透出,历史回放缺省——预估 ERP 单据数按五元组去重的分组输入 */
|
||||
external_org?: string;
|
||||
/** 出生匹配快照上的调拨类型 code。可调拨明细跨类型混排时用来显示类别名称。 */
|
||||
transfer_type?: string;
|
||||
}
|
||||
|
||||
/** 来源实例级进度(决策 18:来源隔离展示) */
|
||||
@@ -135,8 +166,10 @@ export type TransferOrderStatus = 'pending' | 'executing' | 'success' | 'duplica
|
||||
|
||||
/** 单内行(ERP 写入行粒度聚合:物料+批号;quantity 为 6 位小数字符串,与 D14 快照口径一致) */
|
||||
export interface TransferOrderLine {
|
||||
/** 行级溯源收料通知号(2026-09-29 契约扩充;一行恒对应一张 invoice,旧 payload 缺省) */
|
||||
/** 行级溯源单号(档 doc_no;旧 payload 缺省) */
|
||||
invoice_no?: string;
|
||||
/** 档上的外部单号;聚合行内多个单号以逗号连接,旧 payload 缺省 */
|
||||
external_doc_no?: string;
|
||||
material_no: string;
|
||||
material_name: string;
|
||||
lot_no: string;
|
||||
@@ -151,7 +184,8 @@ export interface TransferOrderLine {
|
||||
*/
|
||||
export interface TransferOrder {
|
||||
doc_no: string;
|
||||
receipt_date: string;
|
||||
/** 单异动日期(Task 3 序列化键更名后键名;旧名见 git 历史) */
|
||||
movement_date: string;
|
||||
from_warehouse: string;
|
||||
to_warehouse: string;
|
||||
status: TransferOrderStatus;
|
||||
@@ -188,21 +222,25 @@ export interface TransferBacklogItem {
|
||||
item_id: number;
|
||||
source_code: string;
|
||||
invoice_no: string;
|
||||
/** 档上的外部单号;没有则为空 */
|
||||
external_doc_no?: string;
|
||||
material_no: string;
|
||||
status: string;
|
||||
reason: string;
|
||||
/** 最近一次结果码(如 blocked_file_removed=收料行已从最新文件移除);缺省为普通阻断 */
|
||||
/** 最近一次结果码(如 blocked_file_removed=入站行已从最新文件移除);缺省为普通阻断 */
|
||||
result_code?: string | null;
|
||||
age_days: number;
|
||||
aging_level: string;
|
||||
last_attempt_at?: string | null;
|
||||
receipt_date?: string | null;
|
||||
movement_date?: string | null;
|
||||
material_name?: string | null;
|
||||
from_warehouse?: string | null;
|
||||
to_warehouse?: string | null;
|
||||
lot_no?: string | null;
|
||||
receipt_quantity?: string | null;
|
||||
movement_quantity?: string | null;
|
||||
external_quantity?: string | null;
|
||||
/** 出生匹配快照上的调拨类型 code。空串表示这行没有匹配类型。 */
|
||||
transfer_type?: string;
|
||||
}
|
||||
|
||||
/** 批量操作结果(单行隔离:ok 行带 status,失败行带 error) */
|
||||
@@ -230,11 +268,14 @@ export interface TransferDocumentRetryResult {
|
||||
blocked: { invoice_no: string; item_id: number; reason: string }[];
|
||||
total: number;
|
||||
}
|
||||
/** 待处理池汇总 */
|
||||
/** 待处理池汇总。pending_match 与待匹配清单同一外部单号合并口径;matchable_count 与清单「当前可匹配」同一口径。 */
|
||||
export interface TransferBacklogSummary {
|
||||
recoverable: number;
|
||||
closed: number;
|
||||
unknown: number;
|
||||
pending_match: number;
|
||||
/** 库存匹配卡「当前启用类型可匹配」;旧响应缺省时前端按 0 显示 */
|
||||
matchable_count?: number;
|
||||
aging: {
|
||||
warn_3d: number;
|
||||
escalate_5d: number;
|
||||
@@ -242,21 +283,95 @@ export interface TransferBacklogSummary {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 「待匹配」桶记录(D16 只读投影):按外部单号合计后的一行。
|
||||
* 尚无 items(未匹配/未库存核对),无 item_id——不可勾选执行。
|
||||
* 有外部单号时 quantity 是该单号下的数量合计。
|
||||
*/
|
||||
export interface TransferPendingMatchRecord {
|
||||
ledger_record_id: number;
|
||||
doc_no: string;
|
||||
/** 外部单号(WMS Order #);空串表示该行没有外部单号,未与其他行合并 */
|
||||
external_doc_no?: string | null;
|
||||
material_code?: string | null;
|
||||
material_name?: string | null;
|
||||
movement_date?: string | null;
|
||||
source_code: string;
|
||||
/** 档记录类型 */
|
||||
record_kind?: TransferRecordKind;
|
||||
quantity?: string | null;
|
||||
/** 启用类型范围并集现在圈得住。清单据此把「当前可匹配」和其余行分开。 */
|
||||
matchable?: boolean;
|
||||
}
|
||||
|
||||
/** 证据流种类:入站或出站。来源卡只渲染当前调拨类型 record_kinds 里的种类。 */
|
||||
export type TransferRecordKind = 'inbound' | 'outbound';
|
||||
|
||||
/** 单条证据流的文件状态。unconfigured 只出现在出站未配置报表时。 */
|
||||
export type TransferStreamFileStatus =
|
||||
| 'ready'
|
||||
| 'fetching'
|
||||
| 'failed'
|
||||
| 'no_data'
|
||||
| 'parse_failed'
|
||||
| 'expired'
|
||||
| 'none'
|
||||
| 'unconfigured';
|
||||
|
||||
/** 来源上的一条证据流(GET /sources streams[];来源卡按类型过滤后画括号)。 */
|
||||
export interface TransferSourceStream {
|
||||
record_kind: TransferRecordKind;
|
||||
file_status: TransferStreamFileStatus;
|
||||
has_ready_file: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当天可用证据文件(GET /sources/<code>/evidence-files)。
|
||||
* 只展示归档元数据与预签地址,不解析 Excel。
|
||||
* download_url 带 Content-Disposition,保存名为库存源加东八区年月日和时分。
|
||||
*/
|
||||
export interface TransferEvidenceFile {
|
||||
file_id: number;
|
||||
original_filename: string | null;
|
||||
created_at: string | null;
|
||||
sha256: string | null;
|
||||
file_size: number | null;
|
||||
presigned_url: string;
|
||||
download_url: string;
|
||||
}
|
||||
|
||||
/** 当前最新归档文件重解析结果(POST /sources/{code}/reparse data 投影) */
|
||||
export interface TransferCurrentReparseResult {
|
||||
source_code: string;
|
||||
record_kind: TransferRecordKind;
|
||||
ok: boolean;
|
||||
file_status: TransferSourceFileStatus['file_status'];
|
||||
file_id: number | null;
|
||||
inserted: number;
|
||||
updated: number;
|
||||
skipped: number;
|
||||
sealed_skipped: number;
|
||||
error_code: string | null;
|
||||
error_message: string | null;
|
||||
}
|
||||
|
||||
/** 来源实例选项(决策 3:平台仅分组,实例为执行边界) */
|
||||
export interface TransferSourceOption {
|
||||
source_code: string;
|
||||
display_name: string;
|
||||
platform: string;
|
||||
enabled: boolean;
|
||||
/** 收料文件状态:ready / fetching / failed / parse_failed / expired / none(只读投影货代收料事实;parse_failed=当日可用收料文件解析失败) */
|
||||
file_status?: 'ready' | 'fetching' | 'failed' | 'no_data' | 'parse_failed' | 'expired' | 'none';
|
||||
/** 是否已有当前可用的收料文件(门禁:无 ready 文件禁止确认匹配) */
|
||||
/** 入站文件状态扁平投影(等于 streams 里 inbound;旧调用仍可读) */
|
||||
file_status?: TransferStreamFileStatus;
|
||||
/** 是否已有当前可用的入站文件(扁平投影;确认门禁改看所选类型的每条流) */
|
||||
has_ready_file?: boolean;
|
||||
file_no?: string | null;
|
||||
file_sha256?: string | null;
|
||||
/** 入站与出站两条证据流。缺省时来源卡把扁平 file_status 视为一条入站流。 */
|
||||
streams?: TransferSourceStream[];
|
||||
}
|
||||
|
||||
/** 来源收料文件状态(门禁 + 状态标识 + 重试返回) */
|
||||
/** 来源入站文件状态(门禁 + 状态标识 + 重试返回) */
|
||||
export interface TransferSourceFileStatus {
|
||||
source_code: string;
|
||||
file_status: 'ready' | 'fetching' | 'failed' | 'no_data' | 'parse_failed' | 'expired' | 'none';
|
||||
@@ -279,6 +394,8 @@ export interface TransferOrderGroups {
|
||||
*/
|
||||
export interface TransferExecutedOrderItem {
|
||||
invoice_no: string;
|
||||
/** 档上的外部单号;没有则为空 */
|
||||
external_doc_no?: string;
|
||||
material_no: string;
|
||||
material_name: string;
|
||||
lot_no: string;
|
||||
@@ -296,7 +413,8 @@ export interface TransferExecutedOrder {
|
||||
submit_timestamp: string;
|
||||
status: TransferOrderStatus;
|
||||
status_group: keyof TransferOrderGroups;
|
||||
receipt_date: string;
|
||||
/** 单异动日期(Task 3 序列化键更名后键名;旧名见 git 历史) */
|
||||
movement_date: string;
|
||||
from_warehouse: string;
|
||||
to_warehouse: string;
|
||||
erp_document_no: string | null;
|
||||
|
||||
@@ -2,8 +2,15 @@
|
||||
/**
|
||||
* features/chat/views/ChatView.vue
|
||||
* 单个 Agent 对话页入口:provide 编排上下文,子组件 inject 消费。
|
||||
* 依赖:useChatPage、ChatViewContent/ChatViewOverlays、shared/styles/element-theme.css。
|
||||
* 逻辑:在途调拨业务面板(Transfer* 组件)已 EP 组件化(el-dialog/el-table/el-select),
|
||||
* EP 官方样式和全站 element-theme.css 随本页入口引入,放在暗色变量之后。
|
||||
* 不引管理端 element-trial.css。保证 chat 直达时样式就绪、不依赖 admin 路由先行加载。
|
||||
*/
|
||||
import { provide, reactive } from 'vue';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/shared/styles/element-theme.css';
|
||||
import { useChatPage } from '@/features/chat/composables/useChatPage';
|
||||
import { CHAT_PAGE_KEY, type ChatPageContextProvided } from '@/features/chat/composables/chat.context';
|
||||
import ChatViewContent from '@/features/chat/components/ChatViewContent.vue';
|
||||
|
||||
@@ -617,7 +617,7 @@ async function mountView(query: Record<string, string> = {}) {
|
||||
waiting_system_start: '等待系统启动',
|
||||
waiting_to_start: '等待系统启动',
|
||||
order_creating: '等待系统启动',
|
||||
inventory_matching: '库存匹配',
|
||||
onhand_matching: '库存匹配',
|
||||
excel_generating: 'Excel 生成',
|
||||
},
|
||||
},
|
||||
@@ -731,7 +731,7 @@ async function mountView(query: Record<string, string> = {}) {
|
||||
shippingProcessing: {
|
||||
stage: {
|
||||
order_creating: '创建正式订单',
|
||||
inventory_matching: '库存匹配',
|
||||
onhand_matching: '库存匹配',
|
||||
},
|
||||
stageLabel: {
|
||||
waiting_system_start: '等待系统启动',
|
||||
@@ -764,8 +764,8 @@ async function mountView(query: Record<string, string> = {}) {
|
||||
actionCodes: {
|
||||
confirm_customer: '确认客户',
|
||||
resolve_field_conflicts: '处理字段冲突',
|
||||
retry_inventory_preparation: '重新获取库存',
|
||||
retry_inventory_matching: '重新匹配库存',
|
||||
retry_onhand_preparation: '重新获取库存',
|
||||
retry_onhand_matching: '重新匹配库存',
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1545,11 +1545,11 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
};
|
||||
shippingProcessingProjection.value = {
|
||||
workItemType: 'order_task', workItemNo: 'SN-RPA-RECOVERY-PENDING',
|
||||
status: 'failed', userStatus: 'failed', stage: 'inventory_fetching',
|
||||
status: 'failed', userStatus: 'failed', stage: 'onhand_fetching',
|
||||
progressVersion: 7, currentGate: { status: 'blocked_retryable' },
|
||||
uiState: {
|
||||
status: 'failed', stage: 'inventory_fetching', lifecycleStage: 'fulfillment_prep',
|
||||
primary_action: { code: 'retry_inventory_preparation', i18n_key: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation' },
|
||||
status: 'failed', stage: 'onhand_fetching', lifecycleStage: 'fulfillment_prep',
|
||||
primary_action: { code: 'retry_onhand_preparation', i18n_key: 'workspace.shippingNotice.processGate.inventoryActions.retryInventoryPreparation' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
} as any;
|
||||
@@ -1559,7 +1559,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
ui_state: {
|
||||
actions: {
|
||||
primary: {
|
||||
code: 'retry_inventory_preparation', kind: 'current_gate', enabled: true,
|
||||
code: 'retry_onhand_preparation', kind: 'current_gate', enabled: true,
|
||||
dispatch: 'mutation', requires_confirmation: false,
|
||||
},
|
||||
secondary: [],
|
||||
@@ -1579,7 +1579,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).not.toContain('自动处理失败');
|
||||
});
|
||||
|
||||
it('submits retry_inventory_preparation from A even when B.actions lacks the code', async () => {
|
||||
it('submits retry_onhand_preparation from A even when B.actions lacks the code', async () => {
|
||||
// 回归:右卡只读 A.primary_action 展示「重新获取库存(RPA)」;若仍按 B.actions
|
||||
// 授权,会落到「未识别的动作」。A 展示即写路径授权;capabilities 可作 bypass。
|
||||
activeCase.value = {
|
||||
@@ -1589,11 +1589,11 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
};
|
||||
shippingProcessingProjection.value = {
|
||||
workItemType: 'order_task', workItemNo: 'SN-RPA-A-ONLY',
|
||||
status: 'failed', userStatus: 'retryable', stage: 'inventory_fetching',
|
||||
status: 'failed', userStatus: 'retryable', stage: 'onhand_fetching',
|
||||
progressVersion: 3, currentGate: { status: 'blocked_retryable' },
|
||||
uiState: {
|
||||
status: 'retryable', stage: 'inventory_fetching', lifecycleStage: 'fulfillment_prep',
|
||||
primary_action: { code: 'retry_inventory_preparation' },
|
||||
status: 'retryable', stage: 'onhand_fetching', lifecycleStage: 'fulfillment_prep',
|
||||
primary_action: { code: 'retry_onhand_preparation' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
} as any;
|
||||
@@ -1606,17 +1606,17 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
process_gate: {
|
||||
execution_no: 'EXEC-RPA-A-ONLY',
|
||||
current_blocking_gate: {
|
||||
gate_code: 'inventory_preparation', evaluation_version: 2, status: 'blocked_retryable',
|
||||
gate_code: 'onhand_preparation', evaluation_version: 2, status: 'blocked_retryable',
|
||||
},
|
||||
allowed_actions: ['retry_inventory_preparation'],
|
||||
recovery_targets: [{ action_code: 'retry_inventory_preparation' }],
|
||||
allowed_actions: ['retry_onhand_preparation'],
|
||||
recovery_targets: [{ action_code: 'retry_onhand_preparation' }],
|
||||
},
|
||||
stage_context: {
|
||||
preparation: {
|
||||
status: 'blocked', source_locked: false, source_options: [{ source_code: 'DSV' }],
|
||||
capabilities: [{
|
||||
code: 'retry_inventory_preparation', scope: 'task',
|
||||
action_code: 'retry_inventory_preparation', enabled: true,
|
||||
code: 'retry_onhand_preparation', scope: 'task',
|
||||
action_code: 'retry_onhand_preparation', enabled: true,
|
||||
}],
|
||||
frozen_order_lines: [], lines: [],
|
||||
},
|
||||
@@ -1638,7 +1638,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(submitProcessGatePrimaryActionMock).toHaveBeenCalledWith(
|
||||
expect.any(Object),
|
||||
expect.objectContaining({
|
||||
actionCode: 'retry_inventory_preparation',
|
||||
actionCode: 'retry_onhand_preparation',
|
||||
stageCapabilityBypass: true,
|
||||
}),
|
||||
);
|
||||
@@ -1655,12 +1655,12 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
};
|
||||
shippingProcessingProjection.value = {
|
||||
workItemType: 'order_task', workItemNo: 'SN-RPA-CAP-DISABLED',
|
||||
status: 'failed', userStatus: 'retryable', stage: 'inventory_fetching',
|
||||
status: 'failed', userStatus: 'retryable', stage: 'onhand_fetching',
|
||||
progressVersion: 5, currentGate: { status: 'blocked_retryable' },
|
||||
uiState: {
|
||||
status: 'retryable', stage: 'inventory_fetching', lifecycleStage: 'fulfillment_prep',
|
||||
primary_action: { code: 'retry_inventory_matching' },
|
||||
secondary_actions: [{ code: 'retry_inventory_preparation', enabled: true }],
|
||||
status: 'retryable', stage: 'onhand_fetching', lifecycleStage: 'fulfillment_prep',
|
||||
primary_action: { code: 'retry_onhand_matching' },
|
||||
secondary_actions: [{ code: 'retry_onhand_preparation', enabled: true }],
|
||||
},
|
||||
} as any;
|
||||
const taskApi = await import('@/features/chat/api/shipping.api');
|
||||
@@ -1671,9 +1671,9 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
process_gate: {
|
||||
execution_no: 'EXEC-RPA-CAP-DISABLED',
|
||||
current_blocking_gate: {
|
||||
gate_code: 'inventory_preparation', evaluation_version: 2, status: 'blocked_retryable',
|
||||
gate_code: 'onhand_preparation', evaluation_version: 2, status: 'blocked_retryable',
|
||||
},
|
||||
allowed_actions: ['retry_inventory_matching', 'retry_inventory_preparation'],
|
||||
allowed_actions: ['retry_onhand_matching', 'retry_onhand_preparation'],
|
||||
},
|
||||
stage_context: {
|
||||
preparation: {
|
||||
@@ -1682,13 +1682,13 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
failed_source_codes: ['DSV'],
|
||||
capabilities: [
|
||||
{
|
||||
code: 'retry_inventory_matching', scope: 'task',
|
||||
action_code: 'retry_inventory_matching', enabled: false,
|
||||
code: 'retry_onhand_matching', scope: 'task',
|
||||
action_code: 'retry_onhand_matching', enabled: false,
|
||||
disabled_reason: 'no_match_result',
|
||||
},
|
||||
{
|
||||
code: 'retry_inventory_preparation', scope: 'task',
|
||||
action_code: 'retry_inventory_preparation', enabled: true,
|
||||
code: 'retry_onhand_preparation', scope: 'task',
|
||||
action_code: 'retry_onhand_preparation', enabled: true,
|
||||
disabled_reason: null,
|
||||
},
|
||||
],
|
||||
@@ -1710,7 +1710,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(primary.attributes('data-capability-disabled')).toBe('true');
|
||||
expect(primary.attributes('title')).toContain('暂无库存匹配结果');
|
||||
// 侧路按钮:能力 enabled → 保持可点,不受主按钮禁用影响。
|
||||
const recovery = wrapper.get('[data-testid="review-current-task-recovery-retry_inventory_preparation"]');
|
||||
const recovery = wrapper.get('[data-testid="review-current-task-recovery-retry_onhand_preparation"]');
|
||||
expect(recovery.attributes('disabled')).toBeUndefined();
|
||||
// 点击禁用按钮不得触发提交,也不得弹任何 info 提示(此前会弹未翻译 key)。
|
||||
await primary.trigger('click');
|
||||
@@ -1789,7 +1789,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
confirmed_task_no: 'SN-PROJECTION-PENDING',
|
||||
process_gate: {
|
||||
execution_no: 'EXEC-PROJECTION-PENDING', status: 'blocked_retryable', owner_type: 'human', technical_auto_only: false,
|
||||
current_blocking_gate: { gate_code: 'inventory_preparation', status: 'blocked_retryable' },
|
||||
current_blocking_gate: { gate_code: 'onhand_preparation', status: 'blocked_retryable' },
|
||||
primary_action: { code: 'retry', label_key: 'chat.shippingOrderReview.currentTask.actionRetry' },
|
||||
},
|
||||
automation: { status: 'failed', retryable: true, can_auto_create: false, can_build: true },
|
||||
@@ -1875,7 +1875,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
confirmed_task_id: 91,
|
||||
confirmed_task_no: 'SN-SINGLE-SOURCE-1',
|
||||
// 故意下发与投影分叉的 Case 阶段:单源后必须被无视。
|
||||
current_stage: { code: 'inventory_matching', label_key: 'inventory_matching', inconsistent: false },
|
||||
current_stage: { code: 'onhand_matching', label_key: 'onhand_matching', inconsistent: false },
|
||||
automation: { status: 'running', retryable: false, can_auto_create: false, can_build: true },
|
||||
};
|
||||
shippingProcessingProjection.value = null;
|
||||
@@ -2513,7 +2513,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
};
|
||||
const wrapper = await mountView({ lifecycle_stage: 'order_review' });
|
||||
shippingProcessingProjection.value = {
|
||||
stage: 'inventory_preparation', status: 'processing',
|
||||
stage: 'onhand_preparation', status: 'processing',
|
||||
uiState: {
|
||||
status: 'running', lifecycleStage: 'fulfillment_prep', lifecycleEntries: [],
|
||||
primary_action: null, secondary_actions: [],
|
||||
@@ -2700,10 +2700,10 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
// 而不是默认回退到订单复核。
|
||||
shippingProcessingProjection.value = {
|
||||
status: 'processing',
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
uiState: {
|
||||
status: 'processing',
|
||||
stage: 'inventory_matching',
|
||||
stage: 'onhand_matching',
|
||||
lifecycleStage: 'fulfillment_prep',
|
||||
lifecycleEntries: [
|
||||
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
|
||||
@@ -2804,10 +2804,10 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
draft_line_id: 'line-frozen',
|
||||
snapshot_line_id: 1001,
|
||||
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
|
||||
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
inventory_allowed_actions: ['retry_onhand_preparation', 'retry_onhand_matching'],
|
||||
line_allowed_actions: ['release_onhand_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'onhand_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
@@ -2827,10 +2827,10 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
ui_state: {
|
||||
process_gate: {
|
||||
execution_no: 'EXEC-FROZEN-LINE',
|
||||
current_blocking_gate: { gate_code: 'inventory_preparation', status: 'blocked_retryable' },
|
||||
current_blocking_gate: { gate_code: 'onhand_preparation', status: 'blocked_retryable' },
|
||||
},
|
||||
actions: {
|
||||
primary: { code: 'retry_inventory_preparation', enabled: true, dispatch: 'mutation' },
|
||||
primary: { code: 'retry_onhand_preparation', enabled: true, dispatch: 'mutation' },
|
||||
secondary: [],
|
||||
},
|
||||
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
@@ -2847,10 +2847,10 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
required_qty: '6', available_qty: null, part_available_qty: '9', shortage_qty: null, source_code: 'DBS',
|
||||
inventory_file_no: 'SIF-LINE-DBS', status: 'shortage',
|
||||
draft_line_id: 'line-frozen',
|
||||
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
inventory_allowed_actions: ['retry_onhand_preparation', 'retry_onhand_matching'],
|
||||
line_allowed_actions: ['release_onhand_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'onhand_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
@@ -2886,26 +2886,26 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(wrapper.find('[data-testid="review-fulfillment-frozen-order"]').exists()).toBe(false);
|
||||
// 展示态行级动作收纳进更多菜单(⋯):逐项断言授权动作入口存在,不再有常显按钮。
|
||||
await openLineOverflowMenu(wrapper, 1001);
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-download_inventory_file-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-retry_inventory_preparation-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-retry_inventory_matching-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-release_inventory_shortage-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-download_onhand_file-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-retry_onhand_preparation-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-retry_onhand_matching-1001"]')).toBeTruthy();
|
||||
expect(document.body.querySelector('[data-testid="review-fulfillment-line-action-release_onhand_shortage-1001"]')).toBeTruthy();
|
||||
expect(workspace.text()).toContain('库存不足');
|
||||
await clickLineMenuItem(1001, 'download_inventory_file');
|
||||
await clickLineMenuItem(1001, 'download_onhand_file');
|
||||
expect(downloadWorkspaceShippingLineInventoryFileMock).toHaveBeenCalledWith('SN-FROZEN', 'SIF-LINE-DBS');
|
||||
await openLineOverflowMenu(wrapper, 1001);
|
||||
await clickLineMenuItem(1001, 'retry_inventory_preparation');
|
||||
await clickLineMenuItem(1001, 'retry_onhand_preparation');
|
||||
expect(submitProcessGatePrimaryActionMock).toHaveBeenCalledWith(
|
||||
expect.any(Object),
|
||||
expect.objectContaining({
|
||||
actionCode: 'retry_inventory_preparation',
|
||||
actionCode: 'retry_onhand_preparation',
|
||||
payload: { snapshot_line_id: 1001 },
|
||||
}),
|
||||
);
|
||||
// Gate 恢复受理后立即启动五阶段轮询,不依赖浏览器手动刷新。
|
||||
expect(startWorkflowProgressPollingMock).toHaveBeenCalledTimes(1);
|
||||
await openLineOverflowMenu(wrapper, 1001);
|
||||
await clickLineMenuItem(1001, 'release_inventory_shortage');
|
||||
await clickLineMenuItem(1001, 'release_onhand_shortage');
|
||||
expect(wrapper.get('[data-testid="review-release-inventory-dialog"]').text()).toContain('ODM ID');
|
||||
expect(wrapper.get('[data-testid="review-release-inventory-dialog"]').text()).toContain('ODM-001');
|
||||
const dialog = wrapper.get('[data-testid="review-release-inventory-dialog"]');
|
||||
@@ -2933,9 +2933,9 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
draft_line_id: 'line-frozen',
|
||||
snapshot_line_id: 1001,
|
||||
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
line_allowed_actions: ['release_onhand_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'onhand_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
@@ -2964,7 +2964,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
stage_context: releaseAccepted ? { upload: {} } : {
|
||||
preparation: {
|
||||
frozen_order_lines: [{ snapshot_line_id: 1001, line_no: 1, reservation_id: 'RSV-FROZEN', part_number: 'PN-FROZEN', required_qty: '6' }],
|
||||
lines: [{ snapshot_line_id: 1001, line_no: 1, reservation_id: 'RSV-FROZEN', part_number: 'PN-FROZEN', required_qty: '6', shortage_qty: '3', source_code: 'DBS', status: 'shortage', draft_line_id: 'line-frozen', line_allowed_actions: ['release_inventory_shortage'], release_required_fields: [{ field_id: '102', display_name: '库位' }] }],
|
||||
lines: [{ snapshot_line_id: 1001, line_no: 1, reservation_id: 'RSV-FROZEN', part_number: 'PN-FROZEN', required_qty: '6', shortage_qty: '3', source_code: 'DBS', status: 'shortage', draft_line_id: 'line-frozen', line_allowed_actions: ['release_onhand_shortage'], release_required_fields: [{ field_id: '102', display_name: '库位' }] }],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -2974,7 +2974,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
await flushPromises();
|
||||
// 缺字段短缺行:放行入口在更多菜单,必填补录在行内补录条完成(原因不再强制)。
|
||||
await openLineOverflowMenu(wrapper, 1001);
|
||||
await clickLineMenuItem(1001, 'release_inventory_shortage');
|
||||
await clickLineMenuItem(1001, 'release_onhand_shortage');
|
||||
await wrapper.get('[data-testid="review-fulfillment-release-input-1001-102"]').setValue('A-01');
|
||||
await wrapper.get('[data-testid="review-fulfillment-release-confirm-1001"]').trigger('click');
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
@@ -2997,9 +2997,9 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
draft_line_id: 'line-async',
|
||||
snapshot_line_id: 1002,
|
||||
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
line_allowed_actions: ['release_onhand_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'onhand_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
@@ -3024,7 +3024,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
stage_context: advanceDone ? { upload: {} } : {
|
||||
preparation: {
|
||||
frozen_order_lines: [{ snapshot_line_id: 1002, line_no: 1, reservation_id: 'RSV-ASYNC', part_number: 'PN-ASYNC', required_qty: '6' }],
|
||||
lines: [{ snapshot_line_id: 1002, line_no: 1, reservation_id: 'RSV-ASYNC', part_number: 'PN-ASYNC', required_qty: '6', shortage_qty: '3', source_code: 'DBS', status: 'shortage', draft_line_id: 'line-async', line_allowed_actions: ['release_inventory_shortage'], release_required_fields: [{ field_id: '102', display_name: '库位' }] }],
|
||||
lines: [{ snapshot_line_id: 1002, line_no: 1, reservation_id: 'RSV-ASYNC', part_number: 'PN-ASYNC', required_qty: '6', shortage_qty: '3', source_code: 'DBS', status: 'shortage', draft_line_id: 'line-async', line_allowed_actions: ['release_onhand_shortage'], release_required_fields: [{ field_id: '102', display_name: '库位' }] }],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3033,7 +3033,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
|
||||
await flushPromises();
|
||||
await openLineOverflowMenu(wrapper, 1002);
|
||||
await clickLineMenuItem(1002, 'release_inventory_shortage');
|
||||
await clickLineMenuItem(1002, 'release_onhand_shortage');
|
||||
await wrapper.get('[data-testid="review-fulfillment-release-input-1002-102"]').setValue('A-01');
|
||||
await wrapper.get('[data-testid="review-fulfillment-release-confirm-1002"]').trigger('click');
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
@@ -3071,9 +3071,9 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
draft_line_id: 'line-manual',
|
||||
snapshot_line_id: 1003,
|
||||
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
line_allowed_actions: ['release_onhand_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'onhand_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
@@ -3092,7 +3092,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
stage_context: releaseAccepted ? { upload: {} } : {
|
||||
preparation: {
|
||||
frozen_order_lines: [{ snapshot_line_id: 1003, line_no: 1, reservation_id: 'RSV-MANUAL', part_number: 'PN-MANUAL', required_qty: '6' }],
|
||||
lines: [{ snapshot_line_id: 1003, line_no: 1, reservation_id: 'RSV-MANUAL', part_number: 'PN-MANUAL', required_qty: '6', shortage_qty: '3', source_code: 'DBS', status: 'shortage', draft_line_id: 'line-manual', line_allowed_actions: ['release_inventory_shortage'], release_required_fields: [{ field_id: '102', display_name: '库位' }] }],
|
||||
lines: [{ snapshot_line_id: 1003, line_no: 1, reservation_id: 'RSV-MANUAL', part_number: 'PN-MANUAL', required_qty: '6', shortage_qty: '3', source_code: 'DBS', status: 'shortage', draft_line_id: 'line-manual', line_allowed_actions: ['release_onhand_shortage'], release_required_fields: [{ field_id: '102', display_name: '库位' }] }],
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -3108,7 +3108,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
|
||||
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
|
||||
await openLineOverflowMenu(wrapper, 1003);
|
||||
await clickLineMenuItem(1003, 'release_inventory_shortage');
|
||||
await clickLineMenuItem(1003, 'release_onhand_shortage');
|
||||
await wrapper.get('[data-testid="review-fulfillment-release-input-1003-102"]').setValue('A-01');
|
||||
await wrapper.get('[data-testid="review-fulfillment-release-confirm-1003"]').trigger('click');
|
||||
await wrapper.get('[data-testid="review-lifecycle-stage-fulfillment_prep"]').findAll('button')[1].trigger('click');
|
||||
@@ -3354,7 +3354,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
lifecycle_stage: 'fulfillment_prep', lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
process_gate: {
|
||||
gate_status: 'blocked_retryable', blocking_reason_code: 'inventory_file_missing',
|
||||
primary_action: { code: 'retry_inventory_preparation', label_key: 'retry_inventory_preparation' },
|
||||
primary_action: { code: 'retry_onhand_preparation', label_key: 'retry_onhand_preparation' },
|
||||
},
|
||||
},
|
||||
} as any);
|
||||
@@ -3710,7 +3710,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
primary: {
|
||||
code: 'regenerate_excel_artifact', kind: 'recovery', enabled: true,
|
||||
dispatch: 'mutation',
|
||||
target_surface: 'fulfillment_prep', target_anchor: 'inventory_matching',
|
||||
target_surface: 'fulfillment_prep', target_anchor: 'onhand_matching',
|
||||
requires_confirmation: false,
|
||||
},
|
||||
secondary: [],
|
||||
@@ -4340,7 +4340,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
shippingNoticeNo: 'SN-OT-WAITING-INVENTORY',
|
||||
retryable: true,
|
||||
userStatus: 'retryable',
|
||||
primaryAction: { code: 'retry_inventory_preparation' },
|
||||
primaryAction: { code: 'retry_onhand_preparation' },
|
||||
currentGate: { status: 'blocked_retryable' },
|
||||
inventoryPreparation: {
|
||||
activeAttemptCount: 1,
|
||||
@@ -4349,7 +4349,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
},
|
||||
uiState: {
|
||||
status: 'retryable',
|
||||
primary_action: { code: 'retry_inventory_preparation' },
|
||||
primary_action: { code: 'retry_onhand_preparation' },
|
||||
secondary_actions: [],
|
||||
},
|
||||
};
|
||||
@@ -4358,7 +4358,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
ui_state: {
|
||||
actions: {
|
||||
primary: {
|
||||
code: 'retry_inventory_preparation', kind: 'recovery', enabled: true,
|
||||
code: 'retry_onhand_preparation', kind: 'recovery', enabled: true,
|
||||
dispatch: 'mutation', requires_confirmation: false,
|
||||
},
|
||||
secondary: [],
|
||||
@@ -4366,7 +4366,7 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
process_gate: {
|
||||
execution_no: 'EXEC-INVENTORY-WAITING',
|
||||
current_blocking_gate: {
|
||||
gate_code: 'inventory_preparation', evaluation_version: 1,
|
||||
gate_code: 'onhand_preparation', evaluation_version: 1,
|
||||
},
|
||||
},
|
||||
summary: {}, steps: [],
|
||||
@@ -4418,8 +4418,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
confirmed_task_no: 'SN-WAIT-1',
|
||||
// 故意与 Progress 文案分叉:若宽屏仍直读 Case code,会显示「库存匹配」。
|
||||
current_stage: {
|
||||
code: 'inventory_matching',
|
||||
label_key: 'inventory_matching',
|
||||
code: 'onhand_matching',
|
||||
label_key: 'onhand_matching',
|
||||
inconsistent: false,
|
||||
},
|
||||
automation: {
|
||||
|
||||
@@ -35,6 +35,7 @@ import {
|
||||
getWorkspaceShippingFreightNoticeGroups,
|
||||
batchConfirmWorkspaceShippingNoticesUploaded,
|
||||
batchStartWorkspaceShippingNoticeRpaUpload,
|
||||
refreshWorkspaceCraneUploadStatus,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
retryShippingNoticeIntake,
|
||||
decideWorkspaceShippingOrderReviewLineFulfillment,
|
||||
@@ -850,7 +851,7 @@ const formalTaskActions = computed(() => {
|
||||
|
||||
/** 行级库存选源动作:只在表格逐行处理,禁止作为任务级按钮出现在右侧"当前任务"卡(避免与表格打勾重复)。 */
|
||||
const LINE_SCOPE_INVENTORY_ACTIONS = new Set([
|
||||
'override_line_inventory_source',
|
||||
'override_line_onhand_source',
|
||||
]);
|
||||
|
||||
/**
|
||||
@@ -1888,7 +1889,7 @@ async function executeFormalTaskAction(
|
||||
await nextTick();
|
||||
scrollWorkbenchAnchor('review-fulfillment-prep-workspace');
|
||||
},
|
||||
inventory_upload: () => scrollWorkbenchAnchor('review-formal-task-todo-panel'),
|
||||
onhand_upload: () => scrollWorkbenchAnchor('review-formal-task-todo-panel'),
|
||||
order_fields: () => scrollWorkbenchAnchor('review-order-lines-table'),
|
||||
reservation: () => scrollWorkbenchAnchor('review-order-lines-table'),
|
||||
duplicate_review: () => scrollWorkbenchAnchor('review-duplicate-panel'),
|
||||
@@ -2009,7 +2010,7 @@ async function handleCurrentTaskAction(
|
||||
await nextTick();
|
||||
scrollWorkbenchAnchor('review-formal-task-result-region');
|
||||
break;
|
||||
case 'open_inventory_match_review':
|
||||
case 'open_onhand_match_review':
|
||||
if (hasFormalOt.value) {
|
||||
// 正式 OT 后匹配/缺口语境的真实宿主是通知准备工作区;订单明细表不承载库存结果。
|
||||
scrollWorkbenchAnchor('review-fulfillment-prep-workspace');
|
||||
@@ -2043,7 +2044,7 @@ async function handleCurrentTaskAction(
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'retry_inventory_matching': {
|
||||
case 'retry_onhand_matching': {
|
||||
const summary = displayCase.value?.process_gate;
|
||||
if (!summary) return;
|
||||
const result = await submitProcessGatePrimaryAction(summary, { actionCode: code });
|
||||
@@ -2542,7 +2543,7 @@ const freightNoticeGroupsLoadFailed = ref(false);
|
||||
/** 货代上传分组请求在途守卫:独立于 loading,避免轮询 tick 与动作后刷新并发重载。 */
|
||||
const freightGroupsInFlight = ref(false);
|
||||
const selectedFreightBusinessNos = ref<string[]>([]);
|
||||
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | null>(null);
|
||||
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | 'refresh' | null>(null);
|
||||
/**
|
||||
* 判断货代通知聚合行是否已具备上传成功事实。
|
||||
* 核心逻辑:聚合接口 upload_status 已经过后端 project_notice_upload_status 归一,
|
||||
@@ -2740,13 +2741,13 @@ async function submitLineOdmChoice(line: { snapshot_line_id?: number | null }) {
|
||||
|
||||
function formalPreparationLineAllows(
|
||||
line: { snapshot_line_id?: number | null },
|
||||
action: 'retry_inventory_preparation' | 'retry_inventory_matching' | 'close_unfulfillable' | 'release_inventory_shortage',
|
||||
action: 'retry_onhand_preparation' | 'retry_onhand_matching' | 'close_unfulfillable' | 'release_onhand_shortage',
|
||||
): boolean {
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
if (action === 'close_unfulfillable' || action === 'release_inventory_shortage') {
|
||||
if (action === 'close_unfulfillable' || action === 'release_onhand_shortage') {
|
||||
return Boolean(
|
||||
fulfillment?.line_allowed_actions?.includes(action)
|
||||
&& (action !== 'release_inventory_shortage' || !fulfillment?.release_field_resolution_error),
|
||||
&& (action !== 'release_onhand_shortage' || !fulfillment?.release_field_resolution_error),
|
||||
);
|
||||
}
|
||||
return Boolean(fulfillment?.inventory_allowed_actions?.includes(action));
|
||||
@@ -2758,7 +2759,7 @@ function formalPreparationLineAllows(
|
||||
*/
|
||||
function formalPreparationLineStatusLabel(line: { snapshot_line_id?: number | null; status?: string | null; shortage_qty?: string | number | null }): string {
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
if (fulfillment?.decision?.decision_code === 'release_inventory_shortage') {
|
||||
if (fulfillment?.decision?.decision_code === 'release_onhand_shortage') {
|
||||
return t('chat.shippingOrderReview.lifecycle.prepare.releaseShortage');
|
||||
}
|
||||
const status = String(line.status || '').trim().toLowerCase();
|
||||
@@ -2807,7 +2808,7 @@ async function confirmReleaseInventoryShortage() {
|
||||
try {
|
||||
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
|
||||
draft_line_id: String(line.draft_line_id || ''),
|
||||
decision_code: 'release_inventory_shortage',
|
||||
decision_code: 'release_onhand_shortage',
|
||||
reason,
|
||||
release_field_values: releaseInventoryFieldValues.value,
|
||||
expected_draft_version: activeCase.value?.draft?.draft_version,
|
||||
@@ -2896,7 +2897,7 @@ function releaseBarReadyFor(line: { snapshot_line_id?: number | null }): boolean
|
||||
const fulfillment = formalPreparationLineFulfillment(line);
|
||||
const required = releaseBarLineRequiredFields(line);
|
||||
return Boolean(
|
||||
fulfillment?.line_allowed_actions?.includes('release_inventory_shortage')
|
||||
fulfillment?.line_allowed_actions?.includes('release_onhand_shortage')
|
||||
&& required.every((field) => releaseBarValue(line, field).trim())
|
||||
&& !releaseBarBusy.value[releaseBarKey(line)],
|
||||
);
|
||||
@@ -2917,7 +2918,7 @@ async function confirmReleaseBar(line: { snapshot_line_id?: number | null }) {
|
||||
try {
|
||||
await decideWorkspaceShippingOrderReviewLineFulfillment(caseNo, {
|
||||
draft_line_id: String(fulfillment.draft_line_id || ''),
|
||||
decision_code: 'release_inventory_shortage',
|
||||
decision_code: 'release_onhand_shortage',
|
||||
reason: '',
|
||||
release_field_values: { ...(releaseBarValues.value[key] || {}) },
|
||||
expected_draft_version: activeCase.value?.draft?.draft_version,
|
||||
@@ -3011,7 +3012,7 @@ async function downloadFormalPreparationLineInventoryFile(line: {
|
||||
/** 行级恢复提交当前 Gate 的精确动作,使用冻结快照行身份。 */
|
||||
async function retryFormalPreparationLine(
|
||||
snapshotLineId: number | string,
|
||||
actionCode: 'retry_inventory_preparation' | 'retry_inventory_matching',
|
||||
actionCode: 'retry_onhand_preparation' | 'retry_onhand_matching',
|
||||
) {
|
||||
if (!snapshotLineId) return;
|
||||
await submitFormalGateAction(actionCode, { snapshot_line_id: Number(snapshotLineId) });
|
||||
@@ -3132,20 +3133,20 @@ function overflowItems(line: {
|
||||
shortage_qty?: string | number | null;
|
||||
}): Array<{ key: string; icon: Component; labelKey: string; run: () => void | Promise<void> }> {
|
||||
const items: Array<{ key: string; icon: Component; labelKey: string; run: () => void | Promise<void> }> = [];
|
||||
if (formalPreparationLineAllows(line, 'retry_inventory_matching')) {
|
||||
if (formalPreparationLineAllows(line, 'retry_onhand_matching')) {
|
||||
items.push({
|
||||
key: 'retry_inventory_matching',
|
||||
key: 'retry_onhand_matching',
|
||||
icon: RefreshCw,
|
||||
labelKey: inventoryActionLabelKey('retry_inventory_matching')!,
|
||||
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_inventory_matching'),
|
||||
labelKey: inventoryActionLabelKey('retry_onhand_matching')!,
|
||||
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_onhand_matching'),
|
||||
});
|
||||
}
|
||||
// 放行缺口:缺字段型短缺行 → 行内展开补录条(替代弹窗);仅缺原因的行 → 旧弹窗(原因已可选)。
|
||||
if (formalPreparationLineAllows(line, 'release_inventory_shortage')) {
|
||||
if (formalPreparationLineAllows(line, 'release_onhand_shortage')) {
|
||||
items.push({
|
||||
key: 'release_inventory_shortage',
|
||||
key: 'release_onhand_shortage',
|
||||
icon: Check,
|
||||
labelKey: inventoryActionLabelKey('release_inventory_shortage')!,
|
||||
labelKey: inventoryActionLabelKey('release_onhand_shortage')!,
|
||||
run: () => {
|
||||
if (releaseBarHasFields(line)) expandReleaseBar(line);
|
||||
else openReleaseInventoryShortage(line);
|
||||
@@ -3160,19 +3161,19 @@ function overflowItems(line: {
|
||||
run: () => openCloseLineDialog(line),
|
||||
});
|
||||
}
|
||||
if (formalPreparationLineAllows(line, 'retry_inventory_preparation')) {
|
||||
if (formalPreparationLineAllows(line, 'retry_onhand_preparation')) {
|
||||
items.push({
|
||||
key: 'retry_inventory_preparation',
|
||||
key: 'retry_onhand_preparation',
|
||||
icon: Bot,
|
||||
labelKey: inventoryActionLabelKey('retry_inventory_preparation')!,
|
||||
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_inventory_preparation'),
|
||||
labelKey: inventoryActionLabelKey('retry_onhand_preparation')!,
|
||||
run: () => retryFormalPreparationLine(Number(line.snapshot_line_id), 'retry_onhand_preparation'),
|
||||
});
|
||||
}
|
||||
if (formalPreparationLineInventoryFileNo(line)) {
|
||||
items.push({
|
||||
key: 'download_inventory_file',
|
||||
key: 'download_onhand_file',
|
||||
icon: Download,
|
||||
labelKey: inventoryActionLabelKey('download_inventory_file') || 'chat.shippingOrderReview.lifecycle.prepare.downloadInventory',
|
||||
labelKey: inventoryActionLabelKey('download_onhand_file') || 'chat.shippingOrderReview.lifecycle.prepare.downloadInventory',
|
||||
run: () => downloadFormalPreparationLineInventoryFile(line),
|
||||
});
|
||||
}
|
||||
@@ -3246,7 +3247,7 @@ async function saveInlineEdit(line: {
|
||||
}
|
||||
// 库存源覆写沿用既有 Gate 动作(override_line_inventory_source),后端校验后仅重匹配该行。
|
||||
if (sourceChanged) {
|
||||
await submitFormalGateAction('override_line_inventory_source', {
|
||||
await submitFormalGateAction('override_line_onhand_source', {
|
||||
line_no: draft.line_no,
|
||||
source_code: nextSourceCode,
|
||||
});
|
||||
@@ -3459,7 +3460,7 @@ watch(
|
||||
function hasFreightGroupsInFlightRpa(groups: ShippingFreightNoticeGroup[]): boolean {
|
||||
return (groups || []).some((group) => {
|
||||
const st = String(group.upload_status || '').trim().toLowerCase();
|
||||
return st === 'uploading';
|
||||
return st === 'uploading' || st === 'allocating';
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3524,14 +3525,35 @@ function toggleFreightNoticeSelection(businessNo: string, checked: boolean) {
|
||||
: selectedFreightBusinessNos.value.filter((item) => item !== businessNo);
|
||||
}
|
||||
|
||||
/** 已选通知单中任一已上传时,批量写入动作必须 fail-closed,避免重复提交成功通知。 */
|
||||
/** 已选通知单中任一已上传或仍在 Crane 分配中时,批量写入动作必须停住,避免重复上传。 */
|
||||
const selectedFreightNoticesContainUploaded = computed(() => {
|
||||
const selected = new Set(selectedFreightBusinessNos.value);
|
||||
return freightNoticeGroups.value.some((group) => (
|
||||
selected.has(group.business_no) && isFreightNoticeUploaded(group)
|
||||
selected.has(group.business_no)
|
||||
&& (isFreightNoticeUploaded(group) || String(group.upload_status || '').trim().toLowerCase() === 'allocating')
|
||||
));
|
||||
});
|
||||
|
||||
/**
|
||||
* 手动刷新一张仍在分配中的 Crane 发货单。
|
||||
* @param businessNo - 发货通知单号,即 Pull Request #
|
||||
*/
|
||||
async function refreshCraneUploadStatus(businessNo: string) {
|
||||
if (freightBatchBusy.value) return;
|
||||
freightBatchBusy.value = 'refresh';
|
||||
try {
|
||||
await refreshWorkspaceCraneUploadStatus(businessNo);
|
||||
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (taskNo) await loadFreightNoticeGroups(taskNo);
|
||||
freightNoticeGroupsFinalized = false;
|
||||
startWorkflowProgressPolling();
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
freightBatchBusy.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadFreightNotice(businessNo: string) {
|
||||
try {
|
||||
await downloadWorkspaceShippingNoticeExcelFile(businessNo);
|
||||
@@ -3778,7 +3800,7 @@ const preparationWaveSelectableLines = computed(() => formalPreparationLines.val
|
||||
if (!fulfillment) return false;
|
||||
if (['task_created', 'fulfilled', 'closed_unfulfillable'].includes(String(fulfillment.line_status || ''))) return false;
|
||||
return Boolean(fulfillment.can_fulfill_complete_line)
|
||||
|| fulfillment.decision?.decision_code === 'release_inventory_shortage';
|
||||
|| fulfillment.decision?.decision_code === 'release_onhand_shortage';
|
||||
}));
|
||||
const allPreparationWaveSelected = computed(() => (
|
||||
preparationWaveSelectableLines.value.length > 0
|
||||
@@ -3824,13 +3846,21 @@ function freightLineNoDisplay(line: { line_no?: string | number | null }): {
|
||||
* @param group - 当前发货通知单聚合行(含 upload_status 与逐单错误字段)。
|
||||
*/
|
||||
function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
|
||||
state: 'uploaded' | 'uploading' | 'failed' | 'needs_human' | 'pending';
|
||||
state: 'uploaded' | 'uploading' | 'allocating' | 'failed' | 'needs_human' | 'pending';
|
||||
label: string;
|
||||
chipClass: string;
|
||||
reason: string | null;
|
||||
} {
|
||||
const status = String(group.upload_status || '').trim().toLowerCase();
|
||||
const reason = group.upload_error_message || group.upload_error_code || null;
|
||||
if (status === 'allocating') {
|
||||
return {
|
||||
state: 'allocating',
|
||||
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.allocating'),
|
||||
chipClass: 'bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-200',
|
||||
reason: null,
|
||||
};
|
||||
}
|
||||
if (status === 'uploaded') {
|
||||
return {
|
||||
state: 'uploaded',
|
||||
@@ -5496,7 +5526,15 @@ watch(
|
||||
<span :class="freightUploadStatusDisplay(group).chipClass" :title="freightUploadStatusDisplay(group).reason || undefined" class="rounded-full px-2 py-0.5 font-medium cursor-help" tabindex="0">{{ freightUploadStatusDisplay(group).label }}</span>
|
||||
<button type="button" class="rounded border border-brand-200 px-2 py-1 font-medium text-brand-700 hover:bg-brand-50" data-testid="review-freight-upload-download" :disabled="saving" @click="void downloadFreightNotice(group.business_no)">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.download') }}</button>
|
||||
<button
|
||||
v-if="canRunFreightNoticeAction(group, 'retry_freight_upload_rpa')"
|
||||
v-if="freightUploadStatusDisplay(group).state === 'allocating'"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
|
||||
data-testid="review-freight-upload-refresh"
|
||||
:disabled="freightBatchBusy !== null"
|
||||
@click="void refreshCraneUploadStatus(group.business_no)"
|
||||
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.refreshStatus') }}</button>
|
||||
<button
|
||||
v-if="canRunFreightNoticeAction(group, 'retry_freight_upload_rpa') && freightUploadStatusDisplay(group).state !== 'allocating'"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
|
||||
data-testid="review-freight-upload-rpa"
|
||||
@@ -5504,7 +5542,7 @@ watch(
|
||||
@click="void runFreightNoticeAction(group, 'rpa')"
|
||||
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.rpa') }}</button>
|
||||
<button
|
||||
v-if="canRunFreightNoticeAction(group, 'mark_manual_uploaded')"
|
||||
v-if="canRunFreightNoticeAction(group, 'mark_manual_uploaded') && freightUploadStatusDisplay(group).state !== 'allocating'"
|
||||
type="button"
|
||||
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
|
||||
data-testid="review-freight-upload-confirm"
|
||||
|
||||
Reference in new issue
Block a user