refactor(shipping-notice): 进度信号统一为 15 阶 stage 契约码并透传阻断原因
- 后端进度写入 step_key 全量切换为 15 阶契约 stage 码 - 投影层清除 CheckPoint stepN_* 遗留别名与子串/前缀启发式,阶段信号按契约码精确匹配 - 建单前 Case 摘要透传草稿首要阻断原因 - 前端标签/归一化/处理卡片同步契约码,阻断原因按 i18n 优先展示 - 修复正式下游回看时 activeCase 刻意为空导致队列定位与接收解析上下文静默跳过 - 同步更新投影/门禁/工作台/RPA 流程测试
This commit is contained in:
1 parent
d1adbe5ec5
commit
18af972d20
34 files changed
+903
-111
No files matched your search
+54
@@ -22,6 +22,7 @@ const i18n = createI18n({
|
||||
actionCodes: {
|
||||
reload_inventory_result: '重新读取库存结果',
|
||||
retry_inventory_preparation: '重新获取库存',
|
||||
confirm_customer: '确认客户',
|
||||
},
|
||||
inventoryActions: {
|
||||
reloadInventoryResult: '重新读取库存结果',
|
||||
@@ -337,4 +338,57 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
// 关键断言:无 statusDetail 时说明行完全不渲染,不留空壳。
|
||||
expect(wrapper.find('[data-testid="review-current-task-status-detail"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders the suggested next action instead of the reason text when next_action is present', () => {
|
||||
// v4 语义分离:「下一步」给建议动作(确认客户),原因文案(客户尚未确认)
|
||||
// 属于阻塞原因位,不得再挤进下一步槽位。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
nextAction: 'confirm_customer',
|
||||
} as any,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('hides the generic run-level status detail when a specific blocking reason is shown', () => {
|
||||
// v4 去重:具体阻断原因已由「下一步」承载时,泛化的「当前步骤需要人工处理」属纯重复。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
nextAction: 'confirm_customer',
|
||||
} as any,
|
||||
statusDetail: { text: '当前步骤需要人工处理' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-status-detail"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the run-level status detail when the blocking reason is generic', () => {
|
||||
// 无具体原因(未知码、无契约文案)时,Run 级等待说明仍是唯一信息,必须保留。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: { code: 'internal_gate_reason' } as any,
|
||||
statusDetail: { text: '当前步骤需要人工处理' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-status-detail"]').text()).toBe('当前步骤需要人工处理');
|
||||
});
|
||||
});
|
||||
+27
-6
@@ -10,7 +10,9 @@
|
||||
禁止把读取占位误述为「系统处理中」,也不做骨架→真值的二次刷新;
|
||||
loading 仅在挂载期抑制可执行动作,等权威投影到达后再放行(fail-closed);
|
||||
由 ShippingOrderReviewView 在 mountCurrentProcessingCard 时挂载;
|
||||
v2 新增 statusDetail:状态块内嵌动态说明(隐藏裁决在视图侧,见 spec §5.2)。
|
||||
v2 新增 statusDetail:状态块内嵌动态说明(隐藏裁决在视图侧,见 spec §5.2);
|
||||
v4 语义分离:下一步优先消费 blocking_reason.next_action 的建议动作文案,
|
||||
且具体阻断原因在场时隐藏泛化 statusDetail(防同卡三行「待人工」空话)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
@@ -20,7 +22,10 @@ import type {
|
||||
ShippingProcessingBlockingReason,
|
||||
ShippingProcessingPrimaryAction,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
isGenericBlockingReason,
|
||||
resolveShippingProcessingStageLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
|
||||
import { lookupWorkbenchAction, shouldRenderWorkbenchAction } from '@/features/shipping-progress/workbenchActionRegistry';
|
||||
import { inventoryActionLabelKey, isInternalInventoryAction } from '@/features/shipping-progress/actionPresentation';
|
||||
@@ -147,9 +152,15 @@ const nextStepText = computed(() => {
|
||||
// 其余按 user_status/blocking_reason 照常渲染,空态自然落在「状态待确认」,不做骨架二次刷新。
|
||||
const automationMessage = props.loading ? safeMessage(props.automation?.message) : '';
|
||||
if (automationMessage) return automationMessage;
|
||||
// 1) blocking_reason → 用后端给的 i18n_key 渲染具体阻断
|
||||
// 1) blocking_reason → 先给契约注册的「建议动作」(下一步=做什么),
|
||||
// 再回退原因文案(i18n_key / Gate 命名空间);禁止裸露内部原因码。
|
||||
const br = props.blockingReason;
|
||||
if (br) {
|
||||
const nextAction = String(br.nextAction || br.next_action || '').trim();
|
||||
const actionKey = nextAction
|
||||
? `workspace.shippingNotice.processGate.actionCodes.${nextAction}`
|
||||
: '';
|
||||
if (actionKey && te(actionKey)) return t(actionKey);
|
||||
const i18nKey = String(br.i18nKey || '').trim();
|
||||
if (i18nKey && te(i18nKey)) {
|
||||
return t(i18nKey);
|
||||
@@ -205,6 +216,15 @@ const showNextStep = computed(() => {
|
||||
return !['completed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
/**
|
||||
* 状态块内嵌动态说明的显隐:具体阻断原因已由「下一步」承载时,
|
||||
* Run 级泛化等待说明(如「当前步骤需要人工处理」)属纯重复,隐藏。
|
||||
*/
|
||||
const showStatusDetail = computed(() => {
|
||||
if (!props.statusDetail?.text) return false;
|
||||
return isGenericBlockingReason(props.blockingReason, te);
|
||||
});
|
||||
|
||||
/**
|
||||
* 判断当前工作台是否应隐藏后端下发的纯导航动作。
|
||||
* 批次中心可用它打开工作台;进入工作台后必须复用注册表规则,避免当前阶段再次显示
|
||||
@@ -382,13 +402,14 @@ type ReviewCurrentUserStatus =
|
||||
/>
|
||||
{{ statusLabel }}
|
||||
</dd>
|
||||
<!-- v2:状态块内嵌动态说明(弱文本一行,不加标题/图标/区块;显隐裁决在视图侧)。 -->
|
||||
<!-- v2:状态块内嵌动态说明(弱文本一行,不加标题/图标/区块;
|
||||
v4:blocking_reason 已含具体原因时隐藏,避免与「下一步」重复)。 -->
|
||||
<p
|
||||
v-if="statusDetail?.text"
|
||||
v-if="showStatusDetail"
|
||||
class="w-full text-[11px] leading-4 text-muted"
|
||||
data-testid="review-current-task-status-detail"
|
||||
aria-live="polite"
|
||||
>{{ statusDetail.text }}</p>
|
||||
>{{ statusDetail?.text }}</p>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
|
||||
+82
@@ -1184,4 +1184,86 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-10"]');
|
||||
expect(row.findAll('button')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('shows a specific blocking reason once per waiting-human card without header duplication', async () => {
|
||||
// v4 去重:具体原因由文件行页脚独家承载;任务卡头不再重复同一句。
|
||||
// ui_state 挂在任务条目上(与后端 EML 聚合下发形态一致:任务级为代表子项原因)。
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'waiting_human', [{
|
||||
user_task_no: 'OT-REASON-ONCE', group: 'waiting_human', status_label: 'pending_review',
|
||||
file_count: 1, run_no: 'RUN-REASON-ONCE', can_append: false,
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'customer_unresolved', message: '客户尚未确认' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-REASON', label: 'reason.pdf', filename: 'reason.pdf',
|
||||
document_id: 91, root_document_id: 91, status_label: 'pending_review',
|
||||
}],
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-REASON-ONCE', {
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'reason.pdf', documentId: 91,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-REASON',
|
||||
},
|
||||
status: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'customer_unresolved', message: '客户尚未确认' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 关键断言:具体原因全文只出现一次,且带「阻塞原因:」前缀落在文件行页脚。
|
||||
const matches = wrapper.text().match(/客户尚未确认/g) || [];
|
||||
expect(matches.length).toBe(1);
|
||||
expect(wrapper.text()).toContain('阻塞原因:客户尚未确认');
|
||||
});
|
||||
|
||||
it('hides the blocker line when the backend only provides a generic fallback reason', async () => {
|
||||
// v4:未知原因码不得渲染成「当前步骤需要人工处理」空话;状态芯片已表达待人工。
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'waiting_human', [{
|
||||
user_task_no: 'OT-REASON-GENERIC', group: 'waiting_human', status_label: 'pending_review',
|
||||
file_count: 1, run_no: 'RUN-REASON-GENERIC', can_append: false,
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-GENERIC', label: 'generic.pdf', filename: 'generic.pdf',
|
||||
document_id: 92, root_document_id: 92, status_label: 'pending_review',
|
||||
}],
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-REASON-GENERIC', {
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'generic.pdf', documentId: 92,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-GENERIC',
|
||||
},
|
||||
status: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'mystery_internal_code' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.text()).not.toContain('阻塞原因');
|
||||
expect(wrapper.text()).not.toContain('当前步骤需要人工处理');
|
||||
});
|
||||
});
|
||||
+16
-7
@@ -30,8 +30,8 @@ import {
|
||||
toggleTaskDetails,
|
||||
} from '@/features/chat/shipping/conversationProcessingState';
|
||||
import {
|
||||
resolveBlockingReasonText,
|
||||
resolveShippingProcessingMessage,
|
||||
resolveShippingProcessingReasonLabel,
|
||||
resolveShippingProcessingStageLabel,
|
||||
resolveShippingProcessingStatusLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
@@ -593,7 +593,8 @@ function workbenchFileReason(file: WorkbenchFileRow, task: ConversationProcessin
|
||||
const reason = file.projection.uiState
|
||||
? file.projection.uiState.blocking_reason
|
||||
: file.projection.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
// v4:具体原因才展示(Gate 命名空间/契约 message 可解析),通用兜底返回空串隐藏。
|
||||
return resolveBlockingReasonText(reason, te, t);
|
||||
}
|
||||
return taskReasonLabel(task);
|
||||
}
|
||||
@@ -686,12 +687,20 @@ function stageLabel(task: ConversationProcessingUserTask): string {
|
||||
return intakeStageLabel(projection);
|
||||
}
|
||||
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;i18n 仅负责翻译,不映射或猜测业务原因。 */
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;v4:具体原因才展示,通用兜底返回空串。 */
|
||||
function taskReasonLabel(task: ConversationProcessingUserTask): string {
|
||||
const reason = task.uiState
|
||||
? task.uiState.blocking_reason
|
||||
: task.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
return resolveBlockingReasonText(reason, te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务卡头原因行显隐:workbench 模式下文件行页脚已逐文件承载原因,
|
||||
* 卡头不再重复同一句;非 workbench(折叠聚合卡)仍由卡头独家展示。
|
||||
*/
|
||||
function taskHeaderReasonVisible(task: ConversationProcessingUserTask): boolean {
|
||||
return !props.workbenchMode || visibleWorkbenchFileRows(task).length === 0;
|
||||
}
|
||||
|
||||
/** 同一 EML 聚合卡状态计数;仅用后端下发的 aggregateSummary,不从 UI 状态推导。 */
|
||||
@@ -960,7 +969,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
{{ taskReasonLabel(task) }}
|
||||
</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">
|
||||
@@ -1056,7 +1065,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
<div v-if="!workbenchMode" 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>
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">{{ aggregateStatusLabel(task) }}</div>
|
||||
</button>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-amber-200/70 pt-2">
|
||||
@@ -1323,7 +1332,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
{{ taskReasonLabel(task) }}
|
||||
</div>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-emerald-200/70 pt-2">
|
||||
|
||||
Reference in new issue
Block a user