feat(shipping-notice): 实现对话级批量重试自动推进功能,优化库存与PDF匹配逻辑
- 新增对话级批量重试自动推进的完整链路:后端服务、API、数据投影逻辑 - 前端新增对话级重试按钮、多语言国际化支持与API类型定义 - 优化行级库存重试控制,新增retryable字段统一管控重试按钮展示,清理废弃的view_fulfillment_detail动作,标准化前端动作码排序逻辑 - 修复PDF坐标匹配的fail-close防护逻辑,避免生成伪精确匹配分数 - 调整订单确认后流程,提前进入库存获取阶段,移除冗余的确认建单按钮,优化用户流转体验 - 新增对应单元测试用例覆盖核心业务逻辑
This commit is contained in:
1 parent
fd6a23f870
commit
1008911a7e
41 files changed
+3956
-1256
No files matched your search
+9
-16
@@ -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);
|
||||
});
|
||||
|
||||
|
||||
+36
-76
@@ -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"
|
||||
|
||||
Reference in new issue
Block a user