Merge branch 'dev-new' into runny827

This commit is contained in:
runny committed 2026-09-10 22:01:56 +08:00
commit f1beb6fefb
112 files changed
+6300 -586

No files matched your search

@@ -18,7 +18,9 @@ const i18n = createI18n({
title: '文档模板匹配', subtitle: '摘要', selected: '命中模板', noSelected: '未选定模板',
expandCandidates: '查看候选模板({count})', collapseCandidates: '收起候选模板',
routeType: '路由类型', executionMode: '执行模式',
extractionBlocked: '模板已命中,但字段提取仍被安全门禁阻断', extractionBlockedReason: '阻断原因:{reasons}',
extractionBlocked: '模板已命中,但字段提取仍被安全门禁阻断',
extractionBlockedNoMatch: '模板未唯一命中,字段提取被阻断',
extractionBlockedReason: '阻断原因:{reasons}',
coordinateModel: {
anchorFrame: '锚点坐标框架', status: '变换状态', translateX: '横向平移',
translateY: '纵向平移', reasonCodes: '原因码',
@@ -122,6 +124,30 @@ describe('ReviewProfileMatchPanel', () => {
// 关键断言:唯一模板命中不等于字段已提取,必须明确暴露下游阻断原因。
expect(wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text())
.toContain('PARSE_STRATEGY_ROW_MODE_AMBIGUOUS');
expect(wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text())
.toContain('模板已命中');
});
it('未选定模板时阻断文案不得再写模板已命中', () => {
const wrapper = mount(ReviewProfileMatchPanel, {
props: {
profileMatch: {
available: true,
visibility: 'admin',
status: 'evidence_insufficient',
needs_review: true,
selected_profile: null,
candidates: [],
fallback_reason_codes: ['coordinate_evidence_unavailable'],
},
},
global: { plugins: [i18n] },
});
const blocked = wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text();
expect(blocked).toContain('模板未唯一命中');
expect(blocked).not.toContain('模板已命中');
expect(blocked).toContain('coordinate_evidence_unavailable');
});
it('管理员技术详情展示锚点框架平移和稳定原因码,不展示原始正文或完整坐标', async () => {
@@ -43,10 +43,20 @@ const selectedCoordinateTransform = computed(() => {
const coordinateTransformReasonCodes = computed(() => (
selectedCoordinateTransform.value?.reason_codes || []
));
/** 唯一命中仅证明版式身份;下游字段/明细恢复若受门禁阻断,必须在同卡明确说明。 */
/** 唯一命中仅证明版式身份;下游字段/明细恢复若受门禁阻断,必须在同卡明确说明。
* 未选定模板时不得再写「模板已命中」,避免与上方「未选定模板」矛盾。 */
const extractionBlockReasons = computed(() => (
(props.profileMatch?.fallback_reason_codes || []).filter((code) => String(code).trim())
));
const hasSelectedProfile = computed(() => Boolean(
String(props.profileMatch?.selected_profile?.profile_code || '').trim()
|| String(props.profileMatch?.selected_profile?.display_name || '').trim(),
));
const extractionBlockedTitle = computed(() => (
hasSelectedProfile.value
? t('chat.shippingOrderReview.profileMatch.extractionBlocked')
: t('chat.shippingOrderReview.profileMatch.extractionBlockedNoMatch')
));
watch(
() => `${props.profileMatch?.status || ''}:${props.profileMatch?.selected_profile?.profile_code || ''}:${candidateCount.value}`,
@@ -117,7 +127,7 @@ const selectedLabel = computed(() => {
class="mt-3 rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100"
data-testid="review-profile-match-extraction-blocked"
>
<p class="font-medium">{{ t('chat.shippingOrderReview.profileMatch.extractionBlocked') }}</p>
<p class="font-medium">{{ extractionBlockedTitle }}</p>
<p class="mt-1 text-amber-800 dark:text-amber-200">
{{ t('chat.shippingOrderReview.profileMatch.extractionBlockedReason', { reasons: extractionBlockReasons.join(', ') }) }}
</p>
@@ -1068,29 +1068,54 @@ describe('useShippingOrderReview build eligibility writes', () => {
build_eligibility: { can_build: true, status: 'ready', line_projections: [] },
},
});
api.getCase.mockResolvedValue(readyCase);
const confirmedCase = {
...readyCase,
status: 'confirmed',
confirmed_task_no: 'OT-1',
order_task_no: 'OT-1',
has_formal_ot: true,
};
api.getCase.mockResolvedValue(confirmedCase);
api.getRun.mockResolvedValue({
run_no: 'RUN-1', summary: {},
items: [{ case_no: 'CASE-1', document_id: 1, status: 'ready', available_actions: ['confirm'] }],
});
api.getQueue.mockResolvedValue({
summary: { total: 1, needs_action: 1, processing: 0, completed: 0 },
items: [{
case_no: 'CASE-1', document_id: 1, source_run_no: 'RUN-1', status: 'confirmed',
lifecycle_stage: 'fulfillment_prep',
lifecycle_entries: [{ code: 'fulfillment_prep', state: 'current' }],
}],
});
api.getEvidence.mockResolvedValue({ items: [] });
api.getPreview.mockResolvedValue({ preview_url: '' });
api.getProcessingWorkItem.mockResolvedValue({
work_item_no: 'OT-1', status: 'blocked', user_status: 'waiting_human',
workItemNo: 'OT-1',
status: 'waiting_human',
userStatus: 'waiting_human',
stage: 'inventory_matching',
currentGate: { gateCode: 'inventory_matching', status: 'blocked_manual' },
uiState: {
status: 'waiting_human',
lifecycleStage: 'fulfillment_prep',
lifecycleEntries: [{ code: 'fulfillment_prep', state: 'current' }],
},
});
api.confirmCase.mockResolvedValue({
task_no: 'SN-1', order_task_no: 'OT-1', shipping_notice_no: 'SN-1', idempotent_replay: false,
case: { ...readyCase, status: 'confirmed', order_task_no: 'OT-1' }, auto_progress_started: true,
case: confirmedCase, auto_progress_started: true,
});
const review = useShippingOrderReview();
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
const queueCallsBeforeConfirm = api.getQueue.mock.calls.length;
await review.confirm();
await vi.advanceTimersByTimeAsync(0);
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
await Promise.resolve();
// 中断(waiting_human,即“等待人工处理”)视为线性终态:结果不会自行变化,必须停止轮询。
// 中断(waiting_human)停轮询前须刷新 Case/Queue,否则自动跳阶段拿不到 lifecycle。
expect(api.getQueue.mock.calls.length).toBeGreaterThan(queueCallsBeforeConfirm);
expect(review.workflowProgressPolling.value).toBe(false);
review.stopWorkflowProgressPolling();
@@ -621,9 +621,12 @@ export function useShippingOrderReview(options: {
};
/**
* 轮询正式 OT / Extraction Run 的处理投影,驱动工作流进度与阶段条。
*
* OT ShippingProcessing Extraction Run
* WorkflowItem OT Run
* 核心逻辑:有权威 OT 时刷 shipping processing;投影进入 waiting_human/failed 等
* 终态前先 await refreshActiveAutomationLifecycle,保证五阶段条能跟随跳转后再停轮询。
*
* @param itemNo - 可选工作流/OT 编号覆盖
*/
const startWorkflowProgressPolling = (itemNo?: string | null) => {
stopWorkflowProgressPolling();
@@ -658,12 +661,8 @@ export function useShippingOrderReview(options: {
lastUnifiedStatus = unifiedStatus;
options.onWorkflowRefresh?.();
}
if (UNIFIED_TERMINAL.has(unifiedStatus)) {
stopWorkflowProgressPolling();
return;
}
// 顶部五阶段取 Case/Queue 的 lifecycle_entries。仅当 OT 投影的阶段/门禁发生变化
// 时刷新一次,避免每 2.5 秒重复读取队列;不等待该读取,保证终态轮询及时停止。
// 时刷新一次,避免每 2.5 秒重复读取队列。
const lifecycleFingerprint = [
unifiedStatus,
String(shippingProcessingProjection.value?.stage || ''),
@@ -672,7 +671,13 @@ export function useShippingOrderReview(options: {
].join('|');
if (lifecycleFingerprint !== lastLifecycleFingerprint) {
lastLifecycleFingerprint = lifecycleFingerprint;
void refreshActiveAutomationLifecycle();
// [STEP] waiting_human/failed 也会停轮询,但停前必须落地一次阶段投影,
// 否则提交订单后秒级阻断时五阶段条卡在订单复核、自动跳转永不触发。
await refreshActiveAutomationLifecycle();
}
if (UNIFIED_TERMINAL.has(unifiedStatus)) {
stopWorkflowProgressPolling();
return;
}
return;
}
@@ -1999,6 +1999,47 @@ describe('ShippingOrderReviewView layout phase 1', () => {
}
});
it('follows the backend stage advance when the route has no lifecycle_stage deep link', async () => {
// 无 lifecycle_stage = 尚未钉工作面,应跟随系统 current,不能因空深链永久停在订单复核。
const originalQueue = reviewQueue.value;
try {
reviewQueue.value = {
...reviewQueue.value,
items: [{
...reviewQueue.value.items[0],
lifecycle_stage: 'order_review',
lifecycle_entries: [
{ code: 'order_review', state: 'current', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'unavailable', targetSurface: 'order_lifecycle_workbench' },
],
}],
};
const wrapper = await mountView({});
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
.toBeUndefined();
reviewQueue.value = {
...reviewQueue.value,
items: [{
...reviewQueue.value.items[0],
lifecycle_stage: 'fulfillment_prep',
lifecycle_entries: [
{ code: 'order_review', state: 'available', targetSurface: 'order_lifecycle_workbench' },
{ code: 'fulfillment_prep', state: 'current', targetSurface: 'order_lifecycle_workbench' },
],
}],
};
await nextTick();
await flushPromises();
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
.toBe('fulfillment_prep');
expect(messageMocks.success).toHaveBeenCalledWith('已自动推进到通知准备');
} finally {
reviewQueue.value = originalQueue;
}
});
it('keeps a manually revisited earlier lifecycle stage when the backend advances', async () => {
const originalQueue = reviewQueue.value;
try {
@@ -4451,8 +4451,10 @@ watch(
) return;
// 只响应后端 current 阶段的真实推进:用户点击已完成阶段只会改路由,
// 绝不能触发自动跳转而被带回当前阶段。
// 无 lifecycle_stage 深链 = 尚未钉工作面,视为仍跟随系统(与「仍停在旧 current」同权)。
const requested = String(route.query.lifecycle_stage || '').trim();
if (requested !== previousStage) return;
const followingSystem = !requested || requested === previousStage;
if (!followingSystem) return;
if (lifecycleStagePinnedByUserForCase.value === String(activeCase.value?.case_no || '').trim()) return;
const previousIndex = LIFECYCLE_STAGE_CODES.indexOf(previousStage);
const currentIndex = LIFECYCLE_STAGE_CODES.indexOf(currentStage);