chore(shipping-notice): 统一货代发货生命周期阶段命名并优化全链路业务逻辑

This commit is contained in:
hugo committed 2026-08-17 19:56:51 +08:00
1 parent 5ef8329bd8
commit 4ec4e57005
183 files changed
+14653 -3936

No files matched your search

@@ -13,10 +13,11 @@
<script setup lang="ts">
import { computed, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { ChevronDown, ChevronRight } from 'lucide-vue-next';
import { ChevronDown, ChevronRight, MoreHorizontal } from 'lucide-vue-next';
import type {
ConversationProcessingProjection,
ConversationProcessingUserTask,
ShippingProcessingLifecycleEntry,
ShippingProcessingProjection,
} from '@/features/chat/types/shipping.api.types';
import { getPrimaryDocumentName } from '@/features/chat/shipping/conversationProcessingDisplay';
@@ -30,8 +31,9 @@ import {
} from '@/features/chat/shipping/conversationProcessingState';
import {
resolveShippingProcessingMessage,
resolveShippingProcessingReasonLabel,
resolveShippingProcessingStageLabel,
resolveShippingProcessingStatusLabel,
shippingProcessingStageKey,
} from '@/features/chat/shipping/shippingProcessingLabels';
import { flattenBusinessFileProjections } from '@/features/chat/shipping/conversationProcessingProjection';
import { resolveConversationTaskActionPresentation, resolveProcessingActionPresentation } from '@/features/shipping-progress/actionPresentation';
@@ -48,6 +50,13 @@ const props = defineProps<{
hasMoreHistory?: boolean;
/** 批次中心按状态 → EML → 文件展示,不再嵌入任务级 15 节点进度。 */
workbenchMode?: boolean;
/** 批次四阶段筛选;保留状态/EML 分组,仅隐藏不属于当前阶段的任务。 */
lifecycleFilter?: 'all' | 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'upload_complete';
/** 批次中心本地搜索:只筛叶子文件,父 EML 卡仍保留。 */
fileSearchQuery?: string;
/** 后端已授权下载的正式 Excel 对应 OT。 */
downloadableTaskNos?: string[];
selectedDownloadTaskNos?: string[];
}>();
const emit = defineEmits<{
@@ -61,6 +70,12 @@ const emit = defineEmits<{
intakeAction: [payload: { item: ShippingProcessingProjection; action: string }];
/** OT 卡内统一进度动作。 */
projectionAction: [payload: { projection: ShippingProcessingProjection; item: ActionPresentationItem }];
downloadArtifact: [taskNo: string];
toggleDownloadSelection: [taskNo: string];
/** 文件级生命周期入口;父级只切换工作台展示,不在导航时写入业务状态。 */
openLifecycleStage: [payload: { projection: ShippingProcessingProjection; entry: ShippingProcessingLifecycleEntry }];
/** 单文件低频操作;仅当后端明确授权该动作时才发出。 */
fileAction: [payload: { projection: ShippingProcessingProjection; action: string }];
}>();
const { t, te } = useI18n();
@@ -76,8 +91,17 @@ type WorkbenchFileRow = {
filename?: string | null;
document_id?: number | null;
status_label?: string | null;
po_number?: string | null;
projection?: ShippingProcessingProjection;
};
const LIFECYCLE_STAGE_CODES = ['order_review', 'fulfillment_prep', 'upload_complete'] as const;
type LifecycleStageCode = typeof LIFECYCLE_STAGE_CODES[number];
const LIFECYCLE_STAGE_LABEL_KEYS: Record<string, string> = {
intake_parse: 'intakeParse',
order_review: 'orderReview',
fulfillment_prep: 'fulfillmentPrep',
upload_complete: 'uploadComplete',
};
/** 唯一进度源:统一 conversation_processing / work_items 合成投影。 */
const activeProjection = computed((): ConversationProcessingProjection | null => (
@@ -100,6 +124,23 @@ const waitingHumanTasks = computed(() => statusGroups.value?.waiting_human
|| (activeProjection.value?.needs_action || []).filter((task) => task.userGroup === 'waiting_human'));
const processingTasks = computed(() => statusGroups.value?.processing || activeProjection.value?.processing || []);
/** 任务只要含一个命中附件即保留,避免筛选后打散同一封 EML 的上下文。 */
function taskMatchesLifecycleFilter(task: ConversationProcessingUserTask): boolean {
const filter = props.lifecycleFilter || 'all';
const query = String(props.fileSearchQuery || '').trim().toLowerCase();
// 非批次中心保留历史任务卡兼容展示;只有批次中心才按叶子文件筛选。
if (!props.workbenchMode && filter === 'all' && !query) return true;
return workbenchFileRows(task).some((file) => {
if (filter !== 'all' && String(file.projection?.uiState?.lifecycleStage || '') !== filter) return false;
return !query || [file.filename, file.label, file.po_number]
.some((value) => String(value || '').toLowerCase().includes(query));
});
}
const visibleFailedTasks = computed(() => failedTasks.value.filter(taskMatchesLifecycleFilter));
const visibleWaitingHumanTasks = computed(() => waitingHumanTasks.value.filter(taskMatchesLifecycleFilter));
const visibleProcessingTasks = computed(() => processingTasks.value.filter(taskMatchesLifecycleFilter));
const visibleCompletedTasks = computed(() => completedTasks.value.filter(taskMatchesLifecycleFilter));
/** history 中非取消 →「历史版本」。 */
const historyVersionTasks = computed(() => historyTasks.value.filter(
(task) => String(task.status_label || '').trim().toLowerCase() !== 'cancelled',
@@ -109,6 +150,8 @@ const historyVersionTasks = computed(() => historyTasks.value.filter(
const cancelledHistoryTasks = computed(() => historyTasks.value.filter(
(task) => String(task.status_label || '').trim().toLowerCase() === 'cancelled',
));
const visibleHistoryVersionTasks = computed(() => historyVersionTasks.value.filter(taskMatchesLifecycleFilter));
const visibleCancelledHistoryTasks = computed(() => cancelledHistoryTasks.value.filter(taskMatchesLifecycleFilter));
/** 处理记录标题计数:当前返回的 completed + history。 */
const recordTaskCount = computed(() => (
@@ -249,6 +292,45 @@ function groupTitle(task: ConversationProcessingUserTask): string {
/** 工作台文件行:只展示后端 document objects,避免用任务标题冒充文件。 */
function workbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileRow[] {
const children = task.aggregateChildren || [];
// [AUTHORITY] 批次模式只以实时 work_items 作为文件行真相。Conversation task 的
// children / objects / document_names 是 Run 级兼容快照,可用于非批次卡历史展示,
// 但不得重建批次中的文件名、状态、阶段或操作。
if (props.workbenchMode) {
const taskNo = String(task.user_task_no || '').trim();
const liveLeaves = (props.workItems || []).flatMap((item) => {
const isTaskRoot = String(item.rootOrderTaskNo || '').trim() === taskNo
|| String(item.workItemNo || '').trim() === taskNo;
if (!isTaskRoot) return [];
// EML 父项的实时附件只存在于 aggregateChildren;展开同一份后端 work_item,
// 不读取 conversation task 兼容快照。
return item.sourceType === 'eml'
? flattenBusinessFileProjections([item])
: [item];
}).filter((item) => (
Number(item.sourceSummary?.documentId || 0) > 0
));
const seenLiveDocumentIds = new Set<number>();
const uniqueLiveLeaves = liveLeaves.filter((item) => {
const documentId = Number(item.sourceSummary?.documentId || 0);
if (seenLiveDocumentIds.has(documentId)) return false;
seenLiveDocumentIds.add(documentId);
return true;
});
return uniqueLiveLeaves.map((item, index) => {
const documentId = Number(item.sourceSummary?.documentId || 0);
const filename = String(item.sourceSummary?.filename || '').trim();
return {
kind: 'document' as const,
object_key: documentId ? `DOC-${documentId}` : `${taskNo}-live-${item.workItemNo || index}`,
label: filename || item.workItemNo || `文件 ${index + 1}`,
filename: filename || item.workItemNo || `文件 ${index + 1}`,
document_id: documentId || null,
status_label: String(item.uiState?.status || item.userStatus || item.status || ''),
po_number: item.sourceSummary?.poNumber || null,
projection: item,
};
});
}
if (children.length) {
return flattenBusinessFileProjections(children).map((child, index) => {
const filename = String(child.sourceSummary?.filename || '').trim();
@@ -259,6 +341,7 @@ function workbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileR
label: filename || child.workItemNo || `文件 ${index + 1}`,
filename: filename || child.workItemNo || `文件 ${index + 1}`,
status_label: String(child.uiState?.status || child.userStatus || child.status || ''),
po_number: child.sourceSummary?.poNumber || null,
projection: child,
};
});
@@ -278,6 +361,7 @@ function workbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileR
filename: item.filename,
document_id: item.document_id,
status_label: item.status_label,
po_number: directFileProjection?.sourceSummary?.poNumber || null,
projection: directFileProjection?.sourceType === 'direct_pdf'
? directFileProjection
: undefined,
@@ -285,15 +369,60 @@ function workbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileR
}
const taskName = String(task.title || '').trim().toLowerCase();
if (taskName.endsWith('.eml') || task.aggregateSummary?.intakeNo) return [];
// 新版实时投影可只返回 work_items,不重复旧 task.objects;此时以同一 OT 的叶子
// document 投影生成行,确保文件状态、阶段和按钮仍完全来自后端。
const taskNo = String(task.user_task_no || '').trim();
const liveLeaves = (props.workItems || []).filter((item) => (
String(item.rootOrderTaskNo || '').trim() === taskNo
&& Number(item.sourceSummary?.documentId || 0) > 0
&& !item.childOrderTasks?.length
));
if (liveLeaves.length) {
return liveLeaves.map((item, index) => {
const documentId = Number(item.sourceSummary?.documentId || 0);
const filename = String(item.sourceSummary?.filename || '').trim();
return {
kind: 'document' as const,
object_key: documentId ? `DOC-${documentId}` : `${taskNo}-live-${item.workItemNo || index}`,
label: filename || item.workItemNo || `文件 ${index + 1}`,
filename: filename || item.workItemNo || `文件 ${index + 1}`,
document_id: documentId || null,
status_label: String(item.uiState?.status || item.userStatus || item.status || ''),
po_number: item.sourceSummary?.poNumber || null,
projection: item,
};
});
}
return (task.document_names || []).map((filename, index) => ({
kind: 'document' as const,
object_key: `${task.user_task_no}-document-${index}`,
label: filename,
filename,
status_label: task.status_label,
po_number: null,
}));
}
/** 阶段筛选只收窄附件行,EML 卡本身仍保留以便用户识别邮件来源。 */
function visibleWorkbenchFileRows(task: ConversationProcessingUserTask): WorkbenchFileRow[] {
const filter = props.lifecycleFilter || 'all';
const rows = workbenchFileRows(task);
const query = String(props.fileSearchQuery || '').trim().toLowerCase();
return rows.filter((file) => {
if (filter !== 'all' && String(file.projection?.uiState?.lifecycleStage || '') !== filter) return false;
if (!query) return true;
return [file.filename, file.label, file.po_number].some((value) => String(value || '').toLowerCase().includes(query));
});
}
function fileDownloadTaskNo(file: WorkbenchFileRow): string | null {
const taskNo = String(file.projection?.rootOrderTaskNo || '').trim();
return taskNo && (props.downloadableTaskNos || []).includes(taskNo) ? taskNo : null;
}
function isDownloadSelected(taskNo: string): boolean {
return (props.selectedDownloadTaskNos || []).includes(taskNo);
}
/** 状态组标题按文件计数,与批次总览保持同一口径。 */
function groupFileCount(tasks: ConversationProcessingUserTask[]): number {
const seen = new Set<string>();
@@ -320,20 +449,51 @@ function workbenchFileReason(file: WorkbenchFileRow, task: ConversationProcessin
const reason = file.projection.uiState
? file.projection.uiState.blocking_reason
: file.projection.blockingReason;
if (!reason) return '';
const key = String(reason.i18nKey || '').trim();
return key && te(key) ? t(key) : String(reason.code || '').trim();
return resolveShippingProcessingReasonLabel(reason, te, t);
}
return taskReasonLabel(task);
}
/** 附件阶段来自叶子 ui_state;EML 父阶段只适用于 EML 卡,不得复制到不同状态的附件。 */
function workbenchFileStage(file: WorkbenchFileRow, task: ConversationProcessingUserTask): string {
const stage = file.projection
? (file.projection.uiState?.stage || file.projection.userStage || file.projection.stage)
: stageLabel(task);
const key = shippingProcessingStageKey(String(stage || ''));
return key && te(key) ? t(key) : String(stage || '');
/** 文件工作面显示四阶段业务语义;技术 stage 仍保留给进度诊断,不用于入口可达性。 */
function workbenchFileLifecycleStage(file: WorkbenchFileRow): string {
const code = String(file.projection?.uiState?.lifecycleStage || '').trim();
const key = LIFECYCLE_STAGE_LABEL_KEYS[code];
return key
? t(`chat.shippingNoticeUi.stage.${key}`)
: t('chat.shippingProcessing.stageLabel.waiting_system_start');
}
/** 生命周期入口仅消费后端投影;禁止按候选、Case 或阶段顺序二次裁决。 */
function lifecycleEntries(file: WorkbenchFileRow): ShippingProcessingLifecycleEntry[] {
return file.projection?.uiState?.lifecycleEntries || [];
}
function lifecycleEntry(file: WorkbenchFileRow, target: LifecycleStageCode): ShippingProcessingLifecycleEntry | null {
return lifecycleEntries(file).find((entry) => entry.code === target) || null;
}
function lifecycleEntryState(file: WorkbenchFileRow, target: LifecycleStageCode): 'available' | 'current' | 'unavailable' {
const state = lifecycleEntry(file, target)?.state;
// [FAIL-CLOSED] 服务端新增或异常状态不得被 UI 当作可进入工作台。
return state === 'available' || state === 'current' ? state : 'unavailable';
}
function lifecycleEntryLabel(file: WorkbenchFileRow, target: LifecycleStageCode): string {
const stage = t(`chat.shippingNoticeUi.stage.${LIFECYCLE_STAGE_LABEL_KEYS[target]}`);
const state = lifecycleEntryState(file, target);
const stateKey = state === 'current'
? 'chat.shippingOrderReview.lifecycle.current'
: state === 'available'
? 'chat.shippingOrderReview.lifecycle.available'
: 'chat.shippingOrderReview.lifecycle.blocked';
return `${stage} · ${t(stateKey)}`;
}
function onOpenLifecycleStage(file: WorkbenchFileRow, lifecycleStage: LifecycleStageCode) {
const entry = lifecycleEntry(file, lifecycleStage);
if (!file.projection || !entry) return;
if (lifecycleEntryState(file, lifecycleStage) === 'unavailable') return;
emit('openLifecycleStage', { projection: file.projection, entry });
}
/** 叶子文件动作由自身 ui_state 裁决;没有叶子投影时不伪造可操作按钮。 */
@@ -392,11 +552,7 @@ function taskReasonLabel(task: ConversationProcessingUserTask): string {
const reason = task.uiState
? task.uiState.blocking_reason
: task.blockingReason;
if (!reason) return '';
const key = String(reason.i18nKey || '').trim();
if (key && te(key)) return t(key);
// 未升级响应没有 i18n_key 时仅透传后端原因码,不根据文件名、状态或动作伪造说明。
return String(reason.code || '').trim();
return resolveShippingProcessingReasonLabel(reason, te, t);
}
/** 同一 EML 聚合卡状态计数;仅用后端下发的 aggregateSummary,不从 UI 状态推导。 */
@@ -548,7 +704,27 @@ function presentationActionLabel(task: ConversationProcessingUserTask, item: Act
if (key && te(key)) return t(key);
const extractionKey = `chat.shippingOrderExtractionAction.${code}`;
if (te(extractionKey)) return t(extractionKey);
return code;
return t('chat.shippingProcessing.action.unknown');
}
/**
* 文件低频操作优先读取正式 ui_state;旧 availableActions 仅兼容未下发 ui_state 的旧投影。
* 一旦后端提供 ui_state,遗留字段绝不能重新授予已撤销的操作。
*/
function canCancelFile(file: WorkbenchFileRow): boolean {
const projection = file.projection;
if (!projection) return false;
if (projection.uiState) {
return projection.uiState.secondary_actions.some(
(action) => action.enabled && action.code === 'cancel_unit',
);
}
return projection.availableActions.includes('cancel_unit');
}
function onFileAction(file: WorkbenchFileRow, action: string) {
if (!file.projection || action !== 'cancel_unit' || !canCancelFile(file)) return;
emit('fileAction', { projection: file.projection, action });
}
/**
@@ -579,8 +755,7 @@ function toggleHistorySection() {
* Intake 阶段文案。
*/
function intakeStageLabel(item: ShippingProcessingProjection): string {
const key = shippingProcessingStageKey(item.stage);
return te(key) ? t(key) : String(item.stage || '');
return resolveShippingProcessingStageLabel(item.stage, te, t);
}
</script>
@@ -591,15 +766,15 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
data-testid="shipping-conversation-processing-card"
>
<section
v-if="failedTasks.length"
v-if="visibleFailedTasks.length"
data-testid="shipping-processing-group-failed"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300">
{{ t('chat.shippingProcessing.batchWorkbench.groups.failed', { count: groupFileCount(failedTasks) }) }}
{{ t('chat.shippingProcessing.batchWorkbench.groups.failed', { count: groupFileCount(visibleFailedTasks) }) }}
</div>
<div class="space-y-2">
<article
v-for="task in failedTasks"
v-for="task in visibleFailedTasks"
:key="task.user_task_no"
class="rounded-lg border px-2.5 py-2 transition"
:class="[
@@ -649,13 +824,24 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
</button>
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-rose-200/70 pt-2">
<div v-for="file in workbenchFileRows(task)" :key="file.object_key" class="flex items-center gap-3 rounded-md bg-white/70 px-2 py-2 dark:bg-slate-950/30">
<div class="min-w-0 flex-1">
<div class="truncate text-xs font-medium text-primary">{{ file.filename || file.label }}</div>
<div v-if="workbenchFileReason(file, task)" class="mt-0.5 truncate text-[11px] text-rose-600 dark:text-rose-300">{{ workbenchFileReason(file, task) }}</div>
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-white/70 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center dark:bg-slate-950/30" :data-testid="`shipping-processing-file-${file.object_key}`">
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div>
<div class="flex min-w-0 flex-wrap items-center gap-1">
<span class="w-fit shrink-0 rounded-full bg-rose-100 px-2 py-0.5 font-medium text-rose-700">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.failedFallback') }}</span>
<button v-if="filePrimaryActionItem(file)" type="button" class="rounded-md border border-rose-300 px-2 py-0.5 font-medium text-rose-700 hover:bg-rose-50" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button>
<label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label>
<button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button>
</div>
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5">
<div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600 dark:text-rose-300" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div>
<div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
</div>
<details v-if="canCancelFile(file)" class="relative shrink-0">
<summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface-muted" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" /></summary>
<button type="button" class="absolute right-0 top-7 z-10 whitespace-nowrap rounded border border-rose-200 bg-surface px-2 py-1 text-[11px] text-rose-700 shadow-sm hover:bg-rose-50" data-testid="shipping-processing-file-cancel" @click="onFileAction(file, 'cancel_unit')">{{ t('chat.shippingProcessing.actions.cancelFile') }}</button>
</details>
</div>
<span class="shrink-0 rounded-full bg-rose-100 px-2 py-0.5 text-[11px] font-medium text-rose-700">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.failedFallback') }}</span>
<button v-if="filePrimaryActionItem(file)" type="button" class="shrink-0 rounded-md border border-rose-300 px-2.5 py-1 text-[11px] font-medium text-rose-700 hover:bg-rose-50" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button>
</div>
</div>
<SidebarProgressInline
@@ -666,7 +852,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
/>
<div
v-if="shouldShowTaskLevelActions(task) || (!projectionForTask(task) && canExpandFileDetails(task))"
v-if="shouldShowTaskLevelActions(task) || (!workbenchMode && !projectionForTask(task) && canExpandFileDetails(task))"
class="mt-1.5 flex flex-wrap items-center gap-x-3 gap-y-1"
data-testid="shipping-processing-task-actions"
>
@@ -686,15 +872,15 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</section>
<section
v-if="waitingHumanTasks.length"
v-if="visibleWaitingHumanTasks.length"
data-testid="shipping-processing-group-waiting_human"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300">
{{ t('chat.shippingProcessing.batchWorkbench.groups.waitingHuman', { count: groupFileCount(waitingHumanTasks) }) }}
{{ t('chat.shippingProcessing.batchWorkbench.groups.waitingHuman', { count: groupFileCount(visibleWaitingHumanTasks) }) }}
</div>
<div class="space-y-2">
<article
v-for="task in waitingHumanTasks"
v-for="task in visibleWaitingHumanTasks"
:key="task.user_task_no"
class="rounded-lg border border-amber-400 bg-amber-50/80 px-2.5 py-2 transition dark:border-amber-700 dark:bg-amber-950/30"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
@@ -709,13 +895,12 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">{{ aggregateStatusLabel(task) }}</div>
</button>
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-amber-200/70 pt-2">
<div v-for="file in workbenchFileRows(task)" :key="file.object_key" class="flex items-center gap-3 rounded-md bg-white/70 px-2 py-2 dark:bg-slate-950/30">
<div class="min-w-0 flex-1">
<div class="truncate text-xs font-medium text-primary">{{ file.filename || file.label }}</div>
<div v-if="workbenchFileReason(file, task)" class="mt-0.5 truncate text-[11px] text-rose-600 dark:text-rose-300">{{ workbenchFileReason(file, task) }}</div>
</div>
<span class="shrink-0 rounded-full bg-amber-100 px-2 py-0.5 text-[11px] font-medium text-amber-800">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.waitingFallback') }}</span>
<button v-if="filePrimaryActionItem(file)" type="button" class="shrink-0 rounded-md bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button>
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-white/70 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center dark:bg-slate-950/30" :data-testid="`shipping-processing-file-${file.object_key}`">
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div>
<div class="flex min-w-0 flex-wrap items-center gap-1"><span class="w-fit shrink-0 rounded-full bg-amber-100 px-2 py-0.5 font-medium text-amber-800">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.waitingFallback') }}</span><button v-if="filePrimaryActionItem(file)" type="button" class="rounded-md bg-brand-600 px-2 py-0.5 font-medium text-white hover:bg-brand-700" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button><label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label><button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button></div>
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5"><div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600 dark:text-rose-300" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div><div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
</div><details v-if="canCancelFile(file)" class="relative shrink-0"><summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface-muted" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" /></summary><button type="button" class="absolute right-0 top-7 z-10 whitespace-nowrap rounded border border-rose-200 bg-surface px-2 py-1 text-[11px] text-rose-700 shadow-sm hover:bg-rose-50" data-testid="shipping-processing-file-cancel" @click="onFileAction(file, 'cancel_unit')">{{ t('chat.shippingProcessing.actions.cancelFile') }}</button></details></div>
</div>
</div>
<SidebarProgressInline
@@ -738,15 +923,15 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</section>
<section
v-if="processingTasks.length"
v-if="visibleProcessingTasks.length"
data-testid="shipping-processing-group-processing"
>
<div class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-sky-700 dark:text-sky-300">
{{ t('chat.shippingProcessing.batchWorkbench.groups.processing', { count: groupFileCount(processingTasks) }) }}
{{ t('chat.shippingProcessing.batchWorkbench.groups.processing', { count: groupFileCount(visibleProcessingTasks) }) }}
</div>
<div class="space-y-2">
<article
v-for="task in processingTasks"
v-for="task in visibleProcessingTasks"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface px-2.5 py-2"
:class="focusedTaskNo === task.user_task_no
@@ -790,10 +975,11 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
</button>
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-sky-200/70 pt-2">
<div v-for="file in workbenchFileRows(task)" :key="file.object_key" class="flex items-center gap-3 rounded-md bg-surface-muted/40 px-2 py-2">
<div class="min-w-0 flex-1"><div class="truncate text-xs font-medium text-primary">{{ file.filename || file.label }}</div><div class="mt-0.5 text-[11px] text-secondary">{{ workbenchFileStage(file, task) || t('chat.shippingProcessing.batchWorkbench.fileProcessing') }}</div></div>
<span class="shrink-0 rounded-full bg-sky-100 px-2 py-0.5 text-[11px] font-medium text-sky-700">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.processingFallback') }}</span>
<button v-if="filePrimaryActionItem(file)" type="button" class="shrink-0 rounded-md border border-brand-300 px-2.5 py-1 text-[11px] font-medium text-brand-700 hover:bg-brand-50" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button>
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-surface-muted/40 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center" :data-testid="`shipping-processing-file-${file.object_key}`">
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div><div class="flex min-w-0 flex-wrap items-center gap-1"><span class="w-fit shrink-0 rounded-full bg-sky-100 px-2 py-0.5 font-medium text-sky-700">{{ workbenchFileStatus(file, task) || t('chat.shippingProcessing.batchWorkbench.groups.processingFallback') }}</span><button v-if="filePrimaryActionItem(file)" type="button" class="rounded-md border border-brand-300 px-2 py-0.5 font-medium text-brand-700 hover:bg-brand-50" @click="onFileProjectionAction(file)">{{ presentationActionLabel(task, filePrimaryActionItem(file)!) }}</button><label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label><button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button></div>
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5"><div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div><div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
</div><details v-if="canCancelFile(file)" class="relative shrink-0"><summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface-muted" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" /></summary><button type="button" class="absolute right-0 top-7 z-10 whitespace-nowrap rounded border border-rose-200 bg-surface px-2 py-1 text-[11px] text-rose-700 shadow-sm hover:bg-rose-50" data-testid="shipping-processing-file-cancel" @click="onFileAction(file, 'cancel_unit')">{{ t('chat.shippingProcessing.actions.cancelFile') }}</button></details></div>
</div>
</div>
<SidebarProgressInline
@@ -818,7 +1004,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
</button>
<button
v-if="canExpandFileDetails(task)"
v-if="!workbenchMode && 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"
@@ -841,7 +1027,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</button>
</div>
<button
v-else-if="canExpandFileDetails(task)"
v-else-if="!workbenchMode && 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"
@@ -902,7 +1088,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
data-testid="shipping-processing-history-body"
>
<div
v-if="completedTasks.length"
v-if="visibleCompletedTasks.length"
data-testid="shipping-processing-history-completed"
>
<div class="mb-1 text-[11px] font-medium text-emerald-700 dark:text-emerald-300">
@@ -910,7 +1096,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
<div class="space-y-2">
<article
v-for="task in completedTasks"
v-for="task in visibleCompletedTasks"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
@@ -934,6 +1120,14 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
{{ taskReasonLabel(task) }}
</div>
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-emerald-200/70 pt-2">
<div v-for="file in visibleWorkbenchFileRows(task)" :key="file.object_key" class="grid gap-x-3 gap-y-1 rounded-md bg-emerald-50/40 px-2 py-1.5 text-[11px] sm:grid-cols-[minmax(10rem,1fr)_auto_auto] sm:items-center" :data-testid="`shipping-processing-file-${file.object_key}`">
<div class="min-w-0"><span class="truncate font-medium text-primary">{{ file.filename || file.label }}</span><span class="ml-1 text-secondary">· {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.po', { value: file.po_number || '-' }) }}</span></div><div class="flex min-w-0 flex-wrap items-center gap-1"><span class="w-fit shrink-0 rounded-full bg-emerald-100 px-2 py-0.5 font-medium text-emerald-700">{{ workbenchFileStatus(file, task) }}</span><label v-if="fileDownloadTaskNo(file)" class="inline-flex items-center gap-1 text-secondary"><input type="checkbox" :checked="isDownloadSelected(fileDownloadTaskNo(file)!)" @change="emit('toggleDownloadSelection', fileDownloadTaskNo(file)!)"><span class="sr-only">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.select') }}</span></label><button v-if="fileDownloadTaskNo(file)" type="button" class="rounded-md border border-emerald-300 px-2 py-0.5 font-medium text-emerald-700 hover:bg-emerald-50" @click="emit('downloadArtifact', fileDownloadTaskNo(file)!)">{{ t('chat.shippingProcessing.batchWorkbench.artifacts.download') }}</button></div>
<div class="col-span-full flex min-h-7 items-center justify-between gap-3 border-t border-default pt-1.5"><div class="min-w-0 truncate text-secondary"><span>{{ t('chat.shippingProcessing.batchWorkbench.fileEntries.stage', { value: workbenchFileLifecycleStage(file) }) }}</span><span v-if="workbenchFileReason(file, task)" class="text-rose-600" :title="workbenchFileReason(file, task)"> · {{ t('chat.shippingProcessing.batchWorkbench.fileEntries.blocker', { value: workbenchFileReason(file, task) }) }}</span></div><div v-if="lifecycleEntries(file).length" class="flex shrink-0 flex-wrap justify-end gap-1">
<button v-for="stage in LIFECYCLE_STAGE_CODES" :key="stage" type="button" class="rounded border px-1.5 py-1 text-[11px] font-medium disabled:cursor-not-allowed" :class="lifecycleEntryState(file, stage) === 'current' ? 'border-brand-600 bg-brand-600 text-white hover:bg-brand-700' : lifecycleEntryState(file, stage) === 'available' ? 'border-emerald-300 bg-emerald-50 text-emerald-800 hover:bg-emerald-100' : 'border-default bg-surface-muted text-muted'" :disabled="lifecycleEntryState(file, stage) === 'unavailable'" :title="lifecycleEntryState(file, stage) === 'unavailable' ? t('chat.shippingProcessing.batchWorkbench.fileEntries.unavailable') : undefined" @click="onOpenLifecycleStage(file, stage)">{{ lifecycleEntryLabel(file, stage) }}</button>
</div></div>
</div>
</div>
<button
v-if="recordViewDetailsItem(task)"
type="button"
@@ -948,7 +1142,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
<div
v-if="historyVersionTasks.length"
v-if="visibleHistoryVersionTasks.length"
data-testid="shipping-processing-history-versions"
>
<div class="mb-1 text-[11px] font-medium text-slate-600 dark:text-slate-300">
@@ -956,7 +1150,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
<div class="space-y-2">
<article
v-for="task in historyVersionTasks"
v-for="task in visibleHistoryVersionTasks"
:key="task.user_task_no"
class="rounded-lg border border-default bg-surface/80 px-2.5 py-2"
:data-testid="`shipping-processing-task-${task.user_task_no}`"
@@ -990,7 +1184,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
<div
v-if="cancelledHistoryTasks.length"
v-if="visibleCancelledHistoryTasks.length"
data-testid="shipping-processing-history-cancelled"
>
<div class="mb-1 text-[11px] font-medium text-slate-500 dark:text-slate-400">
@@ -998,7 +1192,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
</div>
<div class="space-y-2">
<article
v-for="task in cancelledHistoryTasks"
v-for="task in visibleCancelledHistoryTasks"
:key="task.user_task_no"
class="rounded-lg border border-dashed border-default bg-surface/60 px-2.5 py-2 opacity-90"
:data-testid="`shipping-processing-task-${task.user_task_no}`"