feat(shipping-notice): 收敛复核状态隔离、STP 重试幂等与 XFA 合成预览标注
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
84a881b554
commit
74270adc22
149 files changed
+20111
-3871
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/api/shipping-order-document-profile.api.ts
|
||||
* 用途:订单文档 Profile 管理、MinerU 样本选择、XFA 统一建议/视觉绑定与发布 API。
|
||||
* 用途:订单文档 Profile 管理、MinerU 样本选择、XFA 统一建议/视觉绑定/合成预览与发布 API。
|
||||
* 依赖:shared/api/client、auth headers、Profile DTO。
|
||||
* 逻辑:页面只使用结构化接口;结构指纹和 HTML 始终由后端持有;XFA suggest/preview 零写 Draft。
|
||||
*/
|
||||
@@ -291,6 +291,78 @@ export const previewOrderProfileSampleXfaValue = (
|
||||
{ method: 'POST', body: JSON.stringify({ path_id: pathId, reveal: Boolean(options?.reveal) }), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 生成或复用绑定冻结 Analysis 的 XFA 合成预览(身份 + 页元数据,不含大图)。 */
|
||||
export const requestOrderProfileSampleXfaSyntheticPreview = (
|
||||
documentId: number,
|
||||
options?: { force?: boolean },
|
||||
) => requestJson<import('../types/shipping-order-document-profile.types').XfaSyntheticPreviewResponse>(
|
||||
`/api/admin/shipping-notice/order-document-profile-samples/${documentId}/xfa/preview`,
|
||||
{ method: 'POST', body: JSON.stringify({ force: Boolean(options?.force) }), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 列出最新 ready 合成预览页并重新签发短时 token。 */
|
||||
export const listOrderProfileSampleXfaSyntheticPreviewPages = (documentId: number) =>
|
||||
requestJson<import('../types/shipping-order-document-profile.types').XfaSyntheticPreviewResponse>(
|
||||
`/api/admin/shipping-notice/order-document-profile-samples/${documentId}/xfa/preview/pages`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/**
|
||||
* 合成预览单页 PNG 的受控路径(配合 preview_token 用 fetch 拉取 blob)。
|
||||
* @param documentId 样本文档 ID
|
||||
* @param pageNo 1-based 页码
|
||||
*/
|
||||
export const orderProfileSampleXfaSyntheticPreviewPagePath = (documentId: number, pageNo: number) =>
|
||||
`/api/admin/shipping-notice/order-document-profile-samples/${documentId}/xfa/preview/pages/${pageNo}`;
|
||||
|
||||
/** 入队 XFA OCR 自动标记 Job(须合成预览 ready)。 */
|
||||
export const enqueueOrderProfileXfaOcrAutomark = (
|
||||
profileId: number,
|
||||
payload: { document_id: number; force?: boolean },
|
||||
) => requestJson<{ job_id: number; status: string; preview_render_checksum?: string }>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/xfa/automark`,
|
||||
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 轮询 OCR 自动标记 Job 状态与建议。 */
|
||||
export const getOrderProfileXfaOcrAutomarkJob = (profileId: number, jobId: number) =>
|
||||
requestJson<{
|
||||
job_id: number;
|
||||
status: string;
|
||||
suggestions?: Array<Record<string, unknown>>;
|
||||
error_code?: string | null;
|
||||
preview_render_checksum?: string | null;
|
||||
}>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/xfa/automark/jobs/${jobId}`,
|
||||
auth(),
|
||||
);
|
||||
|
||||
/** 接受自动标记建议(high→confirmed;medium/low→suggested)。 */
|
||||
export const acceptOrderProfileXfaOcrAutomarkSuggestion = (
|
||||
profileId: number,
|
||||
suggestionId: string,
|
||||
payload: {
|
||||
job_id?: number;
|
||||
preview_render_checksum: string;
|
||||
render_mode?: string;
|
||||
browser_session_id?: string;
|
||||
lease_token?: string;
|
||||
},
|
||||
) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/xfa/automark/suggestions/${encodeURIComponent(suggestionId)}/accept`,
|
||||
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 拒绝自动标记建议。 */
|
||||
export const rejectOrderProfileXfaOcrAutomarkSuggestion = (
|
||||
profileId: number,
|
||||
suggestionId: string,
|
||||
payload?: { job_id?: number; browser_session_id?: string; lease_token?: string },
|
||||
) => requestJson<Record<string, unknown>>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/xfa/automark/suggestions/${encodeURIComponent(suggestionId)}/reject`,
|
||||
{ method: 'POST', body: JSON.stringify(payload || {}), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 预览拆分规则并签发确认令牌;默认脱敏,reveal 需敏感读权限。 */
|
||||
export const previewOrderProfileSampleXfaSplitRules = (
|
||||
documentId: number,
|
||||
@@ -347,7 +419,7 @@ export const suggestOrderProfileXfaVisualBindings = (
|
||||
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },
|
||||
);
|
||||
|
||||
/** 确认视觉绑定;须携带 Lease / operation_id。 */
|
||||
/** 确认视觉绑定;须携带 Lease / operation_id / 合成预览证据。 */
|
||||
export const confirmOrderProfileXfaVisualBinding = (
|
||||
profileId: number,
|
||||
bindingId: string,
|
||||
@@ -357,6 +429,8 @@ export const confirmOrderProfileXfaVisualBinding = (
|
||||
browser_session_id: string;
|
||||
lease_token: string;
|
||||
operation_id: string;
|
||||
preview_render_checksum?: string | null;
|
||||
render_mode?: string | null;
|
||||
},
|
||||
) => requestJson<import('../types/shipping-order-document-profile.types').XfaVisualBindingMutationResponse>(
|
||||
`/api/admin/shipping-notice/order-document-profiles/${profileId}/xfa/visual-bindings/${encodeURIComponent(bindingId)}/confirm`,
|
||||
|
||||
+4
-1
@@ -36,6 +36,7 @@ const documentId = ref(0);
|
||||
const tableId = ref('');
|
||||
const authoritativePathId = ref('');
|
||||
const mirrorPathIds = ref<string[]>([]);
|
||||
const xfaContextReady = ref(false);
|
||||
const browserSessionId = crypto.randomUUID();
|
||||
let sampleRefreshTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
|
||||
@@ -50,7 +51,7 @@ const stepThreeLabel = computed(() => (
|
||||
const canNext = computed(() => {
|
||||
if (step.value === 1) return Boolean(identity.displayName.trim() && identity.schemaId);
|
||||
if (step.value === 2) return Boolean(documentId.value);
|
||||
if (isXfaSample.value) return Boolean(authoritativePathId.value);
|
||||
if (isXfaSample.value) return Boolean(xfaContextReady.value && authoritativePathId.value);
|
||||
return Boolean(tableId.value);
|
||||
});
|
||||
const steps = computed(() => [
|
||||
@@ -111,6 +112,7 @@ watch(documentId, async (id) => {
|
||||
tableId.value = '';
|
||||
authoritativePathId.value = '';
|
||||
mirrorPathIds.value = [];
|
||||
xfaContextReady.value = false;
|
||||
tables.value = [];
|
||||
if (!id) return;
|
||||
await loadTables(id);
|
||||
@@ -222,6 +224,7 @@ onBeforeUnmount(stopSampleRefresh);
|
||||
:mirror-path-ids="mirrorPathIds"
|
||||
@update:authoritative-path-id="authoritativePathId = $event"
|
||||
@update:mirror-path-ids="mirrorPathIds = $event"
|
||||
@update:context-ready="xfaContextReady = $event"
|
||||
/>
|
||||
<OrderProfileModelStartStep v-else v-model="tableId" :tables="tables" />
|
||||
</main>
|
||||
|
||||
+1024
-235
File diff suppressed because it is too large.
Load diff
+255
-118
@@ -1,12 +1,15 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-order-document-profiles/OrderProfileXfaWorkbench.spec.ts
|
||||
* 用途:挂载统一编辑器 desk 内 XFA 片段并验证布局与诊断抽屉(无独立 Header)。
|
||||
* 依赖:Vitest、@vue/test-utils、OrderProfileXfaWorkbench。
|
||||
* 用途:冒烟验证弃用薄包装与 useOrderProfileXfaDesk 默认 synthetic / dirty 契约。
|
||||
* 依赖:Vitest、@vue/test-utils、OrderProfileXfaWorkbench、useOrderProfileXfaDesk。
|
||||
* 逻辑:不再断言三栏 datasets 左栏;断言 desk 可加载且默认原生 PDF 画布。
|
||||
*/
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { defineComponent, h, nextTick } from 'vue';
|
||||
import OrderProfileXfaWorkbench from './OrderProfileXfaWorkbench.vue';
|
||||
import { useOrderProfileXfaDesk } from './composables/useOrderProfileXfaDesk';
|
||||
|
||||
const { saveDraftMock, splitPreviewMock, detailDefinition } = vi.hoisted(() => ({
|
||||
saveDraftMock: vi.fn(),
|
||||
@@ -39,6 +42,7 @@ const baseDefinition = {
|
||||
total_amount_policy: 'must_equal_line_sum' as const,
|
||||
},
|
||||
split_rules: [],
|
||||
bindings: [],
|
||||
};
|
||||
|
||||
vi.mock('vue-router', () => ({
|
||||
@@ -47,7 +51,7 @@ vi.mock('vue-router', () => ({
|
||||
}));
|
||||
|
||||
vi.mock('@/shared/composables/useMessage', () => ({
|
||||
useMessage: () => ({ success: vi.fn(), error: vi.fn() }),
|
||||
useMessage: () => ({ success: vi.fn(), error: vi.fn(), info: vi.fn() }),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/admin/api/shipping-order-document-profile.api', () => ({
|
||||
@@ -88,6 +92,40 @@ vi.mock('@/features/admin/api/shipping-order-document-profile.api', () => ({
|
||||
pages: [{ page_no: 1, preview_token: 'token' }],
|
||||
expires_in_seconds: 60,
|
||||
})),
|
||||
requestOrderProfileSampleXfaSyntheticPreview: vi.fn(async () => ({
|
||||
document_id: 85,
|
||||
identity: {
|
||||
document_id: 85,
|
||||
layout_version_id: 1,
|
||||
structure_analysis_id: 1,
|
||||
source_content_hash: 'a'.repeat(64),
|
||||
template_packet_checksum: 't',
|
||||
datasets_packet_checksum: 'd',
|
||||
dataset_structure_fingerprint: 'f',
|
||||
preview_render_checksum: 'r'.repeat(64),
|
||||
render_mode: 'xfa_dataset_preview',
|
||||
renderer_version: 'hxops.xfa_static_preview.v1',
|
||||
page_count: 1,
|
||||
},
|
||||
status: 'ready',
|
||||
render_mode: 'xfa_dataset_preview',
|
||||
renderer_version: 'hxops.xfa_static_preview.v1',
|
||||
preview_render_checksum: 'r'.repeat(64),
|
||||
page_count: 1,
|
||||
pages: [{ page_no: 1, preview_token: 'synth-token' }],
|
||||
expires_in_seconds: 60,
|
||||
cache_hit: false,
|
||||
})),
|
||||
listOrderProfileSampleXfaSyntheticPreviewPages: vi.fn(),
|
||||
enqueueOrderProfileXfaOcrAutomark: vi.fn(async () => ({ job_id: 9, status: 'queued' })),
|
||||
getOrderProfileXfaOcrAutomarkJob: vi.fn(async () => ({
|
||||
job_id: 9,
|
||||
status: 'succeeded',
|
||||
suggestions: [],
|
||||
preview_render_checksum: 'r'.repeat(64),
|
||||
})),
|
||||
acceptOrderProfileXfaOcrAutomarkSuggestion: vi.fn(),
|
||||
rejectOrderProfileXfaOcrAutomarkSuggestion: vi.fn(),
|
||||
suggestOrderProfileXfaUnifiedMapping: vi.fn(),
|
||||
acquireOrderDocumentProfileEditLease: vi.fn(async () => ({ lease_token: 'lease', expires_at: new Date().toISOString() })),
|
||||
renewOrderDocumentProfileEditLease: vi.fn(),
|
||||
@@ -95,6 +133,8 @@ vi.mock('@/features/admin/api/shipping-order-document-profile.api', () => ({
|
||||
saveOrderDocumentProfileDraft: (...args: unknown[]) => saveDraftMock(...args),
|
||||
previewOrderProfileSampleXfaSplitRules: (...args: unknown[]) => splitPreviewMock(...args),
|
||||
previewOrderProfileSampleXfaValue: vi.fn(),
|
||||
confirmOrderProfileXfaVisualBinding: vi.fn(),
|
||||
rejectOrderProfileXfaVisualBinding: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/admin/api/shipping-order-schema.api', () => ({
|
||||
@@ -107,110 +147,32 @@ vi.mock('@/features/admin/api/shipping-order-schema.api', () => ({
|
||||
enabled: true, aliases: [], normalizer_key: 'trim', validator_keys: [], enum_options: [],
|
||||
evidence_policy: { required: false, source_precedence: [], conflict_policy: 'fail', allow_single_source: true },
|
||||
comparator_key: 'exact',
|
||||
}, {
|
||||
field_id: 'f-bill', field_code: 'bill_to_customer', scope: 'header', display_name: '账款客户', required: false,
|
||||
enabled: true, aliases: [], normalizer_key: 'trim', validator_keys: [], enum_options: [],
|
||||
evidence_policy: { required: false, source_precedence: [], conflict_policy: 'fail', allow_single_source: true },
|
||||
comparator_key: 'exact',
|
||||
}, {
|
||||
field_id: 'f-line', field_code: 'part_number', scope: 'line', display_name: '料号', required: false,
|
||||
enabled: true, aliases: [], normalizer_key: 'trim', validator_keys: [], enum_options: [],
|
||||
evidence_policy: { required: false, source_precedence: [], conflict_policy: 'fail', allow_single_source: true },
|
||||
comparator_key: 'exact',
|
||||
}],
|
||||
},
|
||||
}],
|
||||
})),
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
fallbackLocale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
common: { yes: '是', no: '否', close: '关闭' },
|
||||
admin: {
|
||||
shippingOrderProfiles: {
|
||||
templateModes: { xfa_dataset: 'XFA' },
|
||||
workbench: {
|
||||
headerReturnToLibrary: '返回',
|
||||
headerSaveDraft: '保存',
|
||||
headerValidate: '验证',
|
||||
headerRecoverLease: '恢复',
|
||||
headerTakeOverLease: '接管',
|
||||
saveStatus: { saved: '已保存', saving: '保存中', failed: '失败', readonly: '只读' },
|
||||
leaveConfirm: '离开?',
|
||||
annotationCanvasAriaLabel: '画布',
|
||||
loadingPage: '加载',
|
||||
selectBoundPdf: '选择 PDF',
|
||||
zoomIn: '+', zoomOut: '-', fitPage: '适合',
|
||||
pageNavigation: '页',
|
||||
},
|
||||
xfaUnified: {
|
||||
drawFieldBox: '画框',
|
||||
suggesting: '分析中',
|
||||
openDiagnostics: '高级诊断',
|
||||
diagnosticsDrawerTitle: '诊断',
|
||||
diagnosticsSummary: '{mapped}/{total}',
|
||||
candidatePanelTitle: '候选',
|
||||
acceptCandidate: '采用',
|
||||
confirmVisual: '确认',
|
||||
rejectVisual: '驳回',
|
||||
visualStatus: { suggested: '建议', confirmed: '已确认', rejected: '已驳回', needs_review: '待复核' },
|
||||
},
|
||||
xfaWorkbench: {
|
||||
loading: '加载', loadFailed: '失败', saved: '已保存', saveFailed: '失败', scopeMismatch: 'scope',
|
||||
treeTitle: '树', searchPaths: '搜', collectionBadge: '集合', treeEmpty: '空',
|
||||
schemaTitle: 'Schema', selectLeafFirst: '选叶子', unbind: '解除',
|
||||
filter: { all: '全部', unmapped: '未映射', required: '必填' },
|
||||
scope: { header: '表头', line: '明细' },
|
||||
previewTitle: '预览', blockersTitle: '阻断', currentNode: '节点', noneSelected: '无',
|
||||
headerMaps: '表头映射', lineMaps: '明细映射', requiredCoverage: '{mapped}/{total}',
|
||||
maskedSample: '脱敏', noMappings: '无映射', crossChecksTitle: '交叉校验',
|
||||
crossCheck: { acroform: 'AcroForm', mirror: '镜像', lineAmount: '金额', totalAmount: '总额' },
|
||||
previewHint: '验证页', retryLoad: '重试',
|
||||
blocker: {
|
||||
authoritative_collection_required: '权威必选',
|
||||
duplicate_field_binding: '重复',
|
||||
required_fields_unmapped: '必填未映射',
|
||||
},
|
||||
collectionsTitle: '集合', authoritativeCollection: '权威', selectAuthoritative: '选择',
|
||||
mirrorCollections: '镜像', rowCount: '{count} 行',
|
||||
},
|
||||
xfaUnified: {
|
||||
drawFieldBox: '画字段框', suggesting: '匹配中', suggestFailed: '建议失败',
|
||||
candidatePanelTitle: '候选', acceptCandidate: '采用',
|
||||
confirmVisual: '确认', rejectVisual: '驳回',
|
||||
confirmSuccess: '确认成功', confirmFailed: '确认失败',
|
||||
rejectSuccess: '驳回成功', rejectFailed: '驳回失败',
|
||||
diagnosticsSummary: '{mapped}/{total}', openDiagnostics: '高级诊断',
|
||||
diagnosticsDrawerTitle: '诊断',
|
||||
visualStatus: { suggested: '建议', confirmed: '已确认', rejected: '已驳回', needs_review: '待复核' },
|
||||
},
|
||||
xfaSplit: {
|
||||
title: '拆分', addRule: '新增', deleteConfirm: '删除?', deleteRule: '删', ruleLabel: '规则 {index}', unnamedRule: '未命名',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
describe('OrderProfileXfaWorkbench (deprecated thin wrapper)', () => {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh',
|
||||
messages: { zh: { common: { close: '关闭' }, admin: { shippingOrderProfiles: { xfaWorkbench: { loading: '加载中' } } } } },
|
||||
});
|
||||
|
||||
describe('OrderProfileXfaWorkbench', () => {
|
||||
beforeEach(() => {
|
||||
detailDefinition.value = structuredClone(baseDefinition);
|
||||
saveDraftMock.mockReset();
|
||||
splitPreviewMock.mockReset();
|
||||
detailDefinition.value = null;
|
||||
vi.stubGlobal('fetch', vi.fn(async () => ({
|
||||
ok: true,
|
||||
blob: async () => new Blob([new Uint8Array([137, 80, 78, 71])], { type: 'image/png' }),
|
||||
})));
|
||||
vi.stubGlobal('URL', {
|
||||
...URL,
|
||||
createObjectURL: vi.fn(() => 'blob:mock-page'),
|
||||
revokeObjectURL: vi.fn(),
|
||||
});
|
||||
// Canvas-related absolute URL safety: relative /api fetch must not throw in jsdom.
|
||||
vi.stubGlobal('fetch', vi.fn(async (input: RequestInfo | URL) => {
|
||||
const url = String(input);
|
||||
expect(url.startsWith('/') || url.startsWith('http')).toBe(true);
|
||||
return {
|
||||
ok: true,
|
||||
blob: async () => new Blob(['png'], { type: 'image/png' }),
|
||||
};
|
||||
}));
|
||||
});
|
||||
|
||||
const mountPage = async () => {
|
||||
@@ -218,40 +180,215 @@ describe('OrderProfileXfaWorkbench', () => {
|
||||
props: defaultProps,
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
for (let i = 0; i < 20; i += 1) {
|
||||
for (let i = 0; i < 30; i += 1) {
|
||||
await flushPromises();
|
||||
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||
if (wrapper.find('.xfa-workbench__desk').exists()) break;
|
||||
await nextTick();
|
||||
if (wrapper.find('[data-testid="xfa-thin-canvas"]').exists()) break;
|
||||
}
|
||||
return wrapper;
|
||||
};
|
||||
|
||||
it('mounts canvas-first desk after bootstrap without standalone header', async () => {
|
||||
it('mounts thin deprecated desk without three-column left datasets tree', async () => {
|
||||
const wrapper = await mountPage();
|
||||
expect(wrapper.find('[data-testid="xfa-workbench-deprecated"]').exists()).toBe(true);
|
||||
expect(wrapper.find('.xfa-workbench__desk').exists()).toBe(true);
|
||||
expect(wrapper.find('.xfa-workbench__header').exists()).toBe(false);
|
||||
expect(wrapper.find('.xfa-workbench__canvas').exists()).toBe(true);
|
||||
expect(wrapper.find('.canvas-shell').exists()).toBe(true);
|
||||
expect(wrapper.find('.xfa-tree').exists()).toBe(false);
|
||||
|
||||
await wrapper.find('.xfa-workbench__diagnostics-trigger button').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('.diagnostics-drawer').exists()).toBe(true);
|
||||
expect(wrapper.find('.diagnostics-drawer .xfa-tree').exists()).toBe(true);
|
||||
expect(wrapper.find('.diagnostics-drawer .add-rule').exists()).toBe(false);
|
||||
expect(wrapper.find('.xfa-workbench__left').exists()).toBe(false);
|
||||
expect(wrapper.find('.xfa-workbench__panel').exists()).toBe(false);
|
||||
}, 15000);
|
||||
|
||||
it('opens readonly diagnostics drawer from panel footer', async () => {
|
||||
it('defaults to native preview mode after load', async () => {
|
||||
const wrapper = await mountPage();
|
||||
expect(wrapper.find('.xfa-workbench__panel').exists()).toBe(true);
|
||||
await wrapper.find('.xfa-workbench__diagnostics-trigger button').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('.diagnostics-drawer').exists()).toBe(true);
|
||||
expect(wrapper.find('.diagnostics-drawer .add-rule').exists()).toBe(false);
|
||||
});
|
||||
const vm = wrapper.vm as unknown as { getDesk: () => { previewMode: string; syntheticPreviewStatus: string } };
|
||||
const desk = vm.getDesk();
|
||||
expect(desk.previewMode).toBe('native');
|
||||
expect(['ready', 'loading', 'unavailable', 'failed', 'stale', 'idle']).toContain(desk.syntheticPreviewStatus);
|
||||
}, 15000);
|
||||
|
||||
it('emits dirty-change when local definition diverges from saved snapshot', async () => {
|
||||
const wrapper = await mountPage();
|
||||
expect(wrapper.emitted('dirty-change')?.[0]).toEqual([false]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('useOrderProfileXfaDesk', () => {
|
||||
beforeEach(() => {
|
||||
detailDefinition.value = structuredClone(baseDefinition);
|
||||
vi.stubGlobal('fetch', vi.fn(async () => ({
|
||||
ok: true,
|
||||
blob: async () => new Blob(['png'], { type: 'image/png' }),
|
||||
})));
|
||||
});
|
||||
|
||||
it('demotes confirmed visual bindings when collections are reconfirmed', async () => {
|
||||
detailDefinition.value = {
|
||||
...structuredClone(baseDefinition),
|
||||
bindings: [{
|
||||
binding_id: 'b1',
|
||||
field_id: 'f1',
|
||||
field_code: 'customer_po_no',
|
||||
scope: 'header',
|
||||
value_binding: { type: 'xfa_dataset', path_id: 'invoiced-to-path', data_path: null },
|
||||
visual_binding: {
|
||||
page_no: 1,
|
||||
normalized_bbox: { x0: 0.1, y0: 0.1, x1: 0.2, y1: 0.2 },
|
||||
source: 'user_drawn',
|
||||
status: 'confirmed',
|
||||
region_kind: 'field',
|
||||
confirmed_on: 'xfa_dataset_preview',
|
||||
preview_render_checksum: 'r'.repeat(64),
|
||||
},
|
||||
}],
|
||||
};
|
||||
|
||||
let desk!: ReturnType<typeof useOrderProfileXfaDesk>;
|
||||
const Host = defineComponent({
|
||||
setup() {
|
||||
desk = useOrderProfileXfaDesk({
|
||||
profileId: 52,
|
||||
leaseToken: 'lease',
|
||||
saveState: 'saved',
|
||||
editorSessionId: 'sess',
|
||||
enabled: true,
|
||||
});
|
||||
return () => h('div');
|
||||
},
|
||||
});
|
||||
mount(Host, {
|
||||
global: {
|
||||
plugins: [createI18n({ legacy: false, locale: 'zh', messages: { zh: { admin: { shippingOrderProfiles: {
|
||||
xfaWorkbench: { blocker: { authoritative_collection_required: 'need auth' }, loadFailed: 'fail' },
|
||||
xfaDesk: { collectionsReconfirmedHint: 'ok' },
|
||||
xfaAutoMark: { enqueueFailed: 'e', jobFailed: 'j' },
|
||||
} } } } })],
|
||||
},
|
||||
});
|
||||
|
||||
for (let i = 0; i < 40; i += 1) {
|
||||
await flushPromises();
|
||||
if (!desk.loading.value && desk.definition.value) break;
|
||||
}
|
||||
expect(desk.definition.value).toBeTruthy();
|
||||
expect(desk.loadError.value).toBe(false);
|
||||
|
||||
desk.draftAuthoritativePathId.value = 'items-data';
|
||||
desk.draftMirrorPathIds.value = [];
|
||||
desk.confirmReconfirmCollections();
|
||||
expect(desk.authoritativePathId.value).toBe('items-data');
|
||||
expect(desk.definition.value?.bindings?.[0]?.visual_binding.status).toBe('suggested');
|
||||
}, 15000);
|
||||
|
||||
it('duplicateSelectedBinding clears path/schema and keeps geometry', async () => {
|
||||
detailDefinition.value = {
|
||||
...structuredClone(baseDefinition),
|
||||
bindings: [{
|
||||
binding_id: 'b1',
|
||||
field_id: 'f1',
|
||||
field_code: 'customer_po_no',
|
||||
scope: 'header',
|
||||
value_binding: { type: 'xfa_dataset', path_id: 'invoiced-to-path', data_path: null },
|
||||
visual_binding: {
|
||||
page_no: 1,
|
||||
normalized_bbox: { x0: 0.1, y0: 0.1, x1: 0.2, y1: 0.2 },
|
||||
source: 'user_drawn',
|
||||
status: 'confirmed',
|
||||
region_kind: 'header',
|
||||
confirmed_on: 'xfa_dataset_preview',
|
||||
},
|
||||
}],
|
||||
};
|
||||
|
||||
let desk!: ReturnType<typeof useOrderProfileXfaDesk>;
|
||||
const Host = defineComponent({
|
||||
setup() {
|
||||
desk = useOrderProfileXfaDesk({
|
||||
profileId: 52,
|
||||
leaseToken: 'lease',
|
||||
saveState: 'saved',
|
||||
editorSessionId: 'sess',
|
||||
enabled: true,
|
||||
});
|
||||
return () => h('div');
|
||||
},
|
||||
});
|
||||
mount(Host, {
|
||||
global: {
|
||||
plugins: [createI18n({ legacy: false, locale: 'zh', messages: { zh: { admin: { shippingOrderProfiles: {
|
||||
xfaWorkbench: { loadFailed: 'fail' },
|
||||
xfaAutoMark: { enqueueFailed: 'e', jobFailed: 'j' },
|
||||
} } } } })],
|
||||
},
|
||||
});
|
||||
for (let i = 0; i < 40; i += 1) {
|
||||
await flushPromises();
|
||||
if (!desk.loading.value && desk.definition.value) break;
|
||||
}
|
||||
desk.selectedBindingId.value = 'b1';
|
||||
desk.duplicateSelectedBinding();
|
||||
const copy = desk.definition.value?.bindings?.find((item) => item.binding_id !== 'b1');
|
||||
expect(copy).toBeTruthy();
|
||||
expect(copy?.field_code).toBe('');
|
||||
expect(copy?.value_binding.path_id).toBe('');
|
||||
expect(copy?.visual_binding.status).toBe('suggested');
|
||||
expect((copy?.visual_binding as { region_kind?: string }).region_kind).toBe('header');
|
||||
expect(copy?.visual_binding.normalized_bbox).toEqual({ x0: 0.1, y0: 0.1, x1: 0.2, y1: 0.2 });
|
||||
}, 15000);
|
||||
|
||||
it('annotationDisabled when native pages missing; datasets hidden for anchor', async () => {
|
||||
detailDefinition.value = structuredClone(baseDefinition);
|
||||
let desk!: ReturnType<typeof useOrderProfileXfaDesk>;
|
||||
const Host = defineComponent({
|
||||
setup() {
|
||||
desk = useOrderProfileXfaDesk({
|
||||
profileId: 52,
|
||||
leaseToken: 'lease',
|
||||
saveState: 'saved',
|
||||
editorSessionId: 'sess',
|
||||
enabled: true,
|
||||
});
|
||||
return () => h('div');
|
||||
},
|
||||
});
|
||||
mount(Host, {
|
||||
global: {
|
||||
plugins: [createI18n({ legacy: false, locale: 'zh', messages: { zh: { admin: { shippingOrderProfiles: {
|
||||
xfaWorkbench: { loadFailed: 'fail' },
|
||||
xfaAutoMark: { enqueueFailed: 'e', jobFailed: 'j' },
|
||||
} } } } })],
|
||||
},
|
||||
});
|
||||
for (let i = 0; i < 40; i += 1) {
|
||||
await flushPromises();
|
||||
if (!desk.loading.value && desk.definition.value) break;
|
||||
}
|
||||
// 原生页授权就绪后,synthetic 失败不应禁标注。
|
||||
desk.pageGrants.value = [{ page_no: 1, preview_token: 'token' }];
|
||||
desk.pageGrant.value = { page_no: 1, preview_token: 'token' };
|
||||
desk.pageLoadError.value = null;
|
||||
desk.syntheticPreviewStatus.value = 'unavailable';
|
||||
expect(desk.annotationDisabled.value).toBe(false);
|
||||
|
||||
desk.pageGrant.value = null;
|
||||
desk.pageGrants.value = [];
|
||||
expect(desk.annotationDisabled.value).toBe(true);
|
||||
|
||||
desk.definition.value = {
|
||||
...desk.definition.value!,
|
||||
bindings: [{
|
||||
binding_id: 'anchor-1',
|
||||
field_id: 'a1',
|
||||
field_code: '',
|
||||
scope: 'header',
|
||||
value_binding: { type: 'xfa_dataset', path_id: '', data_path: null },
|
||||
visual_binding: {
|
||||
page_no: 1,
|
||||
normalized_bbox: { x0: 0.1, y0: 0.1, x1: 0.2, y1: 0.2 },
|
||||
source: 'user_drawn',
|
||||
status: 'suggested',
|
||||
region_kind: 'anchor',
|
||||
},
|
||||
}],
|
||||
};
|
||||
desk.selectedBindingId.value = 'anchor-1';
|
||||
expect(desk.showDatasetsSection.value).toBe(false);
|
||||
}, 15000);
|
||||
});
|
||||
+32
-1163
File diff suppressed because it is too large.
Load diff
+62
-6
@@ -1,9 +1,9 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileDocumentCanvas.vue
|
||||
用途:展示受控 PDF 单页预览,并以相对坐标框支持选择、拖动和缩放区域。
|
||||
用途:展示受控 PDF/XFA flatten 单页预览,并以相对坐标框支持选择、拖动和缩放区域。
|
||||
依赖:浏览器 fetch、认证请求头、OrderProfileCanvasRegion。
|
||||
逻辑:父级签发单页令牌并提供分页动作;mode=readonly 时只允许查看/缩放/切页,不允许写入任何标注改动;
|
||||
画布区域 aria-label 走四语言 i18n,供辅助技术正确读出只读/标注模式。
|
||||
画布区域 aria-label 走四语言 i18n;可选 emptyHint/loadError 区分 XFA page_unavailable 与 PDF 缺样本空态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
@@ -36,6 +36,10 @@ const props = defineProps<{
|
||||
orderFieldValueState?: 'idle' | 'loading' | 'ready' | 'failed';
|
||||
/** full=坐标全工具;xfa_visual=仅 XFA 画框。 */
|
||||
annotationToolSet?: 'full' | 'xfa_visual';
|
||||
/** 无图时空态文案;缺省为「选择已绑定的 PDF 样本」。 */
|
||||
emptyHint?: string | null;
|
||||
/** 外部注入的页加载错误(如 XFA page_unavailable);优先于空态提示。 */
|
||||
loadError?: string | null;
|
||||
}>();
|
||||
const { t } = useI18n();
|
||||
const readonlyMode = computed(() => props.mode === 'readonly');
|
||||
@@ -56,10 +60,16 @@ const emit = defineEmits<{
|
||||
page: [pageNo: number];
|
||||
acceptSuggestion: [];
|
||||
rejectSuggestion: [];
|
||||
/** 页图拉取失败(父级可标 page_unavailable)。 */
|
||||
loadFailed: [];
|
||||
/** 用户点击重试(父级决定重拉 grant 或 flatten)。 */
|
||||
retry: [];
|
||||
}>();
|
||||
|
||||
const imageUrl = ref('');
|
||||
const loading = ref(false);
|
||||
/** 本组件内 fetch 失败文案;与 props.loadError 合并展示。 */
|
||||
const internalLoadError = ref<string | null>(null);
|
||||
const canvas = ref<HTMLElement | null>(null);
|
||||
const viewport = ref<HTMLElement | null>(null);
|
||||
const zoom = ref(1);
|
||||
@@ -72,12 +82,26 @@ let activePan: { startX: number; startY: number; scrollLeft: number; scrollTop:
|
||||
let creationStart: { x: number; y: number } | null = null;
|
||||
const creationRegion = ref<OrderProfileCanvasRegion['region'] | null>(null);
|
||||
|
||||
/** 下载一次性 PNG 并在组件卸载或切页时回收浏览器 blob。 */
|
||||
const displayLoadError = computed(() => props.loadError || internalLoadError.value || null);
|
||||
const emptyStateText = computed(() => (
|
||||
props.emptyHint || t('admin.shippingOrderProfiles.workbench.selectBoundPdf')
|
||||
));
|
||||
|
||||
/**
|
||||
* 下载一次性 PNG 并在组件卸载或切页时回收浏览器 blob。
|
||||
* 核心逻辑:失败时写入 internalLoadError 并 emit loadFailed,避免误导为「未绑定样本」。
|
||||
*/
|
||||
const loadPage = async () => {
|
||||
if (!props.profileId || !props.grant) return;
|
||||
if (!props.profileId || !props.grant) {
|
||||
URL.revokeObjectURL(imageUrl.value);
|
||||
imageUrl.value = '';
|
||||
internalLoadError.value = null;
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
URL.revokeObjectURL(imageUrl.value);
|
||||
imageUrl.value = '';
|
||||
internalLoadError.value = null;
|
||||
try {
|
||||
const previewPath = props.previewPagePath
|
||||
|| `/api/admin/shipping-notice/order-document-profiles/${props.profileId}/preview-pages`;
|
||||
@@ -87,11 +111,22 @@ const loadPage = async () => {
|
||||
);
|
||||
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
||||
imageUrl.value = URL.createObjectURL(await response.blob());
|
||||
} catch {
|
||||
internalLoadError.value = t('admin.shippingOrderProfiles.workbench.canvasUnavailable');
|
||||
emit('loadFailed');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 用户点击画布重试:清除内部错误并通知父级。
|
||||
*/
|
||||
const onRetryClick = () => {
|
||||
internalLoadError.value = null;
|
||||
emit('retry');
|
||||
};
|
||||
|
||||
/** 将指针移动映射为相对坐标;readonly 模式只保留选中,不允许几何变化。 */
|
||||
const move = (event: PointerEvent) => {
|
||||
if (!activeDrag || !canvas.value || readonlyMode.value) return;
|
||||
@@ -253,7 +288,13 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
</div>
|
||||
</header>
|
||||
<div v-if="loading" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.loadingPage') }}</div>
|
||||
<div v-else-if="!imageUrl" class="canvas-state">{{ t('admin.shippingOrderProfiles.workbench.selectBoundPdf') }}</div>
|
||||
<div v-else-if="displayLoadError" class="canvas-state canvas-state--error" role="alert">
|
||||
<p>{{ displayLoadError }}</p>
|
||||
<button type="button" class="canvas-retry" @click="onRetryClick">
|
||||
{{ t('admin.shippingOrderProfiles.workbench.retryCanvas') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="!imageUrl" class="canvas-state">{{ emptyStateText }}</div>
|
||||
<div v-else class="canvas-work-area" :class="{ readonly: readonlyMode }">
|
||||
<aside v-if="!readonlyMode" class="annotation-tools">
|
||||
<template v-if="xfaVisualTools">
|
||||
@@ -323,7 +364,22 @@ onBeforeUnmount(() => { endMove(); endPan(); endCreation(); URL.revokeObjectURL(
|
||||
.zoom-control { justify-self: end; }
|
||||
.canvas-toolbar output { min-width: 3.4rem; color: #f8fafc; text-align: center; }
|
||||
.zoom-control .fit-action { padding-inline: .65rem; }
|
||||
.canvas-state { display: grid; min-height: 32rem; place-items: center; color: #94a3b8; font-size: .875rem; }
|
||||
.canvas-state { display: grid; min-height: 32rem; place-items: center; color: #94a3b8; font-size: .875rem; gap: .75rem; }
|
||||
.canvas-state--error { color: #fecaca; }
|
||||
.canvas-retry {
|
||||
display: inline-flex;
|
||||
min-height: 2rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: 1px solid #475569;
|
||||
border-radius: .35rem;
|
||||
background: #1e293b;
|
||||
padding: .35rem .75rem;
|
||||
color: #e2e8f0;
|
||||
font-size: .78rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.canvas-retry:hover { border-color: #60a5fa; background: #26364f; }
|
||||
.canvas-work-area { display: flex; min-height: 0; flex: 1; gap: .6rem; }
|
||||
.canvas-work-area.readonly { gap: 0; }
|
||||
.canvas-viewport { position: relative; min-width: 0; flex: 1; overflow: auto; }
|
||||
|
||||
+115
@@ -0,0 +1,115 @@
|
||||
/**
|
||||
* features/admin/modules/shipping-order-document-profiles/components/OrderProfileXfaConfirmStep.spec.ts
|
||||
* 用途:验证 XFA 集合候选在未选择权威集合时仍可见,且真正无候选时才显示空状态。
|
||||
* 依赖:Vitest、@vue/test-utils、OrderProfileXfaConfirmStep 及其 XFA API。
|
||||
*/
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import OrderProfileXfaConfirmStep from './OrderProfileXfaConfirmStep.vue';
|
||||
|
||||
const { getFieldTree, getCollections, reparseSample } = vi.hoisted(() => ({
|
||||
getFieldTree: vi.fn(),
|
||||
getCollections: vi.fn(),
|
||||
reparseSample: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/admin/api/shipping-order-document-profile.api', () => ({
|
||||
getOrderProfileSampleXfaFieldTree: getFieldTree,
|
||||
getOrderProfileSampleXfaCollections: getCollections,
|
||||
reparseOrderProfileSampleLayout: reparseSample,
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
admin: {
|
||||
shippingOrderProfiles: {
|
||||
wizard: {
|
||||
sampleSelected: '已选样本',
|
||||
xfa: {
|
||||
loading: '加载中',
|
||||
loadErrorTitle: '加载失败',
|
||||
loadErrorHint: '请重试',
|
||||
reload: '重新加载',
|
||||
reparseSample: '重新解析样本',
|
||||
noCollections: '没有可用数据集',
|
||||
intro: 'XFA',
|
||||
noBlankPdf: '不使用空白 PDF',
|
||||
scriptNotice: '不会执行脚本',
|
||||
},
|
||||
},
|
||||
xfaUnified: { createBlockersTitle: '创建前阻断项' },
|
||||
xfaWorkbench: {
|
||||
collectionsTitle: '集合',
|
||||
collectionEvidenceHint: '证据',
|
||||
authoritativeCollection: '权威集合',
|
||||
mirrorCollections: '镜像集合',
|
||||
recommendedAuthoritative: '推荐权威',
|
||||
selectedAuthoritative: '已选权威',
|
||||
rowCount: '{count} 行',
|
||||
nonEmptyCoverage: '{filled}/{total} {percent}',
|
||||
excludedCollections: '排除集合 {count}',
|
||||
allCandidatesExcluded: '全部被排除',
|
||||
emptyStructureReason: '空结构',
|
||||
collectionReason: { data_description_structure: '结构描述', empty_structure: '空结构' },
|
||||
},
|
||||
xfa: { documentKinds: { xfa_hybrid: 'XFA 动态表单' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const sample = {
|
||||
document_id: 132,
|
||||
intake_id: 1,
|
||||
intake_no: 'INT-1',
|
||||
filename: '4510039227.pdf',
|
||||
table_count: 0,
|
||||
document_kind: 'xfa_hybrid',
|
||||
xfa_analysis_ready: true,
|
||||
purpose: 'order_document_profile_sample' as const,
|
||||
parse_status: 'ready',
|
||||
is_template_sample: true,
|
||||
can_delete: true,
|
||||
};
|
||||
|
||||
function mountStep() {
|
||||
return mount(OrderProfileXfaConfirmStep, {
|
||||
global: { plugins: [i18n] },
|
||||
props: { documentId: 132, sample, authoritativePathId: '', mirrorPathIds: [] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('OrderProfileXfaConfirmStep', () => {
|
||||
it('未选择权威集合时仍显示可选数据集', async () => {
|
||||
getFieldTree.mockResolvedValue({ tree: {} });
|
||||
getCollections.mockResolvedValue({
|
||||
collection_candidates: [{
|
||||
path_id: 'items', collection_path_hash: 'h1', row_count: 1,
|
||||
path_label: 'datasets / data / ITEMS / DATA', field_names: ['MATNR'],
|
||||
field_count: 1, non_empty_field_count: 1, non_empty_rate: 1,
|
||||
sample_fields: [{ field_name: 'MATNR', display_value: 'TEMP-S', display_policy: 'partial' }],
|
||||
selectable: true, recommended_role: 'authoritative',
|
||||
}],
|
||||
excluded_collection_candidates: [],
|
||||
});
|
||||
|
||||
const wrapper = mountStep();
|
||||
await vi.waitFor(() => expect(wrapper.text()).toContain('datasets / data / ITEMS / DATA'));
|
||||
expect(wrapper.find('input[type="radio"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('创建前阻断项');
|
||||
});
|
||||
|
||||
it('没有任何候选集合时才显示空状态', async () => {
|
||||
getFieldTree.mockResolvedValue({ tree: {} });
|
||||
getCollections.mockResolvedValue({ collection_candidates: [], excluded_collection_candidates: [] });
|
||||
|
||||
const wrapper = mountStep();
|
||||
await vi.waitFor(() => expect(wrapper.text()).toContain('没有可用数据集'));
|
||||
expect(wrapper.find('input[type="radio"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
+115
-15
@@ -1,18 +1,19 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/OrderProfileXfaConfirmStep.vue
|
||||
用途:创建向导第三步——XFA 样本结构与明细集合确认(不要求 table_id)。
|
||||
依赖:XFA collections API、XfaCollectionSelector、vue-i18n。
|
||||
逻辑:父级传入 documentId 与 v-model 集合 path_id;watch(immediate) 加载上下文,
|
||||
避免 onMounted 再次触发导致重复请求。
|
||||
依赖:XFA collections/field-tree API、layout-reparse API、XfaCollectionSelector、vue-i18n。
|
||||
逻辑:父级传入 documentId 与 v-model 集合 path_id;加载失败以独立错误态阻断创建,
|
||||
区分「无合格集合」与「分析不可用」;重新解析需二次确认且不自动触发。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { BusinessError, resolveLocalizedErrorMessage } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
getOrderProfileSampleXfaCollections,
|
||||
getOrderProfileSampleXfaFieldTree,
|
||||
reparseOrderProfileSampleLayout,
|
||||
} from '@/features/admin/api/shipping-order-document-profile.api';
|
||||
import type { OrderProfileSampleDocument } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
import { flattenXfaTreeNodes } from '../xfaProfileMapping.utils';
|
||||
@@ -27,19 +28,27 @@ const props = defineProps<{
|
||||
const emit = defineEmits<{
|
||||
'update:authoritativePathId': [value: string];
|
||||
'update:mirrorPathIds': [value: string[]];
|
||||
/** 加载失败态变化:父级须据此阻断创建按钮 */
|
||||
'update:contextReady': [value: boolean];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const message = useMessage();
|
||||
const loading = ref(false);
|
||||
const reparsing = ref(false);
|
||||
const loadError = ref<{ code?: string; message: string } | null>(null);
|
||||
const collections = ref<Awaited<ReturnType<typeof getOrderProfileSampleXfaCollections>> | null>(null);
|
||||
const flatNodes = ref(flattenXfaTreeNodes(null));
|
||||
const excludedCollections = computed(() => collections.value?.excluded_collection_candidates || []);
|
||||
const contextReady = computed(() => !loading.value && !loadError.value && collections.value != null);
|
||||
|
||||
/** 创建草稿前的阻断摘要(权威集合必选等)。 */
|
||||
/**
|
||||
* 创建草稿前的阻断摘要(权威集合必选等);加载失败时不计入“无集合”。
|
||||
*/
|
||||
const createBlockers = computed(() => {
|
||||
if (loadError.value || !collections.value) return [];
|
||||
const items: string[] = [];
|
||||
const selectable = (collections.value?.collection_candidates || []).filter((item) => item.selectable !== false);
|
||||
const selectable = (collections.value.collection_candidates || []).filter((item) => item.selectable !== false);
|
||||
if (!props.authoritativePathId && selectable.length) {
|
||||
items.push(t('admin.shippingOrderProfiles.xfaWorkbench.blocker.authoritative_collection_required'));
|
||||
}
|
||||
@@ -54,32 +63,87 @@ const documentKindLabel = computed(() => {
|
||||
return t(`admin.shippingOrderProfiles.xfa.documentKinds.${kind}`, kind);
|
||||
});
|
||||
|
||||
/**
|
||||
* 将 BusinessError 映射为用户可见文案(优先四语言 errors.codes)。
|
||||
* @param error - 捕获异常
|
||||
*/
|
||||
function resolveLoadErrorMessage(error: unknown): { code?: string; message: string } {
|
||||
if (error instanceof BusinessError) {
|
||||
const code = String(error.code || '').trim() || undefined;
|
||||
return {
|
||||
code,
|
||||
message: resolveLocalizedErrorMessage(code, error.message)
|
||||
|| t('admin.shippingOrderProfiles.wizard.xfa.loadFailed'),
|
||||
};
|
||||
}
|
||||
return { message: t('admin.shippingOrderProfiles.wizard.xfa.loadFailed') };
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载 XFA 集合候选与字段树(用于展示标签)。
|
||||
* @returns 完成后更新 flatNodes 与 collections。
|
||||
* 核心逻辑:并发请求;失败写入 loadError 且清空 collections,禁止误显示“没有集合”。
|
||||
*/
|
||||
async function loadXfaContext(): Promise<void> {
|
||||
if (!props.documentId) return;
|
||||
loading.value = true;
|
||||
loadError.value = null;
|
||||
collections.value = null;
|
||||
flatNodes.value = flattenXfaTreeNodes(null);
|
||||
emit('update:contextReady', false);
|
||||
try {
|
||||
const [treeResp, collectionResp] = await Promise.all([
|
||||
getOrderProfileSampleXfaFieldTree(props.documentId),
|
||||
getOrderProfileSampleXfaCollections(props.documentId),
|
||||
]);
|
||||
collections.value = collectionResp;
|
||||
flatNodes.value = flattenXfaTreeNodes(treeResp.tree as import('@/features/admin/types/shipping-order-document-profile.types').XfaFieldTreeNode);
|
||||
flatNodes.value = flattenXfaTreeNodes(
|
||||
treeResp.tree as import('@/features/admin/types/shipping-order-document-profile.types').XfaFieldTreeNode,
|
||||
);
|
||||
if (!props.authoritativePathId && collectionResp.collection_candidates.length === 1) {
|
||||
const only = collectionResp.collection_candidates[0];
|
||||
if (only?.path_id) emit('update:authoritativePathId', only.path_id);
|
||||
}
|
||||
emit('update:contextReady', true);
|
||||
} catch (error) {
|
||||
message.error(error instanceof BusinessError ? error.message : t('admin.shippingOrderProfiles.wizard.xfa.loadFailed'));
|
||||
loadError.value = resolveLoadErrorMessage(error);
|
||||
message.error(loadError.value.message);
|
||||
emit('update:contextReady', false);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 仅重新请求字段树与集合(不触发样本重新解析)。
|
||||
*/
|
||||
async function reloadContext(): Promise<void> {
|
||||
await loadXfaContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* 独立“重新解析样本”:二次确认后调用 layout-reparse;成功后提示用户再点重新加载。
|
||||
*/
|
||||
async function reparseSample(): Promise<void> {
|
||||
if (!props.documentId || reparsing.value) return;
|
||||
const ok = window.confirm(t('admin.shippingOrderProfiles.wizard.xfa.reparseConfirm'));
|
||||
if (!ok) return;
|
||||
reparsing.value = true;
|
||||
try {
|
||||
await reparseOrderProfileSampleLayout(props.documentId);
|
||||
message.success(t('admin.shippingOrderProfiles.wizard.xfa.reparseStarted'));
|
||||
} catch (error) {
|
||||
message.error(
|
||||
error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: t('admin.shippingOrderProfiles.wizard.xfa.reparseFailed'),
|
||||
);
|
||||
} finally {
|
||||
reparsing.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.documentId, () => void loadXfaContext(), { immediate: true });
|
||||
watch(contextReady, (ready) => emit('update:contextReady', ready));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -95,13 +159,29 @@ watch(() => props.documentId, () => void loadXfaContext(), { immediate: true });
|
||||
<li>{{ t('admin.shippingOrderProfiles.wizard.xfa.scriptNotice') }}</li>
|
||||
</ul>
|
||||
</article>
|
||||
|
||||
<p v-if="loading" class="xfa-confirm-step__loading">{{ t('admin.shippingOrderProfiles.wizard.xfa.loading') }}</p>
|
||||
<aside v-else-if="createBlockers.length" class="xfa-confirm-step__blockers" role="status">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaUnified.createBlockersTitle') }}</strong>
|
||||
<ul>
|
||||
<li v-for="(item, index) in createBlockers" :key="index">{{ item }}</li>
|
||||
</ul>
|
||||
|
||||
<aside v-else-if="loadError" class="xfa-confirm-step__error" role="alert">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.wizard.xfa.loadErrorTitle') }}</strong>
|
||||
<p>{{ loadError.message }}</p>
|
||||
<p v-if="loadError.code" class="xfa-confirm-step__error-code">{{ loadError.code }}</p>
|
||||
<p class="xfa-confirm-step__error-hint">{{ t('admin.shippingOrderProfiles.wizard.xfa.loadErrorHint') }}</p>
|
||||
<div class="xfa-confirm-step__error-actions">
|
||||
<button type="button" class="xfa-confirm-step__btn" @click="reloadContext">
|
||||
{{ t('admin.shippingOrderProfiles.wizard.xfa.reload') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="xfa-confirm-step__btn xfa-confirm-step__btn--secondary"
|
||||
:disabled="reparsing"
|
||||
@click="reparseSample"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.wizard.xfa.reparseSample') }}
|
||||
</button>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<XfaCollectionSelector
|
||||
v-else-if="collections && (collections.collection_candidates?.length || excludedCollections.length)"
|
||||
:candidates="collections.collection_candidates || []"
|
||||
@@ -111,7 +191,20 @@ watch(() => props.documentId, () => void loadXfaContext(), { immediate: true });
|
||||
@update:authoritative-path-id="emit('update:authoritativePathId', $event)"
|
||||
@update:mirror-path-ids="emit('update:mirrorPathIds', $event)"
|
||||
/>
|
||||
<p v-else-if="!loading" class="xfa-confirm-step__loading">{{ t('admin.shippingOrderProfiles.wizard.xfa.noCollections') }}</p>
|
||||
|
||||
<aside v-if="createBlockers.length" class="xfa-confirm-step__blockers" role="status">
|
||||
<strong>{{ t('admin.shippingOrderProfiles.xfaUnified.createBlockersTitle') }}</strong>
|
||||
<ul>
|
||||
<li v-for="(item, index) in createBlockers" :key="index">{{ item }}</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<p
|
||||
v-if="collections && !collections.collection_candidates?.length && !excludedCollections.length"
|
||||
class="xfa-confirm-step__loading"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.wizard.xfa.noCollections') }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -124,4 +217,11 @@ watch(() => props.documentId, () => void loadXfaContext(), { immediate: true });
|
||||
.xfa-confirm-step__loading { margin: 0; color: var(--text-muted); }
|
||||
.xfa-confirm-step__blockers { padding: 12px 14px; border: 1px solid var(--status-warning-border); border-radius: var(--radius-control); background: var(--status-warning-bg); color: var(--status-warning-fg); font-size: .84rem; }
|
||||
.xfa-confirm-step__blockers ul { margin: 6px 0 0; padding-left: 18px; }
|
||||
.xfa-confirm-step__error { padding: 14px 16px; border: 1px solid var(--status-danger-border, #f1aeb5); border-radius: var(--radius-control); background: var(--status-danger-bg, #fff5f5); color: var(--status-danger-fg, #9b1c1c); font-size: .86rem; display: flex; flex-direction: column; gap: 8px; }
|
||||
.xfa-confirm-step__error-code { margin: 0; font-family: ui-monospace, monospace; font-size: .75rem; opacity: .85; }
|
||||
.xfa-confirm-step__error-hint { margin: 0; color: var(--text-secondary); }
|
||||
.xfa-confirm-step__error-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
|
||||
.xfa-confirm-step__btn { padding: 6px 12px; border-radius: var(--radius-control); border: 1px solid var(--border-default); background: var(--bg-surface); cursor: pointer; font-size: .84rem; }
|
||||
.xfa-confirm-step__btn--secondary { background: transparent; }
|
||||
.xfa-confirm-step__btn:disabled { opacity: .6; cursor: not-allowed; }
|
||||
</style>
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaAutoMarkPanel.vue
|
||||
用途:XFA OCR/Widget 自动标记建议面板;支持轮询进度与接受/调整/拒绝。
|
||||
依赖:vue-i18n;由 OrderProfileEditorPage(XFA desk)嵌入并接线 automark API。
|
||||
逻辑:props 驱动 suggestions/jobStatus;动作按钮在非 disabled 时 emit 给父级持久化。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
/** 自动标记建议条目。 */
|
||||
export interface XfaAutoMarkSuggestion {
|
||||
suggestion_id: string;
|
||||
field_key?: string | null;
|
||||
field_code?: string | null;
|
||||
suggestion_origin?: 'widget_template' | 'ocr' | string | null;
|
||||
confidence?: number | null;
|
||||
status?: string | null;
|
||||
match_class?: string | null;
|
||||
summary?: string | null;
|
||||
ocr_text?: string | null;
|
||||
dataset_value?: string | null;
|
||||
iou?: number | null;
|
||||
needs_review?: boolean | null;
|
||||
}
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
suggestions?: XfaAutoMarkSuggestion[];
|
||||
disabled?: boolean;
|
||||
initiallyExpanded?: boolean;
|
||||
/** queued|running|succeeded|failed|idle */
|
||||
jobStatus?: string | null;
|
||||
jobError?: string | null;
|
||||
}>(), {
|
||||
suggestions: () => [],
|
||||
disabled: false,
|
||||
initiallyExpanded: true,
|
||||
jobStatus: 'idle',
|
||||
jobError: null,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
accept: [suggestion: XfaAutoMarkSuggestion];
|
||||
adjust: [suggestion: XfaAutoMarkSuggestion];
|
||||
reject: [suggestion: XfaAutoMarkSuggestion];
|
||||
retry: [];
|
||||
'run-full': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const expanded = ref(props.initiallyExpanded);
|
||||
|
||||
watch(() => props.initiallyExpanded, (v) => { expanded.value = v; });
|
||||
|
||||
const items = computed(() => props.suggestions || []);
|
||||
const empty = computed(() => items.value.length === 0);
|
||||
const running = computed(() => ['queued', 'running', 'pending'].includes(String(props.jobStatus || '')));
|
||||
|
||||
/**
|
||||
* 切换面板展开/收起。
|
||||
*/
|
||||
function toggleExpanded(): void {
|
||||
expanded.value = !expanded.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 发出接受建议事件。
|
||||
*/
|
||||
function onAccept(suggestion: XfaAutoMarkSuggestion): void {
|
||||
if (props.disabled || suggestion.needs_review || suggestion.match_class === 'needs_review') return;
|
||||
emit('accept', suggestion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发出调整建议事件(定位到画布手工改框)。
|
||||
*/
|
||||
function onAdjust(suggestion: XfaAutoMarkSuggestion): void {
|
||||
if (props.disabled) return;
|
||||
emit('adjust', suggestion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发出驳回建议事件。
|
||||
*/
|
||||
function onReject(suggestion: XfaAutoMarkSuggestion): void {
|
||||
if (props.disabled) return;
|
||||
emit('reject', suggestion);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析建议来源展示文案。
|
||||
*/
|
||||
function originLabel(origin: string | null | undefined): string {
|
||||
if (origin === 'widget_template') return t('admin.shippingOrderProfiles.xfaAutoMark.originWidget');
|
||||
if (origin === 'ocr') return t('admin.shippingOrderProfiles.xfaAutoMark.originOcr');
|
||||
return t('admin.shippingOrderProfiles.xfaAutoMark.originUnknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* mismatch / needs_review 禁止直接接受。
|
||||
*/
|
||||
function acceptBlocked(item: XfaAutoMarkSuggestion): boolean {
|
||||
return Boolean(item.needs_review || item.match_class === 'needs_review');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="xfa-auto-mark" :aria-label="t('admin.shippingOrderProfiles.xfaAutoMark.title')">
|
||||
<button
|
||||
type="button"
|
||||
class="xfa-auto-mark__header"
|
||||
:aria-expanded="expanded"
|
||||
@click="toggleExpanded"
|
||||
>
|
||||
<span class="xfa-auto-mark__title">
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.title') }}
|
||||
</span>
|
||||
<span class="xfa-auto-mark__count">
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.count', { count: items.length }) }}
|
||||
</span>
|
||||
<span v-if="running" class="xfa-auto-mark__job">{{ t('admin.shippingOrderProfiles.xfaAutoMark.running') }}</span>
|
||||
<span class="xfa-auto-mark__chevron">{{ expanded ? '▾' : '▸' }}</span>
|
||||
</button>
|
||||
|
||||
<div v-if="expanded" class="xfa-auto-mark__body">
|
||||
<p class="xfa-auto-mark__hint">
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.hint') }}
|
||||
</p>
|
||||
<div class="xfa-auto-mark__toolbar">
|
||||
<button type="button" class="action-btn" :disabled="disabled || running" @click="emit('run-full')">
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.runFull') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="jobStatus === 'failed'"
|
||||
type="button"
|
||||
class="action-btn"
|
||||
:disabled="disabled"
|
||||
@click="emit('retry')"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.retry') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="jobError" class="xfa-auto-mark__error">{{ jobError }}</p>
|
||||
<p v-if="empty && !running" class="xfa-auto-mark__empty">
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.empty') }}
|
||||
</p>
|
||||
<ul v-else class="xfa-auto-mark__list">
|
||||
<li
|
||||
v-for="item in items"
|
||||
:key="item.suggestion_id"
|
||||
class="xfa-auto-mark__item"
|
||||
>
|
||||
<div class="xfa-auto-mark__meta">
|
||||
<span class="xfa-auto-mark__field">
|
||||
{{ item.field_code || item.field_key || item.suggestion_id }}
|
||||
</span>
|
||||
<span class="xfa-auto-mark__origin">{{ originLabel(item.suggestion_origin) }}</span>
|
||||
<span v-if="item.match_class" class="xfa-auto-mark__class">{{ item.match_class }}</span>
|
||||
<span v-if="item.confidence != null" class="xfa-auto-mark__confidence">
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.confidence', {
|
||||
value: Math.round(Number(item.confidence) * 100),
|
||||
}) }}
|
||||
</span>
|
||||
</div>
|
||||
<p v-if="item.summary" class="xfa-auto-mark__summary">{{ item.summary }}</p>
|
||||
<p v-else-if="item.ocr_text || item.dataset_value" class="xfa-auto-mark__summary">
|
||||
OCR: {{ item.ocr_text || '—' }} · datasets: {{ item.dataset_value || '—' }}
|
||||
</p>
|
||||
<div class="xfa-auto-mark__actions">
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn action-btn--active"
|
||||
:disabled="disabled || acceptBlocked(item)"
|
||||
@click="onAccept(item)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.accept') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn action-btn--active"
|
||||
:disabled="disabled"
|
||||
@click="onAdjust(item)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.adjust') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="action-btn action-btn--active action-btn--danger"
|
||||
:disabled="disabled"
|
||||
@click="onReject(item)"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaAutoMark.reject') }}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.xfa-auto-mark {
|
||||
border-top: 1px solid #7dd3fc;
|
||||
border-radius: 0;
|
||||
background: #ecfeff;
|
||||
overflow: hidden;
|
||||
color: #155e75;
|
||||
}
|
||||
.xfa-auto-mark__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5rem;
|
||||
width: 100%;
|
||||
padding: 0.65rem 0.9rem;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
text-align: left;
|
||||
color: #155e75;
|
||||
}
|
||||
.xfa-auto-mark__title { font-size: 0.75rem; font-weight: 600; }
|
||||
.xfa-auto-mark__count, .xfa-auto-mark__job {
|
||||
border-radius: 999px;
|
||||
background: #bae6fd;
|
||||
padding: 0.15rem 0.4rem;
|
||||
font-size: 0.72rem;
|
||||
color: #0e7490;
|
||||
}
|
||||
.xfa-auto-mark__chevron { margin-left: auto; color: #0e7490; font-size: 0.75rem; }
|
||||
.xfa-auto-mark__body { padding: 0 0.9rem 0.75rem; border-top: 1px solid #a5f3fc; }
|
||||
.xfa-auto-mark__hint, .xfa-auto-mark__empty { margin: 0.5rem 0 0; font-size: 0.75rem; color: #0e7490; }
|
||||
.xfa-auto-mark__error { margin: 0.35rem 0 0; font-size: 0.75rem; color: #b91c1c; }
|
||||
.xfa-auto-mark__toolbar { display: flex; gap: 0.35rem; margin-top: 0.45rem; }
|
||||
.xfa-auto-mark__toolbar .action-btn {
|
||||
border: 1px solid #0891b2;
|
||||
border-radius: 0.35rem;
|
||||
background: #fff;
|
||||
padding: 0.35rem 0.55rem;
|
||||
color: #0e7490;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.xfa-auto-mark__list {
|
||||
list-style: none;
|
||||
margin: 0.5rem 0 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
max-height: 220px;
|
||||
overflow: auto;
|
||||
}
|
||||
.xfa-auto-mark__item {
|
||||
padding: 0.5rem;
|
||||
border: 1px solid #e2e8f0;
|
||||
border-radius: 0.375rem;
|
||||
background: #fff;
|
||||
}
|
||||
.xfa-auto-mark__meta { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
|
||||
.xfa-auto-mark__field { font-size: 0.8125rem; font-weight: 600; color: #0f172a; }
|
||||
.xfa-auto-mark__origin, .xfa-auto-mark__confidence, .xfa-auto-mark__class {
|
||||
font-size: 0.6875rem;
|
||||
color: #64748b;
|
||||
background: #f1f5f9;
|
||||
border-radius: 0.25rem;
|
||||
padding: 0.1rem 0.35rem;
|
||||
}
|
||||
.xfa-auto-mark__summary { margin: 0.35rem 0 0; font-size: 0.75rem; color: #475569; }
|
||||
.xfa-auto-mark__actions { display: flex; gap: 0.35rem; margin-top: 0.45rem; }
|
||||
.action-btn {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.2rem 0.5rem;
|
||||
border-radius: 0.25rem;
|
||||
border: 1px solid #cbd5e1;
|
||||
background: #f8fafc;
|
||||
color: #334155;
|
||||
}
|
||||
.action-btn:disabled { cursor: not-allowed; opacity: 0.45; }
|
||||
.action-btn--active { cursor: pointer; opacity: 1; }
|
||||
.action-btn--active:hover:not(:disabled) { border-color: #60a5fa; background: #eff6ff; }
|
||||
.action-btn--danger { color: #991b1b; border-color: #fecaca; }
|
||||
</style>
|
||||
+151
@@ -0,0 +1,151 @@
|
||||
<!--
|
||||
features/admin/modules/shipping-order-document-profiles/components/XfaPreviewModeToggle.vue
|
||||
用途:【已废止 / DEPRECATED】原 XFA 原始 PDF / 合成预览双模式切换。
|
||||
依赖:vue-i18n、XfaPreviewCanvasMode 类型。
|
||||
逻辑:硬冻结后 EditorPage 不再导入;保留文件仅防旧引用,请勿在新产品路径使用。
|
||||
替代:唯一 flatten 合成图源;见 useOrderProfileXfaDesk + OrderProfileEditorPage 共享 desk。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { XfaPreviewCanvasMode } from '@/features/admin/types/shipping-order-document-profile.types';
|
||||
|
||||
/** @deprecated 双预览模式已废止;请勿再挂载本组件。 */
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue: XfaPreviewCanvasMode;
|
||||
status?: 'idle' | 'loading' | 'ready' | 'failed' | 'stale' | 'unavailable';
|
||||
pageCount?: number;
|
||||
disabled?: boolean;
|
||||
}>(), {
|
||||
status: 'idle',
|
||||
pageCount: 0,
|
||||
disabled: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:modelValue': [mode: XfaPreviewCanvasMode];
|
||||
'mode-change': [mode: XfaPreviewCanvasMode];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const statusText = computed(() => {
|
||||
switch (props.status) {
|
||||
case 'loading':
|
||||
return t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.statusLoading');
|
||||
case 'ready':
|
||||
return t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.statusReady', {
|
||||
pages: props.pageCount || 0,
|
||||
});
|
||||
case 'failed':
|
||||
return t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.statusFailed');
|
||||
case 'stale':
|
||||
return t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.statusStale');
|
||||
case 'unavailable':
|
||||
return t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.statusUnavailable');
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 切换预览模式并同步 v-model / mode-change。
|
||||
* @param mode 目标模式
|
||||
*/
|
||||
function selectMode(mode: XfaPreviewCanvasMode): void {
|
||||
if (props.disabled || mode === props.modelValue) return;
|
||||
emit('update:modelValue', mode);
|
||||
emit('mode-change', mode);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="xfa-preview-mode-toggle"
|
||||
role="group"
|
||||
:aria-label="t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.label')"
|
||||
>
|
||||
<span class="xfa-preview-mode-toggle__label">
|
||||
{{ t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.label') }}
|
||||
</span>
|
||||
<div class="xfa-preview-mode-toggle__buttons">
|
||||
<button
|
||||
type="button"
|
||||
class="mode-btn"
|
||||
:class="{ active: modelValue === 'original' }"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="modelValue === 'original'"
|
||||
@click="selectMode('original')"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.original') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="mode-btn"
|
||||
:class="{ active: modelValue === 'synthetic' }"
|
||||
:disabled="disabled"
|
||||
:aria-pressed="modelValue === 'synthetic'"
|
||||
@click="selectMode('synthetic')"
|
||||
>
|
||||
{{ t('admin.shippingOrderProfiles.xfaWorkbench.previewMode.synthetic') }}
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="statusText" class="xfa-preview-mode-toggle__status" :data-status="status">
|
||||
{{ statusText }}
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.xfa-preview-mode-toggle {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 0.5rem 0.75rem;
|
||||
margin-bottom: 0.5rem;
|
||||
padding: 0.35rem 0;
|
||||
}
|
||||
.xfa-preview-mode-toggle__label {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 600;
|
||||
color: #475569;
|
||||
}
|
||||
.xfa-preview-mode-toggle__buttons {
|
||||
display: inline-flex;
|
||||
border: 1px solid #cbd5e1;
|
||||
border-radius: 0.375rem;
|
||||
overflow: hidden;
|
||||
}
|
||||
.mode-btn {
|
||||
appearance: none;
|
||||
border: 0;
|
||||
background: #f8fafc;
|
||||
color: #334155;
|
||||
font-size: 0.75rem;
|
||||
padding: 0.3rem 0.65rem;
|
||||
cursor: pointer;
|
||||
}
|
||||
.mode-btn + .mode-btn {
|
||||
border-left: 1px solid #cbd5e1;
|
||||
}
|
||||
.mode-btn.active {
|
||||
background: #0f172a;
|
||||
color: #f8fafc;
|
||||
}
|
||||
.mode-btn:disabled {
|
||||
opacity: 0.55;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.xfa-preview-mode-toggle__status {
|
||||
margin: 0;
|
||||
font-size: 0.7rem;
|
||||
color: #64748b;
|
||||
}
|
||||
.xfa-preview-mode-toggle__status[data-status='failed'],
|
||||
.xfa-preview-mode-toggle__status[data-status='stale'] {
|
||||
color: #b45309;
|
||||
}
|
||||
.xfa-preview-mode-toggle__status[data-status='ready'] {
|
||||
color: #047857;
|
||||
}
|
||||
</style>
|
||||
+1668
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/admin/types/shipping-order-document-profile.types.ts
|
||||
* 用途:订单文档坐标模板、XFA 统一绑定(value/visual/split)、受控样本预览和字段区域 DTO。
|
||||
* 用途:订单文档坐标模板、XFA 统一绑定(value/visual/split)、合成预览与受控样本预览 DTO。
|
||||
* 依赖:无。
|
||||
* 逻辑:管理页面只提交样本选择、白名单解析器与受控 path_id;不持有或提交 HTML/
|
||||
* 完整 XML、原始 PDF bytes 或对象存储地址。template_mode 为鉴别联合入口。
|
||||
@@ -136,6 +136,15 @@ export interface XfaVisualBinding {
|
||||
source: XfaVisualBindingSource;
|
||||
status: XfaVisualBindingStatus;
|
||||
confidence?: number;
|
||||
/** 合成预览渲染校验和(确认时必填)。 */
|
||||
preview_render_checksum?: string | null;
|
||||
/** 须为 xfa_dataset_preview。 */
|
||||
render_mode?: string | null;
|
||||
/** 确认时写入的合成器版本(BE-4 发布门禁必填)。 */
|
||||
renderer_version?: string | null;
|
||||
/** 确认画布,通常为 xfa_dataset_preview。 */
|
||||
confirmed_on?: string | null;
|
||||
region_kind?: string | null;
|
||||
}
|
||||
|
||||
/** 字段对拆分段的引用。 */
|
||||
@@ -815,6 +824,72 @@ export interface OrderProfileUsagePage {
|
||||
|
||||
/** 受控预览授权只对单页生效,令牌不得持久化或复用。 */
|
||||
export interface OrderProfilePreviewPageGrant { page_no: number; preview_token: string; }
|
||||
|
||||
/** XFA 合成预览身份上下文(与后端 PreviewIdentityContext 对齐)。 */
|
||||
export interface XfaSyntheticPreviewIdentity {
|
||||
document_id: number | null;
|
||||
layout_version_id: number | null;
|
||||
structure_analysis_id: number | string | null;
|
||||
source_content_hash: string;
|
||||
template_packet_checksum: string;
|
||||
datasets_packet_checksum: string;
|
||||
dataset_structure_fingerprint: string;
|
||||
preview_render_checksum: string;
|
||||
render_mode: string;
|
||||
renderer_version: string;
|
||||
page_count: number;
|
||||
}
|
||||
|
||||
/** 合成预览页元数据(含短时 token,不含 PNG)。 */
|
||||
export interface XfaSyntheticPreviewPageMeta {
|
||||
page_no: number;
|
||||
preview_token: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
drawn_echo_count?: number;
|
||||
}
|
||||
|
||||
/** 可写入 definition.xfa_preview 的发布证据(无 PNG)。 */
|
||||
export interface XfaPreviewDefinitionMeta {
|
||||
status?: string | null;
|
||||
preview_render_checksum?: string | null;
|
||||
render_mode?: string;
|
||||
renderer_version?: string;
|
||||
page_count?: number;
|
||||
pages_ready?: number[];
|
||||
source_page_count?: number | null;
|
||||
synthetic_page_count?: number | null;
|
||||
pages?: Array<{
|
||||
page_no?: number;
|
||||
source_page_box?: Record<string, number>;
|
||||
synthetic_page_box?: Record<string, number>;
|
||||
page_identity_hash?: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
/** POST/GET xfa/preview 响应摘要。 */
|
||||
export interface XfaSyntheticPreviewResponse {
|
||||
document_id: number | null;
|
||||
identity: XfaSyntheticPreviewIdentity;
|
||||
status: 'ready' | 'needs_review' | 'failed' | 'stale' | string;
|
||||
error_code?: string | null;
|
||||
render_mode: string;
|
||||
renderer_version: string;
|
||||
page_count: number;
|
||||
preview_render_checksum?: string | null;
|
||||
pages: XfaSyntheticPreviewPageMeta[];
|
||||
expires_in_seconds: number;
|
||||
cache_hit: boolean;
|
||||
diagnostics?: Record<string, unknown>;
|
||||
/** BE-3:前端落库 definition.xfa_preview 用 */
|
||||
definition_preview_meta?: XfaPreviewDefinitionMeta;
|
||||
source_page_count?: number | null;
|
||||
synthetic_page_count?: number | null;
|
||||
}
|
||||
|
||||
/** 工作台预览模式:原始 PDFium 对照 vs datasets 合成权威画布。 */
|
||||
export type XfaPreviewCanvasMode = 'original' | 'synthetic';
|
||||
|
||||
export interface OrderProfileBoundSample {
|
||||
id: number;
|
||||
document_id: number;
|
||||
|
||||
@@ -86,6 +86,28 @@ function jsonPost(body?: unknown): RequestInit {
|
||||
};
|
||||
}
|
||||
|
||||
/** 订单处理工作台履约写归属上下文(与后端 assert_notice_task_ownership 对齐)。 */
|
||||
export type ShippingFulfillmentOwnershipContext = {
|
||||
expectedOrderTaskNo?: string;
|
||||
expectedReviewCaseNo?: string;
|
||||
expectedRunNo?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* 将归属上下文序列化为 API snake_case 载荷字段。
|
||||
*/
|
||||
function ownershipPayload(ownership?: ShippingFulfillmentOwnershipContext | null): Record<string, string> {
|
||||
if (!ownership) return {};
|
||||
const out: Record<string, string> = {};
|
||||
const ot = String(ownership.expectedOrderTaskNo || '').trim();
|
||||
const caseNo = String(ownership.expectedReviewCaseNo || '').trim();
|
||||
const run = String(ownership.expectedRunNo || '').trim();
|
||||
if (ot) out.expected_order_task_no = ot;
|
||||
if (caseNo) out.expected_review_case_no = caseNo;
|
||||
if (run) out.expected_run_no = run;
|
||||
return out;
|
||||
}
|
||||
|
||||
function assertShippingOk<T extends ShippingApiStatusPayload>(body: T): T {
|
||||
if (body.status === 'failed') {
|
||||
throw new BusinessError({
|
||||
@@ -401,6 +423,24 @@ export const validateWorkspaceShippingOrderReviewDraft = (caseNo: string, expect
|
||||
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ expected_draft_version: expectedDraftVersion }) },
|
||||
);
|
||||
|
||||
/**
|
||||
* 显式重试 STP 自动建单入队(failed / manual_fallback)。
|
||||
* 核心逻辑:POST 专用 retry;成功返回 queued/reused + job_id;失败为业务错误。
|
||||
* @param caseNo - 复核 Case 编号
|
||||
*/
|
||||
export const retryWorkspaceShippingOrderStpAutoCreate = (caseNo: string) =>
|
||||
requestJson<{
|
||||
status: string;
|
||||
job_id?: number | null;
|
||||
job_status?: string | null;
|
||||
idempotency_key?: string | null;
|
||||
retry_of_job_id?: number | null;
|
||||
case?: ShippingOrderReviewCase;
|
||||
}>(
|
||||
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/stp-auto-create/retry`,
|
||||
{ method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({}) },
|
||||
);
|
||||
|
||||
/**
|
||||
* 为复核明细人工选定一个或多个已启用库存源候选。
|
||||
* 核心逻辑:携带 expected_draft_version 乐观锁;服务端写入行级 inventory_routing 后重跑资格校验。
|
||||
@@ -1205,12 +1245,16 @@ export async function removeWorkspaceShippingNoticeLine(
|
||||
/**
|
||||
* 执行库存匹配。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param ownership - 可选工作台归属上下文
|
||||
* @returns 匹配结果与后续动作提示
|
||||
*/
|
||||
export async function matchWorkspaceShippingInventory(taskNo: string) {
|
||||
export async function matchWorkspaceShippingInventory(
|
||||
taskNo: string,
|
||||
ownership?: ShippingFulfillmentOwnershipContext | null,
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/match-inventory`,
|
||||
jsonPost(),
|
||||
jsonPost(ownershipPayload(ownership)),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
@@ -1265,12 +1309,16 @@ export async function markWorkspaceShippingManualUploaded(
|
||||
/**
|
||||
* 重试将发货 Excel 上传至货代系统。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param ownership - 可选工作台归属上下文
|
||||
* @returns RPA 上传触发或等待结果
|
||||
*/
|
||||
export async function retryWorkspaceShippingUpload(taskNo: string) {
|
||||
export async function retryWorkspaceShippingUpload(
|
||||
taskNo: string,
|
||||
ownership?: ShippingFulfillmentOwnershipContext | null,
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/retry-upload`,
|
||||
jsonPost(),
|
||||
jsonPost(ownershipPayload(ownership)),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
@@ -1278,12 +1326,16 @@ export async function retryWorkspaceShippingUpload(taskNo: string) {
|
||||
/**
|
||||
* 生成发货 Excel。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param ownership - 可选工作台归属上下文
|
||||
* @returns 生成结果,成功时通常会包含下载链接
|
||||
*/
|
||||
export async function generateWorkspaceShippingExcel(taskNo: string) {
|
||||
export async function generateWorkspaceShippingExcel(
|
||||
taskNo: string,
|
||||
ownership?: ShippingFulfillmentOwnershipContext | null,
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/generate-excel`,
|
||||
jsonPost(),
|
||||
jsonPost(ownershipPayload(ownership)),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
+185
-1
@@ -27,6 +27,10 @@ function mountSummary(eligibility: ShippingOrderReviewBuildEligibility, customer
|
||||
canBuildYes: '可建单',
|
||||
canBuildNo: '待处理',
|
||||
blockReasons: { require_manual_review: '需人工确认', unknown: '未知阻断' },
|
||||
gates: {
|
||||
customer_confirmed: '客户已确认',
|
||||
required_fields_complete: '必填字段完整',
|
||||
},
|
||||
},
|
||||
workbench: {
|
||||
primaryBlock: '首要阻断原因',
|
||||
@@ -95,6 +99,25 @@ describe('ReviewBuildEligibilitySummary', () => {
|
||||
expect(wrapper.find('[data-testid="review-eligibility-gate-checklist"]').text()).toContain('✓');
|
||||
});
|
||||
|
||||
it('ignores failed_gates customer_confirmed when customer is already resolved', () => {
|
||||
// 关键断言:客户已确认后不得再把「客户已确认」门禁文案投影为优先处理。
|
||||
const wrapper = mountSummary({
|
||||
can_build: false,
|
||||
status: 'blocked',
|
||||
issues: [],
|
||||
failed_gates: ['customer_confirmed', 'required_fields_complete'],
|
||||
gates: {
|
||||
customer_confirmed: true,
|
||||
required_fields_complete: false,
|
||||
},
|
||||
line_projections: [],
|
||||
}, true);
|
||||
|
||||
const block = wrapper.find('[data-testid="review-eligibility-primary-block"]');
|
||||
expect(block.exists()).toBe(true);
|
||||
expect(block.text()).not.toContain('客户已确认');
|
||||
});
|
||||
|
||||
it('projects concrete manual review facts before falling back to generic copy', () => {
|
||||
const wrapper = mountSummary({
|
||||
can_build: false,
|
||||
@@ -122,8 +145,9 @@ describe('ReviewBuildEligibilitySummary', () => {
|
||||
line_projections: [],
|
||||
});
|
||||
|
||||
// 有门禁 i18n 时优先展示业务门禁名,禁止露出内部 gate code。
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').text())
|
||||
.toContain('未知问题');
|
||||
.toContain('必填字段完整');
|
||||
expect(wrapper.text()).not.toContain('required_fields_complete');
|
||||
});
|
||||
|
||||
@@ -140,4 +164,164 @@ describe('ReviewBuildEligibilitySummary', () => {
|
||||
expect(wrapper.text()).not.toContain('can_build');
|
||||
expect(wrapper.text()).not.toContain('can_auto_create');
|
||||
});
|
||||
|
||||
it('hides primary-block under focusBuildability for inventory combo (UI-03)', () => {
|
||||
// 关键断言:库存阻断由 Gate 卡表达时,资格摘要不得再输出首要阻断标题。
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
issues: '问题',
|
||||
exceptionNav: { prev: '上', next: '下', prevHint: '', nextHint: '' },
|
||||
issueCodes: { unknown: '未知问题' },
|
||||
buildEligibility: {
|
||||
title: '订单检查',
|
||||
canBuildYes: '可建单',
|
||||
canBuildNo: '待处理',
|
||||
blockReasons: { require_manual_review: '需人工确认', unknown: '未知阻断' },
|
||||
gates: { required_fields_complete: '必填字段完整' },
|
||||
},
|
||||
workbench: {
|
||||
primaryBlock: '首要阻断原因',
|
||||
blockCount: '阻断项 {count} 项',
|
||||
viewFullChecks: '查看完整检查',
|
||||
manualReview: {
|
||||
customer: '请确认客户',
|
||||
field: '请确认字段:{field}',
|
||||
lineInventory: '第 {line} 行:请确认库存来源(候选:{candidates})',
|
||||
noCandidates: '暂无候选',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ReviewBuildEligibilitySummary, {
|
||||
props: {
|
||||
eligibility: {
|
||||
can_build: false,
|
||||
status: 'blocked',
|
||||
issues: [{
|
||||
code: 'require_manual_review',
|
||||
severity: 'blocking',
|
||||
explainability: { message: '库存来源待确认' },
|
||||
}],
|
||||
line_projections: [],
|
||||
},
|
||||
focusBuildability: true,
|
||||
exceptionCount: 2,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-build-eligibility-summary"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-eligibility-gate-checklist"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-exception-nav"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('hides primary-block under focusBuildability for field completeness combo (UI-03)', () => {
|
||||
// 关键断言:字段阻断组合态下资格卡只保留摘要与异常导航,不输出第二份首要阻断。
|
||||
const wrapper = mount(ReviewBuildEligibilitySummary, {
|
||||
props: {
|
||||
eligibility: {
|
||||
can_build: false,
|
||||
status: 'blocked',
|
||||
issues: [{
|
||||
code: 'required_field_missing',
|
||||
severity: 'blocking',
|
||||
field_code: 'po_number',
|
||||
}],
|
||||
assessment: { missing_required_fields: ['po_number'], invalid_lines: [] },
|
||||
line_projections: [],
|
||||
},
|
||||
fieldLabels: { po_number: 'PO' },
|
||||
focusBuildability: true,
|
||||
exceptionCount: 1,
|
||||
},
|
||||
global: {
|
||||
plugins: [createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
issueCodes: { unknown: '未知' },
|
||||
issues: '问题',
|
||||
exceptionNav: { prev: '上', next: '下', prevHint: '', nextHint: '' },
|
||||
buildEligibility: {
|
||||
title: '订单检查',
|
||||
canBuildYes: '可建单',
|
||||
canBuildNo: '待处理',
|
||||
gates: {},
|
||||
blockReasons: { unknown: '未知' },
|
||||
},
|
||||
workbench: {
|
||||
primaryBlock: '首要阻断原因',
|
||||
blockCount: '{count}',
|
||||
viewFullChecks: '查看完整检查',
|
||||
missingRequiredFields: '缺失必填',
|
||||
conflictFields: '冲突',
|
||||
manualReview: {
|
||||
customer: '',
|
||||
field: '请确认字段:{field}',
|
||||
lineInventory: '',
|
||||
noCandidates: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})],
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('hides primary-block when technical_auto_only leaves business gate inactive (UI-03)', () => {
|
||||
// 关键断言:仅技术 Gate pending 时 focusBuildability=false,资格卡可展示阻断;本测验证开启 focus 时仍唯一。
|
||||
const wrapper = mount(ReviewBuildEligibilitySummary, {
|
||||
props: {
|
||||
eligibility: {
|
||||
can_build: true,
|
||||
can_auto_create: true,
|
||||
status: 'qualified',
|
||||
issues: [],
|
||||
line_projections: [],
|
||||
},
|
||||
focusBuildability: true,
|
||||
},
|
||||
global: {
|
||||
plugins: [createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
buildEligibility: {
|
||||
title: '订单检查',
|
||||
canBuildYes: '可建单',
|
||||
canBuildNo: '待处理',
|
||||
gates: {},
|
||||
},
|
||||
workbench: {
|
||||
primaryBlock: '首要阻断原因',
|
||||
viewFullChecks: '查看完整检查',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})],
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-eligibility-primary-block"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-build-eligibility-badge"]').text()).toContain('可建单');
|
||||
});
|
||||
});
|
||||
+15
-3
@@ -66,7 +66,7 @@ const blockingIssueCount = computed(() => {
|
||||
return blocking.length || issues.length;
|
||||
});
|
||||
|
||||
/** 首要阻断文案。 */
|
||||
/** 首要阻断文案:仅来自当前未解决业务问题;客户已确认时不得再显示客户确认阻断。 */
|
||||
const primaryBlockMessage = computed(() => {
|
||||
const issues = effectiveIssues.value;
|
||||
const primary = issues.find((item) => String(item.severity || '') === 'blocking') || issues[0];
|
||||
@@ -78,7 +78,13 @@ const primaryBlockMessage = computed(() => {
|
||||
return !reason.startsWith('customer_');
|
||||
});
|
||||
if (!blockedLines.length) {
|
||||
const failedGate = (props.eligibility?.failed_gates || [])[0];
|
||||
const failedGate = (props.eligibility?.failed_gates || []).find((gate) => {
|
||||
const code = String(gate || '').trim().toLowerCase();
|
||||
if (props.customerResolved === true && (code === 'customer_confirmed' || code === 'customer_resolution')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (!failedGate) return '';
|
||||
const gateKey = `chat.shippingOrderReview.buildEligibility.gates.${failedGate}`;
|
||||
return te(gateKey) ? t(gateKey) : t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
@@ -116,7 +122,13 @@ const primaryBlockMessage = computed(() => {
|
||||
if (message) return message;
|
||||
const key = `chat.shippingOrderReview.issueCodes.${code}`;
|
||||
if (code && te(key)) return t(key);
|
||||
const failedGate = (props.eligibility?.failed_gates || [])[0];
|
||||
const failedGate = (props.eligibility?.failed_gates || []).find((gate) => {
|
||||
const gateCode = String(gate || '').trim().toLowerCase();
|
||||
if (props.customerResolved === true && (gateCode === 'customer_confirmed' || gateCode === 'customer_resolution')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (failedGate) {
|
||||
const gateKey = `chat.shippingOrderReview.buildEligibility.gates.${failedGate}`;
|
||||
return te(gateKey) ? t(gateKey) : t('chat.shippingOrderReview.issueCodes.unknown');
|
||||
|
||||
+4
@@ -97,6 +97,10 @@ async function openSelectDialog() {
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
openSelectDialog,
|
||||
});
|
||||
|
||||
/**
|
||||
* 按关键词搜索标准客户。
|
||||
*/
|
||||
|
||||
@@ -117,6 +117,24 @@ async function onRefresh() {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 聚焦裁决区并短暂高亮动作按钮(Footer / Resolver 委托)。
|
||||
*/
|
||||
function focusAdjudication() {
|
||||
const root = document.querySelector('[data-testid="review-duplicate-panel"]');
|
||||
root?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
const actions = document.querySelector('[data-testid="review-duplicate-actions"]');
|
||||
if (!(actions instanceof HTMLElement)) return;
|
||||
actions.classList.add('ring-2', 'ring-amber-400');
|
||||
window.setTimeout(() => {
|
||||
actions.classList.remove('ring-2', 'ring-amber-400');
|
||||
}, 1600);
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
focusAdjudication,
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -168,7 +186,11 @@ async function onRefresh() {
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div v-if="editable && duplicate?.needs_adjudication" class="mt-3 space-y-2">
|
||||
<div
|
||||
v-if="editable && duplicate?.needs_adjudication"
|
||||
class="mt-3 space-y-2 rounded-lg transition-shadow"
|
||||
data-testid="review-duplicate-actions"
|
||||
>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="allowed.has('open_existing')"
|
||||
|
||||
@@ -71,6 +71,24 @@ function onFocus(conflict: ShippingOrderReviewFieldConflict) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 聚焦第一个未解决冲突(Footer / Resolver 委托)。
|
||||
*/
|
||||
function focusFirstConflict() {
|
||||
const first = openConflicts.value[0];
|
||||
if (!first) return;
|
||||
onFocus(first);
|
||||
void Promise.resolve().then(() => {
|
||||
document
|
||||
.querySelector(`[data-testid="review-field-conflict-${first.conflict_key}"]`)
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
});
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
focusFirstConflict,
|
||||
});
|
||||
|
||||
/**
|
||||
* 采用某一候选值。
|
||||
*/
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewWorkbenchFooter.vue
|
||||
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 流程恢复动作)。
|
||||
用途:订单处理工作台底部唯一写操作栏(处置 / 保存 / 统一流程动作)。
|
||||
依赖:vue-i18n、lucide-vue-next、ActionPresentation。
|
||||
逻辑:ShippingOrderReviewView 传入 available_actions 与流程动作投影;sticky bottom;
|
||||
系统自动推进中隐藏无效主写按钮;流程写操作经 flow-action emit。
|
||||
只读查看时仍可展示 view_result/view_record;写按钮受 actionsExecutable 约束;
|
||||
流程写操作经 flow-action emit(与 Resolver 同链);flowBusy||saving 时禁用。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
@@ -17,19 +18,34 @@ const props = withDefaults(defineProps<{
|
||||
saving: boolean;
|
||||
isReadOnly: boolean;
|
||||
hasDraft: boolean;
|
||||
/** can_build && can_auto_create 时隐藏确认按钮并展示自动推进提示 */
|
||||
/** queued|running 时隐藏确认按钮 */
|
||||
hideConfirmBecauseAutoGate?: boolean;
|
||||
/** waiting/queued/running 时展示自动建单提示(可与确认按钮并存) */
|
||||
showAutoGateHint?: boolean;
|
||||
/** failed/manual_fallback 时展示「重试自动推进」 */
|
||||
showStpRetry?: boolean;
|
||||
/** 自动资格提示文案(等待启动 / 正在推进);由父级按真实 Job 状态计算 */
|
||||
autoGateHint?: string;
|
||||
/** 未保存本地修改计数(硬拦截与底栏提示同源) */
|
||||
unsavedCount?: number;
|
||||
/** 统一流程动作(原进度条 ActionBar);surface=review */
|
||||
flowPresentation?: ActionPresentation | null;
|
||||
/** 系统自动推进中:隐藏主写按钮 */
|
||||
automating?: boolean;
|
||||
/** 是否允许业务写(只读查看为 false) */
|
||||
actionsExecutable?: boolean;
|
||||
/** 统一流程动作提交中 */
|
||||
flowBusy?: boolean;
|
||||
}>(), {
|
||||
unsavedCount: 0,
|
||||
flowPresentation: null,
|
||||
automating: false,
|
||||
hideConfirmBecauseAutoGate: false,
|
||||
showAutoGateHint: false,
|
||||
showStpRetry: false,
|
||||
autoGateHint: '',
|
||||
actionsExecutable: true,
|
||||
flowBusy: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -39,6 +55,7 @@ const emit = defineEmits<{
|
||||
'upload-replacement': [event: Event];
|
||||
validate: [];
|
||||
confirm: [];
|
||||
'retry-stp': [];
|
||||
'flow-action': [item: ActionPresentationItem];
|
||||
}>();
|
||||
|
||||
@@ -51,8 +68,6 @@ function hasAction(action: string): boolean {
|
||||
return props.availableActions.includes(action);
|
||||
}
|
||||
|
||||
const showFooter = computed(() => props.hasDraft && !props.isReadOnly);
|
||||
|
||||
const flowItems = computed((): ActionPresentationItem[] => {
|
||||
const presentation = props.flowPresentation;
|
||||
if (!presentation) return [];
|
||||
@@ -64,6 +79,20 @@ const flowItems = computed((): ActionPresentationItem[] => {
|
||||
return items.filter((item) => item.intent !== 'refresh');
|
||||
});
|
||||
|
||||
const hasViewOnlyFlow = computed(() => flowItems.value.some((item) => (
|
||||
item.intent === 'view_result'
|
||||
|| item.intent === 'view_record'
|
||||
|| item.intent === 'open_profile_review'
|
||||
)));
|
||||
|
||||
/** 可编辑底栏,或只读但仍有导航/查看类流程动作。 */
|
||||
const showFooter = computed(() => (
|
||||
props.hasDraft && (!props.isReadOnly || hasViewOnlyFlow.value)
|
||||
));
|
||||
|
||||
const controlsBusy = computed(() => props.saving || props.flowBusy);
|
||||
const canWriteCaseActions = computed(() => props.actionsExecutable && !props.isReadOnly);
|
||||
|
||||
/**
|
||||
* 流程动作文案。
|
||||
*/
|
||||
@@ -71,7 +100,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
if (te(item.labelKey)) return t(item.labelKey);
|
||||
const gateKey = `workspace.shippingNotice.processGate.actions.${item.actionCode}`;
|
||||
if (te(gateKey)) return t(gateKey);
|
||||
return item.actionCode;
|
||||
return t('chat.shippingProcessing.action.none');
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -81,13 +110,15 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
class="sticky bottom-0 z-20 flex shrink-0 flex-col gap-3 border-t border-slate-200 bg-white/95 p-3 shadow-[0_-4px_12px_rgba(15,23,42,0.06)] backdrop-blur sm:flex-row sm:items-center sm:justify-between dark:border-slate-800 dark:bg-slate-900/95"
|
||||
data-testid="review-footer-actions"
|
||||
:data-automating="automating ? '1' : '0'"
|
||||
:data-flow-busy="flowBusy ? '1' : '0'"
|
||||
:data-actions-executable="actionsExecutable ? '1' : '0'"
|
||||
>
|
||||
<div class="order-1 flex flex-wrap items-center gap-2 sm:order-1">
|
||||
<template v-if="!automating">
|
||||
<template v-if="!automating && canWriteCaseActions">
|
||||
<button
|
||||
v-if="hasAction('mark_non_order')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:disabled="controlsBusy"
|
||||
class="rounded border border-rose-200 px-3 py-2 text-sm text-rose-700 hover:bg-rose-50 disabled:opacity-50 dark:border-rose-900 dark:text-rose-300 dark:hover:bg-rose-950/40"
|
||||
@click="emit('mark-non-order')"
|
||||
>
|
||||
@@ -96,7 +127,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
<button
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:disabled="controlsBusy"
|
||||
class="rounded border border-amber-200 px-3 py-2 text-sm text-amber-800 hover:bg-amber-50 disabled:opacity-50 dark:border-amber-900 dark:text-amber-200 dark:hover:bg-amber-950/40"
|
||||
@click="emit('mark-quality-issue')"
|
||||
>
|
||||
@@ -105,7 +136,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
<button
|
||||
v-if="hasAction('reparse')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:disabled="controlsBusy"
|
||||
class="inline-flex items-center gap-1 rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
@click="emit('reparse')"
|
||||
>
|
||||
@@ -114,12 +145,13 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
<label
|
||||
v-if="hasAction('mark_quality_issue')"
|
||||
class="cursor-pointer rounded border border-slate-300 px-3 py-2 text-sm text-slate-600 hover:bg-slate-50 dark:border-slate-700 dark:text-slate-300 dark:hover:bg-slate-800"
|
||||
:class="controlsBusy ? 'pointer-events-none opacity-50' : ''"
|
||||
>
|
||||
<input
|
||||
class="sr-only"
|
||||
type="file"
|
||||
accept="application/pdf,.pdf"
|
||||
:disabled="saving"
|
||||
:disabled="controlsBusy"
|
||||
@change="emit('upload-replacement', $event)"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.uploadReplacement') }}
|
||||
@@ -130,7 +162,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
v-for="item in flowItems"
|
||||
:key="`${item.intent}-${item.actionCode}`"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:disabled="controlsBusy"
|
||||
class="rounded border border-slate-300 px-3 py-2 text-sm text-slate-700 hover:bg-slate-50 disabled:opacity-50 dark:border-slate-700 dark:text-slate-200 dark:hover:bg-slate-800"
|
||||
:data-testid="`review-footer-flow-${item.intent}`"
|
||||
:data-intent="item.intent"
|
||||
@@ -156,17 +188,27 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.automatingFooterHint') }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="hideConfirmBecauseAutoGate"
|
||||
v-else-if="showAutoGateHint && canWriteCaseActions"
|
||||
class="text-xs text-muted"
|
||||
data-testid="review-auto-gate-hint"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.buildEligibility.autoGateProgressHint') }}
|
||||
{{ autoGateHint || t('chat.shippingOrderReview.buildEligibility.autoGateWaitingHint') }}
|
||||
</p>
|
||||
<template v-if="!automating">
|
||||
<template v-if="!automating && canWriteCaseActions">
|
||||
<button
|
||||
v-if="showStpRetry || hasAction('retry_stp_auto_create')"
|
||||
type="button"
|
||||
:disabled="controlsBusy"
|
||||
class="inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-3 py-2 text-sm text-amber-950 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
data-testid="review-retry-stp-auto-create"
|
||||
@click="emit('retry-stp')"
|
||||
>
|
||||
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.autoProgress.retryStp') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="hasAction('validate')"
|
||||
type="button"
|
||||
:disabled="saving"
|
||||
:disabled="controlsBusy"
|
||||
class="inline-flex items-center gap-1 rounded bg-sky-600 px-3 py-2 text-sm text-white disabled:opacity-50"
|
||||
@click="emit('validate')"
|
||||
>
|
||||
@@ -175,7 +217,7 @@ function flowLabel(item: ActionPresentationItem): string {
|
||||
<button
|
||||
v-if="hasAction('confirm') && !hideConfirmBecauseAutoGate"
|
||||
type="button"
|
||||
:disabled="saving || !canConfirmBuild"
|
||||
:disabled="controlsBusy || !canConfirmBuild"
|
||||
class="rounded bg-emerald-600 px-3 py-2 text-sm font-medium text-white disabled:opacity-50"
|
||||
data-testid="review-confirm-create"
|
||||
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
|
||||
|
||||
+65
-17
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewWorkflowProgressPanel.spec.ts
|
||||
* 用途:订单处理台进度面板——紧凑五域条;人工入口仅 Gate 动作。
|
||||
* 用途:订单处理台进度面板——压缩 Strip;人工入口仅 Gate 动作。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n stub、RouterLink stub。
|
||||
* 逻辑:有 processingProjection 才渲染 ReviewProgressStrip;无页内 15 阶展开;manual upload 入口需 nextActionCode。
|
||||
* 逻辑:有 processingProjection 才渲染 ReviewProgressStrip;无五域芯片;manual upload 入口需 nextActionCode。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
ShippingProcessingProjection,
|
||||
ShippingReviewProgressContext,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { SHIPPING_PROCESSING_STAGES } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const messages = {
|
||||
en: {
|
||||
@@ -36,14 +37,12 @@ const messages = {
|
||||
completedOfTotal: '{done} of {total} done',
|
||||
remainingHint: '{count} remaining',
|
||||
positionOfTotal: '{current} / {total}',
|
||||
domainReceiveParse: 'Receive',
|
||||
domainCandidateIdentity: 'Candidate',
|
||||
domainOrderConfirm: 'Confirm',
|
||||
domainInventoryHandle: 'Inventory',
|
||||
domainFulfillmentShip: 'Ship',
|
||||
currentNeedLabel: 'Need: ',
|
||||
systemProcessingNeed: 'System processing',
|
||||
progressTitleWithStage: 'Order processing · {stage}',
|
||||
systemProcessingWithStage: 'System processing · {stage}',
|
||||
viewProcessDetails: 'View process details',
|
||||
viewFullProcess: 'View full process',
|
||||
stageNodesUnavailable: 'Progress details unavailable',
|
||||
},
|
||||
gateReasons: { generic: 'Needs action' },
|
||||
status: {
|
||||
@@ -51,10 +50,7 @@ const messages = {
|
||||
blocked: 'Blocked',
|
||||
processing: 'Processing',
|
||||
},
|
||||
stage: {
|
||||
freight_uploading: 'Uploading to freight',
|
||||
excel_generating: 'Generating Excel',
|
||||
},
|
||||
stage: Object.fromEntries(SHIPPING_PROCESSING_STAGES.map((s) => [s, s])),
|
||||
action: {
|
||||
refresh: 'Refresh',
|
||||
},
|
||||
@@ -72,6 +68,20 @@ const messages = {
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 构造含权威 15 阶的最小投影片段。
|
||||
*/
|
||||
function withStageNodes(
|
||||
partial: Partial<ShippingProcessingProjection>,
|
||||
): Partial<ShippingProcessingProjection> {
|
||||
const stageNodes = SHIPPING_PROCESSING_STAGES.map((stage, absoluteIndex) => ({
|
||||
stage,
|
||||
absoluteIndex,
|
||||
status: (absoluteIndex < 5 ? 'passed' : absoluteIndex === 5 ? 'running' : 'pending') as const,
|
||||
}));
|
||||
return { stageNodes, ...partial };
|
||||
}
|
||||
|
||||
/**
|
||||
* 挂载进度面板。
|
||||
*/
|
||||
@@ -81,12 +91,17 @@ function mountPanel(extras?: {
|
||||
processingProjection?: Partial<ShippingProcessingProjection> | null;
|
||||
}) {
|
||||
const i18n = createI18n({ legacy: false, locale: 'en', messages });
|
||||
const projection = extras?.processingProjection === null
|
||||
? null
|
||||
: extras?.processingProjection
|
||||
? withStageNodes(extras.processingProjection)
|
||||
: null;
|
||||
return mount(ReviewWorkflowProgressPanel, {
|
||||
props: {
|
||||
item: null as ShippingReviewProgressContext | null,
|
||||
taskNo: extras?.taskNo ?? 'SN-1',
|
||||
polling: extras?.polling ?? true,
|
||||
processingProjection: (extras?.processingProjection || null) as ShippingProcessingProjection | null,
|
||||
processingProjection: projection as ShippingProcessingProjection | null,
|
||||
},
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
@@ -109,21 +124,29 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders compact domain strip without inline 15-node expand', () => {
|
||||
it('renders compressed strip with 15 nodes and without domain chips', () => {
|
||||
const wrapper = mountPanel({
|
||||
polling: false,
|
||||
processingProjection: {
|
||||
status: 'processing',
|
||||
stage: 'excel_generating',
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
sourceType: 'eml',
|
||||
currentGate: {
|
||||
gateCode: 'order_review',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'confirm_customer',
|
||||
blockingReasonCode: 'generic',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-progress-unavailable"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-testid="review-progress-domains"] [data-domain]').length).toBe(5);
|
||||
expect(wrapper.find('[data-testid="review-progress-domains"]').exists()).toBe(false);
|
||||
expect(wrapper.findAll('[data-testid="review-progress-stage-nodes"] [data-stage]')).toHaveLength(15);
|
||||
expect(wrapper.find('[data-testid="review-progress-expand-full"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="unified-action-bar"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-open-details"]').exists()).toBe(true);
|
||||
expect(wrapper.get('[data-testid="review-progress-title"]').text()).toContain('Order processing');
|
||||
});
|
||||
|
||||
it('hides manual CTA while automating freight upload', () => {
|
||||
@@ -133,9 +156,13 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
status: 'automating',
|
||||
stage: 'freight_uploading',
|
||||
sourceType: 'eml',
|
||||
currentGate: null,
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
|
||||
expect(wrapper.get('[data-testid="review-progress-title"]').text()).toContain('System processing');
|
||||
expect(wrapper.find('[data-testid="review-progress-refresh"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-progress-current-need"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
|
||||
});
|
||||
@@ -178,5 +205,26 @@ describe('ReviewWorkflowProgressPanel', () => {
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-open-task-workbench"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-generic-next-steps"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('never renders generic next-steps for blocked non-upload gates', () => {
|
||||
const wrapper = mountPanel({
|
||||
polling: false,
|
||||
processingProjection: {
|
||||
status: 'blocked',
|
||||
stage: 'waiting_review',
|
||||
sourceType: 'eml',
|
||||
currentGate: {
|
||||
gateCode: 'order_review',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'confirm_customer',
|
||||
blockingReasonCode: 'generic',
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-progress-current-need"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-generic-next-steps"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-manual-upload-next-steps"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
+19
-92
@@ -1,8 +1,9 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewWorkflowProgressPanel.vue
|
||||
用途:订单处理工作台只读进度区(ReviewProgressStrip)+ Gate / 人工上传下一步提示。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、ReviewProgressStrip。
|
||||
逻辑:节点高亮只读统一投影;打开流程详情 / 刷新 emit 给宿主;写操作不在本面板。
|
||||
用途:订单处理工作台只读进度区外壳——挂载压缩版 ReviewProgressStrip + 人工上传入口。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、ReviewProgressStrip、shippingProcessingFulfillment。
|
||||
逻辑:标题与「当前需要」由 Strip 统一渲染;surface=review 永不渲染 review-generic-next-steps;
|
||||
仅人工上传保留任务台跳转;其他 Gate 只靠 Strip + Footer;写操作不在本面板。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
@@ -15,10 +16,6 @@ import type {
|
||||
import {
|
||||
projectionRequiresManualUploadWorkbench,
|
||||
} from '@/features/chat/shipping/shippingProcessingFulfillment';
|
||||
import {
|
||||
resolveShippingProcessingStatusLabel,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import ReviewProgressStrip from '@/features/shipping-progress/components/ReviewProgressStrip.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -34,52 +31,18 @@ const emit = defineEmits<{
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const { t } = useI18n();
|
||||
|
||||
const hasProjection = computed(() => Boolean(props.processingProjection));
|
||||
|
||||
const unifiedStatusLabel = computed(() => {
|
||||
const status = props.processingProjection?.status;
|
||||
if (!status) return '';
|
||||
return resolveShippingProcessingStatusLabel(status, te, t);
|
||||
});
|
||||
|
||||
const unifiedStageLabel = computed(() => {
|
||||
const stage = props.processingProjection?.stage;
|
||||
if (!stage) return '';
|
||||
const key = shippingProcessingStageKey(stage);
|
||||
return te(key) ? t(key) : stage;
|
||||
});
|
||||
|
||||
/**
|
||||
* 仅当 Gate next_action 明确指人工上传且非 RPA 阶段时展示任务台入口。
|
||||
* 仅当 Gate next_action 明确指人工上传且非 RPA 阶段时展示任务台入口(非纯文案重复)。
|
||||
*/
|
||||
const showTaskWorkbenchLink = computed(() => {
|
||||
if (!props.processingProjection) return false;
|
||||
if (!projectionRequiresManualUploadWorkbench(props.processingProjection)) return false;
|
||||
return Boolean(String(props.taskNo || '').trim());
|
||||
});
|
||||
|
||||
/**
|
||||
* blocked 且非人工上传时展示通用下一步提示(来自 Gate 动作 i18n)。
|
||||
*/
|
||||
const showGenericNextSteps = computed(() => {
|
||||
const projection = props.processingProjection;
|
||||
if (!projection || showTaskWorkbenchLink.value) return false;
|
||||
const nextAction = String(projection.currentGate?.nextActionCode || '').trim();
|
||||
if (!nextAction) return false;
|
||||
const status = String(projection.status || '').trim().toLowerCase();
|
||||
return status === 'blocked' || status === 'needs_action';
|
||||
});
|
||||
|
||||
const genericNextStepMessage = computed(() => {
|
||||
const code = String(props.processingProjection?.currentGate?.nextActionCode || '').trim();
|
||||
if (code) {
|
||||
const gateKey = `workspace.shippingNotice.processGate.actions.${code}`;
|
||||
if (te(gateKey)) return t(gateKey);
|
||||
}
|
||||
return t('chat.shippingOrderReview.workflowProgress.nextStepsGeneric');
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -87,50 +50,21 @@ const genericNextStepMessage = computed(() => {
|
||||
class="rounded-xl border border-default bg-surface-soft/60 p-3"
|
||||
data-testid="review-workflow-progress-panel"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.title') }}
|
||||
</div>
|
||||
<div
|
||||
v-if="hasProjection && (unifiedStatusLabel || unifiedStageLabel)"
|
||||
class="mt-0.5 text-[11px] text-secondary"
|
||||
data-testid="review-progress-unified-label"
|
||||
>
|
||||
<span v-if="unifiedStatusLabel">{{ unifiedStatusLabel }}</span>
|
||||
<span v-if="unifiedStageLabel"> · {{ unifiedStageLabel }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!hasProjection"
|
||||
class="mt-0.5 text-[11px] text-amber-700 dark:text-amber-300"
|
||||
data-testid="review-progress-unavailable"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.progressUnavailable') }}
|
||||
</div>
|
||||
<div v-else class="mt-0.5 text-[11px] text-secondary">
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.subtitle') }}
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
v-if="polling"
|
||||
class="shrink-0 text-[11px] text-muted"
|
||||
data-testid="review-workflow-progress-polling"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.polling') }}
|
||||
</span>
|
||||
<div
|
||||
v-if="!hasProjection"
|
||||
class="text-[11px] text-amber-700 dark:text-amber-300"
|
||||
data-testid="review-progress-unavailable"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.progressUnavailable') }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="processingProjection"
|
||||
class="mt-3"
|
||||
data-testid="review-progress-nodes"
|
||||
>
|
||||
<ReviewProgressStrip
|
||||
:projection="processingProjection"
|
||||
@open-process-details="emit('open-process-details')"
|
||||
@refresh="emit('refresh')"
|
||||
/>
|
||||
</div>
|
||||
<ReviewProgressStrip
|
||||
v-else-if="processingProjection"
|
||||
:projection="processingProjection"
|
||||
:polling="polling"
|
||||
@open-process-details="emit('open-process-details')"
|
||||
@refresh="emit('refresh')"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="showTaskWorkbenchLink"
|
||||
@@ -146,12 +80,5 @@ const genericNextStepMessage = computed(() => {
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.openTaskWorkbench') }}
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="showGenericNextSteps"
|
||||
class="mt-3 rounded-md border border-default bg-surface-soft px-2.5 py-2 text-[11px] text-secondary"
|
||||
data-testid="review-generic-next-steps"
|
||||
>
|
||||
<p>{{ genericNextStepMessage }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
+155
-42
@@ -1,8 +1,9 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingConversationProcessingCard.spec.ts
|
||||
* 用途:验收右侧任务分组卡——needs_action/processing 与短时反馈标签。
|
||||
* 用途:验收右侧任务分组卡——needs_action / processing / 处理记录三子段与动作层级。
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、ShippingConversationProcessingCard。
|
||||
* 逻辑:构造 ConversationProcessingProjection;断言分组、焦点 emit;右侧不渲染 history。
|
||||
* 逻辑:构造 ConversationProcessingProjection;断言分组文案、处理记录折叠与三类子段、
|
||||
* UI-02 单一详情入口、UI-03 history 截断角标、有 workItem 时无任务级主/次按钮。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -22,7 +23,7 @@ const i18n = createI18n({
|
||||
|
||||
function buildProjection(): ConversationProcessingProjection {
|
||||
return {
|
||||
summary: { total_tasks: 3, processing: 1, needs_action: 1, completed: 1, history: 0 },
|
||||
summary: { total_tasks: 3, processing: 1, needs_action: 1, completed: 1, history: 2 },
|
||||
focused_task_no: 'OT-PROC',
|
||||
recent_task_no: 'OT-PROC',
|
||||
needs_action: [{
|
||||
@@ -55,15 +56,28 @@ function buildProjection(): ConversationProcessingProjection {
|
||||
can_append: false,
|
||||
available_actions: ['view_details'],
|
||||
}],
|
||||
history: [{
|
||||
user_task_no: 'OT-HIST',
|
||||
group: 'history',
|
||||
status_label: 'completed',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-HIST',
|
||||
can_append: false,
|
||||
viewed: true,
|
||||
}],
|
||||
history: [
|
||||
{
|
||||
user_task_no: 'OT-HIST',
|
||||
group: 'history',
|
||||
status_label: 'completed',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-HIST',
|
||||
can_append: false,
|
||||
viewed: true,
|
||||
available_actions: ['view_details'],
|
||||
},
|
||||
{
|
||||
user_task_no: 'OT-CANCEL',
|
||||
group: 'history',
|
||||
status_label: 'cancelled',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-CANCEL',
|
||||
can_append: false,
|
||||
viewed: true,
|
||||
available_actions: ['view_details'],
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
|
||||
@@ -103,7 +117,7 @@ function buildWorkItem(
|
||||
}
|
||||
|
||||
describe('ShippingConversationProcessingCard', () => {
|
||||
it('renders needs_action / processing / completed groups, hides history on the right panel', async () => {
|
||||
it('renders needs_action / processing groups and collapsible processing records with three subsections', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection: buildProjection() },
|
||||
global: { plugins: [i18n] },
|
||||
@@ -113,18 +127,88 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-conversation-processing-card"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-needs_action"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-processing"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-completed"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('需要你处理 · 1 个任务');
|
||||
expect(wrapper.text()).toContain('系统处理中 · 1 个任务');
|
||||
expect(wrapper.text()).toContain('刚刚创建');
|
||||
expect(wrapper.text()).toContain('已完成');
|
||||
// UI-04:右侧不展示处理记录分组。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-history"]').exists()).toBe(false);
|
||||
|
||||
// 处理记录默认折叠;标题 count = completed + history 返回条数。
|
||||
const historyGroup = wrapper.find('[data-testid="shipping-processing-group-history"]');
|
||||
expect(historyGroup.exists()).toBe(true);
|
||||
expect(historyGroup.text()).toContain('处理记录 · 3');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-body"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-HIST"]').exists()).toBe(false);
|
||||
|
||||
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-body"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-completed"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-versions"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-cancelled"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-HIST"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-CANCEL"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-completed"]').text()).toContain('已完成');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-versions"]').text()).toContain('历史版本');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-cancelled"]').text()).toContain('已取消');
|
||||
});
|
||||
|
||||
it('renders multi-PDF task title instead of first filename', async () => {
|
||||
it('shows history more badge when summary.history exceeds returned history length', async () => {
|
||||
const projection = buildProjection();
|
||||
projection.summary.history = 14;
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// UI-03:折叠态即可看到「还有 N 条」。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-more"]').text()).toContain('还有 12 条');
|
||||
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-truncated"]').text())
|
||||
.toContain('仅展示最近 2 条,另有 12 条未显示');
|
||||
});
|
||||
|
||||
it('falls back to generic truncated hint when hasMoreHistory but no reliable hidden count', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: buildProjection(),
|
||||
hasMoreHistory: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-more"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-processing-history-truncated"]').text())
|
||||
.toContain('列表已截断,仅展示最近任务');
|
||||
});
|
||||
|
||||
it('keeps processing-record cards read-only without primary CTA or progress', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: buildProjection(),
|
||||
workItems: [
|
||||
buildWorkItem('OT-DONE', { status: 'completed', stage: 'completed' }),
|
||||
],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
const doneCard = wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]');
|
||||
expect(doneCard.find('[data-testid="sidebar-progress-inline"]').exists()).toBe(false);
|
||||
expect(doneCard.find('[data-testid="shipping-processing-task-actions"]').exists()).toBe(false);
|
||||
expect(doneCard.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
|
||||
expect(doneCard.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses expand-files as the only detail entry when canExpandFileDetails', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
@@ -151,12 +235,49 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
await flushPromises();
|
||||
expect(wrapper.text()).toContain('订单识别任务');
|
||||
expect(wrapper.text()).toContain('2 个 PDF');
|
||||
expect(wrapper.text()).toContain('4518838152.pdf、4518838154.pdf');
|
||||
expect(wrapper.text()).toContain('取消整个任务');
|
||||
// 主标题不得单独伪装成首个 PDF 文件名任务。
|
||||
expect(wrapper.text()).toContain('主文件:4518838152.pdf');
|
||||
const titleEl = wrapper.find('[data-testid="shipping-processing-task-OT-MULTI"] .text-sm.font-semibold');
|
||||
expect(titleEl.text()).toContain('订单识别任务');
|
||||
expect(titleEl.text()).not.toContain('4518838152.pdf');
|
||||
|
||||
// UI-02:有文件对象时不双开「查看详情」与「展开文件详情」。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
|
||||
await wrapper.find('[data-testid="shipping-processing-expand-files"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').text()).toContain('取消整个任务');
|
||||
});
|
||||
|
||||
it('shows view_details when task cannot expand file details, and keeps cancel as overflow', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, processing: 0, needs_action: 1, completed: 0, history: 0 },
|
||||
needs_action: [{
|
||||
user_task_no: 'OT-SINGLE',
|
||||
group: 'needs_action',
|
||||
status_label: 'pending_review',
|
||||
file_count: 1,
|
||||
run_no: 'RUN-SINGLE',
|
||||
can_append: false,
|
||||
available_actions: ['view_details', 'cancel_task'],
|
||||
objects: [],
|
||||
}],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
|
||||
// 无文件对象时取消可直接挂在卡上(低频文字链,非主 CTA)。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('shows multi-document title from authoritative projection without workflow fallback', async () => {
|
||||
@@ -192,7 +313,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(titleEl.text()).not.toContain('4518838152.pdf');
|
||||
});
|
||||
|
||||
it('falls back to unnamed PDF instead of internal OT number', async () => {
|
||||
it('uses unified order recognition title instead of internal OT number', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
@@ -214,7 +335,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.text()).toContain('未命名 PDF');
|
||||
expect(wrapper.text()).toContain('订单识别任务');
|
||||
expect(wrapper.text()).not.toContain('20260803-A13F95D2');
|
||||
});
|
||||
|
||||
@@ -242,7 +363,6 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
});
|
||||
await flushPromises();
|
||||
const needCard = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
|
||||
// 关键断言:待操作聚焦卡必须有用户可见 ring,不能只写 data-focused。
|
||||
expect(needCard.attributes('data-focused')).toBe('1');
|
||||
expect(needCard.classes().join(' ')).toContain('ring-brand-400');
|
||||
const other = wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]');
|
||||
@@ -264,12 +384,10 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
const taskRoot = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
|
||||
const buttons = taskRoot.findAll('button');
|
||||
// 最后一个按钮是展开/收起文件详情
|
||||
await buttons[buttons.length - 1].trigger('click');
|
||||
const expandBtn = wrapper.find('[data-testid="shipping-processing-expand-files"]');
|
||||
await expandBtn.trigger('click');
|
||||
expect(wrapper.emitted('expandFiles')?.[0]?.[0]).toMatchObject({ user_task_no: 'OT-NEED' });
|
||||
await buttons[buttons.length - 1].trigger('click');
|
||||
await expandBtn.trigger('click');
|
||||
expect(wrapper.emitted('collapseFiles')).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -294,7 +412,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
expect(wrapper.findAll('[data-testid^="shipping-processing-task-"]')).toHaveLength(20);
|
||||
expect(wrapper.findAll('article[data-testid^="shipping-processing-task-"]')).toHaveLength(20);
|
||||
expect(wrapper.findAll('[data-testid="shipping-conversation-processing-card"]')).toHaveLength(1);
|
||||
});
|
||||
|
||||
@@ -344,7 +462,6 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-processing-group-order-intake"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-intake-SNI-1"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('po.pdf');
|
||||
// 关键断言:失败恢复元信息(原因 / Attempt / 资产)出现在材料卡。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-intake-recovery"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('SHIPPING_NOTICE.INTAKE_PARSE_FAILED');
|
||||
await wrapper.find('[data-testid="shipping-processing-intake-action-retry_parse"]').trigger('click');
|
||||
@@ -354,7 +471,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('renders each PDF task with its own compact projection, including completed tasks', async () => {
|
||||
it('hides task-level primary/secondary when workItem exists but keeps expand-files entry', async () => {
|
||||
const projection = buildProjection();
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
@@ -367,23 +484,19 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
buildWorkItem('OT-PROC', {
|
||||
stage: 'inventory_matching',
|
||||
}),
|
||||
buildWorkItem('OT-DONE', {
|
||||
status: 'completed',
|
||||
stage: 'completed',
|
||||
}),
|
||||
],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 未聚焦时:needs_action/processing 显示紧凑进度;已完成默认收起(UI-05)。
|
||||
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(2);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"] [data-testid="sidebar-progress-inline"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').text()).toContain('待复核');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').text()).toContain('库存匹配');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]').text()).toContain('已完成');
|
||||
expect(wrapper.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
|
||||
// UI-02:有 workItem 时仍保留展开文件详情(OT-NEED 为多文件)。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('maps internal review_case_draft status to a user-facing review label', async () => {
|
||||
|
||||
+427
-203
@@ -1,15 +1,16 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingConversationProcessingCard.vue
|
||||
* 用途:右侧「本次处理中」顶层任务卡——按 needs_action / processing / completed 展示。
|
||||
* 用途:右侧「本次处理中」顶层任务卡——needs_action / processing / 处理记录。
|
||||
* 依赖:vue-i18n、ConversationProcessingProjection、conversationProcessingState、
|
||||
* shippingProcessingLabels、SidebarProgressInline。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems,禁止 Workflow fallback;
|
||||
* 单 PDF 主标题用文件名,多 PDF 用「订单识别任务」;右侧不渲染 history;
|
||||
* 仅聚焦卡展开完整 SidebarProgressInline,未聚焦显示紧凑单行,已完成默认收起(UI-05);
|
||||
* 单 PDF 不展示「展开文件详情」。
|
||||
* conversationProcessingDisplay、actionPresentation、shippingProcessingLabels、SidebarProgressInline。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems;
|
||||
* 统一「订单识别任务」+ 主文件副标题;处理记录默认折叠(已完成/历史版本/已取消);
|
||||
* UI-02:有文件对象时次要入口仅为「展开文件详情」,无文件对象时才「查看详情」;
|
||||
* 有 workItem 时不渲染任务级主/次按钮,仍可保留展开文件入口;
|
||||
* UI-03:history 截断时折叠标题显示「还有 N 条」,展开底部显示明细截断文案。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, watch } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
|
||||
import type {
|
||||
@@ -17,6 +18,7 @@ import type {
|
||||
ConversationProcessingUserTask,
|
||||
ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { getPrimaryDocumentName } from '@/features/chat/shipping/conversationProcessingDisplay';
|
||||
import {
|
||||
createConversationProcessingUiState,
|
||||
focusTaskManually,
|
||||
@@ -32,8 +34,9 @@ import {
|
||||
shippingProcessingSourceTypeKey,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveConversationTaskActionPresentation } from '@/features/shipping-progress/actionPresentation';
|
||||
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
|
||||
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
|
||||
const props = defineProps<{
|
||||
projection: ConversationProcessingProjection | null;
|
||||
@@ -41,6 +44,8 @@ const props = defineProps<{
|
||||
workItems?: ShippingProcessingProjection[] | null;
|
||||
/** 当前会话 ID;切换时重置本地焦点/展开状态 */
|
||||
conversationId?: string | null;
|
||||
/** 后端截断提示:history 还有未返回内容时在处理记录底部展示 */
|
||||
hasMoreHistory?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -60,6 +65,8 @@ const emit = defineEmits<{
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const uiState = createConversationProcessingUiState();
|
||||
/** 处理记录整组默认折叠。 */
|
||||
const historySectionExpanded = ref(false);
|
||||
|
||||
/** 唯一进度源:统一 conversation_processing / work_items 合成投影。 */
|
||||
const activeProjection = computed((): ConversationProcessingProjection | null => (
|
||||
@@ -81,6 +88,31 @@ const hasContent = computed(() => Boolean(
|
||||
));
|
||||
|
||||
const completedTasks = computed(() => activeProjection.value?.completed || []);
|
||||
const historyTasks = computed(() => activeProjection.value?.history || []);
|
||||
|
||||
/** history 中非取消 →「历史版本」。 */
|
||||
const historyVersionTasks = computed(() => historyTasks.value.filter(
|
||||
(task) => String(task.status_label || '').trim().toLowerCase() !== 'cancelled',
|
||||
));
|
||||
|
||||
/** history 中明确 cancelled →「已取消」。 */
|
||||
const cancelledHistoryTasks = computed(() => historyTasks.value.filter(
|
||||
(task) => String(task.status_label || '').trim().toLowerCase() === 'cancelled',
|
||||
));
|
||||
|
||||
/** 处理记录标题计数:当前返回的 completed + history。 */
|
||||
const recordTaskCount = computed(() => (
|
||||
completedTasks.value.length + historyTasks.value.length
|
||||
));
|
||||
|
||||
/**
|
||||
* history 未返回条数:summary.history - 当前 history[];不可靠时为 0(不猜数)。
|
||||
*/
|
||||
const hiddenHistoryCount = computed(() => {
|
||||
const summaryTotal = Number(activeProjection.value?.summary?.history || 0);
|
||||
if (!Number.isFinite(summaryTotal) || summaryTotal <= 0) return 0;
|
||||
return Math.max(0, summaryTotal - historyTasks.value.length);
|
||||
});
|
||||
|
||||
const focusedTaskNo = computed(() => resolveFocusedTask(uiState, {
|
||||
serverFocusedTaskNo: activeProjection.value?.focused_task_no,
|
||||
@@ -106,6 +138,7 @@ watch(
|
||||
(next, prev) => {
|
||||
if (next === prev) return;
|
||||
resetConversationProcessingUiState(uiState);
|
||||
historySectionExpanded.value = false;
|
||||
},
|
||||
);
|
||||
|
||||
@@ -151,48 +184,35 @@ function isMultiDocumentTask(task: ConversationProcessingUserTask): boolean {
|
||||
function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
|
||||
if (isMultiDocumentTask(task)) return true;
|
||||
const objects = Array.isArray(task.objects) ? task.objects : [];
|
||||
return objects.length > 1;
|
||||
return objects.length > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* UI-05:仅聚焦且非已完成卡展开完整进度;未聚焦显示紧凑单行;已完成默认不展进度。
|
||||
* 活跃卡进度:聚焦全量 / 未聚焦紧凑;处理记录(completed/history)永不展实时进度。
|
||||
*/
|
||||
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
|
||||
if (!projectionForTask(task)) return 'hidden';
|
||||
const group = String(task.group || '').trim();
|
||||
if (group === 'completed' || group === 'history') return 'hidden';
|
||||
const focused = focusedTaskNo.value === task.user_task_no;
|
||||
const completed = String(task.group || '').trim() === 'completed'
|
||||
|| String(task.status_label || '').trim().toLowerCase() === 'completed';
|
||||
if (completed && !focused) return 'hidden';
|
||||
if (focused) return 'full';
|
||||
return 'compact';
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务主标题:单 PDF 用文件名;多 PDF 用 i18n「订单识别任务」;禁止 OT/Run 编号。
|
||||
* 任务主标题:统一「订单识别任务」;禁止用 filename / task.title / OT 编号。
|
||||
*/
|
||||
function taskLabel(task: ConversationProcessingUserTask): string {
|
||||
if (isMultiDocumentTask(task)) {
|
||||
return t('chat.shippingProcessing.multiPdfTaskTitle');
|
||||
}
|
||||
const title = String(task.title || '').trim();
|
||||
if (title) return title;
|
||||
return t('chat.shippingProcessing.unnamedPdf');
|
||||
function taskLabel(_task: ConversationProcessingUserTask): string {
|
||||
return t('chat.shippingProcessing.multiPdfTaskTitle');
|
||||
}
|
||||
|
||||
/**
|
||||
* 多 PDF 副标题:前两个文件名;超过两个时追加「等 N 个 PDF」。
|
||||
* 主文件副标题:有主文件名时渲染「主文件:{name}」。
|
||||
*/
|
||||
function documentNamesPreview(task: ConversationProcessingUserTask): string {
|
||||
const names = (Array.isArray(task.document_names) ? task.document_names : [])
|
||||
.map((name) => String(name || '').trim())
|
||||
.filter(Boolean);
|
||||
if (names.length <= 1) return '';
|
||||
const head = names.slice(0, 2).join(t('chat.shippingProcessing.multiPdfNameSeparator'));
|
||||
if (names.length === 2) return head;
|
||||
return t('chat.shippingProcessing.multiPdfNamesMore', {
|
||||
names: head,
|
||||
count: names.length,
|
||||
});
|
||||
function primaryFileLabel(task: ConversationProcessingUserTask): string {
|
||||
const name = getPrimaryDocumentName(task);
|
||||
if (!name) return '';
|
||||
return t('chat.shippingProcessing.primaryFile', { name });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,32 +234,6 @@ function statusLabel(task: ConversationProcessingUserTask): string {
|
||||
return resolveShippingProcessingStatusLabel(String(task.status_label || ''), te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* 最近活动时间:当天仅时分;昨天带「昨天」;更早带月日。
|
||||
*/
|
||||
function activityLabel(task: ConversationProcessingUserTask): string {
|
||||
const raw = String(task.last_activity_at || '').trim();
|
||||
if (!raw) return '';
|
||||
const date = new Date(raw);
|
||||
if (Number.isNaN(date.getTime())) return '';
|
||||
const hh = String(date.getHours()).padStart(2, '0');
|
||||
const mm = String(date.getMinutes()).padStart(2, '0');
|
||||
const time = `${hh}:${mm}`;
|
||||
const now = new Date();
|
||||
const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate());
|
||||
const startOfTarget = new Date(date.getFullYear(), date.getMonth(), date.getDate());
|
||||
const dayDiff = Math.round((startOfToday.getTime() - startOfTarget.getTime()) / 86400000);
|
||||
if (dayDiff === 0) {
|
||||
return t('chat.shippingProcessing.updatedAt', { time });
|
||||
}
|
||||
if (dayDiff === 1) {
|
||||
return t('chat.shippingProcessing.updatedYesterday', { time });
|
||||
}
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
return t('chat.shippingProcessing.updatedOnDate', { date: `${month}-${day}`, time });
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否高亮 needs_action 任务。
|
||||
*/
|
||||
@@ -258,81 +252,141 @@ function isDetailsExpanded(task: ConversationProcessingUserTask): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务级可见操作:只展示后端权威动作中的业务入口。
|
||||
* 解析任务卡 ActionPresentation(cancel/view_details 不作主 CTA)。
|
||||
*/
|
||||
function visibleTaskActions(task: ConversationProcessingUserTask): string[] {
|
||||
const actions = Array.isArray(task.available_actions) ? task.available_actions : [];
|
||||
const preferred = [
|
||||
'view_details',
|
||||
'open_review',
|
||||
'enter_manual_review',
|
||||
'retry_failed_documents',
|
||||
'retry_failed_attachments',
|
||||
'cancel_task',
|
||||
'cancel_run',
|
||||
];
|
||||
const seen = new Set<string>();
|
||||
const result: string[] = [];
|
||||
for (const code of preferred) {
|
||||
if (!actions.includes(code) || seen.has(code)) continue;
|
||||
// 别名去重:只保留一套展示
|
||||
if (code === 'open_review' && seen.has('enter_manual_review')) continue;
|
||||
if (code === 'enter_manual_review' && seen.has('open_review')) continue;
|
||||
if (code === 'retry_failed_documents' && seen.has('retry_failed_attachments')) continue;
|
||||
if (code === 'retry_failed_attachments' && seen.has('retry_failed_documents')) continue;
|
||||
if (code === 'cancel_task' && seen.has('cancel_run')) continue;
|
||||
if (code === 'cancel_run' && seen.has('cancel_task')) continue;
|
||||
seen.add(code);
|
||||
result.push(code);
|
||||
}
|
||||
return result;
|
||||
function taskActionPresentation(task: ConversationProcessingUserTask): ActionPresentation {
|
||||
return resolveConversationTaskActionPresentation(task, { surface: 'right' });
|
||||
}
|
||||
|
||||
/**
|
||||
* 动作按钮文案:任务级取消在多 PDF 时明确为「取消整个任务」。
|
||||
* 唯一主 CTA(实心按钮);处理记录只读卡不调用。
|
||||
*/
|
||||
function actionLabel(task: ConversationProcessingUserTask, action: string): string {
|
||||
const code = String(action || '').trim();
|
||||
function primaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||||
return taskActionPresentation(task).primary;
|
||||
}
|
||||
|
||||
/**
|
||||
* 次要文字链:有文件对象时可展开 → 不返回 view_details(改由展开文件入口承载);
|
||||
* 无文件对象时优先 view_details,否则取非 cancel 的 presentation.secondary。
|
||||
*/
|
||||
function secondaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||||
if (canExpandFileDetails(task)) return null;
|
||||
const presentation = taskActionPresentation(task);
|
||||
const candidates = [
|
||||
presentation.secondary,
|
||||
...presentation.overflow,
|
||||
].filter((item): item is ActionPresentationItem => Boolean(item));
|
||||
const viewDetails = candidates.find(
|
||||
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
|
||||
);
|
||||
if (viewDetails) return viewDetails;
|
||||
const secondary = presentation.secondary;
|
||||
if (!secondary) return null;
|
||||
const code = String(secondary.actionCode || '').trim().toLowerCase();
|
||||
if (code === 'cancel_task' || code === 'cancel_run' || code === 'view_details') return null;
|
||||
return secondary;
|
||||
}
|
||||
|
||||
/**
|
||||
* 低频溢出动作:排除已展示的主/次 CTA 与 view_details。
|
||||
*/
|
||||
function overflowActionItems(task: ConversationProcessingUserTask): ActionPresentationItem[] {
|
||||
const presentation = taskActionPresentation(task);
|
||||
const shown = new Set(
|
||||
[primaryActionItem(task)?.actionCode, secondaryActionItem(task)?.actionCode]
|
||||
.map((code) => String(code || '').trim().toLowerCase())
|
||||
.filter(Boolean),
|
||||
);
|
||||
shown.add('view_details');
|
||||
return [presentation.secondary, ...presentation.overflow]
|
||||
.filter((item): item is ActionPresentationItem => Boolean(item))
|
||||
.filter((item) => {
|
||||
const code = String(item.actionCode || '').trim().toLowerCase();
|
||||
return Boolean(code) && !shown.has(code);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否展示低频溢出:有文件对象时仅展开后显示;无文件对象时直接挂在卡上(如取消)。
|
||||
* 有 workItem 时不渲染任务级溢出(动作由进度条负责)。
|
||||
*/
|
||||
function shouldShowOverflowActions(task: ConversationProcessingUserTask): boolean {
|
||||
if (projectionForTask(task)) return false;
|
||||
if (!overflowActionItems(task).length) return false;
|
||||
if (canExpandFileDetails(task)) return isDetailsExpanded(task);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否渲染任务级主/次动作区(不含「展开文件详情」文件控制)。
|
||||
*/
|
||||
function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boolean {
|
||||
if (projectionForTask(task)) return false;
|
||||
return Boolean(primaryActionItem(task) || secondaryActionItem(task));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理记录只读卡:仅保留 view_details 文字链(无主 CTA / 取消 / 重解析)。
|
||||
*/
|
||||
function recordViewDetailsItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||||
const presentation = taskActionPresentation(task);
|
||||
const candidates = [
|
||||
presentation.primary,
|
||||
presentation.secondary,
|
||||
...presentation.overflow,
|
||||
].filter((item): item is ActionPresentationItem => Boolean(item));
|
||||
return candidates.find(
|
||||
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
|
||||
) || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 动作按钮文案:优先 presentation labelKey;多 PDF 取消明确为「取消整个任务」。
|
||||
*/
|
||||
function presentationActionLabel(task: ConversationProcessingUserTask, item: ActionPresentationItem): string {
|
||||
const code = String(item.actionCode || '').trim();
|
||||
if (
|
||||
(code === 'cancel_task' || code === 'cancel_run')
|
||||
&& isMultiDocumentTask(task)
|
||||
) {
|
||||
return t('chat.shippingProcessing.cancelEntireTask');
|
||||
}
|
||||
if (code === 'cancel_task' || code === 'cancel_run') {
|
||||
return t('chat.shippingProcessing.cancelEntireTaskSingle');
|
||||
}
|
||||
const key = String(item.labelKey || '').trim();
|
||||
if (key && te(key)) return t(key);
|
||||
const extractionKey = `chat.shippingOrderExtractionAction.${code}`;
|
||||
if (te(extractionKey)) return t(extractionKey);
|
||||
const aliases: Record<string, string> = {
|
||||
open_review: 'chat.shippingOrderExtractionAction.enter_manual_review',
|
||||
retry_failed_documents: 'chat.shippingOrderExtractionAction.retry_failed_attachments',
|
||||
};
|
||||
const alias = aliases[code];
|
||||
if (alias && te(alias)) return t(alias);
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行任务级动作:view_details 展开文件;其余交给父级。
|
||||
* 执行任务级动作:view_details / focus_task 本地聚焦;其余交给父级。
|
||||
* 非权威任务号禁止向后端 focus/viewed 写接口。
|
||||
*/
|
||||
function onTaskAction(task: ConversationProcessingUserTask, action: string) {
|
||||
const code = String(action || '').trim();
|
||||
if (!code) return;
|
||||
if (code === 'view_details') {
|
||||
focusTaskManually(uiState, task.user_task_no, { expandDetails: true });
|
||||
markTaskViewed(uiState, task.user_task_no);
|
||||
emit('expandFiles', task);
|
||||
if (code === 'view_details' || code === 'focus_task') {
|
||||
focusTaskManually(uiState, task.user_task_no, { expandDetails: code === 'view_details' });
|
||||
if (code === 'view_details') {
|
||||
markTaskViewed(uiState, task.user_task_no);
|
||||
emit('expandFiles', task);
|
||||
}
|
||||
if (task.user_task_authoritative !== false) {
|
||||
emit('focus', task.user_task_no);
|
||||
emit('viewed', task.user_task_no);
|
||||
if (code === 'view_details') emit('viewed', task.user_task_no);
|
||||
}
|
||||
return;
|
||||
}
|
||||
emit('taskAction', { task, action: code });
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换处理记录整组折叠。
|
||||
*/
|
||||
function toggleHistorySection() {
|
||||
historySectionExpanded.value = !historySectionExpanded.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Intake 材料标题:文件名 / 邮件主题 / Intake 编号。
|
||||
*/
|
||||
@@ -516,14 +570,13 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
<span v-if="activityLabel(task)">{{ activityLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="documentNamesPreview(task)"
|
||||
v-if="primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-document-names"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ documentNamesPreview(task) }}
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="task.recent_append_count"
|
||||
@@ -546,25 +599,47 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||||
/>
|
||||
<div
|
||||
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
v-if="shouldShowTaskLevelActions(task) || (!projectionForTask(task) && canExpandFileDetails(task))"
|
||||
class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
<button
|
||||
v-for="action in visibleTaskActions(task)"
|
||||
:key="`${task.user_task_no}-${action}`"
|
||||
v-if="!projectionForTask(task) && primaryActionItem(task)"
|
||||
type="button"
|
||||
class="rounded-md border border-default bg-surface px-2 py-0.5 text-[11px] text-secondary hover:text-primary"
|
||||
:data-testid="`shipping-processing-action-${action}`"
|
||||
@click="onTaskAction(task, action)"
|
||||
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
|
||||
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
|
||||
>
|
||||
{{ actionLabel(task, action) }}
|
||||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
<ChevronRight v-else class="h-3 w-3" />
|
||||
{{ isDetailsExpanded(task)
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="secondaryActionItem(task)"
|
||||
type="button"
|
||||
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
v-else-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="mt-1.5 flex items-center gap-1 text-[11px] text-secondary hover:text-primary"
|
||||
class="mt-1.5 inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
@@ -573,6 +648,22 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
<div
|
||||
v-if="shouldShowOverflowActions(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
|
||||
data-testid="shipping-processing-task-overflow-actions"
|
||||
>
|
||||
<button
|
||||
v-for="item in overflowActionItems(task)"
|
||||
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
|
||||
type="button"
|
||||
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${item.actionCode}`"
|
||||
@click="onTaskAction(task, item.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, item) }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
@@ -606,14 +697,13 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
<span v-if="activityLabel(task)">{{ activityLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="documentNamesPreview(task)"
|
||||
v-if="primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-document-names"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ documentNamesPreview(task) }}
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="task.recent_append_count"
|
||||
@@ -636,25 +726,47 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||||
/>
|
||||
<div
|
||||
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
v-if="shouldShowTaskLevelActions(task) || (!projectionForTask(task) && canExpandFileDetails(task))"
|
||||
class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
<button
|
||||
v-for="action in visibleTaskActions(task)"
|
||||
:key="`${task.user_task_no}-${action}`"
|
||||
v-if="!projectionForTask(task) && primaryActionItem(task)"
|
||||
type="button"
|
||||
class="rounded-md border border-default bg-surface px-2 py-0.5 text-[11px] text-secondary hover:text-primary"
|
||||
:data-testid="`shipping-processing-action-${action}`"
|
||||
@click="onTaskAction(task, action)"
|
||||
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
|
||||
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
|
||||
>
|
||||
{{ actionLabel(task, action) }}
|
||||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
<ChevronRight v-else class="h-3 w-3" />
|
||||
{{ isDetailsExpanded(task)
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="secondaryActionItem(task)"
|
||||
type="button"
|
||||
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
|
||||
</button>
|
||||
</div>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
v-else-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="mt-1.5 flex items-center gap-1 text-[11px] text-secondary hover:text-primary"
|
||||
class="mt-1.5 inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
data-testid="shipping-processing-expand-files"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
@@ -663,85 +775,197 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
<div
|
||||
v-if="shouldShowOverflowActions(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
|
||||
data-testid="shipping-processing-task-overflow-actions"
|
||||
>
|
||||
<button
|
||||
v-for="item in overflowActionItems(task)"
|
||||
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
|
||||
type="button"
|
||||
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${item.actionCode}`"
|
||||
@click="onTaskAction(task, item.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, item) }}
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="completedTasks.length"
|
||||
data-testid="shipping-processing-group-completed"
|
||||
v-if="recordTaskCount > 0"
|
||||
data-testid="shipping-processing-group-history"
|
||||
>
|
||||
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-emerald-700 dark:text-emerald-300">
|
||||
{{ resolveShippingProcessingMessage('groupCompleted', te, t, { count: completedTasks.length }) }}
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in completedTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-default bg-surface px-2.5 py-2"
|
||||
:class="focusedTaskNo === task.user_task_no
|
||||
? 'ring-1 ring-brand-400'
|
||||
: ''"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
|
||||
<button
|
||||
type="button"
|
||||
class="mb-1.5 flex w-full items-center justify-between gap-2 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-300"
|
||||
data-testid="shipping-processing-history-toggle"
|
||||
@click="toggleHistorySection"
|
||||
>
|
||||
<span class="inline-flex min-w-0 items-center gap-1">
|
||||
<ChevronDown v-if="historySectionExpanded" class="h-3 w-3 shrink-0" />
|
||||
<ChevronRight v-else class="h-3 w-3 shrink-0" />
|
||||
<span>{{ resolveShippingProcessingMessage('groupProcessingRecords', te, t, { count: recordTaskCount }) }}</span>
|
||||
</span>
|
||||
<span
|
||||
v-if="hiddenHistoryCount > 0"
|
||||
class="shrink-0 font-medium normal-case tracking-normal text-muted"
|
||||
data-testid="shipping-processing-history-more"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="w-full text-left"
|
||||
@click="onSelectTask(task)"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
<span v-if="activityLabel(task)">{{ activityLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="documentNamesPreview(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-document-names"
|
||||
>
|
||||
{{ documentNamesPreview(task) }}
|
||||
</div>
|
||||
</button>
|
||||
<SidebarProgressInline
|
||||
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||||
:projection="projectionForTask(task)!"
|
||||
:compact="progressModeForTask(task) === 'compact'"
|
||||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||||
/>
|
||||
<div
|
||||
v-if="visibleTaskActions(task).length && !projectionForTask(task)"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5"
|
||||
data-testid="shipping-processing-task-actions"
|
||||
>
|
||||
<button
|
||||
v-for="action in visibleTaskActions(task)"
|
||||
:key="`${task.user_task_no}-${action}`"
|
||||
type="button"
|
||||
class="rounded-md border border-default bg-surface px-2 py-0.5 text-[11px] text-secondary hover:text-primary"
|
||||
:data-testid="`shipping-processing-action-${action}`"
|
||||
@click="onTaskAction(task, action)"
|
||||
>
|
||||
{{ actionLabel(task, action) }}
|
||||
</button>
|
||||
{{ t('chat.shippingProcessing.historyMoreCount', { count: hiddenHistoryCount }) }}
|
||||
</span>
|
||||
</button>
|
||||
<div
|
||||
v-if="historySectionExpanded"
|
||||
class="space-y-3"
|
||||
data-testid="shipping-processing-history-body"
|
||||
>
|
||||
<div
|
||||
v-if="completedTasks.length"
|
||||
data-testid="shipping-processing-history-completed"
|
||||
>
|
||||
<div class="mb-1 text-[11px] font-medium text-emerald-700 dark:text-emerald-300">
|
||||
{{ resolveShippingProcessingMessage('groupRecordCompleted', te, t) }}
|
||||
</div>
|
||||
<button
|
||||
v-if="canExpandFileDetails(task)"
|
||||
type="button"
|
||||
class="mt-1.5 flex items-center gap-1 text-[11px] text-secondary hover:text-primary"
|
||||
@click="onToggleDetails(task)"
|
||||
>
|
||||
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
|
||||
<ChevronRight v-else class="h-3 w-3" />
|
||||
{{ isDetailsExpanded(task)
|
||||
? t('chat.shippingProcessing.collapseFileDetails')
|
||||
: t('chat.shippingProcessing.expandFileDetails') }}
|
||||
</button>
|
||||
</article>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in completedTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
data-record="1"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<button
|
||||
v-if="recordViewDetailsItem(task)"
|
||||
type="button"
|
||||
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="historyVersionTasks.length"
|
||||
data-testid="shipping-processing-history-versions"
|
||||
>
|
||||
<div class="mb-1 text-[11px] font-medium text-slate-600 dark:text-slate-300">
|
||||
{{ resolveShippingProcessingMessage('groupRecordHistoryVersions', te, t) }}
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in historyVersionTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
data-record="1"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<button
|
||||
v-if="recordViewDetailsItem(task)"
|
||||
type="button"
|
||||
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="cancelledHistoryTasks.length"
|
||||
data-testid="shipping-processing-history-cancelled"
|
||||
>
|
||||
<div class="mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400">
|
||||
{{ resolveShippingProcessingMessage('groupRecordCancelled', te, t) }}
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<article
|
||||
v-for="task in cancelledHistoryTasks"
|
||||
:key="task.user_task_no"
|
||||
class="rounded-lg border border-dashed border-default bg-surface/60 px-2.5 py-2 opacity-90"
|
||||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||||
data-record="1"
|
||||
>
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||||
</div>
|
||||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
<span>{{ statusLabel(task) }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="primaryFileLabel(task)"
|
||||
class="mt-0.5 truncate text-[11px] text-muted"
|
||||
data-testid="shipping-processing-task-primary-file"
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<button
|
||||
v-if="recordViewDetailsItem(task)"
|
||||
type="button"
|
||||
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||||
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
|
||||
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
|
||||
>
|
||||
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
|
||||
</button>
|
||||
</article>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="hiddenHistoryCount > 0"
|
||||
class="text-[11px] text-muted"
|
||||
data-testid="shipping-processing-history-truncated"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.historyTruncatedDetail', {
|
||||
shown: historyTasks.length,
|
||||
hidden: hiddenHistoryCount,
|
||||
}) }}
|
||||
</div>
|
||||
<div
|
||||
v-else-if="hasMoreHistory"
|
||||
class="text-[11px] text-muted"
|
||||
data-testid="shipping-processing-history-truncated"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
+104
-146
@@ -1,18 +1,15 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.spec.ts
|
||||
* 用途:覆盖批次进度卡摘要、阶段、健康提醒与刷新/取消/重试动作。
|
||||
* 用途:覆盖对话区订单识别摘要卡——标题、状态行、handling 一行摘要、唯一主 CTA、查看详情。
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、本域组件与 DTO 类型。
|
||||
* 逻辑:断言过程通知、摘要计数、取消确认与重试;逐 PDF 深链仍由右侧面板承担。
|
||||
* 逻辑:断言不再渲染进度列表/刷新取消/完整 handling 卡片;失败重试与需处理继续处理互斥。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { ref } from 'vue';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import chatZhCn from '@/locales/zh-CN/chat.json';
|
||||
import ShippingOrderExtractionCard from './ShippingOrderExtractionCard.vue';
|
||||
import type { ShippingOrderExtractionState } from '../../types/chat.types';
|
||||
import type { ShippingProcessingProjection } from '../../types/shipping.api.types';
|
||||
import { SHIPPING_WORKFLOW_KEY } from '../../shipping/useShippingNoticeWorkflow';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
@@ -43,7 +40,7 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
|
||||
userVisibleStage: 'extracting',
|
||||
elapsedSeconds: 75,
|
||||
},
|
||||
availableActions: ['refresh_status', 'cancel_run'],
|
||||
availableActions: ['refresh_status', 'cancel_run', 'view_details'],
|
||||
healthTips: [{ code: 'processing_slow', thresholdSeconds: 60, idleOrElapsedSeconds: 90 }],
|
||||
terminal: false,
|
||||
refreshFailed: false,
|
||||
@@ -54,17 +51,23 @@ const buildState = (patch: Partial<ShippingOrderExtractionState> = {}): Shipping
|
||||
});
|
||||
|
||||
describe('ShippingOrderExtractionCard', () => {
|
||||
it('renders batch summary, current stage, health tip and action buttons', () => {
|
||||
// 冷启动 transform 较慢时放宽超时,避免首测误伤。
|
||||
it('renders summary title, file count, system processing and no progress/refresh/cancel', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-1' },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('PO-450003.pdf');
|
||||
expect(wrapper.text()).toContain('提取订单字段中');
|
||||
// 关键断言:对话卡只保留摘要标题与系统处理中状态。
|
||||
expect(wrapper.text()).toContain('订单识别任务');
|
||||
expect(wrapper.text()).toContain('3 个文件');
|
||||
expect(wrapper.text()).toContain('系统处理中');
|
||||
expect(wrapper.text()).toContain('处理时间偏长');
|
||||
expect(wrapper.text()).toContain('刷新状态');
|
||||
expect(wrapper.text()).toContain('取消本次识别');
|
||||
expect(wrapper.text()).toContain('查看详情');
|
||||
expect(wrapper.text()).not.toContain('刷新状态');
|
||||
expect(wrapper.text()).not.toContain('取消本次识别');
|
||||
expect(wrapper.text()).not.toContain('PO-450003.pdf');
|
||||
expect(wrapper.text()).not.toContain('提取订单字段中');
|
||||
expect(wrapper.findAll('[data-testid="chat-progress-summary-list"]').length).toBe(0);
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-summary"]').length).toBe(0);
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-document-result"]').length).toBe(0);
|
||||
}, 30_000);
|
||||
|
||||
@@ -91,12 +94,12 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('发现重复文件');
|
||||
expect(wrapper.text()).toContain('订单识别任务');
|
||||
expect(wrapper.text()).toContain('已关联已有任务');
|
||||
expect(wrapper.text()).not.toContain('需人工处理');
|
||||
});
|
||||
|
||||
it('does not label generated candidates as manual-review exceptions', () => {
|
||||
it('renders candidate confirmation as status notice with continue CTA', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -129,13 +132,14 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
stubs: { 'router-link': true },
|
||||
},
|
||||
});
|
||||
// 关键断言:成功候选可待人工确认,但绝不能提示为识别异常。
|
||||
expect(wrapper.text()).toContain('订单候选已生成');
|
||||
expect(wrapper.text()).toContain('候选待人工确认');
|
||||
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
|
||||
expect(wrapper.text()).toContain('继续处理');
|
||||
expect(wrapper.text()).not.toContain('部分附件需人工处理');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
||||
});
|
||||
|
||||
it('renders mixed handling items with reasons instead of a vague needs-action notice', () => {
|
||||
it('renders one handling summary line without per-item actions or affected refs', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -183,17 +187,51 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('部分附件处理失败');
|
||||
expect(wrapper.text()).toContain('订单待补信息');
|
||||
expect(wrapper.text()).toContain('自动冻结受阻');
|
||||
expect(wrapper.text()).toContain('文件损坏、加密或无法读取');
|
||||
expect(wrapper.text()).toContain('影响对象:');
|
||||
expect(wrapper.text()).toContain('ST-88');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(3);
|
||||
// 无统一投影时仍允许 handlingItems 主按钮(过渡兜底)。
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBeGreaterThan(0);
|
||||
expect(wrapper.text()).toContain('附件处理失败 · 3 项');
|
||||
expect(wrapper.text()).not.toContain('订单待补信息');
|
||||
expect(wrapper.text()).not.toContain('影响对象:');
|
||||
expect(wrapper.text()).not.toContain('ST-88');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBe(0);
|
||||
// 失败优先:唯一主 CTA 为重试解析。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('重试解析');
|
||||
});
|
||||
|
||||
it('hides handling primary actions when unified processing projection is present (UI-01)', () => {
|
||||
it('shows continue CTA for review-required without retry', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
status: 'review_required',
|
||||
availableActions: ['enter_manual_review', 'view_details'],
|
||||
primaryNotice: 'candidate_confirmation',
|
||||
handlingItems: [{
|
||||
category: 'candidate_confirmation',
|
||||
count: 1,
|
||||
reasonCodes: [],
|
||||
affectedRefs: [],
|
||||
primaryAction: 'review_candidate',
|
||||
}],
|
||||
healthTips: [],
|
||||
currentActivity: null,
|
||||
summary: {
|
||||
totalDocuments: 1,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 1,
|
||||
reviewRequiredDocuments: 1,
|
||||
failedDocuments: 0,
|
||||
candidateCount: 1,
|
||||
},
|
||||
}),
|
||||
runNo: 'SNER-REVIEW',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('继续处理');
|
||||
expect(wrapper.text()).not.toContain('重试解析');
|
||||
});
|
||||
|
||||
it('does not render multi-OT ChatProgressSummary list', () => {
|
||||
const projection = {
|
||||
workItemType: 'order_task' as const,
|
||||
workItemNo: 'OT-UI01',
|
||||
@@ -228,134 +266,36 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
userTaskNo: 'OT-UI01',
|
||||
availableActions: ['review_candidate', 'view_details'],
|
||||
primaryNotice: 'candidate_confirmation',
|
||||
handlingItems: [
|
||||
{
|
||||
category: 'candidate_confirmation',
|
||||
count: 1,
|
||||
reasonCodes: [],
|
||||
affectedRefs: [],
|
||||
primaryAction: 'review_candidate',
|
||||
},
|
||||
{
|
||||
category: 'parse_failed',
|
||||
count: 1,
|
||||
reasonCodes: ['layout_failed'],
|
||||
affectedRefs: [],
|
||||
primaryAction: 'retry_failed_documents',
|
||||
},
|
||||
],
|
||||
handlingItems: [{
|
||||
category: 'candidate_confirmation',
|
||||
count: 1,
|
||||
reasonCodes: [],
|
||||
affectedRefs: [],
|
||||
primaryAction: 'review_candidate',
|
||||
}],
|
||||
healthTips: [],
|
||||
currentActivity: null,
|
||||
summary: {
|
||||
totalDocuments: 1,
|
||||
pendingDocuments: 0,
|
||||
processingDocuments: 0,
|
||||
completedDocuments: 1,
|
||||
reviewRequiredDocuments: 1,
|
||||
failedDocuments: 0,
|
||||
candidateCount: 1,
|
||||
},
|
||||
}),
|
||||
runNo: 'SNER-UI01',
|
||||
processingProjection: projection,
|
||||
},
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: {
|
||||
ChatProgressSummary: true,
|
||||
ProcessGateRecoveryCard: true,
|
||||
'router-link': true,
|
||||
},
|
||||
},
|
||||
});
|
||||
// 主操作只来自投影 Presenter;已被 Gate/进度表达的 handling 项不重复列出。
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-primary-action"]').length).toBe(0);
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(1);
|
||||
});
|
||||
|
||||
it('renders one unified progress summary for each PDF under the same root task', () => {
|
||||
const buildWorkItem = (
|
||||
taskNo: string,
|
||||
filename: string,
|
||||
documentId: number,
|
||||
): ShippingProcessingProjection => ({
|
||||
workItemType: 'order_task',
|
||||
workItemNo: taskNo,
|
||||
sourceType: 'direct_pdf',
|
||||
rootOrderTaskNo: 'OT-ROOT',
|
||||
shippingNoticeNo: null,
|
||||
conversationId: 'conv-1',
|
||||
submissionNo: 'SUB-1',
|
||||
intakeNo: 'INT-1',
|
||||
status: 'processing',
|
||||
stage: 'document_parsing',
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-06T00:00:00Z',
|
||||
currentGate: null,
|
||||
availableActions: ['view_details'],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename,
|
||||
documentId,
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
});
|
||||
const workItems = [
|
||||
buildWorkItem('OT-ROOT', 'PO-001.pdf', 1),
|
||||
buildWorkItem('OT-CHILD', 'PO-002.pdf', 2),
|
||||
];
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({ userTaskNo: 'OT-ROOT' }),
|
||||
runNo: 'SNER-MULTI-PDF',
|
||||
},
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
provide: {
|
||||
[SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref(null),
|
||||
processingWorkItems: ref(workItems),
|
||||
loading: ref(false),
|
||||
error: ref(null),
|
||||
refresh: async () => undefined,
|
||||
focusConversationTask: async () => undefined,
|
||||
markConversationTaskViewed: async () => undefined,
|
||||
stop: () => undefined,
|
||||
},
|
||||
},
|
||||
stubs: {
|
||||
ChatProgressSummary: {
|
||||
props: ['projection'],
|
||||
template: '<div data-testid="chat-progress-summary">{{ projection.workItemNo }}</div>',
|
||||
},
|
||||
ProcessGateRecoveryCard: true,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.findAll('[data-testid="chat-progress-summary"]')).toHaveLength(2);
|
||||
expect(wrapper.text()).toContain('PO-001.pdf');
|
||||
expect(wrapper.text()).toContain('PO-002.pdf');
|
||||
});
|
||||
|
||||
it('emits cancel after confirmation', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
availableActions: ['cancel_run', 'refresh_status'],
|
||||
}),
|
||||
runNo: 'SNER-1',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const cancelBtn = wrapper.findAll('button').find((b) => b.text().includes('取消本次识别'));
|
||||
expect(cancelBtn).toBeTruthy();
|
||||
await cancelBtn!.trigger('click');
|
||||
expect(wrapper.text()).toContain('确认取消本次识别');
|
||||
const textarea = wrapper.find('textarea');
|
||||
await textarea.setValue('不再需要识别');
|
||||
const confirmBtn = wrapper.findAll('button').find((b) => b.text() === '取消本次识别');
|
||||
await confirmBtn!.trigger('click');
|
||||
expect(wrapper.emitted('cancel')?.[0]).toEqual(['不再需要识别']);
|
||||
expect(wrapper.findAll('[data-testid="chat-progress-summary-list"]').length).toBe(0);
|
||||
expect(wrapper.text()).not.toContain('PO.pdf');
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').text()).toContain('继续处理');
|
||||
});
|
||||
|
||||
it('emits retry for failed attachments', async () => {
|
||||
it('emits retry for failed attachments via primary CTA', async () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
@@ -375,8 +315,26 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const retryBtn = wrapper.findAll('button').find((b) => b.text().includes('重试失败附件'));
|
||||
await retryBtn!.trigger('click');
|
||||
const retryBtn = wrapper.find('[data-testid="shipping-order-extraction-primary-action"]');
|
||||
expect(retryBtn.text()).toContain('重试解析');
|
||||
await retryBtn.trigger('click');
|
||||
expect(wrapper.emitted('retry')?.length).toBe(1);
|
||||
});
|
||||
|
||||
it('keeps view details as secondary text link only', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: {
|
||||
state: buildState({
|
||||
availableActions: ['view_details'],
|
||||
healthTips: [],
|
||||
}),
|
||||
runNo: 'SNER-1',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const details = wrapper.find('[data-testid="shipping-order-extraction-view-details"]');
|
||||
expect(details.exists()).toBe(true);
|
||||
expect(details.classes().join(' ')).toContain('underline-offset-2');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-primary-action"]').length).toBe(0);
|
||||
});
|
||||
});
|
||||
@@ -1,19 +1,14 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
|
||||
* 用途:聊天主区批次进度卡——摘要计数、Run 级诊断事项、当前文件阶段、健康提醒与动作。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、
|
||||
* orderExtractionProgressDisplay、vue-router、vue-i18n、ChatProgressSummary;
|
||||
* ProcessGateRecoveryCard 仅兼容保留(runLevelProcessGate 当前恒为空)。
|
||||
* 逻辑:有统一投影时按当前 Run 根 OT 展示全部 PDF/OT 紧凑进度,主操作仅来自投影;
|
||||
* handlingItems 保留诊断信息,不再渲染与投影平级的 primaryAction 主按钮;
|
||||
* Run 失败优先展示 errorExplainability.message;详情抽屉证据入口携带 focus+document_id。
|
||||
* 用途:聊天主区「订单识别任务」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。
|
||||
* 逻辑:对话区只做任务摘要;长进度/Gate/刷新取消由右侧栏承接;详情抽屉仅由次要「查看详情」打开。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref } from 'vue';
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from 'lucide-vue-next';
|
||||
import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
|
||||
import type {
|
||||
ShippingOrderExtractionHandlingItemState,
|
||||
ShippingOrderExtractionState,
|
||||
@@ -21,28 +16,12 @@ import type {
|
||||
import type {
|
||||
ShippingOrderExtractionDocumentResult,
|
||||
ShippingOrderExtractionProgressEvent,
|
||||
ShippingProcessGateUserSummary,
|
||||
} from '../../types/shipping.api.types';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import ChatProgressSummary from '@/features/shipping-progress/components/ChatProgressSummary.vue';
|
||||
import {
|
||||
SHIPPING_WORKFLOW_KEY,
|
||||
} from '@/features/chat/shipping/useShippingNoticeWorkflow';
|
||||
import type { ShippingProcessingProjection } from '../../types/shipping.api.types';
|
||||
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
import {
|
||||
listWorkspaceShippingOrderExtractionDocuments,
|
||||
listWorkspaceShippingOrderExtractionProgressEvents,
|
||||
} from '../../api/shipping.api';
|
||||
import {
|
||||
formatOrderExtractionElapsed,
|
||||
resolveOrderExtractionUserStageKey,
|
||||
} from '../../shipping/orderExtractionProgressDisplay';
|
||||
import {
|
||||
listDisplayableHandlingAffectedRefs,
|
||||
type ShippingHandlingAffectedRef,
|
||||
type ShippingHandlingRefTarget,
|
||||
} from '../../shipping/orderExtractionHandlingRefs';
|
||||
import ShippingOrderExtractionDetailsDrawer from './ShippingOrderExtractionDetailsDrawer.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -54,7 +33,7 @@ const props = defineProps<{
|
||||
/** 新版 Run 已替代旧版时,历史卡仅允许查看详情。 */
|
||||
readonly?: boolean;
|
||||
readonlyReason?: string | null;
|
||||
/** 可选统一投影;缺省时从 SHIPPING_WORKFLOW_KEY 解析。 */
|
||||
/** 可选统一投影;摘要卡不再渲染进度,仅保留 prop 兼容宿主。 */
|
||||
processingProjection?: ShippingProcessingProjection | null;
|
||||
}>();
|
||||
|
||||
@@ -67,74 +46,6 @@ const emit = defineEmits<{
|
||||
const { t, te } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const chatPage = inject(CHAT_PAGE_KEY, null);
|
||||
const shippingWorkflow = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
|
||||
/**
|
||||
* 解析当前 Run/任务对应的全部统一 ShippingProcessing 投影。
|
||||
* 核心逻辑:显式 prop 优先;根 OT 同时匹配自身与 rootOrderTaskNo 相同的兄弟 OT;
|
||||
* Candidate 前回退本会话 order_intake,禁止用 find() 丢失同 Run 的其他 PDF。
|
||||
*/
|
||||
const resolvedProcessingProjections = computed((): ShippingProcessingProjection[] => {
|
||||
if (props.processingProjection) return [props.processingProjection];
|
||||
const items = shippingWorkflow?.processingWorkItems?.value || [];
|
||||
if (!items.length) return [];
|
||||
const taskNo = String(props.state.userTaskNo || '').trim();
|
||||
if (taskNo) {
|
||||
const matched = items.filter((item) => (
|
||||
item.workItemType === 'order_task'
|
||||
&& (
|
||||
String(item.workItemNo || '').trim() === taskNo
|
||||
|| String(item.rootOrderTaskNo || '').trim() === taskNo
|
||||
)
|
||||
));
|
||||
if (matched.length) return matched;
|
||||
}
|
||||
return items.filter((item) => item.workItemType === 'order_intake');
|
||||
});
|
||||
|
||||
const hasProcessingProjection = computed(() => resolvedProcessingProjections.value.length > 0);
|
||||
|
||||
/** 进度行标题优先使用 PDF 文件名,其次使用 PO,最后使用工作项号。 */
|
||||
function processingProjectionTitle(item: ShippingProcessingProjection): string {
|
||||
return String(
|
||||
item.sourceSummary?.filename
|
||||
|| item.sourceSummary?.poNumber
|
||||
|| item.workItemNo,
|
||||
).trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一进度摘要动作:刷新 / 进入复核等由宿主路由承接。
|
||||
*/
|
||||
function onChatProgressAction(item: ActionPresentationItem) {
|
||||
if (item.intent === 'refresh') {
|
||||
emit('refresh');
|
||||
return;
|
||||
}
|
||||
if (item.intent === 'open_order_review') {
|
||||
void openOrderReview();
|
||||
}
|
||||
}
|
||||
const confirmCancelOpen = ref(false);
|
||||
const cancelReason = ref('');
|
||||
|
||||
/**
|
||||
* Gate 恢复卡「确认客户」:打开对话叠层客户选择弹窗。
|
||||
*/
|
||||
async function onGateConfirmCustomer(taskNo: string) {
|
||||
await chatPage?.openShippingCustomerDialog?.(taskNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run 级阻断 Gate:co8 后不再从 Workflow items 读取;由复核/Gate 主路径承接。
|
||||
*/
|
||||
const runLevelProcessGate = computed((): ShippingProcessGateUserSummary | null => null);
|
||||
|
||||
const gateNavigationContext = computed(() => ({
|
||||
agentId: String(route.params.agentId || ''),
|
||||
conversationId: String(route.query.conversation_id || ''),
|
||||
}));
|
||||
|
||||
const detailsOpen = ref(false);
|
||||
const detailsLoading = ref(false);
|
||||
@@ -146,24 +57,7 @@ const progressEvents = ref<ShippingOrderExtractionProgressEvent[]>([]);
|
||||
|
||||
const displaySummary = computed(() => props.state.summary);
|
||||
|
||||
const workflowStageLabel = computed(() => '');
|
||||
const workflowLastActivityLabel = computed(() => '');
|
||||
|
||||
const handlingItems = computed(() => {
|
||||
const items = props.state.handlingItems || [];
|
||||
// [UI-04] 有 OT 统一投影时,隐藏已被 Gate/进度表达的复核类事项,仅保留未归属异常。
|
||||
if (!hasProcessingProjection.value) return items;
|
||||
const covered = new Set([
|
||||
'manual_review',
|
||||
'field_conflict',
|
||||
'customer_confirmation',
|
||||
'candidate_confirmation',
|
||||
'duplicate_check',
|
||||
'inventory_source',
|
||||
'review_required',
|
||||
]);
|
||||
return items.filter((item) => !covered.has(String(item.category || '').trim()));
|
||||
});
|
||||
const handlingItems = computed(() => props.state.handlingItems || []);
|
||||
|
||||
/**
|
||||
* 是否为「仅重复关联已有任务、无需人工复核」终态通知。
|
||||
@@ -178,7 +72,7 @@ const isDuplicateOnlyNotice = computed(() => {
|
||||
});
|
||||
|
||||
/**
|
||||
* 是否为纯候选确认场景;优先信任后端 primary_notice,避免用摘要计数掩盖混合原因。
|
||||
* 是否为纯候选确认场景;优先信任后端 primary_notice。
|
||||
*/
|
||||
const isCandidateConfirmationNotice = computed(() => (
|
||||
props.state.primaryNotice === 'candidate_confirmation'
|
||||
@@ -210,18 +104,6 @@ const toneClass = computed(() => {
|
||||
}
|
||||
});
|
||||
|
||||
const stageLabel = computed(() => {
|
||||
const key = resolveOrderExtractionUserStageKey(
|
||||
props.state.currentActivity?.userVisibleStage || props.state.userVisibleStage,
|
||||
props.state.currentActivity?.eventCode || props.state.status,
|
||||
);
|
||||
return te(key) ? t(key) : '';
|
||||
});
|
||||
|
||||
const elapsedLabel = computed(() =>
|
||||
formatOrderExtractionElapsed(props.state.currentActivity?.elapsedSeconds),
|
||||
);
|
||||
|
||||
/**
|
||||
* 将处理事项类别映射为一句过程通知文案。
|
||||
* @param category - 后端 primary_notice / handling item category
|
||||
@@ -232,12 +114,24 @@ function noticeForCategory(category: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 一句过程通知;有 handling_items 时以后端类别为准,不再笼统写「需人工处理」。
|
||||
* 解析处理事项标题。
|
||||
* @param item - 后端 handling item
|
||||
*/
|
||||
const compactLine = computed(() => {
|
||||
function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
|
||||
const key = `chat.shippingOrderExtractionHandling.category.${item.category}`;
|
||||
return te(key) ? t(key) : item.category;
|
||||
}
|
||||
|
||||
/**
|
||||
* 状态短句:排队/处理中仅「系统处理中」;其余用过程通知,不含文件阶段耗时。
|
||||
*/
|
||||
const statusNotice = computed(() => {
|
||||
if (props.state.cancellation?.requested && !props.state.cancellation?.completedAt && !props.state.terminal) {
|
||||
return t('chat.shippingOrderExtractionUserStage.cancellation_requested');
|
||||
}
|
||||
if (props.state.status === 'queued' || props.state.status === 'processing') {
|
||||
return t('chat.shippingProcessing.systemProcessing');
|
||||
}
|
||||
if (isDuplicateOnlyNotice.value) {
|
||||
return t('chat.shippingSessionSummary.processNoticeDuplicateLinked');
|
||||
}
|
||||
@@ -258,78 +152,78 @@ const compactLine = computed(() => {
|
||||
if (explained) return explained;
|
||||
return t('chat.shippingSessionSummary.processNoticeFailed');
|
||||
}
|
||||
default: {
|
||||
if (props.state.status === 'queued' || props.state.status === 'processing') {
|
||||
const parts: string[] = [];
|
||||
const fileName = String(props.state.currentActivity?.fileName || '').trim();
|
||||
if (fileName) {
|
||||
parts.push(t('chat.shippingOrderExtractionCurrentFile', {
|
||||
fileName: fileName || t('chat.shippingOrderExtractionUnknownDocument'),
|
||||
}));
|
||||
}
|
||||
const stage = stageLabel.value;
|
||||
if (stage) parts.push(stage);
|
||||
const elapsed = elapsedLabel.value;
|
||||
if (elapsed) parts.push(t('chat.shippingOrderExtractionElapsed', { elapsed }));
|
||||
if (parts.length) return parts.join(' · ');
|
||||
}
|
||||
default:
|
||||
return t('chat.shippingSessionSummary.processNoticeProcessing');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const activityKey = computed(() => {
|
||||
const code = String(props.state.currentActivity?.eventCode || '').trim();
|
||||
const key = `chat.shippingOrderExtractionActivity.${code}`;
|
||||
return code && te(key) ? key : '';
|
||||
/**
|
||||
* 文件数 + 状态一行:`N 个文件 · 系统处理中`(或终态通知)。
|
||||
*/
|
||||
const statusLine = computed(() => {
|
||||
const count = Math.max(0, Number(displaySummary.value.totalDocuments || 0));
|
||||
const status = statusNotice.value;
|
||||
if (count <= 0) return status;
|
||||
return `${t('chat.shippingProcessing.taskFiles', { count })} · ${status}`;
|
||||
});
|
||||
|
||||
/**
|
||||
* 一行 handling 摘要(无操作按钮);无事项时为空。
|
||||
*/
|
||||
const handlingSummaryLine = computed(() => {
|
||||
const items = handlingItems.value;
|
||||
if (!items.length) return '';
|
||||
const first = items[0];
|
||||
if (!first) return '';
|
||||
const totalCount = items.reduce((sum, item) => sum + Math.max(0, Number(item.count || 0)), 0);
|
||||
const count = totalCount > 0 ? totalCount : items.length;
|
||||
return t('chat.shippingOrderExtractionHandling.summaryLine', {
|
||||
title: handlingTitle(first),
|
||||
count,
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 唯一主 CTA:失败→重试解析;需处理→继续处理;否则不展示。
|
||||
*/
|
||||
const primaryChatAction = computed((): { kind: 'retry' | 'continue'; label: string } | null => {
|
||||
if (props.readonly) return null;
|
||||
const actions = props.state.availableActions || [];
|
||||
const canRetry = actions.includes('retry_failed_attachments')
|
||||
|| actions.includes('retry_failed_documents')
|
||||
|| displaySummary.value.failedDocuments > 0
|
||||
|| props.state.status === 'failed';
|
||||
if (canRetry) {
|
||||
return {
|
||||
kind: 'retry',
|
||||
label: t('chat.shippingNoticeRetryParse'),
|
||||
};
|
||||
}
|
||||
const needsContinue = actions.includes('enter_manual_review')
|
||||
|| actions.includes('review_candidate')
|
||||
|| actions.includes('open_order_review')
|
||||
|| actions.includes('open_order_processing')
|
||||
|| props.state.status === 'review_required'
|
||||
|| props.state.status === 'partially_completed'
|
||||
|| isCandidateConfirmationNotice.value;
|
||||
if (needsContinue) {
|
||||
return {
|
||||
kind: 'continue',
|
||||
label: t('chat.shippingProcessing.continueProcessing'),
|
||||
};
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
const showRetry = computed(() => (
|
||||
!props.readonly && (
|
||||
props.state.availableActions.includes('retry_failed_attachments')
|
||||
|| displaySummary.value.failedDocuments > 0
|
||||
)
|
||||
));
|
||||
const showRefresh = computed(() => !props.readonly && props.state.availableActions.includes('refresh_status'));
|
||||
const showCancel = computed(() => (
|
||||
!props.readonly
|
||||
&&
|
||||
props.state.availableActions.includes('cancel_run')
|
||||
&& !(props.state.cancellation?.requested && !props.state.cancellation?.completedAt)
|
||||
));
|
||||
const healthTips = computed(() => props.state.healthTips || []);
|
||||
|
||||
/**
|
||||
* 解析处理事项标题。
|
||||
* @param item - 后端 handling item
|
||||
*/
|
||||
function handlingTitle(item: ShippingOrderExtractionHandlingItemState): string {
|
||||
const key = `chat.shippingOrderExtractionHandling.category.${item.category}`;
|
||||
return te(key) ? t(key) : item.category;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析原因码文案;未知或内部技术码统一回退为可执行的业务提示。
|
||||
* @param code - 原因码
|
||||
*/
|
||||
function reasonLabel(code: string): string {
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return '';
|
||||
const key = `chat.shippingOrderExtractionReason.${normalized}`;
|
||||
if (te(key)) return t(key);
|
||||
const freezeKey = `chat.shippingOrderExtractionHandling.reason.${normalized}`;
|
||||
return te(freezeKey) ? t(freezeKey) : t('chat.shippingOrderExtractionReasonUnknown');
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开订单复核工作台(Chat order-review 模式)。
|
||||
* @param options.documentId - 可选,定位到具体 PDF
|
||||
* @param options.candidateNo - 可选,写入 query 供复核页筛选
|
||||
* @param options.focus - evidence=证据区;draft=草稿复核(默认)
|
||||
*/
|
||||
async function openOrderReview(options?: {
|
||||
documentId?: number;
|
||||
candidateNo?: string;
|
||||
focus?: 'evidence' | 'draft';
|
||||
}) {
|
||||
const runNo = String(props.runNo || '').trim();
|
||||
@@ -341,8 +235,6 @@ async function openOrderReview(options?: {
|
||||
mode: 'order-review',
|
||||
run_no: runNo,
|
||||
};
|
||||
const candidateNo = String(options?.candidateNo || '').trim();
|
||||
if (candidateNo) query.candidate = candidateNo;
|
||||
const documentId = Number(options?.documentId || 0);
|
||||
if (documentId > 0) query.document_id = String(documentId);
|
||||
const focus = options?.focus === 'evidence' || options?.focus === 'draft'
|
||||
@@ -441,87 +333,15 @@ async function enterReviewFromDetails(payload?: { focus?: 'evidence' | 'draft';
|
||||
}
|
||||
|
||||
/**
|
||||
* 在对话侧聚焦 Task(双工作台主路径);Task 工作台仅作备用深链。
|
||||
* 执行唯一主 CTA:重试解析或进入订单处理。
|
||||
*/
|
||||
async function focusTaskInChat(taskNo: string) {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) return;
|
||||
const conversationId = String(route.query.conversation_id || '').trim();
|
||||
await router.replace({
|
||||
name: 'Chat',
|
||||
params: { agentId: String(route.params.agentId || '') },
|
||||
query: {
|
||||
...route.query,
|
||||
conversation_id: conversationId || undefined,
|
||||
focus_task_no: normalized,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 按受影响对象引用跳转到对话聚焦或复核入口。
|
||||
*/
|
||||
async function openAffectedRef(target: ShippingHandlingRefTarget) {
|
||||
if (target.kind === 'chat_focus_task') {
|
||||
await focusTaskInChat(target.taskNo);
|
||||
return;
|
||||
}
|
||||
if (target.kind === 'review') {
|
||||
await openOrderReview({
|
||||
documentId: target.documentId,
|
||||
candidateNo: target.candidateNo,
|
||||
focus: 'draft',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列出事项下可展示的受影响对象。
|
||||
*/
|
||||
function affectedRows(item: ShippingOrderExtractionHandlingItemState) {
|
||||
return listDisplayableHandlingAffectedRefs(item.affectedRefs as ShippingHandlingAffectedRef[]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按处理事项主动作跳转或触发重试;优先跳到首个受影响对象。
|
||||
* @param item - 处理事项
|
||||
*/
|
||||
async function handleHandlingAction(item: ShippingOrderExtractionHandlingItemState) {
|
||||
if (props.readonly) return;
|
||||
const action = String(item.primaryAction || '').trim();
|
||||
if (action === 'retry_failed_attachments') {
|
||||
async function onPrimaryChatAction() {
|
||||
if (!primaryChatAction.value || props.readonly) return;
|
||||
if (primaryChatAction.value.kind === 'retry') {
|
||||
emit('retry');
|
||||
return;
|
||||
}
|
||||
const first = affectedRows(item)[0];
|
||||
if (first && first.target.kind !== 'none') {
|
||||
await openAffectedRef(first.target);
|
||||
return;
|
||||
}
|
||||
if (action === 'view_details') {
|
||||
await openDetailsDrawer();
|
||||
return;
|
||||
}
|
||||
if (action === 'enter_manual_review' || action === 'review_candidate') {
|
||||
await openOrderReview({ focus: 'draft' });
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认后发出取消事件;取消是请求语义,由后端检查点生效。
|
||||
*/
|
||||
function confirmCancel() {
|
||||
confirmCancelOpen.value = false;
|
||||
const reason = String(cancelReason.value || '').trim();
|
||||
cancelReason.value = '';
|
||||
emit('cancel', reason || undefined);
|
||||
}
|
||||
|
||||
/** 打开取消确认并清空上次填写的原因。 */
|
||||
function openCancelConfirm() {
|
||||
if (props.readonly) return;
|
||||
cancelReason.value = '';
|
||||
confirmCancelOpen.value = true;
|
||||
await openOrderReview({ focus: 'draft' });
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -554,7 +374,21 @@ function openCancelConfirm() {
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionHistory.superseded') }}
|
||||
</div>
|
||||
<div class="text-sm font-medium">{{ compactLine }}</div>
|
||||
|
||||
<div
|
||||
class="text-sm font-medium"
|
||||
data-testid="shipping-order-extraction-title"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.multiPdfTaskTitle') }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="mt-0.5 text-xs opacity-90"
|
||||
data-testid="shipping-order-extraction-status-line"
|
||||
>
|
||||
{{ statusLine }}
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="state.errorExplainability?.request_id"
|
||||
class="mt-1 text-[11px] opacity-80"
|
||||
@@ -564,134 +398,11 @@ function openCancelConfirm() {
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="displaySummary.totalDocuments > 0"
|
||||
class="mt-1.5 flex flex-wrap gap-1.5 text-[11px] opacity-90"
|
||||
data-testid="shipping-order-extraction-summary"
|
||||
v-if="handlingSummaryLine"
|
||||
class="mt-1.5 text-xs opacity-90"
|
||||
data-testid="shipping-order-extraction-handling-summary"
|
||||
>
|
||||
<span>{{ t('chat.shippingOrderExtractionSummary.total', { count: displaySummary.totalDocuments }) }}</span>
|
||||
<span v-if="displaySummary.processingDocuments > 0">
|
||||
{{ t('chat.shippingOrderExtractionSummary.processing', { count: displaySummary.processingDocuments }) }}
|
||||
</span>
|
||||
<span v-if="displaySummary.pendingDocuments > 0">
|
||||
{{ t('chat.shippingOrderExtractionSummary.pending', { count: displaySummary.pendingDocuments }) }}
|
||||
</span>
|
||||
<span v-if="displaySummary.completedDocuments > 0">
|
||||
{{ t('chat.shippingOrderExtractionSummary.completed', { count: displaySummary.completedDocuments }) }}
|
||||
</span>
|
||||
<span v-if="displaySummary.reviewRequiredDocuments > 0">
|
||||
{{ t('chat.shippingOrderExtractionSummary.reviewRequired', { count: displaySummary.reviewRequiredDocuments }) }}
|
||||
</span>
|
||||
<span v-if="displaySummary.failedDocuments > 0">
|
||||
{{ t('chat.shippingOrderExtractionSummary.failed', { count: displaySummary.failedDocuments }) }}
|
||||
</span>
|
||||
<span v-if="(displaySummary.cancelledDocuments || 0) > 0">
|
||||
{{ t('chat.shippingOrderExtractionSummary.cancelled', { count: displaySummary.cancelledDocuments }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="workflowStageLabel || workflowLastActivityLabel"
|
||||
class="mt-1 text-[11px] opacity-80"
|
||||
data-testid="shipping-order-extraction-workflow-meta"
|
||||
>
|
||||
<span v-if="workflowStageLabel">{{ workflowStageLabel }}</span>
|
||||
<span v-if="workflowLastActivityLabel" class="ml-1">· {{ workflowLastActivityLabel }}</span>
|
||||
</div>
|
||||
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="runLevelProcessGate?.current_blocking_gate && !hasProcessingProjection"
|
||||
class="mt-2"
|
||||
:summary="runLevelProcessGate"
|
||||
:can-handle="!readonly"
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="emit('refresh')"
|
||||
@refresh-needed="emit('refresh')"
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="hasProcessingProjection"
|
||||
class="mt-2 space-y-2"
|
||||
data-testid="chat-progress-summary-list"
|
||||
>
|
||||
<div
|
||||
v-for="projection in resolvedProcessingProjections"
|
||||
:key="projection.workItemNo"
|
||||
>
|
||||
<div class="truncate text-[11px] font-semibold opacity-90">
|
||||
{{ processingProjectionTitle(projection) }}
|
||||
</div>
|
||||
<ChatProgressSummary
|
||||
:projection="projection"
|
||||
@action="onChatProgressAction"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="handlingItems.length"
|
||||
class="mt-2 space-y-1.5"
|
||||
data-testid="shipping-order-extraction-handling-items"
|
||||
>
|
||||
<div class="text-[11px] font-medium opacity-90">
|
||||
{{ t('chat.shippingOrderExtractionHandling.title') }}
|
||||
</div>
|
||||
<div
|
||||
v-for="item in handlingItems"
|
||||
:key="item.category"
|
||||
class="rounded-md border border-current/15 bg-black/5 px-2 py-1.5 text-xs dark:bg-white/5"
|
||||
data-testid="shipping-order-extraction-handling-item"
|
||||
>
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="min-w-0 font-medium">
|
||||
{{ handlingTitle(item) }}
|
||||
<span class="ml-1 opacity-80">{{ t('chat.shippingOrderExtractionHandling.count', { count: item.count }) }}</span>
|
||||
</div>
|
||||
<button
|
||||
v-if="item.primaryAction && !readonly && !hasProcessingProjection && (item.primaryAction !== 'review_candidate' || !handlingItems.some((other) => other.primaryAction === 'enter_manual_review'))"
|
||||
type="button"
|
||||
class="shrink-0 rounded-md border border-current/20 px-2 py-0.5 text-[11px] font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-extraction-handling-primary-action"
|
||||
@click="handleHandlingAction(item)"
|
||||
>
|
||||
{{ (item.primaryAction === 'review_candidate' || item.primaryAction === 'enter_manual_review')
|
||||
? t('chat.shippingOrderExtractionAction.enter_manual_review')
|
||||
: te(`chat.shippingOrderExtractionAction.${item.primaryAction}`)
|
||||
? t(`chat.shippingOrderExtractionAction.${item.primaryAction}`)
|
||||
: t('chat.shippingOrderExtractionAction.view_details') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="item.reasonCodes.length" class="mt-1 opacity-80">
|
||||
{{ t('chat.shippingOrderExtractionHandling.reasonPrefix') }}
|
||||
{{ item.reasonCodes.slice(0, 4).map(reasonLabel).join(';') }}
|
||||
</div>
|
||||
<div
|
||||
v-if="affectedRows(item).length"
|
||||
class="mt-1.5 flex flex-wrap gap-1"
|
||||
data-testid="shipping-order-extraction-affected-refs"
|
||||
>
|
||||
<span class="opacity-80">{{ t('chat.shippingOrderExtractionHandling.affectedPrefix') }}</span>
|
||||
<button
|
||||
v-for="row in affectedRows(item)"
|
||||
:key="row.key"
|
||||
type="button"
|
||||
class="rounded border border-current/20 px-1.5 py-0.5 text-[11px] font-medium underline-offset-2 hover:underline"
|
||||
:disabled="readonly"
|
||||
@click="openAffectedRef(row.target)"
|
||||
>
|
||||
{{ row.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="state.currentActivity?.fileName" class="mt-1 text-xs opacity-80">
|
||||
{{ t('chat.shippingOrderExtractionCurrentFile', {
|
||||
fileName: state.currentActivity.fileName || t('chat.shippingOrderExtractionUnknownDocument'),
|
||||
}) }}
|
||||
<span v-if="stageLabel"> · {{ stageLabel }}</span>
|
||||
<span v-else-if="activityKey"> · {{ t(activityKey) }}</span>
|
||||
<span v-if="elapsedLabel"> · {{ t('chat.shippingOrderExtractionElapsed', { elapsed: elapsedLabel }) }}</span>
|
||||
{{ handlingSummaryLine }}
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -707,80 +418,27 @@ function openCancelConfirm() {
|
||||
{{ t('chat.shippingOrderExtractionRefreshFailed') }}
|
||||
</div>
|
||||
|
||||
<div v-if="confirmCancelOpen" class="mt-2 rounded-md border border-current/20 bg-black/5 p-2 text-xs dark:bg-white/5">
|
||||
<div class="font-medium">{{ t('chat.shippingOrderExtractionCancel.confirmTitle') }}</div>
|
||||
<div class="mt-1 opacity-80">{{ t('chat.shippingOrderExtractionCancel.confirmImpact') }}</div>
|
||||
<label class="mt-2 block opacity-90">
|
||||
{{ t('chat.shippingOrderExtractionCancel.reasonOptional') }}
|
||||
<textarea
|
||||
v-model="cancelReason"
|
||||
rows="2"
|
||||
class="input-field mt-1 w-full py-1 text-xs"
|
||||
:placeholder="t('chat.shippingOrderExtractionCancel.reasonOptional')"
|
||||
/>
|
||||
</label>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
:disabled="cancelling"
|
||||
@click="confirmCancel"
|
||||
>
|
||||
{{ cancelling
|
||||
? t('chat.shippingOrderExtractionCancel.submitting')
|
||||
: t('chat.shippingOrderExtractionAction.cancel_run') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md px-2.5 py-1 text-xs font-medium opacity-80 hover:underline"
|
||||
:disabled="cancelling"
|
||||
@click="confirmCancelOpen = false; cancelReason = ''"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionCancel.dismiss') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else class="mt-2 flex flex-wrap gap-2">
|
||||
<div class="mt-2 flex flex-wrap items-center gap-3">
|
||||
<button
|
||||
v-if="primaryChatAction"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
data-testid="shipping-order-extraction-primary-action"
|
||||
:disabled="primaryChatAction.kind === 'retry' && retrying"
|
||||
@click="onPrimaryChatAction"
|
||||
>
|
||||
{{ primaryChatAction.kind === 'retry' && retrying
|
||||
? t('chat.shippingOrderExtractionRetrying')
|
||||
: primaryChatAction.label }}
|
||||
</button>
|
||||
<button
|
||||
v-if="String(props.runNo || '').trim()"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
class="text-xs font-medium underline-offset-2 opacity-80 hover:underline"
|
||||
data-testid="shipping-order-extraction-view-details"
|
||||
@click="openDetailsDrawer"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.view_details') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="showRefresh"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
:disabled="refreshing"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ refreshing
|
||||
? t('chat.shippingOrderExtractionRefreshing')
|
||||
: t('chat.shippingOrderExtractionAction.refresh_status') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="showCancel"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
:disabled="cancelling"
|
||||
@click="openCancelConfirm"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionAction.cancel_run') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="showRetry"
|
||||
type="button"
|
||||
class="inline-flex items-center rounded-md border border-current/20 px-2.5 py-1 text-xs font-medium hover:bg-black/5 dark:hover:bg-white/5"
|
||||
:disabled="retrying"
|
||||
@click="emit('retry')"
|
||||
>
|
||||
{{ retrying
|
||||
? t('chat.shippingOrderExtractionRetrying')
|
||||
: t('chat.shippingOrderExtractionAction.retry_failed_attachments') }}
|
||||
{{ t('chat.shippingProcessing.viewTaskDetails') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -3,9 +3,10 @@
|
||||
* 用途:聊天页右侧「本次处理中」面板——OT 任务卡 + 按需展开的文件明细。
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、ShippingConversationProcessingCard、
|
||||
* conversationProcessingProjection、DetailDrawer、ReasonDialog、ProcessGateRecoveryCard。
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;每张 OT 卡内展示自己的紧凑进度与动作;
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;面板摘要为双行「N 任务 · M 文件」+
|
||||
* 「待我处理 / 系统处理中」;截断时展示 has_more 提示;
|
||||
* mapUserTaskObjectsToFileRows 合成文件行;取消/重识别走 Run API;
|
||||
* 路由 focus_task_no / 服务端 focused_task_no 驱动选中卡与当前阶段摘要;
|
||||
* 路由 focus_task_no / 服务端 focused_task_no 驱动选中卡;
|
||||
* 详情抽屉仅用列表投影,不再请求 WorkflowItem 详情 API。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -859,18 +860,30 @@ watch(
|
||||
{{ t('chat.shippingProcessing.panelPinnedLabel') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
|
||||
<div class="mt-0.5 space-y-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
|
||||
<template v-if="loading && !displayProcessing">
|
||||
{{ t('chat.shippingProcessing.loading') }}
|
||||
</template>
|
||||
<template v-else-if="displayProcessing">
|
||||
{{ t('chat.shippingProcessing.summaryLine', {
|
||||
total: displayProcessing.summary.total_files
|
||||
|| displayProcessing.summary.total_tasks,
|
||||
processing: displayProcessing.summary.processing,
|
||||
needsAction: displayProcessing.summary.needs_action,
|
||||
completed: displayProcessing.summary.completed || 0,
|
||||
}) }}
|
||||
<div data-testid="shipping-processing-summary-totals">
|
||||
{{ t('chat.shippingProcessing.summaryTasksAndFiles', {
|
||||
tasks: Number(displayProcessing.summary.total_tasks || 0),
|
||||
files: Number(displayProcessing.summary.total_files || 0),
|
||||
}) }}
|
||||
</div>
|
||||
<div data-testid="shipping-processing-summary-detail">
|
||||
{{ t('chat.shippingProcessing.summaryLineDetail', {
|
||||
needsAction: Number(displayProcessing.summary.needs_action || 0),
|
||||
processing: Number(displayProcessing.summary.processing || 0),
|
||||
}) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="displayProcessing.summary.has_more_active || displayProcessing.summary.has_more_history"
|
||||
class="text-[11px] text-muted"
|
||||
data-testid="shipping-processing-summary-truncated"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
|
||||
</div>
|
||||
</template>
|
||||
<template v-else>
|
||||
{{ t('chat.shippingProcessing.compactSummary', {
|
||||
@@ -912,6 +925,7 @@ watch(
|
||||
:projection="displayProcessing"
|
||||
:work-items="processingWorkItems"
|
||||
:conversation-id="conversationId"
|
||||
:has-more-history="Boolean(displayProcessing?.summary?.has_more_history)"
|
||||
@focus="(taskNo) => void onProcessingFocus(taskNo)"
|
||||
@viewed="(taskNo) => void onProcessingViewed(taskNo)"
|
||||
@expand-files="onExpandTaskFiles"
|
||||
|
||||
@@ -198,7 +198,17 @@ describe('useShippingOrderReview historical readonly', () => {
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('does not treat peer PDF cases in the same run as historical', () => {
|
||||
// 关键断言:同 Run 多 PDF 并列 Case,不得因 current_case_no 指向另一份而只读。
|
||||
expect(isReviewCaseHistorical(
|
||||
{ case_no: 'CASE-B', status: 'draft' },
|
||||
{ current_case_no: 'CASE-A', version_replaced: false },
|
||||
)).toBe(false);
|
||||
expect(isReviewCaseHistorical(
|
||||
{ case_no: 'CASE-B', status: 'ready' },
|
||||
{ current_case_no: 'CASE-A' },
|
||||
)).toBe(false);
|
||||
});
|
||||
|
||||
it('allows edit when viewing current case', () => {
|
||||
|
||||
@@ -422,7 +432,76 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.previewUrl.value).toMatch(/^blob:/);
|
||||
});
|
||||
|
||||
it('clears activeCase immediately while switching and keeps empty shell on failure (UI-01)', async () => {
|
||||
// 关键断言:loading 期间不得保留旧 Case 业务对象;失败后也不得回显旧值。
|
||||
let resolveCase: ((value: ShippingOrderReviewCase) => void) | null = null;
|
||||
const caseOld = buildCase({ case_no: 'CASE-OLD', document: { id: 1, file_name: 'old.pdf' } });
|
||||
const caseNew = buildCase({ case_no: 'CASE-NEW', document: { id: 2, file_name: 'new.pdf' } });
|
||||
api.getCase.mockImplementation((caseNo: string) => {
|
||||
if (caseNo === 'CASE-NEW') {
|
||||
return new Promise<ShippingOrderReviewCase>((resolve) => {
|
||||
resolveCase = resolve;
|
||||
});
|
||||
}
|
||||
return Promise.resolve(caseOld);
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
await review.selectCase('CASE-OLD');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-OLD');
|
||||
|
||||
const pending = review.selectCase('CASE-NEW');
|
||||
expect(review.caseSwitchLoading.value).toBe(true);
|
||||
expect(review.activeCase.value).toBeNull();
|
||||
expect(review.requestedCaseNo.value).toBe('CASE-NEW');
|
||||
|
||||
resolveCase?.(caseNew);
|
||||
await pending;
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-NEW');
|
||||
expect(review.caseSwitchLoading.value).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps empty skeleton when selectCase fails (UI-01 failure mode 2)', async () => {
|
||||
api.getCase.mockResolvedValueOnce(buildCase({ case_no: 'CASE-OLD' }));
|
||||
api.getEvidence.mockResolvedValueOnce({ items: [] });
|
||||
const review = useShippingOrderReview();
|
||||
await review.selectCase('CASE-OLD');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-OLD');
|
||||
|
||||
api.getCase.mockRejectedValueOnce(new Error('boom'));
|
||||
api.getEvidence.mockRejectedValueOnce(new Error('boom'));
|
||||
await review.selectCase('CASE-FAIL');
|
||||
expect(review.caseSwitchFailed.value).toBe(true);
|
||||
expect(review.activeCase.value).toBeNull();
|
||||
expect(review.requestedCaseNo.value).toBe('CASE-FAIL');
|
||||
});
|
||||
|
||||
it('discards stale selectCase responses when switching PDFs quickly', async () => {
|
||||
// 关键断言:A 后发先至不得覆盖后选的 B;切换时先清空瞬态。
|
||||
let resolveA: ((value: ShippingOrderReviewCase) => void) | null = null;
|
||||
const caseA = buildCase({ case_no: 'CASE-A', document: { id: 1, file_name: 'a.pdf' } });
|
||||
const caseB = buildCase({ case_no: 'CASE-B', document: { id: 2, file_name: 'b.pdf' } });
|
||||
api.getCase.mockImplementation((caseNo: string) => {
|
||||
if (caseNo === 'CASE-A') {
|
||||
return new Promise<ShippingOrderReviewCase>((resolve) => {
|
||||
resolveA = resolve;
|
||||
});
|
||||
}
|
||||
return Promise.resolve(caseB);
|
||||
});
|
||||
api.getEvidence.mockResolvedValue({ items: [] });
|
||||
|
||||
const review = useShippingOrderReview();
|
||||
const pendingA = review.selectCase('CASE-A');
|
||||
await review.selectCase('CASE-B');
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-B');
|
||||
expect(review.requestedCaseNo.value).toBe('CASE-B');
|
||||
|
||||
resolveA?.(caseA);
|
||||
await pendingA;
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-B');
|
||||
});
|
||||
|
||||
it('submits inventory candidates via PUT and refreshes case', async () => {
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* features/chat/shipping-review/useShippingOrderReview.ts
|
||||
* ????????? composable??Run/Case/PDF ??????????
|
||||
* ???shipping API review/extraction-run?useShippingProcessingWorkItem?Vue ref/computed?BusinessError?
|
||||
* ???? runNo ?? Review Run/Case??? ShippingReviewProgressContext?
|
||||
* ?? OT ?? Case.order_task_no / Candidate ????? ShippingProcessing ???
|
||||
* 409 REVIEW_DRAFT_VERSION_MISMATCH ???????build_eligibility ???? reroute/adopt/keep?
|
||||
* ???? extraction-run?draft_ready ? reload?PDF Blob ? ensurePreviewLoaded ????
|
||||
* 用途:订单复核工作台 composable,编排 Run/Case/PDF、草稿写入与建单确认。
|
||||
* 依赖:shipping API review/extraction-run、useShippingProcessingWorkItem、Vue ref/computed、BusinessError。
|
||||
* 逻辑:按 runNo 加载 Review Run/Case;合成 ShippingReviewProgressContext;
|
||||
* OT 绑定 Case.order_task_no / Candidate;切换 Case 时清空 activeCase(纯 skeleton,禁止旧值 DOM);
|
||||
* 409 REVIEW_DRAFT_VERSION_MISMATCH 冲突处理;build_eligibility 驱动 confirm/reroute;
|
||||
* 重识别轮询 extraction-run;PDF Blob 由 ensurePreviewLoaded 按需加载。
|
||||
*/
|
||||
import { computed, getCurrentInstance, onBeforeUnmount, ref } from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
@@ -138,14 +138,15 @@ type WorkItemRef = {
|
||||
} | null | undefined;
|
||||
|
||||
/**
|
||||
* ???? Case ????????superseded ?? WorkItem ?? Case ?????
|
||||
* 判断当前 Case 是否为「已被新版本替代」的历史只读态。
|
||||
* 核心逻辑:仅 status=superseded,或 WorkItem.version_replaced 且 case_no≠current_case_no。
|
||||
* 同 Run 下多 PDF 互为并列 Case,不得因 current_case_no 指向另一 PDF 而误判为历史版。
|
||||
*/
|
||||
export function isReviewCaseHistorical(activeCase: ReviewCaseRef, workItem: WorkItemRef): boolean {
|
||||
const caseNo = String(activeCase?.case_no || '');
|
||||
const currentCaseNo = String(workItem?.current_case_no || '');
|
||||
if (activeCase?.status === 'superseded') return true;
|
||||
if (currentCaseNo && caseNo && currentCaseNo !== caseNo) return true;
|
||||
return Boolean(workItem?.version_replaced && currentCaseNo && caseNo !== currentCaseNo);
|
||||
return Boolean(workItem?.version_replaced && currentCaseNo && caseNo && caseNo !== currentCaseNo);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -346,6 +347,8 @@ export function useShippingOrderReview() {
|
||||
authoritativeOrderTaskNo,
|
||||
{
|
||||
enabled: computed(() => Boolean(authoritativeOrderTaskNo.value)),
|
||||
// 订单处理工作台:旧 progress_version 不得覆盖较新本地投影。
|
||||
monotonicProgressVersion: true,
|
||||
},
|
||||
);
|
||||
const versions = ref<ShippingReviewProgressVersion[]>([]);
|
||||
@@ -378,6 +381,14 @@ export function useShippingOrderReview() {
|
||||
const previewLoading = ref(false);
|
||||
const previewLoadFailed = ref(false);
|
||||
let previewInflight: Promise<boolean> | null = null;
|
||||
/** Case 切换请求代次:快速切换时丢弃过期响应,禁止旧 Case 覆盖新 Case。 */
|
||||
let caseLoadGeneration = 0;
|
||||
/** 当前正在请求或已选定的 Case 编号(与 generation 双校验)。 */
|
||||
const requestedCaseNo = ref<string | null>(null);
|
||||
/** 同 Run 内切换 PDF/Case 的轻量加载态(不触发整页 loading)。 */
|
||||
const caseSwitchLoading = ref(false);
|
||||
/** Case 切换失败(与 Run 级 loadFailed / 进度错误分离)。 */
|
||||
const caseSwitchFailed = ref(false);
|
||||
/** ?????????? Workflow ????? */
|
||||
const showWorkflowProgress = ref(false);
|
||||
const workflowProgressPolling = ref(false);
|
||||
@@ -878,17 +889,65 @@ export function useShippingOrderReview() {
|
||||
}
|
||||
};
|
||||
|
||||
/** ?? PDF ??????????????????????? */
|
||||
const selectCase = async (caseNo: string) => {
|
||||
const [detail, result] = await Promise.all([
|
||||
getWorkspaceShippingOrderReviewCase(caseNo),
|
||||
getWorkspaceShippingOrderReviewEvidence(caseNo),
|
||||
]);
|
||||
activeCase.value = detail;
|
||||
evidence.value = result.items;
|
||||
llmSuggestions.value = detail.llm_suggestions ?? [];
|
||||
/**
|
||||
* 切换 Case 前清理瞬态业务状态。
|
||||
* 核心逻辑:清空 Case/Evidence/LLM 建议/字段与证据焦点/预览与错误标记;
|
||||
* 保留 reviewProgressContext(Run 级进度条按契约绑定整 Run,不随 PDF 跳变)。
|
||||
*/
|
||||
const resetCaseTransientState = () => {
|
||||
activeCase.value = null;
|
||||
evidence.value = [];
|
||||
llmSuggestions.value = [];
|
||||
focusedFieldId.value = null;
|
||||
focusedLineKey.value = null;
|
||||
evidenceDrawerFocus.value = null;
|
||||
draftConflict.value = null;
|
||||
saveFailed.value = false;
|
||||
loadFailed.value = false;
|
||||
statusMessage.value = null;
|
||||
clearPreview();
|
||||
refreshStatusMessage();
|
||||
};
|
||||
|
||||
/**
|
||||
* 切换 PDF/Case:请求代次保护 + 清空业务 Case,防止旧值残留 DOM。
|
||||
* 核心逻辑:立即 activeCase=null;仅保留 Run 进度/PDF 导航;中区纯布局 skeleton;
|
||||
* 失败保持空骨架(不回显旧 Case);过期响应丢弃。
|
||||
* @param caseNo - 目标复核 Case 编号
|
||||
*/
|
||||
const selectCase = async (caseNo: string) => {
|
||||
const target = String(caseNo || '').trim();
|
||||
if (!target) return;
|
||||
const generation = ++caseLoadGeneration;
|
||||
requestedCaseNo.value = target;
|
||||
caseSwitchLoading.value = true;
|
||||
caseSwitchFailed.value = false;
|
||||
// [STEP 1] 清空完整业务 Case 与瞬态,禁止旧字段/Gate/issues 继续渲染。
|
||||
resetCaseTransientState();
|
||||
try {
|
||||
const [detail, result] = await Promise.all([
|
||||
getWorkspaceShippingOrderReviewCase(target),
|
||||
getWorkspaceShippingOrderReviewEvidence(target),
|
||||
]);
|
||||
// [STEP 2] 代次与目标 Case 双校验;过期响应一律丢弃。
|
||||
if (generation !== caseLoadGeneration) return;
|
||||
if (requestedCaseNo.value !== target) return;
|
||||
activeCase.value = detail;
|
||||
evidence.value = result.items;
|
||||
llmSuggestions.value = detail.llm_suggestions ?? [];
|
||||
refreshStatusMessage();
|
||||
} catch {
|
||||
if (generation !== caseLoadGeneration) return;
|
||||
if (requestedCaseNo.value !== target) return;
|
||||
// [STEP 3] 失败保持空骨架,禁止回显切换前 Case。
|
||||
activeCase.value = null;
|
||||
evidence.value = [];
|
||||
llmSuggestions.value = [];
|
||||
caseSwitchFailed.value = true;
|
||||
} finally {
|
||||
if (generation === caseLoadGeneration) {
|
||||
caseSwitchLoading.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/** ?????? Case????????? DTO ??????????????? */
|
||||
@@ -1471,11 +1530,15 @@ export function useShippingOrderReview() {
|
||||
refreshReparseProgress,
|
||||
loading,
|
||||
loadFailed,
|
||||
caseSwitchLoading,
|
||||
caseSwitchFailed,
|
||||
saving,
|
||||
saveFailed,
|
||||
versionsLoading,
|
||||
load,
|
||||
selectCase,
|
||||
resetCaseTransientState,
|
||||
requestedCaseNo,
|
||||
refreshWorkItemContext,
|
||||
currentVersionTarget,
|
||||
openCurrentVersion,
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* features/chat/shipping/conversationProcessingDisplay.spec.ts
|
||||
* 用途:验收主文件回退与正式任务统计。
|
||||
* 依赖:Vitest、conversationProcessingDisplay。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type {
|
||||
ConversationProcessingObject,
|
||||
ConversationProcessingUserTask,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
getPrimaryDocumentName,
|
||||
resolveFormalTaskCount,
|
||||
resolveFormalTaskFileCount,
|
||||
} from './conversationProcessingDisplay';
|
||||
|
||||
/** 构造最小任务卡。 */
|
||||
function task(partial: Partial<ConversationProcessingUserTask>): ConversationProcessingUserTask {
|
||||
return {
|
||||
user_task_no: 'OT-1',
|
||||
group: 'needs_action',
|
||||
can_append: true,
|
||||
...partial,
|
||||
};
|
||||
}
|
||||
|
||||
/** 带可选 primary 标记的 document 行。 */
|
||||
function doc(
|
||||
filename: string,
|
||||
flags: { is_primary?: boolean; primary?: boolean; evidence_role?: string } = {},
|
||||
): ConversationProcessingObject & Record<string, unknown> {
|
||||
return {
|
||||
kind: 'document',
|
||||
object_key: `DOC-${filename}`,
|
||||
label: filename,
|
||||
filename,
|
||||
...flags,
|
||||
};
|
||||
}
|
||||
|
||||
describe('getPrimaryDocumentName', () => {
|
||||
it('prefers primary-marked document filename', () => {
|
||||
const name = getPrimaryDocumentName(task({
|
||||
document_names: ['first.pdf', 'second.pdf'],
|
||||
objects: [doc('first.pdf'), doc('second.pdf', { is_primary: true })],
|
||||
}));
|
||||
expect(name).toBe('second.pdf');
|
||||
});
|
||||
|
||||
it('falls back to document_names[0] without using root_document_id', () => {
|
||||
const name = getPrimaryDocumentName(task({
|
||||
document_names: ['alpha.pdf', 'beta.pdf'],
|
||||
objects: [{
|
||||
kind: 'document',
|
||||
object_key: 'DOC-9',
|
||||
label: 'DOC-9',
|
||||
root_document_id: 99,
|
||||
filename: null,
|
||||
}],
|
||||
}));
|
||||
expect(name).toBe('alpha.pdf');
|
||||
});
|
||||
|
||||
it('returns null when no filename is available', () => {
|
||||
expect(getPrimaryDocumentName(task({ document_names: [], objects: [] }))).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolveFormalTaskCount / resolveFormalTaskFileCount', () => {
|
||||
it('reads summary totals without collapsing files into tasks', () => {
|
||||
const projection = {
|
||||
summary: {
|
||||
total_tasks: 3,
|
||||
total_files: 6,
|
||||
processing: 1,
|
||||
needs_action: 2,
|
||||
history: 0,
|
||||
},
|
||||
needs_action: [],
|
||||
processing: [],
|
||||
completed: [],
|
||||
history: [],
|
||||
};
|
||||
expect(resolveFormalTaskCount(projection)).toBe(3);
|
||||
expect(resolveFormalTaskFileCount(projection)).toBe(6);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,92 @@
|
||||
/**
|
||||
* features/chat/shipping/conversationProcessingDisplay.ts
|
||||
* 用途:右侧栏/对话摘要的纯展示辅助(主文件名、正式任务统计)。
|
||||
* 依赖:ConversationProcessingProjection / UserTask / Object。
|
||||
* 逻辑:由 ShippingConversationProcessingCard、ShippingWorkflowTimeline 消费;
|
||||
* 不推导业务状态;主文件仅 UI 标签;禁止用 root_document_id 当文件名。
|
||||
*/
|
||||
|
||||
import type {
|
||||
ConversationProcessingObject,
|
||||
ConversationProcessingProjection,
|
||||
ConversationProcessingUserTask,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
/**
|
||||
* 判断 object 是否带有可识别的 primary 标记。
|
||||
* 核心逻辑:兼容 is_primary / primary / evidence_role=primary_pdf;不用 root_document_id。
|
||||
* @param object - 任务 objects 行
|
||||
*/
|
||||
function objectHasPrimaryMark(object: ConversationProcessingObject & Record<string, unknown>): boolean {
|
||||
if (object.is_primary === true || object.primary === true) return true;
|
||||
const role = String(object.evidence_role || '').trim().toLowerCase();
|
||||
return role === 'primary_pdf' || role === 'primary';
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析任务「主文件」展示名。
|
||||
* 核心逻辑:优先 objects 中带 primary 标记的 document;否则 document_names[0];都没有返回 null。
|
||||
* @param task - 会话用户可见任务
|
||||
* @returns 主文件名;无则 null(调用方不渲染「主文件」行)
|
||||
*/
|
||||
export function getPrimaryDocumentName(
|
||||
task: ConversationProcessingUserTask | null | undefined,
|
||||
): string | null {
|
||||
if (!task) return null;
|
||||
const objects = Array.isArray(task.objects) ? task.objects : [];
|
||||
for (const raw of objects) {
|
||||
if (!raw || String(raw.kind || '').trim() !== 'document') continue;
|
||||
const row = raw as ConversationProcessingObject & Record<string, unknown>;
|
||||
if (!objectHasPrimaryMark(row)) continue;
|
||||
const name = String(row.filename || row.label || '').trim();
|
||||
if (name) return name;
|
||||
}
|
||||
const names = (Array.isArray(task.document_names) ? task.document_names : [])
|
||||
.map((name) => String(name || '').trim())
|
||||
.filter(Boolean);
|
||||
return names[0] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总正式 OT 任务文件数(不含 order_intake)。
|
||||
* 核心逻辑:优先 summary.total_files;缺失时对 needs_action+processing+completed 的 file_count 求和。
|
||||
* @param projection - 会话 processing 投影
|
||||
*/
|
||||
export function resolveFormalTaskFileCount(
|
||||
projection: ConversationProcessingProjection | null | undefined,
|
||||
): number {
|
||||
if (!projection) return 0;
|
||||
const fromSummary = Number(projection.summary?.total_files);
|
||||
if (Number.isFinite(fromSummary) && fromSummary >= 0 && projection.summary?.total_files != null) {
|
||||
return fromSummary;
|
||||
}
|
||||
const tasks = [
|
||||
...(projection.needs_action || []),
|
||||
...(projection.processing || []),
|
||||
...(projection.completed || []),
|
||||
];
|
||||
return tasks.reduce((sum, task) => {
|
||||
const count = Number(task.file_count);
|
||||
return sum + (Number.isFinite(count) && count > 0 ? count : 0);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 汇总正式 OT 任务数(优先 summary.total_tasks;不含把 files 误当 tasks)。
|
||||
* @param projection - 会话 processing 投影
|
||||
*/
|
||||
export function resolveFormalTaskCount(
|
||||
projection: ConversationProcessingProjection | null | undefined,
|
||||
): number {
|
||||
if (!projection) return 0;
|
||||
const fromSummary = Number(projection.summary?.total_tasks);
|
||||
if (Number.isFinite(fromSummary) && fromSummary >= 0 && projection.summary?.total_tasks != null) {
|
||||
return fromSummary;
|
||||
}
|
||||
return (
|
||||
(projection.needs_action?.length || 0)
|
||||
+ (projection.processing?.length || 0)
|
||||
+ (projection.completed?.length || 0)
|
||||
+ (projection.history?.length || 0)
|
||||
);
|
||||
}
|
||||
@@ -134,14 +134,23 @@ describe('conversationProcessingProjection', () => {
|
||||
}),
|
||||
]);
|
||||
const projection = groupConversationProcessingTasks(tasks, { focusedTaskNo: 'OT-RUN-A' });
|
||||
// 右侧总数不含 history;completed 独立成组。
|
||||
// summary.total_* 含 history(正式 OT 全量);合成路径无截断。
|
||||
expect(projection.summary).toEqual({
|
||||
total_tasks: 4,
|
||||
total_files: 4,
|
||||
total_tasks: 5,
|
||||
total_files: 5,
|
||||
processing: 2,
|
||||
needs_action: 1,
|
||||
completed: 1,
|
||||
history: 1,
|
||||
returned: {
|
||||
needs_action: 1,
|
||||
processing: 2,
|
||||
completed: 1,
|
||||
history: 1,
|
||||
},
|
||||
truncated: { active: false, history: false },
|
||||
has_more_active: false,
|
||||
has_more_history: false,
|
||||
});
|
||||
expect(projection.needs_action[0]?.user_task_no).toBe('OT-RUN-A');
|
||||
expect(projection.processing.map((t) => t.user_task_no).sort()).toEqual([
|
||||
@@ -150,7 +159,7 @@ describe('conversationProcessingProjection', () => {
|
||||
]);
|
||||
expect(projection.completed?.[0]?.user_task_no).toBe('OT-RUN-DONE');
|
||||
expect(projection.history[0]?.user_task_no).toBe('OT-RUN-C');
|
||||
// [UI-02] 缺文件名时 title 为空,交给卡片回退「未命名 PDF」。
|
||||
// title 为空,卡片统一展示「订单识别任务」。
|
||||
const unnamed = projection.processing.find((t) => t.user_task_no === 'OT-RUN-NO-NAME');
|
||||
expect(unnamed?.title).toBeNull();
|
||||
});
|
||||
|
||||
@@ -516,6 +516,7 @@ export function projectConversationProcessingTasks(
|
||||
|
||||
/**
|
||||
* 将任务列表按分组装入 ConversationProcessingProjection。
|
||||
* 核心逻辑:summary.total_* 含 history;合成路径无截断,has_more=false。
|
||||
*/
|
||||
export function groupConversationProcessingTasks(
|
||||
tasks: ConversationProcessingUserTask[],
|
||||
@@ -528,14 +529,23 @@ export function groupConversationProcessingTasks(
|
||||
const processing = tasks.filter((t) => t.group === 'processing');
|
||||
const completed = tasks.filter((t) => t.group === 'completed');
|
||||
const history = tasks.filter((t) => t.group === 'history');
|
||||
const active = [...needs_action, ...processing, ...completed];
|
||||
const all = [...needs_action, ...processing, ...completed, ...history];
|
||||
const summary: ConversationProcessingSummary = {
|
||||
total_tasks: needs_action.length + processing.length + completed.length,
|
||||
total_files: active.reduce((sum, task) => sum + Number(task.file_count || 0), 0),
|
||||
total_tasks: all.length,
|
||||
total_files: all.reduce((sum, task) => sum + Number(task.file_count || 0), 0),
|
||||
processing: processing.length,
|
||||
needs_action: needs_action.length,
|
||||
completed: completed.length,
|
||||
history: history.length,
|
||||
returned: {
|
||||
needs_action: needs_action.length,
|
||||
processing: processing.length,
|
||||
completed: completed.length,
|
||||
history: history.length,
|
||||
},
|
||||
truncated: { active: false, history: false },
|
||||
has_more_active: false,
|
||||
has_more_history: false,
|
||||
};
|
||||
return {
|
||||
summary,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingProcessingWorkItem.ts
|
||||
* 用途:按 work_item_type + work_item_no 轮询统一 ShippingProcessingProjection。
|
||||
* 依赖:shipping.api getWorkspaceShippingProcessingWorkItem、normalizeShippingProcessing。
|
||||
* 逻辑:复核台 / 任务中心双读接入;404 或权威 OT 缺失时保持 null,不打断旧进度 UI。
|
||||
* 依赖:shipping.api、normalizeShippingProcessing、mergeWorkbenchProcessingProjection。
|
||||
* 逻辑:复核台 / 任务中心双读;工作台可启用 monotonicProgressVersion;404 时保持 null。
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
toValue,
|
||||
} from 'vue';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { mergeWorkbenchProcessingProjection } from '@/features/shipping-progress/mergeProcessingProjection';
|
||||
import { getWorkspaceShippingProcessingWorkItem } from '../api/shipping.api';
|
||||
import type { ShippingProcessingProjection } from '../types/shipping.api.types';
|
||||
import { normalizeShippingProcessingProjection } from './normalizeShippingProcessing';
|
||||
@@ -33,7 +34,8 @@ export type ShippingProcessingWorkItemTypeArg = 'order_intake' | 'order_task';
|
||||
*
|
||||
* @param workItemType - order_intake | order_task
|
||||
* @param workItemNo - Intake 编号或 OT 编号(MaybeRef)
|
||||
* @param options.enabled - 是否启用;options.pollMs - 轮询间隔
|
||||
* @param options.enabled - 是否启用;options.pollMs - 轮询间隔;
|
||||
* options.monotonicProgressVersion - 仅工作台:旧 progress_version 不覆盖本地
|
||||
* @returns projection / loading / error / refresh / stop
|
||||
*/
|
||||
export function useShippingProcessingWorkItem(
|
||||
@@ -42,6 +44,8 @@ export function useShippingProcessingWorkItem(
|
||||
options: {
|
||||
enabled?: MaybeRefOrGetter<boolean>;
|
||||
pollMs?: number;
|
||||
/** 仅订单处理工作台开启;任务中心保持默认 false。 */
|
||||
monotonicProgressVersion?: boolean;
|
||||
} = {},
|
||||
): {
|
||||
projection: Ref<ShippingProcessingProjection | null>;
|
||||
@@ -57,6 +61,7 @@ export function useShippingProcessingWorkItem(
|
||||
let generation = 0;
|
||||
let stopped = false;
|
||||
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
||||
const monotonic = Boolean(options.monotonicProgressVersion);
|
||||
|
||||
/**
|
||||
* 清除轮询定时器。
|
||||
@@ -95,10 +100,14 @@ export function useShippingProcessingWorkItem(
|
||||
const raw = await getWorkspaceShippingProcessingWorkItem(workItemType, no);
|
||||
if (stopped || gen !== generation) return;
|
||||
const normalized = normalizeShippingProcessingProjection(raw);
|
||||
projection.value = normalized;
|
||||
// [STEP] 工作台单调合并:旧包丢弃;新包整包替换;同版本浅合并。任务中心不启用。
|
||||
projection.value = monotonic
|
||||
? mergeWorkbenchProcessingProjection(projection.value, normalized)
|
||||
: normalized;
|
||||
error.value = null;
|
||||
clearTimer();
|
||||
if (normalized && !TERMINAL_STATUSES.has(normalized.status) && !stopped) {
|
||||
const next = projection.value;
|
||||
if (next && !TERMINAL_STATUSES.has(next.status) && !stopped) {
|
||||
timer = window.setTimeout(() => {
|
||||
void refresh();
|
||||
}, pollMs);
|
||||
|
||||
@@ -83,6 +83,10 @@ export type ShippingProcessingActionIntent =
|
||||
| 'none'
|
||||
| 'open_order_review'
|
||||
| 'edit_formal_task'
|
||||
| 'open_profile_review'
|
||||
| 'confirm_customer'
|
||||
| 'resolve_field_conflicts'
|
||||
| 'adjudicate_duplicate'
|
||||
| 'open_inventory_source_review'
|
||||
| 'open_inventory_match_review'
|
||||
| 'open_shortage_review'
|
||||
@@ -362,13 +366,27 @@ export interface ConversationProcessingUserTask {
|
||||
*/
|
||||
export interface ConversationProcessingSummary {
|
||||
total_tasks: number;
|
||||
/** 当前活跃任务覆盖的文件数(按 PDF 归并后) */
|
||||
/** 当前会话正式任务覆盖的文件总数(含处理记录,不含 order_intake) */
|
||||
total_files?: number;
|
||||
processing: number;
|
||||
needs_action: number;
|
||||
/** 识别完成且尚未查看的成功通知数 */
|
||||
completed?: number;
|
||||
history: number;
|
||||
/** 截断前全量相对返回列表的截断标记(BE-02) */
|
||||
truncated?: {
|
||||
active?: boolean;
|
||||
history?: boolean;
|
||||
};
|
||||
/** 各分组实际返回条数 */
|
||||
returned?: {
|
||||
needs_action?: number;
|
||||
processing?: number;
|
||||
completed?: number;
|
||||
history?: number;
|
||||
};
|
||||
has_more_active?: boolean;
|
||||
has_more_history?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1990,6 +2008,10 @@ export interface ShippingOrderReviewCase {
|
||||
message?: string | null;
|
||||
task_process_status?: string | null;
|
||||
} | null;
|
||||
/** 用户可见自动建单/推进态;waiting_to_start ≠ running。 */
|
||||
automation?: ShippingOrderReviewAutomation | null;
|
||||
/** 仅管理员;普通用户不下发技术 Gate 码。 */
|
||||
technical_progress?: ShippingOrderReviewTechnicalProgress | null;
|
||||
candidate?: { candidate_no: string; validation_status: string; po_number?: string | null } | null;
|
||||
schema: { schema_version_id: number; fields: ShippingOrderReviewSchemaField[] };
|
||||
draft?: {
|
||||
@@ -2272,6 +2294,8 @@ export interface ShippingOrderReviewProfileMatch {
|
||||
fallback_reason_codes: string[];
|
||||
needs_review: boolean;
|
||||
available: boolean;
|
||||
/** 普通用户返回 admin_only;管理员返回完整审计内容。 */
|
||||
visibility?: 'admin_only' | 'admin' | string | null;
|
||||
table_counts?: {
|
||||
candidate?: number;
|
||||
matched?: number;
|
||||
@@ -2280,6 +2304,33 @@ export interface ShippingOrderReviewProfileMatch {
|
||||
};
|
||||
}
|
||||
|
||||
/** Case 级自动建单/推进状态(资格 ≠ 正在执行)。 */
|
||||
export type ShippingOrderReviewAutomationStatus =
|
||||
| 'idle'
|
||||
| 'waiting_to_start'
|
||||
| 'queued'
|
||||
| 'running'
|
||||
| 'failed'
|
||||
| 'manual_fallback'
|
||||
| 'completed';
|
||||
|
||||
export interface ShippingOrderReviewAutomation {
|
||||
status: ShippingOrderReviewAutomationStatus | string;
|
||||
retryable?: boolean;
|
||||
task_no?: string | null;
|
||||
can_auto_create?: boolean;
|
||||
can_build?: boolean;
|
||||
job_id?: number | null;
|
||||
reason_code?: string | null;
|
||||
}
|
||||
|
||||
/** 管理员可见的技术 Gate 进度(普通用户不下发)。 */
|
||||
export interface ShippingOrderReviewTechnicalProgress {
|
||||
gate_code?: string | null;
|
||||
status?: string | null;
|
||||
blocking_reason_code?: string | null;
|
||||
}
|
||||
|
||||
/** 建单前 Reservation 行级投影。 */
|
||||
export interface ShippingOrderReviewReservationLine {
|
||||
line_index?: number;
|
||||
|
||||
@@ -15,6 +15,7 @@ import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
|
||||
import {
|
||||
auditWorkspaceShippingOrderReviewEligibilityDetails,
|
||||
auditWorkspaceShippingOrderReviewVersionHistory,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
const focusSuggestionField = vi.fn();
|
||||
@@ -105,6 +106,8 @@ const activeCase = ref({
|
||||
issues: [],
|
||||
},
|
||||
process_gate: null,
|
||||
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
|
||||
automation: { status: 'idle', can_auto_create: false, can_build: true },
|
||||
});
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
|
||||
@@ -114,6 +117,11 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
|
||||
auditWorkspaceShippingOrderReviewVersionHistory: vi.fn().mockResolvedValue({ audited: true, case_no: 'CASE-1' }),
|
||||
auditWorkspaceShippingOrderReviewEligibilityDetails: vi.fn().mockResolvedValue({ audited: true, case_no: 'CASE-1' }),
|
||||
autoProgressWorkspaceShippingTask: vi.fn().mockResolvedValue({ status: 'ok' }),
|
||||
retryWorkspaceShippingOrderStpAutoCreate: vi.fn().mockResolvedValue({
|
||||
status: 'queued',
|
||||
job_id: 901,
|
||||
case: null,
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -140,6 +148,9 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
|
||||
isReadOnly: computed(() => false),
|
||||
loading: ref(false),
|
||||
loadFailed: ref(false),
|
||||
caseSwitchLoading: ref(false),
|
||||
caseSwitchFailed: ref(false),
|
||||
requestedCaseNo: ref(null),
|
||||
saving: ref(false),
|
||||
saveFailed: ref(false),
|
||||
versionsLoading: ref(false),
|
||||
@@ -314,6 +325,9 @@ async function mountView() {
|
||||
loading: '加载中',
|
||||
unavailable: '不可用',
|
||||
retryLoad: '重试',
|
||||
caseSwitchLoading: '正在加载当前 PDF…',
|
||||
caseSwitchFailed: '当前 PDF 加载失败,可重试',
|
||||
caseSwitchRetry: '重试',
|
||||
documentNavigation: 'PDF 导航',
|
||||
documents: 'PDF',
|
||||
unnamedDocument: '未命名',
|
||||
@@ -357,11 +371,24 @@ async function mountView() {
|
||||
moreLineFields: '更多列 {count}',
|
||||
collapseFields: '收起',
|
||||
addLine: '新增行',
|
||||
copyLine: '复制行',
|
||||
deleteLine: '删除行',
|
||||
emptyValue: '空',
|
||||
valueSources: { machine: '系统' },
|
||||
primaryBlockTitle: '阻断',
|
||||
primaryBlockParty: '{party}',
|
||||
versionHistory: { title: '版本历史' },
|
||||
auditTrail: { open: '查看审计' },
|
||||
customerResolution: {
|
||||
title: '客户确认',
|
||||
unresolved: '未确认',
|
||||
confirmed: '已确认',
|
||||
select: '选择客户',
|
||||
search: '搜索',
|
||||
empty: '无候选',
|
||||
confirm: '确认',
|
||||
cancel: '取消',
|
||||
},
|
||||
workbench: {
|
||||
mode: {
|
||||
standard: '标准复核',
|
||||
@@ -370,6 +397,7 @@ async function mountView() {
|
||||
reparse: '重新识别',
|
||||
confirm_progress: '建单进度',
|
||||
},
|
||||
moreStatus: '更多状态',
|
||||
enterInventory: '查看库存问题',
|
||||
returnStandard: '返回标准复核',
|
||||
openPdf: '打开 PDF',
|
||||
@@ -381,6 +409,8 @@ async function mountView() {
|
||||
openVersionHistory: '版本历史',
|
||||
auditFailed: '审计记录失败,敏感面板未打开,请重试',
|
||||
summaryRail: '摘要',
|
||||
actionSuccess: '已完成',
|
||||
resultNotReady: '结果未就绪',
|
||||
},
|
||||
evidenceAt: 'PDF 第 {page} 页',
|
||||
evidenceNoHighlight: '无坐标',
|
||||
@@ -429,6 +459,8 @@ async function mountView() {
|
||||
returnToChat: '返回对话查看进度',
|
||||
retry: '重试自动推进',
|
||||
retrySuccess: '已重新触发',
|
||||
retryStp: '重试自动推进',
|
||||
retryStpSuccess: '已重新入队自动建单',
|
||||
},
|
||||
confirmSuccess: '{taskNo}',
|
||||
confirmAutoProgress: '{taskNo}',
|
||||
@@ -540,7 +572,8 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-order-review-view"]').attributes('data-workbench-mode')).toBe('standard');
|
||||
expect(wrapper.find('[data-testid="review-main-editor"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-build-gate-rail"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-document-navigation"]').exists()).toBe(true);
|
||||
// 单 OT/PDF:产品规则隐藏文档导航(mode=hidden),不得断言节点存在。
|
||||
expect(wrapper.find('[data-testid="review-document-navigation"]').exists()).toBe(false);
|
||||
// 标准复核不展示仅含标题的空模式条,避免占用主编辑区高度。
|
||||
expect(wrapper.find('[data-testid="review-workbench-mode"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('对话上下文');
|
||||
@@ -698,6 +731,77 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
expect(banner.text()).toContain('SN-RECOVER-1');
|
||||
});
|
||||
|
||||
it('shows STP retry button for failed automation and calls retry API (UI-02)', async () => {
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
status: 'ready',
|
||||
confirmed_task_no: null,
|
||||
available_actions: ['validate', 'confirm', 'retry_stp_auto_create'],
|
||||
automation: {
|
||||
status: 'failed',
|
||||
retryable: true,
|
||||
can_auto_create: true,
|
||||
can_build: true,
|
||||
reason_code: 'stp_job_failed',
|
||||
},
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
await flushPromises();
|
||||
const btn = wrapper.find('[data-testid="review-retry-stp-auto-create"]');
|
||||
// 关键断言:failed 态必须露出 STP 重试入口(非确认后 auto_progress 重试)。
|
||||
expect(btn.exists()).toBe(true);
|
||||
await btn.trigger('click');
|
||||
await flushPromises();
|
||||
expect(retryWorkspaceShippingOrderStpAutoCreate).toHaveBeenCalledWith('CASE-1');
|
||||
});
|
||||
|
||||
it('shows STP retry for manual_fallback while keeping confirm fallback (UI-02)', async () => {
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
status: 'ready',
|
||||
confirmed_task_no: null,
|
||||
available_actions: ['validate', 'confirm', 'retry_stp_auto_create'],
|
||||
automation: {
|
||||
status: 'manual_fallback',
|
||||
retryable: true,
|
||||
can_auto_create: true,
|
||||
can_build: true,
|
||||
reason_code: 'stp_waiting_timeout',
|
||||
},
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="review-retry-stp-auto-create"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('hides profile match panel when profile_match.available is false', async () => {
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
await flushPromises();
|
||||
// 关键断言:普通用户裁剪后 DOM 不得出现模板匹配面板。
|
||||
expect(wrapper.find('[data-testid="review-profile-match-panel"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('shows profile match panel for admin when profile_match.available is true', async () => {
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
profile_match: {
|
||||
available: true,
|
||||
visibility: 'admin',
|
||||
status: 'matched',
|
||||
candidates: [{ profile_id: 1, score: 0.9 }],
|
||||
selected_profile: { profile_id: 1, profile_code: 'P1' },
|
||||
},
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="review-profile-match-panel"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('treats HTTP/confirm_ok success with confirm_outcome failed as progress failure', async () => {
|
||||
confirmMock.mockResolvedValueOnce({
|
||||
task_no: 'SN-CONFIRM-PROGRESS-FAIL',
|
||||
|
||||
@@ -31,6 +31,7 @@ import {
|
||||
attemptWorkspaceShippingOrderReviewFieldLocate,
|
||||
getWorkspaceShippingOrderReviewEvidenceItem,
|
||||
getWorkspaceShippingTask,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
viewWorkspaceShippingOrderReviewHighlightDiagnostic,
|
||||
} from '../api/shipping.api';
|
||||
import ReviewActionConfirmDialog, {
|
||||
@@ -42,6 +43,7 @@ import ReviewBuildEligibilitySummary from '../components/shipping-review/ReviewB
|
||||
import ReviewCustomerResolutionPanel from '../components/shipping-review/ReviewCustomerResolutionPanel.vue';
|
||||
import ReviewFieldConflictPanel from '../components/shipping-review/ReviewFieldConflictPanel.vue';
|
||||
import ReviewDuplicatePanel from '../components/shipping-review/ReviewDuplicatePanel.vue';
|
||||
import ReviewProfileMatchPanel from '../components/shipping-review/ReviewProfileMatchPanel.vue';
|
||||
import ReviewReservationPanel from '../components/shipping-review/ReviewReservationPanel.vue';
|
||||
import ReviewFulfillmentDecisionPanel from '../components/shipping-review/ReviewFulfillmentDecisionPanel.vue';
|
||||
import ReviewFulfillmentSummaryCard from '../components/shipping-review/ReviewFulfillmentSummaryCard.vue';
|
||||
@@ -68,6 +70,10 @@ import ReviewLlmSuggestionDrawer from '../components/shipping-review/ReviewLlmSu
|
||||
import ReviewVersionHistoryDrawer from '../components/shipping-review/ReviewVersionHistoryDrawer.vue';
|
||||
import ReviewProcessDetailDrawer from '@/features/shipping-progress/components/ReviewProcessDetailDrawer.vue';
|
||||
import { useProcessingActionPresentation } from '@/features/shipping-progress/composables/useProcessingActionPresentation';
|
||||
import {
|
||||
resolveWorkbenchActionItem,
|
||||
type WorkbenchPanelAvailability,
|
||||
} from '@/features/shipping-progress/workbenchActionRegistry';
|
||||
import { parseOrderReviewConfirmResponse } from '../shipping-review/parseOrderReviewConfirmResponse';
|
||||
import { REVIEW_BUILD_ELIGIBILITY_BLOCKED, useShippingOrderReview } from '../shipping-review/useShippingOrderReview';
|
||||
import type { ActionPresentationItem } from '@/features/shipping-progress/types';
|
||||
@@ -108,6 +114,8 @@ const {
|
||||
isReadOnly,
|
||||
loading,
|
||||
loadFailed,
|
||||
caseSwitchLoading,
|
||||
caseSwitchFailed,
|
||||
saving,
|
||||
saveFailed,
|
||||
versionsLoading,
|
||||
@@ -122,6 +130,7 @@ const {
|
||||
ensurePreviewLoaded,
|
||||
load,
|
||||
selectCase,
|
||||
requestedCaseNo,
|
||||
refreshWorkItemContext,
|
||||
openCurrentVersion,
|
||||
reloadLatestDraft,
|
||||
@@ -212,11 +221,61 @@ const pendingSwitchCaseNo = ref<string | null>(null);
|
||||
const otNavMode = ref<ReviewDocumentNavMode>('hidden');
|
||||
const closeFulfillmentOpen = ref(false);
|
||||
const closeFulfillmentLineKeys = ref<string[]>([]);
|
||||
/** focus=evidence 深链只消费一次,切换 PDF 后不得再次自动打开。 */
|
||||
const evidenceFocusConsumed = ref(false);
|
||||
|
||||
/** can_build && can_auto_create 时底栏隐藏「确认建单」并提示自动推进。 */
|
||||
const hideConfirmBecauseAutoGate = computed(() => Boolean(
|
||||
buildEligibility.value?.can_build && buildEligibility.value?.can_auto_create,
|
||||
));
|
||||
/** can_build && can_auto_create 时底栏隐藏「确认建单」;文案仅表示资格达标等待入队,不等于正在推进。 */
|
||||
/** queued|running 时隐藏「确认并创建任务」;waiting_to_start / failed / manual_fallback 保留人工兜底。 */
|
||||
const hideConfirmBecauseAutoGate = computed(() => {
|
||||
const automationStatus = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
|
||||
if (['queued', 'running'].includes(automationStatus)) return true;
|
||||
if (String(activeCase.value?.status || '') === 'confirmed') return true;
|
||||
if (String(activeCase.value?.confirmed_task_no || '').trim()) return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
/** 底栏是否展示自动建单提示(等待 / 推进中)。 */
|
||||
const showAutoGateHint = computed(() => {
|
||||
const automationStatus = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
|
||||
return ['waiting_to_start', 'queued', 'running'].includes(automationStatus);
|
||||
});
|
||||
|
||||
/** failed / manual_fallback 时展示「重试自动推进」。 */
|
||||
const showStpRetry = computed(() => {
|
||||
const automation = activeCase.value?.automation;
|
||||
const status = String(automation?.status || '').trim().toLowerCase();
|
||||
if (!['failed', 'manual_fallback'].includes(status)) return false;
|
||||
if (String(activeCase.value?.status || '') === 'confirmed') return false;
|
||||
if (String(activeCase.value?.confirmed_task_no || '').trim()) return false;
|
||||
return Boolean(automation?.retryable) || (activeCase.value?.available_actions || []).includes('retry_stp_auto_create');
|
||||
});
|
||||
|
||||
/**
|
||||
* 是否存在已确认的自动建单/推进 Job(queued|running)。
|
||||
* 核心逻辑:仅 post_confirm 或投影 status 明确入队/运行时为 true;资格达标不算。
|
||||
*/
|
||||
const hasConfirmedAutomationJob = computed(() => {
|
||||
const automationStatus = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
|
||||
if (['queued', 'running', 'completed'].includes(automationStatus)) return true;
|
||||
const progress = activeCase.value?.post_confirm_auto_progress;
|
||||
const progressStatus = String(progress?.status || '').trim().toLowerCase();
|
||||
if (['queued', 'running', 'started', 'in_progress'].includes(progressStatus)) return true;
|
||||
const projStatus = String(shippingProcessingProjection.value?.status || '').trim().toLowerCase();
|
||||
const hasTask = Boolean(
|
||||
String(activeCase.value?.confirmed_task_no || '').trim()
|
||||
|| String(authoritativeOrderTaskNo.value || '').trim(),
|
||||
);
|
||||
return hasTask && ['processing', 'automating', 'queued'].includes(projStatus);
|
||||
});
|
||||
|
||||
/**
|
||||
* 底栏自动资格提示:无真实 Job 时降级为「等待系统启动」,禁止「正在推进」。
|
||||
*/
|
||||
const autoGateHintKey = computed(() => (
|
||||
hasConfirmedAutomationJob.value
|
||||
? 'chat.shippingOrderReview.buildEligibility.autoGateRunningHint'
|
||||
: 'chat.shippingOrderReview.buildEligibility.autoGateWaitingHint'
|
||||
));
|
||||
|
||||
/** 证据浮窗是否以浮动方式展示(打开且未固定为侧栏)。 */
|
||||
const evidenceFloating = computed(
|
||||
@@ -279,12 +338,17 @@ function hydrateConfirmProgressFromCase() {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 深链 focus=evidence:仅首次进入且尚未消费时打开证据模式;消费后立即从 URL 清除 focus。
|
||||
* 切换 PDF/Case 不得因残留 query 或新 evidence 加载再次自动打开。
|
||||
*/
|
||||
watch(
|
||||
() => [evidence.value, reviewFocus.value] as const,
|
||||
() => [evidence.value, reviewFocus.value, activeCase.value?.case_no] as const,
|
||||
([items, focus]) => {
|
||||
if (focus !== 'evidence' || !items?.length) return;
|
||||
if (focus !== 'evidence' || evidenceFocusConsumed.value || !items?.length) return;
|
||||
const first = items.find((item) => item.bbox) || items[0];
|
||||
if (!first) return;
|
||||
evidenceFocusConsumed.value = true;
|
||||
focusedEvidenceRef.value = {
|
||||
fieldId: String(first.field_id || '').trim(),
|
||||
lineIndex: first.line_index == null ? undefined : Number(first.line_index),
|
||||
@@ -292,6 +356,9 @@ watch(
|
||||
workbenchMode.value = 'evidence';
|
||||
panelState.value = { ...panelState.value, pdfOpen: true };
|
||||
void ensurePreviewLoaded();
|
||||
const nextQuery = { ...route.query };
|
||||
delete nextQuery.focus;
|
||||
void router.replace({ query: nextQuery });
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
@@ -882,12 +949,44 @@ const canEnterInventory = computed(() => (
|
||||
));
|
||||
const availableActions = computed(() => activeCase.value?.available_actions || []);
|
||||
|
||||
/** 订单处理工作台写权限(只读查看为 false)。 */
|
||||
const workbenchActionsExecutable = computed(() => !isReadOnly.value);
|
||||
|
||||
/** 当前 Case 面板可用性,供注册表 requiresPanel 守卫。 */
|
||||
const workbenchPanelAvailability = computed((): WorkbenchPanelAvailability => {
|
||||
const c = activeCase.value;
|
||||
return {
|
||||
customerUnresolved: Boolean(c && !c.customer_resolution?.resolved),
|
||||
hasFieldConflicts: Boolean((c?.field_conflicts || []).length),
|
||||
hasDuplicateAdjudication: Boolean(c?.duplicate?.needs_adjudication),
|
||||
hasProfileMatch: Boolean(c?.profile_match?.available),
|
||||
hasInventoryCandidates: Boolean((routingRecoveryLines.value || []).length),
|
||||
hasInventoryIssues: Boolean(
|
||||
(routingRecoveryLines.value || []).length
|
||||
|| c?.line_fulfillment?.has_shortage,
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
/** 底栏流程写操作:与原进度条 ActionBar 同源,surface=review。 */
|
||||
const flowProjectionRef = computed(() => shippingProcessingProjection.value);
|
||||
const flowPresentation = useProcessingActionPresentation(flowProjectionRef, { surface: 'review' });
|
||||
const flowPresentationOptions = computed(() => ({
|
||||
surface: 'review' as const,
|
||||
actionsExecutable: workbenchActionsExecutable.value,
|
||||
panels: workbenchPanelAvailability.value,
|
||||
}));
|
||||
const flowPresentation = useProcessingActionPresentation(flowProjectionRef, flowPresentationOptions);
|
||||
const flowActionBusy = ref(false);
|
||||
const viewResultLoading = ref(false);
|
||||
|
||||
/** 系统自动推进中:底栏隐藏无效主写按钮。 */
|
||||
const customerResolutionPanelRef = ref<{ openSelectDialog: () => Promise<void> } | null>(null);
|
||||
const customerResolutionWideRef = ref<{ openSelectDialog: () => Promise<void> } | null>(null);
|
||||
const fieldConflictPanelRef = ref<{ focusFirstConflict: () => void } | null>(null);
|
||||
const duplicatePanelRef = ref<{ focusAdjudication: () => void } | null>(null);
|
||||
|
||||
/** 系统自动推进中:仅当存在确认 Job 时隐藏主写按钮;资格达标不算 automating。 */
|
||||
const isProcessingAutomating = computed(() => {
|
||||
if (!hasConfirmedAutomationJob.value) return false;
|
||||
const status = String(shippingProcessingProjection.value?.status || '').trim().toLowerCase();
|
||||
return ['processing', 'automating', 'queued'].includes(status)
|
||||
&& !shippingProcessingProjection.value?.currentGate?.nextActionCode;
|
||||
@@ -1350,57 +1449,226 @@ const retryAutoProgressAfterConfirm = async () => {
|
||||
};
|
||||
|
||||
/**
|
||||
* 统一动作栏点击:优先复用已有写路径;履约业务动作委托 TaskTodoPanel。
|
||||
* STP 自动建单失败 / manual_fallback:调用专用 retry API 重新入队。
|
||||
* 核心逻辑:与确认后 auto_progress 重试分离;成功后刷新 Case 投影。
|
||||
*/
|
||||
const onUnifiedProcessingAction = (item: ActionPresentationItem) => {
|
||||
const intent = item.intent;
|
||||
if (intent === 'retry') {
|
||||
void retryAutoProgressAfterConfirm();
|
||||
return;
|
||||
}
|
||||
if (intent === 'refresh') {
|
||||
void refreshShippingProcessing();
|
||||
void loadFormalTaskDetail();
|
||||
return;
|
||||
}
|
||||
if (intent === 'download_excel' && confirmedNoticeTaskNo.value) {
|
||||
void (async () => {
|
||||
try {
|
||||
await downloadWorkspaceShippingExcelFile(confirmedNoticeTaskNo.value);
|
||||
await loadFormalTaskDetail();
|
||||
} catch (error: unknown) {
|
||||
msg.warning(error instanceof Error ? error.message : t('errors.generic'));
|
||||
}
|
||||
})();
|
||||
return;
|
||||
}
|
||||
if (
|
||||
intent === 'open_manual_upload'
|
||||
|| intent === 'open_inventory_source_review'
|
||||
|| intent === 'open_inventory_match_review'
|
||||
|| intent === 'open_shortage_review'
|
||||
|| intent === 'upload_inventory_file'
|
||||
|| intent === 'regenerate_excel'
|
||||
) {
|
||||
// [UI-01] 履约动作统一由 ActionBar 触发,表单/弹窗仍由 TaskTodoPanel 承接。
|
||||
if (!formalTaskDetail.value && confirmedNoticeTaskNo.value) {
|
||||
void loadFormalTaskDetail().then(() => {
|
||||
void formalTodoPanelRef.value?.invokeActionByCode(item.actionCode);
|
||||
});
|
||||
const retryStpAutoCreate = async () => {
|
||||
const caseNo = String(activeCase.value?.case_no || '').trim();
|
||||
if (!caseNo || progressRetrying.value) return;
|
||||
progressRetrying.value = true;
|
||||
try {
|
||||
const result = await retryWorkspaceShippingOrderStpAutoCreate(caseNo);
|
||||
if (result.case) {
|
||||
activeCase.value = result.case;
|
||||
} else {
|
||||
void formalTodoPanelRef.value?.invokeActionByCode(item.actionCode);
|
||||
await reloadLatestDraft();
|
||||
}
|
||||
void nextTick(() => {
|
||||
document
|
||||
.querySelector('[data-testid="review-formal-task-todo-panel"]')
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
msg.success(t('chat.shippingOrderReview.autoProgress.retryStpSuccess'));
|
||||
} catch (error) {
|
||||
msg.error(resolveReviewErrorMessage(error));
|
||||
} finally {
|
||||
progressRetrying.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 滚动到工作台锚点(data-testid)。
|
||||
*/
|
||||
function scrollWorkbenchAnchor(testId: string | null | undefined) {
|
||||
const id = String(testId || '').trim();
|
||||
if (!id) return;
|
||||
void nextTick(() => {
|
||||
document
|
||||
.querySelector(`[data-testid="${id}"]`)
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保正式任务详情已加载且身份一致,再委托 TaskTodoPanel。
|
||||
*
|
||||
* @returns 是否可继续 invoke
|
||||
*/
|
||||
async function ensureFormalTaskDetailReady(): Promise<boolean> {
|
||||
const taskNo = confirmedNoticeTaskNo.value;
|
||||
if (!taskNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return false;
|
||||
}
|
||||
if (!formalTaskDetail.value || formalTaskDetail.value.task_no !== taskNo) {
|
||||
await loadFormalTaskDetail();
|
||||
}
|
||||
if (!formalTaskDetail.value || formalTaskDetail.value.task_no !== taskNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 统一动作栏点击:经注册表派发到显式执行器(禁止散落 if / Gate POST / 盲调 API)。
|
||||
*/
|
||||
const onUnifiedProcessingAction = async (item: ActionPresentationItem) => {
|
||||
if (flowActionBusy.value) return;
|
||||
// 建单后库存源别名须解析为 todo_panel,禁止再走候选面板。
|
||||
const entry = resolveWorkbenchActionItem(item, {
|
||||
postCreate: hasCreatedShippingTask.value,
|
||||
});
|
||||
if (!entry) {
|
||||
return;
|
||||
}
|
||||
if (intent === 'open_order_review' || intent === 'edit_formal_task') {
|
||||
// 已在订单处理工作台,无需跳转。
|
||||
if (entry.isWrite && !workbenchActionsExecutable.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
flowActionBusy.value = true;
|
||||
try {
|
||||
const behavior = entry.reviewBehavior;
|
||||
|
||||
if (behavior === 'hidden_on_review' || behavior === 'refresh_strip_only') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'open_customer_dialog') {
|
||||
// [A1] 先滚动客户面板,再打开既有确认弹窗;禁止直调确认 API。
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-customer-resolution-panel');
|
||||
const taskNo = String(
|
||||
confirmedNoticeTaskNo.value
|
||||
|| activeCase.value?.confirmed_task_no
|
||||
|| activeCase.value?.order_task_no
|
||||
|| authoritativeOrderTaskNo.value
|
||||
|| '',
|
||||
).trim();
|
||||
if (taskNo && typeof page.openShippingCustomerDialog === 'function') {
|
||||
await page.openShippingCustomerDialog(taskNo);
|
||||
return;
|
||||
}
|
||||
const panel = customerResolutionWideRef.value || customerResolutionPanelRef.value;
|
||||
if (panel?.openSelectDialog) {
|
||||
await panel.openSelectDialog();
|
||||
return;
|
||||
}
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'focus_field_conflicts') {
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-field-conflict-panel');
|
||||
if (fieldConflictPanelRef.value?.focusFirstConflict) {
|
||||
fieldConflictPanelRef.value.focusFirstConflict();
|
||||
} else {
|
||||
const first = activeCase.value?.field_conflicts?.[0];
|
||||
if (first) {
|
||||
focusFieldConflict({
|
||||
fieldCode: first.field_code,
|
||||
lineIndex: first.line_index ?? null,
|
||||
lineKey: first.line_key ?? null,
|
||||
});
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'focus_duplicate_panel') {
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-duplicate-panel');
|
||||
duplicatePanelRef.value?.focusAdjudication?.();
|
||||
void nextTick(() => {
|
||||
document
|
||||
.querySelector('[data-testid="review-duplicate-actions"]')
|
||||
?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'focus_profile_panel') {
|
||||
void router.replace({ query: { ...route.query, focus: 'profile' } });
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-profile-match-panel');
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'open_inventory_candidates') {
|
||||
// [B1] 仅建单前:进入库存模式并定位候选面板;禁止 TaskTodoPanel / 正式 OT API。
|
||||
// 建单后由 resolveWorkbenchActionItem(postCreate) 改写为 todo_panel。
|
||||
if (hasCreatedShippingTask.value) {
|
||||
if (!(await ensureFormalTaskDetailReady())) return;
|
||||
scrollWorkbenchAnchor('review-formal-task-todo-panel');
|
||||
await formalTodoPanelRef.value?.invokeActionByCode('confirm_inventory_source');
|
||||
return;
|
||||
}
|
||||
workbenchMode.value = 'inventory';
|
||||
await nextTick();
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-inventory-candidates-panel');
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'focus_inventory_issues') {
|
||||
workbenchMode.value = 'inventory';
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-inventory-issue-list');
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'view_result') {
|
||||
// [C1] 详情未返回时先 loading + loadFormalTaskDetail,身份匹配后再定位结果区。
|
||||
viewResultLoading.value = true;
|
||||
try {
|
||||
const expectedTaskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (expectedTaskNo) {
|
||||
const ready = await ensureFormalTaskDetailReady();
|
||||
if (!ready) return;
|
||||
if (String(formalTaskDetail.value?.task_no || '').trim() !== expectedTaskNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return;
|
||||
}
|
||||
}
|
||||
await nextTick();
|
||||
const resultEl = document.querySelector('[data-testid="review-formal-task-result-region"]');
|
||||
if (resultEl) {
|
||||
resultEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
} else {
|
||||
scrollWorkbenchAnchor('review-formal-task-todo-panel');
|
||||
msg.info(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
}
|
||||
} finally {
|
||||
viewResultLoading.value = false;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'view_record') {
|
||||
openAuditTrail();
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'download') {
|
||||
if (!confirmedNoticeTaskNo.value) {
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return;
|
||||
}
|
||||
await downloadWorkspaceShippingExcelFile(confirmedNoticeTaskNo.value);
|
||||
await loadFormalTaskDetail();
|
||||
await refreshShippingProcessing();
|
||||
msg.success(t('chat.shippingOrderReview.workbench.actionSuccess'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'retry') {
|
||||
await retryAutoProgressAfterConfirm();
|
||||
await refreshShippingProcessing();
|
||||
return;
|
||||
}
|
||||
|
||||
if (behavior === 'todo_panel') {
|
||||
if (!(await ensureFormalTaskDetailReady())) return;
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-formal-task-todo-panel');
|
||||
const todoCode = entry.todoActionCode || item.actionCode;
|
||||
await formalTodoPanelRef.value?.invokeActionByCode(todoCode);
|
||||
return;
|
||||
}
|
||||
} catch (error: unknown) {
|
||||
msg.warning(error instanceof Error ? error.message : t('errors.generic'));
|
||||
} finally {
|
||||
flowActionBusy.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const reportSave = async (action: () => Promise<unknown> | null) => {
|
||||
@@ -1636,11 +1904,47 @@ const selectReplacement = (event: Event) => {
|
||||
|
||||
/**
|
||||
* 实际切换 Case(无未保存拦截)。
|
||||
* 核心逻辑:清理证据焦点与确认成功条;非 dock 关闭证据模式;只更新 URL,
|
||||
* 由 run/case watch 在同 Run 内走轻量 selectCase,避免整页 load 误报历史版与加载中。
|
||||
*/
|
||||
const select = async (caseNo: string) => {
|
||||
const wasDocked = panelState.value.pdfDocked && panelState.value.pdfOpen;
|
||||
const switchingToCurrent = Boolean(
|
||||
reviewProgressContext.value?.current_case_no
|
||||
&& caseNo === reviewProgressContext.value.current_case_no
|
||||
&& isViewingHistoricalVersion.value,
|
||||
);
|
||||
|
||||
focusedEvidenceRef.value = null;
|
||||
confirmSuccess.value = null;
|
||||
|
||||
// [STEP 1] 浮窗模式关闭;dock 保留布局。切到当前版本强制关浮窗(G19)。
|
||||
if (!wasDocked || switchingToCurrent) {
|
||||
if (workbenchMode.value === 'evidence') {
|
||||
workbenchMode.value = 'standard';
|
||||
}
|
||||
panelState.value = {
|
||||
...panelState.value,
|
||||
pdfOpen: wasDocked && !switchingToCurrent,
|
||||
pdfExpanded: false,
|
||||
pdfDocked: wasDocked && !switchingToCurrent ? panelState.value.pdfDocked : false,
|
||||
eligibilityDetailsOpen: false,
|
||||
};
|
||||
}
|
||||
|
||||
// [STEP 2] 先轻量加载目标 Case,再同步 URL;watch 见已是当前 Case 则跳过二次 load。
|
||||
await selectCase(caseNo);
|
||||
await router.replace({ query: { ...route.query, case: caseNo } });
|
||||
const docId = activeCase.value?.document?.id;
|
||||
const nextQuery: Record<string, unknown> = { ...route.query, case: caseNo };
|
||||
delete nextQuery.focus;
|
||||
delete nextQuery.candidate;
|
||||
if (docId != null) nextQuery.document_id = String(docId);
|
||||
else delete nextQuery.document_id;
|
||||
await router.replace({ query: nextQuery as typeof route.query });
|
||||
|
||||
if (wasDocked && !switchingToCurrent && panelState.value.pdfOpen) {
|
||||
void ensurePreviewLoaded(caseNo);
|
||||
}
|
||||
};
|
||||
|
||||
/** 未保存本地修改数(与底栏提示、切换拦截同源)。 */
|
||||
@@ -1802,13 +2106,25 @@ watch(
|
||||
|
||||
watch(
|
||||
[runNo, () => String(route.query.case || route.query.case_no || ''), conversationId, itemNoFromQuery],
|
||||
([nextRun, nextCase, nextConversationId, nextItemNo]) => {
|
||||
if (nextRun) {
|
||||
void load(nextRun, nextCase || undefined, {
|
||||
conversationId: nextConversationId || undefined,
|
||||
itemNo: nextItemNo || undefined,
|
||||
});
|
||||
([nextRun, nextCase, nextConversationId, nextItemNo], previous) => {
|
||||
if (!nextRun) return;
|
||||
const prevRun = previous?.[0] ? String(previous[0]) : '';
|
||||
const activeNo = String(activeCase.value?.case_no || '').trim();
|
||||
const sameRunLoaded = Boolean(
|
||||
reviewRun.value?.run_no
|
||||
&& String(reviewRun.value.run_no) === String(nextRun)
|
||||
&& prevRun === String(nextRun),
|
||||
);
|
||||
// [STEP] 同 Run 仅切换 PDF/Case:走轻量 selectCase,禁止整页 load 清空进度与闪「正在加载」。
|
||||
if (sameRunLoaded && nextCase) {
|
||||
if (nextCase === activeNo) return;
|
||||
void selectCase(nextCase);
|
||||
return;
|
||||
}
|
||||
void load(nextRun, nextCase || undefined, {
|
||||
conversationId: nextConversationId || undefined,
|
||||
itemNo: nextItemNo || undefined,
|
||||
});
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
@@ -2039,17 +2355,31 @@ watch(
|
||||
class="rounded-xl border border-default bg-surface p-3"
|
||||
data-testid="review-formal-task-todo-panel"
|
||||
>
|
||||
<div v-if="formalTaskDetailLoading" class="py-4 text-center text-xs text-muted">
|
||||
{{ t('workspace.shippingNotice.loading') }}
|
||||
<div
|
||||
data-testid="review-formal-task-result-region"
|
||||
:data-view-result-loading="viewResultLoading ? '1' : '0'"
|
||||
>
|
||||
<div v-if="formalTaskDetailLoading" class="py-4 text-center text-xs text-muted">
|
||||
{{ t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<TaskTodoPanel
|
||||
v-else-if="formalTaskDetail"
|
||||
ref="formalTodoPanelRef"
|
||||
:detail="formalTaskDetail"
|
||||
:gate-can-handle="false"
|
||||
:actions-executable="workbenchActionsExecutable"
|
||||
:hide-primary-actions="true"
|
||||
:expected-notice-task-no="confirmedNoticeTaskNo"
|
||||
:expected-order-task-no="authoritativeOrderTaskNo"
|
||||
:expected-review-case-no="activeCase?.case_no || null"
|
||||
:expected-run-no="runNo || null"
|
||||
@refreshed="() => {
|
||||
void loadFormalTaskDetail();
|
||||
void refreshShippingProcessing();
|
||||
msg.success(t('chat.shippingOrderReview.workbench.actionSuccess'));
|
||||
}"
|
||||
/>
|
||||
</div>
|
||||
<TaskTodoPanel
|
||||
v-else-if="formalTaskDetail"
|
||||
ref="formalTodoPanelRef"
|
||||
:detail="formalTaskDetail"
|
||||
:can-handle="!isReadOnly"
|
||||
:hide-primary-actions="true"
|
||||
@refreshed="() => { void loadFormalTaskDetail(); void refreshShippingProcessing(); }"
|
||||
/>
|
||||
</section>
|
||||
|
||||
<section
|
||||
@@ -2205,6 +2535,48 @@ watch(
|
||||
:class="otNavUsesSidebar ? '' : 'contents'"
|
||||
>
|
||||
<template v-if="showWorkbenchGrid">
|
||||
<div
|
||||
v-if="caseSwitchFailed"
|
||||
class="rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-900 dark:border-rose-900 dark:bg-rose-950/40 dark:text-rose-100"
|
||||
data-testid="review-case-switch-failed"
|
||||
>
|
||||
<p>{{ t('chat.shippingOrderReview.caseSwitchFailed') }}</p>
|
||||
<div
|
||||
class="mt-3 space-y-2"
|
||||
aria-hidden="true"
|
||||
data-testid="review-case-switch-failed-skeleton"
|
||||
>
|
||||
<div class="h-4 w-2/5 animate-pulse rounded bg-rose-200/70 dark:bg-rose-900/50" />
|
||||
<div class="h-10 w-full animate-pulse rounded bg-rose-200/70 dark:bg-rose-900/50" />
|
||||
<div class="h-24 w-full animate-pulse rounded bg-rose-200/70 dark:bg-rose-900/50" />
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 rounded border border-rose-300 px-2 py-1 text-xs hover:bg-rose-100 dark:border-rose-800 dark:hover:bg-rose-950"
|
||||
data-testid="review-case-switch-retry"
|
||||
@click="() => { const target = requestedCaseNo; if (target) void selectCase(target); }"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.caseSwitchRetry') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="caseSwitchLoading"
|
||||
class="space-y-3 rounded-xl border border-dashed border-slate-300 bg-slate-50 p-4 dark:border-slate-700 dark:bg-slate-900/40"
|
||||
data-testid="review-case-switch-loading"
|
||||
>
|
||||
<p class="text-sm text-slate-600 dark:text-slate-300">{{ t('chat.shippingOrderReview.caseSwitchLoading') }}</p>
|
||||
<div class="space-y-2" aria-hidden="true">
|
||||
<div class="h-4 w-2/5 animate-pulse rounded bg-slate-200 dark:bg-slate-700" />
|
||||
<div class="h-10 w-full animate-pulse rounded bg-slate-200 dark:bg-slate-700" />
|
||||
<div class="h-10 w-full animate-pulse rounded bg-slate-200 dark:bg-slate-700" />
|
||||
<div class="h-24 w-full animate-pulse rounded bg-slate-200 dark:bg-slate-700" />
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="activeCase"
|
||||
class="relative space-y-4"
|
||||
data-testid="review-case-workbench-shell"
|
||||
>
|
||||
<ReviewWorkbenchModeToggle
|
||||
v-if="workbenchMode !== 'standard' && workbenchMode !== 'reparse'"
|
||||
:mode="workbenchMode"
|
||||
@@ -2220,7 +2592,7 @@ watch(
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!reparseProgressActive && activeCase?.process_gate?.current_blocking_gate && !activeCase.process_gate.technical_auto_only"
|
||||
:summary="activeCase.process_gate"
|
||||
:can-handle="editable"
|
||||
:can-handle="false"
|
||||
:navigation-context="reviewGateNavigationContext"
|
||||
:field-labels="reviewFieldLabels"
|
||||
@refreshed="reloadLatestDraft"
|
||||
@@ -2229,6 +2601,7 @@ watch(
|
||||
/>
|
||||
<ReviewCustomerResolutionPanel
|
||||
v-if="activeCase && !activeCase.customer_resolution?.resolved"
|
||||
ref="customerResolutionPanelRef"
|
||||
:case-no="activeCase.case_no"
|
||||
:resolution="activeCase.customer_resolution"
|
||||
:editable="editable"
|
||||
@@ -2604,6 +2977,7 @@ watch(
|
||||
<div class="hidden space-y-3 xl:block" data-testid="review-primary-blockers-wide">
|
||||
<ReviewCustomerResolutionPanel
|
||||
v-if="activeCase && !activeCase.customer_resolution?.resolved"
|
||||
ref="customerResolutionWideRef"
|
||||
:case-no="activeCase.case_no"
|
||||
:resolution="activeCase.customer_resolution"
|
||||
:editable="editable"
|
||||
@@ -2612,7 +2986,7 @@ watch(
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!reparseProgressActive && activeCase?.process_gate?.current_blocking_gate && !activeCase.process_gate.technical_auto_only"
|
||||
:summary="activeCase.process_gate"
|
||||
:can-handle="editable"
|
||||
:can-handle="false"
|
||||
:navigation-context="reviewGateNavigationContext"
|
||||
:field-labels="reviewFieldLabels"
|
||||
@refreshed="reloadLatestDraft"
|
||||
@@ -2631,8 +3005,13 @@ watch(
|
||||
@navigate-exception="navigateExceptionField"
|
||||
/>
|
||||
</div>
|
||||
<ReviewProfileMatchPanel
|
||||
v-if="activeCase?.profile_match?.available"
|
||||
:profile-match="activeCase.profile_match"
|
||||
/>
|
||||
<ReviewFieldConflictPanel
|
||||
v-if="activeCase"
|
||||
ref="fieldConflictPanelRef"
|
||||
:case-no="activeCase.case_no"
|
||||
:draft-version="activeCase.draft?.draft_version"
|
||||
:conflicts="activeCase.field_conflicts"
|
||||
@@ -2642,6 +3021,7 @@ watch(
|
||||
/>
|
||||
<ReviewDuplicatePanel
|
||||
v-if="activeCase"
|
||||
ref="duplicatePanelRef"
|
||||
:case-no="activeCase.case_no"
|
||||
:duplicate="activeCase.duplicate"
|
||||
:editable="editable"
|
||||
@@ -2703,6 +3083,7 @@ watch(
|
||||
</details>
|
||||
</aside>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
@@ -2791,19 +3172,25 @@ watch(
|
||||
:available-actions="availableActions"
|
||||
:can-confirm-build="canConfirmBuild"
|
||||
:hide-confirm-because-auto-gate="hideConfirmBecauseAutoGate"
|
||||
:show-auto-gate-hint="showAutoGateHint"
|
||||
:show-stp-retry="showStpRetry"
|
||||
:auto-gate-hint="t(autoGateHintKey)"
|
||||
:saving="saving"
|
||||
:is-read-only="isReadOnly"
|
||||
:has-draft="Boolean(activeCase?.draft)"
|
||||
:unsaved-count="unsavedEditCount"
|
||||
:flow-presentation="flowPresentation"
|
||||
:automating="isProcessingAutomating"
|
||||
:actions-executable="workbenchActionsExecutable"
|
||||
:flow-busy="flowActionBusy"
|
||||
@mark-non-order="openActionDialog('non_order')"
|
||||
@mark-quality-issue="openActionDialog('quality_issue')"
|
||||
@reparse="openActionDialog('reparse')"
|
||||
@upload-replacement="selectReplacement"
|
||||
@validate="reportSave(() => validate())"
|
||||
@confirm="openActionDialog('confirm')"
|
||||
@flow-action="onUnifiedProcessingAction"
|
||||
@retry-stp="() => void retryStpAutoCreate()"
|
||||
@flow-action="(item) => { void onUnifiedProcessingAction(item); }"
|
||||
/>
|
||||
|
||||
<ReviewProcessDetailDrawer
|
||||
|
||||
+11
-5
@@ -6,7 +6,8 @@
|
||||
* 逻辑:导航类动作 router.push;confirm_customer 发射 confirmCustomer 由父级开弹窗;
|
||||
* POST 类动作调 Workspace API;409 触发 refreshed;
|
||||
* 展示 explainability.details 白名单业务事实;下一步文案独立于按钮;
|
||||
* 可展开审计;canHandle=false 时仍展示下一步说明;禁止堆栈/路径/SQL。
|
||||
* 可展开审计;canHandle=false 时不渲染恢复主按钮,提示用 Footer;
|
||||
* 禁止堆栈/路径/SQL。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
@@ -366,10 +367,11 @@ function formatAuditEventLabel(item: Record<string, unknown>): string {
|
||||
</dl>
|
||||
<div class="mt-3 flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
v-if="hasRecoveryAction"
|
||||
v-if="hasRecoveryAction && canHandle"
|
||||
type="button"
|
||||
class="rounded-xl bg-primary px-3 py-1.5 text-sm font-medium text-on-primary disabled:opacity-60"
|
||||
:disabled="!canHandle || busy"
|
||||
:disabled="busy"
|
||||
data-testid="process-gate-recovery-primary"
|
||||
@click="runPrimaryAction"
|
||||
>
|
||||
{{ busy ? $t('workspace.shippingNotice.processGate.submitting') : actionLabel }}
|
||||
@@ -384,8 +386,12 @@ function formatAuditEventLabel(item: Record<string, unknown>): string {
|
||||
? $t('workspace.shippingNotice.processGate.hideAudit')
|
||||
: $t('workspace.shippingNotice.processGate.viewAudit') }}
|
||||
</button>
|
||||
<span v-if="!canHandle" class="text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
|
||||
<span
|
||||
v-if="!canHandle && hasRecoveryAction"
|
||||
class="text-xs text-muted"
|
||||
data-testid="process-gate-readonly-hint"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.processGate.readOnlyUseFooter') }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="auditOpen" class="mt-3 rounded-xl border border-default bg-surface px-3 py-2 text-xs">
|
||||
|
||||
@@ -75,12 +75,13 @@ describe('resolveProcessingActionPresentation', () => {
|
||||
expect(result.primary?.actionCode).toBe('retry_parse');
|
||||
});
|
||||
|
||||
it('filters open_order_review on review surface', () => {
|
||||
it('filters open_order_review and refresh on review surface', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
availableActions: ['open_order_review', 'refresh'],
|
||||
}), { surface: 'review' });
|
||||
expect(result.primary?.intent).toBe('refresh');
|
||||
availableActions: ['open_order_review', 'refresh', 'view_result'],
|
||||
}), { surface: 'review', actionsExecutable: true });
|
||||
expect(result.primary?.intent).toBe('view_result');
|
||||
expect(result.overflow.some((i) => i.intent === 'open_order_review')).toBe(false);
|
||||
expect([result.primary, result.secondary, ...result.overflow].some((i) => i?.intent === 'refresh')).toBe(false);
|
||||
});
|
||||
|
||||
it('maps open_order_review label to processing entry on chat surface', () => {
|
||||
|
||||
@@ -1,23 +1,37 @@
|
||||
/**
|
||||
* features/shipping-progress/actionPresentation.ts
|
||||
* 用途:从统一投影解析四页面共用的 ActionPresentation(主/次/溢出)。
|
||||
* 依赖:ShippingProcessingProjection、SHIPPING_PROCESSING_ACTION_INTENTS、types。
|
||||
* 用途:从统一投影 / 会话 OT 任务解析四页面共用的 ActionPresentation(主/次/溢出)。
|
||||
* 依赖:ShippingProcessingProjection、ConversationProcessingUserTask、workbenchActionRegistry、types。
|
||||
* 逻辑:优先级 Gate.nextActionCode → availableActions → 终态查看 → none;
|
||||
* 自动处理中(processing/automating)主按钮为空;review 面隐藏 open_order_review。
|
||||
* cancel_* 与 view_details 永不作主 CTA;无业务入口时 focus_task 兜底并映射「查看进度」;
|
||||
* 自动处理中(processing/automating)主按钮为空;review 面经注册表 fail-closed 过滤。
|
||||
*/
|
||||
|
||||
import type {
|
||||
ConversationProcessingUserTask,
|
||||
ShippingProcessingActionIntent,
|
||||
ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import type { ActionPresentation, ActionPresentationItem, ActionPresentationSurface } from './types';
|
||||
import type { WorkbenchPanelAvailability } from './workbenchActionRegistry';
|
||||
import {
|
||||
lookupWorkbenchAction,
|
||||
shouldRenderWorkbenchAction,
|
||||
warnUnregisteredWorkbenchAction,
|
||||
} from './workbenchActionRegistry';
|
||||
|
||||
/** 可映射为统一意图的原始动作码(gate / available_actions)。 */
|
||||
const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
open_order_review: 'open_order_review',
|
||||
open_review: 'open_order_review',
|
||||
open_order_processing: 'open_order_review',
|
||||
enter_manual_review: 'open_order_review',
|
||||
edit_formal_task: 'edit_formal_task',
|
||||
freeze_order: 'edit_formal_task',
|
||||
open_profile_review: 'open_profile_review',
|
||||
confirm_customer: 'confirm_customer',
|
||||
resolve_field_conflicts: 'resolve_field_conflicts',
|
||||
adjudicate_duplicate: 'adjudicate_duplicate',
|
||||
open_inventory_source_review: 'open_inventory_source_review',
|
||||
confirm_inventory_source: 'open_inventory_source_review',
|
||||
retry_resolve_inventory_source: 'open_inventory_source_review',
|
||||
@@ -29,6 +43,9 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
retry: 'retry',
|
||||
retry_parse: 'retry',
|
||||
retry_failed_documents: 'retry',
|
||||
retry_failed_attachments: 'retry',
|
||||
retry_upload: 'retry',
|
||||
retry_freight_upload_rpa: 'retry',
|
||||
refresh: 'refresh',
|
||||
regenerate_excel: 'regenerate_excel',
|
||||
generate_excel: 'regenerate_excel',
|
||||
@@ -40,13 +57,21 @@ const ACTION_CODE_TO_INTENT: Record<string, ShippingProcessingActionIntent> = {
|
||||
open_fulfillment: 'view_result',
|
||||
view_result: 'view_result',
|
||||
view_details: 'view_result',
|
||||
focus_task: 'view_result',
|
||||
view_record: 'view_record',
|
||||
/** 取消类动作映射为 view_record,以便进入 presentation(再由 NEVER_PRIMARY 降为次要)。 */
|
||||
cancel_task: 'view_record',
|
||||
cancel_run: 'view_record',
|
||||
};
|
||||
|
||||
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
|
||||
/** 永不升为主 CTA 的动作码(仍可作次要/溢出)。 */
|
||||
const NEVER_PRIMARY_CODES = new Set(['cancel_task', 'cancel_run', 'view_details']);
|
||||
|
||||
/**
|
||||
* 将原始动作码映射为统一意图;未知码返回 null。
|
||||
*
|
||||
* @param code - Gate / available_actions 原始码
|
||||
*/
|
||||
export function mapActionCodeToIntent(code: string | null | undefined): ShippingProcessingActionIntent | null {
|
||||
const normalized = String(code || '').trim().toLowerCase();
|
||||
@@ -56,6 +81,7 @@ export function mapActionCodeToIntent(code: string | null | undefined): Shipping
|
||||
|
||||
/**
|
||||
* 构建单个动作项。
|
||||
* 核心逻辑:默认 labelKey=action.{intent};chat/right 面改写订单处理 / 重试解析 / 查看进度。
|
||||
*/
|
||||
function toItem(
|
||||
code: string,
|
||||
@@ -63,11 +89,18 @@ function toItem(
|
||||
surface?: ActionPresentationSurface,
|
||||
): ActionPresentationItem {
|
||||
let labelKey = `chat.shippingProcessing.action.${intent}`;
|
||||
if (
|
||||
intent === 'open_order_review'
|
||||
&& (surface === 'chat' || surface === 'right')
|
||||
) {
|
||||
const normalized = String(code || '').trim().toLowerCase();
|
||||
const chatOrRight = surface === 'chat' || surface === 'right';
|
||||
if (intent === 'open_order_review' && chatOrRight) {
|
||||
labelKey = 'chat.shippingProcessing.action.open_order_processing';
|
||||
} else if (intent === 'retry' && chatOrRight) {
|
||||
labelKey = 'chat.shippingProcessing.action.retry_parse';
|
||||
} else if (normalized === 'focus_task' && chatOrRight) {
|
||||
labelKey = 'chat.shippingProcessing.action.view_progress';
|
||||
} else if (normalized === 'cancel_task' || normalized === 'cancel_run') {
|
||||
labelKey = 'chat.shippingProcessing.cancelEntireTaskSingle';
|
||||
} else if (normalized === 'view_details') {
|
||||
labelKey = 'chat.shippingProcessing.viewTaskDetails';
|
||||
}
|
||||
return {
|
||||
intent,
|
||||
@@ -76,6 +109,39 @@ function toItem(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 将动作列表拆成主/次/溢出;cancel 与 view_details 永不作 primary。
|
||||
*/
|
||||
function partitionActionItems(items: ActionPresentationItem[]): ActionPresentation {
|
||||
if (!items.length) {
|
||||
return { primary: null, secondary: null, overflow: [] };
|
||||
}
|
||||
const primaryPool = items.filter(
|
||||
(item) => !NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()),
|
||||
);
|
||||
const demoted = items.filter(
|
||||
(item) => NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()),
|
||||
);
|
||||
const primary = primaryPool[0] || null;
|
||||
const rest = [
|
||||
...primaryPool.slice(1),
|
||||
...demoted,
|
||||
];
|
||||
return {
|
||||
primary,
|
||||
secondary: rest[0] || null,
|
||||
overflow: rest.slice(1),
|
||||
};
|
||||
}
|
||||
|
||||
export interface ResolveProcessingActionPresentationOptions {
|
||||
surface?: ActionPresentationSurface;
|
||||
/** 订单处理工作台写权限;仅 surface=review 时生效。 */
|
||||
actionsExecutable?: boolean;
|
||||
/** 面板可用性(review 面 requiresPanel 守卫)。 */
|
||||
panels?: WorkbenchPanelAvailability | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析统一动作投影。
|
||||
*
|
||||
@@ -84,16 +150,22 @@ function toItem(
|
||||
* 2. currentGate.nextActionCode 优先;
|
||||
* 3. availableActions 依次填主/次/溢出;
|
||||
* 4. completed/failed/cancelled → view_result / view_record 兜底;
|
||||
* 5. surface=review 时过滤 open_order_review(已在复核页)。
|
||||
* 5. surface=review 时经注册表 fail-closed(未知隐藏 + 告警;隐藏 refresh/自跳转);
|
||||
* 6. cancel / view_details 强制降为次要或溢出。
|
||||
*
|
||||
* @param projection - 统一处理投影
|
||||
* @param options - surface / actionsExecutable / panels
|
||||
*/
|
||||
export function resolveProcessingActionPresentation(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
options?: { surface?: ActionPresentationSurface },
|
||||
options?: ResolveProcessingActionPresentationOptions,
|
||||
): ActionPresentation {
|
||||
const empty: ActionPresentation = { primary: null, secondary: null, overflow: [] };
|
||||
if (!projection) return empty;
|
||||
|
||||
const surface = options?.surface;
|
||||
const actionsExecutable = options?.actionsExecutable !== false;
|
||||
const panels = options?.panels ?? null;
|
||||
const status = String(projection.status || '').trim().toLowerCase();
|
||||
if (AUTOMATING_STATUSES.has(status) && !projection.currentGate?.nextActionCode) {
|
||||
return empty;
|
||||
@@ -107,10 +179,36 @@ export function resolveProcessingActionPresentation(
|
||||
if (!code) return;
|
||||
const key = code.toLowerCase();
|
||||
if (seen.has(key)) return;
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') return;
|
||||
if (surface === 'review' && intent === 'open_order_review') return;
|
||||
seen.add(key);
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') {
|
||||
// [fail-closed] 未知动作不渲染原始码,仅告警。
|
||||
warnUnregisteredWorkbenchAction({
|
||||
actionCode: code,
|
||||
surface: surface || 'workbench',
|
||||
workItemType: projection.workItemType,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (surface === 'review') {
|
||||
const entry = lookupWorkbenchAction(code) || lookupWorkbenchAction(intent);
|
||||
if (!entry) {
|
||||
warnUnregisteredWorkbenchAction({
|
||||
actionCode: code,
|
||||
surface: 'review',
|
||||
workItemType: projection.workItemType,
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!shouldRenderWorkbenchAction(entry, {
|
||||
actionsExecutable,
|
||||
surface: 'review',
|
||||
panels,
|
||||
actionCode: code,
|
||||
})) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
items.push(toItem(code, intent, surface));
|
||||
};
|
||||
|
||||
@@ -127,9 +225,50 @@ export function resolveProcessingActionPresentation(
|
||||
return empty;
|
||||
}
|
||||
|
||||
return {
|
||||
primary: items[0] || null,
|
||||
secondary: items[1] || null,
|
||||
overflow: items.slice(2),
|
||||
return partitionActionItems(items);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从会话 OT 任务投影解析 ActionPresentation(无 workItem 时的统一适配器)。
|
||||
* 核心逻辑:primary_action 优先;available_actions 补充;无正式入口时 focus_task→查看进度;
|
||||
* cancel/view_details 永不作主 CTA。
|
||||
* @param task - 会话用户可见任务
|
||||
* @param options.surface - 展示面(默认 right)
|
||||
*/
|
||||
export function resolveConversationTaskActionPresentation(
|
||||
task: ConversationProcessingUserTask | null | undefined,
|
||||
options?: { surface?: ActionPresentationSurface },
|
||||
): ActionPresentation {
|
||||
const empty: ActionPresentation = { primary: null, secondary: null, overflow: [] };
|
||||
if (!task) return empty;
|
||||
|
||||
const surface = options?.surface || 'right';
|
||||
const items: ActionPresentationItem[] = [];
|
||||
const seen = new Set<string>();
|
||||
|
||||
const pushCode = (raw: string | null | undefined) => {
|
||||
const code = String(raw || '').trim();
|
||||
if (!code) return;
|
||||
const key = code.toLowerCase();
|
||||
if (seen.has(key)) return;
|
||||
const intent = mapActionCodeToIntent(code);
|
||||
if (!intent || intent === 'none') return;
|
||||
seen.add(key);
|
||||
items.push(toItem(code, intent, surface));
|
||||
};
|
||||
|
||||
pushCode(task.primary_action);
|
||||
for (const action of task.available_actions || []) {
|
||||
pushCode(action);
|
||||
}
|
||||
|
||||
// 无正式业务入口时,默认提供查看进度(focus_task)。
|
||||
const hasPrimaryCandidate = items.some(
|
||||
(item) => !NEVER_PRIMARY_CODES.has(String(item.actionCode || '').trim().toLowerCase()),
|
||||
);
|
||||
if (!hasPrimaryCandidate) {
|
||||
pushCode('focus_task');
|
||||
}
|
||||
|
||||
return partitionActionItems(items);
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
* features/shipping-progress/components/ReviewProgressStrip.spec.ts
|
||||
* 用途:验收压缩进度条——宽屏 15 阶、无五域、阻断需时显示「当前需要」、自动推进刷新。
|
||||
* 依赖:Vitest、@vue/test-utils、vue-i18n、ReviewProgressStrip。
|
||||
* 逻辑:合法 stageNodes → 15 节点;非法 → 不可用提示;automating → 标题换文案且无当前需要。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import {
|
||||
SHIPPING_PROCESSING_STAGES,
|
||||
type ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import ReviewProgressStrip from './ReviewProgressStrip.vue';
|
||||
|
||||
function buildProjection(
|
||||
overrides: Partial<ShippingProcessingProjection> = {},
|
||||
): ShippingProcessingProjection {
|
||||
const stageNodes = SHIPPING_PROCESSING_STAGES.map((stage, absoluteIndex) => ({
|
||||
stage,
|
||||
absoluteIndex,
|
||||
status: (absoluteIndex < 8 ? 'passed' : absoluteIndex === 8 ? 'blocked' : 'pending') as const,
|
||||
}));
|
||||
return {
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-1',
|
||||
sourceType: 'direct_pdf',
|
||||
rootOrderTaskNo: 'OT-1',
|
||||
shippingNoticeNo: null,
|
||||
conversationId: 'c1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
progressVersion: 2,
|
||||
lastActivityAt: '2026-08-05T00:00:00Z',
|
||||
currentGate: {
|
||||
gateCode: 'order_review',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'confirm_customer',
|
||||
blockingReasonCode: 'customer_unresolved',
|
||||
attemptNo: 1,
|
||||
},
|
||||
availableActions: ['confirm_customer'],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'a.pdf',
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
stageNodes,
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
function mountStrip(projection: ShippingProcessingProjection, polling = false) {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
workflowProgress: { polling: '正在刷新进度…' },
|
||||
},
|
||||
shippingProcessing: {
|
||||
progress: {
|
||||
completedOfTotal: '已完成 {done} / {total}',
|
||||
currentNeedLabel: '当前需要:',
|
||||
progressTitleWithStage: '订单处理进度 · {stage}',
|
||||
systemProcessingWithStage: '系统处理中 · {stage}',
|
||||
viewProcessDetails: '查看流程详情',
|
||||
viewFullProcess: '查看完整流程',
|
||||
stageNodesUnavailable: '进度详情暂不可用',
|
||||
},
|
||||
stage: Object.fromEntries(SHIPPING_PROCESSING_STAGES.map((s) => [s, s])),
|
||||
action: { refresh: '刷新', confirm_customer: '确认客户' },
|
||||
gateReasons: { customer_unresolved: '确认客户', generic: '需要处理' },
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
processGate: {
|
||||
actions: { confirm_customer: '确认客户', retry_freight_upload_rpa: '重试货代上传' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return mount(ReviewProgressStrip, {
|
||||
props: { projection, polling },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('ReviewProgressStrip', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('renders title + 15 stage nodes without domain chips', () => {
|
||||
const wrapper = mountStrip(buildProjection());
|
||||
expect(wrapper.get('[data-testid="review-progress-title"]').text()).toContain('订单处理进度');
|
||||
expect(wrapper.find('[data-testid="review-progress-stage-nodes"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-testid="review-progress-stage-nodes"] [data-stage]')).toHaveLength(15);
|
||||
expect(wrapper.find('[data-testid="review-progress-domains"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-current-need"]').text()).toContain('确认客户');
|
||||
expect(wrapper.find('[data-testid="review-progress-completed-summary"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-progress-open-details"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-progress-refresh"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('shows system-processing title and refresh while automating without current need', () => {
|
||||
const wrapper = mountStrip(buildProjection({
|
||||
status: 'automating',
|
||||
stage: 'freight_uploading',
|
||||
currentGate: null,
|
||||
availableActions: [],
|
||||
}));
|
||||
expect(wrapper.get('[data-testid="review-progress-title"]').text()).toContain('系统处理中');
|
||||
expect(wrapper.find('[data-testid="review-progress-current-need"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-refresh"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('hides stage nodes and warns when stageNodes invalid', () => {
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
const wrapper = mountStrip(buildProjection({ stageNodes: [] }));
|
||||
expect(wrapper.find('[data-testid="review-progress-stage-nodes"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-stage-nodes-unavailable"]').exists()).toBe(true);
|
||||
expect(warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('falls back to nextActionCode label when blockingReasonCode missing', () => {
|
||||
const wrapper = mountStrip(buildProjection({
|
||||
currentGate: {
|
||||
gateCode: 'freight_upload',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'retry_freight_upload_rpa',
|
||||
blockingReasonCode: null,
|
||||
attemptNo: 1,
|
||||
},
|
||||
}));
|
||||
expect(wrapper.find('[data-testid="review-progress-current-need"]').text()).toContain('重试货代上传');
|
||||
});
|
||||
|
||||
it('emits open-process-details from details CTA', async () => {
|
||||
const wrapper = mountStrip(buildProjection());
|
||||
await wrapper.get('[data-testid="review-progress-open-details"]').trigger('click');
|
||||
expect(wrapper.emitted('open-process-details')).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -1,24 +1,30 @@
|
||||
<!--
|
||||
features/shipping-progress/components/ReviewProgressStrip.vue
|
||||
用途:订单处理工作台只读紧凑进度——五域摘要 + 当前节点 n/15 + 当前需要 + 打开流程详情。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、gateReasonLabel。
|
||||
逻辑:由 ReviewWorkflowProgressPanel 挂载;正文不展开 15 阶、不挂 ActionBar;写操作只在底部 Footer。
|
||||
用途:订单处理工作台只读进度——宽屏仅 15 阶主进度;窄屏摘要版。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、stageNodesAuthority、gateReasonLabel.resolveCurrentNeedLabel。
|
||||
逻辑:由 ReviewWorkflowProgressPanel 挂载;禁止点击节点;宽屏隐藏五域与 n/15 文案;
|
||||
窄屏不展示 15 阶横条;有阻断 Gate 且非自动推进时显示「当前需要」(优先级 C);
|
||||
「查看流程详情/完整流程」同一 emit;写操作只在 Footer。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import type {
|
||||
ShippingProcessingProjection,
|
||||
ShippingProcessingStageNodeStatus,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressRangeHint } from '../progressWindow';
|
||||
import {
|
||||
buildProgressRangeHint,
|
||||
buildReviewProgressDomainSummary,
|
||||
stageAbsoluteIndex,
|
||||
} from '../progressWindow';
|
||||
import { resolveGateReasonLabel } from '../gateReasonLabel';
|
||||
import type { ProgressDomainState } from '../types';
|
||||
readAuthoritativeStageNodes,
|
||||
warnStageNodesUnavailable,
|
||||
} from '../stageNodesAuthority';
|
||||
import { resolveCurrentNeedLabel } from '../gateReasonLabel';
|
||||
|
||||
const props = defineProps<{
|
||||
projection: ShippingProcessingProjection;
|
||||
/** 宿主轮询中提示(显示在标题行)。 */
|
||||
polling?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -30,7 +36,9 @@ const { t, te } = useI18n();
|
||||
|
||||
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
|
||||
|
||||
const domains = computed(() => buildReviewProgressDomainSummary(props.projection));
|
||||
/** 权威 15 阶;非法时 null(fail-closed)。 */
|
||||
const stageNodes = computed(() => readAuthoritativeStageNodes(props.projection));
|
||||
|
||||
const rangeHint = computed(() => buildProgressRangeHint(props.projection, 'workbench'));
|
||||
|
||||
const isAutomating = computed(() => (
|
||||
@@ -38,38 +46,76 @@ const isAutomating = computed(() => (
|
||||
&& !props.projection.currentGate?.nextActionCode
|
||||
));
|
||||
|
||||
/**
|
||||
* ● 当前阶段 · 第 n/15。
|
||||
*/
|
||||
const currentLine = computed(() => {
|
||||
const stageKey = rangeHint.value?.currentLabelKey || shippingProcessingStageKey(props.projection.stage);
|
||||
const stageLabel = te(stageKey) ? t(stageKey) : props.projection.stage;
|
||||
const index = stageAbsoluteIndex(props.projection.stage) + 1;
|
||||
return `● ${stageLabel} · ${t('chat.shippingProcessing.progress.positionOfTotal', { current: index, total: 15 })}`;
|
||||
const stageLabel = computed(() => {
|
||||
const stage = props.projection.stage;
|
||||
const key = shippingProcessingStageKey(stage);
|
||||
return te(key) ? t(key) : String(stage || '');
|
||||
});
|
||||
|
||||
/**
|
||||
* 当前需要:Gate 原因;自动推进中用系统文案。
|
||||
* 单行标题:自动推进用「系统处理中 · 阶段」;否则「订单处理进度 · 阶段」。
|
||||
*/
|
||||
const currentNeed = computed(() => {
|
||||
const titleLine = computed(() => {
|
||||
const stage = stageLabel.value || '—';
|
||||
if (isAutomating.value) {
|
||||
return t('chat.shippingProcessing.progress.systemProcessingNeed');
|
||||
return t('chat.shippingProcessing.progress.systemProcessingWithStage', { stage });
|
||||
}
|
||||
return resolveGateReasonLabel(
|
||||
props.projection.currentGate?.blockingReasonCode,
|
||||
{ t, te },
|
||||
return t('chat.shippingProcessing.progress.progressTitleWithStage', { stage });
|
||||
});
|
||||
|
||||
/**
|
||||
* 有阻断 Gate 且非自动推进时展示「当前需要」。
|
||||
*/
|
||||
const showCurrentNeed = computed(() => {
|
||||
if (isAutomating.value) return false;
|
||||
const gate = props.projection.currentGate;
|
||||
if (!gate) return false;
|
||||
return Boolean(
|
||||
String(gate.blockingReasonCode || '').trim()
|
||||
|| String(gate.nextActionCode || '').trim(),
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* 五域圆点样式。
|
||||
* 「当前需要」:blockingReasonCode 优先,缺失时回退 nextActionCode(与 Footer 语义对齐)。
|
||||
*/
|
||||
function domainDotClass(state: ProgressDomainState): string {
|
||||
if (state === 'passed') return 'bg-emerald-500';
|
||||
if (state === 'current') return 'bg-brand-500';
|
||||
if (state === 'blocked') return 'bg-amber-500';
|
||||
if (state === 'failed') return 'bg-rose-500';
|
||||
return 'bg-slate-300';
|
||||
const currentNeed = computed(() => {
|
||||
if (!showCurrentNeed.value) return '';
|
||||
return resolveCurrentNeedLabel(props.projection.currentGate, { t, te });
|
||||
});
|
||||
|
||||
watch(
|
||||
stageNodes,
|
||||
(nodes) => {
|
||||
if (!nodes) {
|
||||
warnStageNodesUnavailable({
|
||||
workItemNo: props.projection.workItemNo,
|
||||
reason: 'missing_or_invalid_stage_nodes',
|
||||
});
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 15 阶节点色块(只读高亮,禁止交互)。
|
||||
*/
|
||||
function nodeToneClass(status: ShippingProcessingStageNodeStatus, isCurrent: boolean): string {
|
||||
if (status === 'passed') return 'bg-emerald-500/90 text-white';
|
||||
if (status === 'blocked') return 'bg-amber-500 text-white';
|
||||
if (status === 'failed') return 'bg-rose-500 text-white';
|
||||
if (status === 'running' || isCurrent) return 'bg-brand-500 text-white ring-2 ring-brand-300';
|
||||
if (status === 'skipped') return 'bg-slate-200 text-slate-400 line-through dark:bg-slate-700';
|
||||
return 'bg-slate-100 text-slate-500 dark:bg-slate-800 dark:text-slate-300';
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点展示短标签。
|
||||
*/
|
||||
function nodeShortLabel(stage: string): string {
|
||||
const key = shippingProcessingStageKey(stage);
|
||||
const label = te(key) ? t(key) : stage;
|
||||
return String(label).slice(0, 4);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -78,43 +124,80 @@ function domainDotClass(state: ProgressDomainState): string {
|
||||
class="space-y-2"
|
||||
data-testid="review-progress-strip"
|
||||
>
|
||||
<div
|
||||
v-if="domains.length"
|
||||
class="flex flex-wrap items-center gap-1.5"
|
||||
data-testid="review-progress-domains"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div
|
||||
v-for="domain in domains"
|
||||
:key="domain.key"
|
||||
class="inline-flex items-center gap-1 rounded-md border border-default bg-surface px-2 py-0.5 text-[11px]"
|
||||
:data-domain="domain.key"
|
||||
:data-state="domain.state"
|
||||
class="min-w-0 text-sm font-semibold text-primary"
|
||||
data-testid="review-progress-title"
|
||||
>
|
||||
{{ titleLine }}
|
||||
<span
|
||||
class="inline-block h-1.5 w-1.5 rounded-full"
|
||||
:class="domainDotClass(domain.state)"
|
||||
/>
|
||||
<span :class="domain.state === 'current' || domain.state === 'blocked' ? 'font-semibold text-primary' : 'text-secondary'">
|
||||
{{ t(domain.labelKey) }}
|
||||
v-if="polling"
|
||||
class="ml-2 text-[11px] font-normal text-muted"
|
||||
data-testid="review-workflow-progress-polling"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.workflowProgress.polling') }}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
v-if="isAutomating"
|
||||
type="button"
|
||||
class="shrink-0 rounded-lg border border-default bg-surface px-2.5 py-1 text-[11px] font-medium text-secondary hover:bg-surface-muted"
|
||||
data-testid="review-progress-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.action.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- 宽屏:唯一主进度 = 15 阶只读条。 -->
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-secondary"
|
||||
data-testid="review-progress-range"
|
||||
v-if="stageNodes"
|
||||
class="hidden lg:block"
|
||||
data-testid="review-progress-stage-nodes"
|
||||
>
|
||||
<span data-testid="review-progress-current-line">{{ currentLine }}</span>
|
||||
<span v-if="rangeHint">
|
||||
{{ t('chat.shippingProcessing.progress.completedOfTotal', {
|
||||
done: rangeHint.done,
|
||||
total: rangeHint.total,
|
||||
}) }}
|
||||
</span>
|
||||
<div
|
||||
class="flex gap-1 overflow-x-auto pb-1"
|
||||
role="list"
|
||||
aria-label="shipping-processing-stages"
|
||||
>
|
||||
<div
|
||||
v-for="node in stageNodes"
|
||||
:key="node.stage"
|
||||
role="listitem"
|
||||
class="min-w-[3.25rem] shrink-0 select-none rounded-md px-1.5 py-1 text-center text-[10px] leading-tight pointer-events-none"
|
||||
:class="nodeToneClass(node.status, node.stage === projection.stage)"
|
||||
:data-stage="node.stage"
|
||||
:data-status="node.status"
|
||||
:data-current="node.stage === projection.stage ? '1' : '0'"
|
||||
:title="te(shippingProcessingStageKey(node.stage)) ? t(shippingProcessingStageKey(node.stage)) : node.stage"
|
||||
>
|
||||
<div class="font-semibold">{{ node.absoluteIndex + 1 }}</div>
|
||||
<div class="truncate">{{ nodeShortLabel(node.stage) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
v-else
|
||||
class="hidden text-[11px] text-amber-800 lg:block dark:text-amber-200"
|
||||
data-testid="review-progress-stage-nodes-unavailable"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.stageNodesUnavailable') }}
|
||||
</p>
|
||||
|
||||
<!-- 窄屏摘要:仅已完成 n/15(宽屏由节点色表达,不重复文案)。 -->
|
||||
<p
|
||||
v-if="rangeHint"
|
||||
class="text-[11px] text-secondary lg:hidden"
|
||||
data-testid="review-progress-completed-summary"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.completedOfTotal', {
|
||||
done: rangeHint.done,
|
||||
total: rangeHint.total,
|
||||
}) }}
|
||||
</p>
|
||||
|
||||
<p
|
||||
v-if="currentNeed"
|
||||
v-if="showCurrentNeed && currentNeed"
|
||||
class="text-[11px] text-amber-800 dark:text-amber-200"
|
||||
data-testid="review-progress-current-need"
|
||||
>
|
||||
@@ -129,16 +212,8 @@ function domainDotClass(state: ProgressDomainState): string {
|
||||
data-testid="review-progress-open-details"
|
||||
@click="emit('open-process-details')"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.viewProcessDetails') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="isAutomating"
|
||||
type="button"
|
||||
class="rounded-lg border border-default bg-surface px-2.5 py-1 text-[11px] font-medium text-secondary hover:bg-surface-muted"
|
||||
data-testid="review-progress-refresh"
|
||||
@click="emit('refresh')"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.action.refresh') }}
|
||||
<span class="hidden lg:inline">{{ t('chat.shippingProcessing.progress.viewProcessDetails') }}</span>
|
||||
<span class="lg:hidden">{{ t('chat.shippingProcessing.progress.viewFullProcess') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
SHIPPING_PROCESSING_STAGES,
|
||||
type ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import ChatProgressSummary from './ChatProgressSummary.vue';
|
||||
import SidebarProgressInline from './SidebarProgressInline.vue';
|
||||
import ReviewProgressStrip from './ReviewProgressStrip.vue';
|
||||
@@ -45,6 +48,11 @@ function sampleProjection(): ShippingProcessingProjection {
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
stageNodes: SHIPPING_PROCESSING_STAGES.map((stage, absoluteIndex) => ({
|
||||
stage,
|
||||
absoluteIndex,
|
||||
status: (absoluteIndex < 8 ? 'passed' : absoluteIndex === 8 ? 'blocked' : 'pending') as const,
|
||||
})),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -72,7 +80,11 @@ const i18n = createI18n({
|
||||
domainFulfillmentShip: '发货履约',
|
||||
currentNeedLabel: '当前需要:',
|
||||
systemProcessingNeed: '系统处理中',
|
||||
progressTitleWithStage: '订单处理进度 · {stage}',
|
||||
systemProcessingWithStage: '系统处理中 · {stage}',
|
||||
viewProcessDetails: '查看流程详情',
|
||||
viewFullProcess: '查看完整流程',
|
||||
stageNodesUnavailable: '进度详情暂不可用',
|
||||
closeProcessDetails: '关闭',
|
||||
processDetailsTitle: '流程详情',
|
||||
nodeTime: '时间',
|
||||
@@ -131,20 +143,19 @@ describe('shipping progress presenters', () => {
|
||||
expect(wrapper.find('[data-testid="sidebar-progress-inline"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('mounts ReviewProgressStrip as compact five-domain readonly strip', () => {
|
||||
it('mounts ReviewProgressStrip as compressed 15-stage readonly strip', () => {
|
||||
const wrapper = mount(ReviewProgressStrip, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-progress-strip"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-testid="review-progress-domains"] [data-domain]').length).toBe(5);
|
||||
expect(wrapper.find('[data-testid="review-progress-domains"]').exists()).toBe(false);
|
||||
expect(wrapper.findAll('[data-testid="review-progress-stage-nodes"] [data-stage]').length).toBe(15);
|
||||
// 正文不得再挂 ActionBar / 页内完整 15 阶展开
|
||||
expect(wrapper.find('[data-testid="unified-action-bar"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-expand-full"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-nodes-strip"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-progress-open-details"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('mounts ReviewProcessDetailDrawer with readonly 15 nodes', () => {
|
||||
const wrapper = mount(ReviewProcessDetailDrawer, {
|
||||
props: {
|
||||
|
||||
+7
-6
@@ -7,18 +7,19 @@
|
||||
|
||||
import { computed, unref, type ComputedRef, type MaybeRef, type Ref } from 'vue';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveProcessingActionPresentation } from '../actionPresentation';
|
||||
import type { ActionPresentation, ActionPresentationSurface } from '../types';
|
||||
import {
|
||||
resolveProcessingActionPresentation,
|
||||
type ResolveProcessingActionPresentationOptions,
|
||||
} from '../actionPresentation';
|
||||
import type { ActionPresentation } from '../types';
|
||||
|
||||
export interface UseProcessingActionPresentationOptions {
|
||||
surface?: ActionPresentationSurface;
|
||||
}
|
||||
export type UseProcessingActionPresentationOptions = ResolveProcessingActionPresentationOptions;
|
||||
|
||||
/**
|
||||
* 从投影 ref 得到响应式 ActionPresentation。
|
||||
*
|
||||
* @param projection - 统一投影 ref
|
||||
* @param options - 可选 surface(chat/right/review/workbench)
|
||||
* @param options - surface / actionsExecutable / panels(MaybeRef 以响应式重算)
|
||||
*/
|
||||
export function useProcessingActionPresentation(
|
||||
projection: Ref<ShippingProcessingProjection | null | undefined>
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* features/shipping-progress/gateReasonLabel.spec.ts
|
||||
* 用途:验收「当前需要」文案优先级 C(blockingReason → nextAction)。
|
||||
* 依赖:Vitest、gateReasonLabel。
|
||||
* 逻辑:有 reason 用 gateReasons;仅有 action 用 processGate.actions;均无则空串。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { resolveCurrentNeedLabel, resolveGateReasonLabel } from './gateReasonLabel';
|
||||
|
||||
function makeI18n(messages: Record<string, string>) {
|
||||
return {
|
||||
te: (key: string) => Object.prototype.hasOwnProperty.call(messages, key),
|
||||
t: (key: string) => messages[key] || key,
|
||||
};
|
||||
}
|
||||
|
||||
describe('gateReasonLabel', () => {
|
||||
it('resolveGateReasonLabel prefers shippingProcessing.gateReasons', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.customer_unresolved': '确认客户',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveGateReasonLabel('customer_unresolved', i18n)).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel uses blockingReasonCode first', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.customer_unresolved': '确认客户',
|
||||
'workspace.shippingNotice.processGate.actions.confirm_customer': '确认客户(动作)',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveCurrentNeedLabel({
|
||||
blockingReasonCode: 'customer_unresolved',
|
||||
nextActionCode: 'confirm_customer',
|
||||
}, i18n)).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel falls back to nextActionCode when reason missing', () => {
|
||||
const i18n = makeI18n({
|
||||
'workspace.shippingNotice.processGate.actions.retry_freight_upload_rpa': '重试货代上传',
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveCurrentNeedLabel({
|
||||
blockingReasonCode: null,
|
||||
nextActionCode: 'retry_freight_upload_rpa',
|
||||
}, i18n)).toBe('重试货代上传');
|
||||
});
|
||||
|
||||
it('resolveCurrentNeedLabel returns empty when gate empty', () => {
|
||||
const i18n = makeI18n({
|
||||
'chat.shippingProcessing.gateReasons.generic': '需要处理',
|
||||
});
|
||||
expect(resolveCurrentNeedLabel(null, i18n)).toBe('');
|
||||
expect(resolveCurrentNeedLabel({ blockingReasonCode: '', nextActionCode: '' }, i18n)).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -1,9 +1,9 @@
|
||||
/**
|
||||
* features/shipping-progress/gateReasonLabel.ts
|
||||
* 用途:将 Gate blockingReasonCode 解析为用户可读文案,禁止界面直接暴露内部码。
|
||||
* 依赖:vue-i18n TranslateResult 兼容的 t/te 函数。
|
||||
* 逻辑:优先 chat.shippingProcessing.gateReasons.* → workspace.shippingNotice.workflowReasons.*
|
||||
* → 通用兜底;永不回退为原始 code。
|
||||
* 用途:将 Gate blockingReasonCode / nextActionCode 解析为用户可读「当前需要」文案。
|
||||
* 依赖:vue-i18n 兼容的 t/te。
|
||||
* 逻辑:优先 blockingReasonCode → gateReasons;缺失时 nextActionCode → processGate.actions;
|
||||
* 永不直接暴露内部码;供 ReviewProgressStrip「当前需要」使用。
|
||||
*/
|
||||
|
||||
export type GateReasonI18n = {
|
||||
@@ -37,3 +37,40 @@ export function resolveGateReasonLabel(
|
||||
? i18n.t('chat.shippingProcessing.gateReasons.generic')
|
||||
: i18n.t('chat.shippingProcessing.status.blocked');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析订单处理工作台「当前需要」文案(与 Footer 语义对齐,禁止第二行重复「下一步」)。
|
||||
*
|
||||
* 核心逻辑(优先级 C):
|
||||
* 1. 有 blockingReasonCode → gateReasons / workflowReasons;
|
||||
* 2. 否则有 nextActionCode → processGate.actions / shippingProcessing.action;
|
||||
* 3. 均无则空串(由调用方决定是否展示)。
|
||||
*
|
||||
* @param gate - 当前 Gate 摘要
|
||||
* @param i18n - t / te
|
||||
* @returns 用户可读文案
|
||||
*/
|
||||
export function resolveCurrentNeedLabel(
|
||||
gate: {
|
||||
blockingReasonCode?: string | null;
|
||||
nextActionCode?: string | null;
|
||||
} | null | undefined,
|
||||
i18n: GateReasonI18n,
|
||||
): string {
|
||||
const reasonCode = String(gate?.blockingReasonCode || '').trim();
|
||||
if (reasonCode) {
|
||||
return resolveGateReasonLabel(reasonCode, i18n);
|
||||
}
|
||||
const actionCode = String(gate?.nextActionCode || '').trim();
|
||||
if (!actionCode) return '';
|
||||
const actionKeys = [
|
||||
`workspace.shippingNotice.processGate.actions.${actionCode}`,
|
||||
`chat.shippingProcessing.action.${actionCode}`,
|
||||
];
|
||||
for (const key of actionKeys) {
|
||||
if (i18n.te(key)) return i18n.t(key);
|
||||
}
|
||||
return i18n.te('chat.shippingProcessing.gateReasons.generic')
|
||||
? i18n.t('chat.shippingProcessing.gateReasons.generic')
|
||||
: i18n.t('chat.shippingProcessing.status.blocked');
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* features/shipping-progress/mergeProcessingProjection.spec.ts
|
||||
* 用途:验收工作台 progress_version 单调合并规则。
|
||||
* 依赖:Vitest、mergeProcessingProjection。
|
||||
* 逻辑:旧包丢弃、同版本合并、新包整包替换。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { mergeWorkbenchProcessingProjection } from './mergeProcessingProjection';
|
||||
|
||||
function base(overrides: Partial<ShippingProcessingProjection> = {}): ShippingProcessingProjection {
|
||||
return {
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-1',
|
||||
sourceType: 'eml',
|
||||
rootOrderTaskNo: 'OT-1',
|
||||
shippingNoticeNo: 'SN-1',
|
||||
conversationId: 'c1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'blocked',
|
||||
stage: 'inventory_matching',
|
||||
progressVersion: 3,
|
||||
lastActivityAt: '2026-08-05T00:00:00Z',
|
||||
currentGate: null,
|
||||
availableActions: ['match_inventory'],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'a.pdf',
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('mergeWorkbenchProcessingProjection', () => {
|
||||
it('discards stale incoming with lower progressVersion', () => {
|
||||
const local = base({ progressVersion: 5, stage: 'excel_generating' });
|
||||
const incoming = base({ progressVersion: 4, stage: 'inventory_matching' });
|
||||
expect(mergeWorkbenchProcessingProjection(local, incoming)).toBe(local);
|
||||
});
|
||||
|
||||
it('replaces whole projection when incoming version is newer', () => {
|
||||
const local = base({ progressVersion: 5, stage: 'inventory_matching' });
|
||||
const incoming = base({ progressVersion: 6, stage: 'excel_generating', availableActions: ['download_excel'] });
|
||||
expect(mergeWorkbenchProcessingProjection(local, incoming)).toEqual(incoming);
|
||||
});
|
||||
|
||||
it('merges fields when versions are equal', () => {
|
||||
const local = base({
|
||||
progressVersion: 5,
|
||||
availableActions: ['match_inventory'],
|
||||
currentGate: {
|
||||
gateCode: 'old',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'match_inventory',
|
||||
blockingReasonCode: 'x',
|
||||
attemptNo: 1,
|
||||
},
|
||||
});
|
||||
const incoming = base({
|
||||
progressVersion: 5,
|
||||
availableActions: ['regenerate_excel'],
|
||||
currentGate: null,
|
||||
});
|
||||
const merged = mergeWorkbenchProcessingProjection(local, incoming);
|
||||
expect(merged?.availableActions).toEqual(['regenerate_excel']);
|
||||
expect(merged?.currentGate).toBeNull();
|
||||
expect(merged?.progressVersion).toBe(5);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* features/shipping-progress/mergeProcessingProjection.ts
|
||||
* 用途:订单处理工作台 Projection 按 progress_version 合并(禁止旧包覆盖新包)。
|
||||
* 依赖:ShippingProcessingProjection。
|
||||
* 逻辑:仅工作台启用;任务中心不调用。incoming < local 丢弃;== 字段合并保留本地 UI;> 整包替换。
|
||||
*/
|
||||
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
/**
|
||||
* 按 progressVersion 单调规则合并投影。
|
||||
*
|
||||
* 核心逻辑:
|
||||
* - incoming < local → 返回 local(丢弃整包)
|
||||
* - incoming == local → 浅合并字段,保留 local 上已有临时 UI 相关字段优先
|
||||
* - incoming > local 或 local 为空 → 返回 incoming
|
||||
*
|
||||
* @param local - 当前工作台投影
|
||||
* @param incoming - 新拉取并已 normalize 的投影
|
||||
* @returns 应写入状态的投影
|
||||
*/
|
||||
export function mergeWorkbenchProcessingProjection(
|
||||
local: ShippingProcessingProjection | null | undefined,
|
||||
incoming: ShippingProcessingProjection | null | undefined,
|
||||
): ShippingProcessingProjection | null {
|
||||
if (!incoming) return local ?? null;
|
||||
if (!local) return incoming;
|
||||
|
||||
const localVersion = Number(local.progressVersion || 0);
|
||||
const incomingVersion = Number(incoming.progressVersion || 0);
|
||||
|
||||
if (incomingVersion < localVersion) {
|
||||
return local;
|
||||
}
|
||||
if (incomingVersion > localVersion) {
|
||||
return incoming;
|
||||
}
|
||||
// [STEP] 同版本:incoming 覆盖业务字段;本地临时 UI 由调用方另行保留。
|
||||
return {
|
||||
...local,
|
||||
...incoming,
|
||||
};
|
||||
}
|
||||
@@ -191,19 +191,46 @@ export function buildProgressRangeHint(
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建订单处理工作台五域摘要(默认紧凑条用,非完整 15 阶)。
|
||||
* 构建订单处理工作台五域摘要(压缩业务域一行)。
|
||||
*
|
||||
* 核心逻辑:当前索引落在域内 → current/blocked/failed;整域已过 → passed;否则 pending。
|
||||
* 核心逻辑:若传入 authoritativeNodes(来自 projection.stageNodes),仅据此聚合,禁止第二套启发式;
|
||||
* 未传时回退当前 stage 索引(兼容详情抽屉等非工作台主条场景)。
|
||||
*
|
||||
* @param projection - 统一投影
|
||||
* @param authoritativeNodes - 可选权威 15 阶节点(工作台主条必须传入)
|
||||
*/
|
||||
export function buildReviewProgressDomainSummary(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
authoritativeNodes?: Array<{ absoluteIndex: number; status: ShippingProcessingStageNodeStatus }> | null,
|
||||
): ProgressDomainSummaryItem[] {
|
||||
if (!projection) return [];
|
||||
const currentIndex = stageAbsoluteIndex(projection.stage);
|
||||
const statusNorm = String(projection.status || '').trim().toLowerCase();
|
||||
return REVIEW_PROGRESS_DOMAIN_RANGES.map((domain) => {
|
||||
let state: ProgressDomainState = 'pending';
|
||||
if (currentIndex > domain.end) {
|
||||
if (authoritativeNodes?.length) {
|
||||
// [STEP] 仅由权威节点聚合:域内含 blocked/failed → 对应态;含 running/当前阶 → current;全 passed/skipped → passed。
|
||||
const slice = authoritativeNodes.filter(
|
||||
(node) => node.absoluteIndex >= domain.start && node.absoluteIndex <= domain.end,
|
||||
);
|
||||
if (slice.some((node) => node.status === 'failed')) {
|
||||
state = 'failed';
|
||||
} else if (slice.some((node) => node.status === 'blocked')) {
|
||||
state = 'blocked';
|
||||
} else if (
|
||||
slice.some((node) => node.status === 'running')
|
||||
|| (currentIndex >= domain.start && currentIndex <= domain.end)
|
||||
) {
|
||||
state = 'current';
|
||||
} else if (
|
||||
slice.length > 0
|
||||
&& slice.every((node) => node.status === 'passed' || node.status === 'skipped')
|
||||
) {
|
||||
state = 'passed';
|
||||
} else if (currentIndex > domain.end) {
|
||||
state = 'passed';
|
||||
}
|
||||
} else if (currentIndex > domain.end) {
|
||||
state = 'passed';
|
||||
} else if (currentIndex >= domain.start && currentIndex <= domain.end) {
|
||||
if (statusNorm === 'failed' || statusNorm === 'cancelled') state = 'failed';
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* features/shipping-progress/stageNodesAuthority.spec.ts
|
||||
* 用途:验收 stage_nodes 权威读取与 fail-closed。
|
||||
* 依赖:Vitest、stageNodesAuthority、SHIPPING_PROCESSING_STAGES。
|
||||
* 逻辑:合法 15 节点返回;长度/状态非法返回 null。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
SHIPPING_PROCESSING_STAGES,
|
||||
type ShippingProcessingProjection,
|
||||
type ShippingProcessingStageNode,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { readAuthoritativeStageNodes } from './stageNodesAuthority';
|
||||
|
||||
function projectionWithNodes(
|
||||
nodes: ShippingProcessingStageNode[] | undefined,
|
||||
): ShippingProcessingProjection {
|
||||
return {
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-1',
|
||||
sourceType: 'direct_pdf',
|
||||
rootOrderTaskNo: 'OT-1',
|
||||
shippingNoticeNo: null,
|
||||
conversationId: 'c1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-05T00:00:00Z',
|
||||
currentGate: null,
|
||||
availableActions: [],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'a.pdf',
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
stageNodes: nodes,
|
||||
};
|
||||
}
|
||||
|
||||
describe('readAuthoritativeStageNodes', () => {
|
||||
it('accepts exactly 15 valid nodes', () => {
|
||||
const nodes = SHIPPING_PROCESSING_STAGES.map((stage, absoluteIndex) => ({
|
||||
stage,
|
||||
absoluteIndex,
|
||||
status: absoluteIndex < 8 ? 'passed' as const : absoluteIndex === 8 ? 'blocked' as const : 'pending' as const,
|
||||
}));
|
||||
expect(readAuthoritativeStageNodes(projectionWithNodes(nodes))?.length).toBe(15);
|
||||
});
|
||||
|
||||
it('returns null when stage_nodes missing or wrong length', () => {
|
||||
expect(readAuthoritativeStageNodes(projectionWithNodes(undefined))).toBeNull();
|
||||
expect(readAuthoritativeStageNodes(projectionWithNodes([]))).toBeNull();
|
||||
});
|
||||
|
||||
it('returns null when status is illegal', () => {
|
||||
const nodes = SHIPPING_PROCESSING_STAGES.map((stage, absoluteIndex) => ({
|
||||
stage,
|
||||
absoluteIndex,
|
||||
status: (absoluteIndex === 0 ? 'weird' : 'pending') as ShippingProcessingStageNode['status'],
|
||||
}));
|
||||
expect(readAuthoritativeStageNodes(projectionWithNodes(nodes))).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* features/shipping-progress/stageNodesAuthority.ts
|
||||
* 用途:订单处理工作台 15 阶节点权威读取与校验(只信 projection.stageNodes)。
|
||||
* 依赖:shipping.api.types ShippingProcessingProjection / StageNode、SHIPPING_PROCESSING_STAGES。
|
||||
* 逻辑:ReviewProgressStrip 宽屏条与五域摘要共用;非法/缺失时 fail-closed,禁止启发式造假节点。
|
||||
*/
|
||||
|
||||
import {
|
||||
SHIPPING_PROCESSING_STAGES,
|
||||
type ShippingProcessingProjection,
|
||||
type ShippingProcessingStage,
|
||||
type ShippingProcessingStageNode,
|
||||
type ShippingProcessingStageNodeStatus,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const VALID_NODE_STATUSES = new Set<ShippingProcessingStageNodeStatus>([
|
||||
'skipped',
|
||||
'pending',
|
||||
'running',
|
||||
'passed',
|
||||
'blocked',
|
||||
'failed',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 校验并返回权威 stage_nodes;非法时返回 null。
|
||||
*
|
||||
* 核心逻辑:须恰好 15 个节点,且 stage / absoluteIndex / status 合法。
|
||||
*
|
||||
* @param projection - 统一处理投影
|
||||
* @returns 规范化节点列表;不可用时 null
|
||||
*/
|
||||
export function readAuthoritativeStageNodes(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
): ShippingProcessingStageNode[] | null {
|
||||
const raw = projection?.stageNodes;
|
||||
if (!Array.isArray(raw) || raw.length !== SHIPPING_PROCESSING_STAGES.length) {
|
||||
return null;
|
||||
}
|
||||
const nodes: ShippingProcessingStageNode[] = [];
|
||||
for (let i = 0; i < raw.length; i += 1) {
|
||||
const item = raw[i];
|
||||
if (!item || typeof item !== 'object') return null;
|
||||
const stage = String(item.stage || '').trim() as ShippingProcessingStage;
|
||||
const absoluteIndex = Number(item.absoluteIndex);
|
||||
const status = String(item.status || '').trim() as ShippingProcessingStageNodeStatus;
|
||||
if (!SHIPPING_PROCESSING_STAGES.includes(stage)) return null;
|
||||
if (!Number.isInteger(absoluteIndex) || absoluteIndex !== i) return null;
|
||||
if (SHIPPING_PROCESSING_STAGES[i] !== stage) return null;
|
||||
if (!VALID_NODE_STATUSES.has(status)) return null;
|
||||
nodes.push({ stage, absoluteIndex, status });
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* stage_nodes 不可用时的 fail-closed 告警(仅结构化字段)。
|
||||
*
|
||||
* @param params.workItemNo - 工作项编号
|
||||
* @param params.reason - 简短原因码
|
||||
*/
|
||||
export function warnStageNodesUnavailable(params: {
|
||||
workItemNo?: string | null;
|
||||
reason: string;
|
||||
}): void {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('[shipping-workbench] stage_nodes unavailable', {
|
||||
workItemNo: String(params.workItemNo || '').trim() || null,
|
||||
reason: params.reason,
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* features/shipping-progress/workbenchActionRegistry.spec.ts
|
||||
* 用途:验收订单处理工作台动作注册表与 fail-closed 规则。
|
||||
* 依赖:Vitest、workbenchActionRegistry、actionPresentation。
|
||||
* 逻辑:合法码可渲染;未知码告警且不进入 presentation;review 隐藏自跳转与 refresh。
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveProcessingActionPresentation } from './actionPresentation';
|
||||
import {
|
||||
WORKBENCH_ACTION_REGISTRY,
|
||||
lookupWorkbenchAction,
|
||||
resolveWorkbenchActionItem,
|
||||
shouldRenderWorkbenchAction,
|
||||
} from './workbenchActionRegistry';
|
||||
|
||||
function projection(
|
||||
overrides: Partial<ShippingProcessingProjection> = {},
|
||||
): ShippingProcessingProjection {
|
||||
return {
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-1',
|
||||
sourceType: 'eml',
|
||||
rootOrderTaskNo: 'OT-1',
|
||||
shippingNoticeNo: 'SN-1',
|
||||
conversationId: 'c1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'blocked',
|
||||
stage: 'inventory_matching',
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-05T00:00:00Z',
|
||||
currentGate: null,
|
||||
availableActions: [],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'a.pdf',
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe('workbenchActionRegistry', () => {
|
||||
afterEach(() => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('registers fulfillment and focus actions used by Footer', () => {
|
||||
for (const code of [
|
||||
'confirm_inventory_source',
|
||||
'match_inventory',
|
||||
'generate_excel',
|
||||
'mark_manual_uploaded',
|
||||
'retry_upload',
|
||||
'view_result',
|
||||
'view_record',
|
||||
'confirm_customer',
|
||||
'open_profile_review',
|
||||
'open_inventory_source_review',
|
||||
]) {
|
||||
expect(lookupWorkbenchAction(code)).toBeTruthy();
|
||||
}
|
||||
expect(WORKBENCH_ACTION_REGISTRY.open_inventory_source_review.reviewBehavior).toBe('open_inventory_candidates');
|
||||
expect(WORKBENCH_ACTION_REGISTRY.confirm_inventory_source.reviewBehavior).toBe('todo_panel');
|
||||
expect(WORKBENCH_ACTION_REGISTRY.confirm_customer.reviewBehavior).toBe('open_customer_dialog');
|
||||
});
|
||||
|
||||
it('hides open_order_review / edit_formal_task / refresh on review surface', () => {
|
||||
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.open_order_review, {
|
||||
actionsExecutable: true,
|
||||
surface: 'review',
|
||||
})).toBe(false);
|
||||
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.edit_formal_task, {
|
||||
actionsExecutable: true,
|
||||
surface: 'review',
|
||||
})).toBe(false);
|
||||
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.refresh, {
|
||||
actionsExecutable: true,
|
||||
surface: 'review',
|
||||
})).toBe(false);
|
||||
});
|
||||
|
||||
it('hides write actions when actionsExecutable=false but keeps view_result', () => {
|
||||
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.match_inventory, {
|
||||
actionsExecutable: false,
|
||||
surface: 'review',
|
||||
})).toBe(false);
|
||||
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.view_result, {
|
||||
actionsExecutable: false,
|
||||
surface: 'review',
|
||||
})).toBe(true);
|
||||
});
|
||||
|
||||
it('warns and omits unregistered action codes from review presentation', () => {
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
availableActions: ['totally_unknown_action', 'view_result'],
|
||||
}), { surface: 'review', actionsExecutable: true });
|
||||
expect(result.primary?.intent).toBe('view_result');
|
||||
expect(warn).toHaveBeenCalled();
|
||||
const payload = warn.mock.calls[0]?.[1] as { action_code?: string };
|
||||
expect(payload?.action_code).toBe('totally_unknown_action');
|
||||
});
|
||||
|
||||
it('exposes match_inventory as primary for review Footer', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
currentGate: {
|
||||
gateCode: 'inventory_match',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'match_inventory',
|
||||
blockingReasonCode: 'inventory_shortage',
|
||||
attemptNo: 1,
|
||||
},
|
||||
availableActions: ['refresh'],
|
||||
}), { surface: 'review', actionsExecutable: true });
|
||||
expect(result.primary?.intent).toBe('open_inventory_match_review');
|
||||
expect(result.primary?.actionCode).toBe('match_inventory');
|
||||
expect(result.secondary).toBeNull();
|
||||
});
|
||||
|
||||
it('hides confirm_customer when customer panel unavailable', () => {
|
||||
const warn = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
expect(shouldRenderWorkbenchAction(WORKBENCH_ACTION_REGISTRY.confirm_customer, {
|
||||
actionsExecutable: true,
|
||||
surface: 'review',
|
||||
panels: { customerUnresolved: false },
|
||||
actionCode: 'confirm_customer',
|
||||
})).toBe(false);
|
||||
expect(warn).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('routes aliased open_inventory_source_review to todo_panel after create', () => {
|
||||
// 后端 normalize 后 Footer 只见 open_inventory_source_review;建单后须 Todo。
|
||||
const pre = resolveWorkbenchActionItem({
|
||||
intent: 'open_inventory_source_review',
|
||||
actionCode: 'open_inventory_source_review',
|
||||
labelKey: 'x',
|
||||
}, { postCreate: false });
|
||||
expect(pre?.reviewBehavior).toBe('open_inventory_candidates');
|
||||
|
||||
const post = resolveWorkbenchActionItem({
|
||||
intent: 'open_inventory_source_review',
|
||||
actionCode: 'open_inventory_source_review',
|
||||
labelKey: 'x',
|
||||
}, { postCreate: true });
|
||||
expect(post?.reviewBehavior).toBe('todo_panel');
|
||||
expect(post?.todoActionCode).toBe('confirm_inventory_source');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,491 @@
|
||||
/**
|
||||
* features/shipping-progress/workbenchActionRegistry.ts
|
||||
* 用途:订单处理工作台统一动作注册表(Projection action → 宿主执行器)。
|
||||
* 依赖:shipping.api.types ActionIntent、ActionPresentationItem / Surface。
|
||||
* 逻辑:Footer/Resolver 只经本表派发;未知码 fail-closed(不渲染 + console.warn);
|
||||
* 写交互使用显式执行器(禁止宽泛 navigate_panel);面板依赖由 requiresPanel 守卫。
|
||||
*/
|
||||
|
||||
import type { ShippingProcessingActionIntent } from '@/features/chat/types/shipping.api.types';
|
||||
import type { ActionPresentationItem, ActionPresentationSurface } from './types';
|
||||
|
||||
/** 工作台执行器类别(禁止宽泛 navigate_panel)。 */
|
||||
export type WorkbenchActionExecutorKind =
|
||||
| 'todo_panel'
|
||||
| 'open_customer_dialog'
|
||||
| 'focus_field_conflicts'
|
||||
| 'focus_duplicate_panel'
|
||||
| 'focus_profile_panel'
|
||||
| 'open_inventory_candidates'
|
||||
| 'focus_inventory_issues'
|
||||
| 'download'
|
||||
| 'retry'
|
||||
| 'view_result'
|
||||
| 'view_record'
|
||||
| 'refresh_strip_only'
|
||||
| 'hidden_on_review';
|
||||
|
||||
/** 面板可用性键(与 WorkbenchPanelAvailability 对齐)。 */
|
||||
export type WorkbenchPanelKey =
|
||||
| 'customerUnresolved'
|
||||
| 'hasFieldConflicts'
|
||||
| 'hasDuplicateAdjudication'
|
||||
| 'hasProfileMatch'
|
||||
| 'hasInventoryCandidates'
|
||||
| 'hasInventoryIssues';
|
||||
|
||||
/** 当前 Case 面板是否挂载/有内容,供 requiresPanel 过滤。 */
|
||||
export interface WorkbenchPanelAvailability {
|
||||
customerUnresolved?: boolean;
|
||||
hasFieldConflicts?: boolean;
|
||||
hasDuplicateAdjudication?: boolean;
|
||||
hasProfileMatch?: boolean;
|
||||
hasInventoryCandidates?: boolean;
|
||||
hasInventoryIssues?: boolean;
|
||||
}
|
||||
|
||||
/** 注册表条目。 */
|
||||
export interface WorkbenchActionRegistryEntry {
|
||||
/** 契约意图(与后端 SHIPPING_PROCESSING_ACTION_INTENTS 对齐)。 */
|
||||
intent: ShippingProcessingActionIntent;
|
||||
/** 工作台 surface 行为。 */
|
||||
reviewBehavior: WorkbenchActionExecutorKind;
|
||||
/** TaskTodoPanel 调用时使用的动作码(可与原始码不同)。 */
|
||||
todoActionCode?: string;
|
||||
/** 页面内滚动/高亮锚点 data-testid。 */
|
||||
scrollTestId?: string;
|
||||
/** 是否需要正式 Notice 任务详情(履约写)。 */
|
||||
requiresFormalTask?: boolean;
|
||||
/** 依赖的面板可用性键;缺失时 fail-closed 隐藏。 */
|
||||
requiresPanel?: WorkbenchPanelKey;
|
||||
/** 是否为写操作(actionsExecutable=false 时隐藏)。 */
|
||||
isWrite: boolean;
|
||||
/** 预期 stage family(契约测试用)。 */
|
||||
stageFamily: 'pre_create' | 'post_create' | 'any' | 'terminal';
|
||||
}
|
||||
|
||||
/**
|
||||
* 合法 action_code → 注册条目(含别名)。
|
||||
* 新增后端动作必须先登记本表,否则前端 fail-closed。
|
||||
*/
|
||||
export const WORKBENCH_ACTION_REGISTRY: Record<string, WorkbenchActionRegistryEntry> = {
|
||||
open_order_review: {
|
||||
intent: 'open_order_review',
|
||||
reviewBehavior: 'hidden_on_review',
|
||||
isWrite: false,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
open_review: {
|
||||
intent: 'open_order_review',
|
||||
reviewBehavior: 'hidden_on_review',
|
||||
isWrite: false,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
open_order_processing: {
|
||||
intent: 'open_order_review',
|
||||
reviewBehavior: 'hidden_on_review',
|
||||
isWrite: false,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
enter_manual_review: {
|
||||
intent: 'open_order_review',
|
||||
reviewBehavior: 'hidden_on_review',
|
||||
isWrite: false,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
edit_formal_task: {
|
||||
intent: 'edit_formal_task',
|
||||
reviewBehavior: 'hidden_on_review',
|
||||
isWrite: false,
|
||||
stageFamily: 'any',
|
||||
},
|
||||
freeze_order: {
|
||||
intent: 'edit_formal_task',
|
||||
reviewBehavior: 'hidden_on_review',
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
},
|
||||
open_profile_review: {
|
||||
intent: 'open_profile_review',
|
||||
reviewBehavior: 'focus_profile_panel',
|
||||
scrollTestId: 'review-profile-match-panel',
|
||||
requiresPanel: 'hasProfileMatch',
|
||||
isWrite: false,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
confirm_customer: {
|
||||
intent: 'confirm_customer',
|
||||
reviewBehavior: 'open_customer_dialog',
|
||||
scrollTestId: 'review-customer-resolution-panel',
|
||||
requiresPanel: 'customerUnresolved',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
resolve_field_conflicts: {
|
||||
intent: 'resolve_field_conflicts',
|
||||
reviewBehavior: 'focus_field_conflicts',
|
||||
scrollTestId: 'review-field-conflict-panel',
|
||||
requiresPanel: 'hasFieldConflicts',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
adjudicate_duplicate: {
|
||||
intent: 'adjudicate_duplicate',
|
||||
reviewBehavior: 'focus_duplicate_panel',
|
||||
scrollTestId: 'review-duplicate-panel',
|
||||
requiresPanel: 'hasDuplicateAdjudication',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
// 建单前:打开库存候选面板(禁止 TaskTodoPanel);不依赖面板键(Gate 已授权)。
|
||||
open_inventory_source_review: {
|
||||
intent: 'open_inventory_source_review',
|
||||
reviewBehavior: 'open_inventory_candidates',
|
||||
scrollTestId: 'review-inventory-candidates-panel',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
// 建单后:委托 TaskTodoPanel 确认库存源。
|
||||
confirm_inventory_source: {
|
||||
intent: 'open_inventory_source_review',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'confirm_inventory_source',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
retry_resolve_inventory_source: {
|
||||
intent: 'open_inventory_source_review',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'confirm_inventory_source',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
open_inventory_match_review: {
|
||||
intent: 'open_inventory_match_review',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'match_inventory',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
match_inventory: {
|
||||
intent: 'open_inventory_match_review',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'match_inventory',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
rematch: {
|
||||
intent: 'open_inventory_match_review',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'rematch',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
open_shortage_review: {
|
||||
intent: 'open_shortage_review',
|
||||
reviewBehavior: 'focus_inventory_issues',
|
||||
scrollTestId: 'review-inventory-issue-list',
|
||||
requiresPanel: 'hasInventoryIssues',
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
},
|
||||
upload_inventory_file: {
|
||||
intent: 'upload_inventory_file',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'upload_inventory_file',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
regenerate_excel: {
|
||||
intent: 'regenerate_excel',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'generate_excel',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
generate_excel: {
|
||||
intent: 'regenerate_excel',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'generate_excel',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
download_excel: {
|
||||
intent: 'download_excel',
|
||||
reviewBehavior: 'download',
|
||||
isWrite: false,
|
||||
stageFamily: 'post_create',
|
||||
},
|
||||
open_manual_upload: {
|
||||
intent: 'open_manual_upload',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'mark_manual_uploaded',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
wait_manual_upload: {
|
||||
intent: 'open_manual_upload',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'mark_manual_uploaded',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
mark_manual_uploaded: {
|
||||
intent: 'open_manual_upload',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'mark_manual_uploaded',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
regenerate_manual_upload_todo: {
|
||||
intent: 'open_manual_upload',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'mark_manual_uploaded',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
retry_upload: {
|
||||
intent: 'retry',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'retry_upload',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
retry_freight_upload_rpa: {
|
||||
intent: 'retry',
|
||||
reviewBehavior: 'todo_panel',
|
||||
todoActionCode: 'retry_upload',
|
||||
requiresFormalTask: true,
|
||||
isWrite: true,
|
||||
stageFamily: 'post_create',
|
||||
scrollTestId: 'review-formal-task-todo-panel',
|
||||
},
|
||||
retry: {
|
||||
intent: 'retry',
|
||||
reviewBehavior: 'retry',
|
||||
isWrite: true,
|
||||
stageFamily: 'any',
|
||||
},
|
||||
retry_parse: {
|
||||
intent: 'retry',
|
||||
reviewBehavior: 'retry',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
retry_failed_documents: {
|
||||
intent: 'retry',
|
||||
reviewBehavior: 'retry',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
retry_failed_attachments: {
|
||||
intent: 'retry',
|
||||
reviewBehavior: 'retry',
|
||||
isWrite: true,
|
||||
stageFamily: 'pre_create',
|
||||
},
|
||||
refresh: {
|
||||
intent: 'refresh',
|
||||
reviewBehavior: 'refresh_strip_only',
|
||||
isWrite: false,
|
||||
stageFamily: 'any',
|
||||
},
|
||||
view_result: {
|
||||
intent: 'view_result',
|
||||
reviewBehavior: 'view_result',
|
||||
isWrite: false,
|
||||
stageFamily: 'terminal',
|
||||
scrollTestId: 'review-formal-task-result-region',
|
||||
},
|
||||
open_fulfillment: {
|
||||
intent: 'view_result',
|
||||
reviewBehavior: 'view_result',
|
||||
isWrite: false,
|
||||
stageFamily: 'terminal',
|
||||
scrollTestId: 'review-formal-task-result-region',
|
||||
},
|
||||
view_details: {
|
||||
intent: 'view_result',
|
||||
reviewBehavior: 'view_result',
|
||||
isWrite: false,
|
||||
stageFamily: 'terminal',
|
||||
scrollTestId: 'review-formal-task-result-region',
|
||||
},
|
||||
focus_task: {
|
||||
intent: 'view_result',
|
||||
reviewBehavior: 'view_result',
|
||||
isWrite: false,
|
||||
stageFamily: 'any',
|
||||
scrollTestId: 'review-formal-task-result-region',
|
||||
},
|
||||
view_record: {
|
||||
intent: 'view_record',
|
||||
reviewBehavior: 'view_record',
|
||||
isWrite: false,
|
||||
stageFamily: 'any',
|
||||
},
|
||||
cancel_task: {
|
||||
intent: 'view_record',
|
||||
reviewBehavior: 'view_record',
|
||||
isWrite: false,
|
||||
stageFamily: 'any',
|
||||
},
|
||||
cancel_run: {
|
||||
intent: 'view_record',
|
||||
reviewBehavior: 'view_record',
|
||||
isWrite: false,
|
||||
stageFamily: 'any',
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* 查找注册表条目(大小写不敏感)。
|
||||
*
|
||||
* @param actionCode - Gate / available_actions 原始码
|
||||
* @returns 注册条目;未登记返回 null
|
||||
*/
|
||||
export function lookupWorkbenchAction(actionCode: string | null | undefined): WorkbenchActionRegistryEntry | null {
|
||||
const key = String(actionCode || '').trim().toLowerCase();
|
||||
if (!key) return null;
|
||||
return WORKBENCH_ACTION_REGISTRY[key] || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 未知动作 fail-closed 告警(仅 action_code / surface / workItemType)。
|
||||
*
|
||||
* @param params.actionCode - 未登记动作码
|
||||
* @param params.surface - 展示面
|
||||
* @param params.workItemType - 可选工作项类型
|
||||
*/
|
||||
export function warnUnregisteredWorkbenchAction(params: {
|
||||
actionCode: string;
|
||||
surface: ActionPresentationSurface;
|
||||
workItemType?: string | null;
|
||||
}): void {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('[shipping-workbench] unregistered action hidden', {
|
||||
action_code: String(params.actionCode || '').trim(),
|
||||
surface: params.surface,
|
||||
workItemType: String(params.workItemType || '').trim() || null,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 面板依赖不满足时告警(fail-closed 隐藏)。
|
||||
*
|
||||
* @param params.actionCode - 动作码
|
||||
* @param params.panelKey - 缺失的面板键
|
||||
* @param params.surface - 展示面
|
||||
*/
|
||||
export function warnUnavailableWorkbenchPanel(params: {
|
||||
actionCode: string;
|
||||
panelKey: WorkbenchPanelKey;
|
||||
surface: ActionPresentationSurface;
|
||||
}): void {
|
||||
// eslint-disable-next-line no-console
|
||||
console.warn('[shipping-workbench] required panel unavailable', {
|
||||
action_code: String(params.actionCode || '').trim(),
|
||||
panel_key: params.panelKey,
|
||||
surface: params.surface,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断工作台 surface 是否应渲染该动作。
|
||||
*
|
||||
* 核心逻辑:review 隐藏自跳转与 refresh;写操作受 actionsExecutable 约束;
|
||||
* requiresPanel 在 panels 提供时做可用性守卫。
|
||||
*
|
||||
* @param entry - 注册条目
|
||||
* @param options.actionsExecutable - 是否允许业务写
|
||||
* @param options.surface - 展示面
|
||||
* @param options.panels - 可选面板可用性
|
||||
* @param options.actionCode - 可选原始码(告警用)
|
||||
*/
|
||||
export function shouldRenderWorkbenchAction(
|
||||
entry: WorkbenchActionRegistryEntry,
|
||||
options: {
|
||||
actionsExecutable: boolean;
|
||||
surface: ActionPresentationSurface;
|
||||
panels?: WorkbenchPanelAvailability | null;
|
||||
actionCode?: string;
|
||||
},
|
||||
): boolean {
|
||||
if (options.surface === 'review') {
|
||||
if (entry.reviewBehavior === 'hidden_on_review') return false;
|
||||
if (entry.reviewBehavior === 'refresh_strip_only') return false;
|
||||
}
|
||||
if (entry.isWrite && !options.actionsExecutable) return false;
|
||||
if (entry.requiresPanel && options.panels) {
|
||||
const available = Boolean(options.panels[entry.requiresPanel]);
|
||||
if (!available) {
|
||||
warnUnavailableWorkbenchPanel({
|
||||
actionCode: options.actionCode || entry.intent,
|
||||
panelKey: entry.requiresPanel,
|
||||
surface: options.surface,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 ActionPresentationItem 解析注册条目;未登记返回 null。
|
||||
*
|
||||
* 核心逻辑:优先按原始 actionCode 查找;建单后若后端把 confirm_inventory_source
|
||||
* 别名为 open_inventory_source_review,则改用 todo_panel 条目(禁止再开候选面板)。
|
||||
*
|
||||
* @param item - 统一动作项
|
||||
* @param options.postCreate - 正式 Notice 已建单时为 true
|
||||
*/
|
||||
export function resolveWorkbenchActionItem(
|
||||
item: ActionPresentationItem,
|
||||
options?: { postCreate?: boolean },
|
||||
): WorkbenchActionRegistryEntry | null {
|
||||
const byCode = lookupWorkbenchAction(item.actionCode);
|
||||
const byIntent = lookupWorkbenchAction(item.intent);
|
||||
const entry = byCode || byIntent;
|
||||
if (!entry) return null;
|
||||
|
||||
// [STEP] 建单后库存源确认:契约意图仍是 open_inventory_source_review,执行器须走 Todo。
|
||||
const code = String(item.actionCode || '').trim().toLowerCase();
|
||||
const inventorySourceCodes = new Set([
|
||||
'open_inventory_source_review',
|
||||
'confirm_inventory_source',
|
||||
'retry_resolve_inventory_source',
|
||||
]);
|
||||
if (
|
||||
options?.postCreate
|
||||
&& (entry.intent === 'open_inventory_source_review' || inventorySourceCodes.has(code))
|
||||
) {
|
||||
return lookupWorkbenchAction('confirm_inventory_source') || entry;
|
||||
}
|
||||
return entry;
|
||||
}
|
||||
@@ -1,9 +1,10 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskCenterPage.vue
|
||||
* 用途:发货「任务中心」壳——Pending|Processing|Done + 识别 Run 续办表;仅列表入口。
|
||||
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情(直链摘要)、ShippingRunProgressTable、useShippingTodoBadge、
|
||||
* shippingProcessingLabels。
|
||||
* 逻辑:选中项展示入口卡 + 统一进度紧凑摘要(UI-03);唯一主按钮深链「订单处理工作台」或对话;
|
||||
* 用途:发货「任务中心」壳——Pending|Processing|Done + 识别 Run 续办表;列表入口 + STP 重试。
|
||||
* 依赖:shipping-tasks.api(my-todos)、shipping.api(详情/STP retry)、ShippingRunProgressTable、
|
||||
* useShippingTodoBadge、useMessage、shippingProcessingLabels。
|
||||
* 逻辑:选中项展示入口卡 + 统一进度紧凑摘要(UI-03);主按钮深链「订单处理工作台」;
|
||||
* review_case 在 failed/manual_fallback 时提供「重试自动推进」(与底栏同一 API/幂等键);
|
||||
* 不内嵌 ShippingTaskWorkbench;轮询依据 shipping_processing_status /
|
||||
* process_status / Intake parse_status。
|
||||
*/
|
||||
@@ -15,6 +16,7 @@ import { useI18n } from 'vue-i18n';
|
||||
import {
|
||||
getWorkspaceShippingTask,
|
||||
listShippingChatAgents,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
SHIPPING_NOTICE_AGENT_CODE,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
@@ -25,6 +27,8 @@ import {
|
||||
type ShippingMyTodosCount,
|
||||
} from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { useShippingTodoBadge } from '../composables/useShippingTodoBadge';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
IN_PROGRESS_PROCESSING_STATUSES,
|
||||
TERMINAL_PROCESSING_STATUSES,
|
||||
@@ -42,6 +46,7 @@ import {
|
||||
import ShippingRunProgressTable from './ShippingRunProgressTable.vue';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
/** 进行中 Workflow/Task 前台轮询间隔。 */
|
||||
const FOREGROUND_POLL_MS = 2000;
|
||||
/** 页面隐藏时后台轮询间隔。 */
|
||||
@@ -354,7 +359,7 @@ async function refreshAll(_options?: { silent?: boolean }) {
|
||||
|
||||
/**
|
||||
* 打开订单处理工作台(Chat 主区 order-review;单 OT 全生命周期)。
|
||||
* 任务中心仅作列表入口,禁止在本页履约写操作。
|
||||
* 任务中心仅作列表入口,禁止在本页履约写操作(STP 重试除外)。
|
||||
*/
|
||||
function openOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
@@ -382,6 +387,41 @@ function canOpenOrderProcessing(item: ShippingTaskSummary | ShippingTaskDetail |
|
||||
return Boolean(runNo && agentId);
|
||||
}
|
||||
|
||||
const stpRetrying = ref(false);
|
||||
|
||||
/**
|
||||
* 任务中心是否展示「重试自动推进」(与工作台底栏同一 available_actions / 幂等键)。
|
||||
*/
|
||||
function canRetryStpAutoCreate(item: ShippingTaskSummary | ShippingTaskDetail | null): boolean {
|
||||
if (!item || item.can_handle === false) return false;
|
||||
const caseNo = String(item.review_case_no || '').trim();
|
||||
if (!caseNo) return false;
|
||||
const summaryActions = item.ui_state?.summary?.allowed_actions || [];
|
||||
const buttons = (item.ui_state?.action_buttons || []).map((action) => String(action));
|
||||
return summaryActions.includes('retry_stp_auto_create') || buttons.includes('retry_stp_auto_create');
|
||||
}
|
||||
|
||||
/**
|
||||
* 显式重试 STP 自动建单入队;与 ReviewWorkbenchFooter 共用 POST retry API。
|
||||
*/
|
||||
async function retryStpAutoCreate(item: ShippingTaskSummary | ShippingTaskDetail) {
|
||||
const caseNo = String(item.review_case_no || '').trim();
|
||||
if (!caseNo || stpRetrying.value) return;
|
||||
stpRetrying.value = true;
|
||||
try {
|
||||
await retryWorkspaceShippingOrderStpAutoCreate(caseNo);
|
||||
msg.success(t('chat.shippingOrderReview.autoProgress.retryStpSuccess'));
|
||||
await loadTodos();
|
||||
} catch (error) {
|
||||
const message = error instanceof BusinessError
|
||||
? (error.message || t('chat.shippingOrderReview.autoProgress.retryStp'))
|
||||
: t('chat.shippingOrderReview.autoProgress.retryStp');
|
||||
msg.error(message);
|
||||
} finally {
|
||||
stpRetrying.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开对话「本次处理中」卡,聚焦未建 OT 的 Intake 材料。
|
||||
*/
|
||||
@@ -731,16 +771,29 @@ onBeforeUnmount(() => {
|
||||
{{ selectedItem.source_file_name }}
|
||||
<span v-if="selectedItem.review_run_no"> · {{ selectedItem.review_run_no }}</span>
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!canOpenOrderProcessing(selectedItem)"
|
||||
data-testid="my-todos-open-order-processing"
|
||||
@click="openOrderProcessing(selectedItem)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</button>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!canOpenOrderProcessing(selectedItem)"
|
||||
data-testid="my-todos-open-order-processing"
|
||||
@click="openOrderProcessing(selectedItem)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canRetryStpAutoCreate(selectedItem)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-amber-400 bg-amber-50 px-4 py-2 text-sm font-medium text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
:disabled="stpRetrying"
|
||||
data-testid="my-todos-retry-stp-auto-create"
|
||||
@click="() => { if (selectedItem) void retryStpAutoCreate(selectedItem); }"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.shippingOrderReview.autoProgress.retryStp') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="isIntakeSelection && selectedItem"
|
||||
|
||||
+137
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.actionsExecutable.spec.ts
|
||||
* 用途:验收 A2——Gate 只读时 Footer 委托 invokeActionByCode 仍可写。
|
||||
* 依赖:Vitest、Vue Test Utils、TaskTodoPanel、shipping.api mock。
|
||||
* 逻辑:gateCanHandle=false + actionsExecutable=true 时匹配库存 API 被调用;
|
||||
* actionsExecutable=false 时直接返回;hidePrimaryActions 时不渲染 action_buttons。
|
||||
*/
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import TaskTodoPanel from './TaskTodoPanel.vue';
|
||||
import type { ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const matchInventory = vi.fn().mockResolvedValue({});
|
||||
const refreshBadge = vi.fn().mockResolvedValue(undefined);
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
confirmWorkspaceShippingCustomer: vi.fn(),
|
||||
confirmWorkspaceShippingInventorySource: vi.fn(),
|
||||
freezeWorkspaceShippingOrder: vi.fn(),
|
||||
generateWorkspaceShippingExcel: vi.fn(),
|
||||
listWorkspaceShippingCustomerOptions: vi.fn().mockResolvedValue([]),
|
||||
matchWorkspaceShippingInventory: (...args: unknown[]) => matchInventory(...args),
|
||||
retryWorkspaceShippingUpload: vi.fn(),
|
||||
submitWorkspaceShippingDecision: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
downloadWorkspaceShippingExcelFile: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/composables/useShippingTodoBadge', () => ({
|
||||
refreshShippingTodoBadge: (...args: unknown[]) => refreshBadge(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue', () => ({
|
||||
default: {
|
||||
name: 'ProcessGateRecoveryCard',
|
||||
props: ['summary', 'canHandle'],
|
||||
template: '<div data-testid="gate-stub" :data-can-handle="canHandle" />',
|
||||
},
|
||||
}));
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
errors: {
|
||||
codes: {
|
||||
SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH: '归属不匹配',
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
todo: {
|
||||
currentTodo: '待办',
|
||||
adminViewOnly: '只读',
|
||||
waitingManualUploadNote: '上传',
|
||||
},
|
||||
actions: {
|
||||
failed: '失败',
|
||||
freezeOrder: '冻结',
|
||||
freezeConfirm: '确认',
|
||||
},
|
||||
loading: '加载中',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function detail(): ShippingTaskDetail {
|
||||
return {
|
||||
task_no: 'SN-1',
|
||||
ui_state: {
|
||||
summary: { title: 't', message: 'm' },
|
||||
action_buttons: [],
|
||||
checkpoint_kind: 'inventory',
|
||||
process_gate: null,
|
||||
},
|
||||
} as unknown as ShippingTaskDetail;
|
||||
}
|
||||
|
||||
describe('TaskTodoPanel actionsExecutable', () => {
|
||||
beforeEach(() => {
|
||||
matchInventory.mockClear();
|
||||
refreshBadge.mockClear();
|
||||
});
|
||||
|
||||
it('invokes match API when gateCanHandle=false but actionsExecutable=true', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
gateCanHandle: false,
|
||||
actionsExecutable: true,
|
||||
hidePrimaryActions: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.get('[data-testid="gate-stub"]').attributes('data-can-handle')).toBe('false');
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).toHaveBeenCalledWith('SN-1', undefined);
|
||||
});
|
||||
|
||||
it('blocks fulfillment invoke when expectedNoticeTaskNo mismatches', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
gateCanHandle: false,
|
||||
actionsExecutable: true,
|
||||
hidePrimaryActions: true,
|
||||
expectedNoticeTaskNo: 'SN-OTHER',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('no-ops invokeActionByCode when actionsExecutable=false', async () => {
|
||||
const wrapper = mount(TaskTodoPanel, {
|
||||
props: {
|
||||
detail: detail(),
|
||||
gateCanHandle: false,
|
||||
actionsExecutable: false,
|
||||
hidePrimaryActions: true,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await (wrapper.vm as { invokeActionByCode: (id: string) => Promise<void> }).invokeActionByCode('match_inventory');
|
||||
await flushPromises();
|
||||
expect(matchInventory).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -2,8 +2,8 @@
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.vue
|
||||
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办说明(表单/弹窗入口)。
|
||||
* 依赖:ProcessGateRecoveryCard、shipping.api、shipping-tasks.api、ManualUploadEvidenceDialog。
|
||||
* 逻辑:优先展示 ui_state.process_gate 阻断信息;hidePrimaryActions=true 时不渲染平级主按钮
|
||||
* (由订单处理工作台统一 ActionBar 输出,UI-01 / BE-05);对话框与登记表单仍由此面板承接。
|
||||
* 逻辑:gateCanHandle 控制 Gate 卡写按钮;actionsExecutable 控制 invokeActionByCode / 对话框写;
|
||||
* hidePrimaryActions=true 时不渲染 action_buttons(订单处理工作台写入口仅 Footer)。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -17,6 +17,7 @@ import type {
|
||||
ShippingInventorySourceCandidate,
|
||||
ShippingTaskDetail,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import {
|
||||
confirmWorkspaceShippingCustomer,
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
@@ -26,6 +27,7 @@ import {
|
||||
matchWorkspaceShippingInventory,
|
||||
retryWorkspaceShippingUpload,
|
||||
submitWorkspaceShippingDecision,
|
||||
type ShippingFulfillmentOwnershipContext,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
|
||||
@@ -37,11 +39,31 @@ import { gateSummaryIndicatesManualUpload } from '@/features/chat/shipping/shipp
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
detail: ShippingTaskDetail;
|
||||
canHandle: boolean;
|
||||
/** 为 true 时隐藏主按钮区与 Gate 卡内主操作(统一进度 ActionBar 已输出)。 */
|
||||
/** 兼容旧调用:未显式传 gate/actions 时两者跟随 canHandle。 */
|
||||
canHandle?: boolean;
|
||||
/** Gate 卡是否允许写(订单处理工作台恒为 false)。 */
|
||||
gateCanHandle?: boolean;
|
||||
/** Footer/Resolver 委托的 invokeActionByCode 是否可执行写。 */
|
||||
actionsExecutable?: boolean;
|
||||
/** 为 true 时隐藏全部 action_buttons(订单处理工作台写入口仅 Footer)。 */
|
||||
hidePrimaryActions?: boolean;
|
||||
/** 工作台权威正式 Notice 号;与 detail.task_no 不一致时禁止履约写。 */
|
||||
expectedNoticeTaskNo?: string | null;
|
||||
/** 工作台权威 OT 号,随履约 API 校验归属。 */
|
||||
expectedOrderTaskNo?: string | null;
|
||||
/** 当前 Review Case 号。 */
|
||||
expectedReviewCaseNo?: string | null;
|
||||
/** 当前 Extraction Run 号。 */
|
||||
expectedRunNo?: string | null;
|
||||
}>(), {
|
||||
canHandle: undefined,
|
||||
gateCanHandle: undefined,
|
||||
actionsExecutable: undefined,
|
||||
hidePrimaryActions: false,
|
||||
expectedNoticeTaskNo: null,
|
||||
expectedOrderTaskNo: null,
|
||||
expectedReviewCaseNo: null,
|
||||
expectedRunNo: null,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -173,12 +195,13 @@ const UNIFIED_OWNED_ACTION_IDS = new Set([
|
||||
]);
|
||||
|
||||
const visibleActions = computed(() => {
|
||||
// [STEP] 订单处理工作台:写操作仅 Footer;不渲染 Notice action_buttons(D1)。
|
||||
if (props.hidePrimaryActions) return [];
|
||||
// [STEP] Gate 阻断时后端已清零 action_buttons;前端再兜底隐藏,避免双真相。
|
||||
if (hasBlockingGate.value) return [];
|
||||
return actionButtons.value.filter((action) => {
|
||||
const id = String(action.id || '');
|
||||
// [UI-01 / BE-05] 统一 ActionBar 已表达的动作不再重复渲染;未映射的履约动作仍由本面板承接。
|
||||
if (props.hidePrimaryActions && UNIFIED_OWNED_ACTION_IDS.has(id)) {
|
||||
if (UNIFIED_OWNED_ACTION_IDS.has(id)) {
|
||||
return false;
|
||||
}
|
||||
if (!allowedIds.value.has(id) || !isActionAllowedForCheckpoint(id, checkpointKind.value)) {
|
||||
@@ -190,8 +213,14 @@ const visibleActions = computed(() => {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
/** Gate 卡在统一进度存在时仍可执行业务恢复(客户确认等),但避免与 ActionBar 重复的 next_action。 */
|
||||
const gateCanHandle = computed(() => props.canHandle);
|
||||
/** Gate 卡写权限;订单处理工作台传入 false 保持只读。 */
|
||||
const resolvedGateCanHandle = computed(() => (
|
||||
props.gateCanHandle !== undefined ? Boolean(props.gateCanHandle) : Boolean(props.canHandle)
|
||||
));
|
||||
/** Footer 委托写权限。 */
|
||||
const resolvedActionsExecutable = computed(() => (
|
||||
props.actionsExecutable !== undefined ? Boolean(props.actionsExecutable) : Boolean(props.canHandle)
|
||||
));
|
||||
/**
|
||||
* 动作成功后刷新详情并更新导航徽标。
|
||||
*/
|
||||
@@ -338,13 +367,44 @@ async function onFreezeConfirm() {
|
||||
pendingFreezeVersion.value = null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 组装履约 API 归属上下文(仅非空字段)。
|
||||
*/
|
||||
function ownershipContext(): ShippingFulfillmentOwnershipContext | undefined {
|
||||
const ctx: ShippingFulfillmentOwnershipContext = {};
|
||||
const ot = String(props.expectedOrderTaskNo || '').trim();
|
||||
const caseNo = String(props.expectedReviewCaseNo || '').trim();
|
||||
const run = String(props.expectedRunNo || '').trim();
|
||||
if (ot) ctx.expectedOrderTaskNo = ot;
|
||||
if (caseNo) ctx.expectedReviewCaseNo = caseNo;
|
||||
if (run) ctx.expectedRunNo = run;
|
||||
return (ctx.expectedOrderTaskNo || ctx.expectedReviewCaseNo || ctx.expectedRunNo) ? ctx : undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 履约写前校验正式任务号与工作台权威上下文一致。
|
||||
*
|
||||
* @returns 通过为 true;失败已提示并触发 refreshed
|
||||
*/
|
||||
async function assertFulfillmentOwnership(): Promise<boolean> {
|
||||
const expectedNotice = String(props.expectedNoticeTaskNo || '').trim();
|
||||
const actualNotice = String(props.detail.task_no || '').trim();
|
||||
if (expectedNotice && actualNotice && expectedNotice !== actualNotice) {
|
||||
msg.warning(t('errors.codes.SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH'));
|
||||
emit('refreshed');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
|
||||
*/
|
||||
async function runAction(action: ShippingChatAction) {
|
||||
if (!props.canHandle || busyId.value) return;
|
||||
if (!resolvedActionsExecutable.value || busyId.value) return;
|
||||
const id = String(action.id || '');
|
||||
if (id === 'mark_manual_uploaded') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
manualUploadOpen.value = true;
|
||||
return;
|
||||
}
|
||||
@@ -357,38 +417,47 @@ async function runAction(action: ShippingChatAction) {
|
||||
return;
|
||||
}
|
||||
if (id === 'confirm_inventory_source') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
await runConfirmInventorySource(action);
|
||||
return;
|
||||
}
|
||||
if (id === 'freeze_order') {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
openFreezeDialog();
|
||||
return;
|
||||
}
|
||||
busyId.value = id;
|
||||
try {
|
||||
if (!(await assertFulfillmentOwnership())) return;
|
||||
const ownership = ownershipContext();
|
||||
if (id === 'download_excel' || id === 'export') {
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'generate_excel') {
|
||||
await generateWorkspaceShippingExcel(props.detail.task_no);
|
||||
await generateWorkspaceShippingExcel(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'match_inventory' || id === 'rematch') {
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no);
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
if (id === 'retry_upload') {
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no);
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no, ownership);
|
||||
await afterSuccess();
|
||||
return;
|
||||
}
|
||||
await submitWorkspaceShippingDecision(props.detail.task_no, id);
|
||||
await afterSuccess();
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof BusinessError && e.code === 'SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH') {
|
||||
msg.warning(t('errors.codes.SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH'));
|
||||
emit('refreshed');
|
||||
return;
|
||||
}
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
} finally {
|
||||
busyId.value = null;
|
||||
@@ -421,7 +490,7 @@ defineExpose({
|
||||
<div class="space-y-3">
|
||||
<ProcessGateRecoveryCard
|
||||
:summary="processGateSummary"
|
||||
:can-handle="gateCanHandle"
|
||||
:can-handle="resolvedGateCanHandle"
|
||||
:navigation-context="{
|
||||
agentId: detail.owner_agent_id != null ? String(detail.owner_agent_id) : undefined,
|
||||
conversationId: detail.conversation_id || undefined,
|
||||
@@ -446,7 +515,7 @@ defineExpose({
|
||||
<p v-if="summary.pause_reason" class="mt-1 text-xs text-amber-700">
|
||||
{{ summary.pause_reason }}
|
||||
</p>
|
||||
<div v-if="!canHandle" class="mt-3 text-xs text-muted">
|
||||
<div v-if="!resolvedActionsExecutable" class="mt-3 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnly') }}
|
||||
</div>
|
||||
<div v-else-if="visibleActions.length" class="mt-3 flex flex-wrap gap-2">
|
||||
@@ -477,7 +546,7 @@ defineExpose({
|
||||
v-model:open="manualUploadOpen"
|
||||
:task-no="detail.task_no"
|
||||
:artifact-id="currentExportArtifactId"
|
||||
:disabled="!canHandle"
|
||||
:disabled="!resolvedActionsExecutable"
|
||||
@success="afterSuccess"
|
||||
/>
|
||||
<ShippingCustomerConfirmDialog
|
||||
|
||||
@@ -2981,6 +2981,13 @@
|
||||
"scriptNotice": "Detected scripts will not be executed",
|
||||
"loading": "Loading XFA collections...",
|
||||
"loadFailed": "Failed to load XFA collections",
|
||||
"loadErrorTitle": "Unable to load XFA data source",
|
||||
"loadErrorHint": "This usually means structure analysis is not ready or identity is invalid — not that the sample has no collections.",
|
||||
"reload": "Reload",
|
||||
"reparseSample": "Re-parse sample",
|
||||
"reparseConfirm": "This will re-queue layout and XFA structure analysis for the sample. Continue?",
|
||||
"reparseStarted": "Re-parse submitted. Reload after it finishes.",
|
||||
"reparseFailed": "Failed to submit re-parse",
|
||||
"noCollections": "No line collection candidates found in this sample"
|
||||
},
|
||||
"xfaSource": {
|
||||
@@ -3814,7 +3821,58 @@
|
||||
"lineAmount": "Line amount formula",
|
||||
"totalAmount": "Header total policy"
|
||||
},
|
||||
"previewHint": "Full dry-run extraction and amount identities are shown on the Validate page."
|
||||
"previewHint": "Full dry-run extraction and amount identities are shown on the Validate page.",
|
||||
"previewMode": {
|
||||
"label": "Preview status",
|
||||
"original": "Original PDF",
|
||||
"synthetic": "Synthetic preview",
|
||||
"statusReady": "Synthetic preview ready ({pages} pages)",
|
||||
"statusLoading": "Generating synthetic preview…",
|
||||
"statusUnavailable": "Synthetic preview unavailable",
|
||||
"statusFailed": "Synthetic preview failed",
|
||||
"statusStale": "Synthetic preview is stale; regenerate",
|
||||
"requestFailed": "Failed to request synthetic preview"
|
||||
},
|
||||
"staticPreviewBanner": "Canvas source is the offline full-flatten effective page only; original PDF is never offered.",
|
||||
"datasetsColumn": "XFA datasets",
|
||||
"collectionMeta": "Authoritative: {authoritative} · mirrors {mirrors}",
|
||||
"syntheticNeedsReviewTitle": "Synthetic preview unavailable (needs_review)",
|
||||
"syntheticNeedsReviewBody": "Synthetic preview unavailable (diagnostics only). Use the native PDF canvas for annotation.",
|
||||
"flattenLoading": "Loading preview…",
|
||||
"retrySynthetic": "Retry canvas preview",
|
||||
"pageUnavailable": "This page preview is unavailable. Retry or switch pages to continue.",
|
||||
"viewOriginalReference": "View original PDF reference (deprecated)",
|
||||
"originalNotFormalEvidence": "Deprecated: original PDF entry is never offered.",
|
||||
"retryCanvas": "Retry canvas preview"
|
||||
},
|
||||
"xfaDesk": {
|
||||
"tableSettingsHint": "Does not affect formal XFA datasets values",
|
||||
"readingMode": "Formal reading mode",
|
||||
"readingModes": {
|
||||
"xfa_dataset": "XFA datasets",
|
||||
"pdf_coordinate": "Right of label / coordinates",
|
||||
"ocr_coordinate": "OCR recognition"
|
||||
},
|
||||
"readingModeWarning": "Confirm the formal value source for this field is configured correctly",
|
||||
"datasourceField": "Data source field",
|
||||
"splitRuleField": "Split rules",
|
||||
"datasetsPath": "Datasets path",
|
||||
"pickDatasetsPath": "Pick datasets path",
|
||||
"datasetsSampleValue": "Datasets sample value",
|
||||
"previewStatusTitle": "Preview & OCR status",
|
||||
"ocrStatus": "OCR auto-mark: {status}",
|
||||
"reconfirmCollections": "Reconfirm collections",
|
||||
"reconfirmCollectionsTitle": "Reconfirm line collections",
|
||||
"reconfirmCollectionsHint": "After updating authoritative/mirror collections, confirmed visual bindings become suggested and must be reconfirmed on the native PDF canvas.",
|
||||
"reconfirmCollectionsConfirm": "Confirm and demote visual bindings",
|
||||
"collectionsReconfirmedHint": "Collections updated; confirmed visual boxes were demoted to suggested. Please reconfirm.",
|
||||
"datasetsOverlayToggle": "Show datasets assist values",
|
||||
"datasetsOverlayHint": "Assistive modeling only — not Acrobat/flatten appearance",
|
||||
"blankStructureWarning": "No visual structure or no confirmed boxes yet: structured mapping only is allowed; OCR/coordinate fields still need visible page evidence",
|
||||
"confirmWithoutDatasetsOverlay": "Confirming without datasets assist sample values shown",
|
||||
"sampleDisplayOption": "Sample value display (datasets assist)",
|
||||
"sampleDisplayHint": "On by default; assistive modeling only — not Acrobat/flatten appearance",
|
||||
"datasourceSummary": "Datasource summary"
|
||||
},
|
||||
"xfaUnified": {
|
||||
"drawFieldBox": "Draw field box",
|
||||
@@ -3826,6 +3884,7 @@
|
||||
"rejectVisual": "Reject visual box",
|
||||
"confirmSuccess": "Visual binding confirmed",
|
||||
"confirmFailed": "Failed to confirm visual binding",
|
||||
"confirmRequiresSyntheticPreview": "Load the native PDF preview before confirming a visual binding",
|
||||
"rejectSuccess": "Visual binding rejected",
|
||||
"rejectFailed": "Failed to reject visual binding",
|
||||
"diagnosticsSummary": "Required coverage {mapped}/{total}",
|
||||
@@ -3836,10 +3895,40 @@
|
||||
"confirmed": "Confirmed",
|
||||
"rejected": "Rejected",
|
||||
"needs_review": "Needs review"
|
||||
}
|
||||
},
|
||||
"confirmRequiresNativePreview": "Load the native PDF preview before confirming a visual binding"
|
||||
},
|
||||
"xfaAutoMark": {
|
||||
"title": "Auto-mark suggestions",
|
||||
"count": "{count} items",
|
||||
"hint": "OCR / Widget suggestions are assistive only; formal values still come from XFA datasets. Accept / Adjust / Reject will be wired later.",
|
||||
"empty": "No auto-mark suggestions yet",
|
||||
"accept": "Accept",
|
||||
"adjust": "Adjust",
|
||||
"reject": "Reject",
|
||||
"actionsDisabled": "Auto-mark actions are not wired yet",
|
||||
"originWidget": "Widget/template",
|
||||
"originOcr": "OCR",
|
||||
"originUnknown": "Unknown source",
|
||||
"confidence": "Confidence {value}%",
|
||||
"running": "OCR running…",
|
||||
"runFull": "Run full OCR",
|
||||
"retry": "Retry",
|
||||
"enqueueFailed": "Failed to enqueue auto-mark",
|
||||
"jobFailed": "Auto-mark job failed",
|
||||
"acceptSuccess": "Suggestion accepted",
|
||||
"acceptFailed": "Failed to accept suggestion",
|
||||
"rejectSuccess": "Suggestion rejected",
|
||||
"rejectFailed": "Failed to reject suggestion",
|
||||
"adjustHint": "Adjust the box on the native PDF canvas, then confirm"
|
||||
},
|
||||
"xfaSplit": {
|
||||
"title": "Field split rules",
|
||||
"summaryTitle": "Split rules summary",
|
||||
"summaryCounts": "{total} rules · {confirmed} confirmed",
|
||||
"summaryBlockers": "{count} mapping blockers",
|
||||
"editRules": "Edit split rules",
|
||||
"openFullPanel": "Open full split panel",
|
||||
"openPanel": "Split rules",
|
||||
"expand": "Expand",
|
||||
"collapse": "Collapse",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"shippingOrderExtractionHandling": {
|
||||
"title": "Action required",
|
||||
"count": "{count} item(s)",
|
||||
"summaryLine": "{title} · {count} item(s)",
|
||||
"reasonPrefix": "Reasons: ",
|
||||
"affectedPrefix": "Affected: ",
|
||||
"category": {
|
||||
@@ -1428,6 +1429,9 @@
|
||||
"loading": "Loading review results...",
|
||||
"unavailable": "Review results are unavailable. Please try again later.",
|
||||
"retryLoad": "Retry loading",
|
||||
"caseSwitchLoading": "Loading current PDF…",
|
||||
"caseSwitchFailed": "Failed to load this PDF. You can retry.",
|
||||
"caseSwitchRetry": "Retry",
|
||||
"documentNavigation": "PDF navigation",
|
||||
"documents": "PDF documents",
|
||||
"unnamedDocument": "Unnamed PDF",
|
||||
@@ -1537,6 +1541,8 @@
|
||||
"formal_task": "Formal task"
|
||||
},
|
||||
"formalEditTarget": "Current edit target: formal task",
|
||||
"actionSuccess": "Action completed",
|
||||
"resultNotReady": "Processing result is not ready yet",
|
||||
"enterInventory": "View inventory issues",
|
||||
"returnStandard": "Back to standard review",
|
||||
"openPdf": "Open PDF",
|
||||
@@ -1767,6 +1773,10 @@
|
||||
"viewTask": "Back to chat to view progress",
|
||||
"returnToChat": "Back to chat to view progress",
|
||||
"returnedFocusHint": "Back in chat, focused on task {taskNo} (see In progress on the right)",
|
||||
"retry": "Retry auto-progress",
|
||||
"retryStp": "Retry auto-progress",
|
||||
"retrySuccess": "Auto-progress re-queued",
|
||||
"retryStpSuccess": "Auto-create re-queued",
|
||||
"status": {
|
||||
"ok": "Current automatic steps completed",
|
||||
"running": "Processing",
|
||||
@@ -2142,7 +2152,9 @@
|
||||
"blockReason": "Reason to address",
|
||||
"manualReason": "Manual reason",
|
||||
"confirmBlocked": "Build eligibility is not satisfied. Resolve inventory or validation issues before confirming.",
|
||||
"autoGateProgressHint": "Auto-create eligibility is met — the system will create and progress the order without manual confirm.",
|
||||
"autoGateProgressHint": "Auto-create eligibility is met — waiting for the system to start.",
|
||||
"autoGateWaitingHint": "Auto-create eligibility is met — waiting for the system to start.",
|
||||
"autoGateRunningHint": "The system is creating the order and progressing automatically.",
|
||||
"layers": {
|
||||
"gate": "Process gates",
|
||||
"gatePass": "No blocking gates",
|
||||
@@ -2281,12 +2293,16 @@
|
||||
"failed": "Cancellation request failed. Please try again."
|
||||
},
|
||||
"shippingProcessing": {
|
||||
"panelTitle": "Shipping processing",
|
||||
"panelTitle": "Processing in this conversation",
|
||||
"pendingMaterials": "Pending materials",
|
||||
"orderTasks": "Order tasks",
|
||||
"groupNeedsAction": "Needs your action · {count}",
|
||||
"groupProcessing": "Processing · {count}",
|
||||
"groupNeedsAction": "Needs your action · {count} tasks",
|
||||
"groupProcessing": "System processing · {count} tasks",
|
||||
"groupCompleted": "Completed · {count}",
|
||||
"groupProcessingRecords": "Processing records · {count}",
|
||||
"groupRecordCompleted": "Completed",
|
||||
"groupRecordHistoryVersions": "History versions",
|
||||
"groupRecordCancelled": "Cancelled",
|
||||
"taskTitle": "{label}",
|
||||
"justAppended": "Just added {count} attachment(s)",
|
||||
"justCreated": "Just created · from this send",
|
||||
@@ -2356,7 +2372,11 @@
|
||||
"domainFulfillmentShip": "Fulfillment",
|
||||
"currentNeedLabel": "Current need: ",
|
||||
"systemProcessingNeed": "The system is processing automatically. Wait or refresh progress.",
|
||||
"progressTitleWithStage": "Order processing · {stage}",
|
||||
"systemProcessingWithStage": "System processing · {stage}",
|
||||
"viewProcessDetails": "View process details",
|
||||
"viewFullProcess": "View full process",
|
||||
"stageNodesUnavailable": "Progress details are temporarily unavailable",
|
||||
"closeProcessDetails": "Close process details",
|
||||
"processDetailsTitle": "Process details",
|
||||
"nodeTime": "Time",
|
||||
@@ -2388,6 +2408,10 @@
|
||||
"open_order_review": "Open order processing",
|
||||
"open_order_processing": "Open order processing",
|
||||
"edit_formal_task": "Edit formal task",
|
||||
"open_profile_review": "View profile match",
|
||||
"confirm_customer": "Confirm customer",
|
||||
"resolve_field_conflicts": "Resolve field conflicts",
|
||||
"adjudicate_duplicate": "Adjudicate duplicate",
|
||||
"open_inventory_source_review": "Review inventory source",
|
||||
"open_inventory_match_review": "Review inventory match",
|
||||
"open_shortage_review": "Handle shortage",
|
||||
@@ -2399,13 +2423,26 @@
|
||||
"open_manual_upload": "Manual upload",
|
||||
"view_result": "View result",
|
||||
"view_record": "View record",
|
||||
"view_progress": "View progress",
|
||||
"retry_parse": "Retry parsing",
|
||||
"more": "More"
|
||||
},
|
||||
"title": "In progress",
|
||||
"summaryLine": "{total} files · {processing} processing · {needsAction} need action · {completed} completed",
|
||||
"summaryTasksAndFiles": "{tasks} tasks · {files} files",
|
||||
"summaryLineDetail": "{needsAction} tasks need action · {processing} tasks processing",
|
||||
"summaryTruncatedHint": "List truncated; showing recent tasks only",
|
||||
"historyMoreCount": "{count} more",
|
||||
"historyTruncatedDetail": "Showing the latest {shown}, {hidden} more not shown",
|
||||
"systemProcessing": "System processing",
|
||||
"primaryFile": "Primary file: {name}",
|
||||
"continueProcessing": "Continue",
|
||||
"fileCountUnavailable": "File count unavailable",
|
||||
"panelPinnedHint": "Active tasks keep this panel open; you can still collapse file details",
|
||||
"panelPinnedLabel": "Pinned",
|
||||
"groupHistory": "History · {count}",
|
||||
"groupHistoryRecords": "Past versions · {count}",
|
||||
"groupCancelled": "Cancelled · {count}",
|
||||
"expandHistory": "Expand",
|
||||
"collapseHistory": "Collapse",
|
||||
"taskFiles": "{count} files",
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
"SHIPPING_NOTICE.AUDIT_PERSIST_FAILED": "Failed to persist the audit record. The operation was not completed. Please retry.",
|
||||
"SHIPPING_NOTICE.AUDIT_METADATA_FORBIDDEN": "Audit write contains forbidden sensitive fields.",
|
||||
"SHIPPING_NOTICE.AUDIT_SNAPSHOT_FORBIDDEN": "Audit snapshot contains forbidden sensitive fields.",
|
||||
"SHIPPING_PROCESSING_PROJECTION_INCONSISTENT": "Order progress is inconsistent; fulfillment actions were blocked. Refresh and try again.",
|
||||
"SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH": "The formal task does not match the current processing context. Refresh and try again.",
|
||||
"SHIPPING_ORDER_SCHEMA_NOT_FOUND": "The order template has not been initialized.",
|
||||
"SHIPPING_ORDER_SCHEMA_EXISTS": "The order template already exists.",
|
||||
"SHIPPING_ORDER_SCHEMA_DRAFT_EXISTS": "An order template draft already exists. Complete or publish it first.",
|
||||
@@ -467,9 +469,27 @@
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_EDIT_FORBIDDEN": "You do not have permission to edit XFA split rules.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_TOKEN_INVALID": "The split-rule preview confirmation token is invalid, expired, or does not match the current rules.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_REJECTED": "Split rule confirmation was rejected: the preview token is missing, invalid, already used, or the sample content has changed.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_STORE_UNAVAILABLE": "Confirmation service is temporarily unavailable. Please retry later; contact operations if it persists.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_UNAVAILABLE": "XFA structure analysis is not ready or incomplete. Re-parse the sample and retry.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_MISSING": "No usable XFA structure analysis is bound to the current layout. Re-parse the sample and retry.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_IDENTITY_MISMATCH": "XFA structure analysis identity does not match the current document or layout. The operation was blocked.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_STALE": "XFA structure analysis is stale relative to the current sample content. Re-parse the sample and retry.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_STALE": "The XFA synthetic preview is stale relative to the frozen structure identity. Regenerate the preview before confirming.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_FAILED": "XFA synthetic preview generation failed. Check the sample or retry later.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_UNAVAILABLE": "XFA synthetic preview is unavailable. Generate a preview first or re-parse the sample.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_CONFIRM_REQUIRES_SYNTHETIC_PREVIEW": "Confirming a visual binding requires a synthetic preview. Generate the preview and include its checksum before confirming.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_PAGE_INCONSISTENT": "XFA synthetic preview page count or page boxes do not match the frozen sample. The operation was blocked.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_VALUE_MISMATCH": "XFA synthetic preview echo does not match frozen datasets. The operation was blocked.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_LEGACY_MAPPINGS_FORBIDDEN": "XFA profiles must use unified bindings; legacy header_mappings / line_mapping.fields require migration first.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_OCR_UNAVAILABLE": "XFA synthetic-preview OCR is unavailable. Check the OCR engine deployment and retry; plain PDF paths are unaffected.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SYNTHETIC_PREVIEW_GATE": "XFA synthetic preview publish gate failed: preview not ready, missing checksum, or unconfirmed visual bindings.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_PREVIEW_STALE": "The layout result changed. Refresh the sample and preview it again.",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "The layout result is still being prepared. Refresh the status shortly."
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "The layout result is still being prepared. Refresh the status shortly.",
|
||||
"SHIPPING.STP_RETRY_ALREADY_CONFIRMED": "This review case is already confirmed. Retry post-confirm auto-progress instead.",
|
||||
"SHIPPING.STP_ENQUEUE_FAILED": "Failed to enqueue auto-create. Please retry later or contact an administrator.",
|
||||
"SHIPPING.STP_NOT_ELIGIBLE": "This order is not yet eligible for auto-create. Complete checks and gates, then retry.",
|
||||
"SHIPPING.STP_CASE_NO_REQUIRED": "Review case number is required for auto-create.",
|
||||
"SHIPPING.STP_AUTO_CREATE_FAILED": "Auto-create execution failed. Retry or confirm manually."
|
||||
},
|
||||
"SHIPPING.REVIEW_INVENTORY_SOURCE_UNRESOLVED": "Inventory source is not uniquely resolved. Complete inventory-source review before creating a formal order.",
|
||||
"SHIPPING_REVIEW_INVENTORY_SOURCE_UNRESOLVED": "Inventory source is not uniquely resolved. Complete inventory-source review before creating a formal order."
|
||||
|
||||
@@ -236,6 +236,7 @@
|
||||
"continueAction": "Continue",
|
||||
"actionSubmitted": "Action submitted",
|
||||
"submitting": "Submitting…",
|
||||
"readOnlyUseFooter": "Use the footer action bar to proceed",
|
||||
"actionCodes": {
|
||||
"retry_with_latest_rules": "Retry with latest rules",
|
||||
"open_inventory_source_review": "Open inventory source review",
|
||||
|
||||
@@ -2849,6 +2849,13 @@
|
||||
"scriptNotice": "ตรวจพบสคริปต์แต่จะไม่รัน",
|
||||
"loading": "กำลังโหลดชุด XFA…",
|
||||
"loadFailed": "โหลดชุด XFA ไม่สำเร็จ",
|
||||
"loadErrorTitle": "โหลดแหล่งข้อมูล XFA ไม่ได้",
|
||||
"loadErrorHint": "มักหมายถึงการวิเคราะห์โครงสร้างยังไม่พร้อมหรือตัวตนผิดปกติ ไม่ใช่ว่าตัวอย่างไม่มีชุดข้อมูล",
|
||||
"reload": "โหลดใหม่",
|
||||
"reparseSample": "แยกวิเคราะห์ตัวอย่างใหม่",
|
||||
"reparseConfirm": "ระบบจะจัดคิววิเคราะห์เลย์เอาต์และโครงสร้าง XFA ของตัวอย่างใหม่ ดำเนินการต่อหรือไม่?",
|
||||
"reparseStarted": "ส่งคำขอแยกวิเคราะห์แล้ว กรุณาโหลดใหม่ภายหลัง",
|
||||
"reparseFailed": "ส่งคำขอแยกวิเคราะห์ไม่สำเร็จ",
|
||||
"noCollections": "ตัวอย่างนี้ไม่มีชุดบรรทัดที่ใช้งานได้"
|
||||
},
|
||||
"xfaSource": {
|
||||
@@ -3682,7 +3689,58 @@
|
||||
"lineAmount": "สูตรยอดบรรทัด",
|
||||
"totalAmount": "นโยบายยอดหัว"
|
||||
},
|
||||
"previewHint": "ผลการสกัดแบบ dry-run และสมการยอดดูได้ที่หน้า Validate"
|
||||
"previewHint": "ผลการสกัดแบบ dry-run และสมการยอดดูได้ที่หน้า Validate",
|
||||
"previewMode": {
|
||||
"label": "สถานะตัวอย่าง",
|
||||
"original": "PDF ต้นฉบับ",
|
||||
"synthetic": "ตัวอย่างสังเคราะห์",
|
||||
"statusReady": "ตัวอย่างสังเคราะห์พร้อมแล้ว ({pages} หน้า)",
|
||||
"statusLoading": "กำลังสร้างตัวอย่างสังเคราะห์…",
|
||||
"statusUnavailable": "ตัวอย่างสังเคราะห์ไม่พร้อมใช้งาน",
|
||||
"statusFailed": "สร้างตัวอย่างสังเคราะห์ล้มเหลว",
|
||||
"statusStale": "ตัวอย่างสังเคราะห์ล้าสมัย กรุณาสร้างใหม่",
|
||||
"requestFailed": "ร้องขอตัวอย่างสังเคราะห์ล้มเหลว"
|
||||
},
|
||||
"staticPreviewBanner": "แหล่งภาพเดียวคือหน้า flatten ออฟไลน์เต็มรูปแบบ ไม่มี PDF ต้นฉบับ",
|
||||
"datasetsColumn": "ชุดข้อมูล XFA",
|
||||
"collectionMeta": "ชุดหลัก: {authoritative} · กระจก {mirrors}",
|
||||
"syntheticNeedsReviewTitle": "ตัวอย่างสังเคราะห์ไม่พร้อม (needs_review)",
|
||||
"syntheticNeedsReviewBody": "ตัวอย่างสังเคราะห์ใช้ไม่ได้ (เพื่อวินิจฉัยเท่านั้น) ใช้แคนวาส PDF ดั้งเดิมสำหรับทำเครื่องหมาย",
|
||||
"flattenLoading": "กำลังโหลดตัวอย่าง…",
|
||||
"retrySynthetic": "ลองโหลดแคนวาสอีกครั้ง",
|
||||
"pageUnavailable": "ตัวอย่างหน้านี้ใช้ไม่ได้ ลองใหม่หรือเปลี่ยนหน้าเพื่อทำต่อ",
|
||||
"viewOriginalReference": "ดู PDF ต้นฉบับเพื่ออ้างอิง (เลิกใช้)",
|
||||
"originalNotFormalEvidence": "เลิกใช้แล้ว: ไม่มีทางเข้า PDF ต้นฉบับ",
|
||||
"retryCanvas": "ลองโหลดแคนวาสอีกครั้ง"
|
||||
},
|
||||
"xfaDesk": {
|
||||
"tableSettingsHint": "ไม่กระทบค่าอย่างเป็นทางการจาก XFA datasets",
|
||||
"readingMode": "โหมดอ่านค่าอย่างเป็นทางการ",
|
||||
"readingModes": {
|
||||
"xfa_dataset": "XFA datasets",
|
||||
"pdf_coordinate": "ด้านขวาของป้าย / พิกัด",
|
||||
"ocr_coordinate": "การรู้จำ OCR"
|
||||
},
|
||||
"readingModeWarning": "โปรดยืนยันว่าแหล่งค่าอย่างเป็นทางการของฟิลด์นี้ถูกตั้งค่าถูกต้อง",
|
||||
"datasourceField": "ฟิลด์แหล่งข้อมูล",
|
||||
"splitRuleField": "กฎการแยก",
|
||||
"datasetsPath": "พาธ Datasets",
|
||||
"pickDatasetsPath": "เลือกพาธ datasets",
|
||||
"datasetsSampleValue": "ค่าตัวอย่าง Datasets",
|
||||
"previewStatusTitle": "สถานะตัวอย่างและ OCR",
|
||||
"ocrStatus": "OCR ทำเครื่องหมายอัตโนมัติ: {status}",
|
||||
"reconfirmCollections": "ยืนยันชุดข้อมูลอีกครั้ง",
|
||||
"reconfirmCollectionsTitle": "ยืนยันชุดบรรทัดอีกครั้ง",
|
||||
"reconfirmCollectionsHint": "หลังอัปเดตคอลเลกชันหลัก/กระจก การผูกภาพที่ยืนยันแล้วจะกลายเป็น suggested และต้องยืนยันใหม่บนแคนวาส PDF ดั้งเดิม",
|
||||
"reconfirmCollectionsConfirm": "ยืนยันและลดระดับการผูกภาพ",
|
||||
"collectionsReconfirmedHint": "อัปเดตชุดแล้ว; กรอบภาพที่ยืนยันแล้วถูกลดเป็น suggested กรุณายืนยันใหม่",
|
||||
"datasetsOverlayToggle": "แสดงค่าช่วย datasets",
|
||||
"datasetsOverlayHint": "ใช้ช่วยสร้างโมเดลเท่านั้น ไม่ใช่ลักษณะ Acrobat/flatten",
|
||||
"blankStructureWarning": "ไม่มีโครงที่มองเห็นหรือยังไม่ได้ยืนยันกรอบภาพ: อนุญาตเฉพาะการแมปโครงสร้าง; ฟิลด์ OCR/พิกัดยังต้องมีหลักฐานหน้ามองเห็นได้",
|
||||
"confirmWithoutDatasetsOverlay": "กำลังยืนยันโดยไม่ได้แสดงค่าตัวอย่าง datasets",
|
||||
"sampleDisplayOption": "แสดงค่าตัวอย่าง (ช่วย datasets)",
|
||||
"sampleDisplayHint": "เปิดเป็นค่าเริ่มต้น ใช้ช่วยสร้างโมเดลเท่านั้น ไม่ใช่ลักษณะ Acrobat/flatten",
|
||||
"datasourceSummary": "สรุปแหล่งข้อมูล"
|
||||
},
|
||||
"xfaUnified": {
|
||||
"drawFieldBox": "วาดกรอบฟิลด์",
|
||||
@@ -3694,6 +3752,7 @@
|
||||
"rejectVisual": "ปฏิเสธกรอบภาพ",
|
||||
"confirmSuccess": "ยืนยันการผูกภาพแล้ว",
|
||||
"confirmFailed": "ยืนยันการผูกภาพล้มเหลว",
|
||||
"confirmRequiresSyntheticPreview": "โหลดตัวอย่าง PDF ดั้งเดิมก่อนยืนยันการผูกภาพ",
|
||||
"rejectSuccess": "ปฏิเสธการผูกภาพแล้ว",
|
||||
"rejectFailed": "ปฏิเสธการผูกภาพล้มเหลว",
|
||||
"diagnosticsSummary": "ความครอบคลุมที่จำเป็น {mapped}/{total}",
|
||||
@@ -3704,10 +3763,40 @@
|
||||
"confirmed": "ยืนยันแล้ว",
|
||||
"rejected": "ปฏิเสธแล้ว",
|
||||
"needs_review": "ต้องตรวจ"
|
||||
}
|
||||
},
|
||||
"confirmRequiresNativePreview": "โหลดตัวอย่าง PDF ดั้งเดิมก่อนยืนยันการผูกภาพ"
|
||||
},
|
||||
"xfaAutoMark": {
|
||||
"title": "คำแนะนำทำเครื่องหมายอัตโนมัติ",
|
||||
"count": "{count} รายการ",
|
||||
"hint": "คำแนะนำ OCR/Widget เป็นเพียงตัวช่วย ค่าทางการมาจาก XFA datasets เท่านั้น high ยอมรับเป็น confirmed ได้ medium/low ต้องยืนยันบนแคนวาส mismatch ห้ามยืนยัน",
|
||||
"empty": "ยังไม่มีคำแนะนำทำเครื่องหมายอัตโนมัติ",
|
||||
"accept": "ยอมรับ",
|
||||
"adjust": "ปรับ",
|
||||
"reject": "ปฏิเสธ",
|
||||
"actionsDisabled": "ยังไม่ได้เชื่อมการทำงานทำเครื่องหมายอัตโนมัติ",
|
||||
"originWidget": "Widget/เทมเพลต",
|
||||
"originOcr": "OCR",
|
||||
"originUnknown": "ไม่ทราบแหล่งที่มา",
|
||||
"confidence": "ความมั่นใจ {value}%",
|
||||
"running": "กำลังรัน OCR…",
|
||||
"runFull": "รัน OCR ทั้งหมด",
|
||||
"retry": "ลองใหม่",
|
||||
"enqueueFailed": "เข้าคิวทำเครื่องหมายอัตโนมัติล้มเหลว",
|
||||
"jobFailed": "งานทำเครื่องหมายอัตโนมัติล้มเหลว",
|
||||
"acceptSuccess": "ยอมรับคำแนะนำแล้ว",
|
||||
"acceptFailed": "ยอมรับคำแนะนำล้มเหลว",
|
||||
"rejectSuccess": "ปฏิเสธคำแนะนำแล้ว",
|
||||
"rejectFailed": "ปฏิเสธคำแนะนำล้มเหลว",
|
||||
"adjustHint": "ปรับกรอบบนแคนวาส PDF ดั้งเดิมแล้วค่อยยืนยัน"
|
||||
},
|
||||
"xfaSplit": {
|
||||
"title": "กฎการแยกฟิลด์",
|
||||
"summaryTitle": "สรุปกฎแยกฟิลด์",
|
||||
"summaryCounts": "กฎ {total} · ยืนยันแล้ว {confirmed}",
|
||||
"summaryBlockers": "ตัวบล็อกการแมป {count}",
|
||||
"editRules": "แก้ไขกฎการแยก",
|
||||
"openFullPanel": "เปิดแผงแยกฟิลด์แบบเต็ม",
|
||||
"openPanel": "กฎการแยก",
|
||||
"expand": "ขยาย",
|
||||
"collapse": "ย่อ",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"shippingOrderExtractionHandling": {
|
||||
"title": "รายการที่ต้องจัดการ",
|
||||
"count": "{count} รายการ",
|
||||
"summaryLine": "{title} · {count} รายการ",
|
||||
"reasonPrefix": "สาเหตุ: ",
|
||||
"affectedPrefix": "วัตถุที่ได้รับผล: ",
|
||||
"category": {
|
||||
@@ -1428,6 +1429,9 @@
|
||||
"loading": "กำลังโหลดผลการตรวจทาน...",
|
||||
"unavailable": "ยังโหลดผลการตรวจทานไม่ได้ โปรดลองอีกครั้งภายหลัง",
|
||||
"retryLoad": "ลองโหลดอีกครั้ง",
|
||||
"caseSwitchLoading": "กำลังโหลด PDF ปัจจุบัน…",
|
||||
"caseSwitchFailed": "โหลด PDF ปัจจุบันไม่สำเร็จ สามารถลองใหม่ได้",
|
||||
"caseSwitchRetry": "ลองใหม่",
|
||||
"documentNavigation": "รายการ PDF",
|
||||
"documents": "ไฟล์ PDF",
|
||||
"unnamedDocument": "PDF ไม่มีชื่อ",
|
||||
@@ -1537,6 +1541,8 @@
|
||||
"formal_task": "งานอย่างเป็นทางการ"
|
||||
},
|
||||
"formalEditTarget": "วัตถุที่กำลังแก้ไข: งานอย่างเป็นทางการ",
|
||||
"actionSuccess": "ดำเนินการสำเร็จ",
|
||||
"resultNotReady": "ยังไม่สร้างผลการประมวลผล",
|
||||
"enterInventory": "ดูปัญหาสต็อก",
|
||||
"returnStandard": "กลับสู่การตรวจมาตรฐาน",
|
||||
"openPdf": "เปิด PDF",
|
||||
@@ -1767,6 +1773,10 @@
|
||||
"viewTask": "กลับไปแชทเพื่อดูความคืบหน้า",
|
||||
"returnToChat": "กลับไปแชทเพื่อดูความคืบหน้า",
|
||||
"returnedFocusHint": "กลับสู่แชทแล้ว และโฟกัสงาน {taskNo} (ดูที่แถบด้านขวา)",
|
||||
"retry": "ลองดำเนินการอัตโนมัติอีกครั้ง",
|
||||
"retryStp": "ลองดำเนินการอัตโนมัติอีกครั้ง",
|
||||
"retrySuccess": "จัดคิวดำเนินการอัตโนมัติใหม่แล้ว",
|
||||
"retryStpSuccess": "จัดคิวสร้างออเดอร์อัตโนมัติใหม่แล้ว",
|
||||
"status": {
|
||||
"ok": "ดำเนินขั้นตอนอัตโนมัติที่ทำได้เสร็จแล้ว",
|
||||
"running": "กำลังประมวลผล",
|
||||
@@ -2142,7 +2152,9 @@
|
||||
"blockReason": "เหตุผลที่ต้องดำเนินการ",
|
||||
"manualReason": "เหตุผลด้วยตนเอง",
|
||||
"confirmBlocked": "ร่างยังไม่ผ่านคุณสมบัติการสร้างคำสั่ง โปรดแก้ปัญหาแหล่งสต็อกหรือการตรวจสอบก่อนยืนยัน",
|
||||
"autoGateProgressHint": "ผ่านคุณสมบัติสร้างอัตโนมัติแล้ว — ระบบจะสร้างและดำเนินการต่อโดยไม่ต้องยืนยันด้วยตนเอง",
|
||||
"autoGateProgressHint": "ผ่านคุณสมบัติสร้างอัตโนมัติแล้ว — รอระบบเริ่มทำงาน",
|
||||
"autoGateWaitingHint": "ผ่านคุณสมบัติสร้างอัตโนมัติแล้ว — รอระบบเริ่มทำงาน",
|
||||
"autoGateRunningHint": "ระบบกำลังสร้างออเดอร์และดำเนินการต่อโดยอัตโนมัติ",
|
||||
"layers": {
|
||||
"gate": "Process gates",
|
||||
"gatePass": "ไม่มี gate ที่บล็อก",
|
||||
@@ -2281,12 +2293,16 @@
|
||||
"failed": "คำขอยกเลิกล้มเหลว โปรดลองใหม่ภายหลัง"
|
||||
},
|
||||
"shippingProcessing": {
|
||||
"panelTitle": "การประมวลผลขนส่ง",
|
||||
"panelTitle": "กำลังประมวลผลในการสนทนานี้",
|
||||
"pendingMaterials": "เอกสารรอดำเนินการ",
|
||||
"orderTasks": "งานคำสั่งซื้อ",
|
||||
"groupNeedsAction": "ต้องดำเนินการ · {count}",
|
||||
"groupProcessing": "กำลังประมวลผล · {count}",
|
||||
"groupNeedsAction": "ต้องดำเนินการ · {count} งาน",
|
||||
"groupProcessing": "ระบบกำลังประมวลผล · {count} งาน",
|
||||
"groupCompleted": "เสร็จสิ้น · {count}",
|
||||
"groupProcessingRecords": "ประวัติการประมวลผล · {count}",
|
||||
"groupRecordCompleted": "เสร็จสิ้น",
|
||||
"groupRecordHistoryVersions": "เวอร์ชันก่อนหน้า",
|
||||
"groupRecordCancelled": "ยกเลิกแล้ว",
|
||||
"taskTitle": "{label}",
|
||||
"justAppended": "เพิ่งเพิ่มไฟล์แนบ {count} รายการ",
|
||||
"justCreated": "เพิ่งสร้าง · จากข้อความนี้",
|
||||
@@ -2356,7 +2372,11 @@
|
||||
"domainFulfillmentShip": "จัดส่ง",
|
||||
"currentNeedLabel": "ความต้องการปัจจุบัน: ",
|
||||
"systemProcessingNeed": "ระบบกำลังประมวลผลอัตโนมัติ รอสักครู่หรือรีเฟรชความคืบหน้า",
|
||||
"progressTitleWithStage": "ความคืบหน้าการประมวลผลคำสั่ง · {stage}",
|
||||
"systemProcessingWithStage": "ระบบกำลังประมวลผล · {stage}",
|
||||
"viewProcessDetails": "ดูรายละเอียดกระบวนการ",
|
||||
"viewFullProcess": "ดูกระบวนการทั้งหมด",
|
||||
"stageNodesUnavailable": "รายละเอียดความคืบหน้ายังไม่พร้อมใช้งาน",
|
||||
"closeProcessDetails": "ปิดรายละเอียดกระบวนการ",
|
||||
"processDetailsTitle": "รายละเอียดกระบวนการ",
|
||||
"nodeTime": "เวลา",
|
||||
@@ -2388,6 +2408,10 @@
|
||||
"open_order_review": "เปิดการประมวลผลคำสั่งซื้อ",
|
||||
"open_order_processing": "เปิดการประมวลผลคำสั่งซื้อ",
|
||||
"edit_formal_task": "แก้ไขงานทางการ",
|
||||
"open_profile_review": "ดูการจับคู่โปรไฟล์",
|
||||
"confirm_customer": "ยืนยันลูกค้า",
|
||||
"resolve_field_conflicts": "แก้ความขัดแย้งของฟิลด์",
|
||||
"adjudicate_duplicate": "ตัดสินคำสั่งซื้อซ้ำ",
|
||||
"open_inventory_source_review": "ตรวจทานแหล่งสินค้าคงคลัง",
|
||||
"open_inventory_match_review": "ตรวจทานการจับคู่สต็อก",
|
||||
"open_shortage_review": "จัดการสต็อกไม่พอ",
|
||||
@@ -2399,6 +2423,8 @@
|
||||
"open_manual_upload": "อัปโหลดด้วยตนเอง",
|
||||
"view_result": "ดูผลลัพธ์",
|
||||
"view_record": "ดูบันทึก",
|
||||
"view_progress": "ดูความคืบหน้า",
|
||||
"retry_parse": "ลองแยกวิเคราะห์อีกครั้ง",
|
||||
"more": "เพิ่มเติม"
|
||||
},
|
||||
"title": "กำลังดำเนินการ",
|
||||
@@ -2527,9 +2553,20 @@
|
||||
},
|
||||
"versionHistoryNote": "แสดงเวอร์ชันที่พร้อมใช้งานสำหรับไฟล์นี้",
|
||||
"summaryLine": "{total} ไฟล์ · กำลังทำ {processing} · ต้องดำเนินการ {needsAction} · เสร็จสิ้น {completed}",
|
||||
"summaryTasksAndFiles": "{tasks} งาน · {files} ไฟล์",
|
||||
"summaryLineDetail": "ต้องดำเนินการ {needsAction} งาน · ระบบกำลังประมวลผล {processing} งาน",
|
||||
"summaryTruncatedHint": "รายการถูกตัดทอน แสดงเฉพาะงานล่าสุด",
|
||||
"historyMoreCount": "อีก {count} รายการ",
|
||||
"historyTruncatedDetail": "แสดงล่าสุด {shown} รายการ และยังมีอีก {hidden} รายการที่ไม่ได้แสดง",
|
||||
"systemProcessing": "ระบบกำลังประมวลผล",
|
||||
"primaryFile": "ไฟล์หลัก: {name}",
|
||||
"continueProcessing": "ดำเนินการต่อ",
|
||||
"fileCountUnavailable": "ยังไม่มีจำนวนไฟล์",
|
||||
"panelPinnedHint": "มีงานที่กำลังทำหรือต้องดำเนินการ แผงนี้จะเปิดค้างไว้ คุณยังยุบรายละเอียดไฟล์ได้",
|
||||
"panelPinnedLabel": "เปิดค้าง",
|
||||
"groupHistory": "ประวัติ · {count}",
|
||||
"groupHistoryRecords": "เวอร์ชันก่อนหน้า · {count}",
|
||||
"groupCancelled": "ยกเลิกแล้ว · {count}",
|
||||
"expandHistory": "ขยาย",
|
||||
"collapseHistory": "ย่อ",
|
||||
"taskFiles": "{count} ไฟล์",
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
"SHIPPING_NOTICE.AUDIT_PERSIST_FAILED": "บันทึกการตรวจสอบล้มเหลว การดำเนินการยังไม่เสร็จสิ้น กรุณาลองใหม่",
|
||||
"SHIPPING_NOTICE.AUDIT_METADATA_FORBIDDEN": "การบันทึกตรวจสอบมีฟิลด์ที่ละเอียดอ่อนซึ่งห้ามใช้",
|
||||
"SHIPPING_NOTICE.AUDIT_SNAPSHOT_FORBIDDEN": "สแนปชอตการตรวจสอบมีฟิลด์ที่ละเอียดอ่อนซึ่งห้ามใช้",
|
||||
"SHIPPING_PROCESSING_PROJECTION_INCONSISTENT": "สถานะความคืบหน้าคำสั่งซื้อไม่สอดคล้องกัน การดำเนินการถูกบล็อก กรุณารีเฟรชแล้วลองใหม่",
|
||||
"SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH": "งานทางการไม่ตรงกับบริบทการประมวลผลปัจจุบัน การดำเนินการถูกบล็อก กรุณารีเฟรชแล้วลองใหม่",
|
||||
"SHIPPING_ORDER_SCHEMA_NOT_FOUND": "ยังไม่ได้เริ่มต้นเทมเพลตคำสั่งซื้อ",
|
||||
"SHIPPING_ORDER_SCHEMA_EXISTS": "มีเทมเพลตคำสั่งซื้ออยู่แล้ว",
|
||||
"SHIPPING_ORDER_SCHEMA_DRAFT_EXISTS": "มีฉบับร่างเทมเพลตคำสั่งซื้ออยู่แล้ว โปรดดำเนินการหรือเผยแพร่ฉบับปัจจุบันก่อน",
|
||||
@@ -467,9 +469,27 @@
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_EDIT_FORBIDDEN": "บัญชีนี้ไม่มีสิทธิ์แก้ไขกฎการแยกฟิลด์ XFA",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_TOKEN_INVALID": "โทเคนยืนยันตัวอย่างกฎการแยกไม่ถูกต้อง หมดอายุ หรือไม่ตรงกับกฎปัจจุบัน",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_REJECTED": "การยืนยันกฎการแยกถูกปฏิเสธ: โทเคนตัวอย่างหายไป ไม่ถูกต้อง ถูกใช้แล้ว หรือเนื้อหาตัวอย่างเปลี่ยนแปลง",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_STORE_UNAVAILABLE": "บริการยืนยันชั่วคราวไม่พร้อมใช้งาน กรุณาลองใหม่ภายหลัง หากยังล้มเหลวให้ติดต่อทีมปฏิบัติการ",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_UNAVAILABLE": "การวิเคราะห์โครงสร้าง XFA ยังไม่พร้อมหรือบันทึกไม่ครบ กรุณาแยกวิเคราะห์ตัวอย่างใหม่แล้วลองอีกครั้ง",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_MISSING": "เลย์เอาต์ปัจจุบันไม่ได้ผูกกับการวิเคราะห์โครงสร้าง XFA ที่ใช้ได้ กรุณาแยกวิเคราะห์ตัวอย่างใหม่แล้วลองอีกครั้ง",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_IDENTITY_MISMATCH": "ตัวตนการวิเคราะห์โครงสร้าง XFA ไม่ตรงกับเอกสารหรือเลย์เอาต์ปัจจุบัน การดำเนินการถูกบล็อก",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_STALE": "การวิเคราะห์โครงสร้าง XFA ล้าสมัยเมื่อเทียบกับเนื้อหาตัวอย่างปัจจุบัน กรุณาแยกวิเคราะห์ตัวอย่างใหม่แล้วลองอีกครั้ง",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_STALE": "ตัวอย่างสังเคราะห์ XFA ล้าสมัยเมื่อเทียบกับตัวตนโครงสร้างที่แช่แข็ง กรุณาสร้างตัวอย่างใหม่ก่อนยืนยัน",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_FAILED": "การสร้างตัวอย่างสังเคราะห์ XFA ล้มเหลว กรุณาตรวจสอบตัวอย่างหรือลองใหม่ภายหลัง",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_UNAVAILABLE": "ตัวอย่างสังเคราะห์ XFA ไม่พร้อมใช้งาน กรุณาสร้างตัวอย่างก่อนหรือแยกวิเคราะห์ตัวอย่างใหม่",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_CONFIRM_REQUIRES_SYNTHETIC_PREVIEW": "การยืนยัน visual binding ต้องทำบนตัวอย่างสังเคราะห์ กรุณาสร้างตัวอย่างและส่ง checksum ก่อนยืนยัน",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_PAGE_INCONSISTENT": "จำนวนหน้าหรือกรอบหน้าของตัวอย่างสังเคราะห์ XFA ไม่ตรงกับตัวอย่างที่แช่แข็ง การดำเนินการถูกบล็อก",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_VALUE_MISMATCH": "ข้อความที่แสดงในตัวอย่างสังเคราะห์ XFA ไม่ตรงกับ datasets ที่แช่แข็ง การดำเนินการถูกบล็อก",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_LEGACY_MAPPINGS_FORBIDDEN": "โปรไฟล์ XFA ต้องใช้ bindings แบบรวม ฟิลด์ header_mappings / line_mapping.fields แบบเดิมต้องย้ายก่อน",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_OCR_UNAVAILABLE": "OCR ของภาพตัวอย่างสังเคราะห์ XFA ไม่พร้อมใช้งาน โปรดตรวจสอบการติดตั้ง OCR แล้วลองใหม่ เส้นทาง PDF ธรรมดาไม่ได้รับผลกระทบ",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SYNTHETIC_PREVIEW_GATE": "เกตเผยแพร่ภาพตัวอย่างสังเคราะห์ XFA ไม่ผ่าน: ตัวอย่างยังไม่พร้อม ขาด checksum หรือยังไม่ได้ยืนยันการผูกภาพ",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_PREVIEW_STALE": "ผลเลย์เอาต์เปลี่ยนแปลงแล้ว โปรดรีเฟรชตัวอย่างและดูตัวอย่างอีกครั้ง",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "ผลเลย์เอาต์ยังอยู่ระหว่างการเตรียม โปรดรีเฟรชสถานะอีกครั้งในภายหลัง"
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "ผลเลย์เอาต์ยังอยู่ระหว่างการเตรียม โปรดรีเฟรชสถานะอีกครั้งในภายหลัง",
|
||||
"SHIPPING.STP_RETRY_ALREADY_CONFIRMED": "เคสตรวจทานนี้ยืนยันสร้างงานแล้ว กรุณารีทรายการผลักดันอัตโนมัติหลังยืนยันแทน",
|
||||
"SHIPPING.STP_ENQUEUE_FAILED": "จัดคิวสร้างออเดอร์อัตโนมัติไม่สำเร็จ กรุณาลองใหม่หรือติดต่อผู้ดูแล",
|
||||
"SHIPPING.STP_NOT_ELIGIBLE": "ออเดอร์นี้ยังไม่ผ่านเงื่อนไขสร้างอัตโนมัติ กรุณาตรวจและผ่านเกตก่อนลองใหม่",
|
||||
"SHIPPING.STP_CASE_NO_REQUIRED": "ต้องมีหมายเลขเคสตรวจทานเพื่อสร้างออเดอร์อัตโนมัติ",
|
||||
"SHIPPING.STP_AUTO_CREATE_FAILED": "สร้างออเดอร์อัตโนมัติล้มเหลว กรุณาลองใหม่หรือยืนยันด้วยตนเอง"
|
||||
},
|
||||
"SHIPPING.REVIEW_INVENTORY_SOURCE_UNRESOLVED": "ยังไม่ยืนยันแหล่งสต็อกแบบเฉพาะเจาะจง ไม่สามารถสร้างคำสั่งอย่างเป็นทางการได้ กรุณาตรวจสอบแหล่งสต็อกก่อน",
|
||||
"SHIPPING_REVIEW_INVENTORY_SOURCE_UNRESOLVED": "ยังไม่ยืนยันแหล่งสต็อกแบบเฉพาะเจาะจง ไม่สามารถสร้างคำสั่งอย่างเป็นทางการได้ กรุณาตรวจสอบแหล่งสต็อกก่อน"
|
||||
|
||||
@@ -177,6 +177,7 @@
|
||||
"continueAction": "ดำเนินการต่อ",
|
||||
"actionSubmitted": "ส่งการดำเนินการแล้ว",
|
||||
"submitting": "กำลังส่ง…",
|
||||
"readOnlyUseFooter": "ใช้แถบดำเนินการด้านล่างเพื่อดำเนินการต่อ",
|
||||
"actionCodes": {
|
||||
"retry_with_latest_rules": "ลองใหม่ด้วยกฎล่าสุด",
|
||||
"open_inventory_source_review": "เปิดการตรวจสอบแหล่งสต็อก",
|
||||
|
||||
@@ -3087,6 +3087,13 @@
|
||||
"scriptNotice": "检测到脚本但不会执行",
|
||||
"loading": "正在加载 XFA 集合…",
|
||||
"loadFailed": "加载 XFA 集合失败",
|
||||
"loadErrorTitle": "无法加载 XFA 数据源",
|
||||
"loadErrorHint": "这通常是结构分析未就绪或身份异常,不是“样本没有集合”。",
|
||||
"reload": "重新加载",
|
||||
"reparseSample": "重新解析样本",
|
||||
"reparseConfirm": "将重新排队解析该样本的版面与 XFA 结构。确认继续?",
|
||||
"reparseStarted": "已提交重新解析,请稍后重新加载。",
|
||||
"reparseFailed": "重新解析提交失败",
|
||||
"noCollections": "该样本没有可用的明细集合候选"
|
||||
},
|
||||
"xfaSource": {
|
||||
@@ -3920,7 +3927,58 @@
|
||||
"lineAmount": "明细金额公式",
|
||||
"totalAmount": "表头总额策略"
|
||||
},
|
||||
"previewHint": "完整干跑提取与金额恒等式结果请在「验证」页查看。"
|
||||
"previewHint": "完整干跑提取与金额恒等式结果请在「验证」页查看。",
|
||||
"previewMode": {
|
||||
"label": "预览状态",
|
||||
"original": "原始 PDF(已废止)",
|
||||
"synthetic": "合成预览",
|
||||
"statusReady": "合成预览就绪({pages} 页)",
|
||||
"statusLoading": "正在生成合成预览…",
|
||||
"statusUnavailable": "合成预览不可用",
|
||||
"statusFailed": "合成预览失败",
|
||||
"statusStale": "合成预览已过期,请重新生成",
|
||||
"requestFailed": "请求合成预览失败"
|
||||
},
|
||||
"staticPreviewBanner": "画布唯一图源为离线完整 flatten 有效页;不提供原始 PDF 对照。",
|
||||
"datasetsColumn": "XFA 数据集",
|
||||
"collectionMeta": "权威集合:{authoritative} · 镜像 {mirrors} 个",
|
||||
"syntheticNeedsReviewTitle": "合成预览不可用(needs_review)",
|
||||
"syntheticNeedsReviewBody": "合成预览不可用(仅诊断)。编辑标注请使用原生 PDF 画布。",
|
||||
"flattenLoading": "正在加载预览…",
|
||||
"retrySynthetic": "重试画布预览",
|
||||
"pageUnavailable": "当前页预览不可用,请重试或切换其它页继续标注。",
|
||||
"viewOriginalReference": "查看原始 PDF 对照(已废止)",
|
||||
"originalNotFormalEvidence": "已废止:不提供原始 PDF 入口。",
|
||||
"retryCanvas": "重试画布预览"
|
||||
},
|
||||
"xfaDesk": {
|
||||
"tableSettingsHint": "不影响 XFA datasets 正式取值",
|
||||
"readingMode": "正式取值模式",
|
||||
"readingModes": {
|
||||
"xfa_dataset": "XFA datasets",
|
||||
"pdf_coordinate": "标签右侧 / 坐标读取",
|
||||
"ocr_coordinate": "OCR 识别"
|
||||
},
|
||||
"readingModeWarning": "请确认该字段的正式取值来源已正确配置",
|
||||
"datasourceField": "数据源字段",
|
||||
"splitRuleField": "拆分规则",
|
||||
"datasetsPath": "Datasets 路径",
|
||||
"pickDatasetsPath": "选择 datasets 路径",
|
||||
"datasetsSampleValue": "Datasets 样本值",
|
||||
"previewStatusTitle": "预览与 OCR 状态",
|
||||
"ocrStatus": "OCR 自动标记:{status}",
|
||||
"reconfirmCollections": "重新确认集合",
|
||||
"reconfirmCollectionsTitle": "重新确认明细集合",
|
||||
"reconfirmCollectionsHint": "更新权威/镜像集合后,已确认的视觉绑定将降为 suggested,需在原生 PDF 画布上重新确认。",
|
||||
"reconfirmCollectionsConfirm": "确认并降级视觉绑定",
|
||||
"collectionsReconfirmedHint": "集合已更新;已确认视觉框已降为 suggested,请重新确认。",
|
||||
"datasetsOverlayToggle": "显示 datasets 辅助值",
|
||||
"datasetsOverlayHint": "仅建模辅助,不代表 Acrobat/flatten 正式外观",
|
||||
"blankStructureWarning": "无可视结构或尚未确认视觉框:当前可仅做结构化映射;OCR/坐标字段仍需真实可见页面证据",
|
||||
"confirmWithoutDatasetsOverlay": "当前确认未显示 datasets 辅助样本值",
|
||||
"sampleDisplayOption": "样本值显示(datasets 辅助)",
|
||||
"sampleDisplayHint": "默认开启;仅建模辅助,不代表 Acrobat/flatten 正式外观",
|
||||
"datasourceSummary": "数据源摘要"
|
||||
},
|
||||
"xfaUnified": {
|
||||
"drawFieldBox": "画字段框",
|
||||
@@ -3932,6 +3990,7 @@
|
||||
"rejectVisual": "驳回视觉框",
|
||||
"confirmSuccess": "视觉绑定已确认",
|
||||
"confirmFailed": "确认视觉绑定失败",
|
||||
"confirmRequiresSyntheticPreview": "请先加载原生 PDF 预览后再确认视觉绑定",
|
||||
"rejectSuccess": "视觉绑定已驳回",
|
||||
"rejectFailed": "驳回视觉绑定失败",
|
||||
"diagnosticsSummary": "必填覆盖 {mapped}/{total}",
|
||||
@@ -3943,10 +4002,40 @@
|
||||
"rejected": "已驳回",
|
||||
"needs_review": "待复核"
|
||||
},
|
||||
"createBlockersTitle": "创建前阻断项"
|
||||
"createBlockersTitle": "创建前阻断项",
|
||||
"confirmRequiresNativePreview": "请先加载原生 PDF 预览后再确认视觉绑定"
|
||||
},
|
||||
"xfaAutoMark": {
|
||||
"title": "自动标记建议",
|
||||
"count": "{count} 条",
|
||||
"hint": "OCR / Widget 建议仅作辅助;正式取值仍以 XFA datasets 为准。high 可直接接受为 confirmed;medium/low 接受后仍须在画布确认;mismatch 禁止确认。",
|
||||
"empty": "暂无自动标记建议",
|
||||
"accept": "接受",
|
||||
"adjust": "调整",
|
||||
"reject": "驳回",
|
||||
"actionsDisabled": "自动标记动作尚未接线",
|
||||
"originWidget": "Widget/模板",
|
||||
"originOcr": "OCR",
|
||||
"originUnknown": "未知来源",
|
||||
"confidence": "置信度 {value}%",
|
||||
"running": "OCR 运行中…",
|
||||
"runFull": "运行全量 OCR",
|
||||
"retry": "重试",
|
||||
"enqueueFailed": "自动标记入队失败",
|
||||
"jobFailed": "自动标记任务失败",
|
||||
"acceptSuccess": "建议已接受",
|
||||
"acceptFailed": "接受建议失败",
|
||||
"rejectSuccess": "建议已驳回",
|
||||
"rejectFailed": "驳回建议失败",
|
||||
"adjustHint": "请在原生 PDF 画布上调整框选后确认"
|
||||
},
|
||||
"xfaSplit": {
|
||||
"title": "字段拆分规则",
|
||||
"summaryTitle": "拆分规则摘要",
|
||||
"summaryCounts": "规则 {total} 条 · 已确认 {confirmed} 条",
|
||||
"summaryBlockers": "映射阻断 {count} 项",
|
||||
"editRules": "编辑拆分规则",
|
||||
"openFullPanel": "打开完整拆分面板",
|
||||
"openPanel": "拆分规则",
|
||||
"expand": "展开",
|
||||
"collapse": "收起",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"shippingOrderExtractionHandling": {
|
||||
"title": "待处理事项",
|
||||
"count": "{count} 项",
|
||||
"summaryLine": "{title} · {count} 项",
|
||||
"reasonPrefix": "原因:",
|
||||
"affectedPrefix": "影响对象:",
|
||||
"category": {
|
||||
@@ -1462,6 +1463,9 @@
|
||||
"loading": "正在加载复核结果...",
|
||||
"unavailable": "暂时无法加载复核结果,请稍后重试。",
|
||||
"retryLoad": "重新加载",
|
||||
"caseSwitchLoading": "正在加载当前 PDF…",
|
||||
"caseSwitchFailed": "当前 PDF 加载失败,可重试",
|
||||
"caseSwitchRetry": "重试",
|
||||
"documentNavigation": "PDF 导航",
|
||||
"documents": "PDF 文件",
|
||||
"unnamedDocument": "未命名 PDF",
|
||||
@@ -1571,6 +1575,8 @@
|
||||
"formal_task": "正式任务"
|
||||
},
|
||||
"formalEditTarget": "当前编辑对象:正式任务",
|
||||
"actionSuccess": "操作已完成",
|
||||
"resultNotReady": "处理结果尚未生成",
|
||||
"enterInventory": "查看库存问题",
|
||||
"returnStandard": "返回标准复核",
|
||||
"openPdf": "打开 PDF",
|
||||
@@ -1801,6 +1807,10 @@
|
||||
"viewTask": "返回对话查看进度",
|
||||
"returnToChat": "返回对话查看进度",
|
||||
"returnedFocusHint": "已返回对话,并聚焦任务 {taskNo}(见右侧「本次处理中」)",
|
||||
"retry": "重试自动推进",
|
||||
"retryStp": "重试自动推进",
|
||||
"retrySuccess": "已重新入队自动推进",
|
||||
"retryStpSuccess": "已重新入队自动建单",
|
||||
"status": {
|
||||
"ok": "已完成当前可自动执行步骤",
|
||||
"running": "正在处理中",
|
||||
@@ -2177,7 +2187,9 @@
|
||||
"manualReason": "人工说明",
|
||||
"confirmBlocked": "当前草稿未满足建单资格,请先处理库存源或校验问题后再确认。",
|
||||
"autoCreateBlocked": "人工建单资格已通过,但自动建单资格未通过;确认后将由人工推进。",
|
||||
"autoGateProgressHint": "已满足自动建单条件,系统将自动建单并推进,无需手动确认。",
|
||||
"autoGateProgressHint": "已满足自动建单条件,等待系统启动。",
|
||||
"autoGateWaitingHint": "已满足自动建单条件,等待系统启动。",
|
||||
"autoGateRunningHint": "系统正在自动建单并推进。",
|
||||
"layers": {
|
||||
"gate": "流程门禁",
|
||||
"gatePass": "无阻断门禁",
|
||||
@@ -2282,12 +2294,16 @@
|
||||
}
|
||||
},
|
||||
"shippingProcessing": {
|
||||
"panelTitle": "当前货代处理",
|
||||
"panelTitle": "本次处理中",
|
||||
"pendingMaterials": "待处理材料",
|
||||
"orderTasks": "订单任务",
|
||||
"groupNeedsAction": "需要你处理 · {count}",
|
||||
"groupProcessing": "处理中 · {count}",
|
||||
"groupNeedsAction": "需要你处理 · {count} 个任务",
|
||||
"groupProcessing": "系统处理中 · {count} 个任务",
|
||||
"groupCompleted": "已完成 · {count}",
|
||||
"groupProcessingRecords": "处理记录 · {count}",
|
||||
"groupRecordCompleted": "已完成",
|
||||
"groupRecordHistoryVersions": "历史版本",
|
||||
"groupRecordCancelled": "已取消",
|
||||
"taskTitle": "{label}",
|
||||
"justAppended": "刚刚新增 {count} 个附件",
|
||||
"justCreated": "刚刚创建 · 由本次发送产生",
|
||||
@@ -2357,7 +2373,11 @@
|
||||
"domainFulfillmentShip": "发货履约",
|
||||
"currentNeedLabel": "当前需要:",
|
||||
"systemProcessingNeed": "系统正在自动处理,请稍候或刷新进度",
|
||||
"progressTitleWithStage": "订单处理进度 · {stage}",
|
||||
"systemProcessingWithStage": "系统处理中 · {stage}",
|
||||
"viewProcessDetails": "查看流程详情",
|
||||
"viewFullProcess": "查看完整流程",
|
||||
"stageNodesUnavailable": "进度详情暂不可用",
|
||||
"closeProcessDetails": "关闭流程详情",
|
||||
"processDetailsTitle": "流程详情",
|
||||
"nodeTime": "时间",
|
||||
@@ -2389,6 +2409,10 @@
|
||||
"open_order_review": "进入订单处理",
|
||||
"open_order_processing": "进入订单处理",
|
||||
"edit_formal_task": "编辑正式任务",
|
||||
"open_profile_review": "查看模板匹配",
|
||||
"confirm_customer": "确认客户",
|
||||
"resolve_field_conflicts": "处理字段冲突",
|
||||
"adjudicate_duplicate": "裁决重复订单",
|
||||
"open_inventory_source_review": "进入库存源处理",
|
||||
"open_inventory_match_review": "进入库存匹配处理",
|
||||
"open_shortage_review": "处理库存异常",
|
||||
@@ -2400,13 +2424,26 @@
|
||||
"open_manual_upload": "人工上传登记",
|
||||
"view_result": "查看结果",
|
||||
"view_record": "查看记录",
|
||||
"view_progress": "查看进度",
|
||||
"retry_parse": "重试解析",
|
||||
"more": "更多"
|
||||
},
|
||||
"title": "本次处理中",
|
||||
"summaryLine": "{total} 个文件 · {processing} 个处理中 · {needsAction} 个待处理 · {completed} 个已完成",
|
||||
"summaryTasksAndFiles": "{tasks} 个任务 · {files} 个文件",
|
||||
"summaryLineDetail": "待我处理 {needsAction} 个任务 · 系统处理中 {processing} 个任务",
|
||||
"summaryTruncatedHint": "列表已截断,仅展示最近任务",
|
||||
"historyMoreCount": "还有 {count} 条",
|
||||
"historyTruncatedDetail": "仅展示最近 {shown} 条,另有 {hidden} 条未显示",
|
||||
"systemProcessing": "系统处理中",
|
||||
"primaryFile": "主文件:{name}",
|
||||
"continueProcessing": "继续处理",
|
||||
"fileCountUnavailable": "文件数暂不可用",
|
||||
"panelPinnedHint": "仍有处理中或待处理任务,侧栏保持展开;可收起文件详情",
|
||||
"panelPinnedLabel": "处理中",
|
||||
"groupHistory": "处理记录 · {count}",
|
||||
"groupHistoryRecords": "历史版本 · {count}",
|
||||
"groupCancelled": "已取消 · {count}",
|
||||
"expandHistory": "展开",
|
||||
"collapseHistory": "收起",
|
||||
"taskFiles": "{count} 个文件",
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
"SHIPPING_NOTICE.AUDIT_PERSIST_FAILED": "审计记录写入失败,操作未完成,请稍后重试。",
|
||||
"SHIPPING_NOTICE.AUDIT_METADATA_FORBIDDEN": "审计写入包含禁止的敏感字段。",
|
||||
"SHIPPING_NOTICE.AUDIT_SNAPSHOT_FORBIDDEN": "审计快照包含禁止的敏感字段。",
|
||||
"SHIPPING_PROCESSING_PROJECTION_INCONSISTENT": "订单进度状态不一致,已阻止履约动作。请刷新后重试。",
|
||||
"SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH": "正式任务与当前处理上下文不匹配,已阻止操作。请刷新后重试。",
|
||||
"SHIPPING_ORDER_SCHEMA_NOT_FOUND": "尚未初始化订单模板。",
|
||||
"SHIPPING_ORDER_SCHEMA_EXISTS": "订单模板已存在。",
|
||||
"SHIPPING_ORDER_SCHEMA_DRAFT_EXISTS": "已有订单模板草稿,请先完成或发布当前草稿。",
|
||||
@@ -467,9 +469,27 @@
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_EDIT_FORBIDDEN": "当前账号没有编辑 XFA 拆分规则的权限。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_TOKEN_INVALID": "拆分规则预览确认令牌无效、过期或与当前规则不匹配。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_REJECTED": "拆分规则确认被拒绝:预览令牌缺失、无效、已使用或样本内容已变化。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_STORE_UNAVAILABLE": "确认服务暂不可用,请稍后重试;持续失败请联系运维。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_UNAVAILABLE": "XFA 结构分析尚未就绪或记录不完整,请重新解析样本后重试。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_MISSING": "当前版面未绑定可用的 XFA 结构分析,请重新解析样本后重试。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_IDENTITY_MISMATCH": "XFA 结构分析与当前文档或版面身份不一致,已阻断操作。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_STALE": "XFA 结构分析相对当前样本内容已过期,请重新解析样本后重试。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_STALE": "XFA 合成预览相对冻结结构身份已过期,请重新生成预览后再确认。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_FAILED": "XFA 合成预览生成失败,请检查样本或稍后重试。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_UNAVAILABLE": "XFA 合成预览不可用,请先生成预览或重新解析样本。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_CONFIRM_REQUIRES_SYNTHETIC_PREVIEW": "确认视觉绑定须先在合成预览上完成:请生成合成预览并携带校验和后再确认。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_PAGE_INCONSISTENT": "XFA 合成预览页数或页框与冻结样本不一致,已阻断操作。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_VALUE_MISMATCH": "XFA 合成回显与冻结 datasets 不一致,已阻断操作。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_LEGACY_MAPPINGS_FORBIDDEN": "XFA 模板须使用统一 bindings;旧 header_mappings / line_mapping.fields 须先完成迁移。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_OCR_UNAVAILABLE": "XFA 合成预览 OCR 不可用,请检查 OCR 引擎部署后重试;普通 PDF 路径不受影响。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SYNTHETIC_PREVIEW_GATE": "XFA 合成预览发布门禁未通过:预览未就绪、缺少校验和或视觉绑定未确认。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_PREVIEW_STALE": "版面解析结果已变化,请刷新样本并重新预览复核。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "版面解析仍在准备中,请稍后刷新状态。"
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "版面解析仍在准备中,请稍后刷新状态。",
|
||||
"SHIPPING.STP_RETRY_ALREADY_CONFIRMED": "该复核单已确认建单,请改用确认后自动推进重试。",
|
||||
"SHIPPING.STP_ENQUEUE_FAILED": "自动建单入队失败,请稍后重试或联系管理员。",
|
||||
"SHIPPING.STP_NOT_ELIGIBLE": "当前订单尚未满足自动建单条件,请先完成校验与门禁后再重试。",
|
||||
"SHIPPING.STP_CASE_NO_REQUIRED": "缺少复核单编号,无法执行自动建单。",
|
||||
"SHIPPING.STP_AUTO_CREATE_FAILED": "自动建单执行失败,请重试或改用人工确认。"
|
||||
},
|
||||
"SHIPPING.REVIEW_INVENTORY_SOURCE_UNRESOLVED": "库存源尚未唯一确定,不能创建正式订单。请先完成库存源复核。",
|
||||
"SHIPPING_REVIEW_INVENTORY_SOURCE_UNRESOLVED": "库存源尚未唯一确定,不能创建正式订单。请先完成库存源复核。"
|
||||
|
||||
@@ -238,6 +238,7 @@
|
||||
"continueAction": "继续处理",
|
||||
"actionSubmitted": "操作已提交",
|
||||
"submitting": "提交中…",
|
||||
"readOnlyUseFooter": "请使用底部操作栏继续处理",
|
||||
"actionCodes": {
|
||||
"rematerialize_document": "重新准备文档",
|
||||
"retry_layout_parsing": "重试版面解析",
|
||||
|
||||
@@ -2849,6 +2849,13 @@
|
||||
"scriptNotice": "偵測到指令碼但不會執行",
|
||||
"loading": "正在載入 XFA 集合…",
|
||||
"loadFailed": "載入 XFA 集合失敗",
|
||||
"loadErrorTitle": "無法載入 XFA 資料來源",
|
||||
"loadErrorHint": "這通常是結構分析尚未就緒或身份異常,不是「樣本沒有集合」。",
|
||||
"reload": "重新載入",
|
||||
"reparseSample": "重新解析樣本",
|
||||
"reparseConfirm": "將重新排隊解析該樣本的版面與 XFA 結構。確認繼續?",
|
||||
"reparseStarted": "已提交重新解析,請稍後重新載入。",
|
||||
"reparseFailed": "重新解析提交失敗",
|
||||
"noCollections": "此樣本沒有可用的明細集合候選"
|
||||
},
|
||||
"xfaSource": {
|
||||
@@ -3682,7 +3689,58 @@
|
||||
"lineAmount": "明細金額公式",
|
||||
"totalAmount": "表頭總額策略"
|
||||
},
|
||||
"previewHint": "完整乾跑提取與金額恆等式結果請在「驗證」頁查看。"
|
||||
"previewHint": "完整乾跑提取與金額恆等式結果請在「驗證」頁查看。",
|
||||
"previewMode": {
|
||||
"label": "預覽狀態",
|
||||
"original": "原始 PDF",
|
||||
"synthetic": "合成預覽",
|
||||
"statusReady": "合成預覽就緒({pages} 頁)",
|
||||
"statusLoading": "正在產生合成預覽…",
|
||||
"statusUnavailable": "合成預覽不可用",
|
||||
"statusFailed": "合成預覽失敗",
|
||||
"statusStale": "合成預覽已過期,請重新產生",
|
||||
"requestFailed": "請求合成預覽失敗"
|
||||
},
|
||||
"staticPreviewBanner": "畫布唯一圖源為離線完整 flatten 有效頁;不提供原始 PDF 對照。",
|
||||
"datasetsColumn": "XFA 資料集",
|
||||
"collectionMeta": "權威集合:{authoritative} · 鏡像 {mirrors} 個",
|
||||
"syntheticNeedsReviewTitle": "合成預覽不可用(needs_review)",
|
||||
"syntheticNeedsReviewBody": "合成預覽不可用(僅診斷)。編輯標註請使用原生 PDF 畫布。",
|
||||
"flattenLoading": "正在載入預覽…",
|
||||
"retrySynthetic": "重試畫布預覽",
|
||||
"pageUnavailable": "目前頁預覽不可用,請重試或切換其他頁繼續標註。",
|
||||
"viewOriginalReference": "查看原始 PDF 對照(已廢止)",
|
||||
"originalNotFormalEvidence": "已廢止:不提供原始 PDF 入口。",
|
||||
"retryCanvas": "重試畫布預覽"
|
||||
},
|
||||
"xfaDesk": {
|
||||
"tableSettingsHint": "不影響 XFA datasets 正式取值",
|
||||
"readingMode": "正式取值模式",
|
||||
"readingModes": {
|
||||
"xfa_dataset": "XFA datasets",
|
||||
"pdf_coordinate": "標籤右側 / 座標讀取",
|
||||
"ocr_coordinate": "OCR 識別"
|
||||
},
|
||||
"readingModeWarning": "請確認該欄位的正式取值來源已正確設定",
|
||||
"datasourceField": "資料來源欄位",
|
||||
"splitRuleField": "拆分規則",
|
||||
"datasetsPath": "Datasets 路徑",
|
||||
"pickDatasetsPath": "選擇 datasets 路徑",
|
||||
"datasetsSampleValue": "Datasets 樣本值",
|
||||
"previewStatusTitle": "預覽與 OCR 狀態",
|
||||
"ocrStatus": "OCR 自動標記:{status}",
|
||||
"reconfirmCollections": "重新確認集合",
|
||||
"reconfirmCollectionsTitle": "重新確認明細集合",
|
||||
"reconfirmCollectionsHint": "更新權威/鏡像集合後,已確認的視覺綁定將降為 suggested,需在原生 PDF 畫布上重新確認。",
|
||||
"reconfirmCollectionsConfirm": "確認並降級視覺綁定",
|
||||
"collectionsReconfirmedHint": "集合已更新;已確認視覺框已降為 suggested,請重新確認。",
|
||||
"datasetsOverlayToggle": "顯示 datasets 輔助值",
|
||||
"datasetsOverlayHint": "僅建模輔助,不代表 Acrobat/flatten 正式外觀",
|
||||
"blankStructureWarning": "無可視結構或尚未確認視覺框:目前可僅做結構化對應;OCR/座標欄位仍需真實可見頁面證據",
|
||||
"confirmWithoutDatasetsOverlay": "目前確認未顯示 datasets 輔助樣本值",
|
||||
"sampleDisplayOption": "樣本值顯示(datasets 輔助)",
|
||||
"sampleDisplayHint": "預設開啟;僅建模輔助,不代表 Acrobat/flatten 正式外觀",
|
||||
"datasourceSummary": "資料源摘要"
|
||||
},
|
||||
"xfaUnified": {
|
||||
"drawFieldBox": "畫欄位框",
|
||||
@@ -3694,6 +3752,7 @@
|
||||
"rejectVisual": "駁回視覺框",
|
||||
"confirmSuccess": "視覺綁定已確認",
|
||||
"confirmFailed": "確認視覺綁定失敗",
|
||||
"confirmRequiresSyntheticPreview": "請先載入原生 PDF 預覽後再確認視覺綁定",
|
||||
"rejectSuccess": "視覺綁定已駁回",
|
||||
"rejectFailed": "駁回視覺綁定失敗",
|
||||
"diagnosticsSummary": "必填覆蓋 {mapped}/{total}",
|
||||
@@ -3704,10 +3763,40 @@
|
||||
"confirmed": "已確認",
|
||||
"rejected": "已駁回",
|
||||
"needs_review": "待複核"
|
||||
}
|
||||
},
|
||||
"confirmRequiresNativePreview": "請先載入原生 PDF 預覽後再確認視覺綁定"
|
||||
},
|
||||
"xfaAutoMark": {
|
||||
"title": "自動標記建議",
|
||||
"count": "{count} 條",
|
||||
"hint": "OCR / Widget 建議僅作輔助;正式取值仍以 XFA datasets 為準。Accept / Adjust / Reject 將於後續版本接線。",
|
||||
"empty": "暫無自動標記建議",
|
||||
"accept": "接受",
|
||||
"adjust": "調整",
|
||||
"reject": "駁回",
|
||||
"actionsDisabled": "自動標記動作尚未接線",
|
||||
"originWidget": "Widget/範本",
|
||||
"originOcr": "OCR",
|
||||
"originUnknown": "未知來源",
|
||||
"confidence": "置信度 {value}%",
|
||||
"running": "OCR 執行中…",
|
||||
"runFull": "執行全量 OCR",
|
||||
"retry": "重試",
|
||||
"enqueueFailed": "自動標記入隊失敗",
|
||||
"jobFailed": "自動標記任務失敗",
|
||||
"acceptSuccess": "建議已接受",
|
||||
"acceptFailed": "接受建議失敗",
|
||||
"rejectSuccess": "建議已駁回",
|
||||
"rejectFailed": "駁回建議失敗",
|
||||
"adjustHint": "請在原生 PDF 畫布上調整框選後確認"
|
||||
},
|
||||
"xfaSplit": {
|
||||
"title": "欄位拆分規則",
|
||||
"summaryTitle": "拆分規則摘要",
|
||||
"summaryCounts": "規則 {total} 條 · 已確認 {confirmed} 條",
|
||||
"summaryBlockers": "對應阻斷 {count} 項",
|
||||
"editRules": "編輯拆分規則",
|
||||
"openFullPanel": "開啟完整拆分面板",
|
||||
"openPanel": "拆分規則",
|
||||
"expand": "展開",
|
||||
"collapse": "收起",
|
||||
|
||||
@@ -218,6 +218,7 @@
|
||||
"shippingOrderExtractionHandling": {
|
||||
"title": "待處理事項",
|
||||
"count": "{count} 項",
|
||||
"summaryLine": "{title} · {count} 項",
|
||||
"reasonPrefix": "原因:",
|
||||
"affectedPrefix": "影響對象:",
|
||||
"category": {
|
||||
@@ -1428,6 +1429,9 @@
|
||||
"loading": "正在載入覆核結果...",
|
||||
"unavailable": "暫時無法載入覆核結果,請稍後再試。",
|
||||
"retryLoad": "重新載入",
|
||||
"caseSwitchLoading": "正在載入目前 PDF…",
|
||||
"caseSwitchFailed": "目前 PDF 載入失敗,可重試",
|
||||
"caseSwitchRetry": "重試",
|
||||
"documentNavigation": "PDF 導覽",
|
||||
"documents": "PDF 檔案",
|
||||
"unnamedDocument": "未命名 PDF",
|
||||
@@ -1537,6 +1541,8 @@
|
||||
"formal_task": "正式任務"
|
||||
},
|
||||
"formalEditTarget": "目前編輯對象:正式任務",
|
||||
"actionSuccess": "操作已完成",
|
||||
"resultNotReady": "處理結果尚未生成",
|
||||
"enterInventory": "查看庫存問題",
|
||||
"returnStandard": "返回標準複核",
|
||||
"openPdf": "開啟 PDF",
|
||||
@@ -1767,6 +1773,10 @@
|
||||
"viewTask": "返回對話查看進度",
|
||||
"returnToChat": "返回對話查看進度",
|
||||
"returnedFocusHint": "已返回對話,並聚焦任務 {taskNo}(見右側「本次處理中」)",
|
||||
"retry": "重試自動推進",
|
||||
"retryStp": "重試自動推進",
|
||||
"retrySuccess": "已重新入隊自動推進",
|
||||
"retryStpSuccess": "已重新入隊自動建單",
|
||||
"status": {
|
||||
"ok": "已完成目前可自動執行步驟",
|
||||
"running": "正在處理中",
|
||||
@@ -2142,7 +2152,9 @@
|
||||
"blockReason": "需要處理的原因",
|
||||
"manualReason": "人工說明",
|
||||
"confirmBlocked": "目前草稿未滿足建單資格,請先處理庫存源或校驗問題後再確認。",
|
||||
"autoGateProgressHint": "已滿足自動建單條件,系統將自動建單並推進,無需手動確認。",
|
||||
"autoGateProgressHint": "已滿足自動建單條件,等待系統啟動。",
|
||||
"autoGateWaitingHint": "已滿足自動建單條件,等待系統啟動。",
|
||||
"autoGateRunningHint": "系統正在自動建單並推進。",
|
||||
"layers": {
|
||||
"gate": "流程門禁",
|
||||
"gatePass": "無阻斷門禁",
|
||||
@@ -2281,12 +2293,16 @@
|
||||
"failed": "取消請求失敗,請稍後重試。"
|
||||
},
|
||||
"shippingProcessing": {
|
||||
"panelTitle": "目前貨代處理",
|
||||
"panelTitle": "本次處理中",
|
||||
"pendingMaterials": "待處理材料",
|
||||
"orderTasks": "訂單任務",
|
||||
"groupNeedsAction": "需要你處理 · {count}",
|
||||
"groupProcessing": "處理中 · {count}",
|
||||
"groupNeedsAction": "需要你處理 · {count} 個任務",
|
||||
"groupProcessing": "系統處理中 · {count} 個任務",
|
||||
"groupCompleted": "已完成 · {count}",
|
||||
"groupProcessingRecords": "處理記錄 · {count}",
|
||||
"groupRecordCompleted": "已完成",
|
||||
"groupRecordHistoryVersions": "歷史版本",
|
||||
"groupRecordCancelled": "已取消",
|
||||
"taskTitle": "{label}",
|
||||
"justAppended": "剛剛新增 {count} 個附件",
|
||||
"justCreated": "剛剛建立 · 由本次發送產生",
|
||||
@@ -2356,7 +2372,11 @@
|
||||
"domainFulfillmentShip": "發貨履約",
|
||||
"currentNeedLabel": "目前需要:",
|
||||
"systemProcessingNeed": "系統正在自動處理,請稍候或重新整理進度",
|
||||
"progressTitleWithStage": "訂單處理進度 · {stage}",
|
||||
"systemProcessingWithStage": "系統處理中 · {stage}",
|
||||
"viewProcessDetails": "查看流程詳情",
|
||||
"viewFullProcess": "查看完整流程",
|
||||
"stageNodesUnavailable": "進度詳情暫不可用",
|
||||
"closeProcessDetails": "關閉流程詳情",
|
||||
"processDetailsTitle": "流程詳情",
|
||||
"nodeTime": "時間",
|
||||
@@ -2388,6 +2408,10 @@
|
||||
"open_order_review": "進入訂單處理",
|
||||
"open_order_processing": "進入訂單處理",
|
||||
"edit_formal_task": "編輯正式任務",
|
||||
"open_profile_review": "查看模板匹配",
|
||||
"confirm_customer": "確認客戶",
|
||||
"resolve_field_conflicts": "處理欄位衝突",
|
||||
"adjudicate_duplicate": "裁決重複訂單",
|
||||
"open_inventory_source_review": "進入庫存源處理",
|
||||
"open_inventory_match_review": "進入庫存匹配處理",
|
||||
"open_shortage_review": "處理庫存異常",
|
||||
@@ -2399,6 +2423,8 @@
|
||||
"open_manual_upload": "人工上傳登記",
|
||||
"view_result": "查看結果",
|
||||
"view_record": "查看紀錄",
|
||||
"view_progress": "查看進度",
|
||||
"retry_parse": "重試解析",
|
||||
"more": "更多"
|
||||
},
|
||||
"title": "本次處理中",
|
||||
@@ -2527,9 +2553,20 @@
|
||||
},
|
||||
"versionHistoryNote": "目前顯示此檔案可用的版本記錄。",
|
||||
"summaryLine": "{total} 個檔案 · {processing} 個處理中 · {needsAction} 個待處理 · {completed} 個已完成",
|
||||
"summaryTasksAndFiles": "{tasks} 個任務 · {files} 個檔案",
|
||||
"summaryLineDetail": "待我處理 {needsAction} 個任務 · 系統處理中 {processing} 個任務",
|
||||
"summaryTruncatedHint": "列表已截斷,僅展示最近任務",
|
||||
"historyMoreCount": "還有 {count} 條",
|
||||
"historyTruncatedDetail": "僅展示最近 {shown} 條,另有 {hidden} 條未顯示",
|
||||
"systemProcessing": "系統處理中",
|
||||
"primaryFile": "主檔案:{name}",
|
||||
"continueProcessing": "繼續處理",
|
||||
"fileCountUnavailable": "檔案數暫不可用",
|
||||
"panelPinnedHint": "仍有處理中或待處理任務,側欄保持展開;可收起檔案詳情",
|
||||
"panelPinnedLabel": "處理中",
|
||||
"groupHistory": "處理記錄 · {count}",
|
||||
"groupHistoryRecords": "歷史版本 · {count}",
|
||||
"groupCancelled": "已取消 · {count}",
|
||||
"expandHistory": "展開",
|
||||
"collapseHistory": "收起",
|
||||
"taskFiles": "{count} 個檔案",
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
"SHIPPING_NOTICE.AUDIT_PERSIST_FAILED": "稽核記錄寫入失敗,操作未完成,請稍後重試。",
|
||||
"SHIPPING_NOTICE.AUDIT_METADATA_FORBIDDEN": "稽核寫入包含禁止的敏感欄位。",
|
||||
"SHIPPING_NOTICE.AUDIT_SNAPSHOT_FORBIDDEN": "稽核快照包含禁止的敏感欄位。",
|
||||
"SHIPPING_PROCESSING_PROJECTION_INCONSISTENT": "訂單進度狀態不一致,已阻止履約動作。請重新整理後重試。",
|
||||
"SHIPPING_PROCESSING_TASK_OWNERSHIP_MISMATCH": "正式任務與目前處理內容不符,已阻止操作。請重新整理後重試。",
|
||||
"SHIPPING_ORDER_SCHEMA_NOT_FOUND": "尚未初始化訂單範本。",
|
||||
"SHIPPING_ORDER_SCHEMA_EXISTS": "訂單範本已存在。",
|
||||
"SHIPPING_ORDER_SCHEMA_DRAFT_EXISTS": "已有訂單範本草稿,請先完成或發布目前草稿。",
|
||||
@@ -467,9 +469,27 @@
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_EDIT_FORBIDDEN": "目前帳號沒有編輯 XFA 拆分規則的權限。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_TOKEN_INVALID": "拆分規則預覽確認令牌無效、過期或與目前規則不符。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_REJECTED": "拆分規則確認被拒絕:預覽令牌缺失、無效、已使用或樣本內容已變化。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SPLIT_CONFIRM_STORE_UNAVAILABLE": "確認服務暫不可用,請稍後重試;持續失敗請聯繫運維。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_UNAVAILABLE": "XFA 結構分析尚未就緒或記錄不完整,請重新解析樣本後重試。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_MISSING": "當前版面未綁定可用的 XFA 結構分析,請重新解析樣本後重試。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_IDENTITY_MISMATCH": "XFA 結構分析與當前文檔或版面身份不一致,已阻斷操作。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_ANALYSIS_STALE": "XFA 結構分析相對當前樣本內容已過期,請重新解析樣本後重試。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_STALE": "XFA 合成預覽相對凍結結構身分已過期,請重新產生預覽後再確認。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_FAILED": "XFA 合成預覽產生失敗,請檢查樣本或稍後重試。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_UNAVAILABLE": "XFA 合成預覽不可用,請先產生預覽或重新解析樣本。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_CONFIRM_REQUIRES_SYNTHETIC_PREVIEW": "確認視覺綁定須先在合成預覽上完成:請產生合成預覽並攜帶校驗和後再確認。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_PAGE_INCONSISTENT": "XFA 合成預覽頁數或頁框與凍結樣本不一致,已阻斷操作。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_PREVIEW_VALUE_MISMATCH": "XFA 合成回顯與凍結 datasets 不一致,已阻斷操作。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_LEGACY_MAPPINGS_FORBIDDEN": "XFA 模板須使用統一 bindings;舊 header_mappings / line_mapping.fields 須先完成遷移。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_OCR_UNAVAILABLE": "XFA 合成預覽 OCR 不可用,請檢查 OCR 引擎部署後重試;普通 PDF 路徑不受影響。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_XFA_SYNTHETIC_PREVIEW_GATE": "XFA 合成預覽發佈門禁未通過:預覽未就緒、缺少校驗和或視覺綁定未確認。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_PREVIEW_STALE": "版面解析結果已變更,請重新整理樣本並再次預覽複核。",
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "版面解析仍在準備中,請稍後重新整理狀態。"
|
||||
"SHIPPING.ORDER_DOCUMENT_PROFILE_TEST_NOT_READY": "版面解析仍在準備中,請稍後重新整理狀態。",
|
||||
"SHIPPING.STP_RETRY_ALREADY_CONFIRMED": "該複核單已確認建單,請改用確認後自動推進重試。",
|
||||
"SHIPPING.STP_ENQUEUE_FAILED": "自動建單入隊失敗,請稍後重試或聯絡管理員。",
|
||||
"SHIPPING.STP_NOT_ELIGIBLE": "目前訂單尚未滿足自動建單條件,請先完成校驗與門禁後再重試。",
|
||||
"SHIPPING.STP_CASE_NO_REQUIRED": "缺少複核單編號,無法執行自動建單。",
|
||||
"SHIPPING.STP_AUTO_CREATE_FAILED": "自動建單執行失敗,請重試或改用人工確認。"
|
||||
},
|
||||
"SHIPPING.REVIEW_INVENTORY_SOURCE_UNRESOLVED": "庫存源尚未唯一確定,不能建立正式訂單。請先完成庫存源複核。",
|
||||
"SHIPPING_REVIEW_INVENTORY_SOURCE_UNRESOLVED": "庫存源尚未唯一確定,不能建立正式訂單。請先完成庫存源複核。"
|
||||
|
||||
@@ -237,6 +237,7 @@
|
||||
"continueAction": "繼續處理",
|
||||
"actionSubmitted": "操作已提交",
|
||||
"submitting": "提交中…",
|
||||
"readOnlyUseFooter": "請使用底部操作列繼續處理",
|
||||
"actionCodes": {
|
||||
"retry_with_latest_rules": "依最新規則重試",
|
||||
"open_inventory_source_review": "開啟庫存源覆核",
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* shared/api/client.stpErrors.spec.ts
|
||||
* 用途:锁定 STP 错误码四语言映射(UI-05 / BE-04)。
|
||||
* 依赖:vitest、vue-i18n、resolveLocalizedErrorMessage。
|
||||
* 逻辑:断言 SHIPPING.STP_* 不回落英文后端 message。
|
||||
*/
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
|
||||
vi.mock('@/i18n', async () => {
|
||||
const { createI18n } = await import('vue-i18n');
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
errors: {
|
||||
generic: '通用错误',
|
||||
codes: {
|
||||
'SHIPPING.STP_RETRY_ALREADY_CONFIRMED': '该复核单已确认建单,请改用确认后自动推进重试。',
|
||||
'SHIPPING.STP_ENQUEUE_FAILED': '自动建单入队失败,请稍后重试或联系管理员。',
|
||||
'SHIPPING.STP_NOT_ELIGIBLE': '当前订单尚未满足自动建单条件,请先完成校验与门禁后再重试。',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
return { default: i18n };
|
||||
});
|
||||
|
||||
describe('resolveLocalizedErrorMessage STP codes', () => {
|
||||
it('maps SHIPPING.STP_* codes to locale text instead of English fallback', async () => {
|
||||
const { resolveLocalizedErrorMessage } = await import('./client');
|
||||
expect(resolveLocalizedErrorMessage(
|
||||
'SHIPPING.STP_RETRY_ALREADY_CONFIRMED',
|
||||
'Case already confirmed; use post-confirm auto progress retry',
|
||||
)).toContain('已确认建单');
|
||||
expect(resolveLocalizedErrorMessage(
|
||||
'SHIPPING.STP_ENQUEUE_FAILED',
|
||||
'STP enqueue failed',
|
||||
)).toContain('入队失败');
|
||||
expect(resolveLocalizedErrorMessage(
|
||||
'SHIPPING.STP_NOT_ELIGIBLE',
|
||||
'xfa_shadow_mode',
|
||||
)).toContain('自动建单条件');
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user