feat(shipping-notice): 收敛复核阶段同源投影与 OT 后履约推进

统一 Case/Progress 阶段 label_key、修复 Job 成功未推进 OT 的可重试失败投影与写路径,并落地 OT 后行级匹配/波次履约与版面诊断开关。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
hugoandCursor committed 2026-08-07 13:11:14 +08:00
1 parent 74270adc22
commit fd6a23f870
100 files changed
+12138 -1017

No files matched your search

@@ -0,0 +1,58 @@
<!--
features/chat/components/shipping-review/ReviewCompletedChecksPanel.vue
用途:右侧「已完成检查」折叠列表;仅消费后端 completed_checks。
依赖:vue-i18n。
逻辑:默认折叠;禁止前端自行拼接 Gate/里程碑。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
export interface CompletedCheckItem {
code: string;
status?: string;
completed_at?: string | null;
}
const props = defineProps<{
items?: CompletedCheckItem[] | null;
defaultOpen?: boolean;
}>();
const { t, te } = useI18n();
const checks = computed(() => (props.items || []).filter((item) => String(item.status || 'passed') === 'passed'));
const visible = computed(() => checks.value.length > 0);
/**
* 检查项本地化标签。
*/
function checkLabel(code: string): string {
const key = `chat.shippingOrderReview.completedChecks.codes.${code}`;
return te(key) ? t(key) : code;
}
</script>
<template>
<details
v-if="visible"
class="rounded-xl border border-slate-200 bg-white p-2 text-xs dark:border-slate-800 dark:bg-slate-900"
:open="defaultOpen"
data-testid="review-completed-checks"
>
<summary class="cursor-pointer px-1 py-1 font-medium text-muted">
{{ t('chat.shippingOrderReview.completedChecks.title', { count: checks.length }) }}
</summary>
<ul class="mt-2 space-y-1 px-1 pb-1">
<li
v-for="item in checks"
:key="item.code"
class="flex items-center gap-2 text-[11px] text-secondary"
:data-testid="`review-completed-check-${item.code}`"
>
<span class="text-emerald-600 dark:text-emerald-400" aria-hidden="true">✓</span>
<span>{{ checkLabel(item.code) }}</span>
</li>
</ul>
</details>
</template>
@@ -0,0 +1,155 @@
<!--
features/chat/components/shipping-review/ReviewCurrentProcessingCard.vue
用途:正式 OT 创建后的右侧「当前处理状态」主卡(阶段 + 自动推进合并)。
依赖:vue-i18n、ShippingOrderReviewAutomation、resolveShippingProcessingStageLabel。
逻辑:优先消费 Progress 同源的 stageCode + stageLabelKey;Case current_stage 仅降级;
禁止把阶段码直接当用户文案;Job 明细与 task_missing 诊断仅管理员区;
由 ShippingOrderReviewView 在 has_formal_ot / task_missing 时置顶渲染。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewAutomation } from '@/features/chat/types/shipping.api.types';
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
const props = defineProps<{
stageCode?: string | null;
stageLabelKey?: string | null;
stageInconsistent?: boolean;
taskMissing?: boolean;
taskNo?: string | null;
confirmedTaskId?: number | null;
showAdminDiagnosis?: boolean;
automation?: ShippingOrderReviewAutomation | null;
showRetry?: boolean;
retrying?: boolean;
}>();
const emit = defineEmits<{
retry: [];
}>();
const { t, te } = useI18n();
/**
* 当前处理阶段展示文案:消费 label_key,禁止直接展示阶段码。
*/
const stageLabel = computed(() => {
if (props.taskMissing) {
return t('chat.shippingOrderReview.currentProcessing.taskMissing');
}
if (props.stageInconsistent) {
return t('chat.shippingOrderReview.currentProcessing.stateInconsistent');
}
return resolveShippingProcessingStageLabel(
String(props.stageCode || ''),
te,
t,
props.stageLabelKey,
);
});
/**
* 自动推进用户态文案(消费 phase,禁止前端猜建单/推进)。
*/
const statusLabel = computed(() => {
const automation = props.automation;
const status = String(automation?.status || '').trim().toLowerCase();
const phase = String(automation?.phase || '').trim();
if (props.taskMissing) {
return t('chat.shippingOrderReview.currentProcessing.statusTaskMissing');
}
if (status === 'waiting_to_start') {
return phase === 'pre_ot_stp'
? t('chat.shippingOrderReview.automation.waitingPreOt')
: t('chat.shippingOrderReview.automation.waitingPostOt');
}
if (status === 'queued' || status === 'running') {
return t('chat.shippingOrderReview.currentProcessing.statusRunning');
}
if (status === 'failed' || status === 'manual_fallback') {
return t('chat.shippingOrderReview.currentProcessing.statusFailedRetryable');
}
if (status === 'completed') {
return t('chat.shippingOrderReview.currentProcessing.statusCompleted');
}
return t('chat.shippingOrderReview.currentProcessing.statusIdle');
});
/**
* 主卡重试:仅在有 task_no 且非 task_missing 时由父组件控制 showRetry。
*/
const canShowRetry = computed(() => (
Boolean(props.showRetry)
&& !props.taskMissing
&& Boolean(String(props.taskNo || '').trim())
));
</script>
<template>
<section
class="rounded-xl border border-sky-200 bg-sky-50/80 p-3 shadow-sm dark:border-sky-900 dark:bg-sky-950/30"
data-testid="review-current-processing-card"
:data-task-missing="taskMissing ? '1' : '0'"
:data-automation-status="String(automation?.status || '')"
:data-automation-phase="String(automation?.phase || '')"
>
<header class="mb-2">
<h2 class="text-sm font-semibold text-sky-950 dark:text-sky-100">
{{ t('chat.shippingOrderReview.currentProcessing.title') }}
</h2>
<p class="mt-0.5 text-xs text-sky-900/80 dark:text-sky-200/80">
{{ stageLabel }}
</p>
</header>
<dl class="space-y-1 text-xs text-sky-950 dark:text-sky-100">
<div class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentProcessing.status') }}</dt>
<dd data-testid="review-current-processing-status">{{ statusLabel }}</dd>
</div>
<div v-if="taskNo" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentProcessing.formalOt') }}</dt>
<dd class="font-mono" data-testid="review-current-processing-ot">{{ taskNo }}</dd>
</div>
</dl>
<p
v-if="taskMissing"
class="mt-2 text-[11px] text-rose-800 dark:text-rose-200"
data-testid="review-current-processing-task-missing"
>
{{ t('chat.shippingOrderReview.currentProcessing.taskMissingHint') }}
</p>
<aside
v-if="taskMissing && showAdminDiagnosis"
class="mt-2 rounded border border-rose-300 bg-rose-50/80 p-2 text-[11px] text-rose-950 dark:border-rose-800 dark:bg-rose-950/40 dark:text-rose-100"
data-testid="review-current-processing-admin-diagnosis"
>
<p class="font-medium">{{ t('chat.shippingOrderReview.currentProcessing.adminDiagnosisTitle') }}</p>
<p v-if="confirmedTaskId != null" class="mt-1 font-mono">
{{ t('chat.shippingOrderReview.currentProcessing.confirmedTaskId', { id: confirmedTaskId }) }}
</p>
<p class="mt-1">
{{ t('chat.shippingOrderReview.currentProcessing.adminDiagnosisStatus') }}
</p>
<p class="mt-1 text-muted">
{{ t('chat.shippingOrderReview.currentProcessing.adminDiagnosisHint') }}
</p>
</aside>
<button
v-if="canShowRetry"
type="button"
class="mt-3 inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-2.5 py-1.5 text-xs text-amber-950 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
data-testid="review-current-processing-retry"
:disabled="retrying"
@click="emit('retry')"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ t('chat.shippingOrderReview.autoProgress.retryStp') }}
</button>
</section>
</template>
@@ -0,0 +1,79 @@
<!--
features/chat/components/shipping-review/ReviewFieldCompletenessPanel.vue
用途:字段完整性用户态卡片;与模板匹配分离,消费 Case.field_completeness。
依赖:vue-i18n。
逻辑:仅展示 blocked/ready 与缺失字段;required_field_missing 不进入模板匹配区。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
export interface FieldCompletenessIssue {
code?: string;
field_id?: string | null;
field_code?: string | null;
line_index?: number | null;
message?: string | null;
}
const props = defineProps<{
completeness?: {
status?: string;
issues?: FieldCompletenessIssue[];
} | null;
fieldLabels?: Record<string, string>;
}>();
const { t } = useI18n();
const status = computed(() => String(props.completeness?.status || '').trim().toLowerCase());
const blocked = computed(() => status.value === 'blocked');
const issues = computed(() => props.completeness?.issues || []);
const visible = computed(() => Boolean(status.value));
/**
* 字段展示名。
*/
function fieldLabel(issue: FieldCompletenessIssue): string {
const code = String(issue.field_code || issue.field_id || '').trim();
if (!code) return t('chat.shippingOrderReview.fieldCompleteness.unknownField');
return props.fieldLabels?.[code] || code;
}
</script>
<template>
<section
v-if="visible"
class="rounded-xl border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-800 dark:bg-slate-900"
data-testid="review-field-completeness-panel"
:data-status="status"
>
<header class="flex flex-wrap items-start justify-between gap-2">
<div>
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.fieldCompleteness.title') }}</h2>
<p class="mt-0.5 text-xs text-muted">{{ t('chat.shippingOrderReview.fieldCompleteness.subtitle') }}</p>
</div>
<span
class="rounded-full px-2.5 py-1 text-xs font-medium"
:class="blocked
? 'bg-amber-100 text-amber-900 dark:bg-amber-950 dark:text-amber-100'
: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950 dark:text-emerald-100'"
>
{{ blocked
? t('chat.shippingOrderReview.fieldCompleteness.blocked')
: t('chat.shippingOrderReview.fieldCompleteness.ready') }}
</span>
</header>
<ul v-if="blocked && issues.length" class="mt-2 space-y-1 text-[11px] text-secondary">
<li
v-for="(issue, idx) in issues"
:key="`${issue.field_id || issue.field_code || idx}`"
class="rounded-lg border border-default bg-surface-soft px-2.5 py-1.5"
>
<span class="font-medium">{{ fieldLabel(issue) }}</span>
<span v-if="issue.code" class="ml-2 font-mono text-muted">{{ issue.code }}</span>
</li>
</ul>
</section>
</template>
@@ -2,7 +2,8 @@
features/chat/components/shipping-review/ReviewFulfillmentDecisionPanel.vue
用途:复核工作台行级履约决定(等待补货 / 完整行先行 / 关闭)。
依赖:vue-i18n、decide/wave line-fulfillment API、showReviewResumeOutcome。
逻辑:展示 qty/shortage;逐行决定;选中 fulfill 行可确认波次;关闭 emit open-close-dialog。
逻辑:分列展示料号/需求数量/可用数量/预约单号/状态;禁止 part_number 回退预约单号;
逐行决定;选中 fulfill 行可确认波次;关闭 emit open-close-dialog。
-->
<script setup lang="ts">
import { computed, ref } from 'vue';
@@ -181,8 +182,9 @@ function onCloseRemaining() {
<th v-if="editable" class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.waveSelect') }}</th>
<th class="px-1 py-1 font-medium">#</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.partNumber') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.qty') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.requiredQty') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.reservationId') }}</th>
<th class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.status') }}</th>
<th v-if="editable" class="px-1 py-1 font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.actions') }}</th>
</tr>
@@ -204,14 +206,12 @@ function onCloseRemaining() {
>
</td>
<td class="px-1 py-1">{{ (line.line_index ?? 0) + 1 }}</td>
<td class="px-1 py-1 font-mono">{{ line.part_number || line.reservation_id || '—' }}</td>
<td class="px-1 py-1">
{{ line.required_qty ?? '—' }}
<span v-if="line.available_qty" class="text-muted"> / {{ line.available_qty }}</span>
</td>
<td class="px-1 py-1" :class="line.shortage_qty ? 'font-medium text-rose-700 dark:text-rose-300' : ''">
{{ line.shortage_qty || '—' }}
<td class="px-1 py-1 font-mono" data-testid="review-fulfill-part-number">
{{ line.part_number || t('chat.shippingOrderReview.fulfillmentDecision.partUnrecognized') }}
</td>
<td class="px-1 py-1">{{ line.required_qty ?? '—' }}</td>
<td class="px-1 py-1">{{ line.available_qty ?? '—' }}</td>
<td class="px-1 py-1 font-mono">{{ line.reservation_id || '—' }}</td>
<td class="px-1 py-1">{{ lineStatusLabel(line.line_status) }}</td>
<td v-if="editable && !TERMINAL_STATUSES.has(String(line.line_status || ''))" class="px-1 py-1">
<div class="flex flex-wrap gap-1">
@@ -1,65 +0,0 @@
<!--
features/chat/components/shipping-review/ReviewFulfillmentSummaryCard.vue
用途:复核侧栏紧凑展示行级履约缺口摘要,完整表格在库存模式主区处理。
依赖:vue-i18n、ShippingOrderReviewLineFulfillment。
逻辑:仅显示开放行/缺口计数与进入库存处理入口;不渲染 7 列表格。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewLineFulfillment } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
lineFulfillment: ShippingOrderReviewLineFulfillment | null | undefined;
}>();
const emit = defineEmits<{
'enter-inventory': [];
}>();
const { t } = useI18n();
const visible = computed(() => Boolean(
props.lineFulfillment?.has_open_lines
|| props.lineFulfillment?.has_shortage
|| (props.lineFulfillment?.open_count || 0) > 0,
));
const openCount = computed(() => Number(props.lineFulfillment?.open_count || 0));
const readyCount = computed(() => Number(props.lineFulfillment?.ready_count || 0));
const shortageCount = computed(() => (
props.lineFulfillment?.lines || []
).filter((line) => Boolean(line.shortage_qty)).length);
</script>
<template>
<section
v-if="visible"
class="rounded-xl border border-sky-200 bg-sky-50/70 p-3 shadow-sm dark:border-sky-900 dark:bg-sky-950/40"
data-testid="review-fulfillment-summary-card"
>
<header class="mb-2">
<h2 class="text-sm font-semibold text-sky-950 dark:text-sky-50">
{{ t('chat.shippingOrderReview.fulfillmentDecision.title') }}
</h2>
<p class="mt-0.5 text-xs text-sky-900 dark:text-sky-200">
{{ t('chat.shippingOrderReview.fulfillmentDecision.railHint') }}
</p>
</header>
<ul class="space-y-1 text-xs text-secondary">
<li>{{ t('chat.shippingOrderReview.fulfillmentDecision.openCount', { count: openCount }) }}</li>
<li>{{ t('chat.shippingOrderReview.fulfillmentDecision.readyCount', { count: readyCount }) }}</li>
<li v-if="shortageCount">
{{ t('chat.shippingOrderReview.fulfillmentDecision.shortageCount', { count: shortageCount }) }}
</li>
</ul>
<button
type="button"
class="mt-3 w-full rounded-xl border border-sky-300 bg-white px-3 py-1.5 text-sm text-sky-950 hover:bg-sky-100 dark:border-sky-800 dark:bg-slate-900 dark:text-sky-50 dark:hover:bg-sky-950"
data-testid="review-fulfillment-enter-inventory"
@click="emit('enter-inventory')"
>
{{ t('chat.shippingOrderReview.fulfillmentDecision.enterInventory') }}
</button>
</section>
</template>
@@ -0,0 +1,76 @@
<!--
features/chat/components/shipping-review/ReviewInventoryIssueFallbackCard.vue
用途:无行投影且库存系统失败时的 Case 级兜底卡;仅重试获取库存。
依赖:vue-i18n。
逻辑:由 ShippingOrderReviewView 在 inventory_issue_fallback 或行级库存问题聚合时挂载;
禁止进库存工作台、禁止匹配/关闭/换源。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
export interface InventoryIssueFallback {
kind?: string | null;
reason_label_key?: string | null;
affected_line_count?: number | null;
file_count?: number | null;
allowed_actions?: string[] | null;
}
const props = defineProps<{
fallback: InventoryIssueFallback | null | undefined;
busy?: boolean;
}>();
const emit = defineEmits<{
'retry-preparation': [];
}>();
const { t, te } = useI18n();
const visible = computed(() => {
const actions = props.fallback?.allowed_actions || [];
return Boolean(props.fallback && actions.includes('retry_inventory_preparation'));
});
/**
* 失败原因文案。
*/
const reasonLabel = computed(() => {
const keyCode = String(props.fallback?.reason_label_key || props.fallback?.kind || '').trim();
const key = `chat.shippingOrderReview.inventoryFallback.kinds.${keyCode}`;
return te(key) ? t(key) : t('chat.shippingOrderReview.inventoryFallback.kinds.inventory_file_missing');
});
</script>
<template>
<section
v-if="visible"
class="rounded-xl border border-amber-200 bg-amber-50/70 p-3 shadow-sm dark:border-amber-900 dark:bg-amber-950/30"
data-testid="review-inventory-issue-fallback"
>
<h2 class="text-sm font-semibold text-amber-950 dark:text-amber-50">
{{ t('chat.shippingOrderReview.inventoryFallback.title') }}
</h2>
<p class="mt-1 text-xs text-amber-900 dark:text-amber-100" data-testid="review-inventory-fallback-reason">
{{ reasonLabel }}
</p>
<p
v-if="(fallback?.affected_line_count || 0) > 0"
class="mt-1 text-[11px] text-amber-800/90 dark:text-amber-200/90"
>
{{ t('chat.shippingOrderReview.inventoryFallback.affectedLines', {
count: fallback?.affected_line_count || 0,
}) }}
</p>
<button
type="button"
class="mt-3 w-full rounded-xl border border-amber-300 bg-white px-3 py-1.5 text-sm text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-800 dark:bg-slate-900 dark:text-amber-50"
data-testid="review-inventory-fallback-retry"
:disabled="busy"
@click="emit('retry-preparation')"
>
{{ t('chat.shippingOrderReview.lineOps.retryPreparation') }}
</button>
</section>
</template>
@@ -3,7 +3,7 @@
用途:标准复核侧栏中的异常库存行摘要列表(只显示需处理行)。
依赖:vue-i18n、ShippingOrderReviewBuildEligibilityLineProjection。
逻辑:行列表由后端 recovery/suggestion 投影提供,前端不自行发明异常规则;
点击行可定位明细或进入库存处理模式。
点击行可定位明细;正式 OT 后 showEnterAction=false,禁止切库存工作台。
-->
<script setup lang="ts">
import { useI18n } from 'vue-i18n';
@@ -12,9 +12,11 @@ import type { ShippingOrderReviewBuildEligibilityLineProjection } from '@/featur
defineProps<{
lines: ShippingOrderReviewBuildEligibilityLineProjection[];
/**
* 仅展示「进入库存」入口,不列出行明细(Gate/履约摘要已表达缺口时使用)。
* 仅展示摘要标题,不列出行明细(Gate/履约摘要已表达缺口时使用)。
*/
summaryOnly?: boolean;
/** 是否展示「进入库存」按钮;正式 OT 后应关闭。 */
showEnterAction?: boolean;
}>();
const emit = defineEmits<{
@@ -44,6 +46,7 @@ function blockReasonLabel(reason?: string | null): string {
<header class="mb-2 flex items-center justify-between gap-2">
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.workbench.inventoryIssues') }}</h2>
<button
v-if="showEnterAction"
type="button"
class="rounded border border-amber-300 px-2 py-1 text-xs text-amber-900 hover:bg-amber-50 dark:border-amber-800 dark:text-amber-100 dark:hover:bg-amber-950/40"
data-testid="review-inventory-issues-enter"
@@ -0,0 +1,76 @@
/**
* features/chat/components/shipping-review/ReviewLineFulfillmentAggregateCard.spec.ts
* 用途:锁定 UI-3 订单级聚合卡——同时展示系统进度与人工待办,无逐行摘要。
*/
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import ReviewLineFulfillmentAggregateCard from './ReviewLineFulfillmentAggregateCard.vue';
import type { ShippingOrderReviewLineFulfillment } from '@/features/chat/types/shipping.api.types';
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
lineFulfillmentAggregate: {
title: '履约进度摘要',
hint: '同时展示系统进度与人工待办',
autoProgress: '系统处理中 {count} 行',
manualPending: '待人工处理 {count} 行',
inventoryPending: '库存处理中 {count} 行',
systemFailed: '自动履约失败 {count} 行',
enterInventory: '进入库存/履约处理',
viewLines: '查看订单明细',
},
},
},
},
},
});
describe('ReviewLineFulfillmentAggregateCard', () => {
it('shows system progress and manual pending together with inventory entry', async () => {
const lineFulfillment: ShippingOrderReviewLineFulfillment = {
lines: [],
auto_progress_count: 2,
manual_pending_count: 1,
system_failed_count: 0,
inventory_pending_count: 0,
};
const wrapper = mount(ReviewLineFulfillmentAggregateCard, {
props: { lineFulfillment },
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="review-line-fulfillment-aggregate-card"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-line-fulfillment-aggregate-auto-progress"]').text())
.toContain('2');
expect(wrapper.find('[data-testid="review-line-fulfillment-aggregate-manual-pending"]').text())
.toContain('1');
// 断言:不得只有系统进度而无短缺入口
expect(wrapper.find('[data-testid="review-line-fulfillment-aggregate-enter-inventory"]').exists())
.toBe(true);
await wrapper.get('[data-testid="review-line-fulfillment-aggregate-enter-inventory"]').trigger('click');
expect(wrapper.emitted('enter-inventory')).toBeTruthy();
});
it('hides when all aggregate counts are zero', () => {
const wrapper = mount(ReviewLineFulfillmentAggregateCard, {
props: {
lineFulfillment: {
lines: [],
auto_progress_count: 0,
manual_pending_count: 0,
system_failed_count: 0,
inventory_pending_count: 0,
},
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="review-line-fulfillment-aggregate-card"]').exists()).toBe(false);
});
});
@@ -0,0 +1,114 @@
<!--
features/chat/components/shipping-review/ReviewLineFulfillmentAggregateCard.vue
用途:正式 OT 后右侧订单级履约聚合卡(系统进度 / 人工待办 / 失败),无逐行摘要。
依赖:vue-i18n、ShippingOrderReviewLineFulfillment。
逻辑:由 ShippingOrderReviewView 在 hasFormalOt 时挂载于侧栏主卡区;
同时展示系统进度与短缺入口,禁止只显示「系统处理中」。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewLineFulfillment } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
lineFulfillment: ShippingOrderReviewLineFulfillment | null | undefined;
}>();
const emit = defineEmits<{
'enter-inventory': [];
}>();
const { t } = useI18n();
/**
* 聚合计数(后端投影;缺省按 0)。
*/
const autoProgressCount = computed(() => Number(props.lineFulfillment?.auto_progress_count || 0));
const manualPendingCount = computed(() => Number(props.lineFulfillment?.manual_pending_count || 0));
const systemFailedCount = computed(() => Number(props.lineFulfillment?.system_failed_count || 0));
const inventoryPendingCount = computed(() => Number(
props.lineFulfillment?.inventory_pending_count || 0,
));
/**
* 有任一非零计数才展示;避免空卡占位。
*/
const visible = computed(() => (
autoProgressCount.value > 0
|| manualPendingCount.value > 0
|| systemFailedCount.value > 0
|| inventoryPendingCount.value > 0
));
/**
* 人工/库存/失败需进入明细处理;纯系统进度可不强调入口。
* 本轮禁止切换库存工作台,入口改为由父级滚到明细。
*/
const showEnterInventory = computed(() => (
manualPendingCount.value > 0
|| systemFailedCount.value > 0
|| inventoryPendingCount.value > 0
));
</script>
<template>
<section
v-if="visible"
class="rounded-xl border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-800 dark:bg-slate-900"
data-testid="review-line-fulfillment-aggregate-card"
>
<header class="mb-2">
<h2 class="text-sm font-semibold text-slate-900 dark:text-slate-50">
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.title') }}
</h2>
<p class="mt-0.5 text-xs text-muted">
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.hint') }}
</p>
</header>
<ul class="space-y-1 text-xs text-secondary">
<li
v-if="autoProgressCount > 0"
data-testid="review-line-fulfillment-aggregate-auto-progress"
>
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.autoProgress', {
count: autoProgressCount,
}) }}
</li>
<li
v-if="manualPendingCount > 0"
class="font-medium text-amber-800 dark:text-amber-200"
data-testid="review-line-fulfillment-aggregate-manual-pending"
>
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.manualPending', {
count: manualPendingCount,
}) }}
</li>
<li
v-if="inventoryPendingCount > 0"
data-testid="review-line-fulfillment-aggregate-inventory-pending"
>
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.inventoryPending', {
count: inventoryPendingCount,
}) }}
</li>
<li
v-if="systemFailedCount > 0"
class="font-medium text-rose-700 dark:text-rose-300"
data-testid="review-line-fulfillment-aggregate-system-failed"
>
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.systemFailed', {
count: systemFailedCount,
}) }}
</li>
</ul>
<button
v-if="showEnterInventory"
type="button"
class="mt-3 w-full rounded-xl border border-slate-300 bg-slate-50 px-3 py-1.5 text-sm text-slate-900 hover:bg-slate-100 dark:border-slate-700 dark:bg-slate-950 dark:text-slate-50 dark:hover:bg-slate-800"
data-testid="review-line-fulfillment-aggregate-enter-inventory"
@click="emit('enter-inventory')"
>
{{ t('chat.shippingOrderReview.lineFulfillmentAggregate.viewLines') }}
</button>
</section>
</template>
@@ -0,0 +1,73 @@
/**
* features/chat/components/shipping-review/ReviewLineFulfillmentDetail.spec.ts
* 用途:锁定 UI-2 行内履约摘要字段与审计入口。
*/
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import ReviewLineFulfillmentDetail from './ReviewLineFulfillmentDetail.vue';
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
lineFulfillmentDetail: {
title: '行履约摘要',
wave: '履约波次',
task: '正式任务',
snapshotId: '库存快照 ID',
matchedAt: '匹配校验时间',
decisionSource: '决定来源',
decisionSourceValue: {
system: '系统自动',
user: '人工',
unknown: '未知',
},
failureReason: '自动履约失败原因',
noFailure: '无',
openAudit: '打开审计',
close: '收起',
},
},
},
},
},
});
describe('ReviewLineFulfillmentDetail', () => {
it('renders wave/task/snapshot/source/failure and emits audit', async () => {
const line: ShippingOrderReviewLineFulfillmentLine = {
line_key: 'L1',
inventory_snapshot_id: 42,
inventory_checked_at: '2026-08-07T01:00:00Z',
decision_source: 'system',
auto_fulfill_error_message: 'wave_explode',
decision: {
wave_no: 3,
task_id: 9,
decision_source: 'system',
},
};
const wrapper = mount(ReviewLineFulfillmentDetail, {
props: { line, taskNo: 'SN-100' },
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="review-line-fulfillment-summary"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-line-fulfillment-field-wave"]').text()).toContain('3');
expect(wrapper.find('[data-testid="review-line-fulfillment-field-task"]').text()).toContain('SN-100');
expect(wrapper.find('[data-testid="review-line-fulfillment-field-snapshot"]').text()).toContain('42');
expect(wrapper.find('[data-testid="review-line-fulfillment-field-decisionSource"]').text()).toContain('系统自动');
expect(wrapper.find('[data-testid="review-line-fulfillment-field-failure"]').text()).toContain('wave_explode');
await wrapper.get('[data-testid="review-line-fulfillment-open-audit"]').trigger('click');
expect(wrapper.emitted('open-audit')).toBeTruthy();
await wrapper.get('[data-testid="review-line-fulfillment-summary-close"]').trigger('click');
expect(wrapper.emitted('close')).toBeTruthy();
});
});
@@ -0,0 +1,133 @@
<!--
features/chat/components/shipping-review/ReviewLineFulfillmentDetail.vue
用途:订单明细行内履约摘要(查看履约详情);不进入库存工作台。
依赖:vue-i18n、ShippingOrderReviewLineFulfillmentLine。
逻辑:由 ShippingOrderReviewView 在展开行下方挂载;展示 wave/task/快照/匹配时间/
决定来源/失败原因,并提供审计入口。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
line: ShippingOrderReviewLineFulfillmentLine | null | undefined;
taskNo?: string | null;
}>();
const emit = defineEmits<{
'open-audit': [];
close: [];
}>();
const { t, te } = useI18n();
/**
* 展示用字段行。
*/
const rows = computed(() => {
const line = props.line;
const decision = line?.decision;
const waveNo = decision?.wave_no ?? null;
const taskNo = String(props.taskNo || '').trim()
|| (decision?.task_id != null ? String(decision.task_id) : '');
const source = String(line?.decision_source || decision?.decision_source || '').trim();
const sourceKey = `chat.shippingOrderReview.lineFulfillmentDetail.decisionSourceValue.${source}`;
const sourceLabel = source
? (te(sourceKey) ? t(sourceKey) : source)
: '—';
const failure = String(line?.auto_fulfill_error_message || '').trim();
return [
{
key: 'wave',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.wave'),
value: waveNo != null ? String(waveNo) : '—',
},
{
key: 'task',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.task'),
value: taskNo || '—',
},
{
key: 'snapshot',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.snapshotId'),
value: line?.inventory_snapshot_id != null ? String(line.inventory_snapshot_id) : '—',
},
{
key: 'matchedAt',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.matchedAt'),
value: formatTime(line?.inventory_checked_at),
},
{
key: 'decisionSource',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.decisionSource'),
value: sourceLabel,
},
{
key: 'failure',
label: t('chat.shippingOrderReview.lineFulfillmentDetail.failureReason'),
value: failure || t('chat.shippingOrderReview.lineFulfillmentDetail.noFailure'),
emphasize: Boolean(failure),
},
];
});
/**
* 格式化匹配/校验时间。
*/
function formatTime(value: string | null | undefined): string {
if (!value) return '—';
const date = new Date(value);
return Number.isNaN(date.getTime()) ? String(value) : date.toLocaleString();
}
</script>
<template>
<div
class="rounded-md border border-slate-200 bg-slate-50/80 px-3 py-2 text-xs dark:border-slate-700 dark:bg-slate-950/50"
data-testid="review-line-fulfillment-summary"
role="region"
:aria-label="t('chat.shippingOrderReview.lineFulfillmentDetail.title')"
>
<div class="mb-2 flex items-center justify-between gap-2">
<p class="font-medium text-slate-700 dark:text-slate-200">
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.title') }}
</p>
<div class="flex items-center gap-2">
<button
type="button"
class="rounded border border-slate-300 px-2 py-0.5 text-[11px] text-sky-700 hover:bg-white dark:border-slate-600 dark:text-sky-300 dark:hover:bg-slate-900"
data-testid="review-line-fulfillment-open-audit"
@click="emit('open-audit')"
>
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.openAudit') }}
</button>
<button
type="button"
class="rounded px-2 py-0.5 text-[11px] text-slate-500 hover:bg-slate-100 dark:hover:bg-slate-800"
data-testid="review-line-fulfillment-summary-close"
@click="emit('close')"
>
{{ t('chat.shippingOrderReview.lineFulfillmentDetail.close') }}
</button>
</div>
</div>
<dl class="grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3">
<div
v-for="row in rows"
:key="row.key"
class="min-w-0 rounded bg-white/70 px-2 py-1.5 dark:bg-slate-900/60"
:data-testid="`review-line-fulfillment-field-${row.key}`"
>
<dt class="text-[10px] font-medium text-slate-500 dark:text-slate-400">{{ row.label }}</dt>
<dd
class="mt-0.5 break-words text-[11px] text-slate-800 dark:text-slate-100"
:class="row.emphasize ? 'font-medium text-rose-700 dark:text-rose-300' : ''"
>
{{ row.value }}
</dd>
</div>
</dl>
</div>
</template>
@@ -0,0 +1,115 @@
/**
* features/chat/components/shipping-review/ReviewLineInventoryOps.spec.ts
* 用途:锁定库存浮层仅渲染 inventory_allowed_actions;关闭在更多操作;Teleport 菜单可见。
*/
import { afterEach, describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import ReviewLineInventoryOps from './ReviewLineInventoryOps.vue';
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
const i18n = createI18n({
legacy: false,
locale: 'zh-CN',
messages: {
'zh-CN': {
chat: {
shippingOrderReview: {
lineOps: {
inventoryProcessing: '库存处理',
retryPreparation: '重试获取库存',
retryMatching: '重新匹配库存',
moreActions: '更多操作',
viewFulfillment: '查看履约详情',
},
fulfillmentDecision: {
closeLine: '关闭该明细',
},
},
},
},
},
});
function mountOps(line: Partial<ShippingOrderReviewLineFulfillmentLine>) {
return mount(ReviewLineInventoryOps, {
props: {
line: line as ShippingOrderReviewLineFulfillmentLine,
editable: true,
},
attachTo: document.body,
global: { plugins: [i18n] },
});
}
afterEach(() => {
document.body.innerHTML = '';
});
describe('ReviewLineInventoryOps', () => {
it('shows only preparation when matching not allowed', async () => {
const wrapper = mountOps({
inventory_allowed_actions: ['retry_inventory_preparation'],
line_allowed_actions: [],
});
await wrapper.get('[data-testid="review-line-view-inventory"]').trigger('click');
expect(document.querySelector('[data-testid="review-line-retry-preparation"]')).toBeTruthy();
expect(document.querySelector('[data-testid="review-line-retry-matching"]')).toBeFalsy();
expect(document.querySelector('[data-testid="review-line-decide-close"]')).toBeFalsy();
wrapper.unmount();
});
it('puts close under more actions, not inventory panel', async () => {
const wrapper = mountOps({
inventory_allowed_actions: ['retry_inventory_preparation'],
line_allowed_actions: ['close_unfulfillable'],
});
await wrapper.get('[data-testid="review-line-view-inventory"]').trigger('click');
expect(document.querySelector('[data-testid="review-line-decide-close"]')).toBeFalsy();
await wrapper.get('[data-testid="review-line-more-actions"]').trigger('click');
expect(document.querySelector('[data-testid="review-line-decide-close"]')).toBeTruthy();
wrapper.unmount();
});
it('hides inventory icon when no inventory actions and no problem status', () => {
const wrapper = mountOps({
inventory_allowed_actions: [],
line_allowed_actions: ['close_unfulfillable'],
user_line_status: 'inventory_matched',
inventory_status: 'ready',
display_available: '50',
});
expect(wrapper.find('[data-testid="review-line-view-inventory"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-line-more-actions"]').exists()).toBe(true);
wrapper.unmount();
});
it('shows inventory icon from problem status even when backend actions empty', async () => {
const wrapper = mountOps({
inventory_allowed_actions: [],
line_allowed_actions: [],
user_line_status: 'inventory_pending',
inventory_status: 'preparing',
display_available: 'pending',
});
expect(wrapper.find('[data-testid="review-line-view-inventory"]').exists()).toBe(true);
await wrapper.get('[data-testid="review-line-view-inventory"]').trigger('click');
expect(document.querySelector('[data-testid="review-line-retry-preparation"]')).toBeTruthy();
wrapper.unmount();
});
it('emits retry-inventory for both floating actions', async () => {
const wrapper = mountOps({
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
line_allowed_actions: [],
});
await wrapper.get('[data-testid="review-line-view-inventory"]').trigger('click');
expect(document.querySelector('[data-testid="review-line-retry-preparation"]')).toBeTruthy();
expect(document.querySelector('[data-testid="review-line-retry-matching"]')).toBeTruthy();
(document.querySelector('[data-testid="review-line-retry-matching"]') as HTMLButtonElement).click();
await wrapper.vm.$nextTick();
expect(wrapper.emitted('retry-inventory')?.[0]).toEqual(['retry_inventory_matching']);
wrapper.unmount();
});
});
@@ -0,0 +1,297 @@
<!--
features/chat/components/shipping-review/ReviewLineInventoryOps.vue
用途:明细行库存处理浮层 + 行级更多操作(关闭);不进库存工作台、不在右侧挂动作。
依赖:vue-i18n、lucide、line.inventory_allowed_actions / line_allowed_actions。
逻辑:优先后端动作;库存问题态后端漏下发时前端兜底 preparation(+匹配失败时 matching);
菜单 Teleport 到 body,避免表格 overflow 裁切。
-->
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { MoreHorizontal, Warehouse } from 'lucide-vue-next';
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
line: ShippingOrderReviewLineFulfillmentLine | null | undefined;
editable: boolean;
busy?: boolean;
}>();
const emit = defineEmits<{
'retry-inventory': [actionCode: 'retry_inventory_preparation' | 'retry_inventory_matching'];
'close-line': [];
'view-fulfillment': [];
}>();
const { t } = useI18n();
const inventoryMenuOpen = ref(false);
const moreMenuOpen = ref(false);
const inventoryBtnRef = ref<HTMLElement | null>(null);
const moreBtnRef = ref<HTMLElement | null>(null);
const inventoryMenuStyle = ref<Record<string, string>>({});
const moreMenuStyle = ref<Record<string, string>>({});
const PROBLEM_USER_STATUSES = new Set([
'inventory_file_missing',
'inventory_file_expired',
'inventory_match_failed',
'inventory_source_unrecognized',
'source_conflict',
'shortage',
'inventory_pending',
'acquiring_inventory',
'auto_fulfill_failed',
]);
const PROBLEM_INVENTORY_STATUSES = new Set([
'preparing',
'unavailable',
'mapping_failed',
'source_conflict',
'invalid_key',
]);
/**
* 库存动作集合:后端优先;问题态漏下发时兜底 preparation / matching。
*/
const inventoryActions = computed(() => {
const fromBe = [...(props.line?.inventory_allowed_actions || [])].filter(Boolean);
if (fromBe.length) return new Set(fromBe);
if (!props.line) return new Set<string>();
const userStatus = String(props.line.user_line_status || '').trim();
const invStatus = String(props.line.inventory_status || '').trim();
const matchResult = String(props.line.match_result || '').trim();
const isProblem = (
PROBLEM_USER_STATUSES.has(userStatus)
|| PROBLEM_INVENTORY_STATUSES.has(invStatus)
|| props.line.display_available === 'pending'
|| Boolean(props.line.is_shortage)
);
if (!isProblem) return new Set<string>();
const actions = new Set<string>(['retry_inventory_preparation']);
if (
userStatus === 'inventory_match_failed'
|| invStatus === 'mapping_failed'
|| matchResult === 'mapping_failed'
) {
actions.add('retry_inventory_matching');
}
return actions;
});
const lineActions = computed(() => {
const fromBe = [...(props.line?.line_allowed_actions || [])].filter(Boolean);
if (fromBe.length) return new Set(fromBe);
const userStatus = String(props.line?.user_line_status || '').trim();
if (!props.line) return new Set<string>();
if (['wave_created', 'fulfilled', 'closed'].includes(userStatus)) {
return userStatus === 'closed' ? new Set<string>() : new Set(['view_fulfillment_detail']);
}
if (PROBLEM_USER_STATUSES.has(userStatus) || Boolean(props.line.is_shortage)) {
return new Set(['close_unfulfillable']);
}
return new Set<string>();
});
const showInventoryOps = computed(() => (
inventoryActions.value.has('retry_inventory_preparation')
|| inventoryActions.value.has('retry_inventory_matching')
));
const canRetryPreparation = computed(() => inventoryActions.value.has('retry_inventory_preparation'));
const canRetryMatching = computed(() => inventoryActions.value.has('retry_inventory_matching'));
const canClose = computed(() => lineActions.value.has('close_unfulfillable'));
const canViewFulfillment = computed(() => lineActions.value.has('view_fulfillment_detail'));
const showMore = computed(() => canClose.value || canViewFulfillment.value);
/**
* 按触发按钮定位浮动菜单(fixed,避免被表格 overflow 裁切)。
*/
function placeMenu(anchor: HTMLElement | null, target: typeof inventoryMenuStyle) {
if (!anchor || typeof window === 'undefined') return;
const rect = anchor.getBoundingClientRect();
const width = 168;
const left = Math.max(8, Math.min(rect.right - width, window.innerWidth - width - 8));
target.value = {
position: 'fixed',
top: `${Math.round(rect.bottom + 4)}px`,
left: `${Math.round(left)}px`,
width: `${width}px`,
zIndex: '80',
};
}
/**
* 关闭所有浮层。
*/
function closeMenus() {
inventoryMenuOpen.value = false;
moreMenuOpen.value = false;
}
/**
* 文档点击/滚动时关闭浮层,避免残留遮挡。
*/
function onDocPointerDown(event: Event) {
const target = event.target as Node | null;
if (!target) return;
const el = target as HTMLElement;
if (el.closest?.('[data-testid="review-line-inventory-panel"]')) return;
if (el.closest?.('[data-testid="review-line-more-menu"]')) return;
if (el.closest?.('[data-testid="review-line-view-inventory"]')) return;
if (el.closest?.('[data-testid="review-line-more-actions"]')) return;
closeMenus();
}
function onViewportChange() {
if (inventoryMenuOpen.value) placeMenu(inventoryBtnRef.value, inventoryMenuStyle);
if (moreMenuOpen.value) placeMenu(moreBtnRef.value, moreMenuStyle);
}
/**
* 切换库存处理浮层。
*/
async function toggleInventoryMenu() {
moreMenuOpen.value = false;
inventoryMenuOpen.value = !inventoryMenuOpen.value;
if (inventoryMenuOpen.value) {
await nextTick();
placeMenu(inventoryBtnRef.value, inventoryMenuStyle);
}
}
/**
* 切换更多操作浮层。
*/
async function toggleMoreMenu() {
inventoryMenuOpen.value = false;
moreMenuOpen.value = !moreMenuOpen.value;
if (moreMenuOpen.value) {
await nextTick();
placeMenu(moreBtnRef.value, moreMenuStyle);
}
}
/**
* 触发库存动作并关闭浮层。
*/
function onRetry(actionCode: 'retry_inventory_preparation' | 'retry_inventory_matching') {
closeMenus();
emit('retry-inventory', actionCode);
}
/**
* 关闭明细(由父级弹确认框)。
*/
function onCloseLine() {
closeMenus();
emit('close-line');
}
if (typeof document !== 'undefined') {
document.addEventListener('pointerdown', onDocPointerDown, true);
window.addEventListener('scroll', onViewportChange, true);
window.addEventListener('resize', onViewportChange);
}
onBeforeUnmount(() => {
if (typeof document === 'undefined') return;
document.removeEventListener('pointerdown', onDocPointerDown, true);
window.removeEventListener('scroll', onViewportChange, true);
window.removeEventListener('resize', onViewportChange);
});
</script>
<template>
<div class="relative inline-flex items-center gap-0.5">
<button
v-if="showInventoryOps"
ref="inventoryBtnRef"
type="button"
class="rounded p-1.5 hover:bg-slate-100 disabled:opacity-50 dark:hover:bg-slate-800"
data-testid="review-line-view-inventory"
:disabled="busy"
:aria-label="t('chat.shippingOrderReview.lineOps.inventoryProcessing')"
:title="t('chat.shippingOrderReview.lineOps.inventoryProcessing')"
:aria-expanded="inventoryMenuOpen"
@click="toggleInventoryMenu"
>
<Warehouse class="h-3.5 w-3.5" aria-hidden="true" />
</button>
<button
v-if="showMore"
ref="moreBtnRef"
type="button"
class="rounded p-1.5 hover:bg-slate-100 disabled:opacity-50 dark:hover:bg-slate-800"
data-testid="review-line-more-actions"
:disabled="!editable || busy"
:aria-label="t('chat.shippingOrderReview.lineOps.moreActions')"
:title="t('chat.shippingOrderReview.lineOps.moreActions')"
:aria-expanded="moreMenuOpen"
@click="toggleMoreMenu"
>
<MoreHorizontal class="h-3.5 w-3.5" aria-hidden="true" />
</button>
<Teleport to="body">
<div
v-if="inventoryMenuOpen && showInventoryOps"
class="rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-slate-700 dark:bg-slate-900"
role="menu"
data-testid="review-line-inventory-panel"
:style="inventoryMenuStyle"
>
<button
v-if="canRetryPreparation"
type="button"
class="block w-full px-3 py-2 text-left text-xs hover:bg-slate-50 dark:hover:bg-slate-800"
role="menuitem"
data-testid="review-line-retry-preparation"
@click="onRetry('retry_inventory_preparation')"
>
{{ t('chat.shippingOrderReview.lineOps.retryPreparation') }}
</button>
<button
v-if="canRetryMatching"
type="button"
class="block w-full px-3 py-2 text-left text-xs hover:bg-slate-50 dark:hover:bg-slate-800"
role="menuitem"
data-testid="review-line-retry-matching"
@click="onRetry('retry_inventory_matching')"
>
{{ t('chat.shippingOrderReview.lineOps.retryMatching') }}
</button>
</div>
<div
v-if="moreMenuOpen && showMore"
class="rounded-md border border-slate-200 bg-white py-1 shadow-lg dark:border-slate-700 dark:bg-slate-900"
role="menu"
data-testid="review-line-more-menu"
:style="moreMenuStyle"
>
<button
v-if="canViewFulfillment"
type="button"
class="block w-full px-3 py-2 text-left text-xs hover:bg-slate-50 dark:hover:bg-slate-800"
role="menuitem"
data-testid="review-line-fulfillment-detail"
@click="closeMenus(); emit('view-fulfillment')"
>
{{ t('chat.shippingOrderReview.lineOps.viewFulfillment') }}
</button>
<button
v-if="canClose"
type="button"
class="block w-full px-3 py-2 text-left text-xs text-rose-700 hover:bg-rose-50 dark:text-rose-300 dark:hover:bg-rose-950/40"
role="menuitem"
data-testid="review-line-decide-close"
@click="onCloseLine"
>
{{ t('chat.shippingOrderReview.fulfillmentDecision.closeLine') }}
</button>
</div>
</Teleport>
</div>
</template>
@@ -1,8 +1,9 @@
<!--
features/chat/components/shipping-review/ReviewProfileMatchPanel.vue
用途:复核工作台文档模板匹配只读区(选中模板 / 候选分 / 回退原因)。
用途:复核工作台文档模板匹配只读区(用户四态;管理员详细在技术诊断)。
依赖:vue-i18n、ShippingOrderReviewProfileMatch。
逻辑:A3 只展示;换模板/重抽取仍走 Process Gate 或重新识别 PDF。
逻辑:普通用户只显示 matched/unmatched/ambiguous/unknown;
required_field_missing 不在此展示;分数/Profile ID 仅 admin visibility。
-->
<script setup lang="ts">
import { computed } from 'vue';
@@ -15,11 +16,18 @@ const props = defineProps<{
const { t, te } = useI18n();
const visible = computed(() => Boolean(props.profileMatch?.available));
const visible = computed(() => {
const match = props.profileMatch;
if (!match) return false;
if (match.visibility === 'admin_only' && match.available === false) return false;
return Boolean(match.available !== false);
});
const isAdminView = computed(() => String(props.profileMatch?.visibility || '') === 'admin');
const needsReview = computed(() => Boolean(props.profileMatch?.needs_review));
/**
* 匹配状态本地化。
* 匹配状态本地化(用户四态)。
*/
const statusLabel = computed(() => {
const status = String(props.profileMatch?.status || '').trim();
@@ -28,27 +36,19 @@ const statusLabel = computed(() => {
});
/**
* 选中模板展示名。
* 选中模板展示名(用户仅 display_name)。
*/
const selectedLabel = computed(() => {
const selected = props.profileMatch?.selected_profile;
if (!selected?.profile_code) {
if (!selected) {
return t('chat.shippingOrderReview.profileMatch.noSelected');
}
const name = String(selected.display_name || selected.profile_code).trim();
const name = String(selected.display_name || selected.profile_code || '').trim();
if (!name) return t('chat.shippingOrderReview.profileMatch.noSelected');
if (!isAdminView.value) return name;
const version = selected.version != null ? ` v${selected.version}` : '';
return `${name}${version}`;
});
/**
* 回退原因本地化列表。
*/
const fallbackLabels = computed(() =>
(props.profileMatch?.fallback_reason_codes || []).map((code) => {
const key = `chat.shippingOrderReview.profileMatch.reasons.${code}`;
return te(key) ? t(key) : code;
}),
);
</script>
<template>
@@ -56,6 +56,7 @@ const fallbackLabels = computed(() =>
v-if="visible"
class="rounded-xl border border-slate-200 bg-white p-3 shadow-sm dark:border-slate-800 dark:bg-slate-900"
data-testid="review-profile-match-panel"
:data-status="String(profileMatch?.status || '')"
>
<header class="flex flex-wrap items-start justify-between gap-2">
<div>
@@ -78,47 +79,33 @@ const fallbackLabels = computed(() =>
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.selected') }}</dt>
<dd class="font-medium text-primary" data-testid="review-profile-match-selected">{{ selectedLabel }}</dd>
</div>
<div v-if="profileMatch?.route_type" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.routeType') }}</dt>
<dd class="font-mono">{{ profileMatch.route_type }}</dd>
</div>
<div v-if="profileMatch?.execution_mode" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.executionMode') }}</dt>
<dd class="font-mono">{{ profileMatch.execution_mode }}</dd>
</div>
</dl>
<ul
v-if="(profileMatch?.candidates || []).length"
class="mt-2 space-y-1.5"
data-testid="review-profile-match-candidates"
>
<li
v-for="(item, idx) in profileMatch?.candidates || []"
:key="`${item.profile_code}-${item.version}-${idx}`"
class="rounded-lg border border-default bg-surface-soft px-2.5 py-1.5 text-[11px] text-secondary"
>
<div class="flex flex-wrap items-center justify-between gap-2">
<span class="font-medium text-primary">
{{ item.display_name || item.profile_code }}
<span v-if="item.version != null" class="text-muted">v{{ item.version }}</span>
</span>
<span v-if="item.score != null" class="font-mono text-muted">
{{ t('chat.shippingOrderReview.profileMatch.score', { score: Number(item.score).toFixed(2) }) }}
</span>
<template v-if="isAdminView">
<dl class="mt-2 space-y-1 text-xs text-secondary">
<div v-if="profileMatch?.route_type" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.routeType') }}</dt>
<dd class="font-mono">{{ profileMatch.route_type }}</dd>
</div>
<p v-if="item.reason_codes?.length" class="mt-0.5 text-muted">
{{ item.reason_codes.join(', ') }}
</p>
</li>
</ul>
<ul v-if="fallbackLabels.length" class="mt-2 list-disc space-y-0.5 pl-4 text-[11px] text-amber-900 dark:text-amber-100">
<li v-for="label in fallbackLabels" :key="label">{{ label }}</li>
</ul>
<p class="mt-2 text-[11px] text-muted">
{{ t('chat.shippingOrderReview.profileMatch.reselectHint') }}
</p>
<div v-if="profileMatch?.execution_mode" class="flex flex-wrap gap-x-2">
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.executionMode') }}</dt>
<dd class="font-mono">{{ profileMatch.execution_mode }}</dd>
</div>
</dl>
<ul
v-if="(profileMatch?.candidates || []).length"
class="mt-2 space-y-1.5"
data-testid="review-profile-match-candidates"
>
<li
v-for="(item, idx) in profileMatch?.candidates || []"
:key="`${item.profile_code}-${item.version}-${idx}`"
class="rounded-lg border border-default bg-surface-soft px-2.5 py-1.5 text-[11px] text-secondary"
>
<span class="font-mono">{{ item.profile_code }}</span>
<span v-if="item.score != null" class="ml-2 text-muted">{{ item.score }}</span>
</li>
</ul>
</template>
</section>
</template>
@@ -3,6 +3,7 @@
用途:订单处理工作台只读进度区外壳——挂载压缩版 ReviewProgressStrip + 人工上传入口。
依赖:vue-i18n、ShippingProcessingProjection、ReviewProgressStrip、shippingProcessingFulfillment。
逻辑:标题与「当前需要」由 Strip 统一渲染;surface=review 永不渲染 review-generic-next-steps;
正式 OT 已创建时传 hasFormalOt 抑制「请确认建单」;
仅人工上传保留任务台跳转;其他 Gate 只靠 Strip + Footer;写操作不在本面板。
-->
<script setup lang="ts">
@@ -24,6 +25,8 @@ const props = defineProps<{
polling?: boolean;
/** 统一进度投影:节点与文案的权威来源。 */
processingProjection?: ShippingProcessingProjection | null;
/** 正式 OT 已创建;抑制确认建单类「当前需要」。 */
hasFormalOt?: boolean;
}>();
const emit = defineEmits<{
@@ -47,7 +50,7 @@ const showTaskWorkbenchLink = computed(() => {
<template>
<section
class="rounded-xl border border-default bg-surface-soft/60 p-3"
class="rounded-xl border border-default bg-surface-soft/60 p-2.5"
data-testid="review-workflow-progress-panel"
>
<div
@@ -62,6 +65,7 @@ const showTaskWorkbenchLink = computed(() => {
v-else-if="processingProjection"
:projection="processingProjection"
:polling="polling"
:has-formal-ot="hasFormalOt || Boolean(String(taskNo || '').trim())"
@open-process-details="emit('open-process-details')"
@refresh="emit('refresh')"
/>
@@ -357,6 +357,8 @@ export function useShippingOrderReview() {
const loadFailed = ref(false);
const saving = ref(false);
const saveFailed = ref(false);
/** 显式校验期间清空旧资格投影,避免短暂显示过期的“不可建单”。 */
const validationInProgress = ref(false);
/** ???????????????????????????? */
const draftConflict = ref<DraftVersionConflict | null>(null);
const versionsLoading = ref(false);
@@ -730,11 +732,15 @@ export function useShippingOrderReview() {
/** ?? Case ???????????validate ???? */
const buildEligibility = computed(
() => activeCase.value?.draft?.build_eligibility ?? null,
() => validationInProgress.value ? null : (activeCase.value?.draft?.build_eligibility ?? null),
);
/** ?? build_eligibility ? can_build ? false ???????? */
const canConfirmBuild = computed(() => !isBuildConfirmBlocked(buildEligibility.value));
const canConfirmBuild = computed(() => (
!validationInProgress.value
&& Boolean(buildEligibility.value)
&& !isBuildConfirmBlocked(buildEligibility.value)
));
/** ????????????????? */
const manualInventoryLines = computed(() =>
@@ -956,7 +962,14 @@ export function useShippingOrderReview() {
saveFailed.value = false;
const localVersion = version();
try {
activeCase.value = await action();
const nextCase = await action();
// [STEP] 只接受当前 Case 且不低于本地 Draft 版本的响应;旧请求不得回写新快照。
const currentCaseNo = String(activeCase.value?.case_no || '').trim();
const nextCaseNo = String(nextCase?.case_no || '').trim();
const nextVersion = Number(nextCase?.draft?.draft_version ?? 0);
if (nextCaseNo === currentCaseNo && nextVersion >= localVersion) {
activeCase.value = nextCase;
}
draftConflict.value = null;
if (reviewRun.value && activeCase.value) {
const item = reviewRun.value.items.find((row) => row.case_no === activeCase.value?.case_no);
@@ -1154,7 +1167,15 @@ export function useShippingOrderReview() {
const addLine = () => activeCase.value && save(() => addWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, version()));
const copyLine = (lineKey: string) => activeCase.value && save(() => copyWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, lineKey, version()));
const deleteLine = (lineKey: string) => activeCase.value && save(() => deleteWorkspaceShippingOrderReviewLine(activeCase.value!.case_no, lineKey, version()));
const validate = () => activeCase.value && save(() => validateWorkspaceShippingOrderReviewDraft(activeCase.value!.case_no, version()));
const validate = async () => {
if (!activeCase.value) return;
validationInProgress.value = true;
try {
await save(() => validateWorkspaceShippingOrderReviewDraft(activeCase.value!.case_no, version()));
} finally {
validationInProgress.value = false;
}
};
/**
* ????????????????? Case?
@@ -1533,6 +1554,7 @@ export function useShippingOrderReview() {
caseSwitchLoading,
caseSwitchFailed,
saving,
validationInProgress,
saveFailed,
versionsLoading,
load,
@@ -140,6 +140,7 @@ export function normalizeShippingProcessingProjection(
intakeNo: readString(item, 'intake_no', 'intakeNo'),
status: (readString(item, 'status', 'status') || 'processing') as ShippingProcessingStatus,
stage: (readString(item, 'stage', 'stage') || 'upload_received') as ShippingProcessingStage,
stageLabelKey: readNullableString(item, 'stage_label_key', 'stageLabelKey'),
progressVersion: Number(item.progress_version ?? item.progressVersion ?? 0) || 0,
lastActivityAt: readString(item, 'last_activity_at', 'lastActivityAt'),
stageNodes: stageNodes?.length ? stageNodes : undefined,
@@ -2,7 +2,8 @@
* features/chat/shipping/shippingProcessingLabels.ts
* 用途:将统一 ShippingProcessing 状态/阶段码映射到四语言 i18n 键。
* 依赖:vue-i18n Composer(由调用方传入 t / te)。
* 逻辑:统一读 chat.shippingProcessing.*(含原 shippingWorkflow 合并键,如 taskStatus)。
* 逻辑:统一读 chat.shippingProcessing.*;阶段展示优先消费后端 label_key
* (如 waiting_system_start),禁止把 stage code 直接当用户文案。
*/
/** 会话 processing 旧 status_label → 统一 ShippingProcessingStatus。 */
@@ -79,7 +80,7 @@ export function resolveShippingProcessingMessage(
}
/**
* 解析统一处理阶段的展示文案键。
* 解析统一处理阶段的展示文案键(技术阶段码)。
* @param stage - ShippingProcessingStage 码
* @returns i18n key
*/
@@ -90,6 +91,41 @@ export function shippingProcessingStageKey(stage: string): string {
: 'chat.shippingProcessing.stage.upload_received';
}
/**
* 解析阶段用户文案:优先后端 label_key,禁止直接展示 stage code。
* 核心逻辑:label_key → stageLabel.* / currentProcessing.stages.*;再回退 stage.*。
*
* @param stage - 技术阶段码
* @param te - i18n te
* @param t - i18n t
* @param labelKey - 后端投影 label_key(如 waiting_system_start)
* @returns 本地化文案
*/
export function resolveShippingProcessingStageLabel(
stage: string,
te: (key: string) => boolean,
t: (key: string) => string,
labelKey?: string | null,
): string {
const lk = String(labelKey || '').trim();
if (lk) {
const stageLabelKey = `chat.shippingProcessing.stageLabel.${lk}`;
if (te(stageLabelKey)) return t(stageLabelKey);
const reviewKey = `chat.shippingOrderReview.currentProcessing.stages.${lk}`;
if (te(reviewKey)) return t(reviewKey);
}
const code = String(stage || '').trim();
if (!code) return '—';
const stageKey = shippingProcessingStageKey(code);
if (te(stageKey)) return t(stageKey);
const reviewCodeKey = `chat.shippingOrderReview.currentProcessing.stages.${code}`;
if (te(reviewCodeKey)) return t(reviewCodeKey);
// 禁止把码当文案:无键时回退通用等待文案,而非裸 code。
return te('chat.shippingProcessing.stageLabel.waiting_system_start')
? t('chat.shippingProcessing.stageLabel.waiting_system_start')
: code;
}
/**
* 解析工作项类型文案键。
* @param workItemType - order_intake | order_task
@@ -159,6 +159,11 @@ export interface ShippingProcessingProjection {
intakeNo: string;
status: ShippingProcessingStatus;
stage: ShippingProcessingStage;
/**
* 后端阶段用户文案键(如 waiting_system_start);与 Case.current_stage.label_key 同源。
* 禁止前端把 stage 技术码直接当用户文案。
*/
stageLabelKey?: string | null;
progressVersion: number;
lastActivityAt: string;
/** 后端 15 阶节点态;存在时 UI 优先消费,禁止页面自行推导。 */
@@ -779,6 +784,8 @@ export interface ShippingProcessGateUserSummary {
next_action_code?: ShippingProcessGateActionCode | string | null;
/** 当前阻断仅剩技术自动恢复时为 true(业务用户无写操作) */
technical_auto_only?: boolean;
/** 当前 Gate 责任方:system | human | unknown */
owner_type?: 'system' | 'human' | 'unknown' | string | null;
responsible_party?: ShippingProcessGateResponsibleParty | string | null;
diagnostic_hint?: string | null;
case_no?: string | null;
@@ -1988,15 +1995,54 @@ export interface ShippingOrderReviewCase {
duplicate?: ShippingOrderReviewDuplicate | null;
/** 建单前文档模板匹配只读摘要 */
profile_match?: ShippingOrderReviewProfileMatch | null;
/** 字段完整性(与 Process Gate field_completeness 同源) */
field_completeness?: {
status: 'ready' | 'blocked' | string;
issues: Array<{
code?: string;
field_id?: string | null;
field_code?: string | null;
line_index?: number | null;
message?: string | null;
}>;
} | null;
/** 后端组装的已完成检查;前端禁止自行拼接 */
completed_checks?: Array<{
code: string;
status: 'passed' | string;
completed_at?: string | null;
}> | null;
/** 正式 OT 驱动的当前阶段;建单前为 order_review */
current_stage?: {
code?: string | null;
label_key?: string | null;
source?: string | null;
inconsistent?: boolean;
process_status?: string | null;
current_step?: string | null;
stage_node?: Record<string, unknown> | null;
} | null;
/** 建单前 Reservation 校验摘要 */
reservation?: ShippingOrderReviewReservation | null;
/** 行级履约决定与库存缺口摘要 */
line_fulfillment?: ShippingOrderReviewLineFulfillment | null;
/** 无行投影且库存系统失败时的 Case 级兜底;有行投影时必须为空。 */
inventory_issue_fallback?: {
kind?: string | null;
reason_label_key?: string | null;
affected_line_count?: number | null;
file_count?: number | null;
allowed_actions?: string[] | null;
} | null;
status: string;
disposition?: string | null;
confirmed_task_id?: number | null;
/** 已确认时关联的任务号;供刷新后恢复推进入口。 */
confirmed_task_no?: string | null;
/** 后端权威:confirmed_task_id 指向可读正式 OT */
has_formal_ot?: boolean;
/** confirmed_task_id 有值但 ShippingNotice 不可读 */
task_missing?: boolean;
/**
* 确认建单后的自动推进投影:needs_retry=true 时前端应展示琥珀色重试条。
* 与即时 confirm 响应的 auto_progress 字段语义对齐,供页面重载恢复。
@@ -2322,6 +2368,12 @@ export interface ShippingOrderReviewAutomation {
can_build?: boolean;
job_id?: number | null;
reason_code?: string | null;
/** pre_ot_stp = 建单前 STP;post_ot_progress = 正式 OT 自动推进 */
phase?: 'pre_ot_stp' | 'post_ot_progress' | string | null;
/** 自动执行责任方 */
owner_type?: 'system' | 'human' | 'unknown' | string | null;
/** 管理员诊断:enqueue_status 等 */
technical?: Record<string, unknown> | null;
}
/** 管理员可见的技术 Gate 进度(普通用户不下发)。 */
@@ -2367,6 +2419,7 @@ export interface ShippingOrderReviewLineFulfillmentDecision {
line_index?: number | null;
decision_version?: number;
decision_code?: string;
decision_source?: 'system' | 'user' | 'unknown' | null;
line_status?: string;
is_active?: boolean;
reason?: string | null;
@@ -2388,7 +2441,7 @@ export type ShippingOrderReviewLineFulfillmentDecisionCode =
| 'use_new_inventory_file'
| 'change_inventory_source';
/** 行级履约与库存缺口投影行。 */
/** 行级履约与库存缺口投影行(含 OT 匹配事实与 allowed_actions)。 */
export interface ShippingOrderReviewLineFulfillmentLine {
line_key: string;
line_index?: number | null;
@@ -2399,6 +2452,26 @@ export interface ShippingOrderReviewLineFulfillmentLine {
shortage_qty?: string | null;
can_fulfill_complete_line?: boolean;
line_status?: string;
user_line_status?: string | null;
inventory_status?: string | null;
match_result?: string | null;
is_shortage?: boolean;
display_available?: 'pending' | 'number' | string | null;
inventory_snapshot_id?: number | null;
inventory_checked_at?: string | null;
inventory_source_code?: string | null;
inventory_source?: {
code?: string | null;
label?: string | null;
status?: 'resolved' | 'resolving' | 'unrecognized' | 'conflict' | 'unavailable' | string | null;
source?: string | null;
} | null;
decision_source?: 'system' | 'user' | 'unknown' | null;
/** @deprecated 使用 inventory_allowed_actions + line_allowed_actions */
allowed_actions?: string[];
inventory_allowed_actions?: string[];
line_allowed_actions?: string[];
auto_fulfill_error_message?: string | null;
decision?: ShippingOrderReviewLineFulfillmentDecision | null;
block_reason?: string | null;
}
@@ -2410,6 +2483,17 @@ export interface ShippingOrderReviewLineFulfillment {
ready_count?: number;
has_open_lines?: boolean;
has_shortage?: boolean;
/** 系统自动履约中 / 已入波次行数(订单级聚合卡)。 */
auto_progress_count?: number;
/** 短缺或待人工决定行数。 */
manual_pending_count?: number;
/** 自动履约失败行数。 */
system_failed_count?: number;
/** 库存处理中 / 冲突 / 无效键行数。 */
inventory_pending_count?: number;
/** 是否已形成可消费的行级库存投影(有则不上 Case 兜底卡)。 */
has_line_inventory_projection?: boolean;
line_auto_fulfill_enabled?: boolean;
}
/** 复核 Case 业务审计时间线条目(含白名单前后快照;敏感事件脱敏)。 */
@@ -15,6 +15,7 @@ import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
import {
auditWorkspaceShippingOrderReviewEligibilityDetails,
auditWorkspaceShippingOrderReviewVersionHistory,
autoProgressWorkspaceShippingTask,
retryWorkspaceShippingOrderStpAutoCreate,
} from '@/features/chat/api/shipping.api';
@@ -63,6 +64,8 @@ const reviewRun = ref({
});
const workItem = ref<Record<string, any> | null>(null);
const reviewProgressContext = ref<Record<string, any> | null>(null);
/** 与 activeCase 同源共享,供断言 Progress 优先阶段源。 */
const shippingProcessingProjection = ref<Record<string, any> | null>(null);
const activeCase = ref({
case_no: 'CASE-1',
@@ -125,9 +128,26 @@ vi.mock('@/features/chat/api/shipping.api', async (importOriginal) => {
};
});
/** mock 工厂句柄:vi.mock 提升后由下方 createReviewComposableMock 赋值。 */
const reviewComposableMockApi = vi.hoisted(() => ({
create: null as null | (() => Record<string, unknown>),
}));
vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
REVIEW_BUILD_ELIGIBILITY_BLOCKED: 'SHIPPING.REVIEW_BUILD_ELIGIBILITY_BLOCKED',
useShippingOrderReview: () => ({
useShippingOrderReview: () => {
if (!reviewComposableMockApi.create) {
throw new Error('createReviewComposableMock not initialized');
}
return reviewComposableMockApi.create();
},
}));
/**
* 统一维护 useShippingOrderReview mock 契约,避免新增返回字段时漏改。
*/
function createReviewComposableMock() {
return {
reviewRun,
activeCase,
reviewProgressContext,
@@ -152,6 +172,7 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
caseSwitchFailed: ref(false),
requestedCaseNo: ref(null),
saving: ref(false),
validationInProgress: ref(false),
saveFailed: ref(false),
versionsLoading: ref(false),
evidence: ref([
@@ -204,7 +225,7 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
isWorkItemClosed: computed(() => false),
showWorkflowProgress: computed(() => false),
workflowProgressPolling: computed(() => false),
shippingProcessingProjection: ref(null),
shippingProcessingProjection,
shippingProcessingLoading: ref(false),
shippingProcessingError: ref(null),
refreshShippingProcessing: vi.fn(),
@@ -218,8 +239,10 @@ vi.mock('@/features/chat/shipping-review/useShippingOrderReview', () => ({
reparseLastRefreshedAt: computed(() => null),
reparseStalePolls: computed(() => 0),
refreshReparseProgress: vi.fn(),
}),
}));
};
}
reviewComposableMockApi.create = createReviewComposableMock;
vi.mock('@/shared/composables/useMessage', () => ({
useMessage: () => messageMocks,
@@ -299,12 +322,39 @@ vi.mock('../components/shipping-review/ReviewVersionHistoryDrawer.vue', () => ({
},
}));
vi.mock('../components/shipping-review/ReviewWorkflowProgressPanel.vue', () => ({
default: {
name: 'ReviewWorkflowProgressPanel',
template: '<div data-testid="mock-progress" />',
},
}));
vi.mock('../components/shipping-review/ReviewWorkflowProgressPanel.vue', async () => {
const { computed } = await import('vue');
const { useI18n } = await import('vue-i18n');
const { resolveShippingProcessingStageLabel } = await import(
'@/features/chat/shipping/shippingProcessingLabels'
);
return {
default: {
name: 'ReviewWorkflowProgressPanel',
props: ['processingProjection', 'hasFormalOt', 'polling'],
setup(props: { processingProjection?: Record<string, unknown> | null }) {
const { t, te } = useI18n();
const stageLabel = computed(() => {
const projection = props.processingProjection;
if (!projection) return '';
return resolveShippingProcessingStageLabel(
String(projection.stage || ''),
te,
t,
projection.stageLabelKey != null
? String(projection.stageLabelKey)
: null,
);
});
return { stageLabel };
},
template:
'<div data-testid="mock-progress">'
+ '<span data-testid="review-progress-stage-label">{{ stageLabel }}</span>'
+ '</div>',
},
};
});
/**
* 挂载复核工作台视图并注入最小 Chat 上下文。
@@ -462,12 +512,45 @@ async function mountView() {
retryStp: '重试自动推进',
retryStpSuccess: '已重新入队自动建单',
},
currentProcessing: {
title: '当前处理状态',
status: '状态',
formalOt: '正式 OT',
waitingStart: '等待系统启动',
taskMissing: '正式任务关联异常',
taskMissingHint: '正式任务关联异常,请联系管理员',
stateInconsistent: '状态同步中',
statusRunning: '系统处理中',
statusFailedRetryable: '失败可重试',
statusCompleted: '已完成',
statusIdle: '待机',
statusTaskMissing: '关联异常',
stages: {
waiting_system_start: '等待系统启动',
waiting_to_start: '等待系统启动',
order_creating: '等待系统启动',
inventory_matching: '库存匹配',
},
},
automation: {
waitingPreOt: '等待自动建单',
waitingPostOt: '等待系统启动自动推进',
},
confirmSuccess: '{taskNo}',
confirmAutoProgress: '{taskNo}',
confirmProgressFailed: '已创建任务 {taskNo},但自动推进失败,请重试推进',
jumpToCurrentVersion: '跳转',
currentVersionUnavailable: '不可用',
},
shippingProcessing: {
stage: {
order_creating: '创建正式订单',
inventory_matching: '库存匹配',
},
stageLabel: {
waiting_system_start: '等待系统启动',
},
},
},
errors: { generic: '错误' },
},
@@ -522,8 +605,18 @@ function resetActiveCaseFixture() {
...activeCase.value,
status: 'draft',
confirmed_task_no: null,
confirmed_task_id: null,
has_formal_ot: false,
task_missing: false,
recovery_available: null,
post_confirm_auto_progress: null,
current_stage: null,
technical_progress: null,
automation: { status: 'idle', can_auto_create: false, can_build: true },
available_actions: ['validate', 'confirm', 'mark_non_order', 'reparse'],
profile_match: { available: false, visibility: 'admin_only', candidates: [] },
};
shippingProcessingProjection.value = null;
}
describe('ShippingOrderReviewView layout phase 1', () => {
@@ -731,6 +824,105 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
expect(banner.text()).toContain('SN-RECOVER-1');
});
it('retries formal OT auto-progress from main card after refresh without confirmSuccess (UI-01)', async () => {
// 关键断言:刷新后无 confirmSuccess 时,主卡仍用 confirmed_task_no 调 auto-progress API。
vi.mocked(autoProgressWorkspaceShippingTask).mockClear();
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 42,
confirmed_task_no: 'SN-OT-FAIL-1',
current_stage: { code: 'order_creating', inconsistent: false },
automation: {
status: 'failed',
retryable: true,
phase: 'post_ot_progress',
can_auto_create: false,
can_build: true,
},
post_confirm_auto_progress: {
task_no: 'SN-OT-FAIL-1',
needs_retry: true,
status: 'needs_retry',
},
};
const wrapper = await mountView();
await flushPromises();
const retryBtn = wrapper.find('[data-testid="review-current-processing-retry"]');
expect(retryBtn.exists()).toBe(true);
await retryBtn.trigger('click');
await flushPromises();
expect(autoProgressWorkspaceShippingTask).toHaveBeenCalledWith('SN-OT-FAIL-1');
});
it('keeps top / wide / narrow stage labels identical via Progress projection (waiting_system_start)', async () => {
// 关键断言:Case.current_stage 故意降级为误导码;三处必须消费 Progress label_key 文案。
shippingProcessingProjection.value = {
workItemType: 'order_task',
workItemNo: 'OT-WAIT-1',
sourceType: 'eml',
rootOrderTaskNo: 'OT-WAIT-1',
shippingNoticeNo: 'SN-WAIT-1',
conversationId: 'conv-1',
submissionNo: 'SUB-1',
intakeNo: 'INT-1',
status: 'automating',
stage: 'order_creating',
stageLabelKey: 'waiting_system_start',
progressVersion: 1,
lastActivityAt: '2026-08-07T00:00:00Z',
currentGate: null,
availableActions: [],
sourceSummary: {
emailSubject: null,
filename: 'po.pdf',
documentCount: 1,
parsedDocumentCount: 1,
candidateCount: 1,
customerName: null,
poNumber: 'PO-1',
},
childOrderTasks: [],
};
activeCase.value = {
...activeCase.value,
status: 'confirmed',
has_formal_ot: true,
task_missing: false,
confirmed_task_id: 88,
confirmed_task_no: 'SN-WAIT-1',
// 故意与 Progress 文案分叉:若宽屏仍直读 Case code,会显示「库存匹配」。
current_stage: {
code: 'inventory_matching',
label_key: 'inventory_matching',
inconsistent: false,
},
automation: {
status: 'waiting_to_start',
retryable: false,
phase: 'post_ot_progress',
can_auto_create: false,
can_build: true,
},
};
const wrapper = await mountView();
await flushPromises();
const expected = '等待系统启动';
const top = wrapper.find('[data-testid="review-progress-stage-label"]');
const cards = wrapper.findAll('[data-testid="review-current-processing-card"]');
expect(top.exists()).toBe(true);
expect(cards.length).toBeGreaterThanOrEqual(2);
expect(top.text()).toContain(expected);
for (const card of cards) {
expect(card.text()).toContain(expected);
expect(card.text()).not.toContain('库存匹配');
expect(card.text()).not.toContain('创建正式订单');
}
});
it('shows STP retry button for failed automation and calls retry API (UI-02)', async () => {
activeCase.value = {
...activeCase.value,
File diff suppressed because it is too large. Load diff
@@ -91,6 +91,38 @@ describe('ProcessGateRecoveryCard', () => {
}
});
it('hides the card for system worker / technical_auto_only waits', () => {
const wrapper = mount(ProcessGateRecoveryCard, {
props: {
summary: baseSummary({
technical_auto_only: true,
owner_type: 'system',
responsible_party: 'worker',
next_action_code: 'retry_inventory_preparation',
}),
canHandle: false,
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="process-gate-recovery-card"]').exists()).toBe(false);
expect(wrapper.text()).not.toContain('待处理事项');
});
it('hides the card when responsible_party is worker without owner_type', () => {
const wrapper = mount(ProcessGateRecoveryCard, {
props: {
summary: baseSummary({
responsible_party: 'worker',
owner_type: undefined,
technical_auto_only: false,
}),
canHandle: false,
},
global: { plugins: [i18n] },
});
expect(wrapper.find('[data-testid="process-gate-recovery-card"]').exists()).toBe(false);
});
it('maps audit event codes to business labels and clears cache on execution change', async () => {
const wrapper = mount(ProcessGateRecoveryCard, {
props: { summary: baseSummary({ execution_no: 'EXEC-1' }), canHandle: true },
@@ -1,9 +1,10 @@
/**
* features/shipping-process-gates/components/ProcessGateRecoveryCard.vue
* 用途:任务工作台展示当前待处理环节、原因、业务事实 details、责任方、下一步说明与恢复动作。
* 用途:任务/复核工作台展示当前待处理环节、原因、业务事实 details、责任方、下一步说明与恢复动作。
* 依赖:useShippingProcessGateRecovery、processGateNavigation、process-gates.api、
* ShippingProcessGateUserSummary / ShippingExplainabilityReason。
* 逻辑:导航类动作 router.push;confirm_customer 发射 confirmCustomer 由父级开弹窗;
* 逻辑:仅 owner_type=human(且非 technical_auto_only)时渲染;系统 Worker 等待整卡隐藏;
* 导航类动作 router.push;confirm_customer 发射 confirmCustomer 由父级开弹窗;
* POST 类动作调 Workspace API;409 触发 refreshed;
* 展示 explainability.details 白名单业务事实;下一步文案独立于按钮;
* 可展开审计;canHandle=false 时不渲染恢复主按钮,提示用 Footer;
@@ -81,6 +82,23 @@ const nextActionCode = computed(() =>
);
const hasRecoveryAction = computed(() => Boolean(blockingGate.value && nextActionCode.value));
/**
* 是否对业务用户展示「待处理事项」。
* 核心逻辑:technical_auto_only / owner_type=system 时整卡不渲染;
* 兼容旧投影:无 owner_type 时 responsible_party 为 system/worker 也不展示。
*/
const showAsHumanPending = computed(() => {
if (!props.summary || !blockingGate.value) return false;
if (props.summary.technical_auto_only) return false;
const owner = String(props.summary.owner_type || '').trim().toLowerCase();
if (owner === 'system') return false;
if (!owner) {
const party = String(props.summary.responsible_party || '').trim().toLowerCase();
if (party === 'system' || party === 'worker') return false;
}
return true;
});
/** 最近 Attempt 序号(用户可见);用于展示「已尝试 N 次」,不推导百分比。 */
const latestAttemptNo = computed(() => {
const raw = (blockingGate.value as { latest_attempt?: { attempt_no?: number } } | null)
@@ -311,8 +329,9 @@ function formatAuditEventLabel(item: Record<string, unknown>): string {
<template>
<section
v-if="summary && blockingGate"
v-if="showAsHumanPending"
class="rounded-2xl border border-amber-200/80 bg-amber-50/60 px-4 py-3 dark:border-amber-900/50 dark:bg-amber-950/20"
data-testid="process-gate-recovery-card"
>
<div class="mb-2 text-xs font-semibold uppercase tracking-wide text-amber-800 dark:text-amber-200">
{{ $t('workspace.shippingNotice.processGate.title') }}
@@ -153,4 +153,29 @@ describe('ReviewProgressStrip', () => {
await wrapper.get('[data-testid="review-progress-open-details"]').trigger('click');
expect(wrapper.emitted('open-process-details')).toHaveLength(1);
});
it('places process-details CTA on the title row', () => {
const wrapper = mountStrip(buildProjection());
const titleRow = wrapper.get('[data-testid="review-progress-title"]').element.parentElement;
const details = wrapper.get('[data-testid="review-progress-open-details"]').element;
expect(titleRow?.contains(details)).toBe(true);
});
it('places current-need inside the title row text (not a separate block)', () => {
const wrapper = mountStrip(buildProjection({
status: 'waiting',
currentGate: {
gateCode: 'freight_upload',
status: 'blocked',
nextActionCode: 'retry_freight_upload_rpa',
blockingReasonCode: null,
attemptNo: 1,
},
}));
const titleEl = wrapper.get('[data-testid="review-progress-title"]');
const need = wrapper.get('[data-testid="review-progress-current-need"]');
expect(titleEl.element.contains(need.element)).toBe(true);
expect(need.text()).toContain('当前需要');
expect(need.classes()).not.toContain('sr-only');
});
});
@@ -1,10 +1,9 @@
<!--
features/shipping-progress/components/ReviewProgressStrip.vue
用途:订单处理工作台只读进度——宽屏仅 15 阶主进度;窄屏摘要版。
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、stageNodesAuthority、gateReasonLabel.resolveCurrentNeedLabel。
逻辑:由 ReviewWorkflowProgressPanel 挂载;禁止点击节点;宽屏隐藏五域与 n/15 文案;
窄屏不展示 15 阶横条;有阻断 Gate 且非自动推进时显示「当前需要」(优先级 C);
「查看流程详情/完整流程」同一 emit;写操作只在 Footer。
用途:订单处理工作台只读进度——xl 等宽 15 阶;md 横向滚动;窄屏仅 N/15。
依赖:vue-i18n、ShippingProcessingProjection、progressWindow、stageNodesAuthority、gateReasonLabel。
逻辑:由 ReviewWorkflowProgressPanel 挂载;禁止点击节点;「当前需要」并入标题行文案;
「查看流程详情」在标题行右侧;正式 OT 后抑制「请确认建单」;写操作只在 Footer。
-->
<script setup lang="ts">
import { computed, watch } from 'vue';
@@ -13,7 +12,7 @@ import type {
ShippingProcessingProjection,
ShippingProcessingStageNodeStatus,
} from '@/features/chat/types/shipping.api.types';
import { shippingProcessingStageKey } from '@/features/chat/shipping/shippingProcessingLabels';
import { shippingProcessingStageKey, resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
import { buildProgressRangeHint } from '../progressWindow';
import {
readAuthoritativeStageNodes,
@@ -25,6 +24,8 @@ const props = defineProps<{
projection: ShippingProcessingProjection;
/** 宿主轮询中提示(显示在标题行)。 */
polling?: boolean;
/** 正式 OT 已创建时禁止再投影「请确认建单」类当前需要。 */
hasFormalOt?: boolean;
}>();
const emit = defineEmits<{
@@ -35,23 +36,38 @@ const emit = defineEmits<{
const { t, te } = useI18n();
const AUTOMATING_STATUSES = new Set(['processing', 'automating', 'queued']);
const CONFIRM_BUILD_ACTION_CODES = new Set([
'confirm_create',
'confirm_build',
'open_order_review',
'confirm_order',
]);
const SYSTEM_TECH_ACTION_PREFIXES = ['retry_', 'poll_'];
/** 权威 15 阶;非法时 null(fail-closed)。 */
const stageNodes = computed(() => readAuthoritativeStageNodes(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
));
const stageLabel = computed(() => {
const stage = props.projection.stage;
const key = shippingProcessingStageKey(stage);
return te(key) ? t(key) : String(stage || '');
/**
* 是否处于系统自动推进(含技术重试/轮询动作,避免被 nextAction 误判为人工待办)。
*/
const isAutomating = computed(() => {
const status = String(props.projection.status || '').trim().toLowerCase();
if (!AUTOMATING_STATUSES.has(status)) return false;
const next = String(props.projection.currentGate?.nextActionCode || '').trim().toLowerCase();
if (!next) return true;
if (SYSTEM_TECH_ACTION_PREFIXES.some((prefix) => next.startsWith(prefix))) return true;
return false;
});
const stageLabel = computed(() => resolveShippingProcessingStageLabel(
props.projection.stage,
te,
t,
props.projection.stageLabelKey,
));
/**
* 单行标题:自动推进用「系统处理中 · 阶段」;否则「订单处理进度 · 阶段」。
*/
@@ -65,11 +81,18 @@ const titleLine = computed(() => {
/**
* 有阻断 Gate 且非自动推进时展示「当前需要」。
* 正式 OT 已创建后禁止再显示确认建单类文案。
*/
const showCurrentNeed = computed(() => {
if (isAutomating.value) return false;
const gate = props.projection.currentGate;
if (!gate) return false;
const next = String(gate.nextActionCode || '').trim().toLowerCase();
if (props.hasFormalOt && CONFIRM_BUILD_ACTION_CODES.has(next)) return false;
if (props.hasFormalOt) {
const reason = String(gate.blockingReasonCode || '').trim().toLowerCase();
if (reason === 'waiting_review' || reason.includes('confirm')) return false;
}
return Boolean(
String(gate.blockingReasonCode || '').trim()
|| String(gate.nextActionCode || '').trim(),
@@ -110,26 +133,32 @@ function nodeToneClass(status: ShippingProcessingStageNodeStatus, isCurrent: boo
}
/**
* 节点展示短标签。
* 节点展示短标签(允许两行,不再截断到 4 字硬砍)。
*/
function nodeShortLabel(stage: string): string {
const key = shippingProcessingStageKey(stage);
const label = te(key) ? t(key) : stage;
return String(label).slice(0, 4);
return te(key) ? t(key) : stage;
}
</script>
<template>
<div
class="space-y-2"
class="space-y-1.5"
data-testid="review-progress-strip"
>
<div class="flex items-start justify-between gap-2">
<div class="flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5">
<div
class="min-w-0 text-sm font-semibold text-primary"
class="min-w-0 flex-1 text-sm font-semibold text-primary"
data-testid="review-progress-title"
>
{{ titleLine }}
<span
v-if="showCurrentNeed && currentNeed"
class="ml-2 font-semibold text-amber-800 dark:text-amber-200"
data-testid="review-progress-current-need"
>
· {{ t('chat.shippingProcessing.progress.currentNeedLabel') }}{{ currentNeed }}
</span>
<span
v-if="polling"
class="ml-2 text-[11px] font-normal text-muted"
@@ -138,25 +167,37 @@ function nodeShortLabel(stage: string): string {
{{ 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 class="flex shrink-0 flex-wrap items-center gap-2">
<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>
<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')"
>
<span class="hidden md:inline">{{ t('chat.shippingProcessing.progress.viewProcessDetails') }}</span>
<span class="md:hidden">{{ t('chat.shippingProcessing.progress.viewFullProcess') }}</span>
</button>
</div>
</div>
<!-- 宽屏:唯一主进度 = 15 阶只读条。 -->
<!-- xl:15 阶等宽铺满 -->
<div
v-if="stageNodes"
class="hidden lg:block"
class="hidden xl:block"
data-testid="review-progress-stage-nodes"
>
<div
class="flex gap-1 overflow-x-auto pb-1"
class="grid gap-1"
style="grid-template-columns: repeat(15, minmax(0, 1fr));"
role="list"
aria-label="shipping-processing-stages"
>
@@ -164,7 +205,7 @@ function nodeShortLabel(stage: string): string {
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="min-w-0 select-none rounded-md px-0.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"
@@ -172,22 +213,51 @@ function nodeShortLabel(stage: string): string {
: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 class="line-clamp-2 break-words">{{ nodeShortLabel(node.stage) }}</div>
</div>
</div>
</div>
<!-- md–xl:横向滚动、节点等宽 -->
<div
v-if="stageNodes"
class="hidden overflow-x-auto pb-1 md:block xl:hidden"
data-testid="review-progress-stage-nodes-scroll"
>
<div
class="flex gap-1"
role="list"
aria-label="shipping-processing-stages"
>
<div
v-for="node in stageNodes"
:key="`scroll-${node.stage}`"
role="listitem"
class="w-14 shrink-0 select-none rounded-md px-1 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="line-clamp-2 break-words">{{ nodeShortLabel(node.stage) }}</div>
</div>
</div>
</div>
<p
v-else
class="hidden text-[11px] text-amber-800 lg:block dark:text-amber-200"
class="hidden text-[11px] text-amber-800 md:block dark:text-amber-200"
data-testid="review-progress-stage-nodes-unavailable"
>
{{ t('chat.shippingProcessing.progress.stageNodesUnavailable') }}
</p>
<!-- 窄屏摘要:仅已完成 n/15(宽屏由节点色表达,不重复文案)。 -->
<!-- &lt;md:仅已完成 N/15 + 标题中的当前阶段 -->
<p
v-if="rangeHint"
class="text-[11px] text-secondary lg:hidden"
class="text-[11px] text-secondary md:hidden"
data-testid="review-progress-completed-summary"
>
{{ t('chat.shippingProcessing.progress.completedOfTotal', {
@@ -196,25 +266,5 @@ function nodeShortLabel(stage: string): string {
}) }}
</p>
<p
v-if="showCurrentNeed && 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')"
>
<span class="hidden lg:inline">{{ t('chat.shippingProcessing.progress.viewProcessDetails') }}</span>
<span class="lg:hidden">{{ t('chat.shippingProcessing.progress.viewFullProcess') }}</span>
</button>
</div>
</div>
</template>
@@ -3,7 +3,8 @@
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办说明(表单/弹窗入口)。
* 依赖:ProcessGateRecoveryCard、shipping.api、shipping-tasks.api、ManualUploadEvidenceDialog。
* 逻辑:gateCanHandle 控制 Gate 卡写按钮;actionsExecutable 控制 invokeActionByCode / 对话框写;
* hidePrimaryActions=true 时不渲染 action_buttons(订单处理工作台写入口仅 Footer)。
* hidePrimaryActions=true 时不渲染 action_buttons(订单处理工作台写入口仅 Footer);
* 系统 Worker / technical_auto_only 不计入人工阻断,避免「待处理事项」冒充系统等待。
*/
<script setup lang="ts">
import { computed, ref } from 'vue';
@@ -179,7 +180,28 @@ const allowedIds = computed(() => {
if (Array.isArray(fromSummary) && fromSummary.length) return new Set(fromSummary.map(String));
return new Set(actionButtons.value.map((item) => item.id));
});
const hasBlockingGate = computed(() => Boolean(processGateSummary.value?.current_blocking_gate));
const hasBlockingGate = computed(() => {
const gate = processGateSummary.value;
if (!gate?.current_blocking_gate) return false;
if (gate.technical_auto_only) return false;
const owner = String(gate.owner_type || '').trim().toLowerCase();
if (owner === 'system') return false;
if (!owner) {
const party = String(gate.responsible_party || '').trim().toLowerCase();
if (party === 'system' || party === 'worker') return false;
}
return true;
});
/** 系统自动等待:禁止用「待处理事项」或 STP 待办卡冒充人工动作。 */
const isSystemAutoWait = computed(() => {
const gate = processGateSummary.value;
if (!gate) return false;
if (gate.technical_auto_only) return true;
if (String(gate.owner_type || '').trim().toLowerCase() === 'system') return true;
if (!gate.current_blocking_gate) return false;
return !hasBlockingGate.value;
});
const UNIFIED_OWNED_ACTION_IDS = new Set([
'retry',
@@ -500,7 +522,7 @@ defineExpose({
@confirm-customer="() => void openCustomerDialog()"
/>
<section
v-if="!hasBlockingGate"
v-if="!hasBlockingGate && !isSystemAutoWait"
class="rounded-2xl border border-brand-200/80 bg-brand-50/40 px-4 py-3"
>
<div class="mb-1 text-xs font-semibold uppercase tracking-wide text-brand-700">