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
@@ -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>
|
||||
Reference in new issue
Block a user