feat(shipping-notice): 实现对话级批量重试自动推进功能,优化库存与PDF匹配逻辑

- 新增对话级批量重试自动推进的完整链路:后端服务、API、数据投影逻辑
- 前端新增对话级重试按钮、多语言国际化支持与API类型定义
- 优化行级库存重试控制,新增retryable字段统一管控重试按钮展示,清理废弃的view_fulfillment_detail动作,标准化前端动作码排序逻辑
- 修复PDF坐标匹配的fail-close防护逻辑,避免生成伪精确匹配分数
- 调整订单确认后流程,提前进入库存获取阶段,移除冗余的确认建单按钮,优化用户流转体验
- 新增对应单元测试用例覆盖核心业务逻辑
This commit is contained in:
hugo committed 2026-08-07 16:30:45 +08:00
1 parent fd6a23f870
commit 1008911a7e
41 files changed
+3956 -1256

No files matched your search

@@ -78,13 +78,14 @@ const statusLabel = computed(() => {
});
/**
* 主卡重试:仅在有 task_no 且非 task_missing 时由父组件控制 showRetry。
* 主卡重试:对象级;建单前无 task_no 也可重试 STP;正式 OT 需 task_no。
*/
const canShowRetry = computed(() => (
Boolean(props.showRetry)
&& !props.taskMissing
&& Boolean(String(props.taskNo || '').trim())
));
const canShowRetry = computed(() => {
if (!props.showRetry || props.taskMissing) return false;
if (String(props.taskNo || '').trim()) return true;
// 建单前 STP:无 OT 号也可重试。
return String(props.automation?.phase || '').trim() !== 'post_ot_progress';
});
</script>
<template>
@@ -149,7 +150,7 @@ const canShowRetry = computed(() => (
@click="emit('retry')"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ t('chat.shippingOrderReview.autoProgress.retryStp') }}
{{ t('chat.shippingOrderReview.autoProgress.retryObject') }}
</button>
</section>
</template>
@@ -1,6 +1,6 @@
/**
* features/chat/components/shipping-review/ReviewLineInventoryOps.spec.ts
* 用途:锁定库存浮层仅渲染 inventory_allowed_actions;关闭在更多操作;Teleport 菜单可见。
* 用途:锁定行级只渲染统一「重试」与关闭;消费 retryable,不展示内部动作码。
*/
import { afterEach, describe, expect, it } from 'vitest';
@@ -17,11 +17,8 @@ const i18n = createI18n({
chat: {
shippingOrderReview: {
lineOps: {
inventoryProcessing: '库存处理',
retryPreparation: '重试获取库存',
retryMatching: '重新匹配库存',
retry: '重试',
moreActions: '更多操作',
viewFulfillment: '查看履约详情',
},
fulfillmentDecision: {
closeLine: '关闭该明细',
@@ -32,11 +29,12 @@ const i18n = createI18n({
},
});
function mountOps(line: Partial<ShippingOrderReviewLineFulfillmentLine>) {
function mountOps(line: Partial<ShippingOrderReviewLineFulfillmentLine>, extra: Record<string, unknown> = {}) {
return mount(ReviewLineInventoryOps, {
props: {
line: line as ShippingOrderReviewLineFulfillmentLine,
editable: true,
...extra,
},
attachTo: document.body,
global: { plugins: [i18n] },
@@ -48,68 +46,44 @@ afterEach(() => {
});
describe('ReviewLineInventoryOps', () => {
it('shows only preparation when matching not allowed', async () => {
it('shows unified retry when retryable', async () => {
const wrapper = mountOps({
inventory_allowed_actions: ['retry_inventory_preparation'],
retryable: true,
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();
expect(wrapper.find('[data-testid="review-line-retry"]').exists()).toBe(true);
await wrapper.get('[data-testid="review-line-retry"]').trigger('click');
expect(wrapper.emitted('retry-line')?.length).toBe(1);
wrapper.unmount();
});
it('puts close under more actions, not inventory panel', async () => {
it('hides retry when not retryable even if internal actions present', () => {
const wrapper = mountOps({
inventory_allowed_actions: ['retry_inventory_preparation'],
retryable: false,
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
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-retry"]').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 () => {
it('disables retry while task running', () => {
const wrapper = mountOps({
inventory_allowed_actions: [],
retryable: true,
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();
}, { taskRunning: true });
expect(wrapper.find('[data-testid="review-line-retry"]').exists()).toBe(false);
wrapper.unmount();
});
it('emits retry-inventory for both floating actions', async () => {
it('puts close under more actions', async () => {
const wrapper = mountOps({
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
line_allowed_actions: [],
retryable: false,
line_allowed_actions: ['close_unfulfillable'],
});
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']);
await wrapper.get('[data-testid="review-line-more-actions"]').trigger('click');
expect(document.querySelector('[data-testid="review-line-decide-close"]')).toBeTruthy();
wrapper.unmount();
});
});
@@ -1,118 +1,55 @@
<!--
features/chat/components/shipping-review/ReviewLineInventoryOps.vue
用途:明细行库存处理浮层 + 行级更多操作(关闭);不进库存工作台、不在右侧挂动作。
依赖:vue-i18n、lucide、line.inventory_allowed_actions / line_allowed_actions。
逻辑:优先后端动作;库存问题态后端漏下发时前端兜底 preparation(+匹配失败时 matching);
菜单 Teleport 到 body,避免表格 overflow 裁切。
用途:明细行统一「重试」+ 更多操作(关闭);不进库存工作台。
依赖:vue-i18n、lucide、line.retryable / line_allowed_actions。
逻辑:只消费 retryable 布尔与 close 动作;不展示内部动作码;不发具体节点。
-->
<script setup lang="ts">
import { computed, nextTick, onBeforeUnmount, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { MoreHorizontal, Warehouse } from 'lucide-vue-next';
import { MoreHorizontal, RefreshCw } 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;
/** 任务整体 queued/running 时禁用行级写 */
taskRunning?: boolean;
}>();
const emit = defineEmits<{
'retry-inventory': [actionCode: 'retry_inventory_preparation' | 'retry_inventory_matching'];
'retry-line': [];
'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。
* 是否展示统一「重试」:仅后端 retryable,且任务未整体运行。
*/
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 showRetry = computed(() => (
Boolean(props.line?.retryable)
&& !props.taskRunning
));
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);
const canClose = computed(() => (
[...(props.line?.line_allowed_actions || [])].includes('close_unfulfillable')
));
const showMore = computed(() => canClose.value);
/**
* 按触发按钮定位浮动菜单(fixed,避免被表格 overflow 裁切)。
* 定位更多菜单。
*/
function placeMenu(anchor: HTMLElement | null, target: typeof inventoryMenuStyle) {
function placeMenu(anchor: HTMLElement | null) {
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 = {
moreMenuStyle.value = {
position: 'fixed',
top: `${Math.round(rect.bottom + 4)}px`,
left: `${Math.round(left)}px`,
@@ -121,68 +58,31 @@ function placeMenu(anchor: HTMLElement | null, target: typeof inventoryMenuStyle
};
}
/**
* 关闭所有浮层。
*/
function closeMenus() {
inventoryMenuOpen.value = false;
moreMenuOpen.value = false;
}
/**
* 文档点击/滚动时关闭浮层,避免残留遮挡。
*/
function onDocPointerDown(event: Event) {
const target = event.target as Node | null;
const target = event.target as HTMLElement | 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;
if (target.closest?.('[data-testid="review-line-more-menu"]')) return;
if (target.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);
placeMenu(moreBtnRef.value);
}
}
/**
* 触发库存动作并关闭浮层。
*/
function onRetry(actionCode: 'retry_inventory_preparation' | 'retry_inventory_matching') {
closeMenus();
emit('retry-inventory', actionCode);
function onRetry() {
if (props.busy || props.taskRunning || !showRetry.value) return;
emit('retry-line');
}
/**
* 关闭明细(由父级弹确认框)。
*/
function onCloseLine() {
closeMenus();
emit('close-line');
@@ -190,33 +90,27 @@ function onCloseLine() {
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"
v-if="showRetry"
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"
class="inline-flex items-center gap-0.5 rounded border border-amber-300 bg-amber-50 px-1.5 py-0.5 text-[11px] text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
data-testid="review-line-retry"
:disabled="!editable || busy || taskRunning"
:aria-label="t('chat.shippingOrderReview.lineOps.retry')"
:title="t('chat.shippingOrderReview.lineOps.retry')"
@click="onRetry"
>
<Warehouse class="h-3.5 w-3.5" aria-hidden="true" />
<RefreshCw class="h-3 w-3" :class="busy ? 'animate-spin' : ''" aria-hidden="true" />
{{ t('chat.shippingOrderReview.lineOps.retry') }}
</button>
<button
@@ -225,7 +119,7 @@ onBeforeUnmount(() => {
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"
:disabled="!editable || busy || taskRunning"
:aria-label="t('chat.shippingOrderReview.lineOps.moreActions')"
:title="t('chat.shippingOrderReview.lineOps.moreActions')"
:aria-expanded="moreMenuOpen"
@@ -235,35 +129,6 @@ onBeforeUnmount(() => {
</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"
@@ -271,16 +136,6 @@ onBeforeUnmount(() => {
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"
@@ -203,7 +203,7 @@ function flowLabel(item: ActionPresentationItem): string {
data-testid="review-retry-stp-auto-create"
@click="emit('retry-stp')"
>
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.autoProgress.retryStp') }}
<RefreshCw class="h-4 w-4" />{{ t('chat.shippingOrderReview.autoProgress.retryObject') }}
</button>
<button
v-if="hasAction('validate')"
@@ -214,17 +214,6 @@ function flowLabel(item: ActionPresentationItem): string {
>
<Save class="h-4 w-4" />{{ t('chat.shippingOrderReview.saveNow') }}
</button>
<button
v-if="hasAction('confirm') && !hideConfirmBecauseAutoGate"
type="button"
:disabled="controlsBusy || !canConfirmBuild"
class="rounded bg-emerald-600 px-3 py-2 text-sm font-medium text-white disabled:opacity-50"
data-testid="review-confirm-create"
:title="!canConfirmBuild ? t('chat.shippingOrderReview.buildEligibility.confirmBlocked') : undefined"
@click="emit('confirm')"
>
{{ t('chat.shippingOrderReview.confirmCreate') }}
</button>
</template>
</div>
</footer>
@@ -1,12 +1,13 @@
<!--
features/chat/components/shipping-review/ReviewWorkbenchHeader.vue
用途:订单复核工作台顶栏,展示标题上下文与保存状态。
用途:订单复核工作台顶栏——对话级动作、审计/版本入口与保存状态。
依赖:vue-i18n、lucide-vue-next。
逻辑:ShippingOrderReviewView 传入 run/reviewProgressContext 上下文;emit back 与 open-version-history;不含对话上下文切换。
逻辑:仅当后端 conversation_allowed_actions 含 retry_auto_progress 时渲染对话级按钮;
审计/版本为查看入口;「已保存」为状态文本;不含单个任务单写操作。
-->
<script setup lang="ts">
import { computed } from 'vue';
import { ArrowLeft } from 'lucide-vue-next';
import { ArrowLeft, RefreshCw } from 'lucide-vue-next';
import { useI18n } from 'vue-i18n';
const props = defineProps<{
@@ -19,12 +20,18 @@ const props = defineProps<{
isReadOnly: boolean;
showVersionHistory?: boolean;
showAuditTrail?: boolean;
/** 对话级「重试自动推进」;仅 eligible_count>0 时由父级置 true */
showConversationRetry?: boolean;
conversationRetryEligibleCount?: number;
conversationRetrying?: boolean;
conversationRetryDisabled?: boolean;
}>();
const emit = defineEmits<{
back: [];
'open-version-history': [];
'open-audit-trail': [];
'retry-conversation-auto-progress': [];
}>();
const { t } = useI18n();
@@ -41,6 +48,11 @@ const subtitle = computed(() => {
}
return t('chat.shippingOrderReview.run', { runNo: props.runNo });
});
const showRetry = computed(() => (
Boolean(props.showConversationRetry)
&& Number(props.conversationRetryEligibleCount || 0) > 0
));
</script>
<template>
@@ -57,6 +69,24 @@ const subtitle = computed(() => {
<h1 class="text-base font-semibold">{{ t('chat.shippingOrderReview.title') }}</h1>
<p class="truncate text-xs text-slate-500 dark:text-slate-400">{{ subtitle }}</p>
</div>
<button
v-if="showRetry"
type="button"
class="inline-flex items-center gap-1 rounded border border-amber-400 bg-amber-50 px-2.5 py-1.5 text-xs font-medium text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
data-testid="review-conversation-retry-auto-progress"
:disabled="conversationRetrying || conversationRetryDisabled || isReadOnly"
@click="emit('retry-conversation-auto-progress')"
>
<RefreshCw
class="h-3.5 w-3.5"
:class="conversationRetrying ? 'animate-spin' : ''"
/>
{{ t('chat.shippingOrderReview.autoProgress.retry') }}
<span
v-if="conversationRetryEligibleCount"
class="rounded bg-amber-200/80 px-1 text-[10px] dark:bg-amber-900/60"
>{{ conversationRetryEligibleCount }}</span>
</button>
<button
v-if="showAuditTrail"
type="button"
@@ -204,7 +204,7 @@ describe('ShippingConversationProcessingCard', () => {
const doneCard = wrapper.find('[data-testid="shipping-processing-task-OT-DONE"]');
expect(doneCard.find('[data-testid="sidebar-progress-inline"]').exists()).toBe(false);
expect(doneCard.find('[data-testid="shipping-processing-task-actions"]').exists()).toBe(false);
expect(doneCard.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
expect(doneCard.find('[data-testid="shipping-processing-action-view_result"]').exists()).toBe(true);
expect(doneCard.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
});
@@ -241,13 +241,10 @@ describe('ShippingConversationProcessingCard', () => {
expect(titleEl.text()).not.toContain('4518838152.pdf');
// UI-02:有文件对象时不双开「查看详情」与「展开文件详情」。
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
await wrapper.find('[data-testid="shipping-processing-expand-files"]').trigger('click');
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').text()).toContain('取消整个任务');
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(false);
});
it('shows view_details when task cannot expand file details, and keeps cancel as overflow', async () => {
@@ -274,10 +271,10 @@ describe('ShippingConversationProcessingCard', () => {
});
await flushPromises();
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
// 无文件对象时取消可直接挂在卡上(低频文字链,非主 CTA)。
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-overflow-actions"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-action-cancel_task"]').exists()).toBe(false);
});
it('shows multi-document title from authoritative projection without workflow fallback', async () => {
@@ -384,11 +381,7 @@ describe('ShippingConversationProcessingCard', () => {
global: { plugins: [i18n] },
});
await flushPromises();
const expandBtn = wrapper.find('[data-testid="shipping-processing-expand-files"]');
await expandBtn.trigger('click');
expect(wrapper.emitted('expandFiles')?.[0]?.[0]).toMatchObject({ user_task_no: 'OT-NEED' });
await expandBtn.trigger('click');
expect(wrapper.emitted('collapseFiles')).toBeTruthy();
expect(wrapper.find('[data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
});
it('renders twenty processing tasks in one top-level container', async () => {
@@ -490,12 +483,12 @@ describe('ShippingConversationProcessingCard', () => {
});
await flushPromises();
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(2);
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(1);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').text()).toContain('待复核');
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').text()).toContain('库存匹配');
expect(wrapper.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
// UI-02:有 workItem 时仍保留展开文件详情(OT-NEED 为多文件)。
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-expand-files"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
});
@@ -265,26 +265,28 @@ function primaryActionItem(task: ConversationProcessingUserTask): ActionPresenta
return taskActionPresentation(task).primary;
}
/** needs_action 的用户语义提示:不重复主按钮文案。 */
function currentNeedLabel(task: ConversationProcessingUserTask): string {
if (task.group !== 'needs_action') return '';
const action = String(task.primary_action || task.available_actions?.[0] || '').trim().toLowerCase();
const labels: Record<string, string> = {
confirm_customer: 'chat.shippingProcessing.currentNeed.confirmCustomer',
resolve_field_conflicts: 'chat.shippingProcessing.currentNeed.resolveFieldConflicts',
open_inventory_match_review: 'chat.shippingProcessing.currentNeed.inventoryMatch',
open_order_processing: 'chat.shippingProcessing.currentNeed.orderDraft',
retry: 'chat.shippingProcessing.currentNeed.retry',
retry_parse: 'chat.shippingProcessing.currentNeed.retry',
};
const key = labels[action];
return key && te(key) ? t(key) : t('chat.shippingProcessing.currentNeed.generic');
}
/**
* 次要文字链:有文件对象时可展开 → 不返回 view_details(改由展开文件入口承载);
* 无文件对象时优先 view_details,否则取非 cancel 的 presentation.secondary。
*/
function secondaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
if (canExpandFileDetails(task)) return null;
const presentation = taskActionPresentation(task);
const candidates = [
presentation.secondary,
...presentation.overflow,
].filter((item): item is ActionPresentationItem => Boolean(item));
const viewDetails = candidates.find(
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
);
if (viewDetails) return viewDetails;
const secondary = presentation.secondary;
if (!secondary) return null;
const code = String(secondary.actionCode || '').trim().toLowerCase();
if (code === 'cancel_task' || code === 'cancel_run' || code === 'view_details') return null;
return secondary;
function secondaryActionItem(_task: ConversationProcessingUserTask): ActionPresentationItem | null {
return null;
}
/**
@@ -310,11 +312,8 @@ function overflowActionItems(task: ConversationProcessingUserTask): ActionPresen
* 是否展示低频溢出:有文件对象时仅展开后显示;无文件对象时直接挂在卡上(如取消)。
* 有 workItem 时不渲染任务级溢出(动作由进度条负责)。
*/
function shouldShowOverflowActions(task: ConversationProcessingUserTask): boolean {
if (projectionForTask(task)) return false;
if (!overflowActionItems(task).length) return false;
if (canExpandFileDetails(task)) return isDetailsExpanded(task);
return true;
function shouldShowOverflowActions(_task: ConversationProcessingUserTask): boolean {
return false;
}
/**
@@ -329,15 +328,19 @@ function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boole
* 处理记录只读卡:仅保留 view_details 文字链(无主 CTA / 取消 / 重解析)。
*/
function recordViewDetailsItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
if (String(task.status_label || '').trim().toLowerCase() === 'cancelled') return null;
const presentation = taskActionPresentation(task);
const candidates = [
presentation.primary,
presentation.secondary,
...presentation.overflow,
].filter((item): item is ActionPresentationItem => Boolean(item));
return candidates.find(
(item) => String(item.actionCode || '').trim().toLowerCase() === 'view_details',
) || null;
return candidates.find((item) => {
const code = String(item.actionCode || '').trim().toLowerCase();
return code === 'view_details' || code === 'view_result';
}) || (String(task.group || '') === 'completed'
? { intent: 'view_result', actionCode: 'view_result', labelKey: 'chat.shippingProcessing.action.view_result' }
: null);
}
/**
@@ -591,8 +594,15 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
</div>
</button>
<div
v-if="task.group === 'needs_action' && currentNeedLabel(task)"
class="mt-1 text-[11px] text-secondary"
data-testid="shipping-processing-current-need"
>
{{ t('chat.shippingProcessing.progress.currentNeedLabel') }}{{ currentNeedLabel(task) }}
</div>
<SidebarProgressInline
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
v-if="task.group === 'processing' && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
class="mt-1.5 border-t border-current/10 pt-1.5"
:projection="projectionForTask(task)!"
:compact="progressModeForTask(task) === 'compact'"
@@ -612,57 +622,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
>
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
</button>
<button
v-if="canExpandFileDetails(task)"
type="button"
class="inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
data-testid="shipping-processing-expand-files"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<button
v-else-if="secondaryActionItem(task)"
type="button"
class="text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
:data-testid="`shipping-processing-action-${secondaryActionItem(task)!.actionCode}`"
@click="onTaskAction(task, secondaryActionItem(task)!.actionCode)"
>
{{ presentationActionLabel(task, secondaryActionItem(task)!) }}
</button>
</div>
<button
v-else-if="canExpandFileDetails(task)"
type="button"
class="mt-1.5 inline-flex items-center gap-1 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
data-testid="shipping-processing-expand-files"
@click="onToggleDetails(task)"
>
<ChevronDown v-if="isDetailsExpanded(task)" class="h-3 w-3" />
<ChevronRight v-else class="h-3 w-3" />
{{ isDetailsExpanded(task)
? t('chat.shippingProcessing.collapseFileDetails')
: t('chat.shippingProcessing.expandFileDetails') }}
</button>
<div
v-if="shouldShowOverflowActions(task)"
class="mt-1.5 flex flex-wrap gap-x-3 gap-y-1"
data-testid="shipping-processing-task-overflow-actions"
>
<button
v-for="item in overflowActionItems(task)"
:key="`${task.user_task_no}-overflow-${item.actionCode}`"
type="button"
class="text-[11px] text-muted underline-offset-2 hover:text-secondary hover:underline"
:data-testid="`shipping-processing-action-${item.actionCode}`"
@click="onTaskAction(task, item.actionCode)"
>
{{ presentationActionLabel(task, item) }}
</button>
<span v-if="task.group === 'needs_action'" class="sr-only">{{ currentNeedLabel(task) }}</span>
</div>
</article>
</div>
@@ -54,7 +54,7 @@ const props = defineProps<{
controller?: UseShippingNoticeWorkflowReturn | null;
}>();
const { t, te, locale } = useI18n();
const { t, te } = useI18n();
const msg = useMessage();
const route = useRoute();
const router = useRouter();
@@ -93,8 +93,6 @@ const ctl = computed((): UseShippingNoticeWorkflowReturn => (
const collapsed = ref(false);
/** 复核返回对话时展示的聚焦提示(由 focus_notice 触发一次)。 */
const focusTaskBanner = ref<string | null>(null);
/** 侧栏默认展示本批次全部文件,用户需要同时看到已完成与待处理状态。 */
const pendingOnlyFilter = ref(false);
const actionBusyItemNo = ref<string | null>(null);
const detailOpen = ref(false);
const detailLoading = ref(false);
@@ -106,28 +104,26 @@ const reasonDialogItem = ref<ShippingWorkflowItem | null>(null);
/** 任务级取消:走 Run API,不绑单个 WorkflowItem。 */
const reasonDialogRunNo = ref<string | null>(null);
/** 当前展开文件明细的 OT 任务;收起后清空。 */
/** 移除右侧常驻批次与文件列表:文件明细改为进入订单处理工作台后展示。 */
const expandedTask = ref<ConversationProcessingUserTask | null>(null);
/** 文件明细:由展开任务的 document objects 合成。 */
/** 文件行仅用于 Gate 恢复卡、路由聚焦匹配 activeItem 与 open_review 动作兜底。 */
const items = computed((): ShippingWorkflowItem[] => (
mapUserTaskObjectsToFileRows(expandedTask.value)
));
const processing = computed(() => ctl.value.processing?.value ?? null);
const processingWorkItems = computed((): ShippingProcessingProjection[] => (
Array.isArray(ctl.value.processingWorkItems?.value)
? ctl.value.processingWorkItems.value
: []
));
const processing = computed(() => ctl.value.processing?.value ?? null);
/** 展示投影:统一 ShippingProcessing / conversation_processing。 */
const displayProcessing = computed(() => processing.value);
const loading = computed(() => ctl.value.loading.value);
/** 初始加载:首次打开投影仍为空时显示摘要占位。 */
const initialLoading = computed(() => Boolean(ctl.value.initialLoading?.value));
/** 用户主动刷新(刷新按钮 / 重试 / 重解析等):驱动顶部刷新图标旋转。 */
const manualRefreshing = computed(() => Boolean(ctl.value.manualRefreshing?.value));
const error = computed(() => ctl.value.error.value);
/** 用户从任务卡展开后,按任务内当前有效 PDF 身份过滤;旧数据才回退到 run_no。 */
const fileFilterRunNo = ref<string | null>(null);
const fileFilterDocumentKeys = ref<Set<string>>(new Set());
/** 任务卡明确展开文件详情时为 true(有任务卡时才约束显隐)。 */
const filesDetailVisible = ref(false);
/** 路由或复核返回的权威 OT 聚焦号。 */
const routeFocusedTaskNo = computed(() => String(
route.query.focus_task_no
|| focusTaskBanner.value
@@ -155,53 +151,6 @@ const activeItem = computed(() => {
}) || items.value.find((item) => resolveItemDisplayStatus(item) === 'pending_review') || items.value[0] || null;
});
const visibleItems = computed(() => {
const documentKeys = fileFilterDocumentKeys.value;
if (documentKeys.size) {
return items.value.filter((item) => workflowItemDocumentKeys(item).some(
(key) => documentKeys.has(key),
));
}
const runNo = String(fileFilterRunNo.value || '').trim();
if (!runNo) return items.value;
return items.value.filter((item) => String(item.current_run_no || '').trim() === runNo);
});
/**
* 解析 WorkflowItem 的 PDF 身份候选,顺序与后端聚合契约一致。
* @param item - 侧栏 WorkflowItem
* @returns 可用于匹配任务文档对象的稳定身份键列表
*/
function workflowItemDocumentKeys(item: ShippingWorkflowItem): string[] {
const keys: string[] = [];
const hash = String(item.content_hash || '').trim().toLowerCase();
const rootId = Number(item.root_document_id || 0);
const documentId = Number(item.current_document_id || 0);
if (hash) keys.push(`hash:${hash}`);
if (rootId > 0) keys.push(`root:${rootId}`);
if (documentId > 0) keys.push(`doc:${documentId}`);
return keys;
}
/**
* 解析任务投影内当前有效 PDF 身份,用于跨 Run 展开完整文件集合。
* @param task - 用户可见任务卡
* @returns 当前有效 PDF 的稳定身份键集合
*/
function taskDocumentKeys(task: ConversationProcessingUserTask): Set<string> {
const keys = new Set<string>();
for (const object of task.objects || []) {
if (object.kind !== 'document') continue;
const hash = String(object.content_hash || '').trim().toLowerCase();
const rootId = Number(object.root_document_id || 0);
const documentId = Number(object.document_id || 0);
if (hash) keys.add(`hash:${hash}`);
if (rootId > 0) keys.add(`root:${rootId}`);
if (documentId > 0) keys.add(`doc:${documentId}`);
}
return keys;
}
/** 任务聚合投影存在时隐藏独立「当前阶段」卡,避免三套状态重复(UI-F04)。 */
const showStandaloneCurrentStage = computed(() => {
const projection = displayProcessing.value;
@@ -248,12 +197,9 @@ watch(
);
/**
* 文件列表显隐:有用户任务卡时仅展开后显示;无任务卡时不展示空壳文件抽屉。
* 移除右侧常驻「批次与文件列表」长列表抽屉(UI-REFACTOR 方案 7)。
* 文件明细进入订单处理工作台后展示;此处仅保留 Gate 卡与独立 DetailDrawer,避免两套投影矛盾与高度抖动。
*/
const showFilesDrawer = computed(() => {
if (collapsed.value) return false;
return filesDetailVisible.value && Boolean(expandedTask.value);
});
function itemActivityLabel(item: ShippingWorkflowItem | null): string {
if (!item) return t('chat.shippingProcessing.emptyCompact');
@@ -357,25 +303,28 @@ async function onProcessingFocus(taskNo: string) {
}
/**
* 展开任务文件详情:优先按任务内当前有效 PDF 集合过滤;旧投影回退到代表 run_no。
* 展开文件详情 → 直接进入订单处理工作台(方案 7:移除右侧常驻文件列表)。
* 文件明细在工作台展示;此处仍保留 expandedTask 以便 Gate 卡找到聚焦 Run。
* 无 run_no 时 toast 提示,禁止静默 return。
*/
function onExpandTaskFiles(task: ConversationProcessingUserTask) {
async function onExpandTaskFiles(task: ConversationProcessingUserTask) {
const runNo = String(task.run_no || '').trim();
const documentKeys = taskDocumentKeys(task);
expandedTask.value = task;
fileFilterDocumentKeys.value = documentKeys;
fileFilterRunNo.value = documentKeys.size ? null : (runNo || null);
filesDetailVisible.value = true;
// 走原有工作台入口,保持与「继续处理」按钮一致;失败则静默(仍保留本地聚焦)。
if (runNo) {
try {
await openReviewFromTask(task);
} catch {
/* 路由失败不阻塞,交由上层统一错误处理。 */
}
}
}
/**
* 收起任务文件详情:清空过滤并隐藏下方文件列表。
* 收起文件详情:仅清空本地过滤聚焦态,右侧不再常驻文件长列表。
*/
function onCollapseTaskFiles() {
expandedTask.value = null;
fileFilterRunNo.value = null;
fileFilterDocumentKeys.value = new Set();
filesDetailVisible.value = false;
}
/**
@@ -461,104 +410,6 @@ async function onProcessingTaskAction(payload: {
}
}
type ItemGroupKey =
| 'processing'
| 'queued'
| 'completed'
| 'pending_review'
| 'failed'
| 'waiting_manual_upload';
const PROCESSING_STATUSES = new Set([
'layout_parsing',
'extracting',
'building_order',
'inventory_matching',
'generating_excel',
]);
const QUEUED_STATUSES = new Set(['queued']);
const FAILED_STATUSES = new Set(['failed', 'reparse_failed']);
/** 真正完成/取消;待人工登记不是完成。 */
const COMPLETED_STATUSES = new Set(['closed', 'cancelled']);
const WAITING_MANUAL_UPLOAD_STATUSES = new Set(['manual_upload_pending']);
const UPLOAD_RPA_RUNNING_STATUSES = new Set(['upload_rpa_pending', 'upload_rpa_running']);
const PENDING_REVIEW_STATUSES = new Set(['pending_review']);
const ACTIONABLE_FILTER_STATUSES = new Set([
'pending_review',
'failed',
'reparse_failed',
'queued',
'manual_upload_pending',
'upload_rpa_pending',
'upload_rpa_running',
'upload_rpa_failed',
]);
/**
* 将 Item 归入展示分组;优先 is_waiting_manual_upload / display(禁止单靠 lifecycle 推断人工待办)。
*/
function resolveGroup(item: ShippingWorkflowItem): ItemGroupKey {
const display = resolveItemDisplayStatus(item);
if (PENDING_REVIEW_STATUSES.has(display)) return 'pending_review';
if (FAILED_STATUSES.has(display) || display === 'upload_rpa_failed') return 'failed';
if (UPLOAD_RPA_RUNNING_STATUSES.has(display)) return 'processing';
if (item.is_waiting_manual_upload === true || item.upload_phase === 'manual_pending') {
return 'waiting_manual_upload';
}
if (WAITING_MANUAL_UPLOAD_STATUSES.has(display) && item.is_waiting_manual_upload !== false) {
return 'waiting_manual_upload';
}
const status = String(item.lifecycle_status || '').trim();
if (PENDING_REVIEW_STATUSES.has(status)) return 'pending_review';
if (FAILED_STATUSES.has(status)) return 'failed';
if (
item.is_waiting_manual_upload !== false
&& WAITING_MANUAL_UPLOAD_STATUSES.has(status)
&& !UPLOAD_RPA_RUNNING_STATUSES.has(display)
&& display !== 'upload_rpa_failed'
&& item.upload_phase !== 'rpa_pending'
&& item.upload_phase !== 'rpa_running'
&& item.upload_phase !== 'rpa_failed'
) {
return 'waiting_manual_upload';
}
if (COMPLETED_STATUSES.has(status)) return 'completed';
if (QUEUED_STATUSES.has(status)) return 'queued';
if (PROCESSING_STATUSES.has(status)) return 'processing';
return 'processing';
}
/**
* 是否允许取消:优先后端 available_actions;无 Run 时隐藏(co8 Workflow Item API 已下线)。
*/
function canCancel(item: ShippingWorkflowItem): boolean {
if (!String(item.current_run_no || '').trim()) return false;
const actions = item.available_actions;
if (Array.isArray(actions)) return actions.includes('cancel');
return !COMPLETED_STATUSES.has(String(item.lifecycle_status || '').trim());
}
/**
* 是否允许重试/重新识别:必须以后端 available_actions 为准,且绑定 current_run_no。
*/
function canReparse(item: ShippingWorkflowItem): boolean {
if (!String(item.current_run_no || '').trim()) return false;
const actions = item.available_actions;
if (Array.isArray(actions)) return actions.includes('reparse');
// 无契约时 fail-closed:禁止仅凭 pending_review 展示(会稳定触发 CASE_REQUIRED)。
return false;
}
/**
* 重识别按钮文案:区分 Case 新版本与失败 Run 重试。
*/
function reparseActionLabel(item: ShippingWorkflowItem): string {
if (item.reparse_kind === 'failed_run_retry') {
return t('chat.shippingProcessing.actions.retryFailedRun');
}
return t('chat.shippingProcessing.actions.reparse');
}
/**
* 列表主标题:优先文件名。
*/
@@ -570,42 +421,6 @@ function itemTitle(item: ShippingWorkflowItem): string {
});
}
const filteredItems = computed(() => {
const source = visibleItems.value;
if (!pendingOnlyFilter.value) return source;
return source.filter((item) => {
const display = resolveItemDisplayStatus(item);
return (
ACTIONABLE_FILTER_STATUSES.has(display)
|| ACTIONABLE_FILTER_STATUSES.has(String(item.lifecycle_status || '').trim())
);
});
});
const grouped = computed(() => {
const buckets: Record<ItemGroupKey, ShippingWorkflowItem[]> = {
processing: [],
queued: [],
pending_review: [],
waiting_manual_upload: [],
failed: [],
completed: [],
};
for (const item of filteredItems.value) {
buckets[resolveGroup(item)].push(item);
}
return buckets;
});
const groupOrder: ItemGroupKey[] = [
'processing',
'queued',
'pending_review',
'waiting_manual_upload',
'failed',
'completed',
];
/**
* 解析生命周期状态文案。
*/
@@ -614,20 +429,6 @@ function statusLabel(status: string): string {
return te(key) ? t(key) : t('chat.shippingProcessing.itemStatus.unknown');
}
/**
* 格式化更新时间。
*/
function formatUpdatedLabel(value?: string | null): string {
const date = new Date(String(value || ''));
if (Number.isNaN(date.getTime())) return '';
const time = new Intl.DateTimeFormat(String(locale.value || 'zh-CN'), {
hour: '2-digit',
minute: '2-digit',
hour12: false,
}).format(date);
return t('chat.shippingOrderExtractionDocumentTiming.updated', { time });
}
/**
* 手动刷新。
*/
@@ -635,17 +436,6 @@ async function onRefresh() {
await ctl.value.refresh();
}
/**
* 打开详情抽屉:仅用列表投影,不再请求已 DROP 的 WorkflowItem 详情 API。
*/
function openDetail(item: ShippingWorkflowItem) {
const itemNo = String(item.item_no || '').trim();
if (!itemNo) return;
detailOpen.value = true;
detailItem.value = item;
detailLoading.value = false;
}
/**
* 打开取消原因弹窗:优先绑定 current_run_no,走 Run 级取消 API。
*/
@@ -902,12 +692,15 @@ watch(
<button
type="button"
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary disabled:opacity-50"
:disabled="loading"
:disabled="initialLoading || manualRefreshing"
:title="t('chat.shippingProcessing.actions.refresh')"
data-testid="shipping-workflow-refresh"
@click="onRefresh"
>
<RefreshCw class="h-3.5 w-3.5" :class="{ 'animate-spin': loading }" />
<RefreshCw
class="h-3.5 w-3.5"
:class="{ 'animate-spin': initialLoading || manualRefreshing }"
/>
</button>
</div>
@@ -982,174 +775,11 @@ watch(
</div>
</div>
<div
v-if="showFilesDrawer"
class="mt-3 min-h-0 flex-1 overflow-y-auto rounded-xl border border-default bg-surface-soft/40 p-2"
data-testid="shipping-workflow-details-drawer"
>
<section
class="flex min-h-0 w-full flex-col"
:aria-label="t('chat.shippingProcessing.detailsDrawerTitle')"
>
<div class="flex items-center justify-between gap-2 border-b border-default px-4 py-3">
<div class="min-w-0">
<div class="text-sm font-semibold text-primary">
{{ t('chat.shippingProcessing.detailsDrawerTitle') }}
</div>
<div class="mt-0.5 text-[11px] text-secondary">
{{ t('chat.shippingProcessing.compactSummary', {
active: items.length,
total: counts.total,
}) }}
</div>
</div>
<span class="text-[11px] text-secondary">{{ t('chat.shippingProcessing.activity.fileListTitle') }}</span>
</div>
<div class="p-4">
<div
class="mb-3 flex flex-wrap gap-1.5 text-[11px]"
data-testid="shipping-workflow-counts"
>
<span class="rounded-md bg-sky-50 px-2 py-0.5 text-sky-700 dark:bg-sky-950/40 dark:text-sky-200">
{{ t('chat.shippingProcessing.counts.processing', { count: counts.processing }) }}
</span>
<span
v-if="counts.pending_review > 0"
class="rounded-md bg-amber-50 px-2 py-0.5 text-amber-700 dark:bg-amber-950/40 dark:text-amber-200"
>
{{ t('chat.shippingProcessing.counts.pendingReview', { count: counts.pending_review }) }}
</span>
<span
v-if="(counts.waiting_manual_upload || 0) > 0"
class="rounded-md bg-amber-50 px-2 py-0.5 text-amber-800 dark:bg-amber-950/40 dark:text-amber-100"
>
{{ t('chat.shippingProcessing.counts.waitingManualUpload', {
count: counts.waiting_manual_upload || 0,
}) }}
</span>
<span class="rounded-md bg-emerald-50 px-2 py-0.5 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-200">
{{ t('chat.shippingProcessing.counts.completed', { count: counts.completed }) }}
</span>
<span
v-if="counts.failed > 0"
class="rounded-md bg-rose-50 px-2 py-0.5 text-rose-700 dark:bg-rose-950/40 dark:text-rose-200"
>
{{ t('chat.shippingProcessing.counts.failed', { count: counts.failed }) }}
</span>
</div>
<template v-for="groupKey in groupOrder" :key="groupKey">
<section
v-if="grouped[groupKey].length"
class="mb-3"
:data-testid="`shipping-workflow-group-${groupKey}`"
>
<h3 class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-secondary">
{{ t(`chat.shippingProcessing.groups.${groupKey}`) }}
</h3>
<ul class="space-y-2">
<li
v-for="item in grouped[groupKey]"
:key="item.item_no"
class="rounded-lg border border-default bg-surface-soft/80 px-2.5 py-2"
:data-testid="`shipping-workflow-item-${item.item_no}`"
>
<div class="flex items-start justify-between gap-2">
<div class="min-w-0">
<div
class="truncate text-xs font-semibold text-primary"
:title="itemTitle(item)"
data-testid="shipping-workflow-item-filename"
>
{{ itemTitle(item) }}
</div>
<div class="mt-0.5 text-[11px] text-muted">
{{ t('chat.shippingProcessing.versionLabel', { version: item.current_version_no }) }}
· {{ itemActivityLabel(item) }}
<span v-if="!item.current_case_no" class="ml-1 text-secondary">
· {{ t('chat.shippingProcessing.noReviewCaseYet') }}
</span>
</div>
</div>
<span
class="shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium"
:class="{
'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-100':
groupKey === 'pending_review'
|| groupKey === 'failed'
|| groupKey === 'waiting_manual_upload',
'bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-100':
groupKey === 'processing' || groupKey === 'queued',
'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-100':
groupKey === 'completed',
}"
>
{{ statusLabel(resolveItemDisplayStatus(item)) }}
</span>
</div>
<div v-if="item.last_activity_at || item.updated_at" class="mt-0.5 text-[11px] text-muted">
{{ formatUpdatedLabel(item.last_activity_at || item.updated_at) }}
</div>
<div v-if="groupKey === 'processing' || groupKey === 'queued'" class="mt-1 text-[11px] text-brand-700 dark:text-brand-300">
{{ t('chat.shippingProcessing.activity.currentAction', { action: itemActivityLabel(item) }) }}
</div>
<ProcessGateRecoveryCard
v-if="item.process_gate?.current_blocking_gate"
class="mt-2"
:summary="item.process_gate"
:can-handle="true"
:navigation-context="gateNavigationContext"
@refreshed="() => void ctl.refresh()"
@refresh-needed="() => void ctl.refresh()"
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
/>
<div class="mt-2 flex min-w-0 items-center gap-2 overflow-x-auto whitespace-nowrap pb-0.5">
<button
v-if="groupKey === 'pending_review' && item.current_run_no"
type="button"
class="inline-flex shrink-0 items-center gap-1 rounded-md bg-brand-600 px-2.5 py-1 text-[11px] font-semibold text-white shadow-sm hover:bg-brand-700 disabled:opacity-50"
:disabled="actionBusyItemNo === item.item_no"
data-testid="shipping-workflow-action-open-review"
@click="openReview(item)"
>
{{ t('chat.shippingProcessing.actions.openReview') }}
</button>
<button
type="button"
class="inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-brand-700 hover:underline"
data-testid="shipping-workflow-action-view"
@click="openDetail(item)"
>
{{ t('chat.shippingProcessing.actions.viewProgress') }}
</button>
<button
v-if="canReparse(item)"
type="button"
class="inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-amber-800 hover:underline disabled:opacity-50 dark:text-amber-200"
:disabled="actionBusyItemNo === item.item_no"
data-testid="shipping-workflow-action-reparse"
@click="openReparseDialog(item)"
>
{{ reparseActionLabel(item) }}
</button>
<button
v-if="canCancel(item)"
type="button"
class="inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-rose-700 hover:underline disabled:opacity-50"
:disabled="actionBusyItemNo === item.item_no"
data-testid="shipping-workflow-action-cancel"
@click="openCancelDialog(item)"
>
{{ t('chat.shippingProcessing.actions.cancelFile') }}
</button>
</div>
</li>
</ul>
</section>
</template>
</div>
</section>
</div>
<!--
方案 7:移除右侧常驻「批次与文件列表」聚合抽屉,避免与任务卡投影矛盾与高度抖动。
文件明细统一在订单处理工作台展示;任务卡仅显示任务名 / 文件数 / 状态 / 主按钮。
Gate 级阻断与进度详情仍通过 ProcessGateRecoveryCard 与 ShippingWorkflowItemDetailDrawer 呈现。
-->
<ShippingWorkflowItemDetailDrawer
:open="detailOpen"