feat(shipping-notice): 落地 XFA 统一视觉拆分确认门禁与处理投影收敛
闭合拆分预览令牌单次消费、样本 checksum 绑定与确认审计;正式提取改为 bindings-only。 同步统一标注工作台交互,并补齐进度投影/任务中心与迁移文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
d2b3d74def
commit
84a881b554
195 files changed
+20269
-3463
No files matched your search
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/shipping-progress/actionPresentation.spec.ts
|
||||
* 用途:验收统一动作优先级与自动态空主按钮。
|
||||
* 用途:验收统一动作优先级、自动态空主按钮与 surface 过滤。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -74,4 +74,19 @@ describe('resolveProcessingActionPresentation', () => {
|
||||
expect(result.primary?.intent).toBe('retry');
|
||||
expect(result.primary?.actionCode).toBe('retry_parse');
|
||||
});
|
||||
|
||||
it('filters open_order_review on review surface', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
availableActions: ['open_order_review', 'refresh'],
|
||||
}), { surface: 'review' });
|
||||
expect(result.primary?.intent).toBe('refresh');
|
||||
expect(result.overflow.some((i) => i.intent === 'open_order_review')).toBe(false);
|
||||
});
|
||||
|
||||
it('maps open_order_review label to processing entry on chat surface', () => {
|
||||
const result = resolveProcessingActionPresentation(projection({
|
||||
availableActions: ['open_order_review'],
|
||||
}), { surface: 'chat' });
|
||||
expect(result.primary?.labelKey).toBe('chat.shippingProcessing.action.open_order_processing');
|
||||
});
|
||||
});
|
||||
@@ -3,33 +3,41 @@
|
||||
* 用途:从统一投影解析四页面共用的 ActionPresentation(主/次/溢出)。
|
||||
* 依赖:ShippingProcessingProjection、SHIPPING_PROCESSING_ACTION_INTENTS、types。
|
||||
* 逻辑:优先级 Gate.nextActionCode → availableActions → 终态查看 → none;
|
||||
* 自动处理中(processing/automating)主按钮为空,避免误导性 CTA。
|
||||
* 自动处理中(processing/automating)主按钮为空;review 面隐藏 open_order_review。
|
||||
*/
|
||||
|
||||
import type {
|
||||
ShippingProcessingActionIntent,
|
||||
ShippingProcessingProjection,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import type { ActionPresentation, ActionPresentationItem } from './types';
|
||||
import type { ActionPresentation, ActionPresentationItem, ActionPresentationSurface } from './types';
|
||||
|
||||
/** 可映射为统一意图的原始动作码(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',
|
||||
edit_formal_task: 'edit_formal_task',
|
||||
open_inventory_source_review: 'open_inventory_source_review',
|
||||
confirm_inventory_source: 'open_inventory_source_review',
|
||||
retry_resolve_inventory_source: 'open_inventory_source_review',
|
||||
open_inventory_match_review: 'open_inventory_match_review',
|
||||
rematch: 'open_inventory_match_review',
|
||||
match_inventory: 'open_inventory_match_review',
|
||||
open_shortage_review: 'open_shortage_review',
|
||||
upload_inventory_file: 'upload_inventory_file',
|
||||
retry: 'retry',
|
||||
retry_parse: 'retry',
|
||||
retry_failed_documents: 'retry',
|
||||
refresh: 'refresh',
|
||||
regenerate_excel: 'regenerate_excel',
|
||||
generate_excel: 'regenerate_excel',
|
||||
download_excel: 'download_excel',
|
||||
open_manual_upload: 'open_manual_upload',
|
||||
wait_manual_upload: 'open_manual_upload',
|
||||
mark_manual_uploaded: 'open_manual_upload',
|
||||
regenerate_manual_upload_todo: 'open_manual_upload',
|
||||
open_fulfillment: 'view_result',
|
||||
view_result: 'view_result',
|
||||
view_details: 'view_result',
|
||||
view_record: 'view_record',
|
||||
@@ -49,11 +57,22 @@ export function mapActionCodeToIntent(code: string | null | undefined): Shipping
|
||||
/**
|
||||
* 构建单个动作项。
|
||||
*/
|
||||
function toItem(code: string, intent: ShippingProcessingActionIntent): ActionPresentationItem {
|
||||
function toItem(
|
||||
code: string,
|
||||
intent: ShippingProcessingActionIntent,
|
||||
surface?: ActionPresentationSurface,
|
||||
): ActionPresentationItem {
|
||||
let labelKey = `chat.shippingProcessing.action.${intent}`;
|
||||
if (
|
||||
intent === 'open_order_review'
|
||||
&& (surface === 'chat' || surface === 'right')
|
||||
) {
|
||||
labelKey = 'chat.shippingProcessing.action.open_order_processing';
|
||||
}
|
||||
return {
|
||||
intent,
|
||||
actionCode: code,
|
||||
labelKey: `chat.shippingProcessing.action.${intent}`,
|
||||
labelKey,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -64,14 +83,17 @@ function toItem(code: string, intent: ShippingProcessingActionIntent): ActionPre
|
||||
* 1. processing/automating/queued → 主按钮为空(自动推进中);
|
||||
* 2. currentGate.nextActionCode 优先;
|
||||
* 3. availableActions 依次填主/次/溢出;
|
||||
* 4. completed/failed/cancelled → view_result / view_record 兜底。
|
||||
* 4. completed/failed/cancelled → view_result / view_record 兜底;
|
||||
* 5. surface=review 时过滤 open_order_review(已在复核页)。
|
||||
*/
|
||||
export function resolveProcessingActionPresentation(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
options?: { surface?: ActionPresentationSurface },
|
||||
): ActionPresentation {
|
||||
const empty: ActionPresentation = { primary: null, secondary: null, overflow: [] };
|
||||
if (!projection) return empty;
|
||||
|
||||
const surface = options?.surface;
|
||||
const status = String(projection.status || '').trim().toLowerCase();
|
||||
if (AUTOMATING_STATUSES.has(status) && !projection.currentGate?.nextActionCode) {
|
||||
return empty;
|
||||
@@ -87,8 +109,9 @@ export function resolveProcessingActionPresentation(
|
||||
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);
|
||||
items.push(toItem(code, intent));
|
||||
items.push(toItem(code, intent, surface));
|
||||
};
|
||||
|
||||
pushCode(projection.currentGate?.nextActionCode);
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
<!--
|
||||
features/shipping-progress/components/ChatProgressSummary.vue
|
||||
用途:对话气泡区文本型进度摘要——已完成/当前/阻断 + 主/次动作;默认无卡片网格。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、UnifiedActionBar、UnifiedProgressTrack。
|
||||
逻辑:由 ShippingOrderExtractionCard 挂载;展开后显示完整 UnifiedProgressTrack。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveShippingProcessingStatusLabel, shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressRangeHint, buildProgressWindow } from '../progressWindow';
|
||||
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
|
||||
import type { ActionPresentationItem } from '../types';
|
||||
import UnifiedActionBar from './UnifiedActionBar.vue';
|
||||
import UnifiedProgressTrack from './UnifiedProgressTrack.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
projection: ShippingProcessingProjection;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
action: [item: ActionPresentationItem];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const expanded = ref(false);
|
||||
|
||||
const projectionRef = computed(() => props.projection);
|
||||
const actionPresentation = useProcessingActionPresentation(projectionRef, { surface: 'chat' });
|
||||
const rangeHint = computed(() => buildProgressRangeHint(props.projection, 'chat'));
|
||||
const currentNodes = computed(() => buildProgressWindow(props.projection, 'chat'));
|
||||
|
||||
/**
|
||||
* 当前阶段中性名称。
|
||||
*/
|
||||
const currentStageLabel = computed(() => {
|
||||
const key = rangeHint.value?.currentLabelKey || shippingProcessingStageKey(props.projection.stage);
|
||||
return te(key) ? t(key) : props.projection.stage;
|
||||
});
|
||||
|
||||
/**
|
||||
* 状态 + 已完成摘要行。
|
||||
*/
|
||||
const summaryLine = computed(() => {
|
||||
const hint = rangeHint.value;
|
||||
if (!hint) return '';
|
||||
const completed = t('chat.shippingProcessing.progress.completedOfTotal', {
|
||||
done: hint.done,
|
||||
total: hint.total,
|
||||
});
|
||||
const current = t('chat.shippingProcessing.progress.currentStage', {
|
||||
stage: currentStageLabel.value,
|
||||
});
|
||||
return `${completed} · ${current}`;
|
||||
});
|
||||
|
||||
/**
|
||||
* Gate 阻断原因文案。
|
||||
*/
|
||||
const blockerLabel = computed(() => {
|
||||
const code = String(props.projection.currentGate?.blockingReasonCode || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `workspace.shippingNotice.workflowReasons.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
});
|
||||
|
||||
/**
|
||||
* 当前投影状态标签。
|
||||
*/
|
||||
const statusLabel = computed(() =>
|
||||
resolveShippingProcessingStatusLabel(props.projection.status, te, t),
|
||||
);
|
||||
|
||||
/**
|
||||
* 切换完整轨道展开。
|
||||
*/
|
||||
function toggleExpanded() {
|
||||
expanded.value = !expanded.value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="mt-2 rounded-lg border border-current/15 bg-black/5 px-2.5 py-2 text-xs dark:bg-white/5"
|
||||
data-testid="chat-progress-summary"
|
||||
>
|
||||
<div class="flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<span
|
||||
v-if="statusLabel"
|
||||
class="font-semibold"
|
||||
data-testid="chat-progress-status"
|
||||
>
|
||||
{{ statusLabel }}
|
||||
</span>
|
||||
<span
|
||||
v-if="summaryLine"
|
||||
class="opacity-90"
|
||||
data-testid="chat-progress-summary-line"
|
||||
>
|
||||
{{ summaryLine }}
|
||||
</span>
|
||||
</div>
|
||||
<p
|
||||
v-if="blockerLabel"
|
||||
class="mt-1 font-medium text-amber-800 dark:text-amber-200"
|
||||
data-testid="chat-progress-blocker"
|
||||
>
|
||||
{{ blockerLabel }}
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<UnifiedActionBar
|
||||
:presentation="actionPresentation"
|
||||
@action="(item) => emit('action', item)"
|
||||
/>
|
||||
</div>
|
||||
<button
|
||||
v-if="currentNodes.length"
|
||||
type="button"
|
||||
class="mt-2 text-[11px] font-medium underline-offset-2 hover:underline"
|
||||
data-testid="chat-progress-expand"
|
||||
@click="toggleExpanded"
|
||||
>
|
||||
{{ expanded
|
||||
? t('chat.shippingProcessing.collapseHistory')
|
||||
: t('chat.shippingProcessing.expandHistory') }}
|
||||
</button>
|
||||
<div
|
||||
v-if="expanded"
|
||||
class="mt-2"
|
||||
data-testid="chat-progress-full-track"
|
||||
>
|
||||
<UnifiedProgressTrack
|
||||
:projection="projection"
|
||||
density="chat"
|
||||
compact
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,217 @@
|
||||
<!--
|
||||
features/shipping-progress/components/ReviewProcessDetailDrawer.vue
|
||||
用途:订单处理工作台「流程详情」只读抽屉——完整 15 阶按五域分组。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、shippingProcessingLabels。
|
||||
逻辑:由 ShippingOrderReviewView 挂载;缺时间/主体显示「—」;禁止抽屉内写操作按钮。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
resolveShippingProcessingStatusLabel,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
REVIEW_PROGRESS_DOMAIN_RANGES,
|
||||
buildFullProgressNodes,
|
||||
buildProgressRangeHint,
|
||||
stageAbsoluteIndex,
|
||||
} from '../progressWindow';
|
||||
import type { ProgressWindowNode } from '../types';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
projection: ShippingProcessingProjection | null;
|
||||
/** 标题副文案:PO */
|
||||
poNumber?: string | null;
|
||||
/** 标题副文案:OT */
|
||||
orderTaskNo?: string | null;
|
||||
/** 有审计入口时展示只读链接 */
|
||||
auditAvailable?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
'open-audit': [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const nodes = computed(() => buildFullProgressNodes(props.projection));
|
||||
const rangeHint = computed(() => buildProgressRangeHint(props.projection, 'workbench'));
|
||||
|
||||
const statusLabel = computed(() => {
|
||||
if (!props.projection) return '';
|
||||
return resolveShippingProcessingStatusLabel(props.projection.status, te, t);
|
||||
});
|
||||
|
||||
const positionLabel = computed(() => {
|
||||
if (!props.projection) return '';
|
||||
const index = stageAbsoluteIndex(props.projection.stage) + 1;
|
||||
return t('chat.shippingProcessing.progress.positionOfTotal', { current: index, total: 15 });
|
||||
});
|
||||
|
||||
/**
|
||||
* 按五域分组的完整节点。
|
||||
*/
|
||||
const domainGroups = computed(() => (
|
||||
REVIEW_PROGRESS_DOMAIN_RANGES.map((domain) => ({
|
||||
key: domain.key,
|
||||
labelKey: domain.labelKey,
|
||||
nodes: nodes.value.filter((node) => (
|
||||
node.absoluteIndex >= domain.start && node.absoluteIndex <= domain.end
|
||||
)),
|
||||
}))
|
||||
));
|
||||
|
||||
/**
|
||||
* 阶段名。
|
||||
*/
|
||||
function nodeLabel(node: ProgressWindowNode): string {
|
||||
const key = shippingProcessingStageKey(node.stage);
|
||||
return te(key) ? t(key) : node.stage;
|
||||
}
|
||||
|
||||
/**
|
||||
* 节点态文案。
|
||||
*/
|
||||
function nodeStatusLabel(status: ProgressWindowNode['status']): string {
|
||||
const key = `chat.shippingProcessing.stageNode.${status}`;
|
||||
return te(key) ? t(key) : status;
|
||||
}
|
||||
|
||||
/**
|
||||
* 圆点样式。
|
||||
*/
|
||||
function dotClass(status: ProgressWindowNode['status']): string {
|
||||
if (status === 'passed') return 'bg-emerald-500';
|
||||
if (status === 'running') return 'bg-brand-500';
|
||||
if (status === 'blocked') return 'bg-amber-500';
|
||||
if (status === 'failed') return 'bg-rose-500';
|
||||
if (status === 'skipped') return 'bg-slate-200 opacity-50';
|
||||
return 'bg-slate-300';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex justify-end"
|
||||
data-testid="review-process-detail-drawer"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-slate-900/40"
|
||||
:aria-label="t('chat.shippingProcessing.progress.closeProcessDetails')"
|
||||
data-testid="review-process-detail-backdrop"
|
||||
@click="emit('close')"
|
||||
/>
|
||||
<aside
|
||||
class="relative z-10 flex h-full w-full max-w-md flex-col border-l border-default bg-surface shadow-xl"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('chat.shippingProcessing.progress.processDetailsTitle')"
|
||||
>
|
||||
<header class="flex items-start justify-between gap-3 border-b border-default px-4 py-3">
|
||||
<div class="min-w-0">
|
||||
<h2 class="text-sm font-semibold text-primary">
|
||||
{{ t('chat.shippingProcessing.progress.processDetailsTitle') }}
|
||||
</h2>
|
||||
<p class="mt-0.5 truncate text-[11px] text-secondary">
|
||||
<span v-if="poNumber">PO {{ poNumber }}</span>
|
||||
<span v-if="poNumber && orderTaskNo"> · </span>
|
||||
<span v-if="orderTaskNo">{{ orderTaskNo }}</span>
|
||||
</p>
|
||||
<p
|
||||
v-if="statusLabel || positionLabel"
|
||||
class="mt-1 text-[11px] text-muted"
|
||||
data-testid="review-process-detail-summary"
|
||||
>
|
||||
<span v-if="statusLabel">{{ statusLabel }}</span>
|
||||
<span v-if="statusLabel && positionLabel"> · </span>
|
||||
<span v-if="positionLabel">{{ positionLabel }}</span>
|
||||
<span v-if="rangeHint">
|
||||
· {{ t('chat.shippingProcessing.progress.completedOfTotal', {
|
||||
done: rangeHint.done,
|
||||
total: rangeHint.total,
|
||||
}) }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg p-1.5 text-muted hover:bg-surface-muted hover:text-primary"
|
||||
data-testid="review-process-detail-close"
|
||||
@click="emit('close')"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
</button>
|
||||
</header>
|
||||
|
||||
<div class="min-h-0 flex-1 overflow-y-auto px-4 py-3">
|
||||
<section
|
||||
v-for="group in domainGroups"
|
||||
:key="group.key"
|
||||
class="mb-4"
|
||||
:data-domain-group="group.key"
|
||||
>
|
||||
<h3 class="mb-2 text-[11px] font-semibold uppercase tracking-wide text-muted">
|
||||
{{ t(group.labelKey) }}
|
||||
</h3>
|
||||
<ol class="space-y-2">
|
||||
<li
|
||||
v-for="node in group.nodes"
|
||||
:key="node.stage"
|
||||
class="rounded-lg border border-default bg-surface-soft/50 px-2.5 py-2"
|
||||
:data-stage="node.stage"
|
||||
:data-state="node.status"
|
||||
:data-current="node.isCurrent ? 'true' : 'false'"
|
||||
data-testid="review-process-detail-node"
|
||||
>
|
||||
<div class="flex items-center gap-2 text-xs">
|
||||
<span
|
||||
class="inline-block h-2 w-2 shrink-0 rounded-full"
|
||||
:class="dotClass(node.status)"
|
||||
/>
|
||||
<span :class="node.isCurrent ? 'font-semibold text-primary' : 'text-secondary'">
|
||||
{{ nodeLabel(node) }}
|
||||
</span>
|
||||
<span class="ml-auto shrink-0 text-[10px] text-muted">
|
||||
{{ nodeStatusLabel(node.status) }}
|
||||
</span>
|
||||
</div>
|
||||
<dl class="mt-1.5 grid grid-cols-2 gap-x-2 gap-y-0.5 text-[10px] text-muted">
|
||||
<div>
|
||||
<dt class="inline">{{ t('chat.shippingProcessing.progress.nodeTime') }}</dt>
|
||||
<dd class="ml-1 inline">{{ t('chat.shippingProcessing.progress.placeholderDash') }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="inline">{{ t('chat.shippingProcessing.progress.nodeActor') }}</dt>
|
||||
<dd class="ml-1 inline">{{ t('chat.shippingProcessing.progress.placeholderDash') }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
v-if="auditAvailable"
|
||||
class="border-t border-default px-4 py-3"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="text-[11px] font-medium text-brand-700 underline-offset-2 hover:underline dark:text-brand-300"
|
||||
data-testid="review-process-detail-open-audit"
|
||||
@click="emit('open-audit')"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.viewFullAudit') }}
|
||||
</button>
|
||||
</footer>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -0,0 +1,145 @@
|
||||
<!--
|
||||
features/shipping-progress/components/ReviewProgressStrip.vue
|
||||
用途:订单处理工作台只读紧凑进度——五域摘要 + 当前节点 n/15 + 当前需要 + 打开流程详情。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、gateReasonLabel。
|
||||
逻辑:由 ReviewWorkflowProgressPanel 挂载;正文不展开 15 阶、不挂 ActionBar;写操作只在底部 Footer。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
buildProgressRangeHint,
|
||||
buildReviewProgressDomainSummary,
|
||||
stageAbsoluteIndex,
|
||||
} from '../progressWindow';
|
||||
import { resolveGateReasonLabel } from '../gateReasonLabel';
|
||||
import type { ProgressDomainState } from '../types';
|
||||
|
||||
const props = defineProps<{
|
||||
projection: ShippingProcessingProjection;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'open-process-details': [];
|
||||
refresh: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
|
||||
|
||||
const domains = computed(() => buildReviewProgressDomainSummary(props.projection));
|
||||
const rangeHint = computed(() => buildProgressRangeHint(props.projection, 'workbench'));
|
||||
|
||||
const isAutomating = computed(() => (
|
||||
AUTOMATING_STATUSES.has(String(props.projection.status || '').trim().toLowerCase())
|
||||
&& !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 })}`;
|
||||
});
|
||||
|
||||
/**
|
||||
* 当前需要:Gate 原因;自动推进中用系统文案。
|
||||
*/
|
||||
const currentNeed = computed(() => {
|
||||
if (isAutomating.value) {
|
||||
return t('chat.shippingProcessing.progress.systemProcessingNeed');
|
||||
}
|
||||
return resolveGateReasonLabel(
|
||||
props.projection.currentGate?.blockingReasonCode,
|
||||
{ t, te },
|
||||
);
|
||||
});
|
||||
|
||||
/**
|
||||
* 五域圆点样式。
|
||||
*/
|
||||
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';
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
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
|
||||
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"
|
||||
>
|
||||
<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) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-x-3 gap-y-1 text-[11px] text-secondary"
|
||||
data-testid="review-progress-range"
|
||||
>
|
||||
<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>
|
||||
|
||||
<p
|
||||
v-if="currentNeed"
|
||||
class="text-[11px] text-amber-800 dark:text-amber-200"
|
||||
data-testid="review-progress-current-need"
|
||||
>
|
||||
<span class="font-medium text-secondary">{{ t('chat.shippingProcessing.progress.currentNeedLabel') }}</span>
|
||||
{{ currentNeed }}
|
||||
</p>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default bg-surface px-2.5 py-1 text-[11px] font-medium text-brand-700 hover:bg-surface-muted dark:text-brand-300"
|
||||
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') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,83 @@
|
||||
<!--
|
||||
features/shipping-progress/components/SidebarProgressInline.vue
|
||||
用途:对话右侧紧凑进度行——● 当前阶段 · 第 x/total + Gate 原因 + 内联动作。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、UnifiedActionBar、gateReasonLabel。
|
||||
逻辑:由 ShippingConversationProcessingCard 仅在聚焦卡内嵌完整版;
|
||||
compact=true 时只显示单行阶段摘要,不渲染动作栏。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressRangeHint, stageAbsoluteIndex } from '../progressWindow';
|
||||
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
|
||||
import type { ActionPresentationItem } from '../types';
|
||||
import { resolveGateReasonLabel } from '../gateReasonLabel';
|
||||
import UnifiedActionBar from './UnifiedActionBar.vue';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
projection: ShippingProcessingProjection;
|
||||
/** 非聚焦卡:仅单行摘要,不展开节点与动作。 */
|
||||
compact?: boolean;
|
||||
}>(), {
|
||||
compact: false,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
action: [item: ActionPresentationItem];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const projectionRef = computed(() => props.projection);
|
||||
const actionPresentation = useProcessingActionPresentation(projectionRef, { surface: 'right' });
|
||||
const rangeHint = computed(() => buildProgressRangeHint(props.projection, 'right'));
|
||||
|
||||
/**
|
||||
* 紧凑单行:● 阶段名 · 第 x/total。
|
||||
*/
|
||||
const inlineLine = computed(() => {
|
||||
const hint = rangeHint.value;
|
||||
const stageKey = hint?.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 })}`;
|
||||
});
|
||||
|
||||
/**
|
||||
* Gate 阻断原因(禁止展示内部码)。
|
||||
*/
|
||||
const gateReason = computed(() => resolveGateReasonLabel(
|
||||
props.projection.currentGate?.blockingReasonCode,
|
||||
{ t, te },
|
||||
));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="space-y-1.5"
|
||||
data-testid="sidebar-progress-inline"
|
||||
:data-compact="compact ? '1' : '0'"
|
||||
>
|
||||
<div
|
||||
class="text-[11px] font-medium text-secondary"
|
||||
data-testid="sidebar-progress-line"
|
||||
>
|
||||
{{ inlineLine }}
|
||||
</div>
|
||||
<template v-if="!compact">
|
||||
<p
|
||||
v-if="gateReason"
|
||||
class="text-[11px] text-amber-800 dark:text-amber-200"
|
||||
data-testid="sidebar-progress-gate-reason"
|
||||
>
|
||||
{{ gateReason }}
|
||||
</p>
|
||||
<UnifiedActionBar
|
||||
:presentation="actionPresentation"
|
||||
@action="(item) => emit('action', item)"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,129 @@
|
||||
<!--
|
||||
features/shipping-progress/components/WorkbenchProgressGrouped.vue
|
||||
用途:任务台分组进度——解析 1–10 / 库存 11–12 / 履约 13–15 三域 + 当前阶段;可选动作栏。
|
||||
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、UnifiedProgressTrack、UnifiedActionBar。
|
||||
逻辑:由 ShippingTaskWorkbench 挂载;任务台履约动作归 TaskTodoPanel,默认关闭本组件动作栏(UI-05)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { buildProgressRangeHint, stageAbsoluteIndex } from '../progressWindow';
|
||||
import { useProcessingActionPresentation } from '../composables/useProcessingActionPresentation';
|
||||
import type { ActionPresentationItem } from '../types';
|
||||
import UnifiedActionBar from './UnifiedActionBar.vue';
|
||||
import UnifiedProgressTrack from './UnifiedProgressTrack.vue';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
projection: ShippingProcessingProjection;
|
||||
/** 是否渲染投影动作栏;任务台内嵌时应为 false,避免与 TaskTodoPanel 双入口。 */
|
||||
showActions?: boolean;
|
||||
}>(), {
|
||||
showActions: true,
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
action: [item: ActionPresentationItem];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
const showDetailTrack = ref(false);
|
||||
|
||||
const projectionRef = computed(() => props.projection);
|
||||
const actionPresentation = useProcessingActionPresentation(projectionRef, { surface: 'workbench' });
|
||||
const rangeHint = computed(() => buildProgressRangeHint(props.projection, 'workbench'));
|
||||
|
||||
/** 三域阶段下标区间(0-based,含端点)。 */
|
||||
const DOMAIN_RANGES = [
|
||||
{ key: 'intake', labelKey: 'chat.shippingProcessing.progress.domainIntake', start: 0, end: 9 },
|
||||
{ key: 'inventory', labelKey: 'chat.shippingProcessing.progress.domainInventory', start: 10, end: 11 },
|
||||
{ key: 'fulfillment', labelKey: 'chat.shippingProcessing.progress.domainFulfillment', start: 12, end: 14 },
|
||||
] as const;
|
||||
|
||||
const currentIndex = computed(() => stageAbsoluteIndex(props.projection.stage));
|
||||
|
||||
/**
|
||||
* 判断某域是否为当前/已过/未到。
|
||||
*/
|
||||
function domainState(start: number, end: number): 'passed' | 'current' | 'pending' {
|
||||
const idx = currentIndex.value;
|
||||
if (idx > end) return 'passed';
|
||||
if (idx >= start && idx <= end) return 'current';
|
||||
return 'pending';
|
||||
}
|
||||
|
||||
/**
|
||||
* 域标签样式。
|
||||
*/
|
||||
function domainClass(state: 'passed' | 'current' | 'pending'): string {
|
||||
if (state === 'passed') return 'border-emerald-200 bg-emerald-50 text-emerald-800';
|
||||
if (state === 'current') return 'border-brand-300 bg-brand-50 text-brand-800';
|
||||
return 'border-default bg-surface text-muted';
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前阶段中性名称。
|
||||
*/
|
||||
const currentStageLabel = computed(() => {
|
||||
const key = rangeHint.value?.currentLabelKey || shippingProcessingStageKey(props.projection.stage);
|
||||
return te(key) ? t(key) : props.projection.stage;
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="space-y-3"
|
||||
data-testid="workbench-progress-grouped"
|
||||
>
|
||||
<div
|
||||
v-if="rangeHint"
|
||||
class="text-xs text-secondary"
|
||||
data-testid="workbench-progress-range"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.progress.completedOfTotal', {
|
||||
done: rangeHint.done,
|
||||
total: rangeHint.total,
|
||||
}) }}
|
||||
·
|
||||
{{ t('chat.shippingProcessing.progress.currentStage', { stage: currentStageLabel }) }}
|
||||
</div>
|
||||
|
||||
<div class="grid gap-2 sm:grid-cols-3">
|
||||
<div
|
||||
v-for="domain in DOMAIN_RANGES"
|
||||
:key="domain.key"
|
||||
class="rounded-xl border px-3 py-2 text-xs font-semibold"
|
||||
:class="domainClass(domainState(domain.start, domain.end))"
|
||||
:data-domain="domain.key"
|
||||
:data-state="domainState(domain.start, domain.end)"
|
||||
>
|
||||
{{ te(domain.labelKey) ? t(domain.labelKey) : domain.key }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<UnifiedActionBar
|
||||
v-if="showActions"
|
||||
:presentation="actionPresentation"
|
||||
data-testid="workbench-progress-action-bar"
|
||||
@action="(item) => emit('action', item)"
|
||||
/>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="text-xs font-medium text-brand-700 underline-offset-2 hover:underline dark:text-brand-300"
|
||||
data-testid="workbench-progress-toggle-detail"
|
||||
@click="showDetailTrack = !showDetailTrack"
|
||||
>
|
||||
{{ showDetailTrack
|
||||
? t('chat.shippingProcessing.collapseHistory')
|
||||
: t('chat.shippingProcessing.expandHistory') }}
|
||||
</button>
|
||||
|
||||
<UnifiedProgressTrack
|
||||
v-if="showDetailTrack"
|
||||
:projection="projection"
|
||||
density="workbench"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* features/shipping-progress/components/presenters.spec.ts
|
||||
* 用途:四页面进度 Presenter 冒烟挂载。
|
||||
*/
|
||||
|
||||
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 ChatProgressSummary from './ChatProgressSummary.vue';
|
||||
import SidebarProgressInline from './SidebarProgressInline.vue';
|
||||
import ReviewProgressStrip from './ReviewProgressStrip.vue';
|
||||
import ReviewProcessDetailDrawer from './ReviewProcessDetailDrawer.vue';
|
||||
import WorkbenchProgressGrouped from './WorkbenchProgressGrouped.vue';
|
||||
|
||||
function sampleProjection(): ShippingProcessingProjection {
|
||||
return {
|
||||
workItemType: 'order_task',
|
||||
workItemNo: 'OT-1',
|
||||
sourceType: 'eml',
|
||||
rootOrderTaskNo: 'OT-1',
|
||||
shippingNoticeNo: null,
|
||||
conversationId: 'c1',
|
||||
submissionNo: 'SOS-1',
|
||||
intakeNo: 'SNI-1',
|
||||
status: 'blocked',
|
||||
stage: 'waiting_review',
|
||||
progressVersion: 1,
|
||||
lastActivityAt: '2026-08-05T00:00:00Z',
|
||||
currentGate: {
|
||||
gateCode: 'order_review',
|
||||
status: 'blocked',
|
||||
nextActionCode: 'open_order_review',
|
||||
blockingReasonCode: 'review_required',
|
||||
attemptNo: 1,
|
||||
},
|
||||
availableActions: ['open_order_review', 'refresh'],
|
||||
sourceSummary: {
|
||||
emailSubject: null,
|
||||
filename: 'a.pdf',
|
||||
documentCount: 1,
|
||||
parsedDocumentCount: 1,
|
||||
candidateCount: 1,
|
||||
customerName: null,
|
||||
poNumber: null,
|
||||
},
|
||||
childOrderTasks: [],
|
||||
};
|
||||
}
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingProcessing: {
|
||||
stage: { waiting_review: '订单复核' },
|
||||
status: { blocked: '已阻断' },
|
||||
progress: {
|
||||
completedOfTotal: '已完成 {done} / {total}',
|
||||
currentStage: '当前:{stage}',
|
||||
remainingHint: '后续还有 {count} 个阶段',
|
||||
positionOfTotal: '第 {current} / {total}',
|
||||
domainIntake: '解析与复核',
|
||||
domainInventory: '库存',
|
||||
domainFulfillment: '履约与上传',
|
||||
domainReceiveParse: '接收与解析',
|
||||
domainCandidateIdentity: '候选识别',
|
||||
domainOrderConfirm: '订单确认',
|
||||
domainInventoryHandle: '库存处理',
|
||||
domainFulfillmentShip: '发货履约',
|
||||
currentNeedLabel: '当前需要:',
|
||||
systemProcessingNeed: '系统处理中',
|
||||
viewProcessDetails: '查看流程详情',
|
||||
closeProcessDetails: '关闭',
|
||||
processDetailsTitle: '流程详情',
|
||||
nodeTime: '时间',
|
||||
nodeActor: '主体',
|
||||
placeholderDash: '—',
|
||||
viewFullAudit: '审计',
|
||||
},
|
||||
stageNode: {
|
||||
skipped: '已跳过',
|
||||
pending: '未开始',
|
||||
running: '进行中',
|
||||
passed: '已通过',
|
||||
blocked: '已阻断',
|
||||
failed: '失败',
|
||||
},
|
||||
gateReasons: {
|
||||
generic: '需要人工',
|
||||
review_required: '需要复核',
|
||||
},
|
||||
action: {
|
||||
open_order_review: '进入复核',
|
||||
open_order_processing: '进入订单处理',
|
||||
refresh: '刷新进度',
|
||||
more: '更多',
|
||||
},
|
||||
expandHistory: '展开',
|
||||
collapseHistory: '收起',
|
||||
panelTitle: '当前货代处理',
|
||||
},
|
||||
},
|
||||
workspace: {
|
||||
shippingNotice: {
|
||||
workflowReasons: { review_required: '需要复核' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
describe('shipping progress presenters', () => {
|
||||
const projection = sampleProjection();
|
||||
|
||||
it('mounts ChatProgressSummary', () => {
|
||||
const wrapper = mount(ChatProgressSummary, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="chat-progress-summary"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('mounts SidebarProgressInline', () => {
|
||||
const wrapper = mount(SidebarProgressInline, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="sidebar-progress-inline"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('mounts ReviewProgressStrip as compact five-domain 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);
|
||||
// 正文不得再挂 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: {
|
||||
open: true,
|
||||
projection,
|
||||
poNumber: 'PO-1',
|
||||
orderTaskNo: 'OT-1',
|
||||
},
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: { Teleport: { template: '<div><slot /></div>' } },
|
||||
},
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-process-detail-drawer"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-testid="review-process-detail-node"]').length).toBe(15);
|
||||
expect(wrapper.text()).toContain('—');
|
||||
expect(wrapper.text()).not.toContain('重新处理');
|
||||
});
|
||||
|
||||
it('mounts WorkbenchProgressGrouped with domain groups', () => {
|
||||
const wrapper = mount(WorkbenchProgressGrouped, {
|
||||
props: { projection },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="workbench-progress-grouped"]').exists()).toBe(true);
|
||||
expect(wrapper.findAll('[data-domain]').length).toBe(3);
|
||||
});
|
||||
});
|
||||
+15
-4
@@ -2,20 +2,31 @@
|
||||
* features/shipping-progress/composables/useProcessingActionPresentation.ts
|
||||
* 用途:包装 resolveProcessingActionPresentation,供 Vue 组件消费。
|
||||
* 依赖:vue computed、actionPresentation、ShippingProcessingProjection。
|
||||
* 逻辑:投影变化时重算;页面禁止自行按 status/stage 拼按钮。
|
||||
* 逻辑:投影变化时重算;页面禁止自行按 status/stage 拼按钮;可选 surface 过滤同页动作。
|
||||
*/
|
||||
|
||||
import { computed, type ComputedRef, type Ref } from 'vue';
|
||||
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 } from '../types';
|
||||
import type { ActionPresentation, ActionPresentationSurface } from '../types';
|
||||
|
||||
export interface UseProcessingActionPresentationOptions {
|
||||
surface?: ActionPresentationSurface;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从投影 ref 得到响应式 ActionPresentation。
|
||||
*
|
||||
* @param projection - 统一投影 ref
|
||||
* @param options - 可选 surface(chat/right/review/workbench)
|
||||
*/
|
||||
export function useProcessingActionPresentation(
|
||||
projection: Ref<ShippingProcessingProjection | null | undefined>
|
||||
| ComputedRef<ShippingProcessingProjection | null | undefined>,
|
||||
options?: MaybeRef<UseProcessingActionPresentationOptions | undefined>,
|
||||
): ComputedRef<ActionPresentation> {
|
||||
return computed(() => resolveProcessingActionPresentation(projection.value));
|
||||
return computed(() => resolveProcessingActionPresentation(
|
||||
projection.value,
|
||||
unref(options),
|
||||
));
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* features/shipping-progress/gateReasonLabel.ts
|
||||
* 用途:将 Gate blockingReasonCode 解析为用户可读文案,禁止界面直接暴露内部码。
|
||||
* 依赖:vue-i18n TranslateResult 兼容的 t/te 函数。
|
||||
* 逻辑:优先 chat.shippingProcessing.gateReasons.* → workspace.shippingNotice.workflowReasons.*
|
||||
* → 通用兜底;永不回退为原始 code。
|
||||
*/
|
||||
|
||||
export type GateReasonI18n = {
|
||||
t: (key: string, values?: Record<string, unknown>) => string;
|
||||
te: (key: string) => boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* 解析 Gate 阻断原因文案。
|
||||
*
|
||||
* 核心逻辑:多命名空间查找;未命中时返回「需要人工处理」类兜底,禁止展示内部码。
|
||||
*
|
||||
* @param code - blockingReasonCode
|
||||
* @param i18n - t / te
|
||||
* @returns 用户可读文案;无 code 时空串
|
||||
*/
|
||||
export function resolveGateReasonLabel(
|
||||
code: string | null | undefined,
|
||||
i18n: GateReasonI18n,
|
||||
): string {
|
||||
const normalized = String(code || '').trim();
|
||||
if (!normalized) return '';
|
||||
const keys = [
|
||||
`chat.shippingProcessing.gateReasons.${normalized}`,
|
||||
`workspace.shippingNotice.workflowReasons.${normalized}`,
|
||||
];
|
||||
for (const key of keys) {
|
||||
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');
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
/**
|
||||
* features/shipping-progress/progressWindow.spec.ts
|
||||
* 用途:验收密度窗口切分与节点态推导。
|
||||
* 用途:验收密度窗口切分、stageNodes 优先与范围摘要。
|
||||
*/
|
||||
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingProcessingProjection } from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
buildProgressRangeHint,
|
||||
buildProgressWindow,
|
||||
buildReviewProgressDomainSummary,
|
||||
computeProgressWindowRange,
|
||||
resolveStageNodeStatus,
|
||||
stageAbsoluteIndex,
|
||||
@@ -80,4 +82,40 @@ describe('progressWindow', () => {
|
||||
expect(start).toBeLessThanOrEqual(7);
|
||||
expect(end).toBeGreaterThan(7);
|
||||
});
|
||||
|
||||
it('prefers backend stageNodes status over index heuristic', () => {
|
||||
const nodes = buildProgressWindow(baseProjection({
|
||||
stage: 'inventory_source_resolving',
|
||||
status: 'processing',
|
||||
stageNodes: [
|
||||
{ stage: 'upload_received', absoluteIndex: 0, status: 'passed' },
|
||||
{ stage: 'inventory_source_resolving', absoluteIndex: 7, status: 'failed' },
|
||||
],
|
||||
}), 'workbench');
|
||||
expect(nodes[7]?.status).toBe('failed');
|
||||
});
|
||||
|
||||
it('buildProgressRangeHint returns done/total and current label key', () => {
|
||||
const hint = buildProgressRangeHint(baseProjection({
|
||||
stage: 'waiting_review',
|
||||
status: 'waiting_review',
|
||||
}), 'review');
|
||||
expect(hint).not.toBeNull();
|
||||
expect(hint!.currentLabelKey).toBe('chat.shippingProcessing.stage.waiting_review');
|
||||
expect(hint!.total).toBeGreaterThan(0);
|
||||
expect(hint!.done).toBeGreaterThanOrEqual(0);
|
||||
});
|
||||
|
||||
it('buildReviewProgressDomainSummary maps waiting_review into order_confirm blocked', () => {
|
||||
const domains = buildReviewProgressDomainSummary(baseProjection({
|
||||
stage: 'waiting_review',
|
||||
status: 'blocked',
|
||||
}));
|
||||
expect(domains).toHaveLength(5);
|
||||
expect(domains[0]?.state).toBe('passed');
|
||||
expect(domains[1]?.state).toBe('passed');
|
||||
expect(domains[2]?.key).toBe('order_confirm');
|
||||
expect(domains[2]?.state).toBe('blocked');
|
||||
expect(domains[3]?.state).toBe('pending');
|
||||
});
|
||||
});
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/shipping-progress/progressWindow.ts
|
||||
* 用途:按密度从 15 阶中切出可见进度窗口,并推导节点执行态。
|
||||
* 依赖:SHIPPING_PROCESSING_STAGES / EML_ONLY / types ProgressDensity。
|
||||
* 逻辑:锚点为当前 stage;紧凑模式折叠窗口外节点与边缘 skipped;workbench 展示全 15 阶。
|
||||
* 用途:按密度从 15 阶中切出可见进度窗口,推导节点执行态,并提供订单台五域摘要。
|
||||
* 依赖:SHIPPING_PROCESSING_STAGES / EML_ONLY / types ProgressDensity·ProgressDomain*、shippingProcessingLabels。
|
||||
* 逻辑:锚点为当前 stage;stageNodes 优先;workbench=全 15 阶;五域供 ReviewProgressStrip 紧凑条。
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -14,12 +14,25 @@ import {
|
||||
type ShippingProcessingStageNodeStatus,
|
||||
type ShippingProcessingStatus,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
PROGRESS_DENSITY_WINDOW_SIZE,
|
||||
type ProgressDensity,
|
||||
type ProgressDomainState,
|
||||
type ProgressDomainSummaryItem,
|
||||
type ProgressRangeHint,
|
||||
type ProgressWindowNode,
|
||||
} from './types';
|
||||
|
||||
/** 订单处理工作台五域(0-based 含端点,对齐 15 阶)。 */
|
||||
export const REVIEW_PROGRESS_DOMAIN_RANGES = [
|
||||
{ key: 'receive_parse', labelKey: 'chat.shippingProcessing.progress.domainReceiveParse', start: 0, end: 2 },
|
||||
{ key: 'candidate_identity', labelKey: 'chat.shippingProcessing.progress.domainCandidateIdentity', start: 3, end: 7 },
|
||||
{ key: 'order_confirm', labelKey: 'chat.shippingProcessing.progress.domainOrderConfirm', start: 8, end: 9 },
|
||||
{ key: 'inventory', labelKey: 'chat.shippingProcessing.progress.domainInventoryHandle', start: 10, end: 11 },
|
||||
{ key: 'fulfillment', labelKey: 'chat.shippingProcessing.progress.domainFulfillmentShip', start: 12, end: 14 },
|
||||
] as const;
|
||||
|
||||
/**
|
||||
* 返回 stage 在 15 阶中的下标;未知码回退 0。
|
||||
*/
|
||||
@@ -29,10 +42,26 @@ export function stageAbsoluteIndex(stage: string | null | undefined): number {
|
||||
return idx >= 0 ? idx : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从投影 stageNodes 查找指定阶的后端权威态。
|
||||
*/
|
||||
function resolveBackendNodeStatus(
|
||||
projection: ShippingProcessingProjection,
|
||||
stage: ShippingProcessingStage,
|
||||
absoluteIndex: number,
|
||||
): ShippingProcessingStageNodeStatus | null {
|
||||
const nodes = projection.stageNodes;
|
||||
if (!nodes?.length) return null;
|
||||
const matched = nodes.find((node) => (
|
||||
node.stage === stage || node.absoluteIndex === absoluteIndex
|
||||
));
|
||||
return matched?.status ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 推导单个节点执行态。
|
||||
*
|
||||
* 核心逻辑:direct_pdf 的 EML 专属阶 → skipped;当前阶按投影 status 映射;
|
||||
* 核心逻辑:stageNodes 优先;direct_pdf 的 EML 专属阶 → skipped;当前阶按投影 status 映射;
|
||||
* 已过阶 → passed;未到 → pending;失败/阻断仅落在当前阶。
|
||||
*/
|
||||
export function resolveStageNodeStatus(options: {
|
||||
@@ -41,7 +70,9 @@ export function resolveStageNodeStatus(options: {
|
||||
projectionStatus: ShippingProcessingStatus | string | null | undefined;
|
||||
sourceType?: OrderIntakeSourceType | string | null;
|
||||
stage: ShippingProcessingStage;
|
||||
backendStatus?: ShippingProcessingStageNodeStatus | null;
|
||||
}): ShippingProcessingStageNodeStatus {
|
||||
if (options.backendStatus) return options.backendStatus;
|
||||
const source = String(options.sourceType || '').trim().toLowerCase();
|
||||
if (source === 'direct_pdf' && EML_ONLY_PROCESSING_STAGES.has(options.stage)) {
|
||||
return 'skipped';
|
||||
@@ -77,6 +108,25 @@ export function computeProgressWindowRange(
|
||||
return { start, end };
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析单阶节点态(供窗口与范围摘要共用)。
|
||||
*/
|
||||
function resolveProjectionStageStatus(
|
||||
projection: ShippingProcessingProjection,
|
||||
stage: ShippingProcessingStage,
|
||||
absoluteIndex: number,
|
||||
currentIndex: number,
|
||||
): ShippingProcessingStageNodeStatus {
|
||||
return resolveStageNodeStatus({
|
||||
absoluteIndex,
|
||||
currentIndex,
|
||||
projectionStatus: projection.status,
|
||||
sourceType: projection.sourceType,
|
||||
stage,
|
||||
backendStatus: resolveBackendNodeStatus(projection, stage, absoluteIndex),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 从统一投影构建密度窗口节点列表。
|
||||
*
|
||||
@@ -90,7 +140,6 @@ export function buildProgressWindow(
|
||||
if (!projection) return [];
|
||||
const currentIndex = stageAbsoluteIndex(projection.stage);
|
||||
const { start, end } = computeProgressWindowRange(currentIndex, density);
|
||||
const sourceType = projection.sourceType || null;
|
||||
const nodes: ProgressWindowNode[] = [];
|
||||
for (let i = start; i < end; i += 1) {
|
||||
const stage = SHIPPING_PROCESSING_STAGES[i]!;
|
||||
@@ -98,13 +147,7 @@ export function buildProgressWindow(
|
||||
stage,
|
||||
absoluteIndex: i,
|
||||
isCurrent: i === currentIndex,
|
||||
status: resolveStageNodeStatus({
|
||||
absoluteIndex: i,
|
||||
currentIndex,
|
||||
projectionStatus: projection.status,
|
||||
sourceType,
|
||||
stage,
|
||||
}),
|
||||
status: resolveProjectionStageStatus(projection, stage, i, currentIndex),
|
||||
});
|
||||
}
|
||||
// 紧凑模式:去掉窗口两端连续 skipped,避免空白占位。
|
||||
@@ -114,3 +157,77 @@ export function buildProgressWindow(
|
||||
}
|
||||
return nodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建进度范围摘要(已完成 n/total、当前阶段键、窗口外剩余阶数)。
|
||||
*
|
||||
* @param projection - 统一投影
|
||||
* @param density - 页面密度(决定 hiddenAfter 计算窗口)
|
||||
* @returns 摘要 DTO;无投影时 null
|
||||
*/
|
||||
export function buildProgressRangeHint(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
density: ProgressDensity,
|
||||
): ProgressRangeHint | null {
|
||||
if (!projection) return null;
|
||||
const currentIndex = stageAbsoluteIndex(projection.stage);
|
||||
let done = 0;
|
||||
let total = 0;
|
||||
for (let i = 0; i < SHIPPING_PROCESSING_STAGES.length; i += 1) {
|
||||
const stage = SHIPPING_PROCESSING_STAGES[i]!;
|
||||
const status = resolveProjectionStageStatus(projection, stage, i, currentIndex);
|
||||
if (status === 'skipped') continue;
|
||||
total += 1;
|
||||
if (status === 'passed') done += 1;
|
||||
}
|
||||
const { end } = computeProgressWindowRange(currentIndex, density);
|
||||
const hiddenAfter = Math.max(0, SHIPPING_PROCESSING_STAGES.length - end);
|
||||
return {
|
||||
done,
|
||||
total,
|
||||
currentLabelKey: shippingProcessingStageKey(projection.stage),
|
||||
hiddenAfter,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建订单处理工作台五域摘要(默认紧凑条用,非完整 15 阶)。
|
||||
*
|
||||
* 核心逻辑:当前索引落在域内 → current/blocked/failed;整域已过 → passed;否则 pending。
|
||||
*/
|
||||
export function buildReviewProgressDomainSummary(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
): 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) {
|
||||
state = 'passed';
|
||||
} else if (currentIndex >= domain.start && currentIndex <= domain.end) {
|
||||
if (statusNorm === 'failed' || statusNorm === 'cancelled') state = 'failed';
|
||||
else if (statusNorm === 'blocked' || statusNorm === 'waiting_review' || statusNorm === 'needs_action') {
|
||||
state = 'blocked';
|
||||
} else {
|
||||
state = 'current';
|
||||
}
|
||||
}
|
||||
return {
|
||||
key: domain.key,
|
||||
labelKey: domain.labelKey,
|
||||
start: domain.start,
|
||||
end: domain.end,
|
||||
state,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建完整 15 阶窗口(流程详情抽屉专用)。
|
||||
*/
|
||||
export function buildFullProgressNodes(
|
||||
projection: ShippingProcessingProjection | null | undefined,
|
||||
): ProgressWindowNode[] {
|
||||
return buildProgressWindow(projection, 'workbench');
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/shipping-progress/types.ts
|
||||
* 用途:统一进度轨道与动作栏的前端 DTO(密度、窗口节点、ActionPresentation)。
|
||||
* 用途:统一进度轨道与动作栏的前端 DTO(密度、窗口节点、五域摘要、ActionPresentation)。
|
||||
* 依赖:shipping.api.types 的 Stage / StageNodeStatus / ActionIntent。
|
||||
* 逻辑:供 progressWindow / actionPresentation / Unified* 组件共用;禁止页面私自发明状态码。
|
||||
* 逻辑:供 progressWindow / actionPresentation / Unified* / ReviewProgressStrip 共用;禁止页面私自发明状态码。
|
||||
*/
|
||||
|
||||
import type {
|
||||
@@ -47,3 +47,26 @@ export interface ActionPresentation {
|
||||
secondary: ActionPresentationItem | null;
|
||||
overflow: ActionPresentationItem[];
|
||||
}
|
||||
|
||||
/** 动作栏页面上下文(UI-07:同页隐藏冗余 intent)。 */
|
||||
export type ActionPresentationSurface = 'chat' | 'right' | 'review' | 'workbench';
|
||||
|
||||
/** 进度范围摘要(UI-03:已完成 n/total + 剩余提示)。 */
|
||||
export interface ProgressRangeHint {
|
||||
done: number;
|
||||
total: number;
|
||||
currentLabelKey: string;
|
||||
hiddenAfter: number;
|
||||
}
|
||||
|
||||
/** 订单处理工作台五域摘要状态。 */
|
||||
export type ProgressDomainState = 'passed' | 'current' | 'pending' | 'blocked' | 'failed';
|
||||
|
||||
/** 订单处理工作台五域摘要项。 */
|
||||
export interface ProgressDomainSummaryItem {
|
||||
key: string;
|
||||
labelKey: string;
|
||||
start: number;
|
||||
end: number;
|
||||
state: ProgressDomainState;
|
||||
}
|
||||
Reference in new issue
Block a user