1266 lines
70 KiB
Vue
1266 lines
70 KiB
Vue
/**
|
||
* features/chat/components/shipping/ShippingConversationProcessingCard.vue
|
||
* 用途:右侧「批次进度中心」顶层任务卡——needs_action / processing / 处理记录。
|
||
* 依赖:vue-i18n、ConversationProcessingProjection、conversationProcessingState、
|
||
* conversationProcessingDisplay、actionPresentation、shippingProcessingLabels、SidebarProgressInline。
|
||
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems;
|
||
* 统一「订单识别任务」+ 主文件副标题;处理记录默认折叠(已完成/历史版本/已取消);
|
||
* UI-02:有文件对象时次要入口仅为「展开文件详情」,无文件对象时才「查看详情」;
|
||
* 有 workItem 时由其统一 Gate / Action 投影常驻渲染人工恢复按钮;
|
||
* 点击/展开任务只更新本地焦点与详情,不写服务端 viewed/focus 审计,不得改变同一 Gate 的按钮可见性;
|
||
* UI-03:history 截断时折叠标题显示「还有 N 条」,展开底部显示明细截断文案。
|
||
*/
|
||
<script setup lang="ts">
|
||
import { computed, ref, watch } from 'vue';
|
||
import { useI18n } from 'vue-i18n';
|
||
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';
|
||
import {
|
||
createConversationProcessingUiState,
|
||
focusTaskManually,
|
||
resetConversationProcessingUiState,
|
||
resolveFocusedTask,
|
||
shouldExpandTaskDetails,
|
||
toggleTaskDetails,
|
||
} from '@/features/chat/shipping/conversationProcessingState';
|
||
import {
|
||
resolveShippingProcessingMessage,
|
||
resolveShippingProcessingReasonLabel,
|
||
resolveShippingProcessingStageLabel,
|
||
resolveShippingProcessingStatusLabel,
|
||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||
import { flattenBusinessFileProjections } from '@/features/chat/shipping/conversationProcessingProjection';
|
||
import {
|
||
resolveConversationTaskActionPresentation,
|
||
resolveFilePrimaryActionPresentation,
|
||
} from '@/features/shipping-progress/actionPresentation';
|
||
import SidebarProgressInline from '@/features/shipping-progress/components/SidebarProgressInline.vue';
|
||
import type { ActionPresentation, ActionPresentationItem } from '@/features/shipping-progress/types';
|
||
|
||
const props = defineProps<{
|
||
projection: ConversationProcessingProjection | null;
|
||
/** 统一 ShippingProcessing work_items(含 order_intake) */
|
||
workItems?: ShippingProcessingProjection[] | null;
|
||
/** 当前会话 ID;切换时重置本地焦点/展开状态 */
|
||
conversationId?: string | null;
|
||
/** 后端截断提示:history 还有未返回内容时在处理记录底部展示 */
|
||
hasMoreHistory?: boolean;
|
||
/** 批次中心按状态 → EML → 文件展示,不再嵌入任务级 15 节点进度。 */
|
||
workbenchMode?: boolean;
|
||
/** 批次五阶段筛选;保留状态/EML 分组,仅隐藏不属于当前阶段的任务。 */
|
||
lifecycleFilter?: 'all' | 'intake_parse' | 'order_review' | 'fulfillment_prep' | 'freight_upload' | 'upload_complete';
|
||
/** 批次中心本地搜索:只筛叶子文件,父 EML 卡仍保留。 */
|
||
fileSearchQuery?: string;
|
||
/** 后端已授权下载的正式 Excel 对应 OT。 */
|
||
downloadableTaskNos?: string[];
|
||
selectedDownloadTaskNos?: string[];
|
||
}>();
|
||
|
||
const emit = defineEmits<{
|
||
/** 请求展开某任务下的文件列表(由 Timeline 按 OT objects 合成) */
|
||
expandFiles: [task: ConversationProcessingUserTask];
|
||
/** 收起文件详情:父级应清空过滤并隐藏文件列表 */
|
||
collapseFiles: [];
|
||
/** 任务级权威操作(后端 available_actions) */
|
||
taskAction: [payload: { task: ConversationProcessingUserTask; action: string }];
|
||
/** Intake 级统一投影动作(如 retry_parse) */
|
||
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();
|
||
const uiState = createConversationProcessingUiState();
|
||
/** 处理记录整组默认折叠。 */
|
||
const historySectionExpanded = ref(false);
|
||
|
||
/** 批次中心文件叶子行;EML 仅是聚合容器,文件状态、原因与动作必须取叶子自身投影。 */
|
||
type WorkbenchFileRow = {
|
||
kind: 'document';
|
||
object_key: string;
|
||
label: string;
|
||
filename?: string | null;
|
||
document_id?: number | null;
|
||
status_label?: string | null;
|
||
po_number?: string | null;
|
||
projection?: ShippingProcessingProjection;
|
||
};
|
||
const LIFECYCLE_STAGE_CODES = ['intake_parse', 'order_review', 'fulfillment_prep', 'freight_upload', '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',
|
||
freight_upload: 'freightUpload',
|
||
upload_complete: 'uploadComplete',
|
||
};
|
||
|
||
/** 唯一进度源:统一 conversation_processing / work_items 合成投影。 */
|
||
const activeProjection = computed((): ConversationProcessingProjection | null => (
|
||
props.projection || null
|
||
));
|
||
|
||
const hasContent = computed(() => Boolean(
|
||
activeProjection.value,
|
||
));
|
||
|
||
const statusGroups = computed(() => activeProjection.value?.status_groups || null);
|
||
const completedTasks = computed(() => statusGroups.value?.completed || []);
|
||
const historyTasks = computed(() => [
|
||
...(statusGroups.value?.cancelled || []),
|
||
...(statusGroups.value?.archived || []),
|
||
]);
|
||
/** EML 卡的状态分区必须完全遵循后端 status_groups,禁止旧四组回退重判。 */
|
||
const failedTasks = computed(() => statusGroups.value?.failed || []);
|
||
const waitingHumanTasks = computed(() => statusGroups.value?.waiting_human || []);
|
||
const processingTasks = computed(() => statusGroups.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',
|
||
));
|
||
|
||
/** history 中明确 cancelled →「已取消」。 */
|
||
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(() => (
|
||
completedTasks.value.length + historyTasks.value.length
|
||
));
|
||
|
||
/**
|
||
* history 未返回条数:summary.history - 当前 history[];不可靠时为 0(不猜数)。
|
||
*/
|
||
const hiddenHistoryCount = computed(() => {
|
||
const summaryTotal = Number(activeProjection.value?.summary?.history || 0);
|
||
if (!Number.isFinite(summaryTotal) || summaryTotal <= 0) return 0;
|
||
return Math.max(0, summaryTotal - historyTasks.value.length);
|
||
});
|
||
|
||
const focusedTaskNo = computed(() => resolveFocusedTask(uiState, {
|
||
serverFocusedTaskNo: activeProjection.value?.focused_task_no,
|
||
recentTaskNo: activeProjection.value?.recent_task_no,
|
||
}));
|
||
|
||
/** 按权威 OT 编号取得卡片自己的统一进度投影。 */
|
||
function projectionForTask(task: ConversationProcessingUserTask): ShippingProcessingProjection | null {
|
||
const taskNo = String(task.user_task_no || '').trim();
|
||
if (!taskNo) return null;
|
||
const items = Array.isArray(props.workItems) ? props.workItems : [];
|
||
return items.find((item) => (
|
||
(item.workItemType === 'order_task' || item.workItemType === 'order_intake')
|
||
&& String(item.workItemNo || '').trim() === taskNo
|
||
)) || null;
|
||
}
|
||
|
||
/**
|
||
* 切会话时重置本地焦点/展开,避免跨会话残留。
|
||
*/
|
||
watch(
|
||
() => String(props.conversationId || '').trim(),
|
||
(next, prev) => {
|
||
if (next === prev) return;
|
||
resetConversationProcessingUiState(uiState);
|
||
historySectionExpanded.value = false;
|
||
},
|
||
);
|
||
|
||
/**
|
||
* 点击任务卡:仅本地聚焦,不标记正式 viewed、不强制展开文件、也不写 focus 审计。
|
||
*/
|
||
function onSelectTask(task: ConversationProcessingUserTask) {
|
||
const taskNo = String(task.user_task_no || '').trim();
|
||
if (!taskNo) return;
|
||
focusTaskManually(uiState, taskNo, { expandDetails: false });
|
||
}
|
||
|
||
/**
|
||
* 切换文件详情展开;展开时通知父级过滤,收起时清空过滤。
|
||
* viewed 会回写 Run.seen_at 并重算业务投影,右侧纯展示不得调用。
|
||
*/
|
||
function onToggleDetails(task: ConversationProcessingUserTask) {
|
||
const taskNo = String(task.user_task_no || '').trim();
|
||
if (!taskNo) return;
|
||
toggleTaskDetails(uiState, taskNo);
|
||
if (uiState.expandedDetailTaskNo === taskNo) {
|
||
emit('expandFiles', task);
|
||
} else {
|
||
emit('collapseFiles');
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 是否为多 PDF 任务卡(禁止用首个文件名伪装单文件任务)。
|
||
*/
|
||
function isMultiDocumentTask(task: ConversationProcessingUserTask): boolean {
|
||
if (String(task.display_kind || '').trim() === 'multi_document_task') return true;
|
||
if (Number(task.file_count || 0) > 1) return true;
|
||
return Array.isArray(task.document_names) && task.document_names.length > 1;
|
||
}
|
||
|
||
/**
|
||
* 是否展示「展开文件详情」:单 PDF/单对象时隐藏,避免空抽屉。
|
||
*/
|
||
function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
|
||
if (isMultiDocumentTask(task)) return true;
|
||
const objects = Array.isArray(task.objects) ? task.objects : [];
|
||
return objects.length > 0;
|
||
}
|
||
|
||
/**
|
||
* 活跃卡进度:人工待办始终完整展示 Gate 动作;处理中聚焦全量 / 未聚焦紧凑;
|
||
* 处理记录(completed/history)永不展实时进度。
|
||
*/
|
||
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
|
||
if (props.workbenchMode) return 'hidden';
|
||
if (!projectionForTask(task)) return 'hidden';
|
||
const group = String(task.group || '').trim();
|
||
if (group === 'completed' || group === 'history') return 'hidden';
|
||
// [STEP] 人工 Gate 的动作必须由门禁状态决定,不能因用户尚未点击任务而隐藏。
|
||
if (group === 'needs_action') return 'full';
|
||
const focused = focusedTaskNo.value === task.user_task_no;
|
||
if (focused) return 'full';
|
||
return 'compact';
|
||
}
|
||
|
||
/**
|
||
* 任务主标题:统一「订单识别任务」;禁止用 filename / task.title / OT 编号。
|
||
*/
|
||
function taskLabel(_task: ConversationProcessingUserTask): string {
|
||
return t('chat.shippingProcessing.multiPdfTaskTitle');
|
||
}
|
||
|
||
/** EML 聚合标题优先使用后端邮件文件名,普通文件则显示主文件名。 */
|
||
function groupTitle(task: ConversationProcessingUserTask): string {
|
||
const projection = projectionForTask(task);
|
||
const children = task.aggregateChildren || [];
|
||
const projectionFilename = String(projection?.sourceSummary?.filename || '').trim();
|
||
const emlChild = children.find((child) => (
|
||
String(child.sourceSummary?.filename || '').trim().toLowerCase().endsWith('.eml')
|
||
));
|
||
const emailChild = children.find((child) => Boolean(child.sourceSummary?.emailSubject));
|
||
const isEml = projection?.sourceType === 'eml'
|
||
&& Boolean(
|
||
emlChild
|
||
|| emailChild
|
||
|| projection?.sourceSummary?.emailSubject
|
||
|| projectionFilename.toLowerCase().endsWith('.eml'),
|
||
);
|
||
if (!isEml) return projection?.sourceSummary?.filename || task.title || taskLabel(task);
|
||
// 后端在 EML 聚合根 sourceSummary 写入 Intake 原始邮件资产名;子附件列表不含
|
||
// 邮件本体时仍必须显示该 .eml,不能回退成 Intake 编号或任一 PDF 文件名。
|
||
if (projectionFilename.toLowerCase().endsWith('.eml')) return projectionFilename;
|
||
if (emlChild?.sourceSummary?.filename) return emlChild.sourceSummary.filename;
|
||
if (projection?.sourceSummary?.emailSubject) return `EML · ${projection.sourceSummary.emailSubject}`;
|
||
if (emailChild?.sourceSummary?.emailSubject) return `EML · ${emailChild.sourceSummary.emailSubject}`;
|
||
if (task.aggregateSummary?.intakeNo) {
|
||
return `EML · ${task.aggregateSummary?.intakeNo || task.user_task_no}`;
|
||
}
|
||
return task.title || taskLabel(task);
|
||
}
|
||
|
||
/** 工作台文件行:只展示后端 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();
|
||
const documentId = Number(child.sourceSummary?.documentId || 0) || 0;
|
||
return {
|
||
kind: 'document' as const,
|
||
object_key: documentId ? `DOC-${documentId}` : `${task.user_task_no}-aggregate-${child.workItemNo || index}`,
|
||
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,
|
||
};
|
||
});
|
||
}
|
||
const documents = (task.objects || []).filter((item) => (
|
||
item.kind === 'document'
|
||
&& !String(item.filename || item.label || '').trim().toLowerCase().endsWith('.eml')
|
||
));
|
||
if (documents.length) {
|
||
// direct_pdf 没有 EML aggregate_children;将唯一根 work_item 绑定到其文件行,
|
||
// 使状态、原因和操作仍然来自同一份后端 ui_state,而不是丢失操作或回退 legacy 字段。
|
||
const directFileProjection = projectionForTask(task);
|
||
return documents.map((item) => ({
|
||
kind: 'document' as const,
|
||
object_key: item.object_key,
|
||
label: item.label,
|
||
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,
|
||
}));
|
||
}
|
||
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>();
|
||
return tasks.reduce((total, task) => total + visibleWorkbenchFileRows(task).reduce((count, file) => {
|
||
const filename = String(file.filename || file.label || '').trim().toLowerCase();
|
||
if (filename.endsWith('.eml')) return count;
|
||
const key = String(('document_id' in file ? file.document_id : undefined)
|
||
|| file.object_key || file.filename || file.label || '').trim();
|
||
if (!key || seen.has(key)) return count;
|
||
seen.add(key);
|
||
return count + 1;
|
||
}, 0), 0);
|
||
}
|
||
|
||
function workbenchFileStatus(file: WorkbenchFileRow, task: ConversationProcessingUserTask): string {
|
||
const status = file.projection
|
||
? (file.projection.uiState?.status || file.projection.userStatus || file.projection.status)
|
||
: (file.status_label || task.status_label || '');
|
||
return resolveShippingProcessingStatusLabel(String(status), te, t);
|
||
}
|
||
|
||
function workbenchFileReason(file: WorkbenchFileRow, task: ConversationProcessingUserTask): string {
|
||
if (file.projection) {
|
||
const reason = file.projection.uiState
|
||
? file.projection.uiState.blocking_reason
|
||
: file.projection.blockingReason;
|
||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||
}
|
||
return taskReasonLabel(task);
|
||
}
|
||
|
||
/** 文件工作面显示五阶段业务语义;技术 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 {
|
||
void file;
|
||
// 阶段状态由按钮颜色和 disabled 表达,避免重复的“当前可处理/前置未完成”文案挤占文件行。
|
||
return t(`chat.shippingNoticeUi.stage.${LIFECYCLE_STAGE_LABEL_KEYS[target]}`);
|
||
}
|
||
|
||
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 裁决;没有叶子投影时不伪造可操作按钮。 */
|
||
function filePrimaryActionItem(file: WorkbenchFileRow): ActionPresentationItem | null {
|
||
return file.projection
|
||
? resolveFilePrimaryActionPresentation(file.projection)
|
||
: null;
|
||
}
|
||
|
||
function onFileProjectionAction(file: WorkbenchFileRow) {
|
||
const action = filePrimaryActionItem(file);
|
||
if (file.projection && action) emit('projectionAction', { projection: file.projection, item: action });
|
||
}
|
||
|
||
/**
|
||
* 主文件副标题:有主文件名时渲染「主文件:{name}」。
|
||
*/
|
||
function primaryFileLabel(task: ConversationProcessingUserTask): string {
|
||
const name = getPrimaryDocumentName(task);
|
||
if (!name) return '';
|
||
return t('chat.shippingProcessing.primaryFile', { name });
|
||
}
|
||
|
||
/**
|
||
* 文件数量文案:多 PDF 用「N 个 PDF」,单文件仍用「N 个文件」。
|
||
*/
|
||
function fileCountLabel(task: ConversationProcessingUserTask): string {
|
||
const count = Number(task.file_count || 0);
|
||
if (count <= 0) return '';
|
||
if (isMultiDocumentTask(task)) {
|
||
return t('chat.shippingProcessing.taskPdfCount', { count });
|
||
}
|
||
return t('chat.shippingProcessing.taskFiles', { count });
|
||
}
|
||
|
||
/**
|
||
* 任务状态文案:优先统一 shippingProcessing,回退 shippingWorkflow。
|
||
*/
|
||
function statusLabel(task: ConversationProcessingUserTask): string {
|
||
return resolveShippingProcessingStatusLabel(
|
||
String(task.uiState?.status || task.userStatus || task.status_label || ''),
|
||
te,
|
||
t,
|
||
);
|
||
}
|
||
|
||
/** 展示统一投影的真实履约阶段;识别候选不再冒充最终完成。 */
|
||
function stageLabel(task: ConversationProcessingUserTask): string {
|
||
const projection = projectionForTask(task);
|
||
if (!projection) return '';
|
||
return intakeStageLabel(projection);
|
||
}
|
||
|
||
/** 展示后端 ui_state 已裁决的阻断原因;i18n 仅负责翻译,不映射或猜测业务原因。 */
|
||
function taskReasonLabel(task: ConversationProcessingUserTask): string {
|
||
const reason = task.uiState
|
||
? task.uiState.blocking_reason
|
||
: task.blockingReason;
|
||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||
}
|
||
|
||
/** 同一 EML 聚合卡状态计数;仅用后端下发的 aggregateSummary,不从 UI 状态推导。 */
|
||
function aggregateStatusLabel(task: ConversationProcessingUserTask): string {
|
||
const summary = task.aggregateSummary;
|
||
if (!summary) return '';
|
||
const parts: string[] = [];
|
||
if (summary.completed) parts.push(t('chat.shippingProcessing.aggregate.completed', { count: summary.completed }));
|
||
if (summary.processing) parts.push(t('chat.shippingProcessing.aggregate.processing', { count: summary.processing }));
|
||
if (summary.needsAction) parts.push(t('chat.shippingProcessing.aggregate.needsAction', { count: summary.needsAction }));
|
||
if (summary.failed) parts.push(t('chat.shippingProcessing.aggregate.failed', { count: summary.failed }));
|
||
return parts.join(' · ');
|
||
}
|
||
|
||
/**
|
||
* 是否高亮 needs_action 任务。
|
||
*/
|
||
function isNeedsActionHighlight(task: ConversationProcessingUserTask): boolean {
|
||
return task.group === 'needs_action';
|
||
}
|
||
|
||
/**
|
||
* 是否展开该任务的文件详情区。
|
||
*/
|
||
function isDetailsExpanded(task: ConversationProcessingUserTask): boolean {
|
||
return shouldExpandTaskDetails(uiState, task.user_task_no, {
|
||
focusedTaskNo: focusedTaskNo.value,
|
||
forceExpand: false,
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 解析任务卡 ActionPresentation(cancel/view_details 不作主 CTA)。
|
||
*/
|
||
function taskActionPresentation(task: ConversationProcessingUserTask): ActionPresentation {
|
||
return resolveConversationTaskActionPresentation(task, { surface: 'right' });
|
||
}
|
||
|
||
/**
|
||
* 待确认分组的批次重解析入口:仅消费该分组任务的后端授权,避免按钮脱离业务上下文。
|
||
*/
|
||
function waitingHumanBatchReparseTask(): ConversationProcessingUserTask | null {
|
||
return visibleWaitingHumanTasks.value.find((task) => (
|
||
task.available_actions?.includes('reparse_batch')
|
||
&& String(task.run_no || '').trim()
|
||
)) || null;
|
||
}
|
||
|
||
/**
|
||
* 唯一主 CTA(实心按钮);处理记录只读卡不调用。
|
||
*/
|
||
function primaryActionItem(task: ConversationProcessingUserTask): ActionPresentationItem | null {
|
||
return taskActionPresentation(task).primary;
|
||
}
|
||
|
||
/** needs_action 的用户语义提示:不重复主按钮文案。 */
|
||
function currentNeedLabel(task: ConversationProcessingUserTask): string {
|
||
if (task.group !== 'needs_action') return '';
|
||
const typedTask = task as ConversationProcessingUserTask & {
|
||
primaryAction?: { code?: string } | null;
|
||
};
|
||
const action = String(
|
||
task.uiState
|
||
? (task.uiState.primary_action?.code
|
||
?? task.uiState.secondary_actions.find((item) => item.enabled)?.code
|
||
?? '')
|
||
: (typedTask.primaryAction?.code
|
||
?? 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 {
|
||
return null;
|
||
}
|
||
|
||
/**
|
||
* 低频溢出动作:排除已展示的主/次 CTA 与 view_details。
|
||
*/
|
||
function overflowActionItems(task: ConversationProcessingUserTask): ActionPresentationItem[] {
|
||
const presentation = taskActionPresentation(task);
|
||
const shown = new Set(
|
||
[primaryActionItem(task)?.actionCode, secondaryActionItem(task)?.actionCode]
|
||
.map((code) => String(code || '').trim().toLowerCase())
|
||
.filter(Boolean),
|
||
);
|
||
shown.add('view_details');
|
||
return [presentation.secondary, ...presentation.overflow]
|
||
.filter((item): item is ActionPresentationItem => Boolean(item))
|
||
.filter((item) => {
|
||
const code = String(item.actionCode || '').trim().toLowerCase();
|
||
return Boolean(code) && !shown.has(code);
|
||
});
|
||
}
|
||
|
||
/**
|
||
* 是否展示低频溢出:有文件对象时仅展开后显示;无文件对象时直接挂在卡上(如取消)。
|
||
* 有 workItem 时不渲染任务级溢出(动作由进度条负责)。
|
||
*/
|
||
function shouldShowOverflowActions(_task: ConversationProcessingUserTask): boolean {
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* 是否渲染任务级主/次动作区(不含「展开文件详情」文件控制)。
|
||
*/
|
||
function shouldShowTaskLevelActions(task: ConversationProcessingUserTask): boolean {
|
||
if (props.workbenchMode) return Boolean(primaryActionItem(task));
|
||
if (projectionForTask(task)) return false;
|
||
return Boolean(primaryActionItem(task) || secondaryActionItem(task));
|
||
}
|
||
|
||
/**
|
||
* 处理记录只读卡:仅保留 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) => {
|
||
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);
|
||
}
|
||
|
||
/**
|
||
* 动作按钮文案:优先 presentation labelKey;多 PDF 取消明确为「取消整个任务」。
|
||
*/
|
||
function presentationActionLabel(task: ConversationProcessingUserTask, item: ActionPresentationItem): string {
|
||
const code = String(item.actionCode || '').trim();
|
||
if (
|
||
(code === 'cancel_task' || code === 'cancel_run')
|
||
&& isMultiDocumentTask(task)
|
||
) {
|
||
return t('chat.shippingProcessing.cancelEntireTask');
|
||
}
|
||
const key = String(item.labelKey || '').trim();
|
||
if (key && te(key)) return t(key);
|
||
const extractionKey = `chat.shippingOrderExtractionAction.${code}`;
|
||
if (te(extractionKey)) return t(extractionKey);
|
||
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 });
|
||
}
|
||
|
||
/**
|
||
* 执行任务级动作:view_details / focus_task 本地聚焦;其余交给父级。
|
||
* focus / view_details 仅影响右侧 UI;禁止写 viewed 审计,避免重算任务分组。
|
||
*/
|
||
function onTaskAction(task: ConversationProcessingUserTask, action: string) {
|
||
const code = String(action || '').trim();
|
||
if (!code) return;
|
||
if (code === 'view_details' || code === 'focus_task') {
|
||
focusTaskManually(uiState, task.user_task_no, { expandDetails: code === 'view_details' });
|
||
if (code === 'view_details') {
|
||
emit('expandFiles', task);
|
||
}
|
||
return;
|
||
}
|
||
emit('taskAction', { task, action: code });
|
||
}
|
||
|
||
/**
|
||
* 切换处理记录整组折叠。
|
||
*/
|
||
function toggleHistorySection() {
|
||
historySectionExpanded.value = !historySectionExpanded.value;
|
||
}
|
||
|
||
/**
|
||
* Intake 阶段文案。
|
||
*/
|
||
function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||
return resolveShippingProcessingStageLabel(item.stage, te, t);
|
||
}
|
||
</script>
|
||
|
||
<template>
|
||
<div
|
||
v-if="hasContent"
|
||
class="space-y-3"
|
||
data-testid="shipping-conversation-processing-card"
|
||
>
|
||
<section
|
||
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(visibleFailedTasks) }) }}
|
||
</div>
|
||
<div class="space-y-2">
|
||
<article
|
||
v-for="task in visibleFailedTasks"
|
||
:key="task.user_task_no"
|
||
class="rounded-lg border px-2.5 py-2 transition"
|
||
:class="[
|
||
isNeedsActionHighlight(task)
|
||
? 'border-amber-400 bg-amber-50/80 dark:border-amber-700 dark:bg-amber-950/30'
|
||
: 'border-default bg-surface',
|
||
focusedTaskNo === task.user_task_no ? 'ring-1 ring-brand-400' : '',
|
||
]"
|
||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
|
||
>
|
||
<button
|
||
type="button"
|
||
class="w-full text-left"
|
||
@click="onSelectTask(task)"
|
||
>
|
||
<div class="text-sm font-semibold text-primary">
|
||
{{ workbenchMode ? groupTitle(task) : resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||
</div>
|
||
<div v-if="!workbenchMode" class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||
</div>
|
||
<div
|
||
v-if="!workbenchMode && primaryFileLabel(task)"
|
||
class="mt-0.5 truncate text-[11px] text-muted"
|
||
data-testid="shipping-processing-task-primary-file"
|
||
>
|
||
{{ primaryFileLabel(task) }}
|
||
</div>
|
||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||
{{ taskReasonLabel(task) }}
|
||
</div>
|
||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">
|
||
{{ aggregateStatusLabel(task) }}
|
||
</div>
|
||
<div
|
||
v-if="task.recent_append_count"
|
||
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
|
||
>
|
||
{{ resolveShippingProcessingMessage('justAppended', te, t, { count: task.recent_append_count }) }}
|
||
</div>
|
||
<div
|
||
v-else-if="task.recently_created"
|
||
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
|
||
>
|
||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||
</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 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>
|
||
</div>
|
||
</div>
|
||
<SidebarProgressInline
|
||
v-if="!workbenchMode && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||
:projection="projectionForTask(task)!"
|
||
:compact="progressModeForTask(task) === 'compact'"
|
||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||
/>
|
||
<div
|
||
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"
|
||
>
|
||
<button
|
||
v-if="(!workbenchMode && !projectionForTask(task)) && primaryActionItem(task)"
|
||
type="button"
|
||
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
|
||
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
|
||
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
|
||
>
|
||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||
</button>
|
||
<span v-if="task.group === 'needs_action'" class="sr-only">{{ currentNeedLabel(task) }}</span>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
</section>
|
||
|
||
<section
|
||
v-if="visibleWaitingHumanTasks.length"
|
||
data-testid="shipping-processing-group-waiting_human"
|
||
>
|
||
<div class="mb-1.5 flex items-center justify-between gap-2 text-[11px] font-semibold uppercase tracking-wide text-amber-700 dark:text-amber-300">
|
||
{{ t('chat.shippingProcessing.batchWorkbench.groups.waitingHuman', { count: groupFileCount(visibleWaitingHumanTasks) }) }}
|
||
<button
|
||
v-if="workbenchMode && waitingHumanBatchReparseTask()"
|
||
type="button"
|
||
class="inline-flex items-center gap-1 rounded-md border border-amber-300 bg-amber-50 px-2.5 py-1 text-[11px] font-medium normal-case text-amber-800 hover:bg-amber-100 dark:border-amber-700 dark:bg-amber-950/30 dark:text-amber-200"
|
||
data-testid="shipping-processing-batch-reparse"
|
||
@click="onTaskAction(waitingHumanBatchReparseTask()!, 'reparse_batch')"
|
||
>
|
||
{{ t('chat.shippingOrderReview.lineOps.reparse_batch') }}
|
||
</button>
|
||
</div>
|
||
<div class="space-y-2">
|
||
<article
|
||
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}`"
|
||
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
|
||
>
|
||
<button type="button" class="w-full text-left" @click="onSelectTask(task)">
|
||
<div class="text-sm font-semibold text-primary">{{ workbenchMode ? groupTitle(task) : resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}</div>
|
||
<div v-if="!workbenchMode" class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||
</div>
|
||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||
<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 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
|
||
v-if="!workbenchMode && projectionForTask(task)"
|
||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||
:projection="projectionForTask(task)!"
|
||
:compact="false"
|
||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||
/>
|
||
<button
|
||
v-if="!workbenchMode && primaryActionItem(task)"
|
||
type="button"
|
||
class="mt-2 rounded-md bg-brand-600 px-2.5 py-1.5 text-[11px] font-medium text-white hover:bg-brand-700"
|
||
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
|
||
>
|
||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||
</button>
|
||
</article>
|
||
</div>
|
||
</section>
|
||
|
||
<section
|
||
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(visibleProcessingTasks) }) }}
|
||
</div>
|
||
<div class="space-y-2">
|
||
<article
|
||
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
|
||
? 'ring-1 ring-brand-400'
|
||
: ''"
|
||
:data-testid="`shipping-processing-task-${task.user_task_no}`"
|
||
:data-focused="focusedTaskNo === task.user_task_no ? '1' : '0'"
|
||
>
|
||
<button
|
||
type="button"
|
||
class="w-full text-left"
|
||
@click="onSelectTask(task)"
|
||
>
|
||
<div class="text-sm font-semibold text-primary">
|
||
{{ workbenchMode ? groupTitle(task) : resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||
</div>
|
||
<div v-if="!workbenchMode" class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||
</div>
|
||
<div
|
||
v-if="!workbenchMode && primaryFileLabel(task)"
|
||
class="mt-0.5 truncate text-[11px] text-muted"
|
||
data-testid="shipping-processing-task-primary-file"
|
||
>
|
||
{{ primaryFileLabel(task) }}
|
||
</div>
|
||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">
|
||
{{ aggregateStatusLabel(task) }}
|
||
</div>
|
||
<div
|
||
v-if="task.recent_append_count"
|
||
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
|
||
>
|
||
{{ resolveShippingProcessingMessage('justAppended', te, t, { count: task.recent_append_count }) }}
|
||
</div>
|
||
<div
|
||
v-else-if="task.recently_created"
|
||
class="mt-1 text-[11px] font-medium text-brand-700 dark:text-brand-300"
|
||
>
|
||
{{ resolveShippingProcessingMessage('justCreated', te, t) }}
|
||
</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 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
|
||
v-if="!workbenchMode && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||
:projection="projectionForTask(task)!"
|
||
:compact="progressModeForTask(task) === 'compact'"
|
||
@action="(item) => emit('projectionAction', { projection: projectionForTask(task)!, item })"
|
||
/>
|
||
<div
|
||
v-if="shouldShowTaskLevelActions(task) || (!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"
|
||
>
|
||
<button
|
||
v-if="!workbenchMode && !projectionForTask(task) && primaryActionItem(task)"
|
||
type="button"
|
||
class="rounded-md border border-brand-300 bg-brand-600 px-2.5 py-1 text-[11px] font-medium text-white hover:bg-brand-700 dark:border-brand-700 dark:bg-brand-700 dark:hover:bg-brand-600"
|
||
:data-testid="`shipping-processing-action-${primaryActionItem(task)!.actionCode}`"
|
||
@click="onTaskAction(task, primaryActionItem(task)!.actionCode)"
|
||
>
|
||
{{ presentationActionLabel(task, primaryActionItem(task)!) }}
|
||
</button>
|
||
<button
|
||
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"
|
||
@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="!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"
|
||
@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>
|
||
</div>
|
||
</article>
|
||
</div>
|
||
</section>
|
||
|
||
<section
|
||
v-if="recordTaskCount > 0"
|
||
data-testid="shipping-processing-group-history"
|
||
>
|
||
<button
|
||
type="button"
|
||
class="mb-1.5 flex w-full items-center justify-between gap-2 text-left text-[11px] font-semibold uppercase tracking-wide text-slate-600 dark:text-slate-300"
|
||
data-testid="shipping-processing-history-toggle"
|
||
@click="toggleHistorySection"
|
||
>
|
||
<span class="inline-flex min-w-0 items-center gap-1">
|
||
<ChevronDown v-if="historySectionExpanded" class="h-3 w-3 shrink-0" />
|
||
<ChevronRight v-else class="h-3 w-3 shrink-0" />
|
||
<span>{{ resolveShippingProcessingMessage('groupProcessingRecords', te, t, { count: recordTaskCount }) }}</span>
|
||
</span>
|
||
<span
|
||
v-if="hiddenHistoryCount > 0"
|
||
class="shrink-0 font-medium normal-case tracking-normal text-muted"
|
||
data-testid="shipping-processing-history-more"
|
||
>
|
||
{{ t('chat.shippingProcessing.historyMoreCount', { count: hiddenHistoryCount }) }}
|
||
</span>
|
||
</button>
|
||
<div
|
||
v-if="historySectionExpanded"
|
||
class="space-y-3"
|
||
data-testid="shipping-processing-history-body"
|
||
>
|
||
<div
|
||
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">
|
||
{{ resolveShippingProcessingMessage('groupRecordCompleted', te, t) }}
|
||
</div>
|
||
<div class="space-y-2">
|
||
<article
|
||
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}`"
|
||
data-record="1"
|
||
>
|
||
<div class="text-sm font-semibold text-primary">
|
||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||
</div>
|
||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||
<span>{{ statusLabel(task) }}</span>
|
||
<span v-if="stageLabel(task)">· {{ stageLabel(task) }}</span>
|
||
</div>
|
||
<div
|
||
v-if="primaryFileLabel(task)"
|
||
class="mt-0.5 truncate text-[11px] text-muted"
|
||
data-testid="shipping-processing-task-primary-file"
|
||
>
|
||
{{ primaryFileLabel(task) }}
|
||
</div>
|
||
<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"
|
||
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
|
||
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
|
||
>
|
||
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
|
||
</button>
|
||
</article>
|
||
</div>
|
||
</div>
|
||
|
||
<div
|
||
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">
|
||
{{ resolveShippingProcessingMessage('groupRecordHistoryVersions', te, t) }}
|
||
</div>
|
||
<div class="space-y-2">
|
||
<article
|
||
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}`"
|
||
data-record="1"
|
||
>
|
||
<div class="text-sm font-semibold text-primary">
|
||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||
</div>
|
||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||
<span>{{ statusLabel(task) }}</span>
|
||
</div>
|
||
<div
|
||
v-if="primaryFileLabel(task)"
|
||
class="mt-0.5 truncate text-[11px] text-muted"
|
||
data-testid="shipping-processing-task-primary-file"
|
||
>
|
||
{{ primaryFileLabel(task) }}
|
||
</div>
|
||
<button
|
||
v-if="recordViewDetailsItem(task)"
|
||
type="button"
|
||
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
|
||
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
|
||
>
|
||
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
|
||
</button>
|
||
</article>
|
||
</div>
|
||
</div>
|
||
|
||
<div
|
||
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">
|
||
{{ resolveShippingProcessingMessage('groupRecordCancelled', te, t) }}
|
||
</div>
|
||
<div class="space-y-2">
|
||
<article
|
||
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}`"
|
||
data-record="1"
|
||
>
|
||
<div class="text-sm font-semibold text-primary">
|
||
{{ resolveShippingProcessingMessage('taskTitle', te, t, { label: taskLabel(task) }) }}
|
||
</div>
|
||
<div class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||
<span>{{ statusLabel(task) }}</span>
|
||
</div>
|
||
<div
|
||
v-if="primaryFileLabel(task)"
|
||
class="mt-0.5 truncate text-[11px] text-muted"
|
||
data-testid="shipping-processing-task-primary-file"
|
||
>
|
||
{{ primaryFileLabel(task) }}
|
||
</div>
|
||
<button
|
||
v-if="recordViewDetailsItem(task)"
|
||
type="button"
|
||
class="mt-1.5 text-[11px] text-secondary underline-offset-2 hover:text-primary hover:underline"
|
||
:data-testid="`shipping-processing-action-${recordViewDetailsItem(task)!.actionCode}`"
|
||
@click="onTaskAction(task, recordViewDetailsItem(task)!.actionCode)"
|
||
>
|
||
{{ presentationActionLabel(task, recordViewDetailsItem(task)!) }}
|
||
</button>
|
||
</article>
|
||
</div>
|
||
</div>
|
||
|
||
<div
|
||
v-if="hiddenHistoryCount > 0"
|
||
class="text-[11px] text-muted"
|
||
data-testid="shipping-processing-history-truncated"
|
||
>
|
||
{{ t('chat.shippingProcessing.historyTruncatedDetail', {
|
||
shown: historyTasks.length,
|
||
hidden: hiddenHistoryCount,
|
||
}) }}
|
||
</div>
|
||
<div
|
||
v-else-if="hasMoreHistory"
|
||
class="text-[11px] text-muted"
|
||
data-testid="shipping-processing-history-truncated"
|
||
>
|
||
{{ t('chat.shippingProcessing.summaryTruncatedHint') }}
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
</template>
|