Merge branch 'hugo-shipping-notice' into test
This commit is contained in:
commit
e35f01bbe9
163 files changed
+21008
-2545
No files matched your search
+212
@@ -0,0 +1,212 @@
|
||||
/**
|
||||
* features/admin/modules/integration-connector/IntegrationCallLogsPanel.spec.ts
|
||||
* 用途:锁定集成调用日志面板行为——挂载即拉列表、筛选带参查询、行点击开抽屉呈现
|
||||
* wire 关键文本与步骤时间线、复制按钮按连接类型分流(soap=复制 curl,
|
||||
* database=复制 SQL 绑定内联)、wire_json 为 NULL 的历史行显示「无线级详情」。
|
||||
* 依赖:vi.mock(./api/integration-connector.api)、@vue/test-utils、i18n。
|
||||
* 逻辑:mock 列表固定返回 2 行(同 operation_id 两步),详情按用例切换 soap /
|
||||
* database / 无 wire 三种 wire_json 形态,断言渲染与复制链路。
|
||||
*/
|
||||
import { enableAutoUnmount, flushPromises, mount } from '@vue/test-utils';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
|
||||
import { getIntegrationCall, listIntegrationCalls } from './api/integration-connector.api';
|
||||
import type {
|
||||
IntegrationCallDetail,
|
||||
IntegrationCallLogRow,
|
||||
} from './types/integration-connector.types';
|
||||
|
||||
vi.mock('./api/integration-connector.api', () => ({
|
||||
listIntegrationCalls: vi.fn(),
|
||||
getIntegrationCall: vi.fn(),
|
||||
}));
|
||||
|
||||
const mockList = vi.mocked(listIntegrationCalls);
|
||||
const mockDetail = vi.mocked(getIntegrationCall);
|
||||
|
||||
// 列表 2 行:同一次能力调用的 step0(database 成功)+ step1(soap 失败)
|
||||
const rows: IntegrationCallLogRow[] = [
|
||||
{
|
||||
id: 261, created_at: '2026-09-27T00:29:22', capability: 'in_transit_transfer.create_transfer',
|
||||
operation_id: 'op-cbf5aaaa-1111', trace_id: 'ic-244fbbbb-2222', status: 'business_failed',
|
||||
elapsed_ms: 324, business_ref: 'TGHX1-OR-26092600002', client_code: 'tiptop-ws',
|
||||
interface_code: 'erp-ws-submit-transfer', connector_type: 'soap', step_index: 1, step_count: 2,
|
||||
},
|
||||
{
|
||||
id: 260, created_at: '2026-09-27T00:29:21', capability: 'in_transit_transfer.create_transfer',
|
||||
operation_id: 'op-cbf5aaaa-1111', trace_id: 'ic-244fbbbb-2222', status: 'success',
|
||||
elapsed_ms: 2366, business_ref: null, client_code: 'erp-db',
|
||||
interface_code: 'submit-stage-table', connector_type: 'database', step_index: 0, step_count: 2,
|
||||
},
|
||||
];
|
||||
|
||||
function makeDetail(call: Partial<IntegrationCallDetail['call']>, wireJson: IntegrationCallDetail['call']['wire_json']): IntegrationCallDetail {
|
||||
return {
|
||||
call: {
|
||||
id: 261, created_at: '2026-09-27T00:29:22', capability: 'in_transit_transfer.create_transfer',
|
||||
operation_id: 'op-cbf5aaaa-1111', trace_id: 'ic-244fbbbb-2222', status: 'business_failed',
|
||||
elapsed_ms: 324, business_ref: 'TGHX1-OR-26092600002',
|
||||
binding_snapshot_json: {}, request_summary_json: { doc_no: 'TGHX1-OR-26092600002' },
|
||||
response_summary_json: { code: 'HTTP_500' }, wire_json: wireJson,
|
||||
...call,
|
||||
},
|
||||
timeline: [
|
||||
{ id: 260, step_index: 0, step_count: 2, interface_code: 'submit-stage-table', status: 'success', elapsed_ms: 2366 },
|
||||
{ id: 261, step_index: 1, step_count: 2, interface_code: 'erp-ws-submit-transfer', status: 'business_failed', elapsed_ms: 324 },
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
const soapDetail = makeDetail({}, {
|
||||
kind: 'soap', method: 'POST', url: 'http://erp/WS?wsdl', soap_action: '"urn:CreateTransfer"',
|
||||
request_body: '<soapenv:Envelope><Body>demo</Body></soapenv:Envelope>',
|
||||
http_status: 500, response_body: '<soapenv:Envelope><Fault/></soapenv:Envelope>',
|
||||
});
|
||||
|
||||
const databaseDetail = makeDetail({ id: 260, status: 'success', elapsed_ms: 2366 }, {
|
||||
kind: 'database',
|
||||
statements: [{ phase: 'pre', sql: 'INSERT INTO t (batch) VALUES (:batch)', binds: { batch: 'B1' }, rowcount: 1, row_count: 1 }],
|
||||
rowcount: 1,
|
||||
});
|
||||
|
||||
const noWireDetail = makeDetail({}, null);
|
||||
|
||||
function mountPanel() {
|
||||
return mount(IntegrationCallLogsPanel, { global: { plugins: [i18n] } });
|
||||
}
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
|
||||
describe('IntegrationCallLogsPanel', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
mockList.mockResolvedValue({ total: 2, page: 1, page_size: 20, items: rows });
|
||||
});
|
||||
|
||||
it('挂载即拉取列表并渲染 2 行:时间/单号(business_ref 与 operation_id 前 8 位兜底)/步骤', async () => {
|
||||
// [断言意图] 面板挂载必须自主触发列表查询,不依赖外部触发
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
expect(mockList).toHaveBeenCalledTimes(1);
|
||||
expect(wrapper.findAll('[data-testid="call-row"]')).toHaveLength(2);
|
||||
// 行 261 有 business_ref:单号列显示业务单号
|
||||
expect(wrapper.text()).toContain('TGHX1-OR-26092600002');
|
||||
// 行 260 无 business_ref:单号列回退 operation_id 前 8 位
|
||||
expect(wrapper.text()).toContain('op-cbf5a');
|
||||
// 步骤列 1-based 展示(step_index 0/1 → 1/2、2/2)、状态徽章含原始状态值、耗时带 ms 后缀
|
||||
expect(wrapper.text()).toContain('1/2');
|
||||
expect(wrapper.text()).toContain('2/2');
|
||||
expect(wrapper.text()).toContain('business_failed');
|
||||
expect(wrapper.text()).toContain('2366ms');
|
||||
});
|
||||
|
||||
it('填 interface_code 后点查询:带筛选参数且回第一页重新拉取', async () => {
|
||||
// [断言意图] 筛选值必须原样进入 listIntegrationCalls 入参(querystring 由 api 层拼装)
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="call-filter-interface"]').setValue('erp-ws-submit-transfer');
|
||||
await wrapper.find('[data-testid="call-filter-query"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(mockList).toHaveBeenCalledTimes(2);
|
||||
expect(mockList).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ interface_code: 'erp-ws-submit-transfer', page: 1, page_size: 20 }),
|
||||
);
|
||||
});
|
||||
|
||||
it('点行开详情抽屉:呈现 soap wire 关键文本、两步时间线与复制 operation_id 按钮', async () => {
|
||||
// [断言意图] 抽屉必须展示线级事实原文(请求 body XML)与同 operation_id 的各步时间线
|
||||
mockDetail.mockResolvedValue(soapDetail);
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
await wrapper.findAll('[data-testid="call-row"]')[0].trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="call-detail-drawer"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('<soapenv:Envelope><Body>demo</Body></soapenv:Envelope>');
|
||||
// 时间线两步均渲染(step1 / step2,1-based 展示),当前步高亮存在
|
||||
expect(wrapper.text()).toContain('step1');
|
||||
expect(wrapper.text()).toContain('step2');
|
||||
expect(wrapper.text()).not.toContain('step0');
|
||||
expect(wrapper.text()).toContain('submit-stage-table');
|
||||
expect(wrapper.text()).toContain('erp-ws-submit-transfer');
|
||||
expect(wrapper.find('[data-testid="call-copy-operation-id"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('soap wire 出现复制 curl,点击后写入的命令含 url 与 SOAPAction', async () => {
|
||||
// [断言意图] soap 连接类型只提供 curl 复现入口,命令由 buildCurl 生成(可直接粘贴 bash)
|
||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||
Object.assign(navigator, { clipboard: { writeText } });
|
||||
mockDetail.mockResolvedValue(soapDetail);
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
await wrapper.findAll('[data-testid="call-row"]')[0].trigger('click');
|
||||
await flushPromises();
|
||||
const curlBtn = wrapper.find('[data-testid="call-copy-curl"]');
|
||||
expect(curlBtn.exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="call-copy-sql"]').exists()).toBe(false);
|
||||
await curlBtn.trigger('click');
|
||||
await flushPromises();
|
||||
expect(writeText).toHaveBeenCalledTimes(1);
|
||||
const cmd = String(writeText.mock.calls[0][0]);
|
||||
expect(cmd).toContain("curl -X POST 'http://erp/WS?wsdl'");
|
||||
expect(cmd).toContain('SOAPAction');
|
||||
});
|
||||
|
||||
it('database wire 出现复制 SQL(绑定已内联)且不出现复制 curl;写入类带环境警示', async () => {
|
||||
// [断言意图] database 连接类型只提供 SQL 复现入口,:batch 绑定必须内联为字面量
|
||||
const writeText = vi.fn().mockResolvedValue(undefined);
|
||||
Object.assign(navigator, { clipboard: { writeText } });
|
||||
mockDetail.mockResolvedValue(databaseDetail);
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
await wrapper.findAll('[data-testid="call-row"]')[1].trigger('click');
|
||||
await flushPromises();
|
||||
const sqlBtn = wrapper.find('[data-testid="call-copy-sql"]');
|
||||
expect(sqlBtn.exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="call-copy-curl"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="call-sql-write-warning"]').exists()).toBe(true);
|
||||
await sqlBtn.trigger('click');
|
||||
await flushPromises();
|
||||
expect(writeText).toHaveBeenCalledWith(expect.stringContaining("INSERT INTO t (batch) VALUES ('B1')"));
|
||||
});
|
||||
|
||||
it('wire_json 为 NULL 的历史行:抽屉显示「无线级详情(历史记录)」且无复制 body/raw 入口', async () => {
|
||||
// [断言意图] 历史存量不回填,前端必须如实显示无线级详情而非留白或报错
|
||||
mockDetail.mockResolvedValue(noWireDetail);
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
await wrapper.findAll('[data-testid="call-row"]')[0].trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="call-no-wire"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('无线级详情(历史记录)');
|
||||
expect(wrapper.find('[data-testid="call-copy-body"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="call-copy-raw"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('状态下拉与后端 RESULT_STATUSES 七值对齐;duplicate_success 绿 / duplicate_unverified 红', async () => {
|
||||
// [断言意图] 幂等重放审计行落入 duplicate_* 状态,筛选下拉缺值会导致该类日志无法筛出
|
||||
mockList.mockResolvedValue({
|
||||
total: 2, page: 1, page_size: 20,
|
||||
items: [
|
||||
{ ...rows[0], id: 270, status: 'duplicate_success', business_ref: null, interface_code: 'if-dup-ok' },
|
||||
{ ...rows[0], id: 271, status: 'duplicate_unverified', business_ref: null, interface_code: 'if-dup-unverified' },
|
||||
],
|
||||
});
|
||||
const wrapper = mountPanel();
|
||||
await flushPromises();
|
||||
const options = wrapper.find('[data-testid="call-filter-status"]').findAll('option')
|
||||
.map((o) => o.element.value).filter((v) => v !== '');
|
||||
expect(options).toEqual([
|
||||
'success', 'duplicate_success', 'duplicate_unverified',
|
||||
'business_failed', 'technical_failed', 'timeout', 'result_unknown',
|
||||
]);
|
||||
// [断言意图] 成功族判定:duplicate_success(幂等重放命中,业务已成功)徽章走绿色成功侧
|
||||
const dupOkRow = wrapper.findAll('[data-testid="call-row"]')[0];
|
||||
expect(dupOkRow.text()).toContain('duplicate_success');
|
||||
expect(dupOkRow.find('span.bg-green-100').exists()).toBe(true);
|
||||
// [断言意图] duplicate_unverified(回执未核实)保守归非成功态,徽章保持红色 ✗
|
||||
const dupUnknownRow = wrapper.findAll('[data-testid="call-row"]')[1];
|
||||
expect(dupUnknownRow.text()).toContain('duplicate_unverified');
|
||||
expect(dupUnknownRow.find('span.bg-red-100').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
+51
-4
@@ -23,11 +23,15 @@ const mockState = vi.hoisted(() => {
|
||||
const bindings = [
|
||||
{
|
||||
id: 1, capability: 'in_transit_transfer.query_inventory', context_selector_json: {},
|
||||
client_instance_code: '1001', interface_definition_code: 'IF-A',
|
||||
client_instance_code: '1001', interface_definition_code: 'IF-A', steps_json: [],
|
||||
param_mapping_json: {},
|
||||
mapping_version: 1, priority: 0, environment: 'prod',
|
||||
effective_from: null, effective_to: null, status: 'published',
|
||||
},
|
||||
];
|
||||
const interfaces: Array<Record<string, unknown>> = [];
|
||||
const clients: Array<Record<string, unknown>> = [];
|
||||
let activeEntity = 'credential';
|
||||
const credentials = [
|
||||
{
|
||||
id: 1, code: 'tiptop-erp', secret_ref: 'db:tiptop-erp', secret_provider: 'db',
|
||||
@@ -41,14 +45,14 @@ const mockState = vi.hoisted(() => {
|
||||
},
|
||||
];
|
||||
const noop = () => vi.fn();
|
||||
return { credentials, capabilities, bindings };
|
||||
return { credentials, capabilities, bindings, interfaces, clients, get activeEntity() { return activeEntity; }, set activeEntity(v: string) { activeEntity = v; } };
|
||||
});
|
||||
|
||||
vi.mock('./composables/useIntegrationConnectorAdmin', () => ({
|
||||
useIntegrationConnectorAdmin: () => ({
|
||||
clients: ref([]), interfaces: ref([]), bindings: ref(mockState.bindings),
|
||||
clients: ref(mockState.clients), interfaces: ref(mockState.interfaces), bindings: ref(mockState.bindings),
|
||||
credentials: ref(mockState.credentials), capabilities: ref(mockState.capabilities), credentialTypes: ref([]),
|
||||
isLoading: ref(false), activeEntity: ref('credential'), showFormModal: ref(false), isSaving: ref(false),
|
||||
isLoading: ref(false), activeEntity: ref(mockState.activeEntity), showFormModal: ref(false), isSaving: ref(false),
|
||||
clientForm: ref(createEmptyClientInstanceForm()),
|
||||
interfaceForm: ref(createEmptyInterfaceDefinitionForm()),
|
||||
bindingForm: ref(createEmptyBindingForm()),
|
||||
@@ -133,4 +137,47 @@ describe('IntegrationConnectorPage credential list', () => {
|
||||
expect(text).toContain('在途库存查询');
|
||||
expect(text).toContain('in_transit_transfer.query_inventory');
|
||||
});
|
||||
|
||||
it('绑定列表按有序步骤渲染接口链与每步客户端;steps_json 为空的存量行走旧列兜底', async () => {
|
||||
const ifaceRow = (id: number, code: string, name: string, clientCode: string) => ({
|
||||
id, code, name, client_instance_code: clientCode, connector_type: 'rest', http_method: null,
|
||||
request_path: null, request_spec_json: {}, input_schema_json: {}, response_mapping_json: {},
|
||||
output_schema_json: {}, version: 1, status: 'published', enabled: true,
|
||||
});
|
||||
const clientRow = (id: number, code: string, name: string) => ({
|
||||
id, code, name, connector_type: 'rest', environment: 'prod', endpoint: null,
|
||||
timeout_seconds: null, config_json: {}, credential_ref_code: null, enabled: true,
|
||||
});
|
||||
mockState.interfaces = [ifaceRow(1, 'IF-A', '写入中间表', 'CLI-1'), ifaceRow(2, 'IF-B', '回读结果', 'CLI-2')] as never;
|
||||
mockState.clients = [clientRow(1, 'CLI-1', '生产库'), clientRow(2, 'CLI-2', '生产接口')] as never;
|
||||
mockState.bindings = [{
|
||||
id: 9, capability: 'cap.multi', context_selector_json: {},
|
||||
steps_json: [{ interface_code: 'IF-A', param_mapping_json: {} }, { interface_code: 'IF-B', param_mapping_json: {} }],
|
||||
param_mapping_json: {}, client_instance_code: 'CLI-1', interface_definition_code: 'IF-A',
|
||||
mapping_version: 1, priority: 0, environment: 'prod', effective_from: null, effective_to: null, status: 'published',
|
||||
}] as never;
|
||||
const wrapper = mountPage();
|
||||
const bindTab = wrapper.findAll('[role="tab"]').find((b) => b.text() === '绑定')!;
|
||||
await bindTab.trigger('click');
|
||||
const text = wrapper.text();
|
||||
// 两步全部渲染(编号 + 接口名),每步客户端与接口逐步对齐;列头为「接口步骤(有序)」
|
||||
expect(text).toContain('写入中间表');
|
||||
expect(text).toContain('回读结果');
|
||||
expect(text).toContain('生产库');
|
||||
expect(text).toContain('生产接口');
|
||||
expect(wrapper.findAll('th').some((th) => th.text().includes('接口步骤'))).toBe(true);
|
||||
|
||||
// 存量行兜底:steps_json 为空时由旧单步列合成一步
|
||||
mockState.bindings = [{
|
||||
id: 10, capability: 'cap.single', context_selector_json: {}, steps_json: [],
|
||||
param_mapping_json: {}, client_instance_code: 'CLI-1', interface_definition_code: 'IF-A',
|
||||
mapping_version: 1, priority: 0, environment: 'prod', effective_from: null, effective_to: null, status: 'draft',
|
||||
}] as never;
|
||||
const legacy = mountPage();
|
||||
const legacyTab = legacy.findAll('[role="tab"]').find((b) => b.text() === '绑定')!;
|
||||
await legacyTab.trigger('click');
|
||||
expect(legacy.text()).toContain('写入中间表');
|
||||
expect(legacy.text()).not.toContain('回读结果');
|
||||
mockState.bindings = [];
|
||||
});
|
||||
});
|
||||
+34
-11
@@ -1,7 +1,8 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/IntegrationConnectorPage.vue
|
||||
用途:集成连接器管理页——四个配置实体(客户端实例/接口定义/绑定/凭据引用)tab 列表 +
|
||||
能力清单与手动调用测试;创建/编辑抽屉 + 行内连接测试。
|
||||
能力清单与手动调用测试;创建/编辑抽屉 + 行内连接测试;调用日志 tab
|
||||
承载筛选/分页列表/详情抽屉(能力无关通用口径)。
|
||||
依赖:useIntegrationConnectorAdmin、抽屉与调用测试弹窗组件、useI18n。
|
||||
逻辑:按 tab 展示列表与「新增」;客户端列表展示类型/环境徽章、行内启停开关与
|
||||
连接测试结果(徽章 + 可展开详情);接口定义与绑定列表均以状态徽章 + 生命周期行内
|
||||
@@ -19,8 +20,10 @@ import { useI18n } from 'vue-i18n';
|
||||
import { Plus, Edit, Trash2, Plug, PlayCircle } from 'lucide-vue-next';
|
||||
import IntegrationConnectorFormDrawer from './components/IntegrationConnectorFormDrawer.vue';
|
||||
import IntegrationCapabilityCallModal from './components/IntegrationCapabilityCallModal.vue';
|
||||
import IntegrationCallLogsPanel from './components/IntegrationCallLogsPanel.vue';
|
||||
import { CONNECTOR_TYPE_OPTIONS, ENVIRONMENT_OPTIONS } from './types/integration-connector.types';
|
||||
import { useIntegrationConnectorAdmin } from './composables/useIntegrationConnectorAdmin';
|
||||
import type { IntegrationBindingRow } from './types/integration-connector.types';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
@@ -38,16 +41,17 @@ const {
|
||||
|
||||
onMounted(() => { void loadAll(); });
|
||||
|
||||
type TabKey = 'client' | 'interface' | 'binding' | 'credential' | 'capability';
|
||||
type TabKey = 'client' | 'interface' | 'binding' | 'credential' | 'capability' | 'calls';
|
||||
const tabs: Array<{ key: TabKey; labelKey: string }> = [
|
||||
{ key: 'client', labelKey: 'admin.integrationConnector.tabs.client' },
|
||||
{ key: 'interface', labelKey: 'admin.integrationConnector.tabs.interface' },
|
||||
{ key: 'binding', labelKey: 'admin.integrationConnector.tabs.binding' },
|
||||
{ key: 'credential', labelKey: 'admin.integrationConnector.tabs.credential' },
|
||||
{ key: 'capability', labelKey: 'admin.integrationConnector.tabs.capability' },
|
||||
{ key: 'calls', labelKey: 'admin.integrationConnector.tabs.calls' },
|
||||
];
|
||||
// 当前激活 tab:页面本地状态(capability 为只读注册表 tab,不属于可编辑实体);
|
||||
// 初始取 activeEntity,保证携带实体态进入页面时列表与 tab 一致。
|
||||
// 当前激活 tab:页面本地状态(capability 为只读注册表 tab,calls 为只读调用日志 tab,
|
||||
// 均不属于可编辑实体);初始取 activeEntity,保证携带实体态进入页面时列表与 tab 一致。
|
||||
const activeTab = ref<TabKey>(activeEntity.value);
|
||||
|
||||
/** 客户端选项带 connector_type:接口表单联动展示连接器类型用。 */
|
||||
@@ -64,6 +68,18 @@ function clientNameOf(code: string) {
|
||||
function interfaceNameOf(code: string) {
|
||||
return interfaces.value.find((i) => i.code === code)?.name ?? '';
|
||||
}
|
||||
/** 绑定有序步骤视图:优先 steps_json;存量旧列行(P2 前镜像)兜底合成一步。
|
||||
* 每步客户端由接口归属自带,供客户端列按步骤对齐展示。
|
||||
*/
|
||||
function bindingStepsOf(row: IntegrationBindingRow): Array<{ interface_code: string; client_code: string }> {
|
||||
const steps = row.steps_json?.length
|
||||
? row.steps_json
|
||||
: [{ interface_code: row.interface_definition_code, param_mapping_json: row.param_mapping_json ?? {} }];
|
||||
return steps.map((step) => ({
|
||||
interface_code: step.interface_code,
|
||||
client_code: interfaces.value.find((iface) => iface.code === step.interface_code)?.client_instance_code ?? row.client_instance_code,
|
||||
}));
|
||||
}
|
||||
|
||||
/** 行内展开测试详情的客户端编码(同一时刻至多展开一行)。 */
|
||||
const expandedTestCode = ref('');
|
||||
@@ -148,8 +164,8 @@ function testDetailText(code: string) {
|
||||
|
||||
function selectTab(key: TabKey) {
|
||||
activeTab.value = key;
|
||||
// capability tab 只读展示注册表(无新增/表单入口),activeEntity 保持最后一个可编辑实体供抽屉复用。
|
||||
if (key !== 'capability') activeEntity.value = key;
|
||||
// capability/calls tab 只读展示(无新增/表单入口),activeEntity 保持最后一个可编辑实体供抽屉复用。
|
||||
if (key !== 'capability' && key !== 'calls') activeEntity.value = key;
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -161,7 +177,7 @@ function selectTab(key: TabKey) {
|
||||
<p class="section-desc mt-1">{{ t('admin.integrationConnector.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
v-if="activeTab !== 'capability'"
|
||||
v-if="activeTab !== 'capability' && activeTab !== 'calls'"
|
||||
type="button"
|
||||
class="flex items-center gap-2 px-4 py-2 bg-brand-600 text-white rounded-xl hover:bg-brand-700 transition-all shadow-lg shadow-brand-200 active:scale-95 text-sm font-medium"
|
||||
@click="openCreateModal(activeEntity)"
|
||||
@@ -371,12 +387,16 @@ function selectTab(key: TabKey) {
|
||||
<p v-if="capabilityLabelOf(row.capability) !== row.capability" class="text-xs text-muted mono mt-0.5">{{ row.capability }}</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-primary">{{ clientNameOf(row.client_instance_code) || row.client_instance_code }}</p>
|
||||
<p class="text-xs text-muted mono mt-0.5">{{ row.client_instance_code }}</p>
|
||||
<!-- 有序步骤:逐步渲染客户端(与接口步骤列对齐) -->
|
||||
<p v-for="(step, idx) in bindingStepsOf(row)" :key="`c-${step.interface_code}-${idx}`" class="text-sm text-primary">
|
||||
<span class="mr-1 text-xs text-muted">{{ idx + 1 }}.</span>{{ clientNameOf(step.client_code) || step.client_code }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<p class="text-sm text-primary">{{ interfaceNameOf(row.interface_definition_code) || row.interface_definition_code }}</p>
|
||||
<p class="text-xs text-muted mono mt-0.5">{{ row.interface_definition_code }}</p>
|
||||
<!-- 有序步骤编排:编号 + 接口名,悬停显示接口编码;旧单步行兜底为一步 -->
|
||||
<p v-for="(step, idx) in bindingStepsOf(row)" :key="`i-${step.interface_code}-${idx}`" class="text-sm text-primary">
|
||||
<span class="mr-1 text-xs text-muted">{{ idx + 1 }}.</span><span :title="step.interface_code">{{ interfaceNameOf(step.interface_code) || step.interface_code }}</span>
|
||||
</p>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium" :class="statusBadgeClass(row.status)" data-testid="binding-status">{{ statusLabel(row.status) }}</span>
|
||||
@@ -478,6 +498,9 @@ function selectTab(key: TabKey) {
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 调用日志:筛选 + 分页列表 + 详情抽屉(能力无关通用口径;只读 tab,无新增入口) -->
|
||||
<IntegrationCallLogsPanel v-else-if="activeTab === 'calls'" />
|
||||
|
||||
<!-- 能力清单 -->
|
||||
<div v-else class="admin-table-wrap">
|
||||
<table class="admin-table">
|
||||
|
||||
+32
-1
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/modules/integration-connector/api/integration-connector.api.ts
|
||||
* 集成连接器管理 API 客户端:客户端实例/接口定义/绑定/凭据引用 CRUD + 能力清单 + 连接测试。
|
||||
* 集成连接器管理 API 客户端:客户端实例/接口定义/绑定/凭据引用 CRUD + 能力清单 + 连接测试 + 调用日志查询。
|
||||
* 依赖:@/shared/api/client(requestJson / BusinessError)、@/shared/utils/auth。
|
||||
* 逻辑:薄封装后端 /api/integration-connector/* 全部端点;JSON 写请求带 Content-Type。
|
||||
* 错误码(INTEGRATION.*)由 requestJson 解析到四语言文案。
|
||||
@@ -9,6 +9,9 @@ import { requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type {
|
||||
IntegrationBindingRow,
|
||||
IntegrationCallDetail,
|
||||
IntegrationCallFilters,
|
||||
IntegrationCallLogRow,
|
||||
IntegrationCallResultRow,
|
||||
IntegrationCapabilityRow,
|
||||
IntegrationClientInstanceRow,
|
||||
@@ -121,3 +124,31 @@ export const updateIntegrationCredentialReference = (code: string, payload: Reco
|
||||
requestJson<IntegrationCredentialReferenceRow>(`${BASE}/credential-references/${encodeURIComponent(code)}`, {
|
||||
method: 'PUT', ...jsonAuth(), body: JSON.stringify(payload),
|
||||
});
|
||||
|
||||
// ---- 调用日志 ----
|
||||
|
||||
/**
|
||||
* 把调用日志筛选对象序列化为 querystring。
|
||||
* 约束:过滤 undefined / null / 空串(空筛选拼出无参 URL);数字(page/page_size)转字符串。
|
||||
* 返回值:形如 `?a=1&b=2`(无有效参数时为空串),直接拼接在端点路径后。
|
||||
*/
|
||||
function buildCallLogQuery(filters: IntegrationCallFilters): string {
|
||||
const search = new URLSearchParams();
|
||||
Object.entries(filters).forEach(([key, value]) => {
|
||||
if (value === undefined || value === null || String(value).trim() === '') return;
|
||||
search.set(key, String(value));
|
||||
});
|
||||
const qs = search.toString();
|
||||
return qs ? `?${qs}` : '';
|
||||
}
|
||||
|
||||
/** 集成调用日志分页查询(能力无关;keyword 对请求摘要 JSON 模糊)。 */
|
||||
export const listIntegrationCalls = (filters: IntegrationCallFilters = {}) =>
|
||||
requestJson<{ total: number; page: number; page_size: number; items: IntegrationCallLogRow[] }>(
|
||||
`${BASE}/calls${buildCallLogQuery(filters)}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 调用全量详情(含 wire_json 与同 operation_id 步骤时间线)。 */
|
||||
export const getIntegrationCall = (id: number) =>
|
||||
requestJson<IntegrationCallDetail>(`${BASE}/calls/${id}`, auth());
|
||||
+493
@@ -0,0 +1,493 @@
|
||||
<!--
|
||||
features/admin/modules/integration-connector/components/IntegrationCallLogsPanel.vue
|
||||
用途:集成调用日志面板——筛选条 + 分页列表 + 行点击详情抽屉(能力无关通用口径)。
|
||||
依赖:../api/integration-connector.api(listIntegrationCalls / getIntegrationCall)、
|
||||
../utils/integration-call-replay(buildCurl / buildSqlReplay)、
|
||||
useMessage、copyTextToClipboard、formatLocalDateTime、useI18n。
|
||||
逻辑:筛选(接口编码/客户端编码/连接类型/状态/operation_id/trace_id/业务单号/
|
||||
参数关键字/执行时间起止)回车或点「查询」生效(查询回第一页),「重置」清空;
|
||||
列表按 id 倒序分页,行点击拉取全量详情开右侧抽屉;抽屉含步骤时间线
|
||||
(同 operation_id 各步、当前步高亮)、线级请求与业务参数双栏、原始报文与
|
||||
归一化 JSON 双栏;复制按钮组按连接类型分流:soap/rest=复制 body / 复制 curl,
|
||||
database=复制 SQL(绑定已内联、写入类自动包事务并红字警示),
|
||||
另有复制原始报文 / 复制 JSON / 复制 operation_id / 复制 trace_id;
|
||||
wire_json 为 NULL(历史存量行)时如实显示「无线级详情(历史记录)」,不回填。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ChevronLeft, ChevronRight, X } from 'lucide-vue-next';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { copyTextToClipboard } from '@/shared/utils/clipboard';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import { getIntegrationCall, listIntegrationCalls } from '../api/integration-connector.api';
|
||||
import {
|
||||
CONNECTOR_TYPE_OPTIONS,
|
||||
type IntegrationCallDetail,
|
||||
type IntegrationCallFilters,
|
||||
type IntegrationCallLogRow,
|
||||
type IntegrationCallWire,
|
||||
} from '../types/integration-connector.types';
|
||||
import { buildCurl, buildSqlReplay } from '../utils/integration-call-replay';
|
||||
|
||||
/**
|
||||
* 调用状态固定枚举(与后端 RESULT_STATUSES 七值对齐,含幂等重放的
|
||||
* duplicate_success / duplicate_unverified 审计行;下拉直接用原始值,未注册翻译兜底)。
|
||||
*/
|
||||
const CALL_STATUS_OPTIONS = [
|
||||
'success', 'duplicate_success', 'duplicate_unverified', 'business_failed',
|
||||
'technical_failed', 'timeout', 'result_unknown',
|
||||
] as const;
|
||||
|
||||
const { t } = useI18n();
|
||||
const { error: notifyError, success: notifySuccess } = useMessage();
|
||||
|
||||
const filters = ref<IntegrationCallFilters>({});
|
||||
const items = ref<IntegrationCallLogRow[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
const pageSize = 20;
|
||||
const loading = ref(false);
|
||||
const detail = ref<IntegrationCallDetail | null>(null);
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(total.value / pageSize)));
|
||||
|
||||
/** 当前详情的线级事实(null = 历史存量行或未捕获场景,抽屉如实显示「无线级详情」)。 */
|
||||
const wire = computed<IntegrationCallWire | null>(() => detail.value?.call.wire_json ?? null);
|
||||
|
||||
/** soap/rest 的 wire 头部元信息(method/url/SOAPAction/headers)拼接为多行文本。 */
|
||||
const wireMetaText = computed(() => {
|
||||
const w = wire.value;
|
||||
if (!w || w.kind === 'database') return '';
|
||||
const lines = [`method: ${w.method ?? '-'}`, `url: ${w.url ?? '-'}`];
|
||||
if (w.soap_action !== undefined) lines.push(`SOAPAction: ${w.soap_action}`);
|
||||
if (w.headers) lines.push(`headers: ${w.headers}`);
|
||||
return lines.join('\n');
|
||||
});
|
||||
|
||||
/** database 的 SQL 复现文本(绑定已内联;写入类自动包 BEGIN…ROLLBACK 事务)。 */
|
||||
const sqlReplayText = computed(() =>
|
||||
wire.value && wire.value.kind === 'database' ? buildSqlReplay(wire.value) : '',
|
||||
);
|
||||
|
||||
/** database 写入类语句红字警示显隐(防复现时误写目标库)。 */
|
||||
const hasWriteStatement = computed(() =>
|
||||
(wire.value?.statements ?? []).some((s) => /^\s*(INSERT|UPDATE|DELETE|MERGE)/im.test(s.sql)),
|
||||
);
|
||||
|
||||
/** soap/rest 的 curl 复现命令(凭据位 ***REDACTED***,需手工替换)。 */
|
||||
const curlCommand = computed(() =>
|
||||
wire.value && wire.value.kind !== 'database' ? buildCurl(wire.value) : '',
|
||||
);
|
||||
|
||||
/** 响应区原始报文文本:soap/rest=HTTP 状态行 + 响应报文;database=查询行集(无线级时兜底行数)。 */
|
||||
const rawResponseText = computed(() => {
|
||||
const w = wire.value;
|
||||
if (!w) return '';
|
||||
if (w.kind === 'database') {
|
||||
return w.rows ? prettyJson(w.rows) : `rowcount: ${w.rowcount ?? '-'}`;
|
||||
}
|
||||
return `HTTP ${w.http_status ?? '-'}\n${w.response_body ?? ''}`;
|
||||
});
|
||||
|
||||
/** 拉取列表(当前筛选 + 当前页);失败经全局错误弹窗提示。 */
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await listIntegrationCalls({ ...filters.value, page: page.value, page_size: pageSize });
|
||||
items.value = data.items;
|
||||
total.value = data.total;
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 应用筛选并回第一页(回车或「查询」按钮触发)。 */
|
||||
function query() {
|
||||
page.value = 1;
|
||||
void load();
|
||||
}
|
||||
|
||||
/** 清空全部筛选项并回第一页重新拉取。 */
|
||||
function resetFilters() {
|
||||
filters.value = {};
|
||||
query();
|
||||
}
|
||||
|
||||
function goPrev() {
|
||||
if (page.value > 1) {
|
||||
page.value -= 1;
|
||||
void load();
|
||||
}
|
||||
}
|
||||
|
||||
function goNext() {
|
||||
if (page.value < totalPages.value) {
|
||||
page.value += 1;
|
||||
void load();
|
||||
}
|
||||
}
|
||||
|
||||
/** 点列表行拉全量详情(含 wire_json 与同 operation_id 时间线)并开抽屉。 */
|
||||
async function openDetail(row: IntegrationCallLogRow) {
|
||||
try {
|
||||
detail.value = await getIntegrationCall(row.id);
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
}
|
||||
}
|
||||
|
||||
function closeDetail() {
|
||||
detail.value = null;
|
||||
}
|
||||
|
||||
/** 抽屉打开时 Esc 关闭(与表单抽屉行为一致)。 */
|
||||
function onEscKey(e: KeyboardEvent) {
|
||||
if (e.key === 'Escape' && detail.value) closeDetail();
|
||||
}
|
||||
|
||||
/** 复制文本到剪贴板(带降级方案),成功后弹「已复制」提示。 */
|
||||
async function copy(text: string) {
|
||||
const ok = await copyTextToClipboard(text);
|
||||
if (ok) notifySuccess(t('admin.integrationConnector.callLogs.copied'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用成功族判定:success 与 duplicate_success(幂等重放命中,业务已成功)同属成功侧;
|
||||
* duplicate_unverified(重放命中但回执未核实)保守归非成功态展示。
|
||||
*/
|
||||
function isSuccess(status: string): boolean {
|
||||
return status === 'success' || status === 'duplicate_success';
|
||||
}
|
||||
|
||||
/** 状态徽标配色:成功绿 / 其余红。 */
|
||||
function statusBadgeClass(status: string): string {
|
||||
return isSuccess(status) ? 'bg-green-100 text-green-700' : 'bg-red-100 text-red-700';
|
||||
}
|
||||
|
||||
/** 状态图标:✓ 成功 / ✗ 失败。 */
|
||||
function statusIcon(status: string): string {
|
||||
return isSuccess(status) ? '✓' : '✗';
|
||||
}
|
||||
|
||||
/** 单号列文本:优先业务单号 business_ref,未透传时回退 operation_id 前 8 位。 */
|
||||
function refTextOf(row: IntegrationCallLogRow): string {
|
||||
return row.business_ref || row.operation_id.slice(0, 8);
|
||||
}
|
||||
|
||||
/** 步骤列文本:1-based 序号/总步数(对用户展示从 1 计;存储的 step_index 为 0-based 引擎下标;缺值显示 -)。 */
|
||||
function stepText(row: IntegrationCallLogRow): string {
|
||||
if (row.step_index === null || row.step_index === undefined) return '-/-';
|
||||
return `${row.step_index + 1}/${row.step_count ?? '?'}`;
|
||||
}
|
||||
|
||||
/** 时间线步骤标签:1-based 序号(与列表口径一致)。 */
|
||||
function stepLabel(entry: { step_index: number | null; step_count: number | null }, idx: number): string {
|
||||
const base = entry.step_index ?? idx;
|
||||
return `step${base + 1}`;
|
||||
}
|
||||
|
||||
/** 语句行数:rowcount / row_count 双字段名并存(实现版本差异),两者都读。 */
|
||||
function statementRowCount(s: { rowcount?: number; row_count?: number }): string {
|
||||
const n = s.rowcount ?? s.row_count;
|
||||
return n === undefined ? '' : String(n);
|
||||
}
|
||||
|
||||
/** 时间线条目是否为当前查看的调用(抽屉时间线高亮当前步)。 */
|
||||
function isCurrentStep(entry: IntegrationCallDetail['timeline'][number]): boolean {
|
||||
return detail.value != null && entry.id === detail.value.call.id;
|
||||
}
|
||||
|
||||
function prettyJson(value: unknown): string {
|
||||
return JSON.stringify(value, null, 2);
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
window.addEventListener('keydown', onEscKey);
|
||||
void load();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
window.removeEventListener('keydown', onEscKey);
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<!-- 筛选条:全部可选,回车 / 点查询生效 -->
|
||||
<div class="rounded-xl border border-default bg-surface p-4 space-y-3">
|
||||
<div class="grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5" @keyup.enter="query">
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterInterface') }}</label>
|
||||
<input v-model="filters.interface_code" type="text" class="input-field text-sm font-mono" data-testid="call-filter-interface" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterClient') }}</label>
|
||||
<input v-model="filters.client_code" type="text" class="input-field text-sm font-mono" data-testid="call-filter-client" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterConnector') }}</label>
|
||||
<select v-model="filters.connector_type" class="input-field text-sm" data-testid="call-filter-connector">
|
||||
<option value="">—</option>
|
||||
<option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value">{{ t(opt.labelKey) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterStatus') }}</label>
|
||||
<select v-model="filters.status" class="input-field text-sm font-mono" data-testid="call-filter-status">
|
||||
<option value="">—</option>
|
||||
<option v-for="s in CALL_STATUS_OPTIONS" :key="s" :value="s">{{ s }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterOperationId') }}</label>
|
||||
<input v-model="filters.operation_id" type="text" class="input-field text-sm font-mono" data-testid="call-filter-operation-id" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterTraceId') }}</label>
|
||||
<input v-model="filters.trace_id" type="text" class="input-field text-sm font-mono" data-testid="call-filter-trace-id" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}</label>
|
||||
<input v-model="filters.business_ref" type="text" class="input-field text-sm font-mono" data-testid="call-filter-business-ref" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.filterKeyword') }}</label>
|
||||
<input v-model="filters.keyword" type="text" class="input-field text-sm" data-testid="call-filter-keyword" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.dateFrom') }}</label>
|
||||
<input v-model="filters.date_from" type="date" class="input-field text-sm" data-testid="call-filter-date-from" />
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.callLogs.dateTo') }}</label>
|
||||
<input v-model="filters.date_to" type="date" class="input-field text-sm" data-testid="call-filter-date-to" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<button type="button" class="btn-primary" data-testid="call-filter-query" @click="query">
|
||||
{{ t('admin.integrationConnector.callLogs.query') }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost" data-testid="call-filter-reset" @click="resetFilters">
|
||||
{{ t('admin.integrationConnector.callLogs.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 调用记录列表(id 倒序;行点击开详情抽屉) -->
|
||||
<div class="admin-table-wrap" :class="loading ? 'opacity-60 pointer-events-none' : ''">
|
||||
<div class="px-4 py-3 flex items-center justify-between">
|
||||
<h4 class="text-sm font-bold text-primary">{{ t('admin.integrationConnector.callLogs.title') }}</h4>
|
||||
<span class="text-xs text-muted font-mono">({{ total }})</span>
|
||||
</div>
|
||||
<table class="admin-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left text-xs w-16">#</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colTime') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colCapability') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colInterface') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs">{{ t('admin.integrationConnector.callLogs.colRef') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs w-20">{{ t('admin.integrationConnector.callLogs.colStep') }}</th>
|
||||
<th class="px-4 py-3 text-left text-xs w-44">{{ t('admin.integrationConnector.callLogs.colStatus') }}</th>
|
||||
<th class="px-4 py-3 text-right text-xs w-24">{{ t('admin.integrationConnector.callLogs.colElapsed') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-if="items.length === 0">
|
||||
<td colspan="8" class="px-6 admin-table-empty">{{ t('admin.integrationConnector.empty') }}</td>
|
||||
</tr>
|
||||
<tr
|
||||
v-for="row in items"
|
||||
:key="row.id"
|
||||
data-testid="call-row"
|
||||
class="cursor-pointer hover:bg-surface-soft transition-colors"
|
||||
@click="openDetail(row)"
|
||||
>
|
||||
<td class="px-4 py-3 text-xs text-muted font-mono">{{ row.id }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary font-mono whitespace-nowrap">{{ formatLocalDateTime(row.created_at) }}</td>
|
||||
<td class="px-4 py-3 text-xs font-mono text-secondary max-w-[220px]"><span class="block truncate" :title="row.capability">{{ row.capability }}</span></td>
|
||||
<td class="px-4 py-3 text-xs font-mono text-secondary max-w-[200px]"><span class="block truncate" :title="row.interface_code || ''">{{ row.interface_code || '—' }}</span></td>
|
||||
<td class="px-4 py-3 text-xs font-mono text-secondary" :title="row.business_ref || row.operation_id">{{ refTextOf(row) }}</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary font-mono">{{ stepText(row) }}</td>
|
||||
<td class="px-4 py-3">
|
||||
<span class="inline-flex items-center rounded-full px-2.5 py-0.5 text-xs font-medium font-mono" :class="statusBadgeClass(row.status)">
|
||||
{{ statusIcon(row.status) }} {{ row.status }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-xs text-secondary font-mono text-right whitespace-nowrap">{{ row.elapsed_ms }}ms</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<div class="flex items-center justify-end gap-3 px-4 py-3 text-xs text-secondary">
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
:title="t('admin.integrationConnector.callLogs.prevPage')"
|
||||
data-testid="call-prev-page"
|
||||
:disabled="page <= 1 || loading"
|
||||
@click="goPrev"
|
||||
>
|
||||
<ChevronLeft class="w-4 h-4" />
|
||||
</button>
|
||||
<span class="font-mono">{{ page }} / {{ totalPages }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="p-1.5 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary disabled:opacity-40 disabled:cursor-not-allowed"
|
||||
:title="t('admin.integrationConnector.callLogs.nextPage')"
|
||||
data-testid="call-next-page"
|
||||
:disabled="page >= totalPages || loading"
|
||||
@click="goNext"
|
||||
>
|
||||
<ChevronRight class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 详情抽屉:右侧滑出(步骤时间线 + 线级/归一化双栏 + 复现命令复制) -->
|
||||
<div
|
||||
v-if="detail"
|
||||
class="fixed inset-0 z-50 flex justify-end bg-overlay animate-fade-in"
|
||||
data-testid="call-detail-drawer"
|
||||
@click.self="closeDetail"
|
||||
>
|
||||
<aside role="dialog" aria-modal="true" :aria-label="t('admin.integrationConnector.callLogs.detailTitle')" class="h-full w-full max-w-4xl flex flex-col bg-surface shadow-2xl outline-none">
|
||||
<div class="px-5 sm:px-8 pt-5 sm:pt-6 pb-4 border-b border-default shrink-0 space-y-2">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<h3 class="section-title">{{ t('admin.integrationConnector.callLogs.detailTitle') }} #{{ detail.call.id }}</h3>
|
||||
<button type="button" class="p-2 rounded-lg text-muted hover:bg-surface-soft hover:text-secondary" :aria-label="t('admin.cancel')" data-testid="call-detail-close" @click="closeDetail">
|
||||
<X class="w-4 h-4" />
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-x-6 gap-y-1 text-xs text-secondary">
|
||||
<span><span class="text-muted">{{ t('admin.integrationConnector.callLogs.colCapability') }}: </span><span class="font-mono">{{ detail.call.capability }}</span></span>
|
||||
<span>
|
||||
<span class="text-muted">{{ t('admin.integrationConnector.callLogs.colStatus') }}: </span>
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium font-mono" :class="statusBadgeClass(detail.call.status)">
|
||||
{{ statusIcon(detail.call.status) }} {{ detail.call.status }}
|
||||
</span>
|
||||
</span>
|
||||
<span><span class="text-muted">{{ t('admin.integrationConnector.callLogs.colElapsed') }}: </span><span class="font-mono">{{ detail.call.elapsed_ms }}ms</span></span>
|
||||
<span v-if="detail.call.business_ref">
|
||||
<span class="text-muted">{{ t('admin.integrationConnector.callLogs.filterBusinessRef') }}: </span><span class="font-mono">{{ detail.call.business_ref }}</span>
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-x-6 gap-y-1 text-xs">
|
||||
<span class="flex items-center gap-1.5 min-w-0">
|
||||
<span class="text-muted font-mono shrink-0">operation:</span>
|
||||
<span class="font-mono text-secondary truncate max-w-[240px]" :title="detail.call.operation_id">{{ detail.call.operation_id }}</span>
|
||||
<button type="button" class="px-1.5 py-0.5 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 shrink-0" data-testid="call-copy-operation-id" @click="copy(detail.call.operation_id)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyOperationId') }}
|
||||
</button>
|
||||
</span>
|
||||
<span class="flex items-center gap-1.5 min-w-0">
|
||||
<span class="text-muted font-mono shrink-0">trace:</span>
|
||||
<span class="font-mono text-secondary truncate max-w-[240px]" :title="detail.call.trace_id">{{ detail.call.trace_id }}</span>
|
||||
<button type="button" class="px-1.5 py-0.5 rounded-md text-xs font-medium text-brand-600 hover:bg-brand-50 shrink-0" data-testid="call-copy-trace-id" @click="copy(detail.call.trace_id)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyTraceId') }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="px-5 sm:px-8 py-5 space-y-5 overflow-y-auto flex-1">
|
||||
<!-- 步骤时间线:同一次能力调用的 N 步(当前步高亮) -->
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.timeline') }}</h4>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<template v-for="(entry, idx) in detail.timeline" :key="entry.id">
|
||||
<div class="flex items-center gap-1.5 rounded-lg px-2.5 py-1.5 text-xs" :class="isCurrentStep(entry) ? 'bg-brand-50 ring-1 ring-brand-300' : 'bg-surface-soft'">
|
||||
<span class="inline-block w-2 h-2 rounded-full shrink-0" :class="isSuccess(entry.status) ? 'bg-green-500' : 'bg-red-500'" />
|
||||
<span class="font-mono text-muted">{{ stepLabel(entry, idx) }}</span>
|
||||
<span class="text-secondary font-medium font-mono">{{ entry.interface_code || '—' }}</span>
|
||||
<span class="font-mono" :class="isSuccess(entry.status) ? 'text-green-600' : 'text-red-600'">{{ statusIcon(entry.status) }} {{ entry.status }}</span>
|
||||
<span class="text-muted font-mono">{{ entry.elapsed_ms }}ms</span>
|
||||
</div>
|
||||
<span v-if="idx < detail.timeline.length - 1" class="text-muted" aria-hidden="true">──</span>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 请求:线级请求(wire)+ 业务参数(归一化)双栏 -->
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.request') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.wire') }}</h5>
|
||||
<template v-if="wire">
|
||||
<!-- soap/rest:method/url/SOAPAction/headers + 完整请求 body XML -->
|
||||
<template v-if="wire.kind !== 'database'">
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ wireMetaText }}</pre>
|
||||
<div class="text-xs text-muted font-mono">── request_body ──</div>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ wire.request_body }}</pre>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-body" @click="copy(wire.request_body || '')">
|
||||
{{ t('admin.integrationConnector.callLogs.copyBody') }}
|
||||
</button>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-curl" @click="copy(curlCommand)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyCurl') }}
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
<!-- database:pre/bulk/post 三段最终 SQL + 绑定首行 + 行数;写入类红字警示 -->
|
||||
<template v-else>
|
||||
<div v-for="(s, idx) in wire.statements || []" :key="idx" class="space-y-1">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="inline-flex items-center rounded-full px-2 py-0.5 text-xs font-medium bg-surface-soft text-secondary font-mono">{{ s.phase }}</span>
|
||||
<span v-if="statementRowCount(s)" class="text-xs text-muted font-mono">rows: {{ statementRowCount(s) }}</span>
|
||||
</div>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all">{{ s.sql }}</pre>
|
||||
<pre v-if="s.binds && Object.keys(s.binds).length > 0" class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-muted whitespace-pre-wrap break-all">{{ prettyJson(s.binds) }}</pre>
|
||||
</div>
|
||||
<div v-if="wire.rowcount !== undefined" class="text-xs text-muted font-mono">rowcount: {{ wire.rowcount }}</div>
|
||||
<p v-if="hasWriteStatement" class="text-xs font-medium text-red-600" data-testid="call-sql-write-warning">
|
||||
{{ t('admin.integrationConnector.callLogs.sqlWriteWarning') }}
|
||||
</p>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-sql" @click="copy(sqlReplayText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copySql') }}
|
||||
</button>
|
||||
</template>
|
||||
</template>
|
||||
<!-- 历史存量行 / 未捕获场景:wire_json 为 NULL,如实展示不回填 -->
|
||||
<p v-else class="text-xs text-muted" data-testid="call-no-wire">
|
||||
{{ t('admin.integrationConnector.callLogs.noWire') }}
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.normalized') }}</h5>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ prettyJson(detail.call.request_summary_json) }}</pre>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-request-json" @click="copy(prettyJson(detail.call.request_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 响应:原始报文 + 归一化 JSON 双栏 -->
|
||||
<section class="space-y-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.callLogs.response') }}</h4>
|
||||
<div class="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.rawPayload') }}</h5>
|
||||
<pre v-if="wire" class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ rawResponseText }}</pre>
|
||||
<p v-else class="text-xs text-muted" data-testid="call-no-wire-response">{{ t('admin.integrationConnector.callLogs.noWire') }}</p>
|
||||
<button v-if="wire" type="button" class="btn-ghost text-xs" data-testid="call-copy-raw" @click="copy(rawResponseText)">
|
||||
{{ t('admin.integrationConnector.callLogs.copyRaw') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="rounded-xl border border-default p-3 space-y-2 min-w-0">
|
||||
<h5 class="text-xs font-bold text-primary">{{ t('admin.integrationConnector.callLogs.normalizedJson') }}</h5>
|
||||
<pre class="rounded-lg bg-surface-soft p-2.5 text-xs font-mono text-secondary whitespace-pre-wrap break-all max-h-72 overflow-y-auto">{{ prettyJson(detail.call.response_summary_json) }}</pre>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="call-copy-response-json" @click="copy(prettyJson(detail.call.response_summary_json))">
|
||||
{{ t('admin.integrationConnector.callLogs.copyJson') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
+150
-10
@@ -1,8 +1,9 @@
|
||||
/**
|
||||
* features/admin/modules/integration-connector/components/IntegrationConnectorFormDrawer.spec.ts
|
||||
* 用途:锁定表单按连接器类型动态显示字段——REST 显示超时/HTTP方法/请求路径,
|
||||
* SOAP 显示 WSDL;以及抽屉化后的 JSON 编辑字段(格式化/失焦校验)、
|
||||
* 脏检查关闭确认与 Esc 关闭行为。
|
||||
* SOAP 显示 WSDL,database 显示 db_kind 专属下拉与数据库连接串 label;
|
||||
* 绑定表单的有序步骤编辑器(添加/删除/上移下移/每步独立参数映射);
|
||||
* 以及抽屉化后的 JSON 编辑字段(格式化/失焦校验)、脏检查关闭确认与 Esc 关闭行为。
|
||||
* 依赖:@vue/test-utils、vitest、i18n。
|
||||
* 逻辑:切换 connector_type 断言字段可见性;对 JsonTextareaField 断言格式化改写
|
||||
* 与非法 JSON 提示;mock window.confirm 断言脏表单关闭拦截与放行。
|
||||
@@ -13,11 +14,13 @@ import i18n from '@/i18n';
|
||||
import IntegrationConnectorFormDrawer from './IntegrationConnectorFormDrawer.vue';
|
||||
import JsonTextareaField from './JsonTextareaField.vue';
|
||||
import {
|
||||
bindingRowToForm,
|
||||
createEmptyClientInstanceForm,
|
||||
createEmptyInterfaceDefinitionForm,
|
||||
createEmptyBindingForm,
|
||||
createEmptyCredentialReferenceForm,
|
||||
type InterfaceDefinitionFormState,
|
||||
type IntegrationBindingRow,
|
||||
} from '../types/integration-connector.types';
|
||||
|
||||
enableAutoUnmount(afterEach);
|
||||
@@ -117,7 +120,7 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
expect(chip.attributes('title')).toContain('发布');
|
||||
});
|
||||
|
||||
it('绑定:选定接口定义后客户端实例自动带出并锁定', async () => {
|
||||
it('绑定:添加步骤并选接口后,只读提示该步接口归属的客户端实例', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountDrawer({
|
||||
activeEntity: 'binding',
|
||||
@@ -128,12 +131,12 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
],
|
||||
interfaceOptions: [{ code: '1001-iface', name: '接口A', client_instance_code: '1001' }],
|
||||
});
|
||||
// 未选接口定义前客户端实例可维护
|
||||
expect(wrapper.find('[data-testid="binding-client"]').attributes('disabled')).toBeUndefined();
|
||||
await wrapper.find('[data-testid="binding-interface"]').setValue('1001-iface');
|
||||
// 选定接口定义后:客户端实例按接口归属联动带出且锁定
|
||||
expect(bindingForm.client_instance_code).toBe('1001');
|
||||
expect(wrapper.find('[data-testid="binding-client"]').attributes('disabled')).toBeDefined();
|
||||
// 绑定表单不再单独维护客户端实例下拉(client 由各步接口归属自带)
|
||||
expect(wrapper.find('[data-testid="binding-client"]').exists()).toBe(false);
|
||||
// 添加一步并选择接口定义 → 只读提示其归属客户端实例
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('1001-iface');
|
||||
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('1001');
|
||||
});
|
||||
|
||||
it('绑定能力下拉选项本地化:有翻译显示「中文名(注册名)」,无翻译兜底注册名', () => {
|
||||
@@ -153,6 +156,143 @@ describe('IntegrationConnectorFormDrawer connector-type fields', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('IntegrationConnectorFormDrawer database connector type', () => {
|
||||
it('类型下拉含「数据库直连」;选中后显示 db_kind 四选一下拉、数据库连接串 label,超时照显', async () => {
|
||||
const wrapper = mountDrawer();
|
||||
const typeOptions = wrapper.find('[data-testid="client-connector-type"]').findAll('option');
|
||||
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
// 非 database 类型不渲染 db_kind 下拉
|
||||
expect(wrapper.find('[data-testid="client-db-kind"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
|
||||
const dbKind = wrapper.find('[data-testid="client-db-kind"]');
|
||||
expect(dbKind.exists()).toBe(true);
|
||||
// db_kind 专属下拉四选一(含未选占位项),label 即库名
|
||||
expect(dbKind.findAll('option').map((o) => o.text())).toEqual(['—', 'MySQL', 'Oracle', 'SQL Server', 'PostgreSQL']);
|
||||
// endpoint label 切换为数据库连接串语义;超时字段照常显示
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
expect(labels.some((t) => t.includes('数据库连接串'))).toBe(true);
|
||||
expect(wrapper.find('[data-testid="client-timeout"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('database 类型不显示 HTTP 方法/请求路径(接口表单随客户端联动 database 类型)', async () => {
|
||||
const interfaceForm = createEmptyInterfaceDefinitionForm();
|
||||
const wrapper = mountDrawer({
|
||||
activeEntity: 'interface',
|
||||
interfaceForm,
|
||||
clientOptions: [{ code: 'erp-db', name: 'ERP Oracle', connector_type: 'database' }],
|
||||
});
|
||||
await wrapper.find('[data-testid="interface-client"]').setValue('erp-db');
|
||||
// 接口类型随客户端联动为 database
|
||||
expect(interfaceForm.connector_type).toBe('database');
|
||||
const labels = wrapper.findAll('label').map((l) => l.text());
|
||||
expect(labels.some((t) => t.includes('HTTP 方法'))).toBe(false);
|
||||
expect(labels.some((t) => t.includes('请求路径'))).toBe(false);
|
||||
// 类型只读下拉显示本地化 database 文案
|
||||
expect(wrapper.find('[data-testid="interface-connector-type"]').text()).toContain('数据库直连');
|
||||
});
|
||||
|
||||
it('切回非 database 类型后 db_kind 下拉隐藏且残留值清空', async () => {
|
||||
const clientForm = createEmptyClientInstanceForm();
|
||||
const wrapper = mountDrawer({ clientForm });
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
|
||||
await wrapper.find('[data-testid="client-db-kind"]').setValue('oracle');
|
||||
expect(clientForm.db_kind).toBe('oracle');
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('rest');
|
||||
expect(wrapper.find('[data-testid="client-db-kind"]').exists()).toBe(false);
|
||||
expect(clientForm.db_kind).toBe('');
|
||||
});
|
||||
|
||||
it('database 类型高级配置提示列出生效键 oracle_lib_dir', async () => {
|
||||
const wrapper = mountDrawer();
|
||||
await wrapper.find('[data-testid="client-connector-type"]').setValue('database');
|
||||
expect(wrapper.text()).toContain('"oracle_lib_dir"');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IntegrationConnectorFormDrawer binding steps editor', () => {
|
||||
function mountBinding(overrides: Partial<Record<string, unknown>> = {}) {
|
||||
return mountDrawer({
|
||||
activeEntity: 'binding',
|
||||
clientOptions: [
|
||||
{ code: 'erp-db', name: 'ERP Oracle', connector_type: 'database' },
|
||||
{ code: 'tiptop-ws', name: '鼎捷WS', connector_type: 'soap' },
|
||||
],
|
||||
interfaceOptions: [
|
||||
{ code: 'IF-STAGE', name: '写中间表', client_instance_code: 'erp-db' },
|
||||
{ code: 'IF-SUBMIT', name: '触发WS', client_instance_code: 'tiptop-ws' },
|
||||
],
|
||||
...overrides,
|
||||
});
|
||||
}
|
||||
|
||||
it('接口从单选改为有序多选:添加两步,每步独立接口下拉与归属客户端只读提示', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
// 空态无步骤行
|
||||
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(0);
|
||||
// 添加两步
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
expect(bindingForm.steps).toHaveLength(2);
|
||||
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('IF-STAGE');
|
||||
await wrapper.find('[data-testid="binding-step-interface-1"]').setValue('IF-SUBMIT');
|
||||
// 每步显示归属客户端只读提示(跨客户端步骤:database + soap)
|
||||
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('erp-db');
|
||||
expect(wrapper.find('[data-testid="binding-step-client-1"]').text()).toContain('tiptop-ws');
|
||||
});
|
||||
|
||||
it('上移/下移重排步骤顺序;首步无上移、末步无下移(禁用)', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-step-interface-0"]').setValue('IF-STAGE');
|
||||
await wrapper.find('[data-testid="binding-step-interface-1"]').setValue('IF-SUBMIT');
|
||||
expect(wrapper.find('[data-testid="binding-step-up-0"]').attributes('disabled')).toBeDefined();
|
||||
expect(wrapper.find('[data-testid="binding-step-down-1"]').attributes('disabled')).toBeDefined();
|
||||
// 下移首步 → 顺序翻转
|
||||
await wrapper.find('[data-testid="binding-step-down-0"]').trigger('click');
|
||||
expect(bindingForm.steps[0].interface_code).toBe('IF-SUBMIT');
|
||||
expect(bindingForm.steps[1].interface_code).toBe('IF-STAGE');
|
||||
// 再上移还原
|
||||
await wrapper.find('[data-testid="binding-step-up-1"]').trigger('click');
|
||||
expect(bindingForm.steps[0].interface_code).toBe('IF-STAGE');
|
||||
expect(bindingForm.steps[1].interface_code).toBe('IF-SUBMIT');
|
||||
});
|
||||
|
||||
it('删除步骤移除对应行;每步参数映射独立编辑写回对应步骤', async () => {
|
||||
const bindingForm = createEmptyBindingForm();
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
await wrapper.find('[data-testid="binding-add-step"]').trigger('click');
|
||||
// 每步独立的 param_mapping JSON 编辑(沿用 JsonTextareaField 交互)
|
||||
const stepRows = wrapper.findAll('[data-testid="binding-step-row"]');
|
||||
await stepRows[0].findComponent(JsonTextareaField).find('[data-testid="json-textarea"]')
|
||||
.setValue('{"erp_org":{"expr":"external_org"}}');
|
||||
expect(bindingForm.steps[0].param_mapping_json).toBe('{"erp_org":{"expr":"external_org"}}');
|
||||
expect(bindingForm.steps[1].param_mapping_json).toBe('');
|
||||
// 删除首步 → 只剩原第二步
|
||||
await wrapper.find('[data-testid="binding-step-remove-0"]').trigger('click');
|
||||
expect(bindingForm.steps).toHaveLength(1);
|
||||
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(1);
|
||||
});
|
||||
|
||||
it('既有单接口绑定编辑回归:steps_json 单步行回显为一步且接口预选', () => {
|
||||
const bindingForm = bindingRowToForm({
|
||||
id: 5, capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
|
||||
steps_json: [{ interface_code: 'IF-STAGE', param_mapping_json: { erp_org: { expr: 'external_org' } } }],
|
||||
param_mapping_json: { erp_org: { expr: 'external_org' } },
|
||||
client_instance_code: 'erp-db', interface_definition_code: 'IF-STAGE',
|
||||
mapping_version: 1, priority: 0, environment: 'prod',
|
||||
effective_from: null, effective_to: null, status: 'draft',
|
||||
} as IntegrationBindingRow);
|
||||
const wrapper = mountBinding({ bindingForm });
|
||||
expect(wrapper.findAll('[data-testid="binding-step-row"]').length).toBe(1);
|
||||
expect((wrapper.find('[data-testid="binding-step-interface-0"]').element as HTMLSelectElement).value).toBe('IF-STAGE');
|
||||
expect(wrapper.find('[data-testid="binding-step-client-0"]').text()).toContain('erp-db');
|
||||
});
|
||||
});
|
||||
|
||||
describe('IntegrationConnectorFormDrawer JSON fields', () => {
|
||||
function findJsonField(wrapper: ReturnType<typeof mountDrawer>, labelPart: string) {
|
||||
const field = wrapper
|
||||
@@ -363,7 +503,7 @@ describe('IntegrationConnectorFormDrawer client form redesign', () => {
|
||||
const code = wrapper.find('[data-testid="client-code"]');
|
||||
expect((code.element as HTMLInputElement).disabled).toBe(true);
|
||||
const typeOptions = wrapper.find('[data-testid="client-connector-type"]').findAll('option');
|
||||
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务']);
|
||||
expect(typeOptions.map((o) => o.text())).toEqual(['REST API', 'SOAP 服务', '数据库直连']);
|
||||
const envOptions = wrapper.find('[data-testid="client-environment"]').findAll('option');
|
||||
expect(envOptions.map((o) => o.text())).toEqual(['开发', '测试', '生产']);
|
||||
});
|
||||
|
||||
+137
-34
@@ -7,10 +7,13 @@
|
||||
客户端编码留空时按名称自动建议、
|
||||
接口编码留空时按「客户端实例编码-名称」自动建议(均可手改,已填不覆盖,编辑态编码锁定);
|
||||
客户端实例的连接器类型/环境/凭据引用均为下拉(选项来自模块常量与凭据列表,未知值兜底);
|
||||
connector_type=database 时显示 db_kind 专属四选一下拉(必填校验在 composable 提交层),
|
||||
endpoint label 按类型切换(REST=接口地址 / SOAP=WSDL / database=数据库连接串),切离 database 清空 db_kind;
|
||||
接口定义的连接器类型随所选客户端实例联动只读展示(提交由后端以客户端为准推导);
|
||||
绑定的客户端实例随所选接口定义联动带出并锁定(接口归属即客户端归属);
|
||||
绑定的接口为有序步骤编辑器:添加/删除/上移下移,每步独立 param_mapping JSON,
|
||||
步骤归属客户端以只读提示展示(client 由各步接口自带,表单不再单独维护);
|
||||
绑定表单的能力下拉选项本地化为「中文名(注册名)」(未注册翻译兜底注册名);
|
||||
接口与绑定的状态均为只读徽章(发布/退役走列表生命周期按钮),四个 JSON 契约字段常显不折叠;
|
||||
接口与绑定的状态均为只读徽章(发布/退役走列表生命周期按钮),JSON 契约字段常显不折叠;
|
||||
凭据引用:状态不进表单(由列表生命周期按钮流转);编辑态以「基本信息」只读信息区
|
||||
展示编码/类型/来源/状态(label+值行,与接口定义只读字段同款式),新建态下拉选项
|
||||
文案本地化与列表一致;高级配置帮助文案按连接器类型的生效键动态切换。
|
||||
@@ -24,6 +27,7 @@ import JsonTextareaField from './JsonTextareaField.vue';
|
||||
import {
|
||||
CONNECTOR_CONFIG_KEYS,
|
||||
CONNECTOR_TYPE_OPTIONS,
|
||||
DB_KIND_OPTIONS,
|
||||
ENVIRONMENT_OPTIONS,
|
||||
suggestClientCode,
|
||||
suggestInterfaceCode,
|
||||
@@ -33,6 +37,7 @@ import type {
|
||||
ClientInstanceFormState,
|
||||
CredentialReferenceFormState,
|
||||
InterfaceDefinitionFormState,
|
||||
IntegrationConnectorType,
|
||||
} from '../types/integration-connector.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -43,9 +48,9 @@ const props = defineProps<{
|
||||
bindingForm: BindingFormState;
|
||||
credentialForm: CredentialReferenceFormState;
|
||||
isSaving: boolean;
|
||||
/** 客户端实例选项:connector_type 供接口表单联动展示连接器类型。 */
|
||||
/** 客户端实例选项:connector_type 供接口表单联动展示连接器类型;name 供步骤 client 只读提示。 */
|
||||
clientOptions: Array<{ code: string; name: string; connector_type?: string }>;
|
||||
/** 接口定义选项:client_instance_code 供绑定表单联动带出客户端实例。 */
|
||||
/** 接口定义选项:client_instance_code 供绑定步骤的归属客户端只读提示。 */
|
||||
interfaceOptions: Array<{ code: string; name: string; client_instance_code?: string }>;
|
||||
capabilityOptions: Array<{ name: string }>;
|
||||
credentialTypeOptions: Array<{ type: string; fields: Array<{ key: string; secret: boolean; required: boolean }> }>;
|
||||
@@ -103,6 +108,30 @@ function capabilityOptionLabel(name: string) {
|
||||
return label === name ? name : `${label}(${name})`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换客户端实例的连接器类型:非 database 类型清空 db_kind 残留值,
|
||||
* 避免切走后旧值随保存提交(database 时 db_kind 必填,校验在 composable 提交层)。
|
||||
*/
|
||||
function onConnectorTypeChange() {
|
||||
if (props.clientForm.connector_type !== 'database') {
|
||||
props.clientForm.db_kind = '';
|
||||
}
|
||||
}
|
||||
|
||||
/** 连接地址 label 按类型切换:REST=接口地址 / SOAP=WSDL 地址 / database=数据库连接串。 */
|
||||
const endpointLabelKey = computed(() => {
|
||||
if (props.clientForm.connector_type === 'database') return 'admin.integrationConnector.endpointLabel.database';
|
||||
if (props.clientForm.connector_type === 'soap') return 'admin.integrationConnector.fields.wsdl';
|
||||
return 'admin.integrationConnector.fields.endpoint';
|
||||
});
|
||||
|
||||
/** 连接地址占位符随 label 同步切换(示例格式按类型区分)。 */
|
||||
const endpointPlaceholderKey = computed(() => {
|
||||
if (props.clientForm.connector_type === 'database') return 'admin.integrationConnector.placeholders.database';
|
||||
if (props.clientForm.connector_type === 'soap') return 'admin.integrationConnector.placeholders.wsdl';
|
||||
return 'admin.integrationConnector.placeholders.endpoint';
|
||||
});
|
||||
|
||||
/** 接口编码仍为空且已选客户端实例时,按「客户端编码-名称」补建议(已手填不覆盖)。 */
|
||||
function suggestInterfaceCodeIfEmpty() {
|
||||
const form = props.interfaceForm;
|
||||
@@ -119,21 +148,45 @@ function onInterfaceNameBlur() {
|
||||
/** 切换接口的客户端实例:联动展示其连接器类型(仅展示,提交由后端以客户端为准推导),并补编码建议。 */
|
||||
function onInterfaceClientChange() {
|
||||
const selected = props.clientOptions.find((item) => item.code === props.interfaceForm.client_instance_code);
|
||||
if (selected?.connector_type === 'rest' || selected?.connector_type === 'soap') {
|
||||
props.interfaceForm.connector_type = selected.connector_type;
|
||||
const type = selected?.connector_type as IntegrationConnectorType | undefined;
|
||||
if (type && CONNECTOR_TYPE_OPTIONS.some((opt) => opt.value === type)) {
|
||||
props.interfaceForm.connector_type = type;
|
||||
}
|
||||
suggestInterfaceCodeIfEmpty();
|
||||
}
|
||||
|
||||
// ---- 绑定有序步骤编辑器:接口从单选改为有序多选,client 由各步接口归属自带 ----
|
||||
|
||||
/** 添加步骤:追加到末尾(新步骤默认未选接口、空映射)。 */
|
||||
function addBindingStep() {
|
||||
props.bindingForm.steps.push({ interface_code: '', param_mapping_json: '' });
|
||||
}
|
||||
|
||||
/** 删除指定步骤(按索引,删除后后续步骤序号自动前移)。 */
|
||||
function removeBindingStep(index: number) {
|
||||
props.bindingForm.steps.splice(index, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换绑定的接口定义:联动带出其所属客户端实例并锁定(接口归属即客户端归属)。
|
||||
* 后端创建/更新仍做成对校验(INTEGRATION.BINDING_PAIR_MISMATCH)兜底直连 API 的场景。
|
||||
* 上移/下移指定步骤:delta=-1 上移、+1 下移;越界直接忽略(按钮层已禁用,双保险)。
|
||||
*/
|
||||
function onBindingInterfaceChange() {
|
||||
const selected = props.interfaceOptions.find((item) => item.code === props.bindingForm.interface_definition_code);
|
||||
if (selected?.client_instance_code) {
|
||||
props.bindingForm.client_instance_code = selected.client_instance_code;
|
||||
}
|
||||
function moveBindingStep(index: number, delta: number) {
|
||||
const target = index + delta;
|
||||
const steps = props.bindingForm.steps;
|
||||
if (target < 0 || target >= steps.length) return;
|
||||
const [moved] = steps.splice(index, 1);
|
||||
if (!moved) return;
|
||||
steps.splice(target, 0, moved);
|
||||
}
|
||||
|
||||
/** 步骤归属客户端只读提示:由接口定义归属唯一确定(跨步可不同客户端,如 database+soap)。 */
|
||||
function bindingStepClientHint(index: number): string {
|
||||
const step = props.bindingForm.steps[index];
|
||||
const iface = props.interfaceOptions.find((item) => item.code === step?.interface_code);
|
||||
if (!iface?.client_instance_code) return '';
|
||||
const client = props.clientOptions.find((item) => item.code === iface.client_instance_code);
|
||||
const clientLabel = client ? optionLabel(client.name, client.code) : iface.client_instance_code;
|
||||
return t('admin.integrationConnector.bindingSteps.clientHint', { client: clientLabel });
|
||||
}
|
||||
|
||||
/** 高级配置示例(JSON 属代码示例,不入 i18n——字面大括号会破坏 vue-i18n 消息编译)。 */
|
||||
@@ -269,10 +322,18 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.connectorType') }}</label>
|
||||
<select v-model="clientForm.connector_type" class="input-field text-sm" data-testid="client-connector-type">
|
||||
<select v-model="clientForm.connector_type" class="input-field text-sm" data-testid="client-connector-type" @change="onConnectorTypeChange">
|
||||
<option v-for="opt in CONNECTOR_TYPE_OPTIONS" :key="opt.value" :value="opt.value">{{ t(opt.labelKey) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div v-if="clientForm.connector_type === 'database'" class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.dbKind') }}</label>
|
||||
<!-- db_kind 专属四选一(D16):仅 database 类型显示;未选提交由 composable 校验拦截 -->
|
||||
<select v-model="clientForm.db_kind" class="input-field text-sm" data-testid="client-db-kind">
|
||||
<option value="">—</option>
|
||||
<option v-for="kind in DB_KIND_OPTIONS" :key="kind" :value="kind">{{ t(`admin.integrationConnector.connectorDbKind.${kind}`) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.environment') }}</label>
|
||||
<select v-model="clientForm.environment" class="input-field text-sm" data-testid="client-environment">
|
||||
@@ -284,10 +345,10 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
|
||||
<div class="space-y-4">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.sections.connection') }}</h4>
|
||||
<!-- 连接地址:endpoint 合一字段;label 按连接器类型显示(REST=接口地址,SOAP=WSDL 地址) -->
|
||||
<!-- 连接地址:endpoint 合一字段;label 按连接器类型显示(REST=接口地址,SOAP=WSDL 地址,database=数据库连接串) -->
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ clientForm.connector_type === 'soap' ? t('admin.integrationConnector.fields.wsdl') : t('admin.integrationConnector.fields.endpoint') }}</label>
|
||||
<input v-model="clientForm.endpoint" type="text" class="input-field text-sm" :placeholder="t(clientForm.connector_type === 'soap' ? 'admin.integrationConnector.placeholders.wsdl' : 'admin.integrationConnector.placeholders.endpoint')" data-testid="client-endpoint" />
|
||||
<label class="label-field">{{ t(endpointLabelKey) }}</label>
|
||||
<input v-model="clientForm.endpoint" type="text" class="input-field text-sm" :placeholder="t(endpointPlaceholderKey)" data-testid="client-endpoint" />
|
||||
</div>
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
@@ -377,7 +438,7 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
<!-- 状态不进表单正文:以底部操作条只读下拉展示(转移只经列表生命周期按钮) -->
|
||||
</template>
|
||||
|
||||
<!-- 绑定:客户端实例随接口定义联动锁定;状态为只读徽章(发布/退役走列表生命周期按钮) -->
|
||||
<!-- 绑定:接口为有序步骤编辑器(client 由各步接口归属自带);状态为只读徽章(发布/退役走列表生命周期按钮) -->
|
||||
<template v-else-if="activeEntity === 'binding'">
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2">
|
||||
<div class="space-y-1.5">
|
||||
@@ -392,20 +453,6 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
<option v-for="env in ENVIRONMENT_OPTIONS" :key="env" :value="env">{{ t(`admin.integrationConnector.envLabels.${env}`) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.clientInstance') }}</label>
|
||||
<!-- 已选接口定义即锁定:客户端实例由接口定义归属唯一确定,不可单独维护 -->
|
||||
<select v-model="bindingForm.client_instance_code" class="input-field text-sm disabled:opacity-70" :disabled="Boolean(bindingForm.interface_definition_code)" data-testid="binding-client">
|
||||
<option v-for="opt in clientOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
|
||||
</select>
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.bindingClientHint') }}</p>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.interfaceDef') }}</label>
|
||||
<select v-model="bindingForm.interface_definition_code" class="input-field text-sm" data-testid="binding-interface" @change="onBindingInterfaceChange">
|
||||
<option v-for="opt in interfaceOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.fields.mappingVersion') }}</label>
|
||||
<input v-model.number="bindingForm.mapping_version" type="number" class="input-field text-sm" />
|
||||
@@ -423,13 +470,69 @@ onBeforeUnmount(() => document.removeEventListener('keydown', onKeydown));
|
||||
<input v-model="bindingForm.effective_to" type="datetime-local" class="input-field text-sm" />
|
||||
</div>
|
||||
</div>
|
||||
<!-- 有序步骤编辑器:提交时以 steps_json([{interface_code, param_mapping_json}])发送,
|
||||
调用期按数组顺序执行;client 由各步接口归属自带 → 每步只读提示,不再单独维护 -->
|
||||
<div class="space-y-3">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<h4 class="text-xs font-bold uppercase tracking-wide text-muted">{{ t('admin.integrationConnector.bindingSteps.label') }}</h4>
|
||||
<button type="button" class="btn-ghost text-xs" data-testid="binding-add-step" @click="addBindingStep">
|
||||
+ {{ t('admin.integrationConnector.bindingSteps.add') }}
|
||||
</button>
|
||||
</div>
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.bindingSteps.hint') }}</p>
|
||||
<div
|
||||
v-for="(step, index) in bindingForm.steps"
|
||||
:key="index"
|
||||
class="space-y-2 rounded-lg border border-slate-200 px-3 py-2.5"
|
||||
data-testid="binding-step-row"
|
||||
>
|
||||
<div class="flex items-end gap-2">
|
||||
<span class="pb-2 text-xs font-bold text-muted">{{ index + 1 }}</span>
|
||||
<div class="flex-1 space-y-1.5">
|
||||
<label class="label-field">{{ t('admin.integrationConnector.bindingSteps.interface') }}</label>
|
||||
<select v-model="step.interface_code" class="input-field text-sm" :data-testid="`binding-step-interface-${index}`">
|
||||
<option value="">—</option>
|
||||
<option v-for="opt in interfaceOptions" :key="opt.code" :value="opt.code">{{ optionLabel(opt.name, opt.code) }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-xs"
|
||||
:disabled="index === 0"
|
||||
:title="t('admin.integrationConnector.bindingSteps.moveUp')"
|
||||
:data-testid="`binding-step-up-${index}`"
|
||||
@click="moveBindingStep(index, -1)"
|
||||
>↑</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-xs"
|
||||
:disabled="index === bindingForm.steps.length - 1"
|
||||
:title="t('admin.integrationConnector.bindingSteps.moveDown')"
|
||||
:data-testid="`binding-step-down-${index}`"
|
||||
@click="moveBindingStep(index, 1)"
|
||||
>↓</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-ghost text-xs"
|
||||
:title="t('admin.integrationConnector.bindingSteps.remove')"
|
||||
:data-testid="`binding-step-remove-${index}`"
|
||||
@click="removeBindingStep(index)"
|
||||
>✕</button>
|
||||
</div>
|
||||
<p v-if="bindingStepClientHint(index)" class="text-xs text-muted" :data-testid="`binding-step-client-${index}`">
|
||||
{{ bindingStepClientHint(index) }}
|
||||
</p>
|
||||
<JsonTextareaField
|
||||
v-model="step.param_mapping_json"
|
||||
:label="t('admin.integrationConnector.bindingSteps.paramMapping', { index: index + 1 })"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<details class="rounded-lg border border-slate-200 px-3 py-2">
|
||||
<summary class="cursor-pointer text-xs font-bold text-secondary">{{ t('admin.integrationConnector.advancedConfig') }}</summary>
|
||||
<div class="mt-2 space-y-2">
|
||||
<JsonTextareaField v-model="bindingForm.context_selector_json" :label="t('admin.integrationConnector.fields.contextSelector')" />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.contextSelectorHint') }}</p>
|
||||
<JsonTextareaField v-model="bindingForm.param_mapping_json" :label="t('admin.integrationConnector.fields.paramMapping')" />
|
||||
<p class="text-xs text-muted">{{ t('admin.integrationConnector.fields.paramMappingHint') }}</p>
|
||||
</div>
|
||||
</details>
|
||||
<!-- 状态不进表单正文:以底部操作条只读下拉展示(转移只经列表生命周期按钮) -->
|
||||
|
||||
+79
-11
@@ -76,7 +76,7 @@ describe('useIntegrationConnectorAdmin', () => {
|
||||
c.clientForm.value.config_json = '{"headers":{"X-Tenant":"A"}}';
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationClientInstance).toHaveBeenCalledWith({
|
||||
code: 'erp-x', name: 'ERP X', connector_type: 'rest', environment: 'prod',
|
||||
code: 'erp-x', name: 'ERP X', connector_type: 'rest', environment: 'prod', db_kind: null,
|
||||
endpoint: 'https://x.invalid', timeout_seconds: 90,
|
||||
config_json: { headers: { 'X-Tenant': 'A' } }, credential_ref_code: null, enabled: true,
|
||||
});
|
||||
@@ -85,7 +85,7 @@ describe('useIntegrationConnectorAdmin', () => {
|
||||
it('编辑客户端实例:有 id 走 PUT', async () => {
|
||||
const c = makeHarness();
|
||||
c.openEditModal('client', {
|
||||
id: 1, code: 'erp-x', name: 'old', connector_type: 'rest', environment: 'prod',
|
||||
id: 1, code: 'erp-x', name: 'old', connector_type: 'rest', environment: 'prod', db_kind: null,
|
||||
config_json: {}, credential_ref_code: null, enabled: true,
|
||||
});
|
||||
c.clientForm.value.name = 'new';
|
||||
@@ -93,6 +93,34 @@ describe('useIntegrationConnectorAdmin', () => {
|
||||
expect(api.updateIntegrationClientInstance).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('database 客户端:未选 db_kind 拦截不调 API;选择后 payload 携带 db_kind', async () => {
|
||||
const c = makeHarness();
|
||||
c.openCreateModal('client');
|
||||
c.clientForm.value.code = 'erp-db';
|
||||
c.clientForm.value.name = 'ERP Oracle';
|
||||
c.clientForm.value.connector_type = 'database';
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationClientInstance).not.toHaveBeenCalled();
|
||||
|
||||
c.clientForm.value.db_kind = 'oracle';
|
||||
c.clientForm.value.endpoint = '127.0.0.1:1521/ORCL';
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationClientInstance).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ connector_type: 'database', db_kind: 'oracle', endpoint: '127.0.0.1:1521/ORCL' }),
|
||||
);
|
||||
});
|
||||
|
||||
it('非 database 客户端 payload 的 db_kind 为 null(不输明文,凭据走引用)', async () => {
|
||||
const c = makeHarness();
|
||||
c.openCreateModal('client');
|
||||
c.clientForm.value.code = 'erp-x';
|
||||
c.clientForm.value.name = 'ERP X';
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationClientInstance).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ connector_type: 'rest', db_kind: null, credential_ref_code: null }),
|
||||
);
|
||||
});
|
||||
|
||||
it('非法 JSON 字段触发拦截且不调 API', async () => {
|
||||
const c = makeHarness();
|
||||
c.openCreateModal('client');
|
||||
@@ -130,24 +158,63 @@ describe('useIntegrationConnectorAdmin', () => {
|
||||
expect(api.createIntegrationClientInstance).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('绑定:必填校验与 POST payload(状态与来源快捷列不随表单提交)', async () => {
|
||||
it('绑定:有序多步 payload 用 steps_json,不再发送旧单步顶层字段', async () => {
|
||||
const c = makeHarness();
|
||||
c.openCreateModal('binding');
|
||||
c.bindingForm.value.capability = 'in_transit_transfer.query_inventory';
|
||||
c.bindingForm.value.client_instance_code = 'CLI-A';
|
||||
c.bindingForm.value.interface_definition_code = 'IF-A';
|
||||
c.bindingForm.value.capability = 'in_transit_transfer.create_transfer';
|
||||
c.bindingForm.value.steps = [
|
||||
{ interface_code: 'IF-STAGE', param_mapping_json: '{"erp_org":{"expr":"external_org"}}' },
|
||||
{ interface_code: 'IF-SUBMIT', param_mapping_json: '' },
|
||||
];
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationBinding).toHaveBeenCalledWith({
|
||||
capability: 'in_transit_transfer.query_inventory', context_selector_json: {},
|
||||
param_mapping_json: {},
|
||||
client_instance_code: 'CLI-A', interface_definition_code: 'IF-A',
|
||||
capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
|
||||
steps_json: [
|
||||
{ interface_code: 'IF-STAGE', param_mapping_json: { erp_org: { expr: 'external_org' } } },
|
||||
{ interface_code: 'IF-SUBMIT', param_mapping_json: {} },
|
||||
],
|
||||
mapping_version: 1, priority: 0, environment: 'prod',
|
||||
effective_from: null, effective_to: null,
|
||||
});
|
||||
const payload = api.createIntegrationBinding.mock.calls[0][0] as Record<string, unknown>;
|
||||
// 状态走列表生命周期按钮;客户端实例随接口定义联动(仍随 payload 提交)
|
||||
// 客户端由各步接口归属自带,旧单步字段与状态均不随表单提交
|
||||
expect(payload).not.toHaveProperty('interface_definition_code');
|
||||
expect(payload).not.toHaveProperty('param_mapping_json');
|
||||
expect(payload).not.toHaveProperty('client_instance_code');
|
||||
expect(payload).not.toHaveProperty('status');
|
||||
expect(payload).not.toHaveProperty('context_source_code');
|
||||
});
|
||||
|
||||
it('绑定:步骤缺接口定义或步骤列表为空 → 拦截不调 API', async () => {
|
||||
const c = makeHarness();
|
||||
c.openCreateModal('binding');
|
||||
c.bindingForm.value.capability = 'in_transit_transfer.create_transfer';
|
||||
c.bindingForm.value.steps = [{ interface_code: '', param_mapping_json: '' }];
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationBinding).not.toHaveBeenCalled();
|
||||
c.bindingForm.value.steps = [];
|
||||
await c.saveActive();
|
||||
expect(api.createIntegrationBinding).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('编辑既有 steps_json 绑定:单步行回显为 steps 并仍以 steps_json 提交', async () => {
|
||||
const c = makeHarness();
|
||||
c.openEditModal('binding', {
|
||||
id: 7, capability: 'in_transit_transfer.create_transfer', context_selector_json: {},
|
||||
steps_json: [{ interface_code: 'IF-A', param_mapping_json: { org: { expr: 'external_org' } } }],
|
||||
param_mapping_json: { org: { expr: 'external_org' } },
|
||||
client_instance_code: 'CLI-A', interface_definition_code: 'IF-A',
|
||||
mapping_version: 1, priority: 0, environment: 'prod',
|
||||
effective_from: null, effective_to: null, status: 'draft',
|
||||
});
|
||||
expect(c.bindingForm.value.steps).toEqual([
|
||||
{ interface_code: 'IF-A', param_mapping_json: '{\n "org": {\n "expr": "external_org"\n }\n}' },
|
||||
]);
|
||||
await c.saveActive();
|
||||
expect(api.updateIntegrationBinding).toHaveBeenCalled();
|
||||
const payload = api.updateIntegrationBinding.mock.calls[0][1] as Record<string, unknown>;
|
||||
expect(Array.isArray(payload.steps_json)).toBe(true);
|
||||
expect(payload).not.toHaveProperty('interface_definition_code');
|
||||
expect(payload).not.toHaveProperty('param_mapping_json');
|
||||
});
|
||||
|
||||
it('绑定生命周期:publish 调动作端点并刷新绑定列表', async () => {
|
||||
@@ -156,6 +223,7 @@ describe('useIntegrationConnectorAdmin', () => {
|
||||
api.listIntegrationBindings.mockResolvedValue([]);
|
||||
c.bindings.value = [{
|
||||
id: 7, capability: 'in_transit_transfer.query_inventory', context_selector_json: {},
|
||||
steps_json: [{ interface_code: 'IF-A', param_mapping_json: {} }],
|
||||
client_instance_code: 'CLI-A', interface_definition_code: 'IF-A',
|
||||
mapping_version: 1, priority: 0, environment: 'prod',
|
||||
effective_from: null, effective_to: null, status: 'draft',
|
||||
|
||||
+29
-6
@@ -5,8 +5,10 @@
|
||||
* 依赖:integration-connector.api、types、useMessage、useI18n。
|
||||
* 逻辑:各列表独立 loadAll;新增/编辑共用表单弹窗态(form.id 区分);客户端编码
|
||||
* 可手改、留空按名称自动生成,接口定义编码留空按「客户端编码-名称」自动建议;
|
||||
* 接口与绑定状态只经 change*Lifecycle 按钮流转(表单内只读徽章);绑定表单的
|
||||
* 客户端实例随所选接口定义联动带出并锁定(接口归属即客户端归属);
|
||||
* database 类型 db_kind 必填四选一(未选提交在前端拦截),非 database 恒为 null;
|
||||
* 接口与绑定状态只经 change*Lifecycle 按钮流转(表单内只读徽章);绑定表单为
|
||||
* 有序步骤编辑器(steps 数组),提交 payload 用 steps_json(每步 interface_code +
|
||||
* param_mapping_json),client 由各步接口归属自带、不再发送旧单步顶层字段;
|
||||
* 凭据状态只经列表行内开关流转(启用↔停用,表单不维护状态);
|
||||
* 全部行内状态操作经 lifecycleBusy 互斥(进行中忽略新触发);接口/绑定退役
|
||||
* 接近终态需 window.confirm 二次确认,可逆转移直达;
|
||||
@@ -46,6 +48,7 @@ import {
|
||||
createEmptyCredentialReferenceForm,
|
||||
createEmptyInterfaceDefinitionForm,
|
||||
credentialReferenceRowToForm,
|
||||
DB_KIND_OPTIONS,
|
||||
interfaceDefinitionRowToForm,
|
||||
normalizeConnectionTestResponse,
|
||||
suggestClientCode,
|
||||
@@ -64,6 +67,9 @@ import {
|
||||
type InterfaceDefinitionFormState,
|
||||
} from '../types/integration-connector.types';
|
||||
|
||||
/** db_kind 四库枚举(D16);仅用于 DB_KIND_OPTIONS.includes 的类型收窄。 */
|
||||
type DbKind = (typeof DB_KIND_OPTIONS)[number];
|
||||
|
||||
type EditableEntity = 'client' | 'interface' | 'binding' | 'credential';
|
||||
|
||||
/** 接口定义/绑定生命周期动作(与后端 CONFIG_STATUS_TRANSITIONS 一一对应)。 */
|
||||
@@ -203,9 +209,15 @@ export function useIntegrationConnectorAdmin() {
|
||||
msg.warning(t('admin.integrationConnector.msg.codeInvalid'));
|
||||
return;
|
||||
}
|
||||
// database 类型 db_kind 必填(D16 四选一):未选在前端拦截,不发请求。
|
||||
if (form.connector_type === 'database' && !DB_KIND_OPTIONS.includes(form.db_kind as DbKind)) {
|
||||
msg.warning(t('admin.integrationConnector.msg.fillDbKind'));
|
||||
return;
|
||||
}
|
||||
const configJson = parseJsonField(form.config_json, 'config_json');
|
||||
const payload = {
|
||||
code, name: form.name.trim(), connector_type: form.connector_type,
|
||||
db_kind: form.connector_type === 'database' ? form.db_kind : null,
|
||||
environment: form.environment,
|
||||
endpoint: form.endpoint.trim() || null,
|
||||
timeout_seconds: form.timeout_seconds.trim() ? Number(form.timeout_seconds) : null,
|
||||
@@ -237,16 +249,27 @@ export function useIntegrationConnectorAdmin() {
|
||||
else await createIntegrationInterfaceDefinition(payload);
|
||||
} else if (activeEntity.value === 'binding') {
|
||||
const form = bindingForm.value;
|
||||
if (!form.capability.trim() || !form.client_instance_code.trim() || !form.interface_definition_code.trim()) {
|
||||
// 有序多步:至少一步且每步必选接口;client 由各步接口归属自带(后端按接口推导),
|
||||
// 不再发送旧单步顶层字段(interface_definition_code/param_mapping_json)。
|
||||
if (!form.capability.trim() || form.steps.length === 0) {
|
||||
msg.warning(t('admin.integrationConnector.msg.fillBinding'));
|
||||
return;
|
||||
}
|
||||
// 客户端实例随所选接口定义联动带出(接口归属即客户端归属);
|
||||
const steps: Array<{ interface_code: string; param_mapping_json: Record<string, unknown> }> = [];
|
||||
for (const [index, step] of form.steps.entries()) {
|
||||
if (!step.interface_code.trim()) {
|
||||
msg.warning(t('admin.integrationConnector.msg.fillBinding'));
|
||||
return;
|
||||
}
|
||||
steps.push({
|
||||
interface_code: step.interface_code.trim(),
|
||||
param_mapping_json: parseJsonField(step.param_mapping_json, `steps_json[${index}].param_mapping_json`),
|
||||
});
|
||||
}
|
||||
// 状态不随表单提交:新建固定 draft,发布/退役走列表生命周期按钮。
|
||||
const payload = {
|
||||
capability: form.capability.trim(), context_selector_json: parseJsonField(form.context_selector_json, 'context_selector_json'),
|
||||
param_mapping_json: parseJsonField(form.param_mapping_json, 'param_mapping_json'),
|
||||
client_instance_code: form.client_instance_code.trim(), interface_definition_code: form.interface_definition_code.trim(),
|
||||
steps_json: steps,
|
||||
mapping_version: Number(form.mapping_version || 1), priority: Number(form.priority || 0),
|
||||
environment: form.environment, effective_from: form.effective_from || null, effective_to: form.effective_to || null,
|
||||
};
|
||||
|
||||
+116
-16
@@ -7,14 +7,18 @@
|
||||
*/
|
||||
|
||||
/** 连接器类型:与后端 CONNECTOR_TYPES 对齐。 */
|
||||
export type IntegrationConnectorType = 'rest' | 'soap';
|
||||
export type IntegrationConnectorType = 'rest' | 'soap' | 'database';
|
||||
|
||||
/** 连接器类型选项(labelKey 为 i18n 键;新增类型在此追加一行并补四语言文案)。 */
|
||||
export const CONNECTOR_TYPE_OPTIONS: ReadonlyArray<{ value: IntegrationConnectorType; labelKey: string }> = [
|
||||
{ value: 'rest', labelKey: 'admin.integrationConnector.connectorTypes.rest' },
|
||||
{ value: 'soap', labelKey: 'admin.integrationConnector.connectorTypes.soap' },
|
||||
{ value: 'database', labelKey: 'admin.integrationConnector.connectorTypes.database' },
|
||||
];
|
||||
|
||||
/** database 类型 db_kind 选项(与后端 D16 四库驱动注册表对齐;label 键 connectorDbKind.*)。 */
|
||||
export const DB_KIND_OPTIONS = ['mysql', 'oracle', 'sqlserver', 'postgresql'] as const;
|
||||
|
||||
/** 环境选项(与发布流程 dev→test→prod 对齐;新增环境在此追加并补四语言文案)。 */
|
||||
export const ENVIRONMENT_OPTIONS = ['dev', 'test', 'prod'] as const;
|
||||
|
||||
@@ -22,6 +26,7 @@ export const ENVIRONMENT_OPTIONS = ['dev', 'test', 'prod'] as const;
|
||||
export const CONNECTOR_CONFIG_KEYS: Readonly<Record<string, ReadonlyArray<string>>> = {
|
||||
rest: ['headers'],
|
||||
soap: [],
|
||||
database: ['oracle_lib_dir'],
|
||||
};
|
||||
|
||||
/** 客户端编码规则:小写字母/数字开头,仅小写字母、数字、连字符(保存后不可改)。 */
|
||||
@@ -135,6 +140,8 @@ export interface IntegrationClientInstanceRow {
|
||||
environment: string;
|
||||
endpoint: string | null;
|
||||
timeout_seconds: number | null;
|
||||
/** database 类型专列(D16 四库);rest/soap 为 null。 */
|
||||
db_kind: string | null;
|
||||
config_json: Record<string, unknown>;
|
||||
credential_ref_code: string | null;
|
||||
enabled: boolean;
|
||||
@@ -158,11 +165,18 @@ export interface IntegrationInterfaceDefinitionRow {
|
||||
enabled: boolean;
|
||||
}
|
||||
|
||||
/** 绑定(能力 → 客户端 + 接口 + 映射版本)。 */
|
||||
/** 绑定有序步骤(调用期按序执行;客户端实例由步骤接口归属自带)。 */
|
||||
export interface IntegrationBindingStep {
|
||||
interface_code: string;
|
||||
param_mapping_json: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/** 绑定(能力 → 有序多步接口配方 + 映射版本;旧单步列为 P2 删前镜像,仅回显兜底)。 */
|
||||
export interface IntegrationBindingRow {
|
||||
id: number;
|
||||
capability: string;
|
||||
context_selector_json: Record<string, unknown>;
|
||||
steps_json: IntegrationBindingStep[];
|
||||
param_mapping_json: Record<string, unknown>;
|
||||
client_instance_code: string;
|
||||
interface_definition_code: string;
|
||||
@@ -195,6 +209,8 @@ export interface ClientInstanceFormState {
|
||||
code: string;
|
||||
name: string;
|
||||
connector_type: IntegrationConnectorType;
|
||||
/** database 类型专属四选一(mysql/oracle/sqlserver/postgresql);非 database 恒为空串。 */
|
||||
db_kind: string;
|
||||
environment: string;
|
||||
endpoint: string;
|
||||
timeout_seconds: string;
|
||||
@@ -224,17 +240,24 @@ export interface InterfaceDefinitionFormState {
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定表单(JSON 字段以文本承载,提交时解析)。
|
||||
* client_instance_code 随所选接口定义联动带出并锁定(接口归属即客户端归属),仍随表单提交;
|
||||
* status 仅作徽章展示:新建固定 draft,发布/退役经列表生命周期按钮流转,均不随表单提交。
|
||||
* 绑定表单步骤(JSON 映射以文本承载,提交时解析;每步独立编辑)。
|
||||
*/
|
||||
export interface BindingStepFormState {
|
||||
interface_code: string;
|
||||
param_mapping_json: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定表单(接口为有序多步,client 由各步接口归属自带 → 不再单独维护)。
|
||||
* JSON 字段以文本承载,提交时解析;status 仅作徽章展示:新建固定 draft,
|
||||
* 发布/退役经列表生命周期按钮流转,均不随表单提交。
|
||||
*/
|
||||
export interface BindingFormState {
|
||||
id: number | null;
|
||||
capability: string;
|
||||
context_selector_json: string;
|
||||
param_mapping_json: string;
|
||||
client_instance_code: string;
|
||||
interface_definition_code: string;
|
||||
/** 有序步骤(调用期按数组顺序执行;至少一步且每步必选接口才能提交)。 */
|
||||
steps: BindingStepFormState[];
|
||||
mapping_version: number;
|
||||
priority: number;
|
||||
environment: string;
|
||||
@@ -266,6 +289,7 @@ export function createEmptyClientInstanceForm(): ClientInstanceFormState {
|
||||
code: '',
|
||||
name: '',
|
||||
connector_type: 'rest',
|
||||
db_kind: '',
|
||||
environment: 'prod',
|
||||
endpoint: '',
|
||||
timeout_seconds: '60',
|
||||
@@ -282,6 +306,7 @@ export function clientInstanceRowToForm(row: IntegrationClientInstanceRow): Clie
|
||||
code: row.code,
|
||||
name: row.name,
|
||||
connector_type: row.connector_type,
|
||||
db_kind: row.db_kind ?? '',
|
||||
environment: row.environment,
|
||||
endpoint: row.endpoint ?? '',
|
||||
timeout_seconds: String(row.timeout_seconds ?? ''),
|
||||
@@ -327,15 +352,13 @@ export function interfaceDefinitionRowToForm(row: IntegrationInterfaceDefinition
|
||||
};
|
||||
}
|
||||
|
||||
/** 创建空的绑定表单。 */
|
||||
/** 创建空的绑定表单(空步骤列表,用户经「添加步骤」构建有序配方)。 */
|
||||
export function createEmptyBindingForm(): BindingFormState {
|
||||
return {
|
||||
id: null,
|
||||
capability: '',
|
||||
context_selector_json: '',
|
||||
param_mapping_json: '',
|
||||
client_instance_code: '',
|
||||
interface_definition_code: '',
|
||||
steps: [],
|
||||
mapping_version: 1,
|
||||
priority: 0,
|
||||
environment: 'prod',
|
||||
@@ -345,15 +368,24 @@ export function createEmptyBindingForm(): BindingFormState {
|
||||
};
|
||||
}
|
||||
|
||||
/** 列表行回填为绑定编辑表单(status 仅回显,不随保存提交)。 */
|
||||
/**
|
||||
* 列表行回填为绑定编辑表单(status 仅回显,不随保存提交)。
|
||||
* 步骤优先读 steps_json;steps_json 为空(P2 前的存量旧列行)时由旧单步列合成一步兜底。
|
||||
*/
|
||||
export function bindingRowToForm(row: IntegrationBindingRow): BindingFormState {
|
||||
const rawSteps = row.steps_json?.length
|
||||
? row.steps_json
|
||||
: [{ interface_code: row.interface_definition_code, param_mapping_json: row.param_mapping_json || {} }];
|
||||
return {
|
||||
id: row.id,
|
||||
capability: row.capability,
|
||||
context_selector_json: toJsonText(row.context_selector_json),
|
||||
param_mapping_json: toJsonText(row.param_mapping_json),
|
||||
client_instance_code: row.client_instance_code,
|
||||
interface_definition_code: row.interface_definition_code,
|
||||
steps: rawSteps
|
||||
.filter((step) => step.interface_code)
|
||||
.map((step) => ({
|
||||
interface_code: step.interface_code,
|
||||
param_mapping_json: toJsonText(step.param_mapping_json),
|
||||
})),
|
||||
mapping_version: Number(row.mapping_version || 1),
|
||||
priority: Number(row.priority || 0),
|
||||
environment: row.environment,
|
||||
@@ -388,3 +420,71 @@ export function credentialReferenceRowToForm(row: IntegrationCredentialReference
|
||||
status: row.status,
|
||||
};
|
||||
}
|
||||
|
||||
/** 集成调用日志行(GET /calls 列表项;字段全部能力无关通用口径)。 */
|
||||
export interface IntegrationCallLogRow {
|
||||
id: number;
|
||||
created_at: string | null;
|
||||
capability: string;
|
||||
operation_id: string;
|
||||
trace_id: string;
|
||||
status: string;
|
||||
elapsed_ms: number;
|
||||
business_ref: string | null;
|
||||
client_code: string | null;
|
||||
interface_code: string | null;
|
||||
connector_type: string | null;
|
||||
step_index: number | null;
|
||||
step_count: number | null;
|
||||
}
|
||||
|
||||
/** 线级事实(按连接类型二选一;database=SQL/绑定/行数,soap/rest=HTTP 往返)。 */
|
||||
export interface IntegrationCallWire {
|
||||
kind: 'database' | 'soap' | 'rest';
|
||||
statements?: { phase: string; sql: string; binds: Record<string, unknown>; rowcount?: number; row_count?: number }[];
|
||||
rowcount?: number;
|
||||
rows?: unknown[];
|
||||
method?: string;
|
||||
url?: string;
|
||||
soap_action?: string;
|
||||
headers?: string;
|
||||
request_body?: string;
|
||||
http_status?: number;
|
||||
response_body?: string;
|
||||
}
|
||||
|
||||
/** 调用全量详情(GET /calls/{id};含同 operation_id 步骤时间线)。 */
|
||||
export interface IntegrationCallDetail {
|
||||
call: {
|
||||
id: number;
|
||||
created_at: string | null;
|
||||
capability: string;
|
||||
operation_id: string;
|
||||
trace_id: string;
|
||||
status: string;
|
||||
elapsed_ms: number;
|
||||
business_ref: string | null;
|
||||
binding_snapshot_json: Record<string, unknown>;
|
||||
request_summary_json: Record<string, unknown>;
|
||||
response_summary_json: Record<string, unknown>;
|
||||
wire_json: IntegrationCallWire | null;
|
||||
};
|
||||
timeline: { id: number; step_index: number | null; step_count: number | null; interface_code: string | null; status: string; elapsed_ms: number }[];
|
||||
}
|
||||
|
||||
/** 列表查询条件(全部可选;后端缺省口径 page=1/page_size=20)。 */
|
||||
export interface IntegrationCallFilters {
|
||||
capability?: string;
|
||||
interface_code?: string;
|
||||
client_code?: string;
|
||||
connector_type?: string;
|
||||
status?: string;
|
||||
operation_id?: string;
|
||||
trace_id?: string;
|
||||
keyword?: string;
|
||||
business_ref?: string;
|
||||
date_from?: string;
|
||||
date_to?: string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
}
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
/**
|
||||
* features/admin/modules/integration-connector/utils/integration-call-replay.spec.ts
|
||||
* 验证调用复现命令生成:soap/rest curl 组装(SOAPAction 引号、headers 展开、凭据脱敏)、
|
||||
* inlineBinds 具名绑定内联(单引号转义)、buildSqlReplay 写入类自动包事务 + ROLLBACK 警示。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildCurl, buildSqlReplay, inlineBinds } from './integration-call-replay';
|
||||
import type { IntegrationCallWire } from '../types/integration-connector.types';
|
||||
|
||||
describe('buildCurl(soap)', () => {
|
||||
it('含 Content-Type、SOAPAction(保留双引号)与 --data-binary 完整 body', () => {
|
||||
// [断言意图] SOAPAction 值按真实 ERP 口径自带双引号,生成命令必须原样保留且整体 shell 安全包裹
|
||||
const wire: IntegrationCallWire = {
|
||||
kind: 'soap',
|
||||
method: 'POST',
|
||||
url: 'http://erp.example/TopGP.asmx',
|
||||
soap_action: '"urn:CreateTransfer"',
|
||||
request_body: '<soapenv:Envelope>…</soapenv:Envelope>',
|
||||
};
|
||||
const cmd = buildCurl(wire);
|
||||
expect(cmd).toContain('curl -X POST');
|
||||
expect(cmd).toContain("-H 'SOAPAction: \"urn:CreateTransfer\"'");
|
||||
expect(cmd).toContain("-H 'Content-Type: text/xml; charset=utf-8'");
|
||||
expect(cmd).toContain('--data-binary');
|
||||
expect(cmd).toContain('<soapenv:Envelope>…</soapenv:Envelope>');
|
||||
// [断言意图] 末行不得以续行符 \ 结尾,否则粘贴进 bash 会进入 PS2 续行等待
|
||||
expect(cmd.endsWith('\\')).toBe(false);
|
||||
});
|
||||
|
||||
it('soap_action 缺省时回退空双引号', () => {
|
||||
const cmd = buildCurl({ kind: 'soap', url: 'http://erp.example/svc' });
|
||||
expect(cmd).toContain('SOAPAction: ""');
|
||||
expect(cmd.endsWith('\\')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildCurl(rest)', () => {
|
||||
it('headers JSON 逐个展开为 -H,凭据位 *** 替换为 ***REDACTED***', () => {
|
||||
// [断言意图] 脱敏口径:wire 中凭据位只存 '***',复现命令不得还原真实凭据
|
||||
const wire: IntegrationCallWire = {
|
||||
kind: 'rest',
|
||||
method: 'POST',
|
||||
url: 'https://api.example/v1/orders',
|
||||
headers: JSON.stringify({ 'Content-Type': 'application/json', Authorization: '***', 'X-App-Id': 'demo' }),
|
||||
request_body: '{"doc_no":"TGHX1-OR-00001"}',
|
||||
};
|
||||
const cmd = buildCurl(wire);
|
||||
expect(cmd).toContain("-H 'Content-Type: application/json'");
|
||||
expect(cmd).toContain("-H 'Authorization: ***REDACTED***'");
|
||||
expect(cmd).toContain("-H 'X-App-Id: demo'");
|
||||
expect(cmd).toContain('-d');
|
||||
expect(cmd).toContain('{"doc_no":"TGHX1-OR-00001"}');
|
||||
// [断言意图] 末行不得以续行符 \ 结尾(修复前 -d 段恒带尾随 \,bash 粘贴会挂起)
|
||||
expect(cmd.endsWith('\\')).toBe(false);
|
||||
});
|
||||
|
||||
it('无 headers 无 body 时为单行命令且不以续行符收尾', () => {
|
||||
// [断言意图] 回归:修复前即使裸命令也以 \ 收尾(filter 后末段仍是带 \ 的首行)
|
||||
const cmd = buildCurl({ kind: 'rest', method: 'GET', url: 'https://api.example/ping' });
|
||||
expect(cmd).toContain("curl -X GET 'https://api.example/ping'");
|
||||
expect(cmd.endsWith('\\')).toBe(false);
|
||||
expect(cmd.split('\n')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('inlineBinds', () => {
|
||||
it("字符串绑定单引号转义(it doesn't → doesn''t),数字原样,未知占位符保留", () => {
|
||||
// [断言意图] 单引号必须转义为 '',否则复现 SQL 直接语法报错
|
||||
const sql = "UPDATE t SET note = :note, qty = :qty WHERE id = :id";
|
||||
const out = inlineBinds(sql, { note: "it doesn't", qty: 3, id: 7 });
|
||||
expect(out).toContain("'it doesn''t'");
|
||||
expect(out).toContain('qty = 3');
|
||||
expect(out).toContain('id = 7');
|
||||
|
||||
const unknown = inlineBinds('SELECT :missing FROM dual', {});
|
||||
expect(unknown).toContain(':missing');
|
||||
});
|
||||
});
|
||||
|
||||
describe('buildSqlReplay(写入类)', () => {
|
||||
it('INSERT 语句包 BEGIN; … ROLLBACK; 事务并带环境确认警示;bulk 段注释取首行口径', () => {
|
||||
// [断言意图] 写入类复现默认 ROLLBACK 兜底,防止误写目标库;确认后人工改 COMMIT
|
||||
const wire: IntegrationCallWire = {
|
||||
kind: 'database',
|
||||
statements: [
|
||||
{ phase: 'pre', sql: "INSERT INTO t (a) VALUES (:a)", binds: { a: "O'Brien" } },
|
||||
{ phase: 'bulk', sql: 'UPDATE t SET b = :b', binds: { b: 'x' } },
|
||||
],
|
||||
};
|
||||
const out = buildSqlReplay(wire);
|
||||
expect(out).toContain('⚠ 写入语句');
|
||||
expect(out).toContain('BEGIN;');
|
||||
expect(out).toContain('ROLLBACK');
|
||||
expect(out).toContain("O''Brien");
|
||||
expect(out).toContain('-- bulk(绑定取首行;全量行由应用逐行 executemany)');
|
||||
});
|
||||
|
||||
it('只读 SELECT 不包事务,直接以分号收尾', () => {
|
||||
const out = buildSqlReplay({
|
||||
kind: 'database',
|
||||
statements: [{ phase: 'read', sql: 'SELECT * FROM t WHERE id = :id', binds: { id: 1 } }],
|
||||
});
|
||||
expect(out).not.toContain('BEGIN;');
|
||||
expect(out).not.toContain('ROLLBACK');
|
||||
expect(out).toContain('id = 1');
|
||||
});
|
||||
});
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
/**
|
||||
* features/admin/modules/integration-connector/utils/integration-call-replay.ts
|
||||
* 集成调用复现命令生成(wire → 外部工具可直接执行的文本)。
|
||||
* 依赖:../types/integration-connector.types(IntegrationCallWire 线级事实类型)。
|
||||
* 逻辑:soap/rest 生成 curl(凭据位为 ***REDACTED***,需手工替换);
|
||||
* database 生成绑定已内联的 SQL(写入类包事务并标注警示)。
|
||||
* 供 IntegrationCallLogsPanel 抽屉「复制 curl / 复制 SQL」按钮消费。
|
||||
*/
|
||||
import type { IntegrationCallWire } from '../types/integration-connector.types';
|
||||
|
||||
const REDACTED = '***REDACTED***';
|
||||
|
||||
/** shell 单引号安全包裹(' → '\'' ),保证含单引号的 body/URL 可原样粘贴执行。 */
|
||||
function shellQuote(value: string): string {
|
||||
return `'${value.replace(/'/g, `'\\''`)}'`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 拼接 curl 多行命令并剥离末段尾随续行符。
|
||||
* 约束:末行若以 `\` 结尾,粘贴进 bash 会进入 PS2 续行等待,破坏「可直接执行」承诺;
|
||||
* 末段内容本身恒以引号收尾,结尾的 ` \` 只可能是我们追加的续行符,不会误伤。
|
||||
*/
|
||||
function joinCurlCommand(lines: string[]): string {
|
||||
return lines.filter(Boolean).join('\n').replace(/ \\$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 HTTP 调用的 curl 复现命令。
|
||||
* soap 固定 text/xml + SOAPAction 头(值为空时回退 '""');rest 展开 headers JSON
|
||||
* (值为 '***' 的凭据位替换为 ***REDACTED*** 提示手工替换)。
|
||||
* @param wire - 调用详情 wire_json(kind 必须为 soap/rest,database 走 buildSqlReplay)
|
||||
* @returns 多行 curl 命令文本(\ 续行,可直接粘贴 bash,末行不以 \ 结尾)
|
||||
*/
|
||||
export function buildCurl(wire: IntegrationCallWire): string {
|
||||
if (wire.kind === 'soap') {
|
||||
return joinCurlCommand([
|
||||
`curl -X ${wire.method || 'POST'} ${shellQuote(wire.url || '')} \\`,
|
||||
` -H 'Content-Type: text/xml; charset=utf-8' \\`,
|
||||
` -H ${shellQuote(`SOAPAction: ${wire.soap_action || '""'}`)} \\`,
|
||||
` --data-binary ${shellQuote(wire.request_body || '')}`,
|
||||
]);
|
||||
}
|
||||
const headers = wire.headers
|
||||
? (JSON.parse(wire.headers) as Record<string, string>)
|
||||
: {};
|
||||
const headerLines = Object.entries(headers)
|
||||
.map(([k, v]) => ` -H ${shellQuote(`${k}: ${v === '***' ? REDACTED : v}`)} \\`)
|
||||
.join('\n');
|
||||
const bodyPart = wire.request_body
|
||||
? ` -d ${shellQuote(wire.request_body)} \\`
|
||||
: '';
|
||||
return joinCurlCommand([
|
||||
`curl -X ${wire.method || 'GET'} ${shellQuote(wire.url || '')} \\`,
|
||||
headerLines,
|
||||
bodyPart,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* SQL 字面量引价:null/undefined → NULL,数字原样,字符串单引号包裹且内部 ' 转义为 ''。
|
||||
* @param value - 绑定值(来自 wire statements[].binds,任意 JSON 类型)
|
||||
*/
|
||||
function quoteLiteral(value: unknown): string {
|
||||
if (value === null || value === undefined) return 'NULL';
|
||||
if (typeof value === 'number') return String(value);
|
||||
return `'${String(value).replace(/'/g, "''")}'`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把具名绑定(:name)内联为 SQL 字面量,生成绑定已内联的可执行版 SQL。
|
||||
* @param sql - 含 :name 占位符的原始 SQL(无对应绑定的占位符原样保留,不静默改写)
|
||||
* @param binds - 绑定字典(可为空对象)
|
||||
*/
|
||||
export function inlineBinds(sql: string, binds: Record<string, unknown>): string {
|
||||
return sql.replace(/:([A-Za-z_][A-Za-z0-9_]*)/g, (raw, name: string) =>
|
||||
name in binds ? quoteLiteral(binds[name]) : raw);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 database 类型调用的 SQL 复现文本。
|
||||
* bulk 段绑定取首行并注明全量行由应用 executemany;任一语句为写入类
|
||||
* (INSERT/UPDATE/DELETE/MERGE,大小写不敏感)时包 BEGIN; ... ROLLBACK; 事务并加红字警示,
|
||||
* 防止复现时误写目标库。
|
||||
* @param wire - 调用详情 wire_json(kind 必须为 database)
|
||||
* @returns 可执行 SQL 文本(写入类默认 ROLLBACK,确认后手工改 COMMIT)
|
||||
*/
|
||||
export function buildSqlReplay(wire: IntegrationCallWire): string {
|
||||
const statements = (wire.statements || [])
|
||||
.map((s) => (s.phase === 'bulk'
|
||||
? `-- bulk(绑定取首行;全量行由应用逐行 executemany)\n${inlineBinds(s.sql, s.binds || {})}`
|
||||
: inlineBinds(s.sql, s.binds || {})));
|
||||
const isWrite = statements.some((s) => /^\s*(INSERT|UPDATE|DELETE|MERGE)/im.test(s));
|
||||
const body = statements.join(';\n\n');
|
||||
return isWrite ? `-- ⚠ 写入语句:请确认目标环境后再执行\nBEGIN;\n${body};\nROLLBACK; -- 确认后改为 COMMIT` : `${body};`;
|
||||
}
|
||||
@@ -1,12 +1,16 @@
|
||||
/**
|
||||
* features/chat/api/transfer.api.spec.ts
|
||||
* 用途:锁定在途仓自动调拨 JSON POST 请求头契约——必须携带 Content-Type: application/json,
|
||||
* 否则后端 Flask request.get_json 解析不到 body,导致默认 source_codes=[] 返回 400。
|
||||
* 否则后端 Flask request.get_json 解析不到 body,导致默认 source_codes=[] 返回 400;
|
||||
* 另锁定 D8 异步 202 契约(requestJson 对 200/202 均透传 envelope.data)与
|
||||
* D9 调拨单清单(GET /runs/{run_no} 返回体 orders 数组透传)。
|
||||
* 依赖:Vitest、vi.mock(@/shared/api/client)、transfer.api、getAuthHeaders。
|
||||
* 逻辑:POST(create/execute/cancel/retry/manual-close)断言 headers 含 application/json,
|
||||
* 且 body 序列化正确;GET/blob 端点不强制 Content-Type。
|
||||
* 且 body 序列化正确;GET/blob 端点不强制 Content-Type;
|
||||
* 202 契约用例用 vi.importActual 取真实 requestJson(stub fetch)验证 200/202 同口径。
|
||||
*/
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { afterEach, beforeAll, beforeEach, describe, expect, expectTypeOf, it, vi } from 'vitest';
|
||||
import type { TransferRunResult, TransferOrder } from '../types/transfer.types';
|
||||
|
||||
const requestJson = vi.hoisted(() => vi.fn());
|
||||
const requestBlob = vi.hoisted(() => vi.fn());
|
||||
@@ -78,4 +82,96 @@ describe('transfer.api JSON request contract', () => {
|
||||
expect(init.headers).toBeDefined();
|
||||
}
|
||||
});
|
||||
|
||||
it('getTransferRun 返回体 orders 调拨单清单逐键透传(D9 融合卡数据源)', async () => {
|
||||
// [断言意图] D9:调拨单清单=进度=结果,orders 逐键结构与后端 serialize_run_orders
|
||||
// (Task 11)一致,前端只透传不加工;类型层 TransferRunResult 必含 orders: TransferOrder[]。
|
||||
const order: TransferOrder = {
|
||||
doc_no: 'HTT-OR-26092300001',
|
||||
receipt_date: '2026-09-23',
|
||||
from_warehouse: 'HTT-B25',
|
||||
to_warehouse: 'HTT-B02',
|
||||
status: 'success',
|
||||
erp_document_no: '1401-2609230007',
|
||||
error_message: null,
|
||||
lines: [{ material_no: 'M001', material_name: '材料甲', lot_no: 'VCCN001', quantity: '100.000000', unit: 'KG' }],
|
||||
};
|
||||
requestJson.mockResolvedValue({
|
||||
run_no: 'RUN-T1',
|
||||
status: 'executing',
|
||||
result: { external_documents: [], exceptions: [] },
|
||||
orders: [order],
|
||||
});
|
||||
const run = await getTransferRun('RUN-T1');
|
||||
expect(requestJson).toHaveBeenCalledWith('/api/in-transit-transfer/runs/RUN-T1', { headers: { Authorization: 'Bearer TEST-TOKEN' } });
|
||||
expect(run.orders).toEqual([order]);
|
||||
// 类型补齐锁定(spec 不进 vue-tsc,此处为文档化断言)
|
||||
expectTypeOf<TransferRunResult['orders']>().toEqualTypeOf<TransferOrder[]>();
|
||||
});
|
||||
});
|
||||
|
||||
describe('transfer.api D8 异步 202 契约(真实 requestJson:200/202 均透传 envelope.data)', () => {
|
||||
// importActual 绕开本文件的 client mock 取真实 requestJson(不 resetModules,
|
||||
// 避免全量套件下动态重载的 worker 状态干扰);requestJson 仅按 res.ok(2xx)判成功,
|
||||
// 202 与 200 同口径——前端 API 层零特判、不改 client。
|
||||
let realRequestJson: typeof import('@/shared/api/client').requestJson;
|
||||
|
||||
beforeAll(async () => {
|
||||
({ requestJson: realRequestJson } = await vi.importActual('@/shared/api/client'));
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
// 防其他文件泄漏的 fake timers 卡住 fetch/Response 的微任务与流式读取
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it('HTTP 202 envelope data 原样透传(data = {run_no,status:"queued"})', async () => {
|
||||
const fetchMock = vi.fn();
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
fetchMock.mockResolvedValue(new Response(
|
||||
JSON.stringify({ success: true, data: { run_no: 'RUN-202-1', status: 'queued' }, request_id: 'req-1' }),
|
||||
{ status: 202, headers: { 'Content-Type': 'application/json' } },
|
||||
));
|
||||
const data = await realRequestJson<{ run_no: string; status: string }>('/api/in-transit-transfer/items/execute', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Authorization: 'Bearer TEST-TOKEN' },
|
||||
body: JSON.stringify({ item_ids: [1, 2] }),
|
||||
});
|
||||
const [url, init] = fetchMock.mock.calls[0] as [string, RequestInit];
|
||||
expect(url).toBe('/api/in-transit-transfer/items/execute');
|
||||
expect(init.method).toBe('POST');
|
||||
expect((init.headers as Headers).get('Content-Type')).toBe('application/json');
|
||||
expect(data).toEqual({ run_no: 'RUN-202-1', status: 'queued' });
|
||||
});
|
||||
|
||||
it('HTTP 200 同口径:run 返回体含 orders 数组并逐键透传', async () => {
|
||||
const fetchMock = vi.fn();
|
||||
vi.stubGlobal('fetch', fetchMock);
|
||||
const order: TransferOrder = {
|
||||
doc_no: 'HTT-OR-26092300002',
|
||||
receipt_date: '2026-09-23',
|
||||
from_warehouse: 'HTT-B25',
|
||||
to_warehouse: 'HTT-B02',
|
||||
status: 'executing',
|
||||
erp_document_no: null,
|
||||
error_message: null,
|
||||
lines: [],
|
||||
};
|
||||
fetchMock.mockResolvedValue(new Response(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
data: { run_no: 'RUN-202-2', status: 'executing', result: { external_documents: [], exceptions: [] }, orders: [order] },
|
||||
}),
|
||||
{ status: 200, headers: { 'Content-Type': 'application/json' } },
|
||||
));
|
||||
const run = await realRequestJson<TransferRunResult>('/api/in-transit-transfer/runs/RUN-202-2', {
|
||||
headers: { Authorization: 'Bearer TEST-TOKEN' },
|
||||
});
|
||||
expect(fetchMock.mock.calls[0][0]).toBe('/api/in-transit-transfer/runs/RUN-202-2');
|
||||
expect(run.orders).toEqual([order]);
|
||||
});
|
||||
});
|
||||
@@ -8,9 +8,11 @@ import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type {
|
||||
TransferActionResult,
|
||||
TransferDocumentRetryResult,
|
||||
TransferBacklogItem,
|
||||
TransferBacklogSummary,
|
||||
TransferBatchResult,
|
||||
TransferExecutedOrdersPage,
|
||||
TransferExecuteResponse,
|
||||
TransferMatchingDetail,
|
||||
TransferMatchingItem,
|
||||
@@ -56,7 +58,12 @@ export const listExecutableTransferItems = () =>
|
||||
{ headers: getAuthHeaders() },
|
||||
);
|
||||
|
||||
/** 按明细行执行调拨(item-centric:body {item_ids};三层门禁在后端,失败抛 BusinessError) */
|
||||
/**
|
||||
* 按明细行执行调拨(item-centric:body {item_ids};三层门禁在后端,失败抛 BusinessError)。
|
||||
* D8 异步契约:后端只做门禁+建 Run+建单+入队,返回 202 envelope,
|
||||
* data = { run_no, status: 'queued' };202 在 requestJson 内按 2xx 与 200 同口径透传,
|
||||
* 本层零特判。进度/结果由 getTransferRun 轮询获取(D9 调拨单清单)。
|
||||
*/
|
||||
export const executeTransferItems = (itemIds: number[]) =>
|
||||
requestJson<TransferExecuteResponse>(`${BASE}/items/execute`, {
|
||||
method: 'POST',
|
||||
@@ -64,12 +71,77 @@ export const executeTransferItems = (itemIds: number[]) =>
|
||||
body: JSON.stringify({ item_ids: itemIds }),
|
||||
});
|
||||
|
||||
/** 恢复 Run 最终结果 */
|
||||
/**
|
||||
* 恢复 Run 结果与调拨单清单(D9 融合卡数据源:调拨单清单=进度=结果)。
|
||||
* 返回体 = result(单号聚合 + exceptions 既有口径)+ orders(TransferOrder[] 逐键,
|
||||
* 对应后端 serialize_run_orders);终态 Run 亦同口径投影,供刷新/重进页面恢复。
|
||||
*/
|
||||
export const getTransferRun = (runNo: string) =>
|
||||
requestJson<TransferRunResult>(`${BASE}/runs/${runNo}`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
|
||||
/**
|
||||
* 人工重新触发 result_unknown 单(D11 SOP 唯一出口,202 异步)。
|
||||
* 契约(计划 Task 10):POST /runs/{run_no}/documents/{doc_no}/retrigger → 202,
|
||||
* data = { run_no, doc_no, status: 'queued' };复用原单 doc_no/submit_timestamp,
|
||||
* 只触发末步(幂等,不重插)。非 result_unknown 单 → 400(TRANSFER.RETRIGGER_NOT_ALLOWED)。
|
||||
*/
|
||||
export const retriggerTransferDocument = (runNo: string, docNo: string) =>
|
||||
requestJson<{ run_no: string; doc_no: string; status: string }>(
|
||||
`${BASE}/runs/${encodeURIComponent(runNo)}/documents/${encodeURIComponent(docNo)}/retrigger`,
|
||||
{ method: 'POST', headers: jsonHeaders() },
|
||||
);
|
||||
|
||||
/**
|
||||
* 人工关闭失败单(D18:语义=A 废单不废行;契约取自计划 Task 17)。
|
||||
* POST /documents/{doc_no}/close,body { reason }(必填);仅 business_failed/
|
||||
* technical_failed 可关——单 cancelled、单内行脱离回 ready_to_execute(可重组新单);
|
||||
* result_unknown → 400(提示走重新触发,D11);pending/executing → 400(在飞)。
|
||||
*/
|
||||
export const closeTransferDocument = (docNo: string, reason: string) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/documents/${encodeURIComponent(docNo)}/close`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
body: JSON.stringify({ reason }),
|
||||
});
|
||||
|
||||
/**
|
||||
* 调拨单级重试(失败单一键恢复主路径):POST /documents/{doc_no}/retry。
|
||||
* 后端按单圈行逐行重查;全部 ready 自动建新 Run 重跑(复用原单号),
|
||||
* 任一行仍阻断则不重跑,返回 {doc_no, rerun, run_no, ready, blocked, total}。
|
||||
*/
|
||||
export const retryTransferOrder = (docNo: string) =>
|
||||
requestJson<TransferDocumentRetryResult>(`${BASE}/documents/${encodeURIComponent(docNo)}/retry`, {
|
||||
method: 'POST',
|
||||
headers: jsonHeaders(),
|
||||
});
|
||||
|
||||
/**
|
||||
* 已执行单分页查询(首页「已执行」区块数据源;计划 Task 17)。
|
||||
* GET /documents?status_group=&date_from=&date_to=&page=&page_size=;
|
||||
* 返回体 groups(计数恒全量,不受筛选影响)+ orders(TransferExecutedOrder 逐键)。
|
||||
* 缺省参数不下发(后端按缺省口径:全部分组、不限时间、page=1、page_size=20)。
|
||||
*/
|
||||
export const fetchExecutedOrders = (params: {
|
||||
statusGroup?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
}) => {
|
||||
const query = new URLSearchParams();
|
||||
if (params.statusGroup) query.set('status_group', params.statusGroup);
|
||||
if (params.dateFrom) query.set('date_from', params.dateFrom);
|
||||
if (params.dateTo) query.set('date_to', params.dateTo);
|
||||
if (params.page != null) query.set('page', String(params.page));
|
||||
if (params.pageSize != null) query.set('page_size', String(params.pageSize));
|
||||
const qs = query.toString();
|
||||
return requestJson<TransferExecutedOrdersPage>(`${BASE}/documents${qs ? `?${qs}` : ''}`, {
|
||||
headers: getAuthHeaders(),
|
||||
});
|
||||
};
|
||||
|
||||
/** 请求停止剩余任务 */
|
||||
export const cancelTransferRun = (runNo: string, reason: string) =>
|
||||
requestJson<TransferActionResult>(`${BASE}/runs/${runNo}/cancel`, {
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
依赖:props.items、i18n chat.transfer.*、transferBatch.deriveBatchNo。
|
||||
逻辑:仅 blocked_recoverable 可勾选与操作;result_unknown / manually_closed 只读;
|
||||
可恢复行按 result_code 细分徽标(blocked_file_removed=文件已移除);
|
||||
blocked_file_removed 行行内仅留「标记无需继续处理」(重查不可恢复——消失证据
|
||||
无法由重查翻回,唯一出口=人工关闭或等文件重新同步);
|
||||
勾选集合为卡片本地态,操作经 emit 交父组件调用批量端点并刷新。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -37,6 +39,14 @@ function isActionable(item: TransferBacklogItem): boolean {
|
||||
return item.status === 'blocked_recoverable';
|
||||
}
|
||||
|
||||
/**
|
||||
* 失效行(文件已移除)判定:行内只留「标记无需继续处理」出口。
|
||||
* @param item 待处理池行;result_code=blocked_file_removed 为失效行
|
||||
*/
|
||||
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();
|
||||
@@ -261,7 +271,10 @@ function resultLabelKey(item: TransferBacklogItem): string {
|
||||
<td class="p-2">{{ $t(agingLabel(item.aging_level)) }}</td>
|
||||
<td class="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}`"
|
||||
@@ -271,6 +284,7 @@ function resultLabelKey(item: TransferBacklogItem): string {
|
||||
{{ $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"
|
||||
:data-testid="`transfer-backlog-resume-${item.invoice_no}`"
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferExecutedCards.spec.ts
|
||||
* 用途:验证已执行统计卡片入口——四卡渲染(计数对齐分组)/ 点击 emit open(group)。
|
||||
* 依赖:vi.mock(transfer.api)、@vue/test-utils、i18n。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const api = vi.hoisted(() => ({ fetchExecutedOrders: vi.fn() }));
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import TransferExecutedCards from './TransferExecutedCards.vue';
|
||||
|
||||
const GROUPS = { success: 3, failed: 2, executing: 1, result_unknown: 1 };
|
||||
|
||||
function mountCards() {
|
||||
return mount(TransferExecutedCards, { global: { plugins: [i18n] } });
|
||||
}
|
||||
|
||||
describe('TransferExecutedCards 已执行统计卡片入口', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.fetchExecutedOrders.mockResolvedValue({
|
||||
groups: GROUPS, orders: [], total: 0, page: 1, page_size: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it('挂载拉取分组计数(pageSize=1)并渲染四张卡片,数字对齐分组', async () => {
|
||||
const wrapper = mountCards();
|
||||
await flushPromises();
|
||||
// [断言意图] 只为取分组计数,列表不消费(pageSize=1 最小请求)。
|
||||
expect(api.fetchExecutedOrders).toHaveBeenCalledWith(expect.objectContaining({ page: 1, pageSize: 1 }));
|
||||
for (const key of ['success', 'failed', 'executing', 'resultUnknown']) {
|
||||
expect(wrapper.find(`[data-testid="transfer-executed-card-${key}"]`).exists()).toBe(true);
|
||||
}
|
||||
// [断言意图] 数字对齐分组计数(恒全量口径)。
|
||||
expect(wrapper.find('[data-testid="transfer-executed-card-success"]').text()).toContain('3');
|
||||
expect(wrapper.find('[data-testid="transfer-executed-card-failed"]').text()).toContain('2');
|
||||
});
|
||||
|
||||
it('卡片点击 emit open(group)', async () => {
|
||||
const wrapper = mountCards();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-executed-card-failed"]').trigger('click');
|
||||
// [断言意图] 卡片=入口:只 emit,不做任何路由/加载。
|
||||
expect(wrapper.emitted('open')).toEqual([['failed']]);
|
||||
await wrapper.find('[data-testid="transfer-executed-card-resultUnknown"]').trigger('click');
|
||||
expect(wrapper.emitted('open')![1]).toEqual(['result_unknown']);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,62 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferExecutedCards.vue
|
||||
|
||||
用途:首页「已执行调拨单」统计卡片入口——四张数字卡片(风格对齐待办看板),
|
||||
点击 emit('open', group) 由首页面板跳转明细列表子视图。
|
||||
依赖:fetchExecutedOrders(transfer.api)、vue-i18n。
|
||||
逻辑:挂载拉取分组计数(pageSize=1,列表不消费);计数恒全量由后端保证;
|
||||
纯入口组件,不含列表/动作。
|
||||
-->
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted, ref } from 'vue';
|
||||
import { fetchExecutedOrders } from '@/features/chat/api/transfer.api';
|
||||
|
||||
type TransferOrderGroups = Record<'success' | 'failed' | 'executing' | 'result_unknown', number>;
|
||||
|
||||
const emit = defineEmits<{ (e: 'open', group: 'success' | 'failed' | 'executing' | 'result_unknown'): void }>();
|
||||
|
||||
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' },
|
||||
];
|
||||
|
||||
/**
|
||||
* 拉取分组计数(pageSize=1 最小请求;计数恒全量由后端保证)。
|
||||
* 失败静默:不抛错不打断首页,计数保持初始 0,由用户刷新/下次进入兜底重拉
|
||||
* (纯入口组件无加载态 UI,loading 已随 P2-5 移除)。
|
||||
*/
|
||||
async function load() {
|
||||
try {
|
||||
const data = await fetchExecutedOrders({ page: 1, pageSize: 1 });
|
||||
groups.value = data.groups;
|
||||
} catch {
|
||||
// 静默保持 0,刷新/重进兜底(失败不打断首页)。
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => { void load(); });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="grid grid-cols-2 gap-3 lg:grid-cols-4">
|
||||
<button
|
||||
v-for="card in GROUP_CARDS"
|
||||
:key="card.key"
|
||||
type="button"
|
||||
class="rounded-2xl border p-4 text-left transition-colors"
|
||||
:class="card.cls"
|
||||
:data-testid="`transfer-executed-card-${card.key}`"
|
||||
@click="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>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,223 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferExecutedOrders.spec.ts
|
||||
* 用途:验证已执行明细列表子视图——initialGroup 初始筛选 / 返回 emit /
|
||||
* 全部与日期筛选 / 分页 / failed 单动作(重试+关闭调拨单)/ result_unknown 仅重新触发。
|
||||
* 依赖:vi.mock(transfer.api)、@vue/test-utils、i18n。
|
||||
* 逻辑:Mock API 断言带参重拉与关闭链路(D18 原因必填、成功后刷新列表)。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import i18n from '@/i18n';
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
fetchExecutedOrders: vi.fn(),
|
||||
closeTransferDocument: vi.fn(),
|
||||
retryTransferOrder: vi.fn(),
|
||||
retriggerTransferDocument: vi.fn(),
|
||||
listExecutableTransferItems: vi.fn(),
|
||||
batchRequeryTransferItems: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
|
||||
import TransferExecutedOrders from './TransferExecutedOrders.vue';
|
||||
|
||||
const GROUPS = { success: 3, failed: 2, executing: 1, result_unknown: 1 };
|
||||
|
||||
const FAILED_TICKET = {
|
||||
doc_no: 'D-FAIL-1',
|
||||
submit_timestamp: '2026-08-06 09:00:00',
|
||||
status: 'business_failed',
|
||||
status_group: 'failed',
|
||||
receipt_date: '2026-08-05',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN01',
|
||||
erp_document_no: null,
|
||||
error_message: null,
|
||||
created_at: '2026-09-20T08:00:00',
|
||||
run_no: 'RUN-1',
|
||||
items: [
|
||||
{ invoice_no: 'INV-A', material_no: 'MAT-A', material_name: '物料A', lot_no: 'LOT-A', quantity: '500', unit: '个' },
|
||||
{ invoice_no: 'INV-B', material_no: 'MAT-B', material_name: '物料B', lot_no: 'LOT-B', quantity: '300', unit: 'PCS' },
|
||||
],
|
||||
};
|
||||
|
||||
const UNKNOWN_TICKET = {
|
||||
doc_no: 'D-UNK-1',
|
||||
submit_timestamp: '2026-08-06 10:00:00',
|
||||
status: 'result_unknown',
|
||||
status_group: 'result_unknown',
|
||||
receipt_date: '2026-08-05',
|
||||
from_warehouse: 'DBS-TRANSIT',
|
||||
to_warehouse: 'HUB-CN02',
|
||||
erp_document_no: null,
|
||||
error_message: null,
|
||||
created_at: '2026-09-21T08:00:00',
|
||||
run_no: 'RUN-1',
|
||||
items: [
|
||||
{ invoice_no: 'INV-C', material_no: 'MAT-C', material_name: '物料C', lot_no: 'LOT-C', quantity: '100', unit: 'PCS' },
|
||||
],
|
||||
};
|
||||
|
||||
function mountList(initialGroup = 'failed') {
|
||||
return mount(TransferExecutedOrders, {
|
||||
props: { initialGroup },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
function pagePayload(overrides: Record<string, unknown> = {}) {
|
||||
return {
|
||||
groups: GROUPS,
|
||||
total: 2,
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
orders: [FAILED_TICKET, UNKNOWN_TICKET],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('TransferExecutedOrders 已执行明细列表子视图', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.fetchExecutedOrders.mockResolvedValue(pagePayload());
|
||||
api.closeTransferDocument.mockResolvedValue({ doc_no: 'D-FAIL-1', status: 'cancelled' });
|
||||
api.retriggerTransferDocument.mockResolvedValue({ run_no: 'RUN-1', doc_no: 'D-UNK-1', status: 'queued' });
|
||||
api.listExecutableTransferItems.mockResolvedValue({ items: [], counts: { executable_count: 0 } });
|
||||
api.batchRequeryTransferItems.mockResolvedValue({ total: 0, results: [] });
|
||||
});
|
||||
|
||||
it('挂载拉取并渲染单列表(缺省参数 page=1)', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
expect(api.fetchExecutedOrders).toHaveBeenCalledTimes(1);
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ page: 1, pageSize: 20 }),
|
||||
);
|
||||
// [断言意图] 单行渲染存在性(排序为后端 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);
|
||||
});
|
||||
|
||||
it('initialGroup 初始筛选 + [全部] 清筛选重拉 + [返回] emit back', async () => {
|
||||
const wrapper = mountList('failed');
|
||||
await flushPromises();
|
||||
// [断言意图] 初始筛选生效:首拉带 statusGroup=failed。
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ statusGroup: 'failed', page: 1 }),
|
||||
);
|
||||
// [断言意图] 全部 chip 清筛选并重拉。
|
||||
await wrapper.find('[data-testid="transfer-executed-all"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ statusGroup: undefined, page: 1 }),
|
||||
);
|
||||
// [断言意图] 返回=emit('back'),由首页面板切回卡片视图。
|
||||
await wrapper.find('[data-testid="transfer-executed-back"]').trigger('click');
|
||||
expect(wrapper.emitted('back')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('日期范围变更带参重拉(dateFrom/dateTo + page=1;仅筛列表,计数恒全量由后端保证)', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-executed-date-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 flushPromises();
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ dateFrom: '2026-09-01', dateTo: '2026-09-30', page: 1 }),
|
||||
);
|
||||
});
|
||||
|
||||
it('分页:下一页带 page=2 重拉,首页时上一页禁用', async () => {
|
||||
// 后端契约:page 请求参数原样回显(response.page=请求页),mock 同口径。
|
||||
api.fetchExecutedOrders.mockImplementation((params: { page?: number } | undefined) =>
|
||||
Promise.resolve(pagePayload({
|
||||
total: 45,
|
||||
page: params?.page ?? 1,
|
||||
orders: [FAILED_TICKET, UNKNOWN_TICKET],
|
||||
})),
|
||||
);
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
expect((wrapper.find('[data-testid="transfer-executed-prev"]').element as HTMLButtonElement).disabled).toBe(true);
|
||||
await wrapper.find('[data-testid="transfer-executed-next"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(expect.objectContaining({ page: 2 }));
|
||||
expect((wrapper.find('[data-testid="transfer-executed-prev"]').element as HTMLButtonElement).disabled).toBe(false);
|
||||
});
|
||||
|
||||
it('failed 单行点击展开 invoice 粒度明细,且动作区含 [重试] 与 [关闭调拨单]', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-executed-items-D-FAIL-1"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="transfer-executed-order-D-FAIL-1"]').trigger('click');
|
||||
await flushPromises();
|
||||
const items = wrapper.find('[data-testid="transfer-executed-items-D-FAIL-1"]');
|
||||
expect(items.exists()).toBe(true);
|
||||
// [断言意图] 展开=invoice 粒度行明细(逐 Invoice 行可见)。
|
||||
expect(items.text()).toContain('INV-A');
|
||||
expect(items.text()).toContain('INV-B');
|
||||
expect(wrapper.find('[data-testid="transfer-executed-retry-D-FAIL-1"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-executed-close-D-FAIL-1"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('failed 单 [重试]:调用单级重试端点,rerun 成功后重拉列表', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
api.retryTransferOrder.mockResolvedValueOnce({
|
||||
doc_no: 'D-FAIL-1', rerun: true, run_no: 'RUN-2', ready: 2, blocked: [], total: 2,
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-executed-retry-D-FAIL-1"]').trigger('click');
|
||||
await flushPromises();
|
||||
// [断言意图] 一键恢复主路径:重试直调 POST /documents/{doc_no}/retry。
|
||||
expect(api.retryTransferOrder).toHaveBeenCalledWith('D-FAIL-1');
|
||||
expect(api.fetchExecutedOrders.mock.calls.length).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
|
||||
it('关闭单:原因必填(空禁用确认),填写后确认调用 close 并刷新列表', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-executed-close-D-FAIL-1"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-executed-close-dialog"]').exists()).toBe(true);
|
||||
const confirm = wrapper.find('[data-testid="transfer-executed-close-confirm"]');
|
||||
// [断言意图] D18 原因必填:空原因确认钮禁用(后端同样兜底 400)。
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(true);
|
||||
await wrapper.find('[data-testid="transfer-executed-close-reason"]').setValue('ERP 查无此单');
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(false);
|
||||
await confirm.trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.closeTransferDocument).toHaveBeenCalledTimes(1);
|
||||
expect(api.closeTransferDocument).toHaveBeenCalledWith('D-FAIL-1', 'ERP 查无此单');
|
||||
// [断言意图] 关闭成功后重拉列表(行脱离回待执行池,单面需同步)。
|
||||
expect(api.fetchExecutedOrders.mock.calls.length).toBeGreaterThanOrEqual(2);
|
||||
expect(wrapper.find('[data-testid="transfer-executed-close-dialog"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('result_unknown 单仅 [重新触发]:无关闭入口、无重试(D11 红线)', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-executed-retrigger-D-UNK-1"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-executed-close-D-UNK-1"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-executed-retry-D-UNK-1"]').exists()).toBe(false);
|
||||
|
||||
await wrapper.find('[data-testid="transfer-executed-retrigger-D-UNK-1"]').trigger('click');
|
||||
await flushPromises();
|
||||
// [断言意图] 重新触发复用 T10 封装(run_no+doc_no),成功后重拉列表。
|
||||
expect(api.retriggerTransferDocument).toHaveBeenCalledWith('RUN-1', 'D-UNK-1');
|
||||
expect(api.fetchExecutedOrders.mock.calls.length).toBeGreaterThanOrEqual(2);
|
||||
});
|
||||
|
||||
it('[刷新] 按钮重拉列表', async () => {
|
||||
const wrapper = mountList();
|
||||
await flushPromises();
|
||||
const before = api.fetchExecutedOrders.mock.calls.length;
|
||||
await wrapper.find('[data-testid="transfer-executed-refresh"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.fetchExecutedOrders.mock.calls.length).toBe(before + 1);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,417 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferExecutedOrders.vue
|
||||
用途:「已执行调拨单」明细列表子视图(首页统计卡片下钻目标,与待办/可调拨
|
||||
子视图同模式)——工具栏(← 返回 + 全部 + 日期范围 + 刷新)+ 单分组列表
|
||||
(单行点击展开 invoice 粒度明细;failed 行 [重查]+单据级 [关闭单];
|
||||
result_unknown 行仅 [重新触发],D11 无关闭入口)+ 上一页/下一页分页;
|
||||
无自动轮询(进入拉一次 + 手动刷新)。
|
||||
依赖:transfer.api(fetchExecutedOrders/closeTransferDocument/retriggerTransferDocument)、
|
||||
useMessage、i18n chat.transfer.homeExecuted.*。
|
||||
逻辑:props.initialGroup(首页卡片点击带入的初始分组,''=全部)→ mounted→load;
|
||||
[全部] 点击→清 statusGroup+page=1;日期范围变更→page=1+load;[返回]→
|
||||
emit('back') 由首页面板切回卡片视图;关闭单走 D18 原因必填弹窗(同单行
|
||||
影响面 + 「关闭调拨单≠ERP 无单」红线)→close→load。行为与融合卡
|
||||
(TransferResultCard)一致。分组计数恒全量由后端保证,本视图不消费计数
|
||||
(计数展示在首页 TransferExecutedCards)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
closeTransferDocument,
|
||||
fetchExecutedOrders,
|
||||
retryTransferOrder,
|
||||
retriggerTransferDocument,
|
||||
} from '../../api/transfer.api';
|
||||
import type {
|
||||
TransferExecutedOrder,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
/** 每页条数(与后端默认 page_size=20 同口径;上限 100 由后端收口)。 */
|
||||
const PAGE_SIZE = 20;
|
||||
|
||||
const { t } = useI18n();
|
||||
const { error: notifyError, success: notifySuccess } = useMessage();
|
||||
|
||||
// props:进入子视图时的初始分组(首页卡片点击带入);''=全部。
|
||||
const props = defineProps<{ initialGroup?: string }>();
|
||||
const emit = defineEmits<{ (e: 'back'): void }>();
|
||||
|
||||
const orders = ref<TransferExecutedOrder[]>([]);
|
||||
const total = ref(0);
|
||||
const page = ref(1);
|
||||
/** 当前单分组筛选(''=全部;首页卡片带入,[全部] 清回)。 */
|
||||
const statusGroup = ref(props.initialGroup || '');
|
||||
const dateFrom = ref('');
|
||||
const dateTo = ref('');
|
||||
const loading = ref(false);
|
||||
/** 展开行明细的单(doc_no;单行点击切换,invoice 粒度)。 */
|
||||
const expandedDocNo = ref('');
|
||||
/** 待关闭单弹窗(D18:docNo + 原因必填)。 */
|
||||
const closeDialog = ref<{ docNo: string; reason: string }>({ docNo: '', reason: '' });
|
||||
|
||||
const actionBusy = ref(false);
|
||||
|
||||
const hasNext = computed(() => page.value * PAGE_SIZE < total.value);
|
||||
const hasPrev = computed(() => page.value > 1);
|
||||
|
||||
/** 关闭弹窗目标单(按 doc_no 回查,渲染同单行影响面清单)。 */
|
||||
const closeTarget = computed<TransferExecutedOrder | null>(
|
||||
() => orders.value.find((order) => order.doc_no === closeDialog.value.docNo) ?? null,
|
||||
);
|
||||
|
||||
/** 拉取已执行单(status_group/时间窗仅筛列表;分组计数恒全量由后端保证)。 */
|
||||
async function load() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const data = await fetchExecutedOrders({
|
||||
statusGroup: statusGroup.value || undefined,
|
||||
dateFrom: dateFrom.value || undefined,
|
||||
dateTo: dateTo.value || undefined,
|
||||
page: page.value,
|
||||
pageSize: PAGE_SIZE,
|
||||
});
|
||||
orders.value = data.orders;
|
||||
total.value = data.total;
|
||||
page.value = data.page;
|
||||
} catch (e) {
|
||||
// 单次失败保留旧值(子视图入口口径:手动刷新兜底,不做自动轮询)
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** [全部] 点击:清分组筛选并回第一页重拉(与日期变更同口径)。 */
|
||||
async function clearGroup() {
|
||||
statusGroup.value = '';
|
||||
page.value = 1;
|
||||
await load();
|
||||
}
|
||||
|
||||
/** 日期范围变更:仅筛列表(计数恒全量),回第一页。 */
|
||||
async function onDateChange() {
|
||||
page.value = 1;
|
||||
await load();
|
||||
}
|
||||
|
||||
async function goToPage(next: number) {
|
||||
page.value = next;
|
||||
await load();
|
||||
}
|
||||
|
||||
/** 单行点击:展开/收起 invoice 粒度行明细。 */
|
||||
function toggleExpand(docNo: string) {
|
||||
expandedDocNo.value = expandedDocNo.value === docNo ? '' : docNo;
|
||||
}
|
||||
|
||||
function isFailedOrder(order: TransferExecutedOrder): boolean {
|
||||
return order.status === 'business_failed' || order.status === 'technical_failed';
|
||||
}
|
||||
|
||||
/** 单状态徽标文案(成功族亮 ERP 单号,无单号回退状态文案;禁 undefined/null 上屏)。 */
|
||||
function orderBadgeText(order: TransferExecutedOrder): string {
|
||||
switch (order.status) {
|
||||
case 'success':
|
||||
case 'duplicate_success':
|
||||
return order.erp_document_no || t('chat.transfer.orderStatus.success');
|
||||
case 'pending':
|
||||
return t('chat.transfer.orderStatus.pending');
|
||||
case 'executing':
|
||||
return t('chat.transfer.orderStatus.executing');
|
||||
case 'business_failed':
|
||||
case 'technical_failed':
|
||||
// 用户口径:失败统一展示(原因走行级明细),不再区分业务/技术。
|
||||
return t('chat.transfer.orderStatus.failed');
|
||||
case 'result_unknown':
|
||||
return t('chat.transfer.orderStatus.resultUnknown');
|
||||
default:
|
||||
return order.status;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* failed 单 [重试](一键恢复主路径):调 POST /documents/{doc_no}/retry——
|
||||
* 后端按单圈行逐行重查,全部 ready 自动建新 Run 重跑(复用原单号,分支②);
|
||||
* 部分行仍阻断则不重跑(单是原子单位),阻断明细以 toast 摘要提示、行留恢复池。
|
||||
*/
|
||||
async function onRetry(order: TransferExecutedOrder) {
|
||||
actionBusy.value = true;
|
||||
try {
|
||||
const result = await retryTransferOrder(order.doc_no);
|
||||
if (result.rerun) {
|
||||
notifySuccess(t('chat.transfer.orderAction.retryAccepted', { docNo: order.doc_no }));
|
||||
} else {
|
||||
notifyError(t('chat.transfer.orderAction.retryPartial', {
|
||||
ready: result.ready,
|
||||
blocked: result.blocked.length,
|
||||
}));
|
||||
}
|
||||
await load();
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
actionBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* result_unknown 行 [重新触发](D11 唯一出口):复用 T13 封装
|
||||
* (run_no + doc_no → POST /runs/{run_no}/documents/{doc_no}/retrigger),成功后重拉。
|
||||
*/
|
||||
async function onRetrigger(order: TransferExecutedOrder) {
|
||||
if (!order.run_no || actionBusy.value) return;
|
||||
actionBusy.value = true;
|
||||
try {
|
||||
await retriggerTransferDocument(order.run_no, order.doc_no);
|
||||
notifySuccess(t('chat.transfer.toastRetriggerAccepted'));
|
||||
await load();
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
actionBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openCloseDialog(order: TransferExecutedOrder) {
|
||||
closeDialog.value = { docNo: order.doc_no, reason: '' };
|
||||
}
|
||||
|
||||
/** [关闭单] 确认(D18:原因必填;仅失败单可关):close 后单 cancelled、行脱离回
|
||||
* ready_to_execute;成功后重拉列表(统计/列表同步,组锁释放可另开新单)。 */
|
||||
async function confirmCloseOrder() {
|
||||
const reason = closeDialog.value.reason.trim();
|
||||
if (!closeDialog.value.docNo || !reason || actionBusy.value) return;
|
||||
actionBusy.value = true;
|
||||
try {
|
||||
await closeTransferDocument(closeDialog.value.docNo, reason);
|
||||
closeDialog.value = { docNo: '', reason: '' };
|
||||
notifySuccess(t('chat.transfer.toastOrderClosed'));
|
||||
await load();
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
actionBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => { void load(); });
|
||||
</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"
|
||||
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'"
|
||||
data-testid="transfer-executed-all"
|
||||
@click="clearGroup"
|
||||
>
|
||||
{{ $t('chat.transfer.homeExecuted.all') }}
|
||||
</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 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">
|
||||
{{ $t('chat.transfer.homeExecuted.refresh') }}
|
||||
</button>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- 空态 -->
|
||||
<div v-if="!orders.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted" data-testid="transfer-executed-empty">
|
||||
{{ $t('chat.transfer.homeExecuted.empty') }}
|
||||
</div>
|
||||
|
||||
<!-- 单列表:单行点击展开 invoice 粒度明细;动作按 D11/D18 守卫 -->
|
||||
<ul v-else class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="order in orders"
|
||||
:key="order.doc_no"
|
||||
class="cursor-pointer rounded-lg border border-default"
|
||||
:data-testid="`transfer-executed-order-${order.doc_no}`"
|
||||
@click="toggleExpand(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">
|
||||
{{ order.receipt_date || '—' }} · {{ order.from_warehouse }}→{{ order.to_warehouse }}
|
||||
· {{ $t('chat.transfer.materialCount', { count: order.items.length }) }}
|
||||
</span>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': order.status_group === 'success',
|
||||
'bg-sky-50 text-sky-700': order.status_group === 'executing',
|
||||
'bg-red-50 text-red-700': order.status_group === 'failed',
|
||||
'bg-amber-50 text-amber-700': order.status_group === 'result_unknown',
|
||||
}"
|
||||
:data-testid="`transfer-executed-status-${order.doc_no}`"
|
||||
>
|
||||
{{ orderBadgeText(order) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- 单据级行内动作(D11/D18:result_unknown 仅重新触发;failed 行重查 + 单据级关闭单) -->
|
||||
<div
|
||||
v-if="order.status === 'result_unknown' || isFailedOrder(order)"
|
||||
class="flex flex-wrap gap-2 px-3 pb-2"
|
||||
>
|
||||
<button
|
||||
v-if="order.status === 'result_unknown'"
|
||||
type="button"
|
||||
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-executed-retrigger-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click.stop="onRetrigger(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retrigger') }}
|
||||
</button>
|
||||
<template v-if="isFailedOrder(order)">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-executed-retry-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click.stop="onRetry(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-executed-close-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click.stop="openCloseDialog(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.closeOrder') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 展开明细(invoice 粒度行集) -->
|
||||
<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>
|
||||
<td class="p-1">{{ item.lot_no || '—' }}</td>
|
||||
<td class="p-1">{{ item.quantity }}<template v-if="item.unit"> {{ item.unit }}</template></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- 分页:上一页/下一页(无自动轮询,手动翻页) -->
|
||||
<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"
|
||||
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"
|
||||
data-testid="transfer-executed-next"
|
||||
:disabled="!hasNext || loading"
|
||||
@click="goToPage(page + 1)"
|
||||
>
|
||||
→
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线) -->
|
||||
<div
|
||||
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"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<h3 class="text-base font-bold text-primary">
|
||||
{{ $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>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -1,8 +1,9 @@
|
||||
/**
|
||||
* features/chat/components/messages/TransferHomePanel.spec.ts
|
||||
* 用途:验证在途仓自动调拨 Agent 的 Chat 首页入口区——
|
||||
* home 视图渲染“今日待办 + 历史待办”计数卡;点击入口独立触发
|
||||
* source-select / backlog 卡片(复用自驱动的 TransferMessageView,不注入消息流)。
|
||||
* home 视图渲染“今日待办 + 历史待办”计数卡与「已执行」统计卡片入口;
|
||||
* 点击入口独立触发 source-select / backlog 卡片(复用自驱动的
|
||||
* TransferMessageView,不注入消息流)与已执行明细列表子视图。
|
||||
* 依赖:vi.mock(transfer.api)、@vue/test-utils、i18n。
|
||||
* 逻辑:Mock API 断言入口切换与计数展示;对应后端 backlog/summary 契约面。
|
||||
*/
|
||||
@@ -24,6 +25,7 @@ const api = vi.hoisted(() => ({
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
listExecutableTransferItems: vi.fn(),
|
||||
fetchExecutedOrders: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
@@ -48,6 +50,11 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
api.listTransferSources.mockResolvedValue([
|
||||
{ source_code: 'DBS-AWSBI', display_name: 'AWSBI', platform: 'dbs', enabled: true, has_ready_file: true, file_status: 'ready' },
|
||||
]);
|
||||
// 已执行卡片入口挂载拉分组计数(pageSize=1);不 mock 会因组件静默失败成为未处理 rejection。
|
||||
api.fetchExecutedOrders.mockResolvedValue({
|
||||
groups: { success: 0, failed: 0, executing: 0, result_unknown: 0 },
|
||||
orders: [], total: 0, page: 1, page_size: 1,
|
||||
});
|
||||
});
|
||||
|
||||
it('home 视图渲染标题、今日待办入口与三张历史待办计数卡', async () => {
|
||||
@@ -131,6 +138,27 @@ describe('TransferHomePanel chat home entry', () => {
|
||||
expect(wrapper.text()).toContain('INV-003');
|
||||
});
|
||||
|
||||
it('点击已执行统计卡片进入明细列表子视图:initial-group 透传且 flow-active=true', async () => {
|
||||
// 卡片分组计数非零(入口可见);列表 mock 返回空单(本例只验证接线,不验证行渲染)。
|
||||
api.fetchExecutedOrders.mockResolvedValue({
|
||||
groups: { success: 3, failed: 2, executing: 1, result_unknown: 1 },
|
||||
orders: [], total: 0, page: 1, page_size: 20,
|
||||
});
|
||||
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-executed-card-failed"]').trigger('click');
|
||||
await flushPromises();
|
||||
// [断言意图] 卡片=入口:HomePanel 切到 executed 子视图并挂载列表组件。
|
||||
expect(wrapper.find('[data-testid="transfer-executed"]').exists()).toBe(true);
|
||||
// [断言意图] initial-group 透传:列表首拉带 statusGroup=failed(卡片点击带入的初始分组)。
|
||||
expect(api.fetchExecutedOrders).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ statusGroup: 'failed', page: 1 }),
|
||||
);
|
||||
// [断言意图] 子视图=业务流激活(父级据此隐藏聊天输入框)。
|
||||
expect(wrapper.emitted('flow-active')?.at(-1)?.[0]).toBe(true);
|
||||
});
|
||||
|
||||
it('子视图提供“返回首页”并切回 home', async () => {
|
||||
const wrapper = mountHome();
|
||||
await flushPromises();
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferHomePanel.vue
|
||||
用途:在途仓自动调拨 Agent 的 Chat 首页入口区——上区「库存匹配」动作入口,
|
||||
下区「待办看板」四队列(可调拨明细/待恢复异常/已人工关闭/结果未知),
|
||||
点击进入对应处理视图(复用自驱动的 TransferMessageView)。
|
||||
依赖:TransferMessageView(复用自驱动卡片)、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:home 时拉取待办汇总与可调拨明细计数;非 home 时渲染 TransferMessageView。
|
||||
卡片不注入消息流,因此无需后端 ChatLog 消息。
|
||||
中区「待办看板」四队列(可调拨明细/待恢复异常/已人工关闭/结果未知),
|
||||
下区「已执行」统计卡片入口(四张分组计数卡,点击跳转明细列表子视图),
|
||||
点击进入对应处理视图(复用自驱动的 TransferMessageView / TransferExecutedOrders)。
|
||||
依赖:TransferMessageView(复用自驱动卡片)、TransferExecutedCards(已执行卡片入口)、
|
||||
TransferExecutedOrders(已执行明细列表子视图)、useChatTransfer、i18n chat.transfer.*。
|
||||
逻辑:home 时拉取待办汇总与可调拨明细计数并挂载已执行卡片;'executed' 子视图由
|
||||
openExecuted(group) 进入(卡片带入初始分组)并挂载列表组件;其余非 home 视图
|
||||
渲染 TransferMessageView。卡片不注入消息流,因此无需后端 ChatLog 消息。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import TransferMessageView from './TransferMessageView.vue';
|
||||
import TransferExecutedCards from './TransferExecutedCards.vue';
|
||||
import TransferExecutedOrders from './TransferExecutedOrders.vue';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -21,7 +26,7 @@ const emit = defineEmits<{
|
||||
'flow-active': [active: boolean];
|
||||
}>();
|
||||
|
||||
type HomeView = 'home' | 'source-select' | 'backlog' | 'executable';
|
||||
type HomeView = 'home' | 'source-select' | 'backlog' | 'executable' | 'executed';
|
||||
/** 待处理池结果筛选(与 TransferBacklogSummaryCard 的筛选选项一致)。 */
|
||||
type BacklogFilter = 'all' | 'recoverable' | 'closed' | 'unknown';
|
||||
|
||||
@@ -29,6 +34,8 @@ const transfer = useChatTransfer();
|
||||
const view = ref<HomeView>('home');
|
||||
/** 历史待办计数卡对应的初始筛选:点击哪张卡就落到哪个切片。 */
|
||||
const backlogFilter = ref<BacklogFilter>('all');
|
||||
/** 已执行卡片带入的初始分组(''=全部)。 */
|
||||
const executedGroup = ref<'success' | 'failed' | 'executing' | 'result_unknown' | ''>('');
|
||||
|
||||
/** 打开待处理池并按计数卡切片(recoverable/closed/unknown)。 */
|
||||
function openBacklog(filter: BacklogFilter) {
|
||||
@@ -36,6 +43,12 @@ function openBacklog(filter: BacklogFilter) {
|
||||
view.value = 'backlog';
|
||||
}
|
||||
|
||||
/** 打开已执行明细列表子视图(卡片入口,与 openBacklog 同模式)。 */
|
||||
function openExecuted(group: 'success' | 'failed' | 'executing' | 'result_unknown') {
|
||||
executedGroup.value = group;
|
||||
view.value = 'executed';
|
||||
}
|
||||
|
||||
/** home 视图需要待办汇总与可调拨明细计数;进入时拉取。 */
|
||||
async function loadHomeSummary() {
|
||||
if (view.value !== 'home') return;
|
||||
@@ -139,9 +152,20 @@ function goBack() {
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<!-- 已执行调拨单:统计卡片入口(点击跳转明细列表子视图) -->
|
||||
<section :aria-label="$t('chat.transfer.homeExecuted.title')">
|
||||
<p class="mb-2 text-sm font-bold text-secondary">{{ $t('chat.transfer.homeExecuted.title') }}</p>
|
||||
<TransferExecutedCards @open="openExecuted" />
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 已执行明细列表子视图(卡片下钻目标;返回回首页) -->
|
||||
<div v-else-if="view === 'executed'" class="w-full max-w-[min(96vw,1500px)] pr-2">
|
||||
<TransferExecutedOrders :initial-group="executedGroup" @back="goBack" />
|
||||
</div>
|
||||
|
||||
<!-- 子流程:复用自驱动的 TransferMessageView(宽表格需要全宽,上限对齐消息气泡宽布局) -->
|
||||
<div v-else class="w-full max-w-[min(96vw,1500px)] pr-2">
|
||||
<button
|
||||
|
||||
@@ -5,10 +5,15 @@
|
||||
逻辑:明细表渲染 filtered(关键字/结果筛选生效);阻断/未成熟项 checkbox 禁用;
|
||||
勾选键 = 明细行 item_id(历史回放行无 item_id 禁用防误选);
|
||||
库存数量下方小字透出查询时刻(checked_at);stale 行置灰 + 重查提示;
|
||||
file_current=false 行提示文件已更新;blocked_file_removed 徽标独立文案;
|
||||
重查范围含可恢复阻断与可执行行(重查仍按 invoice_no 提交);阻断原因经结果徽标
|
||||
title 悬浮透出不占行高;无选择或 busy 时生成按钮禁用;emit execute(itemIds);
|
||||
来源级解析/文件失败经 sources.error_code 透出(防"安静全 0")。
|
||||
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")。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -58,6 +63,11 @@ function isBlocked(item: TransferMatchingItem): boolean {
|
||||
return String(item.result).startsWith('blocked_');
|
||||
}
|
||||
|
||||
/** 文件已移除的行:证据已失效,重查/重新匹配都救不了,退出主视图进待处理池。 */
|
||||
function isFileRemoved(item: TransferMatchingItem): boolean {
|
||||
return item.result === 'blocked_file_removed';
|
||||
}
|
||||
|
||||
/** 勾选可用范围:可执行(可生成调拨)或可恢复阻断(可重查 ERP)。 */
|
||||
function isSelectable(item: TransferMatchingItem): boolean {
|
||||
return item.result === 'executable';
|
||||
@@ -67,13 +77,17 @@ function isCheckable(item: TransferMatchingItem): boolean {
|
||||
return hasSelectionKey(item) && (isSelectable(item) || isBlocked(item));
|
||||
}
|
||||
|
||||
/** 可重查行:可恢复阻断 + 可执行(已可执行也允许重查核对最新库存)。 */
|
||||
/** 可重查行:可恢复阻断 + 可执行(文件已移除行除外——重查救不了已消失的行)。 */
|
||||
function isRequeryable(item: TransferMatchingItem): boolean {
|
||||
return isBlocked(item) || item.result === 'executable';
|
||||
return (isBlocked(item) || item.result === 'executable') && !isFileRemoved(item);
|
||||
}
|
||||
|
||||
/** 已失效行(文件移除):主视图隐藏,仅以计数提示承载(去待处理池处理)。 */
|
||||
const removedRows = computed(() => props.items.filter(isFileRemoved));
|
||||
|
||||
const filtered = computed(() =>
|
||||
props.items.filter((item) => {
|
||||
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]
|
||||
@@ -135,6 +149,7 @@ 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',
|
||||
blocked_future_date: 'chat.transfer.resultBlocked',
|
||||
@@ -173,7 +188,7 @@ 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-5" data-testid="transfer-match-counts">
|
||||
<div class="mb-3 grid grid-cols-2 gap-2 sm:grid-cols-7" 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>
|
||||
@@ -194,6 +209,16 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
<div class="text-lg font-black text-brand-600">{{ summary.estimated_external_write_count }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.estimatedExternalWrites') }}</div>
|
||||
</div>
|
||||
<!-- 待查库存:文件已落地、尚未查过 ERP 库存的行数(历史回放缺省 0) -->
|
||||
<div class="rounded-lg bg-surface-soft p-2 text-center">
|
||||
<div class="text-lg font-black text-secondary">{{ summary.counts.pending_stock_check_count ?? 0 }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.pendingStockCheckCount') }}</div>
|
||||
</div>
|
||||
<!-- 已失效:文件消失已出清的行数(不进默认视图,处理入口在待处理异常池) -->
|
||||
<div class="rounded-lg bg-surface-soft p-2 text-center">
|
||||
<div class="text-lg font-black text-muted">{{ summary.counts.invalid_count ?? 0 }}</div>
|
||||
<div class="text-[11px] text-muted">{{ $t('chat.transfer.invalidRowCount', { count: summary.counts.invalid_count ?? 0 }) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -301,15 +326,15 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="{
|
||||
'bg-emerald-50 text-emerald-700': item.result === 'executable',
|
||||
'bg-amber-50 text-amber-700': item.result === 'not_matured',
|
||||
'bg-red-50 text-red-700': !isSelectable(item) && item.result !== 'not_matured',
|
||||
'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(超 TTL 执行会被拦截)/ 文件版本已过期 -->
|
||||
<!-- 行级警示小标: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"
|
||||
@@ -341,6 +366,16 @@ function reasonTitle(item: TransferMatchingItem): string | undefined {
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- 已失效行折叠提示:文件移除的行退出主视图(证据已失效不可行动),
|
||||
引导去待处理异常池处理(可「标记无需继续处理」),不在主清单占位。 -->
|
||||
<div
|
||||
v-if="removedRows.length"
|
||||
class="mt-2 rounded-lg bg-surface-soft px-3 py-2 text-[11px] text-muted"
|
||||
data-testid="transfer-file-removed-hint"
|
||||
>
|
||||
{{ $t('chat.transfer.fileRemovedQuarantined', { count: removedRows.length }) }}
|
||||
</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.selectedCount', { count: selectedCount }) }} ·
|
||||
|
||||
@@ -16,6 +16,7 @@ const api = vi.hoisted(() => ({
|
||||
listExecutableTransferItems: vi.fn(),
|
||||
executeTransferItems: vi.fn(),
|
||||
getTransferRun: vi.fn(),
|
||||
retryTransferOrder: vi.fn(),
|
||||
retryTransferItem: vi.fn(),
|
||||
manualCloseTransferItem: vi.fn(),
|
||||
batchRequeryTransferItems: vi.fn(),
|
||||
@@ -26,6 +27,8 @@ const api = vi.hoisted(() => ({
|
||||
listTransferBacklog: vi.fn(),
|
||||
getTransferBacklogSummary: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
retriggerTransferDocument: vi.fn(),
|
||||
closeTransferDocument: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/transfer.api', () => api);
|
||||
@@ -60,7 +63,7 @@ const payload = {
|
||||
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',
|
||||
invoice_no: 'INV-001', receipt_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' }],
|
||||
@@ -328,3 +331,254 @@ describe('TransferMessageView self-driving wiring', () => {
|
||||
expect(wrapper.find('[data-testid="transfer-match-card"]').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Task 13 融合卡(D9:调拨单清单=进度=结果):T0 全待处理 / T1 逐单徽标+轮询 /
|
||||
// T2 终态动作 / result_unknown 重新触发(D11)/ 失败行关闭单(D18)/ 重查库存 /
|
||||
// 门禁 4xx 行内报错 / 无取消执行入口。
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const t13Line = (materialNo: string, name: string, lot: string, qty: string, reason?: string) => ({
|
||||
material_no: materialNo, material_name: name, lot_no: lot, quantity: qty, unit: 'KG',
|
||||
// [P2-3 契约扩充] 后端失败/未知单行带行级 reason(= 行级 result_message);缺省=无行级原因态
|
||||
...(reason ? { reason } : {}),
|
||||
});
|
||||
|
||||
function t13Run(status: string, orders: Array<Record<string, unknown>>) {
|
||||
return {
|
||||
run_no: 'RUN-T13', status,
|
||||
result: { external_documents: [], exceptions: [] },
|
||||
orders,
|
||||
};
|
||||
}
|
||||
|
||||
/** T0:提交后立即(单已建好,全部待处理)。 */
|
||||
const t13Pending = t13Run('queued', [
|
||||
{
|
||||
doc_no: 'HTT-OR-1', receipt_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',
|
||||
status: 'pending', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M003', '材料丙', 'V3', '55.000000')],
|
||||
},
|
||||
]);
|
||||
|
||||
/** T1:执行中(轮询刷新,逐单亮结果)。 */
|
||||
const t13Executing = t13Run('executing', [
|
||||
{
|
||||
doc_no: 'D-EXE', receipt_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',
|
||||
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',
|
||||
status: 'business_failed', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('M003', '材料丙', 'V3', '55.000000')],
|
||||
},
|
||||
]);
|
||||
|
||||
/** T2:终态部分失败(成功 + 结果未知 + 业务失败)。 */
|
||||
const t13Partial = t13Run('partial_failed', [
|
||||
{
|
||||
doc_no: 'D-OK', receipt_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',
|
||||
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',
|
||||
status: 'business_failed', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('MAT-1', '连接器组件', 'LOT-10', '1200.000000', '料号无有效成本')],
|
||||
},
|
||||
]);
|
||||
|
||||
function mountRunView() {
|
||||
return mount(TransferMessageView, {
|
||||
props: { payload: { kind: 'run', run_no: 'RUN-T13' } },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('融合卡(Task 13):调拨单清单=进度=结果', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
api.executeTransferItems.mockResolvedValue({ run_no: 'RUN-T13', status: 'queued' });
|
||||
api.retriggerTransferDocument.mockResolvedValue({ run_no: 'RUN-T13', doc_no: 'D-UNK', status: 'queued' });
|
||||
api.closeTransferDocument.mockResolvedValue({ status: 'cancelled' });
|
||||
api.batchRequeryTransferItems.mockResolvedValue({
|
||||
total: 1, results: [{ item_id: 101, ok: true, status: 'ready_to_execute' }],
|
||||
});
|
||||
});
|
||||
|
||||
it('T0 全待处理:卡顶「排队中」,单行=收料日期·仓库·物料数·合计+待处理徽标,行明细常驻展开,非终态无下载区', async () => {
|
||||
api.getTransferRun.mockResolvedValue(t13Pending);
|
||||
const wrapper = mountRunView();
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-result-card"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-run-badge"]').text()).toContain('排队中');
|
||||
const summary = wrapper.find('[data-testid="transfer-order-summary-HTT-OR-1"]');
|
||||
expect(summary.exists()).toBe(true);
|
||||
expect(summary.text()).toContain('2026-09-23');
|
||||
expect(summary.text()).toContain('B25');
|
||||
expect(summary.text()).toContain('B02');
|
||||
expect(summary.text()).toContain('2 项物料');
|
||||
expect(summary.text()).toContain('600');
|
||||
expect(wrapper.find('[data-testid="transfer-order-status-HTT-OR-1"]').text()).toContain('待处理');
|
||||
// 行明细常驻展开:不做任何点击即可见物料行
|
||||
const row = wrapper.find('[data-testid="transfer-order-HTT-OR-1"]');
|
||||
expect(row.text()).toContain('材料甲');
|
||||
expect(row.text()).toContain('材料乙');
|
||||
// 非终态不出现下载动作区
|
||||
expect(wrapper.find('[data-testid="transfer-result-downloads"]').exists()).toBe(false);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('T1 执行中:4s 轮询逐单亮徽标(单号/执行中/失败),卡顶汇总「执行中」;单次失败保留旧值并显示连接中', async () => {
|
||||
vi.useFakeTimers();
|
||||
try {
|
||||
api.getTransferRun.mockResolvedValueOnce(t13Pending).mockResolvedValueOnce(t13Executing);
|
||||
const wrapper = mountRunView();
|
||||
await vi.advanceTimersByTimeAsync(0); // 初始帧:全待处理
|
||||
expect(wrapper.find('[data-testid="transfer-run-badge"]').text()).toContain('排队中');
|
||||
await vi.advanceTimersByTimeAsync(4000); // 4s 轮询帧:逐单亮结果
|
||||
expect(wrapper.find('[data-testid="transfer-run-badge"]').text()).toContain('执行中');
|
||||
expect(wrapper.find('[data-testid="transfer-order-status-D-OK"]').text()).toContain('1401-2609230008');
|
||||
expect(wrapper.find('[data-testid="transfer-order-status-D-EXE"]').text()).toContain('执行中');
|
||||
expect(wrapper.find('[data-testid="transfer-order-status-D-BUS"]').text()).toContain('失败');
|
||||
// 单次轮询失败:显示「连接中」,旧单面保留不清空
|
||||
api.getTransferRun.mockRejectedValueOnce(new Error('network down'));
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(wrapper.find('[data-testid="transfer-poll-connecting"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-order-status-D-OK"]').exists()).toBe(true);
|
||||
wrapper.unmount();
|
||||
} finally {
|
||||
vi.useRealTimers();
|
||||
}
|
||||
});
|
||||
|
||||
it('T2 终态:卡顶「部分失败」+下载区;失败行有重查+关闭单;result_unknown 行仅有重新触发(D11 无关闭入口);无取消执行入口', async () => {
|
||||
api.getTransferRun.mockResolvedValue(t13Partial);
|
||||
const wrapper = mountRunView();
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="transfer-run-badge"]').text()).toContain('部分失败');
|
||||
expect(wrapper.find('[data-testid="transfer-result-downloads"]').exists()).toBe(true);
|
||||
// result_unknown 行:仅 [重新触发],无 [关闭单](D11 禁闭)
|
||||
expect(wrapper.find('[data-testid="transfer-order-retrigger-D-UNK"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-order-close-D-UNK"]').exists()).toBe(false);
|
||||
// business_failed 行:[重试] + [关闭调拨单],无 [重新触发]
|
||||
expect(wrapper.find('[data-testid="transfer-order-retry-D-FAIL"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-order-close-D-FAIL"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-order-retrigger-D-FAIL"]').exists()).toBe(false);
|
||||
// [P2-3] 行级 reason 有/无两态:失败行(带 reason)显示「原因:…」;无行级原因的未知行不渲染原因行
|
||||
const failReason = wrapper.find('[data-testid="transfer-order-reason-D-FAIL"]');
|
||||
expect(failReason.exists()).toBe(true);
|
||||
expect(failReason.text()).toContain('原因:');
|
||||
expect(failReason.text()).toContain('料号无有效成本');
|
||||
expect(wrapper.find('[data-testid="transfer-order-reason-D-UNK"]').exists()).toBe(false);
|
||||
// 成功单无动作按钮
|
||||
expect(wrapper.find('[data-testid="transfer-order-recheck-D-OK"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="transfer-order-close-D-OK"]').exists()).toBe(false);
|
||||
// 无取消执行入口(D9:无取消执行)
|
||||
expect(wrapper.text()).not.toContain('取消执行');
|
||||
expect(wrapper.find('[data-testid="transfer-run-cancel"]').exists()).toBe(false);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('result_unknown 行「重新触发」:确认弹层(D11 幂等语义)后调 retrigger 端点(202)', async () => {
|
||||
api.getTransferRun.mockResolvedValue(t13Partial);
|
||||
const wrapper = mountRunView();
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-order-retrigger-D-UNK"]').trigger('click');
|
||||
const dialog = wrapper.find('[data-testid="transfer-retrigger-dialog"]');
|
||||
expect(dialog.exists()).toBe(true);
|
||||
expect(dialog.text()).toContain('幂等');
|
||||
await wrapper.find('[data-testid="transfer-retrigger-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.retriggerTransferDocument).toHaveBeenCalledWith('RUN-T13', 'D-UNK');
|
||||
expect(wrapper.find('[data-testid="transfer-retrigger-dialog"]').exists()).toBe(false);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('失败行「关闭单」:弹层列同单行影响面+ERP 红线;原因必填(空则确认禁用);确认后调 close 端点并上抛刷新', async () => {
|
||||
api.getTransferRun.mockResolvedValue(t13Partial);
|
||||
const wrapper = mountRunView();
|
||||
await flushPromises();
|
||||
const fetchesBefore = api.getTransferRun.mock.calls.length;
|
||||
await wrapper.find('[data-testid="transfer-order-close-D-FAIL"]').trigger('click');
|
||||
const dialog = wrapper.find('[data-testid="transfer-order-close-dialog"]');
|
||||
expect(dialog.exists()).toBe(true);
|
||||
expect(dialog.text()).toContain('D-FAIL');
|
||||
expect(dialog.text()).toContain('连接器组件'); // 同单行影响面
|
||||
expect(dialog.text()).toContain('ERP'); // 红线:关闭调拨单≠ERP 无单,关前须人工确认
|
||||
const confirm = wrapper.find('[data-testid="transfer-order-close-confirm"]');
|
||||
expect((confirm.element as HTMLButtonElement).disabled).toBe(true); // 原因必填
|
||||
await wrapper.find('[data-testid="transfer-order-close-reason"]').setValue('ERP 查无此单');
|
||||
await wrapper.find('[data-testid="transfer-order-close-confirm"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.closeTransferDocument).toHaveBeenCalledWith('D-FAIL', 'ERP 查无此单');
|
||||
// emit 上抛 → 父级刷新(run 调拨单清单重拉)
|
||||
expect(api.getTransferRun.mock.calls.length).toBeGreaterThan(fetchesBefore);
|
||||
expect(wrapper.find('[data-testid="transfer-order-close-dialog"]').exists()).toBe(false);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('失败行「重试」:调单级重试端点;预检卡提交 202 后切融合卡', async () => {
|
||||
// [断言意图] 202 只拿 run_no 即切融合卡(D8);失败单一键重试直调
|
||||
// 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',
|
||||
status: 'business_failed', erp_document_no: null, error_message: null,
|
||||
lines: [t13Line('MAT-1', '连接器组件', '', '1200.000000')],
|
||||
},
|
||||
]));
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
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);
|
||||
expect(wrapper.find('[data-testid="transfer-run-badge"]').exists()).toBe(true);
|
||||
// [P2-3 无行级原因态] 失败行 reason 缺失时不渲染原因行(状态文案兜底)
|
||||
expect(wrapper.find('[data-testid="transfer-order-reason-D-FAIL"]').exists()).toBe(false);
|
||||
// [一键恢复] 失败行重试直调单级端点(rerun=true 自动重跑)
|
||||
api.retryTransferOrder.mockResolvedValueOnce({
|
||||
doc_no: 'D-FAIL', rerun: true, run_no: 'RUN-9', ready: 1, blocked: [], total: 1,
|
||||
});
|
||||
await wrapper.find('[data-testid="transfer-order-retry-D-FAIL"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(api.retryTransferOrder).toHaveBeenCalledWith('D-FAIL');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('门禁 4xx:useMessage 行内报错,留在预检卡并刷新状态(重拉匹配详情)', async () => {
|
||||
api.executeTransferItems.mockRejectedValueOnce(new Error('部分明细行匹配结果已过期,请重新匹配'));
|
||||
api.getTransferMatching.mockResolvedValue({ summary: payload.summary, items: payload.items, sources: payload.sources });
|
||||
const wrapper = mount(TransferMessageView, {
|
||||
props: { payload },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="transfer-generate-button"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(messageMocks.error).toHaveBeenCalled();
|
||||
expect(wrapper.find('[data-testid="transfer-match-card"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="transfer-result-card"]').exists()).toBe(false);
|
||||
expect(api.getTransferMatching).toHaveBeenCalledWith('MTG-1');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
@@ -1,13 +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 异步——存在抓取中来源时组合式函数自动轮询
|
||||
GET /sources,RPA 回调收口后状态自动刷新,离开来源卡即停轮询;
|
||||
恢复处理 = 按明细 id 重查库存(batch-requery 唯一后端),完成后刷新待处理池并
|
||||
统计提示,不再跳转匹配卡;执行后切换为结果卡;下载走 requestBlob;
|
||||
不展示执行审计入口(决策 19)。
|
||||
统计提示,不再跳转匹配卡;预检卡提交 202(D8)→ 切融合卡 kind='run'(run_no 传卡,
|
||||
轮询由融合卡自驱动,父级停自身轮询),门禁 4xx → useMessage 行内报错 + 预检状态刷新;
|
||||
融合卡失败单「重查库存」复用 batch-requery(会话明细行关联 item_id)、「关闭单」
|
||||
上抛 closed 事件后刷新 run 调拨单清单与可执行池(D18 行脱离回 ready_to_execute);
|
||||
下载走 requestBlob;不展示执行审计入口(决策 19);全程无取消执行入口(D9)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
@@ -21,7 +26,7 @@ import TransferExecutableCard from './TransferExecutableCard.vue';
|
||||
import TransferManualCloseDialog from './TransferManualCloseDialog.vue';
|
||||
import TransferSourceSelectCard from './TransferSourceSelectCard.vue';
|
||||
import { useChatTransfer } from '../../composables/useChatTransfer';
|
||||
import { downloadTransferSourceFiles, getTransferMatching, requeryTransferMatchingItems } from '../../api/transfer.api';
|
||||
import { downloadTransferSourceFiles, getTransferMatching, retryTransferOrder, requeryTransferMatchingItems } from '../../api/transfer.api';
|
||||
import { triggerBlobDownload } from '@/shared/utils/download';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import type {
|
||||
@@ -30,6 +35,7 @@ import type {
|
||||
TransferMatchingSummary,
|
||||
TransferRunResult,
|
||||
TransferSourceProgress,
|
||||
TransferOrder,
|
||||
TransferType,
|
||||
} from '../../types/transfer.types';
|
||||
|
||||
@@ -64,6 +70,8 @@ const closeTarget = ref<TransferBacklogItem | null>(null);
|
||||
const batchCloseIds = ref<number[]>([]);
|
||||
/** 正在重试收料 RPA 的来源编码集合(按来源独立展示重试中)。 */
|
||||
const retryingSource = ref<Set<string>>(new Set());
|
||||
/** 上次提交执行的明细行快照(失败单「重查库存」按物料/收料日期关联 item_id 用)。 */
|
||||
const lastExecutedItems = ref<TransferMatchingItem[]>([]);
|
||||
|
||||
const transfer = useChatTransfer();
|
||||
|
||||
@@ -107,6 +115,12 @@ function applyPayload(payload?: Record<string, unknown> | null) {
|
||||
applyPayload(props.payload);
|
||||
watch(() => props.payload, applyPayload);
|
||||
|
||||
// 离开来源选择卡即停来源轮询(确认匹配切匹配卡/回放替换 payload 后,
|
||||
// 来源抓取状态与本卡无关;轮询实例由 useChatTransfer 作用域销毁兜底清理)
|
||||
watch(mode, (value) => {
|
||||
if (value !== 'source-select') transfer.stopSourcePolling();
|
||||
});
|
||||
|
||||
/** 打包下载选中来源的最新归档收料文件 */
|
||||
async function onDownloadSources(sourceCodes: string[]) {
|
||||
if (!sourceCodes.length) return;
|
||||
@@ -160,18 +174,69 @@ async function onExecutableRequery(itemIds: number[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/** 按勾选明细行直接生成调拨单(item-centric:门禁在后端,失败经 reportError 展示) */
|
||||
/**
|
||||
* 预检卡提交(匹配卡/可执行卡点「生成调拨单」):门禁在后端,失败抛 BusinessError。
|
||||
* D8 异步 202:只拿 {run_no, status:'queued'} 即切融合卡(kind='run')——
|
||||
* 融合卡自驱动轮询接管进度/结果,父级停掉本实例轮询防双打点;提交受理 toast 反馈。
|
||||
* 门禁 4xx:useMessage 行内报错 + 预检状态刷新(匹配详情/可执行池可能已变化)。
|
||||
*/
|
||||
async function onExecute(itemIds: number[]) {
|
||||
busy.value = true;
|
||||
try {
|
||||
transfer.selected.value = new Set(itemIds);
|
||||
// 快照本次执行明细行(融合卡失败单「重查库存」关联 item_id 的数据源之一):
|
||||
// 本地 items(匹配卡回放)/ composable 匹配与可执行池三处都可能持有行记录
|
||||
const executedSet = new Set(itemIds);
|
||||
lastExecutedItems.value = [...items.value, ...transfer.items.value, ...transfer.executableItems.value]
|
||||
.filter((item) => item.item_id != null && executedSet.has(item.item_id));
|
||||
const outcome = await transfer.execute();
|
||||
if (outcome) {
|
||||
mode.value = 'result';
|
||||
transfer.stopRunPolling(); // 融合卡(自驱动轮询)接管,父级轮询停止
|
||||
mode.value = 'run';
|
||||
runNo.value = outcome.run_no;
|
||||
status.value = outcome.status;
|
||||
run.value = transfer.run.value;
|
||||
notifySuccess(t('chat.transfer.execute.accepted'));
|
||||
}
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
await refreshPrecheckState();
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 门禁失败后的预检状态刷新(best-effort:匹配视图重拉详情、可执行池重拉队列,不掩盖原错误)。 */
|
||||
async function refreshPrecheckState() {
|
||||
try {
|
||||
if (mode.value === 'match' && transfer.matchingId.value) {
|
||||
await transfer.refreshMatching();
|
||||
} else if (mode.value === 'executable') {
|
||||
await transfer.loadExecutableItems();
|
||||
}
|
||||
} catch {
|
||||
// 刷新失败静默:原门禁错误已经 useMessage 提示
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 融合卡失败单「重试」(一键恢复主路径):POST /documents/{doc_no}/retry——
|
||||
* 后端按单圈行逐行重查,全部 ready 自动建新 Run 重跑(复用原单号,分支②);
|
||||
* 部分行仍阻断则不重跑,阻断明细以 toast 摘要提示、行留恢复池。
|
||||
*/
|
||||
async function onOrderRetry(order: TransferOrder) {
|
||||
busy.value = true;
|
||||
try {
|
||||
const result = await retryTransferOrder(order.doc_no);
|
||||
if (result.rerun) {
|
||||
notifySuccess(t('chat.transfer.orderAction.retryAccepted', { docNo: order.doc_no }));
|
||||
} else {
|
||||
notifyError(t('chat.transfer.orderAction.retryPartial', {
|
||||
ready: result.ready,
|
||||
blocked: result.blocked.length,
|
||||
}));
|
||||
}
|
||||
await refreshPrecheckState();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
} finally {
|
||||
@@ -179,6 +244,19 @@ async function onExecute(itemIds: number[]) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 融合卡关闭单完成(D18 上抛事件):行脱离单回 ready_to_execute——
|
||||
* 父级刷新 run 调拨单清单与可执行池(best-effort,失败经 useMessage 提示)。
|
||||
*/
|
||||
async function onOrderClosed() {
|
||||
try {
|
||||
await transfer.refreshRun();
|
||||
await transfer.loadExecutableItems();
|
||||
} catch (e) {
|
||||
reportError(e);
|
||||
}
|
||||
}
|
||||
|
||||
async function onDownloadReceipt() {
|
||||
try {
|
||||
await transfer.downloadReceiptFiles();
|
||||
@@ -358,12 +436,16 @@ async function onSourceRetry(sourceCodes: string[]) {
|
||||
@execute="onExecute"
|
||||
/>
|
||||
<TransferProgressCard v-else-if="mode === 'progress'" :run-no="runNo" :status="status" :busy="busy" />
|
||||
<!-- 融合卡(D9:调拨单清单=进度=结果):run_no 自驱动轮询;kind='run' 为 202 新流程,'result' 兼容历史回放 -->
|
||||
<TransferResultCard
|
||||
v-else-if="mode === 'result' && run"
|
||||
:run="run"
|
||||
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-erp="onDownloadErp"
|
||||
@download-exceptions="onDownloadExceptions"
|
||||
@retry="onOrderRetry"
|
||||
@closed="onOrderClosed"
|
||||
/>
|
||||
<TransferBacklogSummaryCard
|
||||
v-else-if="mode === 'backlog'"
|
||||
|
||||
@@ -1,107 +1,428 @@
|
||||
<!--
|
||||
features/chat/components/messages/TransferResultCard.vue
|
||||
用途:结果卡——按 ERP 单号聚合(决策 20)、可展开物料明细、未生成单据异常区、
|
||||
下载收料来源文件 / ERP 库存表(决策 21)。不展示执行审计入口(决策 19)。
|
||||
依赖:props.run、i18n chat.transfer.*。
|
||||
逻辑:<details> 展开/收起物料行;异常单独分区;两个下载按钮 + 异常 Excel。
|
||||
用途:融合卡(D9:调拨单清单=进度=结果)——props { run_no } 自驱动轮询 GET /runs/{run_no},
|
||||
逐单展示「收料日期 · 拨出→拨入 · N 物料 · 合计」与状态徽标(待处理/执行中/ERP 单号/失败),
|
||||
行明细常驻展开;result_unknown 行 [重新触发](D11 唯一出口,幂等只触发末步);
|
||||
失败行 [重查库存](emit 上抛,复用既有 batch-requery)+ [关闭单](D18:原因必填 +
|
||||
同单行影响面 + 「关闭调拨单≠ERP 无单」红线确认);终态出下载区。无取消执行入口(D9)。
|
||||
依赖:props.runNo/initialRun、useChatTransfer(自有实例轮询:startRunPolling/refreshRun)、
|
||||
transfer.api(retriggerTransferDocument/closeTransferDocument)、useMessage、i18n chat.transfer.*。
|
||||
逻辑:挂载即拉取打底一帧并按 4s 轮询直至 run 终态(onUnmounted 停止);单次失败保留旧值并显示
|
||||
「连接中…」;卡顶徽标按单汇总(全成功→成功/混合→部分失败/全失败→失败/全待处理→排队中/其余→执行中);
|
||||
历史回放旧 payload(无 orders)把 result.external_documents 投影为成功单兼容展示。
|
||||
失败/未知单的单据级 error_message 恒 null(T11 评审移交 + P2-3 契约扩充:后端失败/未知单行带
|
||||
行级 reason=result_message):❌ 原因行级优先、无则仅展示状态文案,禁止渲染 undefined/null 字样。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import type { TransferRunResult } from '../../types/transfer.types';
|
||||
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { isTerminalRunStatus, useChatTransfer } from '../../composables/useChatTransfer';
|
||||
import { closeTransferDocument, retriggerTransferDocument } from '../../api/transfer.api';
|
||||
import type { TransferRunResult, TransferOrder, TransferOrderLine } from '../../types/transfer.types';
|
||||
|
||||
defineProps<{
|
||||
run: TransferRunResult;
|
||||
const props = defineProps<{
|
||||
/** Run 编号(必传):自驱动轮询与重新触发的目标 Run。 */
|
||||
runNo: string;
|
||||
/** 初始 run 投影(历史回放/提交流程已拉取时打底;缺省由卡片自行拉取)。 */
|
||||
initialRun?: TransferRunResult | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
downloadReceipt: [];
|
||||
downloadErp: [];
|
||||
downloadExceptions: [];
|
||||
/** 失败单 [重试]:上抛父级调 POST /documents/{doc_no}/retry(一键重查+自动重跑)。 */
|
||||
retry: [order: TransferOrder];
|
||||
/** 关闭单完成:上抛父级刷新(D18 行脱离回 ready_to_execute,可执行池/调拨单清单需同步)。 */
|
||||
closed: [docNo: string];
|
||||
}>();
|
||||
|
||||
function reasonLabel(reason: string): string {
|
||||
const { t } = useI18n();
|
||||
const { error: notifyError, success: notifySuccess } = useMessage();
|
||||
|
||||
/** 卡片自有组合式实例:轮询/拉取与父级实例互不串扰(父级在切换后停掉自己的轮询)。 */
|
||||
const transfer = useChatTransfer();
|
||||
const { pollConnecting } = transfer;
|
||||
|
||||
const run = ref<TransferRunResult | null>(props.initialRun ?? null);
|
||||
const actionBusy = ref(false);
|
||||
/** 待关闭单(D18 弹层目标)。 */
|
||||
const closeTarget = ref<TransferOrder | null>(null);
|
||||
const closeReason = ref('');
|
||||
/** 待重新触发单(D11 弹层目标)。 */
|
||||
const retriggerTarget = ref<TransferOrder | null>(null);
|
||||
|
||||
/** 是否终态:终态停止轮询并展示下载动作区(交互细则:终态即停)。 */
|
||||
const terminal = computed(() => isTerminalRunStatus(run.value?.status));
|
||||
|
||||
/** 调拨单清单:优先服务端 orders;历史回放旧 payload 投影 external_documents 为成功单。 */
|
||||
const orders = computed<TransferOrder[]>(() => {
|
||||
const data = run.value;
|
||||
if (!data) return [];
|
||||
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: '',
|
||||
from_warehouse: doc.from_warehouse,
|
||||
to_warehouse: doc.to_warehouse,
|
||||
status: 'success' as const,
|
||||
erp_document_no: doc.document_no,
|
||||
error_message: null,
|
||||
lines: (doc.lines ?? []).map((line) => ({
|
||||
material_no: line.material_no,
|
||||
material_name: line.material_name,
|
||||
lot_no: '',
|
||||
quantity: line.quantity,
|
||||
unit: '',
|
||||
})),
|
||||
}));
|
||||
});
|
||||
|
||||
/** 卡顶徽标(按单汇总):全成功族→成功;全失败族→失败;全待处理→排队中;
|
||||
* 仍有在飞单→执行中;其余混合→部分失败。
|
||||
* [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 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' };
|
||||
}
|
||||
if (list.every((item) => successFamily(item.status))) {
|
||||
return { key: 'chat.transfer.runBadge.success', cls: 'bg-emerald-50 text-emerald-700' };
|
||||
}
|
||||
if (list.every((item) => failedFamily(item.status))) {
|
||||
return { key: 'chat.transfer.runBadge.failed', cls: 'bg-red-50 text-red-700' };
|
||||
}
|
||||
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.partialFailed', cls: 'bg-amber-50 text-amber-700' };
|
||||
});
|
||||
|
||||
/** 单据级状态徽标(成功族亮 ERP 单号;无单号回退状态文案,禁止出现 undefined/null)。 */
|
||||
function orderBadgeText(order: TransferOrder): string {
|
||||
switch (order.status) {
|
||||
case 'pending':
|
||||
return t('chat.transfer.orderStatus.pending');
|
||||
case 'executing':
|
||||
return t('chat.transfer.orderStatus.executing');
|
||||
case 'success':
|
||||
case 'duplicate_success':
|
||||
return order.erp_document_no || t('chat.transfer.orderStatus.success');
|
||||
case 'business_failed':
|
||||
case 'technical_failed':
|
||||
// 用户口径:失败统一展示(原因走行级 reason/result_message),不再区分业务/技术。
|
||||
return t('chat.transfer.orderStatus.failed');
|
||||
case 'result_unknown':
|
||||
return t('chat.transfer.orderStatus.resultUnknown');
|
||||
case 'cancelled':
|
||||
return t('chat.transfer.orderStatus.cancelled');
|
||||
default:
|
||||
return order.status;
|
||||
}
|
||||
}
|
||||
|
||||
function orderBadgeCls(order: TransferOrder): string {
|
||||
switch (order.status) {
|
||||
case 'success':
|
||||
case 'duplicate_success':
|
||||
return 'bg-emerald-50 text-emerald-700';
|
||||
case 'executing':
|
||||
return 'bg-sky-50 text-sky-700';
|
||||
case 'business_failed':
|
||||
case 'technical_failed':
|
||||
return 'bg-red-50 text-red-700';
|
||||
case 'result_unknown':
|
||||
return 'bg-amber-50 text-amber-700';
|
||||
default:
|
||||
return 'bg-slate-100 text-slate-600';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 失败/未知单原因文案(T11 精度约定 + P2-3 契约扩充):单据级 error_message 恒 null——
|
||||
* 后端在失败/未知单行集带行级 `reason`(= 行级 result_message),取首个非空行级原因
|
||||
* (兼容历史 result_message 键);无行级原因返回空串,徽标状态文案兜底
|
||||
* (模板仅在非空时渲染「原因:…」行,杜绝 undefined/null 字样上屏)。
|
||||
*/
|
||||
function orderReason(order: TransferOrder): string {
|
||||
for (const line of order.lines ?? []) {
|
||||
const record = line as unknown as Record<string, unknown>;
|
||||
const reason = record.reason ?? record.result_message;
|
||||
if (typeof reason === 'string' && reason.trim()) return reason.trim();
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
/** 单行合计数量(6 位小数聚合串相加后去尾零展示,如 600)。 */
|
||||
function orderTotalQuantity(order: TransferOrder): string {
|
||||
let sum = 0;
|
||||
for (const line of order.lines ?? []) {
|
||||
const quantity = Number(line.quantity);
|
||||
if (Number.isFinite(quantity)) sum += quantity;
|
||||
}
|
||||
return String(Number(sum.toFixed(6)));
|
||||
}
|
||||
|
||||
/** 单行数量单位(取首行原值;无行不展示)。 */
|
||||
function orderUnit(order: TransferOrder): string {
|
||||
return order.lines?.[0]?.unit ?? '';
|
||||
}
|
||||
|
||||
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}`;
|
||||
}
|
||||
|
||||
/** 未入单异常行文案映射(口径不变:blocked/business/technical/unknown/matching_expired)。 */
|
||||
function exceptionReasonLabel(reason: string): string {
|
||||
const map: Record<string, string> = {
|
||||
blocked_quantity_mismatch: 'chat.transfer.resultBlocked',
|
||||
blocked_inventory_not_found: 'chat.transfer.resultBlocked',
|
||||
business_failed: 'chat.transfer.exceptionBusinessFailed',
|
||||
technical_failed: 'chat.transfer.exceptionTechnicalFailed',
|
||||
result_unknown: 'chat.transfer.resultUnknown',
|
||||
result_unknown: 'chat.transfer.orderStatus.resultUnknown',
|
||||
matching_expired: 'chat.transfer.exceptionMatchExpired',
|
||||
};
|
||||
return map[reason] ?? 'chat.transfer.resultBlocked';
|
||||
}
|
||||
|
||||
/** [STEP 1] 挂载:终态原位恢复不轮询;否则拉取打底一帧 + 启动 4s 轮询(D8:提交只拿 run_no)。 */
|
||||
onMounted(async () => {
|
||||
if (!props.runNo || isTerminalRunStatus(run.value?.status)) return;
|
||||
if (!run.value) {
|
||||
try {
|
||||
run.value = await transfer.refreshRun(props.runNo);
|
||||
} catch {
|
||||
// 打底一帧失败:保留空态,由轮询兜底(单帧失败不清画面)
|
||||
}
|
||||
}
|
||||
if (!isTerminalRunStatus(run.value?.status)) {
|
||||
transfer.startRunPolling(props.runNo, (latest) => {
|
||||
run.value = latest;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/** 卸载停止轮询(幂等;组合式实例的 onScopeDispose 兜底)。 */
|
||||
onUnmounted(() => {
|
||||
transfer.stopRunPolling();
|
||||
});
|
||||
|
||||
/** [重新触发] 确认(D11):复用原单 doc_no/submit_timestamp 只触发末步(幂等);
|
||||
* [P1 双保险·前端半] 成功后先立即 refreshRun 打一帧(后端受理时已同步 run.status='executing',
|
||||
* 消除 worker 领取前首帧陈旧终态的窗口),再进入 4s 间隔轮询直至新终态
|
||||
* (终态误停窗口由后端同步置 executing 保证关闭,见 useChatTransfer 轮询终态判定处注释)。 */
|
||||
async function confirmRetrigger() {
|
||||
const target = retriggerTarget.value;
|
||||
if (!target || actionBusy.value) return;
|
||||
actionBusy.value = true;
|
||||
try {
|
||||
await retriggerTransferDocument(props.runNo, target.doc_no);
|
||||
retriggerTarget.value = null;
|
||||
notifySuccess(t('chat.transfer.toastRetriggerAccepted'));
|
||||
try {
|
||||
run.value = await transfer.refreshRun(props.runNo);
|
||||
} catch {
|
||||
// 首帧失败保留旧单面,由间隔轮询兜底(单帧失败不清画面)
|
||||
}
|
||||
transfer.startRunPolling(props.runNo, (latest) => {
|
||||
run.value = latest;
|
||||
});
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
actionBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function openCloseDialog(order: TransferOrder) {
|
||||
closeTarget.value = order;
|
||||
closeReason.value = '';
|
||||
}
|
||||
|
||||
/** [关闭单] 确认(D18:原因必填;仅失败单可关):close 后单 cancelled、行脱离回
|
||||
* ready_to_execute;本卡重拉调拨单清单 + emit 上抛父级刷新(可执行池/待处理池)。 */
|
||||
async function confirmCloseOrder() {
|
||||
const target = closeTarget.value;
|
||||
const reason = closeReason.value.trim();
|
||||
if (!target || !reason || actionBusy.value) return;
|
||||
actionBusy.value = true;
|
||||
try {
|
||||
await closeTransferDocument(target.doc_no, reason);
|
||||
closeTarget.value = null;
|
||||
notifySuccess(t('chat.transfer.toastOrderClosed'));
|
||||
emit('closed', target.doc_no);
|
||||
try {
|
||||
run.value = await transfer.refreshRun(props.runNo);
|
||||
} catch {
|
||||
// 刷新失败保留旧单面(关闭调拨单结果已上抛父级刷新)
|
||||
}
|
||||
} catch (e) {
|
||||
notifyError(e instanceof Error ? e.message : String(e));
|
||||
} finally {
|
||||
actionBusy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="my-2 rounded-2xl border border-brand-100 bg-surface p-4 shadow-sm" data-testid="transfer-result-card">
|
||||
<div class="mb-3 flex items-center justify-between">
|
||||
<h3 class="text-sm font-bold text-primary">{{ $t('chat.transfer.resultTitle') }}</h3>
|
||||
<span class="text-xs text-muted">{{ run.run_no }}</span>
|
||||
<div class="mb-3 flex flex-wrap items-center justify-between gap-2">
|
||||
<h3 class="text-sm font-bold text-primary">
|
||||
{{ $t('chat.transfer.runTitle') }}
|
||||
<span class="ml-1 text-xs text-muted">{{ runNo }}</span>
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<span
|
||||
v-if="pollConnecting"
|
||||
class="rounded-full bg-slate-100 px-2 py-0.5 text-[11px] text-slate-500"
|
||||
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">
|
||||
{{ $t(runBadge.key) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 已生成 ERP 单据:按单号聚合 + 可展开物料明细 -->
|
||||
<div v-if="run.result.external_documents.length" class="flex flex-col gap-2">
|
||||
<details
|
||||
v-for="doc in run.result.external_documents"
|
||||
:key="doc.document_no"
|
||||
<div v-if="!orders.length" class="rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.runBadge.queued') }}
|
||||
</div>
|
||||
|
||||
<!-- 调拨单清单(D9:调拨单清单=进度=结果):行明细常驻展开,无取消执行入口 -->
|
||||
<ul v-else class="flex flex-col gap-2">
|
||||
<li
|
||||
v-for="order in orders"
|
||||
:key="order.doc_no"
|
||||
class="rounded-lg border border-default"
|
||||
data-testid="transfer-erp-document"
|
||||
:data-testid="`transfer-order-${order.doc_no}`"
|
||||
>
|
||||
<summary class="flex cursor-pointer flex-wrap items-center justify-between gap-2 px-3 py-2 text-xs">
|
||||
<span class="font-bold text-brand-700">{{ doc.document_no }}</span>
|
||||
<span class="text-secondary">{{ doc.from_warehouse }} → {{ doc.to_warehouse }}</span>
|
||||
<span class="text-muted">{{ $t('chat.transfer.materialCount', { count: doc.material_count }) }}</span>
|
||||
<span class="font-bold text-secondary">{{ doc.total_quantity }}</span>
|
||||
<span class="rounded-full bg-emerald-50 px-2 py-0.5 font-bold text-emerald-700">
|
||||
{{ $t('chat.transfer.posted') }}
|
||||
<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 }}
|
||||
· {{ $t('chat.transfer.materialCount', { count: order.lines.length }) }}
|
||||
<template v-if="order.lines.length"> · {{ orderTotalQuantity(order) }} {{ orderUnit(order) }}</template>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="border-t border-subtle px-3 py-2">
|
||||
<table class="w-full text-xs" data-testid="transfer-erp-document-lines">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-bold"
|
||||
:class="orderBadgeCls(order)"
|
||||
:data-testid="`transfer-order-status-${order.doc_no}`"
|
||||
>
|
||||
{{ orderBadgeText(order) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- 失败/未知单原因([P2-3 契约扩充] 行级 reason 优先;无则不渲染——状态文案兜底,禁 undefined/null) -->
|
||||
<div
|
||||
v-if="orderReason(order)"
|
||||
class="px-3 pb-1 text-[11px] text-red-500"
|
||||
:data-testid="`transfer-order-reason-${order.doc_no}`"
|
||||
>
|
||||
{{ $t('chat.transfer.orderReasonPrefix', { reason: orderReason(order) }) }}
|
||||
</div>
|
||||
|
||||
<!-- 单据级行内动作(D11/D18:result_unknown 仅重新触发;失败行重查+关闭单) -->
|
||||
<div
|
||||
v-if="order.status === 'result_unknown' || isFailedOrder(order)"
|
||||
class="flex flex-wrap gap-2 px-3 pb-2"
|
||||
>
|
||||
<button
|
||||
v-if="order.status === 'result_unknown'"
|
||||
type="button"
|
||||
class="rounded border border-amber-300 px-2 py-0.5 text-[11px] font-bold text-amber-700 transition hover:bg-amber-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-order-retrigger-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click="retriggerTarget = order"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retrigger') }}
|
||||
</button>
|
||||
<template v-if="isFailedOrder(order)">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-brand-200 px-2 py-0.5 text-[11px] font-bold text-brand-700 transition hover:bg-brand-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-order-retry-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click="emit('retry', order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.retry') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-red-200 px-2 py-0.5 text-[11px] font-bold text-red-700 transition hover:bg-red-50 disabled:opacity-40"
|
||||
:data-testid="`transfer-order-close-${order.doc_no}`"
|
||||
:disabled="actionBusy"
|
||||
@click="openCloseDialog(order)"
|
||||
>
|
||||
{{ $t('chat.transfer.orderAction.closeOrder') }}
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- 行明细常驻展开(物料 × 批号聚合行) -->
|
||||
<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.colMaterial') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colName') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colSpec') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colInvoice') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colFromBatch') }}</th>
|
||||
<th class="p-1">{{ $t('chat.transfer.colToQty') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="line in doc.lines" :key="line.invoice_no" class="border-t border-subtle">
|
||||
<tr v-for="(line, index) in order.lines" :key="lineKey(order, line, index)" class="border-t border-subtle">
|
||||
<td class="p-1">{{ line.material_no }}</td>
|
||||
<td class="p-1">{{ line.material_name }}</td>
|
||||
<td class="p-1">{{ line.specification }}</td>
|
||||
<td class="p-1">{{ line.invoice_no }}</td>
|
||||
<td class="p-1">{{ line.quantity }}</td>
|
||||
<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>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
<div v-else class="mb-3 rounded-lg bg-surface-soft p-3 text-xs text-muted">
|
||||
{{ $t('chat.transfer.noDocuments') }}
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- 未生成 ERP 单据的异常区(决策 20 单独展示) -->
|
||||
<div v-if="run.result.exceptions.length" class="mt-3" data-testid="transfer-exceptions-area">
|
||||
<!-- 未入单异常区(口径不变):早于建单被阻断的行不落在任何单内,fail-closed 单独展示 -->
|
||||
<div
|
||||
v-if="(run?.result?.exceptions?.length ?? 0) > 0"
|
||||
class="mt-3"
|
||||
data-testid="transfer-exceptions-area"
|
||||
>
|
||||
<h4 class="mb-1 text-xs font-bold text-secondary">{{ $t('chat.transfer.exceptionsTitle') }}</h4>
|
||||
<ul class="flex flex-col gap-1">
|
||||
<li
|
||||
v-for="exc in run.result.exceptions"
|
||||
v-for="exc in run?.result?.exceptions"
|
||||
:key="exc.invoice_no"
|
||||
class="rounded-lg bg-red-50 px-3 py-1.5 text-xs text-red-700"
|
||||
data-testid="transfer-exception-item"
|
||||
>
|
||||
<span class="font-bold">{{ exc.invoice_no }}</span>
|
||||
<span class="mx-1 text-red-400">·</span>{{ exc.source_code }} · {{ $t(reasonLabel(exc.reason)) }}
|
||||
<span class="mx-1 text-red-400">·</span>{{ exc.source_code }} · {{ $t(exceptionReasonLabel(exc.reason)) }}
|
||||
<div class="text-[11px] text-red-500">{{ exc.facts }}</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- 下载:收料来源文件 + ERP 库存表(决策 21);无审计入口(决策 19) -->
|
||||
<div class="mt-3 flex flex-wrap gap-2 border-t border-subtle pt-3" data-testid="transfer-result-downloads">
|
||||
<!-- 终态动作:下载异常清单 / 收料文件 / 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')"
|
||||
>
|
||||
{{ $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"
|
||||
@@ -118,14 +439,87 @@ function reasonLabel(reason: string): string {
|
||||
>
|
||||
{{ $t('chat.transfer.downloadErpInventory') }}
|
||||
</button>
|
||||
<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')"
|
||||
>
|
||||
{{ $t('chat.transfer.downloadExceptions') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 重新触发确认弹层(D11:说明幂等复用原单只触发末步;无取消执行语义) -->
|
||||
<div
|
||||
v-if="retriggerTarget"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
data-testid="transfer-retrigger-dialog"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 关闭单确认弹层(D18:原因必填 + 同单行影响面 + 「关闭调拨单≠ERP 无单」红线) -->
|
||||
<div
|
||||
v-if="closeTarget"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
data-testid="transfer-order-close-dialog"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl bg-surface p-5 shadow-xl">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -3,6 +3,8 @@
|
||||
* 用途:在途调拨批号转换规则(拨出/拨入批号展示)。
|
||||
* 依赖:无。
|
||||
* 逻辑:原批号以 WTP 开头时替换前缀为 HOW 获得真实批号;其余规则不变、原样展示。
|
||||
* 本函数是后端 movement_contract.external_lot_no(库存查询/建单下传侧唯一实现)
|
||||
* 的展示侧镜像,两侧行为须逐字节一致,改动必须双侧同步。
|
||||
*/
|
||||
|
||||
/** 原批号(如 WMS 的 WTP26082728)→ 真实批号(HOW26082728);空值/非 WTP 原样返回。 */
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
/**
|
||||
* features/chat/components/messages/transferCards.spec.ts
|
||||
* 用途:验证在途调拨三张核心卡片(文件进度/匹配/结果)+ 关闭弹窗的交互与禁用语义。
|
||||
* 用途:验证在途调拨核心卡片(文件进度/匹配/融合结果卡)+ 关闭弹窗的交互与禁用语义。
|
||||
* 依赖:@vue/test-utils、i18n、transfer.types。
|
||||
* 逻辑:断言按钮禁用、勾选禁用、ERP 单号展开/收起、异常展示、下载按钮与
|
||||
* 结果页不出现“查看执行审计”入口(决策 19)。
|
||||
* 逻辑:断言按钮禁用、勾选禁用、融合卡单行常驻展开(历史回放旧 result 投影兼容)、
|
||||
* 异常展示、下载按钮与结果页不出现“查看执行审计”入口(决策 19);
|
||||
* 计数卡新字段(待查库存/已失效,历史缺省按 0)与 pending 徽标
|
||||
* (evidence-sync,2026-09-25)。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -118,20 +120,81 @@ describe('TransferMatchCard', () => {
|
||||
const row = wrapper.find('[data-testid="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('重新匹配');
|
||||
expect(wrapper.find('[data-testid="transfer-item-file-changed"]').text()).toContain('自动对齐');
|
||||
});
|
||||
|
||||
it('blocked_file_removed 结果行展示「文件已移除」独立徽标', () => {
|
||||
const removedItems = [{ ...items[0], result: 'blocked_file_removed' }];
|
||||
it('计数卡透出待查库存/已失效计数;历史 payload 缺省按 0 展示', () => {
|
||||
// [断言意图] evidence-sync(2026-09-25):后端 counts 新增 pending_stock_check_count /
|
||||
// invalid_count(历史数据可缺省);卡片须原样透出数值,缺省回退 0,
|
||||
// 已失效标签经 {count} 插值渲染(「已失效 N 行」)。
|
||||
const summaryWithNewCounts = {
|
||||
...summary,
|
||||
counts: { ...summary.counts, pending_stock_check_count: 5, invalid_count: 2 },
|
||||
};
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: removedItems, selected: new Set<number>() },
|
||||
props: { summary: summaryWithNewCounts, items, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
expect(wrapper.find('[data-testid="transfer-item-result"]').text()).toContain('文件已移除');
|
||||
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,
|
||||
});
|
||||
expect(legacyWrapper.find('[data-testid="transfer-match-counts"]').text()).toContain('已失效 0 行');
|
||||
});
|
||||
|
||||
it('同 Invoice 跨收料日期拆票(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||||
// [断言意图] 回归防线(2026-09-21):拆票设计下 invoice_no 不再唯一,
|
||||
it('pending_stock_check 行徽标展示「待查库存」(amber 同未成熟色系)', () => {
|
||||
// [断言意图] evidence-sync(2026-09-25):文件已落地未查 ERP 的行为
|
||||
// pending_stock_check,徽标须用独立文案且为 amber 族(非阻断红)。
|
||||
const pendingItems = [{ ...items[0], result: 'pending_stock_check' }];
|
||||
const wrapper = mount(TransferMatchCard, {
|
||||
props: { summary, items: pendingItems, selected: new Set<number>() },
|
||||
...mountOptions,
|
||||
});
|
||||
const badge = wrapper.find('[data-testid="transfer-item-result"]');
|
||||
expect(badge.text()).toContain('待查库存');
|
||||
expect(badge.classes()).toContain('bg-amber-50');
|
||||
});
|
||||
|
||||
it('blocked_file_removed 行退出主视图:表格不渲染,仅折叠提示计数并引导去待处理池', () => {
|
||||
// [断言意图] 回归防线(2026-09-24):文件移除的行证据已失效,重查/重新匹配
|
||||
// 都救不了——留驻主清单只会提示做不到的动作(死锁观感)。主视图只渲染
|
||||
// 可行动行;失效行以折叠提示计数承载,处理入口在待处理异常池。
|
||||
const mixedItems = [
|
||||
{ ...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,
|
||||
});
|
||||
// 失效行不出现在表格(含其重查按钮/勾选框),可行动行照常渲染。
|
||||
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);
|
||||
// 折叠提示透出失效行数与去处理池的引导。
|
||||
const hint = wrapper.find('[data-testid="transfer-file-removed-hint"]');
|
||||
expect(hint.exists()).toBe(true);
|
||||
expect(hint.text()).toContain('1');
|
||||
expect(hint.text()).toContain('待处理异常');
|
||||
});
|
||||
|
||||
it('全部行均文件移除时表格为空,仅剩折叠提示', () => {
|
||||
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);
|
||||
expect(wrapper.find('[data-testid="transfer-file-removed-hint"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('同 Invoice 跨收料日期拆单(重复 invoice_no)时,筛选后仅渲染匹配行', async () => {
|
||||
// [断言意图] 回归防线(2026-09-21):拆单设计下 invoice_no 不再唯一,
|
||||
// 行 key 若仍用 invoice_no 会出现重复 key,Vue 列表 diff 错乱导致
|
||||
// 筛选后不匹配行残留/克隆(用户输入 HOX 仍见 SLC2PHX 行)。
|
||||
// 行身份 = (来源, Invoice, 料号, 收料日期),key 必须用同一粒度。
|
||||
@@ -152,7 +215,8 @@ describe('TransferMatchCard', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('TransferResultCard', () => {
|
||||
describe('TransferResultCard(Task 13 融合卡)', () => {
|
||||
// 历史回放旧 payload(无 orders,仅 result.external_documents)——融合卡投影为成功单展示
|
||||
const run = {
|
||||
run_no: 'RUN-1',
|
||||
status: 'partial_failed',
|
||||
@@ -169,32 +233,37 @@ describe('TransferResultCard', () => {
|
||||
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('按 ERP 单号聚合展示,物料明细可展开/收起', async () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
const doc = wrapper.find('[data-testid="transfer-erp-document"]');
|
||||
expect(doc.text()).toContain('TRF-10001');
|
||||
expect(doc.attributes('open')).toBeUndefined();
|
||||
await doc.find('summary').trigger('click');
|
||||
expect(doc.attributes('open')).toBeDefined();
|
||||
expect(wrapper.find('[data-testid="transfer-erp-document-lines"]').text()).toContain('INV-001');
|
||||
it('历史回放(旧 result 投影):按单号展示单行,行明细常驻展开无需点击', async () => {
|
||||
const wrapper = mountCard();
|
||||
const order = wrapper.find('[data-testid="transfer-order-TRF-10001"]');
|
||||
expect(order.exists()).toBe(true);
|
||||
expect(order.text()).toContain('TRF-10001');
|
||||
// 常驻展开:物料行直接可见(旧 <details> 交互移除,D9 调拨单清单=进度=结果)
|
||||
expect(wrapper.find('[data-testid="transfer-order-lines-TRF-10001"]').text()).toContain('MAT-1');
|
||||
expect(wrapper.find('[data-testid="transfer-order-lines-TRF-10001"]').text()).toContain('连接器');
|
||||
// 终态出下载区
|
||||
expect(wrapper.find('[data-testid="transfer-result-downloads"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('未生成单据异常单独展示', () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
it('未入单异常单独展示(口径不变)', () => {
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.find('[data-testid="transfer-exceptions-area"]').text()).toContain('INV-999');
|
||||
});
|
||||
|
||||
it('提供两个下载按钮(收料来源文件 + ERP 库存表)', async () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
it('提供下载按钮(收料来源文件 + ERP 库存表 + 异常清单)', async () => {
|
||||
const wrapper = mountCard();
|
||||
await wrapper.find('[data-testid="transfer-download-receipt"]').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('downloadErp')).toBeTruthy();
|
||||
expect(wrapper.emitted('downloadExceptions')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('结果页不出现“查看执行审计”入口(决策 19)', () => {
|
||||
const wrapper = mount(TransferResultCard, { props: { run }, ...mountOptions });
|
||||
const wrapper = mountCard();
|
||||
expect(wrapper.text()).not.toContain('审计');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/**
|
||||
* features/chat/composables/useChatTransfer.spec.ts
|
||||
* 用途:验证匹配创建/恢复、选择范围、直接生成执行 Run、结果恢复与防重复。
|
||||
* 用途:验证匹配创建/恢复、选择范围、直接生成执行 Run、结果恢复与防重复;
|
||||
* 另验证 D8 异步 202 提交后的 Run 轮询(4s 间隔、终态停止、单次失败保留旧值、清理)。
|
||||
* 依赖:vi.mock(transfer.api)、useChatTransfer。
|
||||
* 逻辑:用 Mock API 驱动组合式函数,断言状态流转与调用参数。
|
||||
* 逻辑:用 Mock API 驱动组合式函数,断言状态流转与调用参数;
|
||||
* 轮询用例用 fake timers 推进 4s 周期并断言终态/失败/清理分支。
|
||||
*/
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { afterEach, describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
import { effectScope } from 'vue';
|
||||
|
||||
const api = vi.hoisted(() => ({
|
||||
createTransferMatching: vi.fn(),
|
||||
@@ -18,6 +21,8 @@ const api = vi.hoisted(() => ({
|
||||
downloadTransferReceiptFiles: vi.fn(),
|
||||
downloadTransferErpInventory: vi.fn(),
|
||||
downloadTransferExceptions: vi.fn(),
|
||||
listTransferSources: vi.fn(),
|
||||
retryTransferSourceRpa: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('../api/transfer.api', () => api);
|
||||
@@ -128,3 +133,247 @@ describe('useChatTransfer', () => {
|
||||
expect(transfer.run.value).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('useChatTransfer Run 轮询(D8 异步 202 / D9 融合卡数据源)', () => {
|
||||
/** 轮询用例的标准 Run 载荷(status 可变,用于驱动终态/继续分支) */
|
||||
const polledRun = (status = 'executing') => ({
|
||||
run_no: 'RUN-POLL-1',
|
||||
status,
|
||||
result: { external_documents: [], exceptions: [] },
|
||||
orders: [],
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('每 4s 轮询一次 getTransferRun:起始不立即打点,成功覆盖 run 并回吐 onUpdate', async () => {
|
||||
// [断言意图] 轮询是纯间隔制:提交流程已 refreshRun 一次,startRunPolling 起始不再重复打点;
|
||||
// 每轮成功才覆盖 run 旧值(失败轮不清屏),并把最新 Run 回吐给 onUpdate(融合卡渲染源)。
|
||||
const payload = polledRun();
|
||||
api.getTransferRun.mockResolvedValue(payload);
|
||||
const transfer = useChatTransfer();
|
||||
const onUpdate = vi.fn();
|
||||
transfer.startRunPolling('RUN-POLL-1', onUpdate);
|
||||
expect(api.getTransferRun).not.toHaveBeenCalled();
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(1);
|
||||
expect(api.getTransferRun).toHaveBeenCalledWith('RUN-POLL-1');
|
||||
expect(transfer.run.value).toEqual(payload);
|
||||
expect(onUpdate).toHaveBeenCalledWith(payload);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('run.status 落入终态集合(success/partial_failed/failed)即停止轮询', async () => {
|
||||
// [断言意图] 终态判定只看 run.status(口径对齐后端 RUN_TRANSITIONS 收尾);
|
||||
// 终态后不再排下一轮定时器——即使再推进 20s 也不产生新请求。
|
||||
api.getTransferRun
|
||||
.mockResolvedValueOnce(polledRun('executing'))
|
||||
.mockResolvedValue(polledRun('success'));
|
||||
const transfer = useChatTransfer();
|
||||
transfer.startRunPolling('RUN-POLL-1', () => {});
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(1);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(2);
|
||||
expect(transfer.run.value?.status).toBe('success');
|
||||
await vi.advanceTimersByTimeAsync(20000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('run.status=cancelled(人工停止)驱动终态即停止轮询', async () => {
|
||||
// [断言意图] cancelled 是严格终态(后端人工停止、无出边):终态集合四态
|
||||
// success/partial_failed/failed/cancelled 中本用例单独锁定 cancelled 分支,
|
||||
// 取消后轮询必须停止——即使再推进 20s 也不产生新请求(防取消后空转)。
|
||||
api.getTransferRun
|
||||
.mockResolvedValueOnce(polledRun('executing'))
|
||||
.mockResolvedValue(polledRun('cancelled'));
|
||||
const transfer = useChatTransfer();
|
||||
transfer.startRunPolling('RUN-POLL-1', () => {});
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(1);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(2);
|
||||
expect(transfer.run.value?.status).toBe('cancelled');
|
||||
await vi.advanceTimersByTimeAsync(20000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('单次失败保留旧值并继续下一轮', async () => {
|
||||
// [断言意图] 网络抖动不清空已展示数据:失败轮 run 保持上一轮成功值;
|
||||
// 连续失败计数被成功拉取清零,下一轮照常执行。
|
||||
const first = polledRun();
|
||||
api.getTransferRun
|
||||
.mockResolvedValueOnce(first)
|
||||
.mockRejectedValueOnce(new Error('network down'))
|
||||
.mockResolvedValue(polledRun('success'));
|
||||
const transfer = useChatTransfer();
|
||||
transfer.startRunPolling('RUN-POLL-1', () => {});
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(transfer.run.value).toEqual(first);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(transfer.run.value).toEqual(first);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(3);
|
||||
expect(transfer.run.value?.status).toBe('success');
|
||||
});
|
||||
|
||||
it('连续失败达上限(3 次)后停止轮询并落 error', async () => {
|
||||
// [断言意图] 连续失败上限是防无限空转的兜底:达上限即停止并按既有模式落 error.value;
|
||||
// 单次失败不落 error(只有达上限这一刻才置位)。
|
||||
api.getTransferRun.mockRejectedValue(new Error('backend down'));
|
||||
const transfer = useChatTransfer();
|
||||
transfer.startRunPolling('RUN-POLL-1', () => {});
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(3);
|
||||
expect(transfer.error.value).not.toBe('');
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
|
||||
it('手动 stop 句柄与作用域销毁均停止轮询', async () => {
|
||||
// [断言意图] 组件卸载/作用域销毁必须清理定时器(onScopeDispose),防止离屏后继续请求。
|
||||
api.getTransferRun.mockResolvedValue(polledRun());
|
||||
const scope = effectScope();
|
||||
let transfer!: ReturnType<typeof useChatTransfer>;
|
||||
scope.run(() => {
|
||||
transfer = useChatTransfer();
|
||||
});
|
||||
const stop = transfer.startRunPolling('RUN-POLL-1', () => {});
|
||||
stop();
|
||||
await vi.advanceTimersByTimeAsync(8000);
|
||||
expect(api.getTransferRun).not.toHaveBeenCalled();
|
||||
|
||||
api.getTransferRun.mockClear();
|
||||
transfer.startRunPolling('RUN-POLL-1', () => {});
|
||||
scope.stop();
|
||||
await vi.advanceTimersByTimeAsync(8000);
|
||||
expect(api.getTransferRun).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('execute 提交拿到 run_no 后自动开始轮询并随终态停止', async () => {
|
||||
// [断言意图] D8 提交只拿 {run_no,status:'queued'}:既有 refreshRun 打第 1 点,
|
||||
// 随后轮询自动接管(第 2/3 点),全单终态(run → success)后停止。
|
||||
api.createTransferMatching.mockResolvedValue(summary);
|
||||
api.getTransferMatching.mockResolvedValue(detail);
|
||||
api.executeTransferItems.mockResolvedValue({ run_no: 'RUN-AUTO-1', status: 'queued' });
|
||||
api.getTransferRun
|
||||
.mockResolvedValueOnce(polledRun())
|
||||
.mockResolvedValueOnce(polledRun())
|
||||
.mockResolvedValue({ ...polledRun('success'), run_no: 'RUN-AUTO-1' });
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.createMatching(['DBS-AWSBI']);
|
||||
await transfer.execute();
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(1);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(2);
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(3);
|
||||
await vi.advanceTimersByTimeAsync(20000);
|
||||
expect(api.getTransferRun).toHaveBeenCalledTimes(3);
|
||||
});
|
||||
});
|
||||
|
||||
describe('useChatTransfer 来源状态轮询(收料 RPA 202 异步收口)', () => {
|
||||
/** 来源选择卡轮询用例的标准来源载荷(file_status 可变,驱动 fetching→终态分支) */
|
||||
const sourceOptionsWith = (file_status: string) => [
|
||||
{
|
||||
source_code: 'CRANE-FP',
|
||||
display_name: 'Crane FootPrint',
|
||||
platform: 'CRANE',
|
||||
enabled: true,
|
||||
file_status,
|
||||
has_ready_file: file_status === 'ready',
|
||||
},
|
||||
];
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
vi.useFakeTimers();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('重试收料 RPA 后来源处于抓取中即自动轮询,收口(ready)后停止', async () => {
|
||||
// [断言意图] 重试 202 返回后 loadSources 首帧仍是 fetching(RPA 回调未到),
|
||||
// 轮询必须自动接管:收口帧把 抓取中→ready 投影进 sourceOptions(修复状态卡死),
|
||||
// 全部来源脱离 fetching 即停——再推进 20s 也不产生新请求。
|
||||
api.retryTransferSourceRpa.mockResolvedValue({ source_code: 'CRANE-FP', ok: true, file_status: 'fetching' });
|
||||
api.listTransferSources
|
||||
.mockResolvedValueOnce(sourceOptionsWith('fetching'))
|
||||
.mockResolvedValue(sourceOptionsWith('ready'));
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.retrySourceRpa('CRANE-FP');
|
||||
expect(transfer.sourceOptions.value[0].file_status).toBe('fetching');
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(2);
|
||||
expect(transfer.sourceOptions.value[0].file_status).toBe('ready');
|
||||
await vi.advanceTimersByTimeAsync(20000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('loadSources 观察到抓取中来源(页面刷新/会话恢复)同样自动启动轮询', async () => {
|
||||
// [断言意图] 轮询挂在 loadSources 快照同步上而非只挂重试入口:进入卡片时
|
||||
// 已有 fetching 来源(上次触发后刷新页面)也必须继续跟踪到收口。
|
||||
api.listTransferSources
|
||||
.mockResolvedValueOnce(sourceOptionsWith('fetching'))
|
||||
.mockResolvedValue(sourceOptionsWith('failed'));
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.loadSources();
|
||||
await vi.advanceTimersByTimeAsync(4000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(2);
|
||||
expect(transfer.sourceOptions.value[0].file_status).toBe('failed');
|
||||
});
|
||||
|
||||
it('来源均非抓取中时不启动轮询', async () => {
|
||||
// [断言意图] 无 fetching 来源不产生任何后台请求(轮询只为收口跟踪而存在)。
|
||||
api.listTransferSources.mockResolvedValue(sourceOptionsWith('ready'));
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.loadSources();
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('来源轮询连续失败达上限(3 次)后停止且不落 error', async () => {
|
||||
// [断言意图] 连续失败上限与 Run 轮询同口径(防无限空转);差异点:来源轮询
|
||||
// 不落 error.value(卡片有手动重试/确认门禁兜底,失败噪声不上抛主流程)。
|
||||
api.retryTransferSourceRpa.mockResolvedValue({ source_code: 'CRANE-FP', ok: true, file_status: 'fetching' });
|
||||
api.listTransferSources
|
||||
.mockResolvedValueOnce(sourceOptionsWith('fetching'))
|
||||
.mockRejectedValue(new Error('backend down'));
|
||||
const transfer = useChatTransfer();
|
||||
await transfer.retrySourceRpa('CRANE-FP');
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(4); // 首帧 1 + 轮询 3
|
||||
expect(transfer.error.value).toBe('');
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(4);
|
||||
});
|
||||
|
||||
it('reset 与作用域销毁均停止来源轮询', async () => {
|
||||
// [断言意图] 离开卡片(reset/卸载)必须清理来源轮询定时器,防离屏后继续请求。
|
||||
api.listTransferSources.mockResolvedValue(sourceOptionsWith('fetching'));
|
||||
const scope = effectScope();
|
||||
let transfer!: ReturnType<typeof useChatTransfer>;
|
||||
scope.run(() => {
|
||||
transfer = useChatTransfer();
|
||||
});
|
||||
await transfer.loadSources();
|
||||
transfer.reset();
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(1);
|
||||
|
||||
await transfer.loadSources();
|
||||
scope.stop();
|
||||
await vi.advanceTimersByTimeAsync(12000);
|
||||
expect(api.listTransferSources).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
});
|
||||
@@ -1,14 +1,19 @@
|
||||
/**
|
||||
* features/chat/composables/useChatTransfer.ts
|
||||
* 用途:在途仓自动调拨聊天编排入口——匹配创建/恢复、选择范围(按明细 item_id)、
|
||||
* 按行直接生成执行 Run、Run 进度与结果恢复、人工重试/关闭、恢复处理(重查)、下载。
|
||||
* 依赖:transfer.api、transfer.types、useMessage、Vue refs/computed。
|
||||
* 逻辑:前端只消费稳定 DTO;Run 是异步真相源,刷新/重进由 GET 恢复;
|
||||
* 按行直接生成执行 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 来源时
|
||||
* 4s 轮询 GET /sources 直至全部脱离 fetching(ready/failed/expired/none);
|
||||
* 勾选集合以明细行 item_id 为键(历史回放行无 item_id 不可选);
|
||||
* 恢复处理 = 按明细 id 重查库存(batch-requery 是唯一后端);
|
||||
* 防重复点击(busy);错误统一 useMessage 展示 BusinessError。
|
||||
*/
|
||||
import { computed, ref, type Ref } from 'vue';
|
||||
import { computed, getCurrentScope, onScopeDispose, ref, type Ref } from 'vue';
|
||||
import i18n from '@/i18n';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
batchManualCloseTransferItems,
|
||||
@@ -42,6 +47,41 @@ import type {
|
||||
TransferType,
|
||||
} from '../types/transfer.types';
|
||||
|
||||
/** Run 轮询间隔(ms):D9 融合卡「调拨单清单=进度=结果」按 4s 定时拉取 GET /runs/{run_no} */
|
||||
const RUN_POLL_INTERVAL_MS = 4000;
|
||||
|
||||
/** 轮询连续失败停止上限:防后端持续不可用时无限空转;单次失败保留旧值继续下一轮 */
|
||||
const RUN_POLL_MAX_CONSECUTIVE_FAILURES = 3;
|
||||
|
||||
/** 来源状态轮询间隔(ms):来源选择卡存在抓取中来源时按 4s 重拉 GET /sources(与 Run 轮询同节奏) */
|
||||
const SOURCE_POLL_INTERVAL_MS = 4000;
|
||||
|
||||
/** 来源轮询连续失败停止上限(口径同 Run 轮询):防后端持续不可用时无限空转 */
|
||||
const SOURCE_POLL_MAX_CONSECUTIVE_FAILURES = 3;
|
||||
|
||||
/**
|
||||
* Run 轮询终态集合(口径对齐后端 status.py RUN_TRANSITIONS 收尾):
|
||||
* executing 只流向 success / partial_failed / failed / cancelled——
|
||||
* success=全单成功族;partial_failed/failed=存在未成单(唯一出边=人工 retrigger,
|
||||
* 由重触发流程重新发起轮询,不作为轮询继续条件);cancelled=人工停止的严格终态
|
||||
* (防止取消后轮询空转)。「单全终态」由后端 finalize_run 汇总进 run.status,
|
||||
* 前端只判 run.status,无需逐单推断。
|
||||
*/
|
||||
const TERMINAL_RUN_STATUSES: ReadonlySet<string> = new Set([
|
||||
'success',
|
||||
'partial_failed',
|
||||
'failed',
|
||||
'cancelled',
|
||||
]);
|
||||
|
||||
/**
|
||||
* Run 是否已处终态(轮询停止判据,口径同 TERMINAL_RUN_STATUSES)。
|
||||
* 融合卡/视图在挂载与恢复场景用其决定「原位渲染」还是「继续轮询」。
|
||||
*/
|
||||
export function isTerminalRunStatus(status: string | null | undefined): boolean {
|
||||
return typeof status === 'string' && TERMINAL_RUN_STATUSES.has(status);
|
||||
}
|
||||
|
||||
export function useChatTransfer() {
|
||||
const { error: notifyError } = useMessage();
|
||||
|
||||
@@ -59,6 +99,19 @@ export function useChatTransfer() {
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
|
||||
// Run 轮询状态(实例级闭包):generation 使被停止/替换轮次的在途回调失效,防止僵尸轮询复活
|
||||
let pollTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let pollGeneration = 0;
|
||||
let pollConsecutiveFailures = 0;
|
||||
// 轮询连接状态(交互细则 #2:单次失败保留旧值继续轮询,连续失败显示「连接中…」不清空画面)
|
||||
const pollConnecting = ref(false);
|
||||
// 来源状态轮询状态(实例级闭包,generation 语义同 Run 轮询):
|
||||
// 收料 RPA 是异步回调收口(重试 202 后状态先投影 fetching,终态靠后端回调落库),
|
||||
// 前端必须轮询 GET /sources 才能把 抓取中→ready/failed 反映到来源选择卡
|
||||
let sourcePollTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let sourcePollGeneration = 0;
|
||||
let sourcePollConsecutiveFailures = 0;
|
||||
|
||||
/** 全部可执行明细行 id(阻断/未成熟/无 item_id 的历史行不可勾选) */
|
||||
const executableItemIds = computed(() =>
|
||||
items.value
|
||||
@@ -124,10 +177,15 @@ export function useChatTransfer() {
|
||||
selected.value = next;
|
||||
}
|
||||
|
||||
/** 按勾选明细行直接生成调拨单(item-centric:门禁在后端,失败抛 BusinessError) */
|
||||
/**
|
||||
* 按勾选明细行直接生成调拨单(item-centric:门禁在后端,失败抛 BusinessError)。
|
||||
* D8 异步 202:提交只拿 { run_no, status: 'queued' }——先 refreshRun 打底一帧,
|
||||
* 随后自动开始 4s 轮询接管进度/结果,直至 run.status 落入终态集合。
|
||||
*/
|
||||
async function execute() {
|
||||
if (selected.value.size === 0) {
|
||||
notifyError('请至少选择一个可执行明细行');
|
||||
// [P2-2] 组合式函数可能运行在组件 setup 之外(单测直调),经 i18n.global 取四语言文案
|
||||
notifyError(i18n.global.t('chat.transfer.execute.noSelection'));
|
||||
return null;
|
||||
}
|
||||
busy.value = true;
|
||||
@@ -136,6 +194,8 @@ export function useChatTransfer() {
|
||||
const result = await executeTransferItems([...selected.value]);
|
||||
runNo.value = result.run_no;
|
||||
await refreshRun();
|
||||
// 提交成功即自动轮询(沿既有交互流:busy 复位后卡片可直接消费 run 更新)
|
||||
startRunPolling(result.run_no, () => {});
|
||||
return result;
|
||||
} catch (e) {
|
||||
error.value = String(e);
|
||||
@@ -145,19 +205,109 @@ export function useChatTransfer() {
|
||||
}
|
||||
}
|
||||
|
||||
/** 恢复 Run 最终结果 */
|
||||
async function refreshRun() {
|
||||
if (!runNo.value) return null;
|
||||
const data = await getTransferRun(runNo.value);
|
||||
/** 恢复 Run 结果与调拨单清单(D9:run 含 orders 调拨单清单,终态 Run 亦同口径投影)。
|
||||
* @param runNoArg 显式 run_no(融合卡自驱动轮询用自有实例按卡内 run_no 拉取);
|
||||
* 缺省沿用实例 runNo(既有提交/恢复路径不变)。 */
|
||||
async function refreshRun(runNoArg?: string) {
|
||||
const target = runNoArg ?? runNo.value;
|
||||
if (!target) return null;
|
||||
const data = await getTransferRun(target);
|
||||
run.value = data;
|
||||
return data;
|
||||
}
|
||||
|
||||
/** 请求停止剩余任务 */
|
||||
/**
|
||||
* 停止当前 Run 轮询(幂等,即 startRunPolling 返回的手动句柄)。
|
||||
* 核心逻辑:递增 generation 使在途请求的回调失效(防止僵尸轮询复活),
|
||||
* 并清掉尚未触发的定时器;重复调用安全。
|
||||
*/
|
||||
function stopRunPolling() {
|
||||
pollGeneration += 1;
|
||||
if (pollTimer !== null) {
|
||||
clearTimeout(pollTimer);
|
||||
pollTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动 Run 轮询(D8 异步 202:提交只拿 run_no,进度/结果靠轮询调拨单清单直至终态)。
|
||||
*
|
||||
* 【AI 触发时机】:execute 提交拿到 run_no 后自动调用;或页面刷新/会话恢复
|
||||
* 拿到未终态 run_no 时由调用方手动调用——融合卡靠 onUpdate 逐单亮状态与 ERP 单号。
|
||||
*
|
||||
* 核心逻辑:[STEP 1] 停掉本实例既有轮询(单实例单轮询,重复调用先停旧轮);
|
||||
* [STEP 2] 间隔制 4s 定时 GET getTransferRun——起始不立即打点(提交流程已 refreshRun);
|
||||
* [STEP 3] 成功才覆盖 run 旧值并回吐 onUpdate;run.status 落入 TERMINAL_RUN_STATUSES 即停;
|
||||
* [STEP 4] 单次失败保留旧值(不清 run、不置 error)继续下一轮;连续失败达
|
||||
* RUN_POLL_MAX_CONSECUTIVE_FAILURES 上限才停止并按既有模式落 error.value。
|
||||
* 清理:作用域销毁自动停止(onScopeDispose 在组合式函数创建时注册——
|
||||
* execute/手动调用都发生在 setup 之后的无作用域上下文,不能在此刻注册);返回手动 stop 句柄。
|
||||
*
|
||||
* @param pollRunNo - Run 编号(必传;来自 execute 响应或回放 payload 的 run_no;
|
||||
* 参数名带 poll 前缀避免遮蔽外层同名 runNo ref)
|
||||
* @param onUpdate - 每轮成功拉取的回调(参数为最新 TransferRunResult,含 orders;
|
||||
* 业务约束:禁止在该回调内再次调用 startRunPolling,避免同实例轮询互相顶替)
|
||||
* @returns stop 手动停止句柄(幂等,可重复调用)
|
||||
*/
|
||||
function startRunPolling(pollRunNo: string, onUpdate: (run: TransferRunResult) => void): () => void {
|
||||
stopRunPolling();
|
||||
const generation = ++pollGeneration;
|
||||
pollConsecutiveFailures = 0;
|
||||
pollConnecting.value = false; // 新轮询起点:连接视为正常,失败帧再置位
|
||||
|
||||
const scheduleNext = () => {
|
||||
if (generation !== pollGeneration) return;
|
||||
pollTimer = setTimeout(() => { void pollOnce(); }, RUN_POLL_INTERVAL_MS);
|
||||
};
|
||||
|
||||
const pollOnce = async () => {
|
||||
if (generation !== pollGeneration) return;
|
||||
try {
|
||||
const data = await getTransferRun(pollRunNo);
|
||||
if (generation !== pollGeneration) return;
|
||||
pollConsecutiveFailures = 0;
|
||||
pollConnecting.value = false; // 成功帧恢复连接态(保留旧值→新值,画面不清空)
|
||||
run.value = data;
|
||||
onUpdate(data);
|
||||
if (TERMINAL_RUN_STATUSES.has(data.status)) {
|
||||
// [P1 双保险] retrigger 窗口不误停:人工重新触发(result_unknown 单)受理时,
|
||||
// 后端已同步把 run.status 置回 executing(T10 同步段),故「retrigger 已受理但
|
||||
// worker 未领取」的瞬态不会以陈旧终态落入本判定而提前停轮;
|
||||
// 前端半(融合卡 confirmRetrigger)在进入本间隔轮询前先 refreshRun 打一帧兜底。
|
||||
stopRunPolling();
|
||||
return; // 终态:不再排下一轮
|
||||
}
|
||||
} catch (e) {
|
||||
if (generation !== pollGeneration) return;
|
||||
pollConsecutiveFailures += 1;
|
||||
pollConnecting.value = true; // 连续失败显示「连接中…」;终限停止后保留该提示
|
||||
if (pollConsecutiveFailures >= RUN_POLL_MAX_CONSECUTIVE_FAILURES) {
|
||||
error.value = String(e);
|
||||
stopRunPolling();
|
||||
return;
|
||||
}
|
||||
// 单次失败:保留旧值,静默进入下一轮
|
||||
}
|
||||
scheduleNext();
|
||||
};
|
||||
|
||||
scheduleNext();
|
||||
return stopRunPolling;
|
||||
}
|
||||
|
||||
// 卸载/作用域销毁清理:必须在组合式函数创建时(setup 作用域内)注册;
|
||||
// stopRunPolling/stopSourcePolling 均幂等,轮询未启动/已停止时调用为空操作。
|
||||
if (getCurrentScope()) onScopeDispose(() => {
|
||||
stopRunPolling();
|
||||
stopSourcePolling();
|
||||
});
|
||||
|
||||
/** 请求停止剩余任务(run → cancelled 后本轮轮询一并停止,避免空转) */
|
||||
async function cancelRun(reason: string) {
|
||||
if (!runNo.value) return null;
|
||||
const result = await cancelTransferRun(runNo.value, reason);
|
||||
await refreshRun();
|
||||
stopRunPolling();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -199,13 +349,83 @@ export function useChatTransfer() {
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 加载来源实例列表(决策 3:平台仅分组,每来源附收料文件状态) */
|
||||
/** 加载来源实例列表(决策 3:平台仅分组,每来源附收料文件状态);
|
||||
* 载入后按快照同步来源轮询:存在 fetching 来源即自动接管(触发重试后 RPA 异步收口,
|
||||
* 终态 ready/failed 只有重拉 /sources 才可见——否则来源卡永远停在「抓取中」)。 */
|
||||
async function loadSources() {
|
||||
sourceOptions.value = await listTransferSources();
|
||||
syncSourcePolling();
|
||||
return sourceOptions.value;
|
||||
}
|
||||
|
||||
/** 对指定来源重新触发收料 RPA 抓取,并刷新来源状态 */
|
||||
/**
|
||||
* 停止来源状态轮询(幂等):递增 generation 使在途回调失效并清掉未触发定时器。
|
||||
* 【AI 触发时机】:离开来源选择卡(确认匹配切匹配卡/回放替换 payload)与
|
||||
* 作用域销毁/reset 时由调用方调用,防止离屏后继续请求。
|
||||
*/
|
||||
function stopSourcePolling() {
|
||||
sourcePollGeneration += 1;
|
||||
if (sourcePollTimer !== null) {
|
||||
clearTimeout(sourcePollTimer);
|
||||
sourcePollTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动来源状态轮询(4s 间隔制,语义对齐 Run 轮询):按 interval 重拉 GET /sources,
|
||||
* 成功才覆盖 sourceOptions;全部来源脱离 fetching(ready/failed/expired/none 投影)
|
||||
* 即停止;单次失败保留旧值继续下一轮,连续失败达上限才停止(不落 error——来源卡
|
||||
* 有手动重试/刷新兜底,避免轮询失败噪声打断主流程)。
|
||||
* 起始不立即打点:两条进入路径(loadSources 挂载恢复 / retrySourceRpa 触发后)都已有新鲜一帧。
|
||||
*/
|
||||
function startSourcePolling() {
|
||||
stopSourcePolling();
|
||||
const generation = ++sourcePollGeneration;
|
||||
sourcePollConsecutiveFailures = 0;
|
||||
|
||||
const scheduleNext = () => {
|
||||
if (generation !== sourcePollGeneration) return;
|
||||
sourcePollTimer = setTimeout(() => { void pollOnce(); }, SOURCE_POLL_INTERVAL_MS);
|
||||
};
|
||||
|
||||
const pollOnce = async () => {
|
||||
if (generation !== sourcePollGeneration) return;
|
||||
try {
|
||||
const options = await listTransferSources();
|
||||
if (generation !== sourcePollGeneration) return;
|
||||
sourcePollConsecutiveFailures = 0;
|
||||
sourceOptions.value = options;
|
||||
// 直接判服务端快照(不经 syncSourcePolling,防与既有轮询互相顶替)
|
||||
if (!options.some((source) => source.file_status === 'fetching')) {
|
||||
stopSourcePolling();
|
||||
return;
|
||||
}
|
||||
} catch {
|
||||
if (generation !== sourcePollGeneration) return;
|
||||
sourcePollConsecutiveFailures += 1;
|
||||
if (sourcePollConsecutiveFailures >= SOURCE_POLL_MAX_CONSECUTIVE_FAILURES) {
|
||||
stopSourcePolling();
|
||||
return;
|
||||
}
|
||||
// 单次失败:保留旧值,静默进入下一轮
|
||||
}
|
||||
scheduleNext();
|
||||
};
|
||||
|
||||
scheduleNext();
|
||||
}
|
||||
|
||||
/** 按当前来源快照同步轮询启停:有抓取中来源→启动(重复调用先停旧轮),无→停止。 */
|
||||
function syncSourcePolling() {
|
||||
if (sourceOptions.value.some((source) => source.file_status === 'fetching')) {
|
||||
startSourcePolling();
|
||||
} else {
|
||||
stopSourcePolling();
|
||||
}
|
||||
}
|
||||
|
||||
/** 对指定来源重新触发收料 RPA 抓取,并刷新来源状态(触发后 202 + fetching,
|
||||
* loadSources 观察到 fetching 即自动开始来源轮询,RPA 回调收口后状态自动刷新) */
|
||||
async function retrySourceRpa(sourceCode: string) {
|
||||
const status = await retryTransferSourceRpa(sourceCode);
|
||||
await loadSources();
|
||||
@@ -253,6 +473,8 @@ export function useChatTransfer() {
|
||||
}
|
||||
|
||||
function reset() {
|
||||
stopRunPolling();
|
||||
stopSourcePolling();
|
||||
matchingId.value = null;
|
||||
matching.value = null;
|
||||
items.value = [];
|
||||
@@ -274,6 +496,7 @@ export function useChatTransfer() {
|
||||
sources,
|
||||
runNo,
|
||||
run,
|
||||
pollConnecting,
|
||||
backlog,
|
||||
backlogSummary,
|
||||
executableItems,
|
||||
@@ -289,6 +512,10 @@ export function useChatTransfer() {
|
||||
toggleSelect,
|
||||
execute,
|
||||
refreshRun,
|
||||
startRunPolling,
|
||||
stopRunPolling,
|
||||
startSourcePolling,
|
||||
stopSourcePolling,
|
||||
cancelRun,
|
||||
retry,
|
||||
manualClose,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
* features/chat/types/transfer.types.ts
|
||||
* 用途:在途仓自动调拨前端 DTO 类型(与后端 /api/in-transit-transfer 契约一致)。
|
||||
* 依赖:无。
|
||||
* 逻辑:卡片/组合式函数只消费这些稳定类型;状态与后端 13 状态集对齐。
|
||||
* 逻辑:卡片/组合式函数只消费这些稳定类型;行状态与后端 13 状态集对齐,
|
||||
* 单(TransferDocument)状态八态与 Run 调拨单清单(orders)对齐后端 Task 11 序列化。
|
||||
*/
|
||||
|
||||
/** 调拨业务类型(与后端 TransferType 枚举一致;类型 2/3 一期占位未开放) */
|
||||
@@ -15,6 +16,10 @@ export interface TransferMatchingCounts {
|
||||
matched_count: number;
|
||||
executable_count: number;
|
||||
blocked_count: number;
|
||||
/** 文件已落地、尚未查 ERP 库存的待查行数 */
|
||||
pending_stock_check_count?: number;
|
||||
/** 文件消失已出清的失效行数(不进默认视图) */
|
||||
invalid_count?: number;
|
||||
}
|
||||
|
||||
/** 原始文件行追溯 */
|
||||
@@ -111,7 +116,41 @@ export interface TransferExceptionItem {
|
||||
facts: string;
|
||||
}
|
||||
|
||||
/** Run 结果投影 */
|
||||
/**
|
||||
* 调拨单(TransferDocument)状态八态,与后端单状态机一致(status.py / execution_service):
|
||||
* pending(待执行)→ executing(执行中)→ success / duplicate_success(成功族,带 ERP 单号)/
|
||||
* business_failed / technical_failed(失败族,error_message 带原因)/ result_unknown(结果未知,
|
||||
* 唯一出边=人工 retrigger)/ cancelled(人工关闭单)。
|
||||
*/
|
||||
export type TransferOrderStatus = 'pending' | 'executing' | 'success' | 'duplicate_success'
|
||||
| 'business_failed' | 'technical_failed' | 'result_unknown' | 'cancelled';
|
||||
|
||||
/** 单内行(ERP 写入行粒度聚合:物料+批号;quantity 为 6 位小数字符串,与 D14 快照口径一致) */
|
||||
export interface TransferOrderLine {
|
||||
material_no: string;
|
||||
material_name: string;
|
||||
lot_no: string;
|
||||
quantity: string;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调拨单(D9 融合卡数据源:调拨单清单=进度=结果)。
|
||||
* 与后端 GET /runs/{run_no} 返回体 orders 数组逐键对应(serialize_run_orders);
|
||||
* erp_document_no / error_message 二态互斥(成功族带单号,失败族带原因,其余为 null)。
|
||||
*/
|
||||
export interface TransferOrder {
|
||||
doc_no: string;
|
||||
receipt_date: string;
|
||||
from_warehouse: string;
|
||||
to_warehouse: string;
|
||||
status: TransferOrderStatus;
|
||||
erp_document_no: string | null;
|
||||
error_message: string | null;
|
||||
lines: TransferOrderLine[];
|
||||
}
|
||||
|
||||
/** Run 结果投影(result 单号聚合 + orders 调拨单清单:D9 融合卡数据源) */
|
||||
export interface TransferRunResult {
|
||||
run_no: string;
|
||||
status: string;
|
||||
@@ -119,9 +158,15 @@ export interface TransferRunResult {
|
||||
external_documents: ErpDocument[];
|
||||
exceptions: TransferExceptionItem[];
|
||||
};
|
||||
/** 调拨单清单(后端 Task 11 序列化逐键;终态 Run 亦同口径投影) */
|
||||
orders: TransferOrder[];
|
||||
}
|
||||
|
||||
/** 执行响应 */
|
||||
/**
|
||||
* 执行响应(D8 异步 202:POST /items/execute 只做门禁+建 Run+建单+入队,
|
||||
* data = { run_no, status: 'queued' };进度/结果由前端轮询 GET /runs/{run_no} 获取)。
|
||||
* result 为同步执行时代的旧口径,202 后不再返回,保留可选兼容历史回放 payload。
|
||||
*/
|
||||
export interface TransferExecuteResponse {
|
||||
run_no: string;
|
||||
status: string;
|
||||
@@ -165,6 +210,16 @@ export interface TransferActionResult {
|
||||
cancelled_count?: number;
|
||||
}
|
||||
|
||||
|
||||
/** 调拨单级重试响应(retry_document:全部 ready 自动重跑,部分阻断留恢复池) */
|
||||
export interface TransferDocumentRetryResult {
|
||||
doc_no: string;
|
||||
rerun: boolean;
|
||||
run_no: string | null;
|
||||
ready: number;
|
||||
blocked: { invoice_no: string; item_id: number; reason: string }[];
|
||||
total: number;
|
||||
}
|
||||
/** 待处理池汇总 */
|
||||
export interface TransferBacklogSummary {
|
||||
recoverable: number;
|
||||
@@ -199,3 +254,53 @@ export interface TransferSourceFileStatus {
|
||||
file_no?: string | null;
|
||||
file_sha256?: string | null;
|
||||
}
|
||||
|
||||
/** 已执行单统计分组(首页区块 chip;计数恒全量,不受筛选影响——后端口径) */
|
||||
export interface TransferOrderGroups {
|
||||
success: number;
|
||||
failed: number;
|
||||
executing: number;
|
||||
result_unknown: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已执行单行明细(invoice 粒度;GET /documents orders[].items,
|
||||
* 与融合卡的聚合 lines 不同——本视图逐 Invoice 行展示,供展开明细与关闭影响面核对)。
|
||||
*/
|
||||
export interface TransferExecutedOrderItem {
|
||||
invoice_no: string;
|
||||
material_no: string;
|
||||
material_name: string;
|
||||
lot_no: string;
|
||||
quantity: string;
|
||||
unit: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 已执行单(首页「已执行」区块;与后端 GET /documents 返回体 orders 逐键对应)。
|
||||
* run_no 为重新触发(D11)所需——result_unknown 行持它调
|
||||
* POST /runs/{run_no}/documents/{doc_no}/retrigger(T13 封装 retriggerTransferDocument)。
|
||||
*/
|
||||
export interface TransferExecutedOrder {
|
||||
doc_no: string;
|
||||
submit_timestamp: string;
|
||||
status: TransferOrderStatus;
|
||||
status_group: keyof TransferOrderGroups;
|
||||
receipt_date: string;
|
||||
from_warehouse: string;
|
||||
to_warehouse: string;
|
||||
erp_document_no: string | null;
|
||||
error_message: string | null;
|
||||
created_at: string;
|
||||
run_no: string | null;
|
||||
items: TransferExecutedOrderItem[];
|
||||
}
|
||||
|
||||
/** 已执行单分页查询响应(GET /documents;groups 计数恒全量,total 为筛选后分页总数) */
|
||||
export interface TransferExecutedOrdersPage {
|
||||
groups: TransferOrderGroups;
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
orders: TransferExecutedOrder[];
|
||||
}
|
||||
@@ -5166,7 +5166,8 @@
|
||||
"interface": "Interface Definitions",
|
||||
"binding": "Bindings",
|
||||
"credential": "Credential References",
|
||||
"capability": "Capabilities"
|
||||
"capability": "Capabilities",
|
||||
"calls": "Call logs"
|
||||
},
|
||||
"statusLabels": {
|
||||
"draft": "Draft",
|
||||
@@ -5217,7 +5218,7 @@
|
||||
"environment": "Environment",
|
||||
"status": "Status",
|
||||
"clientInstance": "Client Instance",
|
||||
"interfaceDef": "Interface",
|
||||
"interfaceDef": "Interface Steps (ordered)",
|
||||
"secretRef": "Secret Reference",
|
||||
"secretProvider": "Source",
|
||||
"account": "Account",
|
||||
@@ -5232,6 +5233,7 @@
|
||||
"code": "Code",
|
||||
"name": "Name",
|
||||
"connectorType": "Connector Type",
|
||||
"dbKind": "Database kind (db_kind)",
|
||||
"environment": "Environment",
|
||||
"credentialRef": "Credential Reference Code",
|
||||
"configJson": "Connection Config JSON (endpoint / timeout / default org, etc.)",
|
||||
@@ -5253,9 +5255,6 @@
|
||||
"effectiveTo": "Effective To",
|
||||
"contextSelector": "Advanced Routing Conditions JSON",
|
||||
"contextSelectorHint": "All key-value pairs must be contained in the call context to match; callers currently send no routing context, so leave it empty for the default binding.",
|
||||
"paramMapping": "Parameter Mapping JSON",
|
||||
"paramMappingHint": "Translation rules from domain params to interface params (e.g. erp_org to organization, condition template); leave empty for same-name passthrough.",
|
||||
"bindingClientHint": "Derived and locked from the selected interface definition; not editable separately.",
|
||||
"secretRef": "Secret Reference Key",
|
||||
"secretProvider": "Secret Source",
|
||||
"credentialType": "Credential Type",
|
||||
@@ -5283,7 +5282,8 @@
|
||||
"msg": {
|
||||
"fillClient": "Please fill in the name",
|
||||
"fillInterface": "Please select a client instance (the code can be auto-generated)",
|
||||
"fillBinding": "Please fill in the capability, client instance and interface definition",
|
||||
"fillBinding": "Please fill in the capability and add at least one step (choose an interface per step)",
|
||||
"fillDbKind": "Please choose a database kind (MySQL / Oracle / SQL Server / PostgreSQL)",
|
||||
"fillCredential": "Please fill in the code and the secret reference",
|
||||
"fillCredentialDb": "Please fill in the code and the required credential fields: {fields}",
|
||||
"credentialTypeMissing": "Credential type list not loaded, please refresh and retry",
|
||||
@@ -5318,7 +5318,8 @@
|
||||
"endpoint": "https://erp-api.example.com/ws",
|
||||
"wsdl": "https://erp-api.example.com/wsdl",
|
||||
"requestPath": "Path supports placeholders, e.g. /transfer/xxx",
|
||||
"passwordKeep": "Leave blank to keep the current password"
|
||||
"passwordKeep": "Leave blank to keep the current password",
|
||||
"database": "erp-host:1521/ORCL or 127.0.0.1:3306/dbname"
|
||||
},
|
||||
"advancedConfig": "Advanced Config (JSON)",
|
||||
"formatJson": "Format",
|
||||
@@ -5339,7 +5340,70 @@
|
||||
},
|
||||
"connectorTypes": {
|
||||
"rest": "REST API",
|
||||
"soap": "SOAP Service"
|
||||
"soap": "SOAP Service",
|
||||
"database": "Database (Direct)"
|
||||
},
|
||||
"connectorDbKind": {
|
||||
"mysql": "MySQL",
|
||||
"oracle": "Oracle",
|
||||
"sqlserver": "SQL Server",
|
||||
"postgresql": "PostgreSQL"
|
||||
},
|
||||
"endpointLabel": {
|
||||
"database": "Database connection string (host:port/service or /database)"
|
||||
},
|
||||
"bindingSteps": {
|
||||
"label": "Execution Steps (ordered)",
|
||||
"add": "Add Step",
|
||||
"remove": "Remove Step",
|
||||
"moveUp": "Move Up",
|
||||
"moveDown": "Move Down",
|
||||
"interface": "Interface Definition",
|
||||
"paramMapping": "Step {index} Parameter Mapping JSON",
|
||||
"clientHint": "Client instance is derived from this step's interface: {client}",
|
||||
"hint": "Steps run in array order; each step has its own parameter mapping, and the client instance comes with each step's interface."
|
||||
},
|
||||
"callLogs": {
|
||||
"title": "Call records",
|
||||
"filterInterface": "Interface",
|
||||
"filterClient": "Client code",
|
||||
"filterConnector": "Connector type",
|
||||
"filterStatus": "Status",
|
||||
"filterOperationId": "Operation ID",
|
||||
"filterTraceId": "Trace ID",
|
||||
"filterBusinessRef": "Business ref",
|
||||
"filterKeyword": "Keyword in request",
|
||||
"dateFrom": "Time from",
|
||||
"dateTo": "Time to",
|
||||
"query": "Query",
|
||||
"reset": "Reset",
|
||||
"colTime": "Time",
|
||||
"colCapability": "Capability",
|
||||
"colInterface": "Interface",
|
||||
"colRef": "Ref",
|
||||
"colStep": "Step",
|
||||
"colStatus": "Status",
|
||||
"colElapsed": "Elapsed",
|
||||
"detailTitle": "Call detail",
|
||||
"timeline": "Step timeline",
|
||||
"request": "Request",
|
||||
"response": "Response",
|
||||
"wire": "Wire-level request",
|
||||
"rawPayload": "Raw payload",
|
||||
"normalized": "Business params (normalized)",
|
||||
"normalizedJson": "Normalized JSON",
|
||||
"copyBody": "Copy body",
|
||||
"copyCurl": "Copy curl",
|
||||
"copySql": "Copy SQL",
|
||||
"copyRaw": "Copy raw payload",
|
||||
"copyJson": "Copy JSON",
|
||||
"copyOperationId": "Copy operation_id",
|
||||
"copyTraceId": "Copy trace_id",
|
||||
"copied": "Copied",
|
||||
"noWire": "No wire details (historical record)",
|
||||
"sqlWriteWarning": "⚠ Write statements: confirm target environment before executing",
|
||||
"prevPage": "Previous page",
|
||||
"nextPage": "Next page"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3711,6 +3711,8 @@
|
||||
"blockedCount": "Blocked",
|
||||
"estimatedQuantity": "Est. transfer qty",
|
||||
"estimatedExternalWrites": "Est. ERP documents",
|
||||
"pendingStockCheckCount": "Pending stock check",
|
||||
"invalidRowCount": "{count} invalid rows",
|
||||
"reasonQuantityMismatch": "ERP book stock quantity does not match the received quantity",
|
||||
"reasonInventoryNotFound": "No ERP stock record for this lot; stock is shown as 0",
|
||||
"reasonExternalQueryFailed": "External system query failed",
|
||||
@@ -3742,8 +3744,10 @@
|
||||
"resultBlocked": "Blocked",
|
||||
"resultUnknown": "Result unknown",
|
||||
"resultFileRemoved": "Removed from file",
|
||||
"resultPendingStockCheck": "Pending stock check",
|
||||
"staleRow": "Stale — requery",
|
||||
"fileChangedRow": "File updated — re-match",
|
||||
"fileChangedRow": "File updated; data will realign",
|
||||
"fileRemovedQuarantined": "{count} more rows were invalidated (removed from the receipt file) and are hidden from this list; handle them under Pending Exceptions (mark as no further action).",
|
||||
"runProgress": "Transfer run progress",
|
||||
"runExecuting": "Executing",
|
||||
"runSuccess": "Completed",
|
||||
@@ -3771,7 +3775,6 @@
|
||||
"receiptDateInvalid": "Start date cannot be after end date",
|
||||
"toastRequeryDone": "Requery done: {ok} rows updated, {failed} failed",
|
||||
"toastRequeryRecovered": "Resume done: {recovered} executable · {blocked} still blocked",
|
||||
"toastExecuteStale": "{count} stale rows — requery before generating",
|
||||
"toastExecuteFileChanged": "{count} rows with file updated — re-match",
|
||||
"toastCloseDone": "Closed: {ok} succeeded, {failed} failed",
|
||||
"batchCloseTitle": "Mark as no further action ({count} items)",
|
||||
@@ -3837,6 +3840,84 @@
|
||||
"homeExecutableHint": "Select rows and generate transfer orders",
|
||||
"executableTitle": "Executable items",
|
||||
"executableEmpty": "No executable items",
|
||||
"executableSelectedCount": "{count} executable rows selected"
|
||||
"executableSelectedCount": "{count} executable rows selected",
|
||||
"runTitle": "Generate transfer orders",
|
||||
"runBadge": {
|
||||
"queued": "Queued",
|
||||
"executing": "Executing",
|
||||
"success": "Success",
|
||||
"partialFailed": "Partially failed",
|
||||
"failed": "Failed"
|
||||
},
|
||||
"orderStatus": {
|
||||
"pending": "Pending",
|
||||
"executing": "Executing",
|
||||
"success": "Success",
|
||||
"resultUnknown": "Result unknown",
|
||||
"failed": "Failed",
|
||||
"cancelled": "Closed"
|
||||
},
|
||||
"orderAction": {
|
||||
"retrigger": "Retrigger",
|
||||
"retry": "Retry",
|
||||
"retryAccepted": "Order {docNo} has been resubmitted; progress will refresh automatically.",
|
||||
"retryPartial": "Recheck finished: {ready} line(s) executable, {blocked} still blocked and kept in the recovery pool.",
|
||||
"closeOrder": "Close order"
|
||||
},
|
||||
"orderReasonPrefix": "Reason: {reason}",
|
||||
"poll": {
|
||||
"connecting": "Connecting…"
|
||||
},
|
||||
"execute": {
|
||||
"accepted": "Submitted. Execution is queued; progress will update below.",
|
||||
"noSelection": "Select at least one executable row"
|
||||
},
|
||||
"retriggerDialog": {
|
||||
"title": "Retrigger {docNo}",
|
||||
"body": "Reuses this order's original document no. and submit timestamp and retriggers only the final step (idempotent and safe; no duplicate document will be created).",
|
||||
"confirm": "Confirm retrigger",
|
||||
"dismiss": "Back"
|
||||
},
|
||||
"orderClose": {
|
||||
"title": "Close order {docNo}",
|
||||
"impactHint": "The {count} line(s) of this order will be detached and returned to the pending pool (they can be re-selected into a new order):",
|
||||
"redline": "Closing an order does not mean no ERP document exists: manually confirm in ERP before closing.",
|
||||
"reasonPlaceholder": "Reason (required)",
|
||||
"confirm": "Confirm close",
|
||||
"dismiss": "Back"
|
||||
},
|
||||
"toastOrderClosed": "Order closed; its rows returned to the pending pool",
|
||||
"toastRetriggerAccepted": "Retriggered; the final step is queued",
|
||||
"homeExecuted": {
|
||||
"title": "Executed transfer orders",
|
||||
"refresh": "Refresh",
|
||||
"empty": "No executed orders yet",
|
||||
"pageInfo": "{total} orders · page {page}",
|
||||
"back": "Back",
|
||||
"all": "All",
|
||||
"groupHint": {
|
||||
"success": "ERP number written back, view details",
|
||||
"failed": "Recheck stock or close the order",
|
||||
"executing": "Writing stage table / triggering ERP",
|
||||
"resultUnknown": "Read-only, verify with ERP offline"
|
||||
},
|
||||
"dateFrom": "Date from",
|
||||
"dateTo": "Date to",
|
||||
"group": {
|
||||
"success": "Success",
|
||||
"failed": "Failed",
|
||||
"executing": "Executing",
|
||||
"resultUnknown": "Unknown result"
|
||||
},
|
||||
"closeDialog": {
|
||||
"title": "Close order {docNo}",
|
||||
"reasonRequired": "Close reason (required)",
|
||||
"redlineWhole": "Closing voids the whole order (including unposted rows) and cannot be undone.",
|
||||
"redlineResidue": "Rows already written to ERP are not deleted automatically; verify residuals manually per the SOP.",
|
||||
"redlineReopen": "All rows will leave this order and return to the ready-to-execute pool for re-grouping.",
|
||||
"redlineErpCheck": "Closing an order does not mean no ERP document exists: confirm in ERP that no matching document exists before closing.",
|
||||
"confirm": "Confirm close"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,6 +561,14 @@
|
||||
"TRANSFER.BATCH_ITEMS_REQUIRED": "Item ids are required.",
|
||||
"TRANSFER.EXECUTE_ITEMS_INVALID": "Some rows do not exist or are not executable; refresh and retry.",
|
||||
"TRANSFER.ITEMS_STALE": "Some rows were evaluated too long ago; re-run the matching.",
|
||||
"TRANSFER.FILE_CHANGED": "The receipt file has changed; re-run the matching before executing."
|
||||
"TRANSFER.FILE_CHANGED": "The receipt file has changed; re-run the matching before executing.",
|
||||
"TRANSFER.ORG_REQUIRED": "External organization code is required.",
|
||||
"TRANSFER.RETRIGGER_NOT_ALLOWED": "Only result_unknown tickets can be retriggered; closing and recreating is forbidden.",
|
||||
"TRANSFER.RETRY_NOT_ALLOWED": "This row was removed along with the file and cannot be requeried; mark it as no further action or wait for the file to re-sync.",
|
||||
"TRANSFER.DOCUMENT_CLOSE_NOT_ALLOWED": "Only failed tickets (business/technical) can be closed; use \"Retrigger\" for result_unknown tickets, in-flight tickets cannot be closed.",
|
||||
"TRANSFER.DOCUMENT_NOT_FOUND": "Transfer ticket not found.",
|
||||
"INTEGRATION.BINDING_LEGACY_PUT_REJECTED": "Legacy single-step fields would truncate this binding's multi-step recipe; submit ordered steps via steps_json instead.",
|
||||
"INTEGRATION.CALL_NOT_FOUND": "Integration call not found.",
|
||||
"INTEGRATION.BINDING_STEPS_INVALID": "Binding steps invalid: steps_json is required, must be a non-empty array of objects."
|
||||
}
|
||||
}
|
||||
@@ -5035,7 +5035,8 @@
|
||||
"interface": "นิยามอินเทอร์เฟซ",
|
||||
"binding": "การผูก",
|
||||
"credential": "การอ้างอิงข้อมูลรับรอง",
|
||||
"capability": "รายการความสามารถ"
|
||||
"capability": "รายการความสามารถ",
|
||||
"calls": "ประวัติการเรียกใช้"
|
||||
},
|
||||
"statusLabels": {
|
||||
"draft": "ฉบับร่าง",
|
||||
@@ -5086,7 +5087,7 @@
|
||||
"environment": "สภาพแวดล้อม",
|
||||
"status": "สถานะ",
|
||||
"clientInstance": "อินสแตนซ์ไคลเอ็นต์",
|
||||
"interfaceDef": "อินเทอร์เฟซ",
|
||||
"interfaceDef": "ขั้นตอนอินเทอร์เฟซ (เรียงลำดับ)",
|
||||
"secretRef": "การอ้างอิง Secret",
|
||||
"secretProvider": "แหล่งที่มา",
|
||||
"account": "บัญชี",
|
||||
@@ -5101,6 +5102,7 @@
|
||||
"code": "รหัส",
|
||||
"name": "ชื่อ",
|
||||
"connectorType": "ประเภทตัวเชื่อมต่อ",
|
||||
"dbKind": "ชนิดฐานข้อมูล (db_kind)",
|
||||
"environment": "สภาพแวดล้อม",
|
||||
"credentialRef": "รหัสการอ้างอิงข้อมูลรับรอง",
|
||||
"configJson": "JSON การตั้งค่าการเชื่อมต่อ (ที่อยู่/หมดเวลา/org เริ่มต้น ฯลฯ)",
|
||||
@@ -5122,9 +5124,6 @@
|
||||
"effectiveTo": "มีผลถึง",
|
||||
"contextSelector": "JSON เงื่อนไขการกำหนดเส้นทางขั้นสูง",
|
||||
"contextSelectorHint": "คู่คีย์-ค่าทั้งหมดต้องอยู่ในบริบทการเรียกจึงจะจับคู่ได้ โดยเวอร์ชันปัจจุบันผู้เรียกไม่ส่งบริบทการกำหนดเส้นทาง ปล่อยว่างไว้จะเป็นการผูกค่าเริ่มต้น",
|
||||
"paramMapping": "JSON การแมปพารามิเตอร์",
|
||||
"paramMappingHint": "กฎการแปลพารามิเตอร์โดเมนเป็นพารามิเตอร์อินเทอร์เฟซ (เช่น erp_org เป็น organization, เทมเพลต condition) หากว่างจะส่งต่อชื่อเดียวกัน",
|
||||
"bindingClientHint": "ดึงและล็อกโดยอัตโนมัติตามคำนิยามอินเทอร์เฟซที่เลือก แก้ไขเองไม่ได้",
|
||||
"secretRef": "คีย์อ้างอิง Secret",
|
||||
"secretProvider": "แหล่ง Secret",
|
||||
"credentialType": "ประเภทข้อมูลรับรอง",
|
||||
@@ -5152,7 +5151,8 @@
|
||||
"msg": {
|
||||
"fillClient": "กรุณากรอกชื่อ",
|
||||
"fillInterface": "กรุณาเลือกอินสแตนซ์ไคลเอ็นต์ (รหัสสร้างอัตโนมัติได้)",
|
||||
"fillBinding": "กรุณากรอกความสามารถ อินสแตนซ์ไคลเอ็นต์ และนิยามอินเทอร์เฟซ",
|
||||
"fillBinding": "กรุณากรอกความสามารถ และเพิ่มขั้นตอนอย่างน้อยหนึ่งขั้น (เลือกอินเทอร์เฟซของแต่ละขั้น)",
|
||||
"fillDbKind": "กรุณาเลือกชนิดฐานข้อมูล (MySQL / Oracle / SQL Server / PostgreSQL)",
|
||||
"fillCredential": "กรุณากรอกรหัสและการอ้างอิง Secret",
|
||||
"fillCredentialDb": "กรุณากรอกรหัส และฟิลด์ข้อมูลประจำตัวที่จำเป็น: {fields}",
|
||||
"credentialTypeMissing": "รายการประเภทข้อมูลประจำตัวยังไม่โหลด โปรดรีเฟรชแล้วลองใหม่",
|
||||
@@ -5187,7 +5187,8 @@
|
||||
"endpoint": "https://erp-api.example.com/ws",
|
||||
"wsdl": "https://erp-api.example.com/wsdl",
|
||||
"requestPath": "เส้นทางรองรับตัวยึดตำแหน่ง เช่น /transfer/xxx",
|
||||
"passwordKeep": "ปล่อยว่างไว้เพื่อคงรหัสผ่านเดิม"
|
||||
"passwordKeep": "ปล่อยว่างไว้เพื่อคงรหัสผ่านเดิม",
|
||||
"database": "erp-host:1521/ORCL หรือ 127.0.0.1:3306/dbname"
|
||||
},
|
||||
"advancedConfig": "การตั้งค่าขั้นสูง (JSON)",
|
||||
"formatJson": "จัดรูปแบบ",
|
||||
@@ -5208,7 +5209,70 @@
|
||||
},
|
||||
"connectorTypes": {
|
||||
"rest": "REST API",
|
||||
"soap": "บริการ SOAP"
|
||||
"soap": "บริการ SOAP",
|
||||
"database": "ฐานข้อมูล (เชื่อมตรง)"
|
||||
},
|
||||
"connectorDbKind": {
|
||||
"mysql": "MySQL",
|
||||
"oracle": "Oracle",
|
||||
"sqlserver": "SQL Server",
|
||||
"postgresql": "PostgreSQL"
|
||||
},
|
||||
"endpointLabel": {
|
||||
"database": "สตริงการเชื่อมต่อฐานข้อมูล (host:port/service หรือ /database)"
|
||||
},
|
||||
"bindingSteps": {
|
||||
"label": "ขั้นตอนการทำงาน (ตามลำดับ)",
|
||||
"add": "เพิ่มขั้นตอน",
|
||||
"remove": "ลบขั้นตอน",
|
||||
"moveUp": "ย้ายขึ้น",
|
||||
"moveDown": "ย้ายลง",
|
||||
"interface": "นิยามอินเทอร์เฟซ",
|
||||
"paramMapping": "JSON การแมปพารามิเตอร์ของขั้นตอนที่ {index}",
|
||||
"clientHint": "อินสแตนซ์ไคลเอ็นต์กำหนดอัตโนมัติจากอินเทอร์เฟซของขั้นตอนนี้: {client}",
|
||||
"hint": "ขั้นตอนจะทำงานตามลำดับในอาร์เรย์ แต่ละขั้นตอนมีการแมปพารามิเตอร์ของตัวเอง และอินสแตนซ์ไคลเอ็นต์มาพร้อมกับอินเทอร์เฟซของแต่ละขั้นตอน"
|
||||
},
|
||||
"callLogs": {
|
||||
"title": "บันทึกการเรียกใช้",
|
||||
"filterInterface": "รหัสอินเทอร์เฟซ",
|
||||
"filterClient": "รหัสไคลเอ็นต์",
|
||||
"filterConnector": "ประเภทตัวเชื่อมต่อ",
|
||||
"filterStatus": "สถานะ",
|
||||
"filterOperationId": "operation_id",
|
||||
"filterTraceId": "trace_id",
|
||||
"filterBusinessRef": "เลขที่เอกสารธุรกิจ",
|
||||
"filterKeyword": "คำสำคัญในคำขอ",
|
||||
"dateFrom": "เวลาเริ่มต้น",
|
||||
"dateTo": "เวลาสิ้นสุด",
|
||||
"query": "ค้นหา",
|
||||
"reset": "รีเซ็ต",
|
||||
"colTime": "เวลา",
|
||||
"colCapability": "ความสามารถ",
|
||||
"colInterface": "อินเทอร์เฟซ",
|
||||
"colRef": "เลขที่อ้างอิง",
|
||||
"colStep": "ขั้นตอน",
|
||||
"colStatus": "สถานะ",
|
||||
"colElapsed": "เวลาที่ใช้",
|
||||
"detailTitle": "รายละเอียดการเรียกใช้",
|
||||
"timeline": "ไทม์ไลน์ขั้นตอน",
|
||||
"request": "คำขอ",
|
||||
"response": "การตอบกลับ",
|
||||
"wire": "คำขอระดับ wire",
|
||||
"rawPayload": "ข้อความดิบ",
|
||||
"normalized": "พารามิเตอร์ธุรกิจ (มาตรฐาน)",
|
||||
"normalizedJson": "JSON มาตรฐาน",
|
||||
"copyBody": "คัดลอก body",
|
||||
"copyCurl": "คัดลอก curl",
|
||||
"copySql": "คัดลอก SQL",
|
||||
"copyRaw": "คัดลอกข้อความดิบ",
|
||||
"copyJson": "คัดลอก JSON",
|
||||
"copyOperationId": "คัดลอก operation_id",
|
||||
"copyTraceId": "คัดลอก trace_id",
|
||||
"copied": "คัดลอกแล้ว",
|
||||
"noWire": "ไม่มีรายละเอียดระดับ wire (ระเบียนเก่า)",
|
||||
"sqlWriteWarning": "⚠ คำสั่งเขียน: โปรดยืนยันสภาพแวดล้อมเป้าหมายก่อนดำเนินการ",
|
||||
"prevPage": "หน้าก่อนหน้า",
|
||||
"nextPage": "หน้าถัดไป"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3711,6 +3711,8 @@
|
||||
"blockedCount": "ถูกบล็อก",
|
||||
"estimatedQuantity": "จำนวนโอนโดยประมาณ",
|
||||
"estimatedExternalWrites": "เอกสาร ERP โดยประมาณ",
|
||||
"pendingStockCheckCount": "รอตรวจสอบสต๊อก",
|
||||
"invalidRowCount": "{count} แถวหมดอายุ",
|
||||
"reasonQuantityMismatch": "ปริมาณสต๊อกตามบัญชี ERP ไม่ตรงกับปริมาณที่รับสินค้า",
|
||||
"reasonInventoryNotFound": "ไม่มีระเบียนสต๊อก ERP สำหรับล็อตนี้ แสดงสต๊อกเป็น 0",
|
||||
"reasonExternalQueryFailed": "การสอบถามระบบภายนอกล้มเหลว",
|
||||
@@ -3742,8 +3744,10 @@
|
||||
"resultBlocked": "ถูกบล็อก",
|
||||
"resultUnknown": "ผลไม่ทราบ",
|
||||
"resultFileRemoved": "ถูกลบออกจากไฟล์",
|
||||
"resultPendingStockCheck": "รอตรวจสอบสต๊อก",
|
||||
"staleRow": "ข้อมูลหมดอายุ กรุณาตรวจซ้ำ",
|
||||
"fileChangedRow": "ไฟล์มีการเปลี่ยนแปลง กรุณาจับคู่ใหม่",
|
||||
"fileChangedRow": "ไฟล์อัปเดตแล้ว ข้อมูลจะจัดตำแหน่งใหม่อัตโนมัติ",
|
||||
"fileRemovedQuarantined": "อีก {count} รายการถือเป็นยกเลิกเนื่องจากถูกลบออกจากไฟล์รับของ และถูกซ่อนจากรายการนี้ โปรดดำเนินการใน「ข้อยกเว้นที่รอดำเนินการ」โดยสามารถทำเครื่องหมายว่าไม่จำเป็นต้องดำเนินการต่อ",
|
||||
"runProgress": "ความคืบหน้าการโอน",
|
||||
"runExecuting": "กำลังดำเนินการ",
|
||||
"runSuccess": "เสร็จสิ้น",
|
||||
@@ -3771,7 +3775,6 @@
|
||||
"receiptDateInvalid": "วันเริ่มต้นต้องไม่ช้ากว่าวันสิ้นสุด",
|
||||
"toastRequeryDone": "ตรวจซ้ำเสร็จ: อัปเดตแล้ว {ok} แถว ล้มเหลว {failed} แถว",
|
||||
"toastRequeryRecovered": "กู้คืนเสร็จสิ้น: {recovered} รายการดำเนินการได้ · {blocked} รายการยังถูกบล็อก",
|
||||
"toastExecuteStale": "{count} รายการข้อมูลหมดอายุ กรุณาตรวจซ้ำก่อนสร้าง",
|
||||
"toastExecuteFileChanged": "{count} รายการไฟล์มีการเปลี่ยนแปลง กรุณาจับคู่ใหม่",
|
||||
"toastCloseDone": "ปิดแล้ว: สำเร็จ {ok} รายการ ล้มเหลว {failed} รายการ",
|
||||
"batchCloseTitle": "ทำเครื่องหมายไม่ต้องดำเนินการต่อ ({count} รายการ)",
|
||||
@@ -3837,6 +3840,84 @@
|
||||
"homeExecutableHint": "เลือกแถวเพื่อสร้างใบโอน",
|
||||
"executableTitle": "รายการที่โอนได้",
|
||||
"executableEmpty": "ไม่มีรายการที่โอนได้",
|
||||
"executableSelectedCount": "เลือกแล้ว {count} รายการ"
|
||||
"executableSelectedCount": "เลือกแล้ว {count} รายการ",
|
||||
"runTitle": "สร้างใบโอน",
|
||||
"runBadge": {
|
||||
"queued": "อยู่ในคิว",
|
||||
"executing": "กำลังดำเนินการ",
|
||||
"success": "สำเร็จ",
|
||||
"partialFailed": "ล้มเหลวบางส่วน",
|
||||
"failed": "ล้มเหลว"
|
||||
},
|
||||
"orderStatus": {
|
||||
"pending": "รอดำเนินการ",
|
||||
"executing": "กำลังดำเนินการ",
|
||||
"success": "สำเร็จ",
|
||||
"resultUnknown": "ผลลัพธ์ไม่ทราบแน่ชัด",
|
||||
"failed": "ล้มเหลว",
|
||||
"cancelled": "ปิดไปแล้ว"
|
||||
},
|
||||
"orderAction": {
|
||||
"retrigger": "ทริกเกอร์ใหม่",
|
||||
"retry": "ลองใหม่",
|
||||
"retryAccepted": "ส่งใบโอนย้าย {docNo} เข้าคิวดำเนินการใหม่แล้ว ความคืบหน้าจะรีเฟรชอัตโนมัติ",
|
||||
"retryPartial": "ตรวจสอบซ้ำเสร็จ: {ready} รายการพร้อมดำเนินการ {blocked} รายการยังถูกบล็อกและอยู่ในคลังรอกู้คืน",
|
||||
"closeOrder": "ปิดใบโอนย้าย"
|
||||
},
|
||||
"orderReasonPrefix": "เหตุผล: {reason}",
|
||||
"poll": {
|
||||
"connecting": "กำลังเชื่อมต่อ…"
|
||||
},
|
||||
"execute": {
|
||||
"accepted": "ส่งคำขอแล้ว งานอยู่ในคิว ความคืบหน้าจะแสดงด้านล่าง",
|
||||
"noSelection": "กรุณาเลือกรายการที่ดำเนินการได้อย่างน้อยหนึ่งรายการ"
|
||||
},
|
||||
"retriggerDialog": {
|
||||
"title": "ทริกเกอร์ใหม่ {docNo}",
|
||||
"body": "จะใช้หมายเลขเอกสารและเวลาส่งเดิมของใบโอนย้ายนี้ และทริกเกอร์เฉพาะขั้นตอนสุดท้าย (idempotent ปลอดภัย จะไม่สร้างเอกสารซ้ำ)",
|
||||
"confirm": "ยืนยันการทริกเกอร์ใหม่",
|
||||
"dismiss": "กลับ"
|
||||
},
|
||||
"orderClose": {
|
||||
"title": "ปิดใบโอนย้าย {docNo}",
|
||||
"impactHint": "รายการ {count} รายการของใบโอนย้ายนี้จะถูกแยกออกและกลับไปยังคลังรอดำเนินการ (เลือกจัดใหม่ได้):",
|
||||
"redline": "การปิดใบโอนย้ายไม่ได้แปลว่าไม่มีเอกสารใน ERP: ต้องยืนยันใน ERP ด้วยตนเองก่อนปิด",
|
||||
"reasonPlaceholder": "เหตุผล (จำเป็น)",
|
||||
"confirm": "ยืนยันการปิด",
|
||||
"dismiss": "กลับ"
|
||||
},
|
||||
"toastOrderClosed": "ปิดใบโอนย้ายแล้ว รายการกลับไปยังคลังรอดำเนินการ",
|
||||
"toastRetriggerAccepted": "ทริกเกอร์ใหม่แล้ว ขั้นตอนสุดท้ายอยู่ในคิว",
|
||||
"homeExecuted": {
|
||||
"title": "ใบโอนย้ายที่ดำเนินการแล้ว",
|
||||
"refresh": "รีเฟรช",
|
||||
"empty": "ยังไม่มีใบโอนย้ายที่ดำเนินการแล้ว",
|
||||
"pageInfo": "ทั้งหมด {total} ใบ · หน้า {page}",
|
||||
"back": "ย้อนกลับ",
|
||||
"all": "ทั้งหมด",
|
||||
"groupHint": {
|
||||
"success": "เลขที่ ERP อัปเดตกลับแล้ว ดูรายละเอียดได้",
|
||||
"failed": "ตรวจสอบสต็อกซ้ำหรือปิดใบโอนได้",
|
||||
"executing": "กำลังเขียนตารางงาน/เรียก ERP สร้างใบโอน",
|
||||
"resultUnknown": "อ่านอย่างเดียว ต้องตรวจสอบกับ ERP"
|
||||
},
|
||||
"dateFrom": "วันที่เริ่มต้น",
|
||||
"dateTo": "วันที่สิ้นสุด",
|
||||
"group": {
|
||||
"success": "สำเร็จ",
|
||||
"failed": "ล้มเหลว",
|
||||
"executing": "กำลังดำเนินการ",
|
||||
"resultUnknown": "ผลลัพธ์ไม่ทราบแน่ชัด"
|
||||
},
|
||||
"closeDialog": {
|
||||
"title": "ปิดใบโอนย้าย {docNo}",
|
||||
"reasonRequired": "เหตุผลในการปิด (จำเป็น)",
|
||||
"redlineWhole": "การปิดจะยกเลิกใบโอนย้ายทั้งใบ (รวมถึงแถวที่ยังไม่ได้บันทึก) และไม่สามารถย้อนกลับได้",
|
||||
"redlineResidue": "แถวที่บันทึกลง ERP แล้วจะไม่ถูกลบโดยอัตโนมัติ ต้องตรวจสอบแถวค้างด้วยตนเองตาม SOP",
|
||||
"redlineReopen": "รายละเอียดทั้งหมดในใบโอนย้ายจะแยกออกจากใบนี้และกลับไปที่คิวรอดำเนินการ เพื่อจัดใหม่ได้",
|
||||
"redlineErpCheck": "การปิดใบโอนย้ายไม่ได้แปลว่าไม่มีเอกสารใน ERP: ต้องยืนยันด้วยตนเองใน ERP ว่าไม่มีเอกสารที่เกี่ยวข้องก่อนปิด",
|
||||
"confirm": "ยืนยันการปิด"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,6 +561,14 @@
|
||||
"TRANSFER.BATCH_ITEMS_REQUIRED": "กรุณาระบุรายการที่ต้องการดำเนินการ",
|
||||
"TRANSFER.EXECUTE_ITEMS_INVALID": "บางรายการไม่มีอยู่หรือดำเนินการไม่ได้ กรุณารีเฟรชแล้วลองใหม่",
|
||||
"TRANSFER.ITEMS_STALE": "ผลการจับคู่ของบางรายการหมดอายุแล้ว กรุณาจับคู่ใหม่",
|
||||
"TRANSFER.FILE_CHANGED": "ไฟล์รับสินค้ามีการเปลี่ยนแปลง กรุณาจับคู่ใหม่ก่อนดำเนินการ"
|
||||
"TRANSFER.FILE_CHANGED": "ไฟล์รับสินค้ามีการเปลี่ยนแปลง กรุณาจับคู่ใหม่ก่อนดำเนินการ",
|
||||
"TRANSFER.ORG_REQUIRED": "กรุณาระบุรหัสองค์กรภายนอก",
|
||||
"TRANSFER.RETRIGGER_NOT_ALLOWED": "เฉพาะตั๋วที่ผลลัพธ์ไม่ทราบแน่ชัด (result_unknown) เท่านั้นที่ทริกเกอร์ซ้ำได้ ห้ามปิดแล้วสร้างใหม่",
|
||||
"TRANSFER.RETRY_NOT_ALLOWED": "แถวนี้ถูกลบออกไปพร้อมกับไฟล์และตรวจซ้ำไม่ได้ โปรดทำเครื่องหมายว่าไม่จำเป็นต้องดำเนินการต่อ หรือรอให้ไฟล์ซิงก์ใหม่",
|
||||
"TRANSFER.DOCUMENT_CLOSE_NOT_ALLOWED": "ปิดได้เฉพาะตั๋วที่ล้มเหลว (ถูกปฏิเสธทางธุรกิจ/ล้มเหลวทางเทคนิค) สำหรับตั๋วที่ผลลัพธ์ไม่ทราบแน่ชัดโปรดใช้ \"ทริกเกอร์ใหม่\" และตั๋วที่กำลังดำเนินการปิดไม่ได้",
|
||||
"TRANSFER.DOCUMENT_NOT_FOUND": "ไม่พบตั๋วโอนย้าย",
|
||||
"INTEGRATION.BINDING_LEGACY_PUT_REJECTED": "ฟิลด์ขั้นตอนเดียวแบบเดิมจะตัดทอนสูตรหลายขั้นตอนของการผูกนี้ โปรดส่งขั้นตอนตามลำดับด้วย steps_json แทน",
|
||||
"INTEGRATION.CALL_NOT_FOUND": "ไม่พบระเบียนการเรียกใช้งานการผสานรวม",
|
||||
"INTEGRATION.BINDING_STEPS_INVALID": "การกำหนดค่าขั้นตอนการเชื่อมโยงไม่ถูกต้อง: steps_json จำเป็นต้องมีและเป็นอาร์เรย์ที่ไม่ว่าง โดยแต่ละรายการต้องเป็นออบเจกต์"
|
||||
}
|
||||
}
|
||||
@@ -5194,7 +5194,8 @@
|
||||
"interface": "接口定义",
|
||||
"binding": "绑定",
|
||||
"credential": "凭据引用",
|
||||
"capability": "能力清单"
|
||||
"capability": "能力清单",
|
||||
"calls": "调用日志"
|
||||
},
|
||||
"statusLabels": {
|
||||
"draft": "草稿",
|
||||
@@ -5245,7 +5246,7 @@
|
||||
"environment": "环境",
|
||||
"status": "状态",
|
||||
"clientInstance": "客户端实例",
|
||||
"interfaceDef": "接口定义",
|
||||
"interfaceDef": "接口步骤(有序)",
|
||||
"secretRef": "Secret 引用",
|
||||
"secretProvider": "来源",
|
||||
"account": "账号",
|
||||
@@ -5260,6 +5261,7 @@
|
||||
"code": "编码",
|
||||
"name": "名称",
|
||||
"connectorType": "连接器类型",
|
||||
"dbKind": "数据库类型(db_kind)",
|
||||
"environment": "环境",
|
||||
"credentialRef": "凭据引用编码",
|
||||
"configJson": "连接配置 JSON(接口地址/超时/默认 org 等)",
|
||||
@@ -5281,9 +5283,6 @@
|
||||
"effectiveTo": "生效结束",
|
||||
"contextSelector": "高级路由条件 JSON",
|
||||
"contextSelectorHint": "键值对须全部包含于调用上下文才会命中;当前版本调用方不传路由上下文,留空即为默认绑定。",
|
||||
"paramMapping": "参数映射 JSON",
|
||||
"paramMappingHint": "域参数到接口参数的翻译规则(如 erp_org→organization、condition 模板);留空=同名直通。",
|
||||
"bindingClientHint": "随所选接口定义自动带出并锁定,不可单独修改。",
|
||||
"secretRef": "Secret 引用键",
|
||||
"secretProvider": "Secret 来源",
|
||||
"credentialType": "凭据类型",
|
||||
@@ -5311,7 +5310,8 @@
|
||||
"msg": {
|
||||
"fillClient": "请填写名称",
|
||||
"fillInterface": "请选择客户端实例(编码可自动生成)",
|
||||
"fillBinding": "请填写能力、客户端实例与接口定义",
|
||||
"fillBinding": "请填写能力,并至少添加一个步骤(每步选择接口定义)",
|
||||
"fillDbKind": "请选择数据库类型(MySQL / Oracle / SQL Server / PostgreSQL)",
|
||||
"fillCredential": "请填写编码与 Secret 引用",
|
||||
"fillCredentialDb": "请填写编码,以及必填凭据字段:{fields}",
|
||||
"credentialTypeMissing": "凭据类型清单未加载,请刷新页面后重试",
|
||||
@@ -5346,7 +5346,8 @@
|
||||
"endpoint": "https://erp-api.example.com/ws",
|
||||
"wsdl": "https://erp-api.example.com/wsdl",
|
||||
"requestPath": "路径支持占位符,如 /transfer/xxx",
|
||||
"passwordKeep": "留空则保持原密码不变"
|
||||
"passwordKeep": "留空则保持原密码不变",
|
||||
"database": "erp-host:1521/ORCL 或 127.0.0.1:3306/dbname"
|
||||
},
|
||||
"advancedConfig": "高级配置(JSON)",
|
||||
"formatJson": "格式化",
|
||||
@@ -5367,7 +5368,70 @@
|
||||
},
|
||||
"connectorTypes": {
|
||||
"rest": "REST API",
|
||||
"soap": "SOAP 服务"
|
||||
"soap": "SOAP 服务",
|
||||
"database": "数据库直连"
|
||||
},
|
||||
"connectorDbKind": {
|
||||
"mysql": "MySQL",
|
||||
"oracle": "Oracle",
|
||||
"sqlserver": "SQL Server",
|
||||
"postgresql": "PostgreSQL"
|
||||
},
|
||||
"endpointLabel": {
|
||||
"database": "数据库连接串(host:port/service 或 /database)"
|
||||
},
|
||||
"bindingSteps": {
|
||||
"label": "执行步骤(有序)",
|
||||
"add": "添加步骤",
|
||||
"remove": "删除步骤",
|
||||
"moveUp": "上移",
|
||||
"moveDown": "下移",
|
||||
"interface": "接口定义",
|
||||
"paramMapping": "步骤 {index} 参数映射 JSON",
|
||||
"clientHint": "客户端实例由该步接口归属自动确定:{client}",
|
||||
"hint": "步骤按数组顺序执行;每步可配置独立的参数映射,客户端实例由各步接口归属自带。"
|
||||
},
|
||||
"callLogs": {
|
||||
"title": "调用记录",
|
||||
"filterInterface": "接口编码",
|
||||
"filterClient": "客户端编码",
|
||||
"filterConnector": "连接类型",
|
||||
"filterStatus": "状态",
|
||||
"filterOperationId": "operation_id",
|
||||
"filterTraceId": "trace_id",
|
||||
"filterBusinessRef": "业务单号",
|
||||
"filterKeyword": "参数关键字(模糊搜请求内容)",
|
||||
"dateFrom": "执行时间起",
|
||||
"dateTo": "执行时间止",
|
||||
"query": "查询",
|
||||
"reset": "重置",
|
||||
"colTime": "时间",
|
||||
"colCapability": "能力",
|
||||
"colInterface": "接口",
|
||||
"colRef": "单号",
|
||||
"colStep": "步骤",
|
||||
"colStatus": "状态",
|
||||
"colElapsed": "耗时",
|
||||
"detailTitle": "调用详情",
|
||||
"timeline": "步骤时间线",
|
||||
"request": "请求",
|
||||
"response": "响应",
|
||||
"wire": "线级请求(wire)",
|
||||
"rawPayload": "原始报文",
|
||||
"normalized": "业务参数(归一化)",
|
||||
"normalizedJson": "归一化 JSON",
|
||||
"copyBody": "复制 body",
|
||||
"copyCurl": "复制 curl",
|
||||
"copySql": "复制 SQL",
|
||||
"copyRaw": "复制原始报文",
|
||||
"copyJson": "复制 JSON",
|
||||
"copyOperationId": "复制 operation_id",
|
||||
"copyTraceId": "复制 trace_id",
|
||||
"copied": "已复制",
|
||||
"noWire": "无线级详情(历史记录)",
|
||||
"sqlWriteWarning": "⚠ 写入语句:请确认目标环境后再执行",
|
||||
"prevPage": "上一页",
|
||||
"nextPage": "下一页"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3784,6 +3784,8 @@
|
||||
"blockedCount": "阻断",
|
||||
"estimatedQuantity": "预计调拨数量",
|
||||
"estimatedExternalWrites": "预计 ERP 单据",
|
||||
"pendingStockCheckCount": "待查库存",
|
||||
"invalidRowCount": "已失效 {count} 行",
|
||||
"reasonQuantityMismatch": "ERP 账面库存数量与收料数量不一致",
|
||||
"reasonInventoryNotFound": "ERP 无此批号的库存记录,库存按 0 展示",
|
||||
"reasonExternalQueryFailed": "外部系统查询失败",
|
||||
@@ -3815,8 +3817,10 @@
|
||||
"resultBlocked": "已阻断",
|
||||
"resultUnknown": "结果未知",
|
||||
"resultFileRemoved": "文件已移除",
|
||||
"resultPendingStockCheck": "待查库存",
|
||||
"staleRow": "数据已过期,请重查",
|
||||
"fileChangedRow": "文件已更新,请重新匹配",
|
||||
"fileChangedRow": "文件已更新,将自动对齐",
|
||||
"fileRemovedQuarantined": "另有 {count} 行已随收料文件移除而失效,已移出本清单;请到「待处理异常」处理,可标记无需继续处理。",
|
||||
"runProgress": "调拨执行进度",
|
||||
"runExecuting": "执行中",
|
||||
"runSuccess": "已完成",
|
||||
@@ -3844,7 +3848,6 @@
|
||||
"receiptDateInvalid": "起始日期不得晚于截止日期",
|
||||
"toastRequeryDone": "重查完成:{ok} 行已更新,{failed} 行失败",
|
||||
"toastRequeryRecovered": "恢复完成:{recovered} 笔已可执行 · {blocked} 笔仍阻断",
|
||||
"toastExecuteStale": "{count} 笔数据已过期,请重查后生成",
|
||||
"toastExecuteFileChanged": "{count} 笔文件已更新,请重新匹配",
|
||||
"toastCloseDone": "关闭完成:{ok} 行成功,{failed} 行失败",
|
||||
"batchCloseTitle": "标记无需继续处理({count} 项)",
|
||||
@@ -3910,6 +3913,84 @@
|
||||
"homeExecutableHint": "勾选后按行生成调拨单",
|
||||
"executableTitle": "可调拨明细",
|
||||
"executableEmpty": "暂无可调拨明细",
|
||||
"executableSelectedCount": "已选 {count} 笔可执行明细"
|
||||
"executableSelectedCount": "已选 {count} 笔可执行明细",
|
||||
"runTitle": "调拨单生成",
|
||||
"runBadge": {
|
||||
"queued": "排队中",
|
||||
"executing": "执行中",
|
||||
"success": "成功",
|
||||
"partialFailed": "部分失败",
|
||||
"failed": "失败"
|
||||
},
|
||||
"orderStatus": {
|
||||
"pending": "待处理",
|
||||
"executing": "执行中",
|
||||
"success": "成功",
|
||||
"resultUnknown": "结果未知",
|
||||
"failed": "失败",
|
||||
"cancelled": "已关闭"
|
||||
},
|
||||
"orderAction": {
|
||||
"retrigger": "重新触发",
|
||||
"retry": "重试",
|
||||
"retryAccepted": "调拨单 {docNo} 已重新提交执行,进度将自动刷新。",
|
||||
"retryPartial": "重查完成:{ready} 行可执行、{blocked} 行仍阻断已留恢复池。",
|
||||
"closeOrder": "关闭调拨单"
|
||||
},
|
||||
"orderReasonPrefix": "原因:{reason}",
|
||||
"poll": {
|
||||
"connecting": "连接中…"
|
||||
},
|
||||
"execute": {
|
||||
"accepted": "已提交,执行排队中,进度将在下方更新。",
|
||||
"noSelection": "请至少选择一个可执行明细行"
|
||||
},
|
||||
"retriggerDialog": {
|
||||
"title": "重新触发 {docNo}",
|
||||
"body": "将复用本单原单号与提交时间戳,只重新触发末步(幂等安全,不会重复建单)。",
|
||||
"confirm": "确认重新触发",
|
||||
"dismiss": "返回"
|
||||
},
|
||||
"orderClose": {
|
||||
"title": "关闭调拨单 {docNo}",
|
||||
"impactHint": "本票 {count} 行明细将随关闭脱离并回到待执行池(可重新勾选组建新票):",
|
||||
"redline": "关闭调拨单≠ERP 无单据:关闭前必须人工到 ERP 确认无对应单据。",
|
||||
"reasonPlaceholder": "关闭原因(必填)",
|
||||
"confirm": "确认关闭",
|
||||
"dismiss": "返回"
|
||||
},
|
||||
"toastOrderClosed": "调拨单已关闭,行已回到待执行池",
|
||||
"toastRetriggerAccepted": "已重新触发,正在排队执行末步",
|
||||
"homeExecuted": {
|
||||
"title": "已执行调拨单",
|
||||
"refresh": "刷新",
|
||||
"empty": "暂无已执行调拨单",
|
||||
"pageInfo": "共 {total} 张 · 第 {page} 页",
|
||||
"back": "返回",
|
||||
"all": "全部",
|
||||
"groupHint": {
|
||||
"success": "ERP 单号已回写,可查看明细",
|
||||
"failed": "可重查库存或人工关票",
|
||||
"executing": "正在写中间表/触发 ERP 建单",
|
||||
"resultUnknown": "只读,需线下核实 ERP"
|
||||
},
|
||||
"dateFrom": "开始日期",
|
||||
"dateTo": "结束日期",
|
||||
"group": {
|
||||
"success": "成功",
|
||||
"failed": "失败",
|
||||
"executing": "执行中",
|
||||
"resultUnknown": "结果未知"
|
||||
},
|
||||
"closeDialog": {
|
||||
"title": "关闭调拨单 {docNo}",
|
||||
"reasonRequired": "关闭原因(必填)",
|
||||
"redlineWhole": "关闭将作废整张调拨单(含未成行),操作不可撤销。",
|
||||
"redlineResidue": "ERP 可能已写入的行不会被自动删除,残留行需按 SOP 人工核对。",
|
||||
"redlineReopen": "单内全部明细将脱离本单回到待执行池,可重新勾选组建新票。",
|
||||
"redlineErpCheck": "关闭调拨单≠ERP 无单据:关闭前必须人工到 ERP 确认无对应单据。",
|
||||
"confirm": "确认关闭"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,6 +561,14 @@
|
||||
"TRANSFER.BATCH_ITEMS_REQUIRED": "请提供要操作的明细行。",
|
||||
"TRANSFER.EXECUTE_ITEMS_INVALID": "部分明细行不存在或不可执行,请刷新后重试。",
|
||||
"TRANSFER.ITEMS_STALE": "部分明细行匹配结果已过期,请重新匹配。",
|
||||
"TRANSFER.FILE_CHANGED": "收料文件已更新,请重新匹配后再执行。"
|
||||
"TRANSFER.FILE_CHANGED": "收料文件已更新,请重新匹配后再执行。",
|
||||
"TRANSFER.ORG_REQUIRED": "外部组织代码不能为空。",
|
||||
"TRANSFER.RETRIGGER_NOT_ALLOWED": "仅结果未知(result_unknown)票允许重新触发;禁止关闭后重建。",
|
||||
"TRANSFER.RETRY_NOT_ALLOWED": "该行已随文件移除,无法重查;请标记无需继续处理或等待文件重新同步。",
|
||||
"TRANSFER.DOCUMENT_CLOSE_NOT_ALLOWED": "仅失败票(业务拒绝/技术失败)允许关闭;结果未知票请使用「重新触发」,执行中的票不可关闭。",
|
||||
"TRANSFER.DOCUMENT_NOT_FOUND": "调拨票不存在。",
|
||||
"INTEGRATION.BINDING_LEGACY_PUT_REJECTED": "旧单步字段会截断该绑定的多步配方,请改用 steps_json 提交有序步骤。",
|
||||
"INTEGRATION.CALL_NOT_FOUND": "集成调用记录不存在。",
|
||||
"INTEGRATION.BINDING_STEPS_INVALID": "绑定步骤配置不合法:steps_json 必填且为非空数组,每项须为对象。"
|
||||
}
|
||||
}
|
||||
@@ -5040,7 +5040,8 @@
|
||||
"interface": "介面定義",
|
||||
"binding": "繫結",
|
||||
"credential": "憑證引用",
|
||||
"capability": "能力清單"
|
||||
"capability": "能力清單",
|
||||
"calls": "呼叫日誌"
|
||||
},
|
||||
"statusLabels": {
|
||||
"draft": "草稿",
|
||||
@@ -5091,7 +5092,7 @@
|
||||
"environment": "環境",
|
||||
"status": "狀態",
|
||||
"clientInstance": "客戶端實例",
|
||||
"interfaceDef": "介面定義",
|
||||
"interfaceDef": "介面步驟(有序)",
|
||||
"secretRef": "Secret 引用",
|
||||
"secretProvider": "來源",
|
||||
"account": "帳號",
|
||||
@@ -5106,6 +5107,7 @@
|
||||
"code": "編碼",
|
||||
"name": "名稱",
|
||||
"connectorType": "連接器類型",
|
||||
"dbKind": "資料庫類型(db_kind)",
|
||||
"environment": "環境",
|
||||
"credentialRef": "憑證引用編碼",
|
||||
"configJson": "連接配置 JSON(介面位址/逾時/預設 org 等)",
|
||||
@@ -5127,9 +5129,6 @@
|
||||
"effectiveTo": "生效結束",
|
||||
"contextSelector": "進階路由條件 JSON",
|
||||
"contextSelectorHint": "鍵值對須全部包含於呼叫上下文才會命中;當前版本呼叫方不傳路由上下文,留空即為預設綁定。",
|
||||
"paramMapping": "參數映射 JSON",
|
||||
"paramMappingHint": "域參數到介面參數的翻譯規則(如 erp_org→organization、condition 模板);留空=同名直通。",
|
||||
"bindingClientHint": "隨所選介面定義自動帶出並鎖定,不可單獨修改。",
|
||||
"secretRef": "Secret 引用鍵",
|
||||
"secretProvider": "Secret 來源",
|
||||
"credentialType": "憑證類型",
|
||||
@@ -5157,7 +5156,8 @@
|
||||
"msg": {
|
||||
"fillClient": "請填寫名稱",
|
||||
"fillInterface": "請選擇客戶端實例(編碼可自動產生)",
|
||||
"fillBinding": "請填寫能力、客戶端實例與介面定義",
|
||||
"fillBinding": "請填寫能力,並至少新增一個步驟(每步選擇介面定義)",
|
||||
"fillDbKind": "請選擇資料庫類型(MySQL / Oracle / SQL Server / PostgreSQL)",
|
||||
"fillCredential": "請填寫編碼與 Secret 引用",
|
||||
"fillCredentialDb": "請填寫編碼,以及必填憑據欄位:{fields}",
|
||||
"credentialTypeMissing": "憑據類型清單未載入,請重新整理頁面後重試",
|
||||
@@ -5192,7 +5192,8 @@
|
||||
"endpoint": "https://erp-api.example.com/ws",
|
||||
"wsdl": "https://erp-api.example.com/wsdl",
|
||||
"requestPath": "路徑支援佔位符,如 /transfer/xxx",
|
||||
"passwordKeep": "留空則保持原密碼不變"
|
||||
"passwordKeep": "留空則保持原密碼不變",
|
||||
"database": "erp-host:1521/ORCL 或 127.0.0.1:3306/dbname"
|
||||
},
|
||||
"advancedConfig": "進階配置(JSON)",
|
||||
"formatJson": "格式化",
|
||||
@@ -5213,7 +5214,70 @@
|
||||
},
|
||||
"connectorTypes": {
|
||||
"rest": "REST API",
|
||||
"soap": "SOAP 服務"
|
||||
"soap": "SOAP 服務",
|
||||
"database": "資料庫直連"
|
||||
},
|
||||
"connectorDbKind": {
|
||||
"mysql": "MySQL",
|
||||
"oracle": "Oracle",
|
||||
"sqlserver": "SQL Server",
|
||||
"postgresql": "PostgreSQL"
|
||||
},
|
||||
"endpointLabel": {
|
||||
"database": "資料庫連線字串(host:port/service 或 /database)"
|
||||
},
|
||||
"bindingSteps": {
|
||||
"label": "執行步驟(有序)",
|
||||
"add": "新增步驟",
|
||||
"remove": "刪除步驟",
|
||||
"moveUp": "上移",
|
||||
"moveDown": "下移",
|
||||
"interface": "介面定義",
|
||||
"paramMapping": "步驟 {index} 參數映射 JSON",
|
||||
"clientHint": "客戶端實例由該步介面歸屬自動確定:{client}",
|
||||
"hint": "步驟按陣列順序執行;每步可配置獨立的參數映射,客戶端實例由各步介面歸屬自帶。"
|
||||
},
|
||||
"callLogs": {
|
||||
"title": "呼叫記錄",
|
||||
"filterInterface": "介面編碼",
|
||||
"filterClient": "客戶端編碼",
|
||||
"filterConnector": "連線類型",
|
||||
"filterStatus": "狀態",
|
||||
"filterOperationId": "operation_id",
|
||||
"filterTraceId": "trace_id",
|
||||
"filterBusinessRef": "業務單號",
|
||||
"filterKeyword": "參數關鍵字(模糊搜尋請求內容)",
|
||||
"dateFrom": "執行時間起",
|
||||
"dateTo": "執行時間止",
|
||||
"query": "查詢",
|
||||
"reset": "重置",
|
||||
"colTime": "時間",
|
||||
"colCapability": "能力",
|
||||
"colInterface": "介面",
|
||||
"colRef": "單號",
|
||||
"colStep": "步驟",
|
||||
"colStatus": "狀態",
|
||||
"colElapsed": "耗時",
|
||||
"detailTitle": "呼叫詳情",
|
||||
"timeline": "步驟時間線",
|
||||
"request": "請求",
|
||||
"response": "回應",
|
||||
"wire": "線級請求(wire)",
|
||||
"rawPayload": "原始報文",
|
||||
"normalized": "業務參數(歸一化)",
|
||||
"normalizedJson": "歸一化 JSON",
|
||||
"copyBody": "複製 body",
|
||||
"copyCurl": "複製 curl",
|
||||
"copySql": "複製 SQL",
|
||||
"copyRaw": "複製原始報文",
|
||||
"copyJson": "複製 JSON",
|
||||
"copyOperationId": "複製 operation_id",
|
||||
"copyTraceId": "複製 trace_id",
|
||||
"copied": "已複製",
|
||||
"noWire": "無線級詳情(歷史記錄)",
|
||||
"sqlWriteWarning": "⚠ 寫入語句:請確認目標環境後再執行",
|
||||
"prevPage": "上一頁",
|
||||
"nextPage": "下一頁"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3711,6 +3711,8 @@
|
||||
"blockedCount": "阻斷",
|
||||
"estimatedQuantity": "預計調撥數量",
|
||||
"estimatedExternalWrites": "預計 ERP 單據",
|
||||
"pendingStockCheckCount": "待查庫存",
|
||||
"invalidRowCount": "已失效 {count} 行",
|
||||
"reasonQuantityMismatch": "ERP 帳面庫存數量與收料數量不一致",
|
||||
"reasonInventoryNotFound": "ERP 無此批號的庫存記錄,庫存按 0 顯示",
|
||||
"reasonExternalQueryFailed": "外部系統查詢失敗",
|
||||
@@ -3742,8 +3744,10 @@
|
||||
"resultBlocked": "已阻斷",
|
||||
"resultUnknown": "結果未知",
|
||||
"resultFileRemoved": "檔案已移除",
|
||||
"resultPendingStockCheck": "待查庫存",
|
||||
"staleRow": "資料已過期,請重查",
|
||||
"fileChangedRow": "檔案已更新,請重新匹配",
|
||||
"fileChangedRow": "檔案已更新,將自動對齊",
|
||||
"fileRemovedQuarantined": "另有 {count} 筆已隨收料檔案移除而失效,已移出本清單;請到「待處理異常」處理,可標記無需繼續處理。",
|
||||
"runProgress": "調撥執行進度",
|
||||
"runExecuting": "執行中",
|
||||
"runSuccess": "已完成",
|
||||
@@ -3771,7 +3775,6 @@
|
||||
"receiptDateInvalid": "起始日期不得晚於截止日期",
|
||||
"toastRequeryDone": "重查完成:{ok} 行已更新,{failed} 行失敗",
|
||||
"toastRequeryRecovered": "恢復完成:{recovered} 筆已可執行 · {blocked} 筆仍阻斷",
|
||||
"toastExecuteStale": "{count} 筆資料已過期,請重查後產生",
|
||||
"toastExecuteFileChanged": "{count} 筆檔案已更新,請重新匹配",
|
||||
"toastCloseDone": "關閉完成:{ok} 行成功,{failed} 行失敗",
|
||||
"batchCloseTitle": "標記無需繼續處理({count} 項)",
|
||||
@@ -3837,6 +3840,84 @@
|
||||
"homeExecutableHint": "勾選後按行產生調撥單",
|
||||
"executableTitle": "可調撥明細",
|
||||
"executableEmpty": "暫無可調撥明細",
|
||||
"executableSelectedCount": "已選 {count} 筆可執行明細"
|
||||
"executableSelectedCount": "已選 {count} 筆可執行明細",
|
||||
"runTitle": "調撥單生成",
|
||||
"runBadge": {
|
||||
"queued": "排隊中",
|
||||
"executing": "執行中",
|
||||
"success": "成功",
|
||||
"partialFailed": "部分失敗",
|
||||
"failed": "失敗"
|
||||
},
|
||||
"orderStatus": {
|
||||
"pending": "待處理",
|
||||
"executing": "執行中",
|
||||
"success": "成功",
|
||||
"resultUnknown": "結果未知",
|
||||
"failed": "失敗",
|
||||
"cancelled": "已關閉"
|
||||
},
|
||||
"orderAction": {
|
||||
"retrigger": "重新觸發",
|
||||
"retry": "重試",
|
||||
"retryAccepted": "調撥單 {docNo} 已重新提交執行,進度將自動刷新。",
|
||||
"retryPartial": "重查完成:{ready} 行可執行、{blocked} 行仍阻斷已留恢復池。",
|
||||
"closeOrder": "關閉調撥單"
|
||||
},
|
||||
"orderReasonPrefix": "原因:{reason}",
|
||||
"poll": {
|
||||
"connecting": "連線中…"
|
||||
},
|
||||
"execute": {
|
||||
"accepted": "已提交,執行排隊中,進度將於下方更新。",
|
||||
"noSelection": "請至少選擇一個可執行明細行"
|
||||
},
|
||||
"retriggerDialog": {
|
||||
"title": "重新觸發 {docNo}",
|
||||
"body": "將復用本單原單號與提交時間戳,只重新觸發末步(冪等安全,不會重複建單)。",
|
||||
"confirm": "確認重新觸發",
|
||||
"dismiss": "返回"
|
||||
},
|
||||
"orderClose": {
|
||||
"title": "關閉調撥單 {docNo}",
|
||||
"impactHint": "本票 {count} 行明細將隨關閉脫離並回到待執行池(可重新勾選組建新票):",
|
||||
"redline": "關閉調撥單≠ERP 無單據:關閉前必須人工到 ERP 確認無對應單據。",
|
||||
"reasonPlaceholder": "關閉原因(必填)",
|
||||
"confirm": "確認關閉",
|
||||
"dismiss": "返回"
|
||||
},
|
||||
"toastOrderClosed": "調撥單已關閉,行已回到待執行池",
|
||||
"toastRetriggerAccepted": "已重新觸發,正在排隊執行末步",
|
||||
"homeExecuted": {
|
||||
"title": "已執行調撥單",
|
||||
"refresh": "重新整理",
|
||||
"empty": "暫無已執行調撥單",
|
||||
"pageInfo": "共 {total} 張 · 第 {page} 頁",
|
||||
"back": "返回",
|
||||
"all": "全部",
|
||||
"groupHint": {
|
||||
"success": "ERP 單號已回寫,可查看明細",
|
||||
"failed": "可重查庫存或人工關票",
|
||||
"executing": "正在寫中間表/觸發 ERP 建單",
|
||||
"resultUnknown": "唯讀,需線下核實 ERP"
|
||||
},
|
||||
"dateFrom": "開始日期",
|
||||
"dateTo": "結束日期",
|
||||
"group": {
|
||||
"success": "成功",
|
||||
"failed": "失敗",
|
||||
"executing": "執行中",
|
||||
"resultUnknown": "結果未知"
|
||||
},
|
||||
"closeDialog": {
|
||||
"title": "關閉調撥單 {docNo}",
|
||||
"reasonRequired": "關閉原因(必填)",
|
||||
"redlineWhole": "關閉將作廢整張調撥單(含未成行),操作不可撤銷。",
|
||||
"redlineResidue": "ERP 可能已寫入的行不會被自動刪除,殘留行需按 SOP 人工核對。",
|
||||
"redlineReopen": "單內全部明細將脫離本單回到待執行池,可重新勾選組建新票。",
|
||||
"redlineErpCheck": "關閉調撥單≠ERP 無單據:關閉前必須人工到 ERP 確認無對應單據。",
|
||||
"confirm": "確認關閉"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -561,6 +561,14 @@
|
||||
"TRANSFER.BATCH_ITEMS_REQUIRED": "請提供要操作的明細行。",
|
||||
"TRANSFER.EXECUTE_ITEMS_INVALID": "部分明細行不存在或不可執行,請重新整理後再試。",
|
||||
"TRANSFER.ITEMS_STALE": "部分明細行匹配結果已過期,請重新匹配。",
|
||||
"TRANSFER.FILE_CHANGED": "收料檔案已更新,請重新匹配後再執行。"
|
||||
"TRANSFER.FILE_CHANGED": "收料檔案已更新,請重新匹配後再執行。",
|
||||
"TRANSFER.ORG_REQUIRED": "外部組織代碼不能為空。",
|
||||
"TRANSFER.RETRIGGER_NOT_ALLOWED": "僅結果未知(result_unknown)票允許重新觸發;禁止關閉後重建。",
|
||||
"TRANSFER.RETRY_NOT_ALLOWED": "該行已隨檔案移除,無法重查;請標記無需繼續處理或等待檔案重新同步。",
|
||||
"TRANSFER.DOCUMENT_CLOSE_NOT_ALLOWED": "僅失敗票(業務拒絕/技術失敗)允許關閉;結果未知票請使用「重新觸發」,執行中的票不可關閉。",
|
||||
"TRANSFER.DOCUMENT_NOT_FOUND": "調撥票不存在。",
|
||||
"INTEGRATION.BINDING_LEGACY_PUT_REJECTED": "舊單步欄位會截斷該繫結的多步配方,請改用 steps_json 提交有序步驟。",
|
||||
"INTEGRATION.CALL_NOT_FOUND": "整合調用記錄不存在。",
|
||||
"INTEGRATION.BINDING_STEPS_INVALID": "綁定步驟配置不合法:steps_json 必填且為非空陣列,每項須為物件。"
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user