feat(shipping-notice): 增强发货通知与审计功能,支持敏感数据控制与哈希链校验

- 更新发货通知工具 API,剥离不可信的操作人身份字段,确保审计安全
- 引入审计事件的哈希链校验机制,支持数据完整性验证
- 增强订单抽取与审计功能,支持敏感快照的访问控制
- 更新相关模型与服务,确保新功能的完整性与可追溯性
- 完善文档与代码注释,反映新的业务逻辑与审计要求
This commit is contained in:
hugo committed 2026-07-31 08:59:44 +08:00
1 parent 95cdfe66b0
commit d0fe084999
225 files changed
+25923 -6653

No files matched your search

@@ -0,0 +1,117 @@
/**
* features/workspace/shipping-task-center/ManualUploadEvidenceDialog.spec.ts
* 用途:锁定人工上传登记弹窗无障碍与必填校验契约。
* 依赖:vitest、@vue/test-utils、vue-i18n、file-assets / shipping-tasks API mock。
* 逻辑:打开时具备 dialog 角色;Escape 关闭;缺少回执号不得提交;关闭后恢复先前焦点。
*/
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { mount, flushPromises } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import { nextTick } from 'vue';
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
vi.mock('@/shared/api/file-assets.api', () => ({
uploadFileAsset: vi.fn(async () => ({ asset_no: 'FA-TEST-1' })),
}));
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
markWorkspaceShippingManualUploaded: vi.fn(async () => ({})),
}));
const messages = {
'zh-CN': {
workspace: {
shippingNotice: {
actions: { failed: '失败' },
manualUpload: {
title: '登记人工上传',
hint: '请上传凭据并填写回执号',
evidenceLabel: '证据文件',
freightRefLabel: '货代回执号',
evidenceRequired: '请先选择证据文件',
freightRefRequired: '请填写货代回执号',
cancel: '取消',
submit: '确认已上传',
submitting: '提交中…',
},
},
},
},
};
/**
* 挂载人工上传登记弹窗。
*/
function mountDialog(open = true) {
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
return mount(ManualUploadEvidenceDialog, {
props: {
open,
taskNo: 'SN-DIALOG-1',
artifactId: 9,
},
attachTo: document.body,
global: { plugins: [i18n] },
});
}
describe('ManualUploadEvidenceDialog', () => {
beforeEach(() => {
document.body.innerHTML = '';
});
afterEach(() => {
document.body.innerHTML = '';
});
it('exposes dialog accessibility attributes when open', async () => {
const wrapper = mountDialog(true);
await nextTick();
const dialog = wrapper.get('[data-testid="manual-upload-evidence-dialog"]');
expect(dialog.attributes('role')).toBe('dialog');
expect(dialog.attributes('aria-modal')).toBe('true');
wrapper.unmount();
});
it('closes on Escape and restores prior focus', async () => {
const trigger = document.createElement('button');
trigger.type = 'button';
trigger.textContent = 'open';
document.body.appendChild(trigger);
trigger.focus();
expect(document.activeElement).toBe(trigger);
const wrapper = mountDialog(true);
await nextTick();
await flushPromises();
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
await nextTick();
await flushPromises();
expect(wrapper.emitted('update:open')?.at(-1)).toEqual([false]);
await wrapper.setProps({ open: false });
await nextTick();
await flushPromises();
expect(document.activeElement).toBe(trigger);
wrapper.unmount();
});
it('requires freight receipt before submit when evidence is selected', async () => {
const wrapper = mountDialog(true);
await nextTick();
const fileInput = wrapper.get('input[type="file"]');
const file = new File(['evidence'], 'shot.png', { type: 'image/png' });
Object.defineProperty(fileInput.element, 'files', {
value: [file],
configurable: true,
});
await fileInput.trigger('change');
await nextTick();
const submit = wrapper.findAll('button').find((btn) => btn.text().includes('确认已上传'));
expect(submit).toBeTruthy();
expect(submit!.attributes('disabled')).toBeDefined();
wrapper.unmount();
});
});
@@ -1,11 +1,12 @@
/**
* features/workspace/shipping-task-center/ManualUploadEvidenceDialog.vue
* 用途:人工上传凭据对话框;截图/PDF 证据必填,回执号可选。
* 依赖:uploadFileAsset、workspace shipping-tasks.api。
* 逻辑:由 TaskTodoPanel 在 mark_manual_uploaded 动作时打开;禁止触发 RPA 上传。
* 用途:人工上传凭据对话框;截图/PDF 证据与货代回执号均必填。
* 依赖:uploadFileAsset、workspace shipping-tasks.api、Vue watch/nextTick。
* 逻辑:由 TaskTodoPanel 在 mark_manual_uploaded 动作时打开;禁止触发 RPA 上传;
* 对齐复核弹层无障碍:role=dialog、aria-modal、焦点陷阱、Escape、关闭后焦点恢复。
*/
<script setup lang="ts">
import { ref } from 'vue';
import { nextTick, onBeforeUnmount, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { uploadFileAsset } from '@/shared/api/file-assets.api';
import { markWorkspaceShippingManualUploaded } from '@/features/workspace/api/shipping-tasks.api';
@@ -27,6 +28,26 @@ const busy = ref(false);
const error = ref('');
const evidenceFile = ref<File | null>(null);
const freightRefNo = ref('');
const panelRef = ref<HTMLElement | null>(null);
let previouslyFocused: HTMLElement | null = null;
const FOCUSABLE_SELECTOR = [
'a[href]',
'button:not([disabled])',
'textarea:not([disabled])',
'input:not([disabled])',
'select:not([disabled])',
'[tabindex]:not([tabindex="-1"])',
].join(',');
/**
* 收集弹窗内可聚焦控件,供 Tab 陷阱使用。
*/
function focusableNodes(): HTMLElement[] {
if (!panelRef.value) return [];
return Array.from(panelRef.value.querySelectorAll<HTMLElement>(FOCUSABLE_SELECTOR))
.filter((node) => !node.hasAttribute('disabled') && node.getAttribute('aria-hidden') !== 'true');
}
/**
* 关闭对话框并清空本地表单。
@@ -39,6 +60,71 @@ function close() {
emit('update:open', false);
}
/**
* Escape 关闭;Tab / Shift+Tab 在弹窗内循环。
*/
function onKeydown(event: KeyboardEvent) {
if (!props.open) return;
if (event.key === 'Escape') {
if (busy.value) return;
event.preventDefault();
event.stopPropagation();
close();
return;
}
if (event.key !== 'Tab') return;
const nodes = focusableNodes();
const first = nodes[0];
const last = nodes[nodes.length - 1];
if (!first || !last) {
event.preventDefault();
return;
}
const active = document.activeElement as HTMLElement | null;
const inside = Boolean(active && panelRef.value?.contains(active));
if (event.shiftKey) {
if (!inside || active === first) {
event.preventDefault();
last.focus();
}
return;
}
if (!inside || active === last) {
event.preventDefault();
first.focus();
}
}
watch(
() => props.open,
async (isOpen, wasOpen) => {
if (typeof document === 'undefined') return;
if (isOpen && !wasOpen) {
previouslyFocused = document.activeElement instanceof HTMLElement
? document.activeElement
: null;
document.addEventListener('keydown', onKeydown, true);
await nextTick();
(focusableNodes()[0] || panelRef.value)?.focus();
return;
}
if (!isOpen && wasOpen) {
document.removeEventListener('keydown', onKeydown, true);
const restoreTarget = previouslyFocused;
previouslyFocused = null;
await nextTick();
restoreTarget?.focus?.();
}
},
{ immediate: true },
);
onBeforeUnmount(() => {
if (typeof document !== 'undefined') {
document.removeEventListener('keydown', onKeydown, true);
}
});
/**
* 选择证据文件(截图或 PDF)。
*/
@@ -50,6 +136,7 @@ function onFileChange(event: Event) {
/**
* 上传证据资产并登记人工上传完成。
* 核心逻辑:证据文件与回执号均必填,与后端 record_manual_upload 契约一致。
*/
async function submit() {
if (props.disabled || busy.value) return;
@@ -57,14 +144,19 @@ async function submit() {
error.value = t('workspace.shippingNotice.manualUpload.evidenceRequired');
return;
}
const receipt = freightRefNo.value.trim();
if (!receipt) {
error.value = t('workspace.shippingNotice.manualUpload.freightRefRequired');
return;
}
busy.value = true;
error.value = '';
try {
const asset = await uploadFileAsset(evidenceFile.value);
await markWorkspaceShippingManualUploaded(props.taskNo, {
evidence_asset_no: asset.asset_no,
freight_ref_no: receipt,
...(props.artifactId ? { artifact_id: props.artifactId } : {}),
...(freightRefNo.value.trim() ? { freight_ref_no: freightRefNo.value.trim() } : {}),
});
emit('success');
close();
@@ -82,8 +174,19 @@ async function submit() {
class="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
@click.self="close"
>
<div class="w-full max-w-md rounded-2xl border border-default bg-surface p-5 shadow-xl">
<h3 class="text-base font-semibold text-primary">
<div
ref="panelRef"
role="dialog"
aria-modal="true"
:aria-labelledby="'manual-upload-evidence-title'"
tabindex="-1"
class="w-full max-w-md rounded-2xl border border-default bg-surface p-5 shadow-xl outline-none"
data-testid="manual-upload-evidence-dialog"
>
<h3
id="manual-upload-evidence-title"
class="text-base font-semibold text-primary"
>
{{ $t('workspace.shippingNotice.manualUpload.title') }}
</h3>
<p class="mt-1 text-sm text-muted">
@@ -102,7 +205,7 @@ async function submit() {
</label>
<label class="mt-3 block text-xs font-medium text-muted">
{{ $t('workspace.shippingNotice.manualUpload.freightRefOptional') }}
{{ $t('workspace.shippingNotice.manualUpload.freightRefLabel') }}
<input
v-model="freightRefNo"
type="text"
@@ -111,7 +214,7 @@ async function submit() {
>
</label>
<p v-if="error" class="mt-3 text-sm text-rose-600">{{ error }}</p>
<p v-if="error" class="mt-3 text-sm text-rose-600" role="alert">{{ error }}</p>
<div class="mt-5 flex justify-end gap-2">
<button
@@ -125,7 +228,7 @@ async function submit() {
<button
type="button"
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
:disabled="busy || disabled || !evidenceFile"
:disabled="busy || disabled || !evidenceFile || !freightRefNo.trim()"
@click="submit"
>
{{ busy ? $t('workspace.shippingNotice.manualUpload.submitting') : $t('workspace.shippingNotice.manualUpload.submit') }}
@@ -2,10 +2,11 @@
* features/workspace/shipping-task-center/ShippingTaskCenterPage.vue
* 用途:发货「我的待办」壳——Pending|Processing|Done + 识别 Run 续办表 + 右侧任务工作台或复核深链。
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情、ShippingTaskWorkbench、ShippingRunProgressTable、useShippingTodoBadge。
* 逻辑:review_case 项用 review_run_no 打开人工复核;task 项打开任务处理工作台;识别页承接取消/重试/回会话。
* 逻辑:review_case 项用 review_run_no 打开人工复核;task 项打开任务处理工作台;
* 仅对进行中 Workflow/Task 自动刷新(前台 2s / 后台 8s)。
*/
<script setup lang="ts">
import { computed, onMounted, ref, watch } from 'vue';
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { ExternalLink, RefreshCw } from 'lucide-vue-next';
import {
@@ -24,6 +25,39 @@ import { useShippingTodoBadge } from '../composables/useShippingTodoBadge';
import ShippingTaskWorkbench from './ShippingTaskWorkbench.vue';
import ShippingRunProgressTable from './ShippingRunProgressTable.vue';
/** 进行中 Workflow/Task 前台轮询间隔。 */
const FOREGROUND_POLL_MS = 2000;
/** 页面隐藏时后台轮询间隔。 */
const BACKGROUND_POLL_MS = 8000;
/** 仍视为进行中、需要自动刷新的任务 process_status。 */
const IN_PROGRESS_PROCESS = new Set([
'parsing',
'parsed',
'matching',
'matched',
'waiting_upload',
'uploading',
'upload_failed',
'exporting',
'needs_human',
'pending_void',
]);
/** WorkflowItem 仍开放处理的生命周期(含待人工上传登记)。 */
const IN_PROGRESS_WORKFLOW_ITEM = new Set([
'queued',
'layout_parsing',
'extracting',
'building_order',
'inventory_matching',
'generating_excel',
'pending_review',
'manual_upload_pending',
'reparse_failed',
'failed',
]);
const route = useRoute();
const router = useRouter();
const { refreshShippingTodoBadge } = useShippingTodoBadge();
@@ -54,6 +88,8 @@ const bucketCounts = ref<ShippingMyTodosCount>({
total_pending_badge: 0,
});
const chatAgentId = ref<number | null>(null);
let pollTimer: ReturnType<typeof setTimeout> | null = null;
let pollInFlight = false;
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)));
const canHandle = computed(() => detail.value?.can_handle !== false);
@@ -89,6 +125,73 @@ function todoDisplayNo(item: ShippingTaskSummary): string {
return String(item.task_no || item.todo_ref || '—');
}
/**
* 判断详情是否仍处于进行中(含绑定 WorkflowItem)。
*/
function isDetailInProgress(task: ShippingTaskDetail | null): boolean {
if (!task) return false;
const process = String(task.process_status || '').trim();
if (IN_PROGRESS_PROCESS.has(process)) return true;
const itemStatus = String(task.workflow_item?.lifecycle_status || '').trim();
return IN_PROGRESS_WORKFLOW_ITEM.has(itemStatus);
}
/**
* 是否应继续自动轮询:仅 processing 桶、进行中详情,或 runs 面。
*/
const shouldAutoRefresh = computed(() => {
if (surface.value === 'runs') return true;
if (bucket.value === 'processing') return true;
if (isDetailInProgress(detail.value)) return true;
return tasks.value.some((item) => {
const status = String(item.process_status || '').trim();
return IN_PROGRESS_PROCESS.has(status) || item.item_kind === 'review_case';
});
});
/**
* 按页面可见性选择轮询间隔。
*/
function resolvePollMs(): number {
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') {
return BACKGROUND_POLL_MS;
}
return FOREGROUND_POLL_MS;
}
/**
* 停止自动轮询。
*/
function stopAutoRefresh() {
if (pollTimer != null) {
clearTimeout(pollTimer);
pollTimer = null;
}
}
/**
* 调度下一次自动刷新(仅进行中 Workflow/Task)。
*/
function scheduleAutoRefresh() {
stopAutoRefresh();
if (!shouldAutoRefresh.value) return;
pollTimer = setTimeout(() => {
void (async () => {
if (pollInFlight || !shouldAutoRefresh.value) {
scheduleAutoRefresh();
return;
}
pollInFlight = true;
try {
await refreshAll({ silent: true });
} finally {
pollInFlight = false;
scheduleAutoRefresh();
}
})();
}, resolvePollMs());
}
/**
* 解析货代 Chat Agent,供复核/会话深链。
*/
@@ -194,9 +297,15 @@ async function loadDetail(taskNo: string) {
/**
* 列表与详情联动刷新。
* @param options.silent - 轮询时不强制切换 loading 闪烁(详情仍更新)
*/
async function refreshAll() {
await Promise.all([loadTodos(), loadCounts()]);
async function refreshAll(options?: { silent?: boolean }) {
const silent = Boolean(options?.silent);
if (!silent) {
await Promise.all([loadTodos(), loadCounts()]);
} else {
await Promise.all([loadTodos(), loadCounts()]);
}
if (isDirectTaskRoute.value && preferredTaskNo.value) {
await loadDetail(preferredTaskNo.value);
return;
@@ -286,20 +395,35 @@ watch(selectedItem, (item) => {
}
});
watch(shouldAutoRefresh, () => {
scheduleAutoRefresh();
});
function onVisibilityChange() {
scheduleAutoRefresh();
}
onMounted(async () => {
await Promise.all([resolveChatAgent(), loadCounts(), loadTodos()]);
if (preferredTaskNo.value) {
if (isDirectTaskRoute.value) {
selectedRef.value = preferredTaskNo.value;
await loadDetail(preferredTaskNo.value);
return;
}
const hit = tasks.value.find((item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value);
if (!hit) {
selectedRef.value = preferredTaskNo.value;
await loadDetail(preferredTaskNo.value);
} else {
const hit = tasks.value.find((item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value);
if (!hit) {
selectedRef.value = preferredTaskNo.value;
await loadDetail(preferredTaskNo.value);
}
}
}
document.addEventListener('visibilitychange', onVisibilityChange);
scheduleAutoRefresh();
});
onBeforeUnmount(() => {
stopAutoRefresh();
document.removeEventListener('visibilitychange', onVisibilityChange);
});
</script>
@@ -313,7 +437,7 @@ onMounted(async () => {
<button
type="button"
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft"
@click="refreshAll"
@click="refreshAll()"
>
<RefreshCw class="h-3.5 w-3.5" />
{{ $t('workspace.shippingNotice.refresh') }}
@@ -359,7 +483,7 @@ onMounted(async () => {
{{ $t('workspace.shippingNotice.openChat') }}
</button>
</div>
<ShippingTaskWorkbench :detail="detail" :can-handle="canHandle" @refreshed="refreshAll" />
<ShippingTaskWorkbench :detail="detail" :can-handle="canHandle" @refreshed="() => refreshAll()" />
</div>
</div>
@@ -534,7 +658,7 @@ onMounted(async () => {
<ShippingTaskWorkbench
:detail="detail"
:can-handle="canHandle"
@refreshed="refreshAll"
@refreshed="() => refreshAll()"
/>
</div>
</div>
@@ -1,18 +1,23 @@
/**
* features/workspace/shipping-task-center/ShippingTaskWorkbench.vue
* 用途:发货任务处理主区——当前待办栏、订单概览、时间线;履约写操作入口。
* 依赖:TaskTodoPanel、TaskProgressTimeline、ShippingTaskParsedResultCard、ShippingWorkflowStepper。
* 逻辑:由 ShippingTaskCenterPage 选中任务后挂载;只消费后端 ui_state,不发明进度百分比。
* 用途:发货任务处理主区——当前待办栏、统一节点、最后活动/终止原因、STP 事实、订单概览、时间线。
* 依赖:TaskTodoPanel、StpProgressFactsPanel、TaskProgressTimeline、ShippingTaskParsedResultCard、ShippingWorkflowStepper。
* 逻辑:由 ShippingTaskCenterPage 选中任务后挂载;只消费后端 ui_state / workflow_item,不发明进度百分比。
*/
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
import ShippingMatchResultCard from '@/features/chat/components/messages/ShippingMatchResultCard.vue';
import ShippingTaskParsedResultCard from '@/features/chat/components/ShippingTaskParsedResultCard.vue';
import { resolveShippingWorkflowSteps } from '@/features/chat/shipping';
import type { ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import TaskTodoPanel from './TaskTodoPanel.vue';
import StpProgressFactsPanel from './StpProgressFactsPanel.vue';
import TaskProgressTimeline from './TaskProgressTimeline.vue';
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
import { useMessage } from '@/shared/composables/useMessage';
const props = defineProps<{
detail: ShippingTaskDetail;
@@ -23,6 +28,9 @@ const emit = defineEmits<{
refreshed: [];
}>();
const { t } = useI18n();
const msg = useMessage();
const workflowSteps = computed(() => resolveShippingWorkflowSteps(props.detail));
const shortageLines = computed(() => props.detail.shortage?.lines || []);
const hasMatchCard = computed(() =>
@@ -30,6 +38,26 @@ const hasMatchCard = computed(() =>
|| shortageLines.value.length > 0,
);
const events = computed(() => props.detail.events || []);
const workflowItem = computed(() => props.detail.workflow_item || null);
const workflowEvents = computed(() => workflowItem.value?.events || []);
const stpFacts = computed(() => props.detail.ui_state?.summary?.stp_facts || null);
const lastActivityAt = computed(() => workflowItem.value?.last_activity_at || props.detail.updated_at || null);
const terminateReason = computed(() => workflowItem.value?.closed_reason || null);
const hasExcelArtifact = computed(() =>
Array.isArray(props.detail.export_artifacts) && props.detail.export_artifacts.length > 0,
);
/**
* 下载已生成的发货 Excel。
*/
async function downloadExcel() {
try {
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
emit('refreshed');
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
}
}
</script>
<template>
@@ -45,8 +73,35 @@ const events = computed(() => props.detail.events || []);
{{ $t('workspace.shippingNotice.todo.workflow') }}
</div>
<ShippingWorkflowStepper :steps="workflowSteps" />
<dl class="mt-3 grid gap-2 text-xs sm:grid-cols-2">
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.todo.lastActivity') }}</dt>
<dd class="text-secondary">{{ lastActivityAt ? formatLocalDateTime(lastActivityAt) : '—' }}</dd>
</div>
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.todo.terminateReason') }}</dt>
<dd class="text-secondary">{{ terminateReason || '—' }}</dd>
</div>
<div v-if="workflowItem" class="sm:col-span-2">
<dt class="text-muted">{{ $t('workspace.shippingNotice.todo.workflowItem') }}</dt>
<dd class="font-mono text-secondary">
{{ workflowItem.item_no }} · {{ workflowItem.lifecycle_status }} · {{ workflowItem.current_stage }}
</dd>
</div>
</dl>
<div v-if="hasExcelArtifact" class="mt-3">
<button
type="button"
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft"
@click="downloadExcel"
>
{{ $t('workspace.shippingNotice.todo.downloadExcel') }}
</button>
</div>
</section>
<StpProgressFactsPanel :facts="stpFacts" />
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
<h3 class="mb-3 text-sm font-semibold text-secondary">
{{ $t('workspace.shippingNotice.todo.orderOverview') }}
@@ -97,6 +152,6 @@ const events = computed(() => props.detail.events || []);
:action-busy="false"
/>
<TaskProgressTimeline :events="events" />
<TaskProgressTimeline :events="events" :workflow-events="workflowEvents" />
</div>
</template>
@@ -0,0 +1,126 @@
/**
* features/workspace/shipping-task-center/StpProgressFactsPanel.vue
* 用途:展示后端 ui_state.summary.stp_facts,含逐行 Reservation/料号/实际库存源/文件证据。
* 依赖:ShippingTaskUiState.summary.stp_facts、vue-i18n。
* 逻辑:由 ShippingTaskWorkbench 在待办栏下方挂载;无 stp_facts 时不渲染;不发明进度。
*/
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import type { ShippingStpFacts } from '@/features/chat/types/shipping.api.types';
const props = defineProps<{
facts: ShippingStpFacts | null | undefined;
}>();
const { t, te } = useI18n();
const visible = computed(() => Boolean(props.facts));
const resolutionEntries = computed(() => {
const counts = props.facts?.resolution_counts || {};
return Object.entries(counts).map(([disposition, count]) => ({ disposition, count }));
});
const lineRows = computed(() => props.facts?.line_resolutions || []);
/**
* 行级 disposition 文案;未知码回退原文。
*/
function dispositionLabel(disposition: string): string {
const key = `workspace.shippingNotice.stpFacts.disposition.${disposition}`;
return te(key) ? t(key) : disposition;
}
/**
* 行证据摘要:文件号 + 行引用键。
*/
function evidenceText(row: NonNullable<ShippingStpFacts['line_resolutions']>[number]): string {
const fileNo = String(row?.inventory_file_no || '').trim();
const ref = row?.inventory_row_ref;
const refParts = [
ref?.reservation_id,
ref?.part_number,
ref?.source_code,
].filter(Boolean).map(String);
if (fileNo && refParts.length) return `${fileNo} · ${refParts.join('/')}`;
if (fileNo) return fileNo;
if (refParts.length) return refParts.join('/');
return '—';
}
</script>
<template>
<section
v-if="visible && facts"
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
data-testid="stp-progress-facts-panel"
>
<h3 class="mb-2 text-sm font-semibold text-secondary">
{{ $t('workspace.shippingNotice.stpFacts.title') }}
</h3>
<dl class="grid gap-2 text-xs sm:grid-cols-2">
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.stpFacts.inventorySourceStatus') }}</dt>
<dd class="font-medium text-secondary">{{ facts.inventory_source_status || '—' }}</dd>
</div>
<div>
<dt class="text-muted">{{ $t('workspace.shippingNotice.stpFacts.inventorySourceCode') }}</dt>
<dd class="font-medium text-secondary">{{ facts.inventory_source_code || '—' }}</dd>
</div>
<div class="sm:col-span-2">
<dt class="text-muted">{{ $t('workspace.shippingNotice.stpFacts.frozenCandidates') }}</dt>
<dd class="font-medium text-secondary">
{{ (facts.frozen_candidate_codes || []).join(', ') || '—' }}
</dd>
</div>
<div v-if="facts.multi_source_excel_block" class="sm:col-span-2 rounded-lg bg-amber-50 px-3 py-2 text-amber-900">
{{ $t('workspace.shippingNotice.stpFacts.multiSourceBlock') }}
<span v-if="(facts.resolved_ok_source_codes || []).length">
({{ (facts.resolved_ok_source_codes || []).join(', ') }})
</span>
</div>
<div v-if="resolutionEntries.length" class="sm:col-span-2">
<dt class="mb-1 text-muted">{{ $t('workspace.shippingNotice.stpFacts.resolutionCounts') }}</dt>
<dd class="flex flex-wrap gap-2">
<span
v-for="item in resolutionEntries"
:key="item.disposition"
class="rounded-full border border-default/70 px-2 py-0.5 text-secondary"
>
{{ dispositionLabel(item.disposition) }}
× {{ item.count }}
</span>
</dd>
</div>
</dl>
<div v-if="lineRows.length" class="mt-3 overflow-x-auto">
<div class="mb-1 text-xs text-muted">{{ $t('workspace.shippingNotice.stpFacts.lineTableTitle') }}</div>
<table class="min-w-full border-collapse text-xs">
<thead>
<tr class="border-b border-default/70 text-left text-muted">
<th class="py-1 pr-2 font-medium">{{ $t('workspace.shippingNotice.stpFacts.colLine') }}</th>
<th class="py-1 pr-2 font-medium">{{ $t('workspace.shippingNotice.stpFacts.colReservation') }}</th>
<th class="py-1 pr-2 font-medium">{{ $t('workspace.shippingNotice.stpFacts.colPart') }}</th>
<th class="py-1 pr-2 font-medium">{{ $t('workspace.shippingNotice.stpFacts.colDisposition') }}</th>
<th class="py-1 pr-2 font-medium">{{ $t('workspace.shippingNotice.stpFacts.colSource') }}</th>
<th class="py-1 font-medium">{{ $t('workspace.shippingNotice.stpFacts.colEvidence') }}</th>
</tr>
</thead>
<tbody>
<tr
v-for="(row, index) in lineRows"
:key="`${row.line_key || row.line_index}-${index}`"
class="border-b border-default/50 align-top"
>
<td class="py-1.5 pr-2 font-mono">{{ (row.line_index ?? index) + 1 }}</td>
<td class="py-1.5 pr-2 font-mono">{{ row.effective_reservation_id || '—' }}</td>
<td class="py-1.5 pr-2 font-mono">{{ row.part_number || '—' }}</td>
<td class="py-1.5 pr-2">{{ dispositionLabel(String(row.disposition || 'unknown')) }}</td>
<td class="py-1.5 pr-2 font-mono">{{ row.resolved_inventory_source_code || '—' }}</td>
<td class="py-1.5 font-mono text-muted">{{ evidenceText(row) }}</td>
</tr>
</tbody>
</table>
</div>
</section>
</template>
@@ -0,0 +1,60 @@
/**
* features/workspace/shipping-task-center/TaskProgressTimeline.spec.ts
* 用途:锁定任务中心时间线同时消费 Task Event 与 Workflow Event。
* 依赖:Vitest、@vue/test-utils、TaskProgressTimeline。
* 逻辑:合并排序后两类事件均可见;Workflow 操作人展示 type/id。
*/
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import { createI18n } from 'vue-i18n';
import TaskProgressTimeline from './TaskProgressTimeline.vue';
const messages = {
'zh-CN': {
workspace: {
shippingNotice: {
events: '事件时间线',
operator: '操作者 {id}',
eventTypes: { system: '系统', task_created: '任务已创建' },
workflowEvents: { stage_changed: '阶段变更', upload_manual_confirmed: '人工上传已登记' },
timeline: {
empty: '暂无事件记录',
detail: '查看详情',
sourceTask: '任务事件',
sourceWorkflow: 'Workflow 事件',
workflowEvent: 'Workflow 事件',
},
},
},
},
};
describe('TaskProgressTimeline', () => {
it('merges task and workflow events and shows workflow actor type/id', () => {
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
const wrapper = mount(TaskProgressTimeline, {
props: {
events: [
{ event_type: 'task_created', created_at: '2026-07-31T01:00:00Z', actor_id: 1 },
],
workflowEvents: [
{
seq_no: 1,
event_code: 'upload_manual_confirmed',
actor_type: 'user',
actor_id: '42',
occurred_at: '2026-07-31T01:01:00Z',
},
],
},
global: { plugins: [i18n] },
});
// 关键断言:时间线同时展示 Task 与 Workflow 事件来源标签,且 Workflow 显示操作人。
expect(wrapper.text()).toContain('任务事件');
expect(wrapper.text()).toContain('Workflow 事件');
expect(wrapper.text()).toContain('任务已创建');
expect(wrapper.text()).toContain('人工上传已登记');
expect(wrapper.text()).toContain('操作者 1');
expect(wrapper.text()).toContain('操作者 user/42');
});
});
@@ -1,16 +1,93 @@
/**
* features/workspace/shipping-task-center/TaskProgressTimeline.vue
* 用途:展示任务事件时间线(只读),不发明进度百分比。
* 依赖:ShippingTaskEvent、dateTime 工具。
* 逻辑:由 ShippingTaskWorkbench 传入 detail.events。
* 用途:展示任务事件 + Workflow Event 统一时间线(只读),不发明进度百分比。
* 依赖:ShippingTaskEvent、ShippingWorkflowEvent、dateTime、vue-i18n。
* 逻辑:由 ShippingTaskWorkbench 传入 task events 与 workflow events;按时间合并排序;
* Workflow 事件操作人展示为 actor_type/actor_id。
*/
<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { formatLocalDateTime } from '@/shared/utils/dateTime';
import type { ShippingTaskEvent } from '@/features/chat/types/shipping.api.types';
import type { ShippingTaskEvent, ShippingWorkflowEvent } from '@/features/chat/types/shipping.api.types';
defineProps<{
const props = defineProps<{
events: ShippingTaskEvent[];
workflowEvents?: ShippingWorkflowEvent[];
}>();
const { t, te } = useI18n();
type TimelineRow = {
key: string;
label: string;
createdAt?: string | null;
actor?: string | null;
detail?: Record<string, unknown> | null;
source: 'task' | 'workflow';
};
/**
* 将任务事件类型映射为可读文案;契约外码原样展示。
*/
function taskEventLabel(eventType: string | null | undefined): string {
const code = String(eventType || '').trim();
if (!code) return t('workspace.shippingNotice.eventTypes.system');
const key = `workspace.shippingNotice.eventTypes.${code}`;
return te(key) ? t(key) : code;
}
/**
* 将 Workflow Event 码映射为可读文案。
*/
function workflowEventLabel(event: ShippingWorkflowEvent): string {
const code = String(event.event_code || event.message_code || event.stage_code || '').trim();
if (!code) return t('workspace.shippingNotice.timeline.workflowEvent');
const key = `workspace.shippingNotice.workflowEvents.${code}`;
return te(key) ? t(key) : code;
}
/**
* 格式化操作人展示:优先 type/id,便于审计追溯。
* @param actorType - 角色(user/system/admin…)
* @param actorId - 操作者 ID 或系统标识
*/
function formatActorLabel(actorType?: string | null, actorId?: string | number | null): string | null {
const type = String(actorType || '').trim();
const id = actorId == null ? '' : String(actorId).trim();
if (type && id) return `${type}/${id}`;
if (id) return id;
if (type) return type;
return null;
}
const rows = computed<TimelineRow[]>(() => {
const taskRows: TimelineRow[] = (props.events || []).map((event, index) => ({
key: `task-${event.event_type}-${index}`,
label: taskEventLabel(event.event_type),
createdAt: event.created_at,
actor: formatActorLabel(null, event.actor_id),
detail: event.detail_json || null,
source: 'task',
}));
const workflowRows: TimelineRow[] = (props.workflowEvents || []).map((event, index) => ({
key: `wf-${event.seq_no}-${index}`,
label: workflowEventLabel(event),
createdAt: event.occurred_at,
actor: formatActorLabel(event.actor_type, event.actor_id),
detail: {
...(event.payload || {}),
...(event.reason ? { reason: event.reason } : {}),
...(event.stage_code ? { stage_code: event.stage_code } : {}),
},
source: 'workflow',
}));
return [...taskRows, ...workflowRows].sort((a, b) => {
const ta = a.createdAt ? new Date(a.createdAt).getTime() : 0;
const tb = b.createdAt ? new Date(b.createdAt).getTime() : 0;
return ta - tb;
});
});
</script>
<template>
@@ -18,21 +95,34 @@ defineProps<{
<h3 class="mb-2 text-sm font-semibold text-secondary">
{{ $t('workspace.shippingNotice.events') }}
</h3>
<div v-if="!events.length" class="py-4 text-center text-xs text-muted">
<div v-if="!rows.length" class="py-4 text-center text-xs text-muted">
{{ $t('workspace.shippingNotice.timeline.empty') }}
</div>
<div
v-for="(event, index) in events"
:key="`${event.event_type}-${index}`"
v-for="row in rows"
:key="row.key"
class="border-t border-default/70 py-2 first:border-t-0 first:pt-0"
>
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
<span class="font-medium text-secondary">{{ event.event_type }}</span>
<span class="text-muted">{{ formatLocalDateTime(event.created_at) }}</span>
<span v-if="event.actor_id" class="text-muted">{{ $t('workspace.shippingNotice.operator', { id: event.actor_id }) }}</span>
<span class="font-medium text-secondary">{{ row.label }}</span>
<span
class="rounded px-1.5 py-0.5 text-[10px]"
:class="row.source === 'workflow' ? 'bg-indigo-50 text-indigo-700' : 'bg-slate-100 text-slate-600'"
>
{{ row.source === 'workflow'
? $t('workspace.shippingNotice.timeline.sourceWorkflow')
: $t('workspace.shippingNotice.timeline.sourceTask') }}
</span>
<span class="text-muted">{{ formatLocalDateTime(row.createdAt) }}</span>
<span v-if="row.actor" class="text-muted">{{ $t('workspace.shippingNotice.operator', { id: row.actor }) }}</span>
</div>
<pre v-if="event.detail_json && Object.keys(event.detail_json).length" class="mt-1 whitespace-pre-wrap break-words text-xs text-muted">{{ JSON.stringify(event.detail_json, null, 2) }}</pre>
<pre v-if="event.before_json || event.after_json" class="mt-1 whitespace-pre-wrap break-words text-xs text-muted">{{ JSON.stringify({ before: event.before_json, after: event.after_json }, null, 2) }}</pre>
<details
v-if="row.detail && Object.keys(row.detail).length"
class="mt-1 text-xs text-muted"
>
<summary class="cursor-pointer select-none">{{ $t('workspace.shippingNotice.timeline.detail') }}</summary>
<pre class="mt-1 whitespace-pre-wrap break-words">{{ JSON.stringify(row.detail, null, 2) }}</pre>
</details>
</div>
</section>
</template>
@@ -1,131 +1,91 @@
/**
* features/workspace/shipping-task-center/TaskTodoPanel.vue
* 用途:仅渲染后端 ui_state.action_buttons / summary.allowed_actions 对应的当前待办动作。
* 依赖:shipping.api 履约写接口、shipping-tasks.api 下载/人工上传、各确认对话框。
* 逻辑:禁止按 process_status 二次推导按钮;管理员 can_handle=false 时只读。
* 依赖:shipping.api 履约写接口、shipping-tasks.api 下载/人工上传、ManualUploadEvidenceDialog、各确认对话框。
* 逻辑:禁止按 process_status 二次推导按钮;管理员 can_handle=false 时只读;
* wait_manual_upload 允许下载 Excel + 登记人工上传凭据(禁 RPA);
* 多源阻断时对话框候选强制取 stp_facts.recovery_source_codes,禁止展示冻结全集。
*/
<script setup lang="ts">
import { computed, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useMessage } from '@/shared/composables/useMessage';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCustomerConfirmDialog.vue';
import type {
ShippingChatAction,
ShippingCustomerOption,
ShippingInventorySourceCandidate,
ShippingTaskDetail,
} from '@/features/chat/types/shipping.api.types';
import {
confirmWorkspaceShippingCustomer,
confirmWorkspaceShippingInventorySource,
freezeWorkspaceShippingOrder,
generateWorkspaceShippingExcel,
listWorkspaceShippingCustomerOptions,
matchWorkspaceShippingInventory,
retryWorkspaceShippingUpload,
submitWorkspaceShippingDecision,
} from '@/features/chat/api/shipping.api';
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
import InventorySourceSelectDialog from './InventorySourceSelectDialog.vue';
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
const props = defineProps<{
detail: ShippingTaskDetail;
canHandle: boolean;
}>();
const emit = defineEmits<{
refreshed: [];
}>();
const { t } = useI18n();
const msg = useMessage();
const busyId = ref<string | null>(null);
const manualUploadOpen = ref(false);
const customerDialogOpen = ref(false);
const customerOptions = ref<ShippingCustomerOption[]>([]);
const customerLoading = ref(false);
const freezeDialogOpen = ref(false);
const pendingFreezeVersion = ref<number | null>(null);
const inventorySourceDialogOpen = ref(false);
const inventorySourceCandidates = ref<ShippingInventorySourceCandidate[]>([]);
const inventorySourceInitialCode = ref('');
const summary = computed(() => props.detail.ui_state?.summary || {});
const actionButtons = computed(() => props.detail.ui_state?.action_buttons || []);
const checkpointKind = computed(() => String(props.detail.ui_state?.checkpoint_kind || ''));
const checkpoint = computed(() => String(props.detail.ui_state?.checkpoint || ''));
/**
* 是否展示「待人工上传登记」提示。
* 核心逻辑:wait_manual_upload,或 export_ready/export_generated 且已有导出文件名/工件。
*/
const showWaitingManualUploadNote = computed(() => {
if (checkpointKind.value === 'wait_manual_upload') return true;
if (checkpoint.value === 'export_ready' || checkpoint.value === 'export_generated') {
return Boolean(
props.detail.export_file_name
|| (Array.isArray(props.detail.export_artifacts) && props.detail.export_artifacts.length > 0),
);
}
return false;
});
/** 当前导出工件 id,供人工上传登记对话框绑定。 */
const currentExportArtifactId = computed(() => {
const artifacts = props.detail.export_artifacts;
if (!Array.isArray(artifacts) || !artifacts.length) return null;
const id = Number(artifacts[0]?.id);
return Number.isFinite(id) ? id : null;
});
/** auto_continue 仅保留刷新;正常 STP 由后台自动推进。 */
const AUTO_CONTINUE_ACTIONS = new Set(['refresh']);
/** wait_manual_upload 仅允许下载/导出/人工上传确认。 */
const WAIT_MANUAL_UPLOAD_ACTIONS = new Set(['download_excel', 'export', 'mark_manual_uploaded', 'refresh']);
/** must_human 保留例外处理动作,禁止 Chat 侧履约写路径。 */
const MUST_HUMAN_ACTIONS = new Set([
'confirm',
@@ -142,7 +102,6 @@ const MUST_HUMAN_ACTIONS = new Set([
'match_inventory',
'refresh',
]);
/**
* 按 STP checkpoint_kind 过滤工作台动作,避免 auto_continue 误点写操作。
*/
@@ -153,601 +112,291 @@ function isActionAllowedForCheckpoint(actionId: string, kind: string): boolean {
if (kind === 'must_human') return MUST_HUMAN_ACTIONS.has(actionId);
return true;
}
const allowedIds = computed(() => {
const fromSummary = summary.value.allowed_actions;
if (Array.isArray(fromSummary) && fromSummary.length) return new Set(fromSummary.map(String));
return new Set(actionButtons.value.map((item) => item.id));
});
const visibleActions = computed(() =>
actionButtons.value.filter((action) => {
const id = String(action.id || '');
return allowedIds.value.has(id) && isActionAllowedForCheckpoint(id, checkpointKind.value);
}),
);
/**
* 动作成功后刷新详情并更新导航徽标。
*/
async function afterSuccess() {
await refreshShippingTodoBadge(true);
emit('refreshed');
}
/**
* 从任务上下文解析唯一库存源编码;多候选或无候选时返回空字符串。
*/
function resolveSingleInventorySourceCode(action: ShippingChatAction): string {
const fromAction = String(action.source_code || '').trim().toUpperCase();
if (fromAction) return fromAction;
const resolution = props.detail.inventory_source_resolution;
const candidates = resolution && typeof resolution === 'object'
? (resolution as { candidates?: unknown }).candidates
: null;
if (Array.isArray(candidates) && candidates.length === 1) {
const only = candidates[0];
if (only && typeof only === 'object') {
return String((only as { source_code?: unknown }).source_code || '').trim().toUpperCase();
}
}
return '';
}
/**
* 打开库存源选择对话框;若已能唯一解析则直接提交。
*/
async function runConfirmInventorySource(action: ShippingChatAction) {
const directCode = resolveSingleInventorySourceCode(action);
if (directCode) {
busyId.value = 'confirm_inventory_source';
try {
await confirmWorkspaceShippingInventorySource(props.detail.task_no, directCode);
await afterSuccess();
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
} finally {
busyId.value = null;
}
return;
}
const resolution = props.detail.inventory_source_resolution;
const raw = resolution && typeof resolution === 'object'
? (resolution as { candidates?: unknown }).candidates
: null;
inventorySourceCandidates.value = Array.isArray(raw)
? raw.filter((item): item is ShippingInventorySourceCandidate =>
Boolean(item && typeof item === 'object' && (item as ShippingInventorySourceCandidate).source_code))
: [];
inventorySourceInitialCode.value = String(action.source_code || '').trim().toUpperCase();
inventorySourceDialogOpen.value = true;
}
/**
* 对话框确认库存源后提交后端。
*/
async function onInventorySourceConfirm(sourceCode: string) {
if (!sourceCode.trim()) {
msg.warning(t('workspace.shippingNotice.actions.inventorySourcePrompt'));
return;
}
busyId.value = 'confirm_inventory_source';
try {
await confirmWorkspaceShippingInventorySource(props.detail.task_no, sourceCode.trim().toUpperCase());
await afterSuccess();
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
} finally {
busyId.value = null;
}
}
/**
* 打开客户确认对话框并加载启用标准客户。
*/
async function openCustomerDialog() {
customerDialogOpen.value = true;
customerLoading.value = true;
try {
customerOptions.value = await listWorkspaceShippingCustomerOptions();
} catch (e: unknown) {
customerOptions.value = [];
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.customerNotFound'));
} finally {
customerLoading.value = false;
}
}
/**
* 按关键词刷新客户选项。
*/
async function searchCustomers(query: string) {
customerLoading.value = true;
try {
customerOptions.value = await listWorkspaceShippingCustomerOptions(query.trim());
if (!customerOptions.value.length) {
msg.warning(t('workspace.shippingNotice.actions.customerNotFound'));
}
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.customerNotFound'));
} finally {
customerLoading.value = false;
}
}
/**
* 确认客户后刷新任务详情。
*/
async function onCustomerConfirm(customerId: number) {
busyId.value = 'confirm_customer';
try {
await confirmWorkspaceShippingCustomer(props.detail.task_no, customerId);
customerDialogOpen.value = false;
await afterSuccess();
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
} finally {
busyId.value = null;
}
}
/**
* 校验版本并打开冻结确认对话框。
*/
function openFreezeDialog() {
const version = Number(props.detail.order_data_version);
if (!Number.isInteger(version) || version < 1) {
msg.warning(t('workspace.shippingNotice.actions.freezeFailed'));
return;
}
pendingFreezeVersion.value = version;
freezeDialogOpen.value = true;
}
/**
* 确认冻结后提交后端。
*/
async function onFreezeConfirm() {
const version = pendingFreezeVersion.value;
if (version == null) return;
busyId.value = 'freeze_order';
try {
await freezeWorkspaceShippingOrder(props.detail.task_no, version);
await afterSuccess();
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
} finally {
busyId.value = null;
pendingFreezeVersion.value = null;
}
}
/**
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
*/
async function runAction(action: ShippingChatAction) {
if (!props.canHandle || busyId.value) return;
const id = String(action.id || '');
if (id === 'mark_manual_uploaded') {
manualUploadOpen.value = true;
return;
}
if (id === 'refresh') {
emit('refreshed');
return;
}
if (id === 'confirm_customer') {
await openCustomerDialog();
return;
}
if (id === 'confirm_inventory_source') {
await runConfirmInventorySource(action);
return;
}
if (id === 'freeze_order') {
openFreezeDialog();
return;
}
busyId.value = id;
try {
if (id === 'download_excel' || id === 'export') {
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
await afterSuccess();
return;
}
if (id === 'generate_excel') {
await generateWorkspaceShippingExcel(props.detail.task_no);
await afterSuccess();
return;
}
if (id === 'match_inventory' || id === 'rematch') {
await matchWorkspaceShippingInventory(props.detail.task_no);
await afterSuccess();
return;
}
if (id === 'retry_upload') {
await retryWorkspaceShippingUpload(props.detail.task_no);
await afterSuccess();
return;
}
await submitWorkspaceShippingDecision(props.detail.task_no, id);
await afterSuccess();
} catch (e: unknown) {
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
} finally {
busyId.value = null;
}
}
</script>
<template>
<section class="rounded-2xl border border-brand-200/80 bg-brand-50/40 px-4 py-3">
<div class="mb-1 text-xs font-semibold uppercase tracking-wide text-brand-700">
{{ $t('workspace.shippingNotice.todo.currentTodo') }}
</div>
<h3 class="text-sm font-semibold text-primary">
{{ summary.current_todo || summary.title || $t('workspace.shippingNotice.todo.noActionTitle') }}
</h3>
<p class="mt-1 text-sm text-secondary">
{{ summary.message || $t('workspace.shippingNotice.todo.noActionMessage') }}
</p>
<p v-if="summary.pause_reason" class="mt-1 text-xs text-amber-700">
{{ summary.pause_reason }}
</p>
<div v-if="!canHandle" class="mt-3 text-xs text-muted">
{{ $t('workspace.shippingNotice.todo.adminViewOnly') }}
</div>
<div v-else-if="visibleActions.length" class="mt-3 flex flex-wrap gap-2">
<button
v-for="action in visibleActions"
:key="action.id"
type="button"
class="rounded-xl px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50"
:class="action.variant === 'danger'
? 'bg-rose-600 text-white hover:bg-rose-700'
: action.variant === 'secondary'
? 'border border-default bg-surface text-secondary hover:bg-surface-soft'
: 'bg-brand-600 text-white hover:bg-brand-700'"
:disabled="busyId === action.id"
@click="runAction(action)"
>
{{ action.label }}
</button>
</div>
<p
v-if="showWaitingManualUploadNote"
class="mt-3 rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-800"
data-testid="manual-upload-end-note"
>
{{ $t('workspace.shippingNotice.todo.waitingManualUploadNote') }}
</p>
<ManualUploadEvidenceDialog
v-model:open="manualUploadOpen"
:task-no="detail.task_no"
:artifact-id="detail.export_artifacts?.[0]?.id"
:artifact-id="currentExportArtifactId"
:disabled="!canHandle"
@success="afterSuccess"
/>
<ShippingCustomerConfirmDialog
:open="customerDialogOpen"
:options="customerOptions"
:loading="customerLoading"
@close="customerDialogOpen = false"
@search="searchCustomers"
@confirm="onCustomerConfirm"
/>
<InventorySourceSelectDialog
v-model:open="inventorySourceDialogOpen"
:candidates="inventorySourceCandidates"
:initial-code="inventorySourceInitialCode"
@confirm="onInventorySourceConfirm"
/>
<DeleteConfirmDialog
v-model="freezeDialogOpen"
confirm-tone="primary"
:title="$t('workspace.shippingNotice.actions.freezeOrder')"
:message="$t('workspace.shippingNotice.actions.freezeConfirm')"
:confirm-text="$t('workspace.shippingNotice.actions.freezeOrder')"
:confirm-loading="busyId === 'freeze_order'"
@confirm="onFreezeConfirm"
/>
</section>
</template>