feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -3,7 +3,8 @@
|
||||
* 用途:发货「我的待办」壳——Pending|Processing|Done + 识别 Run 续办表 + 右侧任务工作台或复核深链。
|
||||
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情、ShippingTaskWorkbench、ShippingRunProgressTable、useShippingTodoBadge。
|
||||
* 逻辑:review_case 项用 review_run_no 打开人工复核;task 项打开任务处理工作台;
|
||||
* 仅对进行中 Workflow/Task 自动刷新(前台 2s / 后台 8s)。
|
||||
* 轮询仅依据 shipping_processing_status / process_status / Intake parse_status,
|
||||
* 不回退 WorkflowItem lifecycle;created/queued/parsing Intake 持续刷新。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
@@ -22,6 +23,14 @@ import {
|
||||
type ShippingMyTodosCount,
|
||||
} from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { useShippingTodoBadge } from '../composables/useShippingTodoBadge';
|
||||
import {
|
||||
IN_PROGRESS_PROCESSING_STATUSES,
|
||||
TERMINAL_PROCESSING_STATUSES,
|
||||
} from '@/features/chat/shipping/shippingProcessingFulfillment';
|
||||
import {
|
||||
IN_PROGRESS_PROCESS,
|
||||
isShippingTodoListItemInProgress,
|
||||
} from './shippingTaskCenterPolling';
|
||||
import ShippingTaskWorkbench from './ShippingTaskWorkbench.vue';
|
||||
import ShippingRunProgressTable from './ShippingRunProgressTable.vue';
|
||||
|
||||
@@ -30,33 +39,29 @@ 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',
|
||||
]);
|
||||
/**
|
||||
* 判断详情是否仍处于进行中。
|
||||
* 核心逻辑:与列表同源——优先 shipping_processing_status;缺失时回退 process_status;
|
||||
* 不回退 WorkflowItem lifecycle(UI-03)。
|
||||
*/
|
||||
function isDetailInProgress(task: ShippingTaskDetail | null): boolean {
|
||||
if (!task) return false;
|
||||
const unified = String(task.shipping_processing_status || '').trim().toLowerCase();
|
||||
if (unified) {
|
||||
if (TERMINAL_PROCESSING_STATUSES.has(unified)) return false;
|
||||
return IN_PROGRESS_PROCESSING_STATUSES.has(unified);
|
||||
}
|
||||
const process = String(task.process_status || '').trim();
|
||||
return IN_PROGRESS_PROCESS.has(process);
|
||||
}
|
||||
|
||||
/** 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',
|
||||
]);
|
||||
/**
|
||||
* 判断列表项是否应触发轮询刷新。
|
||||
* 核心逻辑:委托 isShippingTodoListItemInProgress(Intake created/queued/parsing 必须轮询)。
|
||||
*/
|
||||
function isListItemInProgress(item: ShippingTaskSummary): boolean {
|
||||
return isShippingTodoListItemInProgress(item);
|
||||
}
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@@ -104,49 +109,43 @@ const selectedItem = computed(() =>
|
||||
);
|
||||
const isReviewSelection = computed(() => selectedItem.value?.item_kind === 'review_case'
|
||||
|| Boolean(selectedItem.value?.review_run_no && !selectedItem.value?.task_no));
|
||||
const isIntakeSelection = computed(() => selectedItem.value?.item_kind === 'order_intake'
|
||||
|| Boolean(selectedItem.value?.intake_no && !selectedItem.value?.task_no && !selectedItem.value?.review_run_no));
|
||||
|
||||
/**
|
||||
* 待办列表项稳定主键:复核用 case_no,任务用 task_no。
|
||||
* 待办列表项稳定主键:复核用 case_no,Intake 用 intake_no,任务用 task_no。
|
||||
*/
|
||||
function todoItemKey(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.todo_ref || item.review_case_no || item.review_run_no || '');
|
||||
}
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.todo_ref || item.intake_no || '');
|
||||
}
|
||||
return String(item.todo_ref || item.task_no || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表展示编号:复核显示 case_no,任务显示 SN。
|
||||
* 列表展示编号:复核显示 case_no,Intake 显示 intake_no,任务显示 SN。
|
||||
*/
|
||||
function todoDisplayNo(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.review_case_no || item.review_run_no || item.todo_ref || '—');
|
||||
}
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.intake_no || item.todo_ref || '—');
|
||||
}
|
||||
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 面。
|
||||
* 是否应继续自动轮询:processing 桶、进行中详情,或 runs 面;列表项按统一投影 / process_status。
|
||||
*/
|
||||
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';
|
||||
});
|
||||
return tasks.value.some((item) => isListItemInProgress(item));
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -335,6 +334,20 @@ function openReview(item: ShippingTaskSummary) {
|
||||
void router.push({ path: `/chat/${agentId}`, query });
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开对话「本次处理中」卡,聚焦未建 OT 的 Intake 材料。
|
||||
*/
|
||||
function openIntakeConversation(item: ShippingTaskSummary) {
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
|
||||
if (!agentId) return;
|
||||
const query: Record<string, string> = {};
|
||||
const cid = String(item.conversation_id || '').trim();
|
||||
if (cid) query.conversation_id = cid;
|
||||
const intakeNo = String(item.intake_no || item.todo_ref || '').trim();
|
||||
if (intakeNo) query.intake_no = intakeNo;
|
||||
void router.push({ path: `/chat/${agentId}`, query });
|
||||
}
|
||||
|
||||
/**
|
||||
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
|
||||
*/
|
||||
@@ -356,10 +369,17 @@ async function selectTodo(item: ShippingTaskSummary) {
|
||||
const nextQuery: Record<string, string> = { ...route.query as Record<string, string> };
|
||||
if (item.item_kind === 'review_case' || item.review_run_no) {
|
||||
delete nextQuery.task_no;
|
||||
delete nextQuery.intake_no;
|
||||
if (item.review_run_no) nextQuery.run_no = String(item.review_run_no);
|
||||
detail.value = null;
|
||||
} else if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
delete nextQuery.task_no;
|
||||
delete nextQuery.run_no;
|
||||
if (item.intake_no) nextQuery.intake_no = String(item.intake_no);
|
||||
detail.value = null;
|
||||
} else if (item.task_no) {
|
||||
delete nextQuery.run_no;
|
||||
delete nextQuery.intake_no;
|
||||
nextQuery.task_no = item.task_no;
|
||||
await loadDetail(item.task_no);
|
||||
}
|
||||
@@ -386,7 +406,12 @@ watch(selectedItem, (item) => {
|
||||
detail.value = null;
|
||||
return;
|
||||
}
|
||||
if (item.item_kind === 'review_case' || (item.review_run_no && !item.task_no)) {
|
||||
if (
|
||||
item.item_kind === 'review_case'
|
||||
|| item.item_kind === 'order_intake'
|
||||
|| (item.review_run_no && !item.task_no)
|
||||
|| (item.intake_no && !item.task_no)
|
||||
) {
|
||||
detail.value = null;
|
||||
return;
|
||||
}
|
||||
@@ -512,6 +537,7 @@ onBeforeUnmount(() => {
|
||||
<option value="review">{{ $t('workspace.shippingNotice.myTodos.filters.review') }}</option>
|
||||
<option value="exception">{{ $t('workspace.shippingNotice.myTodos.filters.exception') }}</option>
|
||||
<option value="manual_upload">{{ $t('workspace.shippingNotice.myTodos.filters.manualUpload') }}</option>
|
||||
<option value="intake_parse">{{ $t('workspace.shippingNotice.myTodos.filters.intakeParse') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1 flex-1 min-w-[10rem]">
|
||||
@@ -578,6 +604,12 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.todo_category === 'intake_parse' || item.item_kind === 'order_intake'"
|
||||
class="rounded-full bg-violet-50 px-2 py-0.5 text-[10px] text-violet-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.can_handle === false"
|
||||
class="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600"
|
||||
@@ -636,6 +668,30 @@ onBeforeUnmount(() => {
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="isIntakeSelection && selectedItem"
|
||||
class="space-y-4 rounded-2xl border border-default bg-surface p-6"
|
||||
data-testid="my-todos-intake-selection"
|
||||
>
|
||||
<div class="font-mono text-lg font-bold text-primary">{{ todoDisplayNo(selectedItem) }}</div>
|
||||
<p class="text-sm text-secondary">
|
||||
{{ selectedItem.ui_state?.summary?.message || selectedItem.ui_state?.summary?.current_todo }}
|
||||
</p>
|
||||
<p v-if="selectedItem.source_file_name" class="text-xs text-muted">
|
||||
{{ selectedItem.source_file_name }}
|
||||
<span v-if="selectedItem.intake_parse_status"> · {{ selectedItem.intake_parse_status }}</span>
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!(selectedItem.owner_agent_id || chatAgentId)"
|
||||
data-testid="my-todos-open-intake-conversation"
|
||||
@click="openIntakeConversation(selectedItem)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openConversation') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="detailLoading" class="rounded-2xl border border-dashed border-default py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskWorkbench.vue
|
||||
* 用途:发货任务处理主区——当前待办栏、统一节点、最后活动/终止原因、STP 事实、订单概览、时间线。
|
||||
* 依赖:TaskTodoPanel、StpProgressFactsPanel、TaskProgressTimeline、ShippingTaskParsedResultCard、ShippingWorkflowStepper。
|
||||
* 逻辑:由 ShippingTaskCenterPage 选中任务后挂载;只消费后端 ui_state / workflow_item,不发明进度百分比。
|
||||
* 用途:发货任务处理主区——当前待办栏、统一 15 阶进度、最后活动/终止原因、STP 事实、订单概览、时间线。
|
||||
* 依赖:TaskTodoPanel、StpProgressFactsPanel、TaskProgressTimeline、ShippingTaskParsedResultCard、
|
||||
* useShippingProcessingWorkItem、UnifiedProgressTrack、listWorkspaceShippingTaskAuditTimeline。
|
||||
* 逻辑:由 ShippingTaskCenterPage 选中任务后挂载;OT 身份取 detail.order_task_no(禁止 WorkflowItem);
|
||||
* 进度仅来自 ShippingProcessingProjection;时间线仅消费统一 ShippingAuditEvent。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref, watch } 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 {
|
||||
resolveShippingProcessingStatusLabel,
|
||||
shippingProcessingStageKey,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { useShippingProcessingWorkItem } from '@/features/chat/shipping/useShippingProcessingWorkItem';
|
||||
import type { ShippingTaskAuditTimelineItem, ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
|
||||
import { listWorkspaceShippingTaskAuditTimeline } from '@/features/chat/api/shipping.api';
|
||||
import UnifiedProgressTrack from '@/features/shipping-progress/components/UnifiedProgressTrack.vue';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import TaskTodoPanel from './TaskTodoPanel.vue';
|
||||
import StpProgressFactsPanel from './StpProgressFactsPanel.vue';
|
||||
@@ -31,27 +38,62 @@ const emit = defineEmits<{
|
||||
const { t, te } = useI18n();
|
||||
const msg = useMessage();
|
||||
|
||||
const workflowSteps = computed(() => resolveShippingWorkflowSteps(props.detail));
|
||||
const shortageLines = computed(() => props.detail.shortage?.lines || []);
|
||||
const hasMatchCard = computed(() =>
|
||||
(Array.isArray(props.detail.line_results) && props.detail.line_results.length > 0)
|
||||
|| 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 auditTimelineItems = ref<ShippingTaskAuditTimelineItem[]>([]);
|
||||
const auditTimelineLoading = ref(false);
|
||||
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(() => {
|
||||
const code = String(workflowItem.value?.closed_reason || '').trim();
|
||||
if (!code) return null;
|
||||
const key = `workspace.shippingNotice.workflowReasons.${code}`;
|
||||
return te(key) ? t(key) : t('workspace.shippingNotice.timeline.updated');
|
||||
});
|
||||
const hasExcelArtifact = computed(() =>
|
||||
Array.isArray(props.detail.export_artifacts) && props.detail.export_artifacts.length > 0,
|
||||
);
|
||||
|
||||
/**
|
||||
* 权威 OT:任务中心 enrich 写入的 order_task_no(UI-02 / BE-02)。
|
||||
* 禁止再从已下线的 workflow_item 读取。
|
||||
*/
|
||||
const authoritativeOrderTaskNo = computed(() => {
|
||||
const fromDetail = String(props.detail.order_task_no || '').trim();
|
||||
return fromDetail || null;
|
||||
});
|
||||
|
||||
const { projection: shippingProcessingProjection } = useShippingProcessingWorkItem(
|
||||
'order_task',
|
||||
authoritativeOrderTaskNo,
|
||||
{
|
||||
enabled: computed(() => Boolean(authoritativeOrderTaskNo.value)),
|
||||
},
|
||||
);
|
||||
|
||||
/** 最后活动:统一投影优先,否则 Notice.updated_at。 */
|
||||
const lastActivityAt = computed(() =>
|
||||
shippingProcessingProjection.value?.lastActivityAt
|
||||
|| props.detail.updated_at
|
||||
|| null,
|
||||
);
|
||||
const terminateReason = computed(() => {
|
||||
const code = String(
|
||||
shippingProcessingProjection.value?.currentGate?.blockingReasonCode || '',
|
||||
).trim();
|
||||
if (!code) return null;
|
||||
const key = `workspace.shippingNotice.workflowReasons.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
});
|
||||
|
||||
/** 统一投影是否可用。 */
|
||||
const hasFulfillmentProjection = computed(() => Boolean(shippingProcessingProjection.value));
|
||||
|
||||
const unifiedProcessingLabel = computed(() => {
|
||||
const projection = shippingProcessingProjection.value;
|
||||
if (!projection) return '';
|
||||
const status = resolveShippingProcessingStatusLabel(projection.status, te, t);
|
||||
const stageKey = shippingProcessingStageKey(projection.stage);
|
||||
const stage = te(stageKey) ? t(stageKey) : projection.stage;
|
||||
return [status, stage].filter(Boolean).join(' · ');
|
||||
});
|
||||
|
||||
/** 将内部状态映射为业务文案,未知值不回显原始状态码。 */
|
||||
function workflowStatusLabel(value: unknown): string {
|
||||
const code = String(value || '').trim();
|
||||
@@ -68,6 +110,38 @@ const taskMatchStatusLabel = computed(() => {
|
||||
return te(key) ? t(key) : t('workspace.shippingNotice.matchStatus.unknown');
|
||||
});
|
||||
|
||||
/**
|
||||
* 拉取任务统一审计时间线(ShippingAuditEvent 单源)。
|
||||
*/
|
||||
async function loadAuditTimeline(taskNo: string) {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) {
|
||||
auditTimelineItems.value = [];
|
||||
return;
|
||||
}
|
||||
auditTimelineLoading.value = true;
|
||||
try {
|
||||
const result = await listWorkspaceShippingTaskAuditTimeline(normalized, {
|
||||
page: 1,
|
||||
page_size: 100,
|
||||
});
|
||||
auditTimelineItems.value = result.items || [];
|
||||
} catch (e: unknown) {
|
||||
auditTimelineItems.value = [];
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.timeline.loadFailed'));
|
||||
} finally {
|
||||
auditTimelineLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [props.detail.task_no, props.detail.updated_at] as const,
|
||||
([taskNo]) => {
|
||||
void loadAuditTimeline(taskNo);
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 下载已生成的发货 Excel。
|
||||
*/
|
||||
@@ -93,7 +167,25 @@ async function downloadExcel() {
|
||||
<div class="mb-3 text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.workflow') }}
|
||||
</div>
|
||||
<ShippingWorkflowStepper :steps="workflowSteps" />
|
||||
<p
|
||||
v-if="unifiedProcessingLabel"
|
||||
class="mb-2 text-xs text-secondary"
|
||||
data-testid="task-shipping-processing-summary"
|
||||
>
|
||||
{{ unifiedProcessingLabel }}
|
||||
</p>
|
||||
<p
|
||||
v-else-if="!hasFulfillmentProjection"
|
||||
class="mb-2 text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="task-workbench-progress-unavailable"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.todo.progressUnavailable') }}
|
||||
</p>
|
||||
<UnifiedProgressTrack
|
||||
v-if="shippingProcessingProjection"
|
||||
:projection="shippingProcessingProjection"
|
||||
density="workbench"
|
||||
/>
|
||||
<dl class="mt-3 grid gap-2 text-xs sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.todo.lastActivity') }}</dt>
|
||||
@@ -103,12 +195,6 @@ async function downloadExcel() {
|
||||
<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="text-secondary">
|
||||
{{ workflowStatusLabel(workflowItem.lifecycle_status) }} · {{ workflowStatusLabel(workflowItem.current_stage) }}
|
||||
</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div v-if="hasExcelArtifact" class="mt-3">
|
||||
<button
|
||||
@@ -173,6 +259,9 @@ async function downloadExcel() {
|
||||
:action-busy="false"
|
||||
/>
|
||||
|
||||
<TaskProgressTimeline :events="events" :workflow-events="workflowEvents" />
|
||||
<TaskProgressTimeline
|
||||
:items="auditTimelineItems"
|
||||
:loading="auditTimelineLoading"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/TaskProgressTimeline.spec.ts
|
||||
* 用途:锁定任务中心时间线同时消费 Task Event 与 Workflow Event。
|
||||
* 用途:锁定任务中心时间线仅消费统一 ShippingAuditEvent 条目。
|
||||
* 依赖:Vitest、@vue/test-utils、TaskProgressTimeline。
|
||||
* 逻辑:合并排序后两类事件均可见;未知内部码、操作人 ID 与 JSON 详情不展示。
|
||||
* 逻辑:渲染 auditItems;未知内部码与敏感字段不直出;空态与 loading 态可区分。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
@@ -15,14 +15,14 @@ const messages = {
|
||||
shippingNotice: {
|
||||
events: '事件时间线',
|
||||
operator: '操作者 {id}',
|
||||
eventTypes: { system: '系统', task_created: '任务已创建' },
|
||||
workflowEvents: { stage_changed: '阶段变更', upload_manual_confirmed: '人工上传已登记' },
|
||||
auditTimeline: {
|
||||
events: { task_created: '任务已创建' },
|
||||
},
|
||||
eventTypes: { system: '系统' },
|
||||
timeline: {
|
||||
empty: '暂无事件记录',
|
||||
detail: '查看详情',
|
||||
sourceTask: '任务事件',
|
||||
sourceWorkflow: '文件处理记录',
|
||||
workflowEvent: '文件处理记录',
|
||||
loading: '加载中…',
|
||||
sourceAudit: '审计记录',
|
||||
updated: '处理状态已更新',
|
||||
actors: { user: '业务人员', system: '系统' },
|
||||
},
|
||||
@@ -32,61 +32,54 @@ const messages = {
|
||||
};
|
||||
|
||||
describe('TaskProgressTimeline', () => {
|
||||
it('merges task and workflow events and shows workflow actor type/id', () => {
|
||||
it('renders unified audit items with actor display and source badge', () => {
|
||||
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: [
|
||||
items: [
|
||||
{
|
||||
seq_no: 1,
|
||||
event_code: 'upload_manual_confirmed',
|
||||
actor_type: 'user',
|
||||
actor_id: '42',
|
||||
occurred_at: '2026-07-31T01:01:00Z',
|
||||
id: 1,
|
||||
event_type: 'task_created',
|
||||
actor_display: '业务人员',
|
||||
created_at: '2026-07-31T01:00:00Z',
|
||||
reason: '任务创建成功',
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
event_type: 'upload_rpa_triggered',
|
||||
actor_type: 'system',
|
||||
created_at: '2026-07-31T01:01:00Z',
|
||||
},
|
||||
],
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
// 关键断言:时间线同时展示 Task 与 Workflow 事件来源标签,且 Workflow 显示操作人。
|
||||
expect(wrapper.text()).toContain('任务事件');
|
||||
expect(wrapper.text()).toContain('文件处理记录');
|
||||
// 关键断言:统一审计来源标签与本地化事件文案可见。
|
||||
expect(wrapper.text()).toContain('审计记录');
|
||||
expect(wrapper.text()).toContain('任务已创建');
|
||||
expect(wrapper.text()).toContain('人工上传已登记');
|
||||
expect(wrapper.text()).toContain('处理状态已更新');
|
||||
expect(wrapper.text()).toContain('操作者 业务人员');
|
||||
expect(wrapper.text()).not.toContain('user/42');
|
||||
expect(wrapper.text()).not.toContain('操作者 1');
|
||||
expect(wrapper.text()).toContain('操作者 系统');
|
||||
expect(wrapper.text()).toContain('任务创建成功');
|
||||
expect(wrapper.text()).not.toContain('upload_rpa_triggered');
|
||||
});
|
||||
|
||||
it('does not expose unknown event codes or raw detail JSON', () => {
|
||||
it('shows empty state when no audit items', () => {
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
|
||||
const wrapper = mount(TaskProgressTimeline, {
|
||||
props: {
|
||||
events: [{
|
||||
event_type: 'internal_task_event',
|
||||
actor_id: 99,
|
||||
detail_json: { node_id: 'node-1', error: 'HTTP 500' },
|
||||
}],
|
||||
workflowEvents: [{
|
||||
seq_no: 2,
|
||||
event_code: 'internal_workflow_event',
|
||||
actor_type: 'worker',
|
||||
actor_id: 'worker-7',
|
||||
payload: { gate_code: 'quality_gate_internal' },
|
||||
}],
|
||||
},
|
||||
props: { items: [] },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
const text = wrapper.text();
|
||||
expect(text).toContain('处理状态已更新');
|
||||
for (const technicalText of [
|
||||
'internal_task_event', 'internal_workflow_event', 'node_id', 'HTTP 500',
|
||||
'gate_code', 'quality_gate_internal', 'worker-7',
|
||||
]) {
|
||||
expect(text).not.toContain(technicalText);
|
||||
}
|
||||
expect(wrapper.text()).toContain('暂无事件记录');
|
||||
});
|
||||
|
||||
it('shows loading placeholder before items arrive', () => {
|
||||
const i18n = createI18n({ legacy: false, locale: 'zh-CN', messages });
|
||||
const wrapper = mount(TaskProgressTimeline, {
|
||||
props: { items: [], loading: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.text()).toContain('加载中…');
|
||||
expect(wrapper.text()).not.toContain('暂无事件记录');
|
||||
});
|
||||
});
|
||||
@@ -1,19 +1,18 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/TaskProgressTimeline.vue
|
||||
* 用途:展示任务事件 + Workflow Event 统一时间线(只读),不发明进度百分比。
|
||||
* 依赖:ShippingTaskEvent、ShippingWorkflowEvent、dateTime、vue-i18n。
|
||||
* 逻辑:由 ShippingTaskWorkbench 传入 task events 与 workflow events;按时间合并排序;
|
||||
* 未知事件与操作者内部标识统一使用通用业务文案。
|
||||
* 用途:展示任务工作台统一 ShippingAuditEvent 时间线(只读),不发明进度百分比。
|
||||
* 依赖:ShippingTaskAuditTimelineItem、dateTime、vue-i18n。
|
||||
* 逻辑:由 ShippingTaskWorkbench 传入 auditItems;不再合并 TaskEvent / WorkflowEvent 双轨。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import type { ShippingTaskEvent, ShippingWorkflowEvent } from '@/features/chat/types/shipping.api.types';
|
||||
import type { ShippingTaskAuditTimelineItem } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
events: ShippingTaskEvent[];
|
||||
workflowEvents?: ShippingWorkflowEvent[];
|
||||
items: ShippingTaskAuditTimelineItem[];
|
||||
loading?: boolean;
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -23,64 +22,49 @@ type TimelineRow = {
|
||||
label: string;
|
||||
createdAt?: string | null;
|
||||
actor?: string | null;
|
||||
source: 'task' | 'workflow';
|
||||
reason?: string | null;
|
||||
};
|
||||
|
||||
/**
|
||||
* 将任务事件类型映射为可读文案;契约外码使用通用说明。
|
||||
* 将统一审计 event_type/action 映射为可读文案;契约外码使用通用说明。
|
||||
*/
|
||||
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) : t('workspace.shippingNotice.timeline.updated');
|
||||
function auditEventLabel(item: ShippingTaskAuditTimelineItem): string {
|
||||
const eventType = String(item.event_type || item.action || '').trim();
|
||||
const auditKey = `workspace.shippingNotice.auditTimeline.events.${eventType}`;
|
||||
if (eventType && te(auditKey)) return t(auditKey);
|
||||
const legacyKey = `workspace.shippingNotice.eventTypes.${eventType}`;
|
||||
if (eventType && te(legacyKey)) return t(legacyKey);
|
||||
return t('workspace.shippingNotice.timeline.updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* 将 Workflow Event 码映射为可读文案。
|
||||
* 格式化操作人展示:优先 actor_display,其次 actor_type 映射。
|
||||
*/
|
||||
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) : t('workspace.shippingNotice.timeline.updated');
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化操作人展示:普通工作台只显示业务角色,不展示内部 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();
|
||||
function formatActorLabel(item: ShippingTaskAuditTimelineItem): string | null {
|
||||
const display = String(item.actor_display || '').trim();
|
||||
if (display) return display;
|
||||
const type = String(item.actor_type || '').trim();
|
||||
const roleKey = `workspace.shippingNotice.timeline.actors.${type}`;
|
||||
if (type && te(roleKey)) return t(roleKey);
|
||||
if (type || id) return t('workspace.shippingNotice.timeline.actors.user');
|
||||
if (type) return t('workspace.shippingNotice.timeline.actors.user');
|
||||
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),
|
||||
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),
|
||||
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;
|
||||
});
|
||||
});
|
||||
const rows = computed<TimelineRow[]>(() =>
|
||||
(props.items || [])
|
||||
.map((item, index) => ({
|
||||
key: `audit-${item.id ?? index}`,
|
||||
label: auditEventLabel(item),
|
||||
createdAt: item.created_at,
|
||||
actor: formatActorLabel(item),
|
||||
reason: String(item.reason || '').trim() || null,
|
||||
}))
|
||||
.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>
|
||||
@@ -88,7 +72,10 @@ const rows = computed<TimelineRow[]>(() => {
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">
|
||||
{{ $t('workspace.shippingNotice.events') }}
|
||||
</h3>
|
||||
<div v-if="!rows.length" class="py-4 text-center text-xs text-muted">
|
||||
<div v-if="loading && !rows.length" class="py-4 text-center text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.timeline.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!rows.length" class="py-4 text-center text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.timeline.empty') }}
|
||||
</div>
|
||||
<div
|
||||
@@ -98,17 +85,13 @@ const rows = computed<TimelineRow[]>(() => {
|
||||
>
|
||||
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
|
||||
<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 class="rounded bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-600">
|
||||
{{ $t('workspace.shippingNotice.timeline.sourceAudit') }}
|
||||
</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>
|
||||
<p v-if="row.reason" class="mt-1 text-[11px] text-muted">{{ row.reason }}</p>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -2,10 +2,8 @@
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.vue
|
||||
* 用途:渲染统一 Gate 恢复卡片与 STP 履约待办动作(ui_state.action_buttons)。
|
||||
* 依赖:ProcessGateRecoveryCard、shipping.api、shipping-tasks.api、ManualUploadEvidenceDialog。
|
||||
* 逻辑:优先展示 ui_state.process_gate 阻断信息与 next_action_code;禁止按 process_status
|
||||
* 二次推导门禁动作;存在 current_blocking_gate 时不渲染旧 action_buttons(Gate 唯一真相);
|
||||
* confirm_customer 打开本面板客户弹窗(非跳转复核);管理员 can_handle=false 时只读;
|
||||
* 无 Gate 阻断时 wait_manual_upload 允许下载 Excel + 人工上传凭据。
|
||||
* 逻辑:优先展示 ui_state.process_gate 阻断信息与 next_action_code;禁止按 workflow_item.lifecycle
|
||||
* 或 process_status 推断人工上传;存在 current_blocking_gate 时不渲染旧 action_buttons。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -35,6 +33,7 @@ import InventorySourceSelectDialog from './InventorySourceSelectDialog.vue';
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import type { ShippingProcessGateUserSummary } from '@/features/chat/types/shipping.api.types';
|
||||
import { gateSummaryIndicatesManualUpload } from '@/features/chat/shipping/shippingProcessingFulfillment';
|
||||
|
||||
const props = defineProps<{
|
||||
detail: ShippingTaskDetail;
|
||||
@@ -66,7 +65,6 @@ const processGateSummary = computed((): ShippingProcessGateUserSummary | null =>
|
||||
);
|
||||
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 || ''));
|
||||
/** 统一 Gate 投影中的主要恢复动作;用于去重旧 action_buttons。 */
|
||||
const processGateNextAction = computed(() =>
|
||||
String(
|
||||
@@ -90,17 +88,27 @@ const displayTodoMessage = computed(() =>
|
||||
|
||||
/**
|
||||
* 是否展示「待人工上传登记」提示。
|
||||
* 核心逻辑:wait_manual_upload,或 export_ready/export_generated 且已有导出文件名/工件。
|
||||
* 核心逻辑:优先 process_gate / current_blocking_gate 的 next_action_code 与
|
||||
* available_actions;RPA 上传中不展示;禁止用 workflow_item.lifecycle 作主判据。
|
||||
*/
|
||||
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;
|
||||
const process = String(props.detail.process_status || '').trim();
|
||||
if (process === 'uploading') return false;
|
||||
const gateNextAction = String(
|
||||
processGateSummary.value?.current_blocking_gate?.next_action_code
|
||||
|| processGateSummary.value?.next_action_code
|
||||
|| processGateNextAction.value
|
||||
|| '',
|
||||
).trim();
|
||||
const allowedActions = [
|
||||
...(summary.value.allowed_actions || []),
|
||||
...(actionButtons.value.map((item) => item.id)),
|
||||
];
|
||||
return gateSummaryIndicatesManualUpload({
|
||||
nextActionCode: gateNextAction,
|
||||
checkpointKind: checkpointKind.value,
|
||||
availableActions: allowedActions,
|
||||
});
|
||||
});
|
||||
|
||||
/** 当前导出工件 id,供人工上传登记对话框绑定。 */
|
||||
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/shippingTaskCenterPolling.spec.ts
|
||||
* 用途:验收任务中心 Intake / Review / OT 轮询边界(UI-01 / UI-02)。
|
||||
* 依赖:isShippingTodoListItemInProgress、ShippingTaskSummary。
|
||||
* 逻辑:parsing Intake 轮询;parse_failed 停止;Intake→OT 后按投影状态决定。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import type { ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import { isShippingTodoListItemInProgress } from './shippingTaskCenterPolling';
|
||||
|
||||
function intakeItem(status: string): ShippingTaskSummary {
|
||||
return {
|
||||
item_kind: 'order_intake',
|
||||
todo_ref: 'SNI-1',
|
||||
intake_no: 'SNI-1',
|
||||
intake_parse_status: status,
|
||||
process_status: status,
|
||||
todo_category: 'intake_parse',
|
||||
} as ShippingTaskSummary;
|
||||
}
|
||||
|
||||
describe('isShippingTodoListItemInProgress', () => {
|
||||
it('polls created/queued/parsing intake items', () => {
|
||||
// 关键断言:解析中 Intake 必须持续轮询,避免任务中心卡在旧状态。
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('created'))).toBe(true);
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('queued'))).toBe(true);
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('parsing'))).toBe(true);
|
||||
});
|
||||
|
||||
it('stops polling parse_failed intake items', () => {
|
||||
expect(isShippingTodoListItemInProgress(intakeItem('parse_failed'))).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps polling open review cases', () => {
|
||||
expect(
|
||||
isShippingTodoListItemInProgress({
|
||||
item_kind: 'review_case',
|
||||
review_case_no: 'SNRC-1',
|
||||
review_run_no: 'SNER-1',
|
||||
} as ShippingTaskSummary),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('after intake becomes OT, uses shipping_processing_status', () => {
|
||||
// Intake 消失后由 OT 卡承接:waiting_review 继续轮询,completed 停止。
|
||||
expect(
|
||||
isShippingTodoListItemInProgress({
|
||||
item_kind: 'task',
|
||||
task_no: 'OT-1',
|
||||
shipping_processing_status: 'waiting_review',
|
||||
} as ShippingTaskSummary),
|
||||
).toBe(true);
|
||||
expect(
|
||||
isShippingTodoListItemInProgress({
|
||||
item_kind: 'task',
|
||||
task_no: 'OT-1',
|
||||
shipping_processing_status: 'completed',
|
||||
} as ShippingTaskSummary),
|
||||
).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/shippingTaskCenterPolling.ts
|
||||
* 用途:任务中心列表项是否仍需前台轮询(纯函数,供页面与单测共用)。
|
||||
* 依赖:ShippingTaskSummary、shippingProcessingFulfillment 状态集合。
|
||||
* 逻辑:ShippingTaskCenterPage 用本函数决定 poll;Intake created/queued/parsing 必须轮询,
|
||||
* parse_failed 停止;review_case 持续轮询;OT/Notice 走统一投影状态。
|
||||
*/
|
||||
|
||||
import type { ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
IN_PROGRESS_PROCESSING_STATUSES,
|
||||
TERMINAL_PROCESSING_STATUSES,
|
||||
} from '@/features/chat/shipping/shippingProcessingFulfillment';
|
||||
|
||||
/** 仍视为进行中、需要自动刷新的任务 process_status(列表项无统一投影时的 notice 任务兜底)。 */
|
||||
export const IN_PROGRESS_PROCESS = new Set([
|
||||
'parsing',
|
||||
'parsed',
|
||||
'matching',
|
||||
'matched',
|
||||
'waiting_upload',
|
||||
'uploading',
|
||||
'upload_failed',
|
||||
'exporting',
|
||||
'needs_human',
|
||||
'pending_void',
|
||||
]);
|
||||
|
||||
/** Intake 仍在解析、必须轮询的状态。 */
|
||||
export const INTAKE_POLLING_PARSE_STATUSES = new Set([
|
||||
'created',
|
||||
'queued',
|
||||
'parsing',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 判断列表项是否应触发轮询刷新。
|
||||
* 核心逻辑:review_case 持续轮询;order_intake 仅 created/queued/parsing;
|
||||
* 其余优先 shipping_processing_status,缺省回退 process_status;
|
||||
* 不复用 WorkflowItem lifecycle。
|
||||
* @param item - 我的待办列表项
|
||||
* @returns 是否需要继续轮询
|
||||
*/
|
||||
export function isShippingTodoListItemInProgress(item: ShippingTaskSummary): boolean {
|
||||
if (item.item_kind === 'review_case' || (item.review_run_no && !item.task_no)) {
|
||||
return true;
|
||||
}
|
||||
if (item.item_kind === 'order_intake') {
|
||||
const intakeStatus = String(
|
||||
item.intake_parse_status || item.process_status || '',
|
||||
).trim().toLowerCase();
|
||||
return INTAKE_POLLING_PARSE_STATUSES.has(intakeStatus);
|
||||
}
|
||||
const unified = String(item.shipping_processing_status || '').trim().toLowerCase();
|
||||
if (unified) {
|
||||
if (TERMINAL_PROCESSING_STATUSES.has(unified)) return false;
|
||||
return IN_PROGRESS_PROCESSING_STATUSES.has(unified);
|
||||
}
|
||||
const process = String(item.process_status || '').trim();
|
||||
return IN_PROGRESS_PROCESS.has(process);
|
||||
}
|
||||
@@ -1,651 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/views/ShippingNoticeView.vue
|
||||
* 用途:遗留货代任务列表视图;主写入口已迁至 shipping-task-center 工作台。
|
||||
* 依赖:ShippingWorkflowStepper、ShippingMatchResultCard、ShippingTaskParsedResultCard、shipping.api。
|
||||
* 逻辑:保留只读审计浏览;履约写操作请使用 ShippingTaskCenterPage / ShippingTaskWorkbench。
|
||||
* 用途:遗留货代任务列表入口;重定向到统一任务中心,禁止再维护独立 Stepper 进度。
|
||||
* 依赖:vue-router。
|
||||
* 逻辑:挂载即 replace 到 workspace-shipping-my-tasks;保留 query.task_no。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, ExternalLink, RefreshCw } from 'lucide-vue-next';
|
||||
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 { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import {
|
||||
getWorkspaceShippingTask,
|
||||
listShippingChatAgents,
|
||||
listWorkspaceShippingTasks,
|
||||
SHIPPING_NOTICE_AGENT_CODE,
|
||||
type ShippingCurrentStepProgress,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { resolveShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import { sanitizeShippingRuntimeStatusText } from '@/features/chat/shipping/shippingText';
|
||||
import { SHIPPING_TASK_STATUS_FILTERS } from '../shippingTaskStatuses';
|
||||
|
||||
const props = defineProps<{
|
||||
embedded?: boolean;
|
||||
}>();
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { t, te } = useI18n();
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const tasks = ref<ShippingTaskSummary[]>([]);
|
||||
const selectedTaskNo = ref<string | null>(null);
|
||||
const detail = ref<ShippingTaskDetail | null>(null);
|
||||
const statusFilter = ref('all');
|
||||
const lifecycleFilter = ref('active');
|
||||
const chatAgentId = ref<number | null>(null);
|
||||
const currentPage = ref(1);
|
||||
const pageSize = 10;
|
||||
const totalTasks = ref(0);
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)));
|
||||
const pageStart = computed(() => (totalTasks.value === 0 ? 0 : (currentPage.value - 1) * pageSize + 1));
|
||||
const pageEnd = computed(() => Math.min(currentPage.value * pageSize, totalTasks.value));
|
||||
const batchProgressLabel = computed(() => {
|
||||
if (!detail.value?.batch_index || !detail.value?.batch_total) return '';
|
||||
return t('chat.shippingNoticeUi.batchProgress', {
|
||||
index: detail.value.batch_index,
|
||||
total: detail.value.batch_total,
|
||||
});
|
||||
});
|
||||
|
||||
const statusOptions = computed(() => [
|
||||
{ value: 'all', label: t('workspace.shippingNotice.status.all') },
|
||||
...SHIPPING_TASK_STATUS_FILTERS.map(([value, labelKey]) => ({
|
||||
value,
|
||||
label: t(`workspace.shippingNotice.status.${labelKey}`),
|
||||
})),
|
||||
]);
|
||||
const lifecycleOptions = computed(() => [
|
||||
{ value: 'active', label: t('workspace.shippingNotice.lifecycle.active') },
|
||||
{ value: 'deleted', label: t('workspace.shippingNotice.lifecycle.deleted') },
|
||||
{ value: 'voided', label: t('workspace.shippingNotice.lifecycle.voided') },
|
||||
{ value: 'archived', label: t('workspace.shippingNotice.lifecycle.archived') },
|
||||
]);
|
||||
|
||||
type ShippingStatusSource = Pick<
|
||||
ShippingTaskSummary,
|
||||
'process_status' | 'review_status' | 'pending_human_reason' | 'match_status'
|
||||
>;
|
||||
|
||||
const displayStatusCode = (source: ShippingStatusSource | string) => {
|
||||
if (typeof source === 'string') return source;
|
||||
const reason = String(source.pending_human_reason || '').trim();
|
||||
const reviewStatus = String(source.review_status || '').trim();
|
||||
if (reason === 'shortage' || reason === 'shortage_review' || reviewStatus === 'shortage_review') return 'shortage_review';
|
||||
return String(source.process_status || '').trim();
|
||||
};
|
||||
|
||||
const statusBadge = (source: ShippingStatusSource | string) => {
|
||||
const status = displayStatusCode(source);
|
||||
const map: Record<string, { cls: string; label: string }> = {
|
||||
created: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.created') },
|
||||
parsed: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.shippingNotice.status.parsed') },
|
||||
pending_review: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.pendingReview') },
|
||||
shortage_review: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.shippingNotice.status.shortageReview') },
|
||||
waiting_inventory: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.waitingInventory') },
|
||||
inventory_ready: { cls: 'bg-blue-100 text-blue-700', label: t('workspace.shippingNotice.status.inventoryReady') },
|
||||
matched: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.shippingNotice.status.matched') },
|
||||
waiting_upload: { cls: 'bg-amber-100 text-amber-700', label: t('workspace.shippingNotice.status.waitingUpload') },
|
||||
uploaded: { cls: 'bg-emerald-100 text-emerald-700', label: t('workspace.shippingNotice.status.uploaded') },
|
||||
upload_failed: { cls: 'bg-rose-100 text-rose-700', label: t('workspace.shippingNotice.status.uploadFailed') },
|
||||
rejected: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.rejected') },
|
||||
closed: { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.closed') },
|
||||
};
|
||||
return map[status] || { cls: 'bg-slate-100 text-secondary', label: t('workspace.shippingNotice.status.unknown') };
|
||||
};
|
||||
|
||||
const matchStatusLabel = (status?: string | null) => {
|
||||
const key = String(status || '').trim();
|
||||
const map: Record<string, string> = {
|
||||
fulfillable: t('workspace.shippingNotice.matchStatus.fulfillable'),
|
||||
partial: t('workspace.shippingNotice.matchStatus.partial'),
|
||||
unfulfillable: t('workspace.shippingNotice.matchStatus.unfulfillable'),
|
||||
};
|
||||
return map[key] || (key ? t('workspace.shippingNotice.matchStatus.unknown') : '—');
|
||||
};
|
||||
|
||||
const eventLabel = (eventType: string) => {
|
||||
const normalized = String(eventType || '').trim().replace(/[^a-zA-Z0-9_]/g, '');
|
||||
const key = `workspace.shippingNotice.eventTypes.${normalized}`;
|
||||
return te(key) ? t(key) : t('workspace.shippingNotice.eventTypes.system');
|
||||
};
|
||||
|
||||
const detailWorkflowSteps = computed(() => (
|
||||
resolveShippingWorkflowSteps(detail.value)
|
||||
));
|
||||
const detailStepProgress = computed<ShippingCurrentStepProgress | null>(() => {
|
||||
const payload = detail.value?.step_payload;
|
||||
if (!payload || typeof payload !== 'object') return null;
|
||||
const progress = (payload as Record<string, unknown>).current_step_progress;
|
||||
return progress && typeof progress === 'object' ? progress as ShippingCurrentStepProgress : null;
|
||||
});
|
||||
const detailStepMessage = computed(() =>
|
||||
sanitizeShippingRuntimeStatusText(String(detailStepProgress.value?.message || '').trim()),
|
||||
);
|
||||
const detailStepDetail = computed(() =>
|
||||
sanitizeShippingRuntimeStatusText(String(detailStepProgress.value?.detail || '').trim()),
|
||||
);
|
||||
const detailErrorMessage = computed(() =>
|
||||
sanitizeShippingRuntimeStatusText(String(detail.value?.error_message || '').trim()),
|
||||
);
|
||||
const detailIssues = computed(() => (
|
||||
Array.isArray(detail.value?.ui_state?.summary?.issues)
|
||||
? detail.value.ui_state.summary.issues
|
||||
.map((item) => sanitizeShippingRuntimeStatusText(String(item || '').trim()))
|
||||
.filter(Boolean)
|
||||
: []
|
||||
));
|
||||
const detailTodoTitle = computed(() => (
|
||||
sanitizeShippingRuntimeStatusText(String(detail.value?.ui_state?.summary?.title || '').trim())
|
||||
|| t('workspace.shippingNotice.todo.noActionTitle')
|
||||
));
|
||||
const detailTodoMessage = computed(() => (
|
||||
sanitizeShippingRuntimeStatusText(String(detail.value?.ui_state?.summary?.message || '').trim())
|
||||
|| detailIssues.value[0]
|
||||
|| t('workspace.shippingNotice.todo.noActionMessage')
|
||||
));
|
||||
|
||||
const inventorySnapshotLabel = (triggerType?: string | null) => {
|
||||
const key = String(triggerType || 'on_demand');
|
||||
const map: Record<string, string> = {
|
||||
scheduled: t('workspace.shippingNotice.inventorySnapshot.sourceScheduled'),
|
||||
on_demand: t('workspace.shippingNotice.inventorySnapshot.sourceOnDemand'),
|
||||
manual_upload: t('workspace.shippingNotice.inventorySnapshot.sourceManual'),
|
||||
};
|
||||
return map[key] || map.on_demand;
|
||||
};
|
||||
|
||||
const inventorySourceStatusLabel = (status?: string | null) => {
|
||||
const key = String(status || '').trim();
|
||||
if (!key) return '—';
|
||||
const i18nKey = `workspace.shippingNotice.inventorySource.statusLabels.${key}`;
|
||||
return te(i18nKey) ? t(i18nKey) : key;
|
||||
};
|
||||
|
||||
const inventorySourceMethodLabel = (method?: string | null) => {
|
||||
const key = String(method || '').trim();
|
||||
if (!key) return '—';
|
||||
const i18nKey = `workspace.shippingNotice.inventorySource.methodLabels.${key}`;
|
||||
return te(i18nKey) ? t(i18nKey) : key;
|
||||
};
|
||||
|
||||
const hasInventorySourceFields = computed(() => {
|
||||
const item = detail.value;
|
||||
if (!item) return false;
|
||||
return !!(
|
||||
item.inventory_source_code
|
||||
|| item.inventory_warehouse_id
|
||||
|| item.inventory_source_status
|
||||
);
|
||||
});
|
||||
|
||||
/** 拉取当前筛选条件的一页任务;筛选/刷新时重置页码以避免落入空页。 */
|
||||
const loadCases = async (resetPage = false) => {
|
||||
if (resetPage) currentPage.value = 1;
|
||||
loading.value = true;
|
||||
try {
|
||||
let result = await listWorkspaceShippingTasks({
|
||||
process_status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
||||
lifecycle_status: lifecycleFilter.value,
|
||||
page: currentPage.value,
|
||||
page_size: pageSize,
|
||||
});
|
||||
// 删除当前页最后一条后可能出现空页;回退一页重新查询,避免显示误导性的空结果。
|
||||
if (result.items.length === 0 && result.total > 0 && currentPage.value > 1) {
|
||||
currentPage.value = Math.ceil(result.total / pageSize);
|
||||
result = await listWorkspaceShippingTasks({
|
||||
process_status: statusFilter.value === 'all' ? undefined : statusFilter.value,
|
||||
lifecycle_status: lifecycleFilter.value,
|
||||
page: currentPage.value,
|
||||
page_size: pageSize,
|
||||
});
|
||||
}
|
||||
tasks.value = result.items;
|
||||
totalTasks.value = result.total;
|
||||
selectedTaskNo.value = null;
|
||||
} catch {
|
||||
tasks.value = [];
|
||||
totalTasks.value = 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/** 切换页码并重新读取只读任务列表。 */
|
||||
const changePage = async (page: number) => {
|
||||
const normalized = Math.max(1, Math.min(page, totalPages.value));
|
||||
if (normalized === currentPage.value || loading.value) return;
|
||||
currentPage.value = normalized;
|
||||
await loadCases();
|
||||
};
|
||||
|
||||
const loadDetail = async (taskNo: string) => {
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
detail.value = await getWorkspaceShippingTask(taskNo);
|
||||
} catch {
|
||||
detail.value = null;
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
const resolveChatAgent = async () => {
|
||||
try {
|
||||
const agents = await listShippingChatAgents();
|
||||
const found = agents.find((a) => String(a.agent_code || '').trim() === SHIPPING_NOTICE_AGENT_CODE);
|
||||
if (found) chatAgentId.value = found.id;
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
|
||||
* 将遗留发货详情页重定向到任务中心(统一进度消费面)。
|
||||
*/
|
||||
const openInChat = (taskNo: string, conversationId?: string | null, batchNo?: string | null) => {
|
||||
if (!chatAgentId.value) return;
|
||||
const query: Record<string, string> = { task_id: taskNo };
|
||||
const normalizedBatchNo = String(batchNo || '').trim();
|
||||
if (normalizedBatchNo) query.batch_no = normalizedBatchNo;
|
||||
const cid = String(conversationId || '').trim();
|
||||
if (/^[0-9a-f]{32}$/i.test(cid)) query.conversation_id = cid;
|
||||
router.push({ path: `/chat/${chatAgentId.value}`, query });
|
||||
};
|
||||
|
||||
const shortageLines = computed(() => detail.value?.shortage?.lines || []);
|
||||
const hasMatchCard = computed(() =>
|
||||
!!detail.value && (
|
||||
(Array.isArray(detail.value.line_results) && detail.value.line_results.length > 0)
|
||||
|| shortageLines.value.length > 0
|
||||
),
|
||||
);
|
||||
|
||||
watch(selectedTaskNo, (val) => {
|
||||
if (val) loadDetail(val);
|
||||
else detail.value = null;
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([loadCases(), resolveChatAgent()]);
|
||||
onMounted(() => {
|
||||
const taskNo = String(route.query.task_no || route.params.taskNo || '').trim();
|
||||
void router.replace({
|
||||
name: 'workspace-shipping-my-tasks',
|
||||
query: taskNo ? { task_no: taskNo } : undefined,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-5 animate-fade-in-up">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
v-if="!embedded"
|
||||
type="button"
|
||||
class="inline-flex h-9 w-9 items-center justify-center rounded-xl border border-default text-secondary hover:bg-surface-soft"
|
||||
@click="router.push('/workspace')"
|
||||
>
|
||||
<ArrowLeft class="h-4 w-4" />
|
||||
</button>
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-primary">{{ $t('workspace.shippingNotice.title') }}</h2>
|
||||
<p class="text-sm text-muted">{{ $t('workspace.shippingNotice.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<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 transition-colors hover:bg-surface-soft"
|
||||
@click="loadCases(true)"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default/80 bg-surface/70 px-4 py-3 shadow-sm">
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.filters.status') }}</label>
|
||||
<select v-model="statusFilter" class="rounded-xl border border-default bg-surface px-3 py-2 text-sm">
|
||||
<option v-for="opt in statusOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="mb-1 block text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.filters.lifecycle') }}</label>
|
||||
<select v-model="lifecycleFilter" class="rounded-xl border border-default bg-surface px-3 py-2 text-sm">
|
||||
<option v-for="opt in lifecycleOptions" :key="opt.value" :value="opt.value">{{ opt.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700"
|
||||
@click="loadCases(true)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.search') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,2.15fr)]">
|
||||
<div class="space-y-2">
|
||||
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="tasks.length === 0" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.empty') }}
|
||||
</div>
|
||||
<article
|
||||
v-for="item in tasks"
|
||||
:key="item.task_no"
|
||||
class="flex w-full items-start gap-3 rounded-2xl border px-4 py-3 transition-colors"
|
||||
:class="selectedTaskNo === item.task_no ? 'border-brand-400 bg-brand-50/60' : 'border-default hover:bg-surface-soft/70'"
|
||||
>
|
||||
<button type="button" class="min-w-0 flex-1 text-left" @click="selectedTaskNo = item.task_no">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="font-mono text-sm font-semibold text-primary">{{ item.task_no }}</span>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-xs font-medium"
|
||||
:class="statusBadge(item).cls"
|
||||
:title="item.process_status"
|
||||
>
|
||||
{{ statusBadge(item).label }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 truncate text-sm text-secondary">{{ item.customer_name || '—' }}</div>
|
||||
<div
|
||||
v-if="item.ui_state?.summary?.title"
|
||||
class="mt-1 truncate text-xs font-medium text-brand-700"
|
||||
>
|
||||
{{ sanitizeShippingRuntimeStatusText(item.ui_state.summary.title) }}
|
||||
</div>
|
||||
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted">
|
||||
<span>{{ formatLocalDateTime(item.created_at) }}</span>
|
||||
<span v-if="item.batch_index && item.batch_total" class="rounded-full bg-sky-50 px-2 py-0.5 font-medium text-sky-700">
|
||||
{{ t('chat.shippingNoticeUi.batchProgress', { index: item.batch_index, total: item.batch_total }) }}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</article>
|
||||
<div
|
||||
v-if="totalTasks > 0"
|
||||
class="flex items-center justify-between gap-2 pt-2 text-sm text-muted"
|
||||
>
|
||||
<span>{{ $t('workspace.shippingNotice.pagination.summary', { start: pageStart, end: pageEnd, total: totalTasks }) }}</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2.5 py-1.5 text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="currentPage <= 1 || loading"
|
||||
@click="changePage(currentPage - 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.previous') }}
|
||||
</button>
|
||||
<span class="whitespace-nowrap">{{ $t('workspace.shippingNotice.pagination.page', { page: currentPage, total: totalPages }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2.5 py-1.5 text-secondary hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:disabled="currentPage >= totalPages || loading"
|
||||
@click="changePage(currentPage + 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border border-default bg-surface/50 p-5">
|
||||
<div v-if="!selectedTaskNo" class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.selectCase') }}
|
||||
</div>
|
||||
<div v-else-if="detailLoading" class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!detail" class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loadFailed') }}
|
||||
</div>
|
||||
<div v-else class="space-y-4">
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
|
||||
<div class="flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span>{{ detail.customer_name }} · {{ detail.customer_code || '—' }}</span>
|
||||
<span v-if="batchProgressLabel" class="rounded-full bg-sky-50 px-2 py-0.5 text-xs font-medium text-sky-700">
|
||||
{{ batchProgressLabel }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="chatAgentId"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-300 bg-brand-50 px-3 py-1.5 text-sm font-medium text-brand-700 hover:bg-brand-100"
|
||||
@click="openInChat(detail.task_no, detail.conversation_id, detail.batch_no)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.openChat') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="rounded-2xl border border-brand-200 bg-brand-50/50 p-4">
|
||||
<div class="min-w-0">
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-brand-700">
|
||||
{{ $t('workspace.shippingNotice.todo.currentTodo') }}
|
||||
</div>
|
||||
<h3 class="mt-1 text-base font-semibold text-primary">{{ detailTodoTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-secondary">{{ detailTodoMessage }}</p>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.openTask') }}:
|
||||
{{ $t('workspace.shippingNotice.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
|
||||
<div class="mb-3 text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.workflow') }}
|
||||
</div>
|
||||
<ShippingWorkflowStepper :steps="detailWorkflowSteps" />
|
||||
</section>
|
||||
|
||||
<div
|
||||
v-if="detailStepProgress && (detailStepMessage || detailStepDetail)"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3"
|
||||
>
|
||||
<div class="text-xs font-medium text-primary">
|
||||
{{ detailStepProgress.step_title || t('chat.shippingNoticeUi.stepDetail.title') }}
|
||||
</div>
|
||||
<div v-if="detailStepMessage" class="mt-1 text-sm text-secondary">
|
||||
{{ detailStepMessage }}
|
||||
</div>
|
||||
<div v-if="detailStepDetail" class="mt-1 text-xs text-muted">
|
||||
{{ detailStepDetail }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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') }}</h3>
|
||||
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.status') }}</dt>
|
||||
<dd :title="detail.process_status">{{ statusBadge(detail).label }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.match') }}</dt>
|
||||
<dd :title="detail.match_status || ''">{{ matchStatusLabel(detail.match_status) }}</dd>
|
||||
</div>
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.shipTo') }}</dt><dd>{{ detail.ship_to || '—' }}</dd></div>
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt><dd>{{ detail.freight_ref_no || '—' }}</dd></div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<div
|
||||
v-if="hasInventorySourceFields"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
|
||||
>
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">
|
||||
{{ $t('workspace.shippingNotice.inventorySource.title') }}
|
||||
</h3>
|
||||
<dl class="grid gap-2 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.sourceCode') }}</dt>
|
||||
<dd class="font-mono">{{ detail.inventory_source_code || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.status') }}</dt>
|
||||
<dd>{{ inventorySourceStatusLabel(detail.inventory_source_status) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.warehouseId') }}</dt>
|
||||
<dd class="font-mono">{{ detail.inventory_warehouse_id || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.method') }}</dt>
|
||||
<dd>{{ inventorySourceMethodLabel(detail.inventory_source_method) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.configVersion') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.inventory_source_config_version || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySource.confirmedBy') }}</dt>
|
||||
<dd class="font-mono">{{ detail.inventory_source_confirmed_by ?? '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="detail.inventory_snapshot"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
|
||||
>
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">
|
||||
{{ $t('workspace.shippingNotice.inventorySnapshot.title') }}
|
||||
</h3>
|
||||
<dl class="grid gap-2 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.warehouseId') }}</dt>
|
||||
<dd class="font-mono">{{ detail.inventory_snapshot.warehouse_id || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.source') }}</dt>
|
||||
<dd>{{ inventorySnapshotLabel(detail.inventory_snapshot.trigger_type) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.exportedAt') }}</dt>
|
||||
<dd>{{ detail.inventory_snapshot.exported_at || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.fileNo') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.inventory_snapshot.inventory_file_no || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="detail.inventory_snapshot.is_fresh === false"
|
||||
class="mt-2 text-xs text-amber-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.inventorySnapshot.expired') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="detailErrorMessage" class="rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-sm text-rose-700">
|
||||
{{ detailErrorMessage }}
|
||||
</div>
|
||||
|
||||
<div v-if="detailIssues.length" class="rounded-xl border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-800">
|
||||
<div v-for="issue in detailIssues" :key="issue" class="py-0.5">{{ issue }}</div>
|
||||
</div>
|
||||
|
||||
<ShippingMatchResultCard
|
||||
v-if="hasMatchCard"
|
||||
:task-id="detail.task_no"
|
||||
:match-status="detail.match_status"
|
||||
:line-results="detail.line_results"
|
||||
:shortage-lines="shortageLines"
|
||||
:action-buttons="[]"
|
||||
:action-busy="false"
|
||||
/>
|
||||
|
||||
<section
|
||||
v-if="detail.inventory_verifications?.length"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
|
||||
>
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.inventoryTitle') }}</h3>
|
||||
<div v-for="verification in detail.inventory_verifications" :key="verification.id" 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">#{{ verification.id }} · {{ verification.status }}</span>
|
||||
<span>{{ formatLocalDateTime(verification.created_at) }}</span>
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-muted">
|
||||
<span v-for="line in verification.lines" :key="line.reservation_id" class="mr-3 inline-block">
|
||||
{{ $t('workspace.shippingNotice.fulfillmentTimeline.verificationLine', { reservationId: line.reservation_id, availableQty: line.available_qty, requiredQty: line.required_qty, status: line.status }) }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="detail.export_artifacts?.length"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
|
||||
>
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.artifactTitle') }}</h3>
|
||||
<div v-for="artifact in detail.export_artifacts" :key="artifact.id" 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-mono font-medium text-secondary">{{ artifact.artifact_no }}</span>
|
||||
<span>{{ artifact.status }}</span>
|
||||
<span>{{ artifact.file_name }}</span>
|
||||
<span>{{ formatLocalDateTime(artifact.created_at) }}</span>
|
||||
</div>
|
||||
<p class="mt-1 text-xs text-muted">{{ $t('workspace.shippingNotice.fulfillmentTimeline.reservationIds', { reservationIds: artifact.reservation_ids.join(', ') || '—' }) }}</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section
|
||||
v-if="detail.upload_attempts?.length"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm"
|
||||
>
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.fulfillmentTimeline.uploadTitle') }}</h3>
|
||||
<div v-for="attempt in detail.upload_attempts" :key="attempt.id" 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">{{ $t('workspace.shippingNotice.fulfillmentTimeline.uploadAttempt', { artifactId: attempt.artifact_id, attemptNo: attempt.attempt_no }) }}</span>
|
||||
<span>{{ attempt.mode }}</span><span>{{ attempt.status }}</span>
|
||||
<span>{{ formatLocalDateTime(attempt.finished_at || attempt.created_at) }}</span>
|
||||
</div>
|
||||
<p v-if="attempt.freight_ref_no || attempt.error_message || attempt.evidence_asset_id" class="mt-1 text-xs text-muted">
|
||||
{{ attempt.freight_ref_no ? $t('workspace.shippingNotice.fulfillmentTimeline.freightRef', { freightRefNo: attempt.freight_ref_no }) : '' }}
|
||||
{{ attempt.error_message ? ` ${attempt.error_message}` : '' }}
|
||||
{{ attempt.evidence_asset_id ? ` ${$t('workspace.shippingNotice.fulfillmentTimeline.evidenceAsset', { assetId: attempt.evidence_asset_id })}` : '' }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<ShippingTaskParsedResultCard
|
||||
v-if="detail.lines?.length || detail.process_field_gate || detail.parse_validation || detail.source_candidate || detail.field_conflicts?.length"
|
||||
class="mt-3"
|
||||
:task-no="detail.task_no"
|
||||
:po-number="detail.po_number"
|
||||
:lines="detail.lines"
|
||||
:parse-validation="detail.parse_validation || detail.step_payload?.parse_validation || null"
|
||||
:process-field-gate="detail.process_field_gate || null"
|
||||
:source-candidate="detail.source_candidate || null"
|
||||
:field-conflicts="detail.field_conflicts || []"
|
||||
:order-data-version="detail.order_data_version"
|
||||
:default-expanded="true"
|
||||
@refreshed="detail?.task_no && loadDetail(detail.task_no)"
|
||||
/>
|
||||
|
||||
<div v-if="detail.events?.length">
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.events') }}</h3>
|
||||
<ul class="max-h-48 space-y-1 overflow-y-auto text-xs text-muted">
|
||||
<li v-for="(ev, idx) in [...detail.events].reverse()" :key="idx">
|
||||
<span class="font-medium text-secondary" :title="ev.event_type">{{ eventLabel(ev.event_type) }}</span>
|
||||
<span class="ml-2">{{ formatLocalDateTime(ev.created_at) }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex min-h-[12rem] items-center justify-center text-sm text-secondary" data-testid="shipping-notice-view-redirect">
|
||||
Redirecting…
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user