Merge branch 'dev' into runny827

feat(training): 新增精益培训视频与周任务管理

# Conflicts:
#	backend/app/models/__init__.py
This commit is contained in:
runny committed 2026-09-08 18:30:09 +08:00
1 parent 85d27e9ffa
commit 91b7233872
812 files changed
+73763 -18908

No files matched your search

@@ -9,7 +9,11 @@
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
import { resolveShippingProcessingStageLabel, resolveShippingProcessingStatusLabel } from '@/features/chat/shipping/shippingProcessingLabels';
import {
resolveShippingLifecycleStageLabel,
resolveShippingProcessingStatusLabel,
isGenericBlockingReason,
} from '@/features/chat/shipping/shippingProcessingLabels';
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
import type { ActionPresentationItem } from '../types';
import { resolveGateReasonLabel } from '../gateReasonLabel';
@@ -35,20 +39,22 @@ const actionPresentation = useProcessingActionPresentation(projectionRef, { surf
* 紧凑单行:● 阶段名 · 第 x/total。
*/
const inlineLine = computed(() => {
const stage = props.projection.uiState?.stage || props.projection.userStage || props.projection.stage;
const stageLabel = resolveShippingProcessingStageLabel(stage, te, t);
const stage = props.projection.uiState?.lifecycleStage || props.projection.uiState?.stage || props.projection.userStage || props.projection.stage;
const stageLabel = resolveShippingLifecycleStageLabel(stage, te, t);
return `● ${stageLabel}`;
});
/**
* Gate 阻断原因(禁止展示内部码)。
* Gate 阻断原因(仅具体、非兜底才展示,避免与状态标签重复;禁止展示内部码)。
*/
const gateReason = computed(() => resolveGateReasonLabel(
props.projection.uiState
? props.projection.uiState.blocking_reason?.code
: (props.projection.blockingReason?.code || props.projection.currentGate?.blockingReasonCode),
{ t, te },
));
const gateReason = computed(() => {
const reason = props.projection.uiState
? props.projection.uiState.blocking_reason
: (props.projection.blockingReason || null);
if (isGenericBlockingReason(reason, te)) return '';
const code = String(reason?.code || props.projection.currentGate?.blockingReasonCode || '').trim();
return resolveGateReasonLabel(code, { t, te });
});
/** 单一状态标签:阶段行只描述位置,状态标签只描述当前可操作状态。 */
const statusLabel = computed(() => resolveShippingProcessingStatusLabel(
@@ -0,0 +1,61 @@
/**
* features/shipping-progress/stageMapping.spec.ts
* 用途:验收「处理阶段 → 5 业务标签」唯一前端映射。
* 依赖:Vitest、stageMapping、SHIPPING_PROCESSING_STAGES。
* 逻辑:15 阶全部映射且与后端 LIFECYCLE_STAGE_BY_PROCESSING_STAGE 方向一致;
* 未知/非法阶段 clamp 到 intake_parse;5 段标签 i18n 键齐全。
*/
import { describe, expect, it } from 'vitest';
import { SHIPPING_PROCESSING_STAGES } from '@/features/chat/types/shipping.api.types';
import {
LIFECYCLE_STAGE_CODES,
LIFECYCLE_STAGE_LABEL_KEYS,
mapProcessingStageToLifecycle,
SHIPPING_STAGE_TO_LIFECYCLE,
} from './stageMapping';
describe('stageMapping', () => {
it('将全部 15 阶处理阶段映射到 5 段业务标签且不漂移', () => {
// 权威方向:后端 lifecycle_projection.LIFECYCLE_STAGE_BY_PROCESSING_STAGE。
const expected: Record<string, string> = {
upload_received: 'intake_parse',
email_parsing: 'intake_parse',
document_parsing: 'intake_parse',
email_adjudicating: 'intake_parse',
candidate_creating: 'intake_parse',
customer_resolving: 'order_review',
duplicate_checking: 'order_review',
inventory_source_resolving: 'order_review',
waiting_review: 'order_review',
order_creating: 'fulfillment_prep',
inventory_fetching: 'fulfillment_prep',
inventory_matching: 'fulfillment_prep',
excel_generating: 'fulfillment_prep',
freight_uploading: 'freight_upload',
completed: 'upload_complete',
};
for (const stage of SHIPPING_PROCESSING_STAGES) {
expect(SHIPPING_STAGE_TO_LIFECYCLE[stage]).toBe(expected[stage]);
expect(LIFECYCLE_STAGE_CODES).toContain(SHIPPING_STAGE_TO_LIFECYCLE[stage]);
}
});
it('过渡态归入对应业务标签(库存准备/充足性→通知准备;人工上传交接→货代上传)', () => {
expect(mapProcessingStageToLifecycle('inventory_preparation')).toBe('fulfillment_prep');
expect(mapProcessingStageToLifecycle('inventory_sufficiency')).toBe('fulfillment_prep');
expect(mapProcessingStageToLifecycle('manual_upload_handoff')).toBe('freight_upload');
});
it('未知/非法阶段 clamp 到 intake_parse 安全兜底', () => {
expect(mapProcessingStageToLifecycle('bogus_stage')).toBe('intake_parse');
expect(mapProcessingStageToLifecycle('')).toBe('intake_parse');
expect(mapProcessingStageToLifecycle(null)).toBe('intake_parse');
expect(mapProcessingStageToLifecycle(undefined)).toBe('intake_parse');
});
it('5 段业务标签 i18n key 后缀齐全', () => {
for (const code of LIFECYCLE_STAGE_CODES) {
expect(LIFECYCLE_STAGE_LABEL_KEYS[code]).toBeTruthy();
}
});
});
@@ -0,0 +1,85 @@
/**
* features/shipping-progress/stageMapping.ts
* 用途:发货通知统一阶段口径映射的唯一前端模块(处理阶段 → 5 业务标签)。
* 依赖:features/chat/types/shipping.api.types.ts 的 ShippingProcessingStage /
* SHIPPING_PROCESSING_STAGES(与后端 progress_audit_contract 对齐)。
* 逻辑:批次中心卡片、生命周期工作台 5 段头部统一消费本模块,禁止前端任何页面
* 私自分叉「处理阶段 → 5 tab」映射;后端权威映射为
* lifecycle_projection.LIFECYCLE_STAGE_BY_PROCESSING_STAGE,此处是它的前端镜像。
* 未知/非法阶段 clamp 到 `intake_parse` 安全兜底(阶段不漂移)。
*/
import {
SHIPPING_PROCESSING_STAGES,
type ShippingProcessingStage,
} from '@/features/chat/types/shipping.api.types';
/** 5 段业务标签(后端 lifecycle_projection.LIFECYCLE_STAGES 的前端镜像)。 */
export const LIFECYCLE_STAGE_CODES = [
'intake_parse',
'order_review',
'fulfillment_prep',
'freight_upload',
'upload_complete',
] as const;
/** 5 段业务标签码联合类型。 */
export type LifecycleStageCode = (typeof LIFECYCLE_STAGE_CODES)[number];
/** 5 段业务标签(code → i18n key 后缀;i18n 前缀 chat.shippingNoticeUi.stage.)。 */
export const LIFECYCLE_STAGE_LABEL_KEYS: Record<string, string> = {
intake_parse: 'intakeParse',
order_review: 'orderReview',
fulfillment_prep: 'fulfillmentPrep',
freight_upload: 'freightUpload',
upload_complete: 'uploadComplete',
};
/** 处理阶段 → 5 业务标签映射(唯一);顺序即后端 15 阶,禁止前端自行增删。 */
export const SHIPPING_STAGE_TO_LIFECYCLE: Record<string, LifecycleStageCode> = {
upload_received: 'intake_parse',
email_parsing: 'intake_parse',
document_parsing: 'intake_parse',
email_adjudicating: 'intake_parse',
candidate_creating: 'intake_parse',
customer_resolving: 'order_review',
duplicate_checking: 'order_review',
inventory_source_resolving: 'order_review',
waiting_review: 'order_review',
order_creating: 'fulfillment_prep',
inventory_fetching: 'fulfillment_prep',
// 过渡态:库存准备/充足性归入通知准备。
inventory_preparation: 'fulfillment_prep',
inventory_matching: 'fulfillment_prep',
inventory_sufficiency: 'fulfillment_prep',
excel_generating: 'fulfillment_prep',
freight_uploading: 'freight_upload',
// 过渡态:人工上传交接归入货代上传。
manual_upload_handoff: 'freight_upload',
completed: 'upload_complete',
};
/**
* 将统一处理阶段映射为 5 段业务标签;未知/非法阶段 clamp 到「接收解析」安全兜底。
*
* @param stage - 后端投影下发的处理阶段码(SHIPPING_PROCESSING_STAGES)。
* @returns 5 段业务标签码(LIFECYCLE_STAGE_CODES 之一)。
*/
export function mapProcessingStageToLifecycle(
stage: string | null | undefined,
): LifecycleStageCode {
const code = String(stage || '').trim();
return SHIPPING_STAGE_TO_LIFECYCLE[code] ?? 'intake_parse';
}
/**
* 判断某处理阶段码是否在共享 15 阶序列内(未知阶段返回 false,供调用方 fail-closed)。
*
* @param stage - 处理阶段码。
* @returns 是否属于共享 SHIPPING_PROCESSING_STAGES。
*/
export function isKnownProcessingStage(
stage: string | null | undefined,
): stage is ShippingProcessingStage {
return SHIPPING_PROCESSING_STAGES.includes(String(stage || '') as ShippingProcessingStage);
}
@@ -154,23 +154,23 @@ describe('workbenchActionRegistry', () => {
expect(resolved?.todoActionCode).toBe('retry_inventory_matching');
});
it('routes reload inventory result through the formal Gate todo action', () => {
it('routes merged inventory rematch through the formal Gate todo action', () => {
const result = resolveProcessingActionPresentation(projection({
uiState: {
status: 'retryable', stage: 'inventory_preparation', blocking_reason: null,
primary_action: { code: 'reload_inventory_result', label_key: 'x' }, secondary_actions: [],
primary_action: { code: 'retry_inventory_matching', label_key: 'x' }, secondary_actions: [],
},
currentGate: {
gateCode: 'inventory_preparation',
status: 'blocked_retryable',
nextActionCode: 'reload_inventory_result',
nextActionCode: 'retry_inventory_matching',
},
}), { surface: 'review' });
const resolved = resolveWorkbenchActionItem(result.primary!, { postCreate: true });
expect(result.primary?.intent).toBe('reload_inventory_result');
expect(result.primary?.intent).toBe('retry_inventory_matching');
expect(resolved?.reviewBehavior).toBe('todo_panel');
expect(resolved?.todoActionCode).toBe('reload_inventory_result');
expect(resolved?.todoActionCode).toBe('retry_inventory_matching');
});
it('shows RPA upload retry instead of manual upload entries when Gate 19 is blocked', () => {