feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估
- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。 - 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。 - 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。 - 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。 - 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
1 parent
cef3d5b26a
commit
3a9fbac2fc
226 files changed
+25010
-2098
No files matched your search
@@ -4,7 +4,7 @@
|
||||
* 用途:渲染单个 PDF 的订单抽取结果摘要,供详情抽屉按文档逐项展示。
|
||||
* 依赖:订单抽取文档 DTO、vue-i18n。
|
||||
* 逻辑:默认只展示状态/PO/行数/阻断原因;审计与补充信息收入详情折叠;
|
||||
* 「查看证据」与「人工复核」分别携带 focus+documentId;未知原因码回退通用文案并展开技术码。
|
||||
* 「查看证据」与「人工复核」分别携带 focus+documentId;内部错误码只转为业务提示。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -46,7 +46,10 @@ const statusTone = computed(() => {
|
||||
}
|
||||
});
|
||||
|
||||
const statusLabel = computed(() => t(`chat.shippingOrderExtractionDocumentStatus.${props.document.status}`));
|
||||
const statusLabel = computed(() => {
|
||||
const key = `chat.shippingOrderExtractionDocumentStatus.${props.document.status}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderExtractionDocumentStatus.unknown');
|
||||
});
|
||||
const statusActivityLabel = computed(() => {
|
||||
const key = `chat.shippingOrderExtractionActivity.${props.document.activity_event_code || props.document.status}`;
|
||||
return te(key) ? t(key) : statusLabel.value;
|
||||
@@ -74,13 +77,6 @@ const reasonLabel = computed(() => {
|
||||
}
|
||||
return t('chat.shippingOrderExtractionReasonUnknown');
|
||||
});
|
||||
const reasonTechnicalCode = computed(() => {
|
||||
const code = String(props.document.reason_code || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderExtractionReason.${code}`;
|
||||
if (te(key) || code.startsWith('SHIPPING_NOTICE.')) return '';
|
||||
return code;
|
||||
});
|
||||
const emailSupplementLabel = computed(() => {
|
||||
const status = props.document.email_supplement?.status || 'none';
|
||||
const key = `chat.shippingOrderExtractionEmailSupplement.${status}`;
|
||||
@@ -90,7 +86,7 @@ const emailSupplementRelations = computed(() => (
|
||||
(props.document.email_supplement?.relation_codes || [])
|
||||
.map((code) => {
|
||||
const key = `chat.shippingOrderExtractionEmailSupplementRelation.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderExtractionEmailSupplementRelation.unknown');
|
||||
})
|
||||
));
|
||||
const reservationStatusLabel = computed(() => {
|
||||
@@ -110,13 +106,13 @@ const routeTypeLabel = computed(() => {
|
||||
const code = String(props.document.route_type || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderExtractionRouteType.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderExtractionRouteType.unknown');
|
||||
});
|
||||
const freezeSourceLabel = computed(() => {
|
||||
const code = String(props.document.freeze_source || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderExtractionFreezeSource.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderExtractionFreezeSource.unknown');
|
||||
});
|
||||
const budgetCostLabel = computed(() => {
|
||||
if (!props.document.budget_cost) return '';
|
||||
@@ -129,7 +125,7 @@ const budgetCostLabel = computed(() => {
|
||||
const reviewDetails = computed(() => props.document.review_details || []);
|
||||
const reviewFieldLabel = (fieldCode: string | null | undefined): string => {
|
||||
const key = `chat.shippingOrderExtractionReviewField.${fieldCode || ''}`;
|
||||
return fieldCode && te(key) ? t(key) : (fieldCode || t('chat.shippingOrderExtractionReviewField.unknown'));
|
||||
return fieldCode && te(key) ? t(key) : t('chat.shippingOrderExtractionReviewField.unknown');
|
||||
};
|
||||
|
||||
const canEnterManualReview = computed(() => (
|
||||
@@ -190,10 +186,6 @@ const hasAuditDetails = computed(() => Boolean(
|
||||
<!-- 异常信息 -->
|
||||
<div v-if="reasonLabel" class="mt-2 text-xs font-medium opacity-90">
|
||||
{{ reasonLabel }}
|
||||
<details v-if="reasonTechnicalCode" class="mt-1 font-normal opacity-80">
|
||||
<summary class="cursor-pointer">{{ t('chat.shippingOrderExtractionReasonTechDetails') }}</summary>
|
||||
<code class="mt-1 block break-all text-[11px]">{{ reasonTechnicalCode }}</code>
|
||||
</details>
|
||||
</div>
|
||||
<ul v-if="reviewDetails.length" class="mt-2 space-y-1 text-xs font-medium opacity-90">
|
||||
<li v-for="detail in reviewDetails" :key="`${detail.line_number}-${detail.field_code || 'general'}`">
|
||||
|
||||
@@ -4,15 +4,17 @@
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、
|
||||
* orderExtractionProgressDisplay、Workflow 计数投影、vue-router、vue-i18n。
|
||||
* 逻辑:有 Workflow 投影时优先展示统一 counts;否则回退 handling_items / primary_notice;
|
||||
* Run 失败优先展示 errorExplainability.message(含 request_id 提示),禁止只展示技术错误码;
|
||||
* 「查看处理详情」挂载详情抽屉;抽屉内证据/复核入口携带 focus+document_id 打开复核页;
|
||||
* 用户界面只展示业务原因,内部错误码仅保留在管理员审计中;
|
||||
* 文档与时间线加载失败支持独立就地重试;右侧 ShippingWorkflowTimeline 承接逐 PDF 明细。
|
||||
* 文档与时间线加载失败支持独立就地重试;右侧 ShippingWorkflowTimeline 承接逐 PDF 明细;
|
||||
* Gate confirm_customer 经 ChatPage 打开客户选择弹窗。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { CircleCheck, CircleX, LoaderCircle, TriangleAlert } from 'lucide-vue-next';
|
||||
import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
|
||||
import type {
|
||||
ShippingOrderExtractionHandlingItemState,
|
||||
ShippingOrderExtractionState,
|
||||
@@ -59,10 +61,18 @@ const emit = defineEmits<{
|
||||
const { t, te } = useI18n();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const chatPage = inject(CHAT_PAGE_KEY, null);
|
||||
const confirmCancelOpen = ref(false);
|
||||
const cancelReason = ref('');
|
||||
const injectedWorkflow = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
|
||||
/**
|
||||
* Gate 恢复卡「确认客户」:打开对话叠层客户选择弹窗。
|
||||
*/
|
||||
async function onGateConfirmCustomer(taskNo: string) {
|
||||
await chatPage?.openShippingCustomerDialog?.(taskNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 Workflow Items 中取首个阻断 Gate 摘要,供 Run 级卡片展示。
|
||||
*/
|
||||
@@ -219,8 +229,11 @@ const compactLine = computed(() => {
|
||||
case 'review_required':
|
||||
return t('chat.shippingSessionSummary.processNoticeNeedsAction');
|
||||
case 'failed':
|
||||
case 'cancelled':
|
||||
case 'cancelled': {
|
||||
const explained = String(props.state.errorExplainability?.message || '').trim();
|
||||
if (explained) return explained;
|
||||
return t('chat.shippingSessionSummary.processNoticeFailed');
|
||||
}
|
||||
default: {
|
||||
if (props.state.status === 'queued' || props.state.status === 'processing') {
|
||||
const parts: string[] = [];
|
||||
@@ -399,23 +412,29 @@ async function enterReviewFromDetails(payload?: { focus?: 'evidence' | 'draft';
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开任务工作台,定位自动冻结受阻等任务号。
|
||||
* 在对话侧聚焦 Task(双工作台主路径);Task 工作台仅作备用深链。
|
||||
*/
|
||||
async function openTaskWorkbench(taskNo: string) {
|
||||
async function focusTaskInChat(taskNo: string) {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) return;
|
||||
await router.push({
|
||||
name: 'workspace-shipping-tasks',
|
||||
params: { taskNo: normalized },
|
||||
const conversationId = String(route.query.conversation_id || '').trim();
|
||||
await router.replace({
|
||||
name: 'Chat',
|
||||
params: { agentId: String(route.params.agentId || '') },
|
||||
query: {
|
||||
...route.query,
|
||||
conversation_id: conversationId || undefined,
|
||||
focus_task_no: normalized,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 按受影响对象引用跳转到任务或复核入口。
|
||||
* 按受影响对象引用跳转到对话聚焦或复核入口。
|
||||
*/
|
||||
async function openAffectedRef(target: ShippingHandlingRefTarget) {
|
||||
if (target.kind === 'task') {
|
||||
await openTaskWorkbench(target.taskNo);
|
||||
if (target.kind === 'chat_focus_task') {
|
||||
await focusTaskInChat(target.taskNo);
|
||||
return;
|
||||
}
|
||||
if (target.kind === 'review') {
|
||||
@@ -498,6 +517,13 @@ function openCancelConfirm() {
|
||||
|
||||
<div class="min-w-0 flex-1">
|
||||
<div class="text-sm font-medium">{{ compactLine }}</div>
|
||||
<p
|
||||
v-if="state.errorExplainability?.request_id"
|
||||
class="mt-1 text-[11px] opacity-80"
|
||||
data-testid="shipping-order-extraction-error-request-id"
|
||||
>
|
||||
{{ t('chat.shippingOrderExtractionErrorRequestId', { id: state.errorExplainability.request_id }) }}
|
||||
</p>
|
||||
|
||||
<div
|
||||
v-if="displaySummary.totalDocuments > 0"
|
||||
@@ -542,6 +568,7 @@ function openCancelConfirm() {
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="emit('refresh')"
|
||||
@refresh-needed="emit('refresh')"
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
|
||||
<div
|
||||
|
||||
+2
-4
@@ -5,7 +5,7 @@
|
||||
* 依赖:订单抽取状态卡、文档结果项、订单抽取 progress-events DTO、vue-i18n。
|
||||
* 逻辑:聊天摘要卡只显示概览;需要查看逐文档结果和每轮事件原因时由本抽屉承接;
|
||||
* 以模态对话框语义呈现(初始焦点、Tab 陷阱、Escape/关闭后焦点恢复);
|
||||
* 文档与时间线加载失败分别提供就地重试。
|
||||
* 文档与时间线加载失败分别提供就地重试;内部错误码不向普通用户展示。
|
||||
*/
|
||||
import { nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
@@ -284,9 +284,7 @@ onBeforeUnmount(() => {
|
||||
}) }}
|
||||
</div>
|
||||
<div v-if="state.unitSummary?.technicalFailureReasonCodes?.length" class="mt-1">
|
||||
{{ t('chat.shippingOrderExtractionTechnicalFailureCodes', {
|
||||
codes: state.unitSummary.technicalFailureReasonCodes.join(', '),
|
||||
}) }}
|
||||
{{ t('chat.shippingOrderExtractionTechnicalFailureUserHint') }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
|
||||
+26
@@ -133,4 +133,30 @@ describe('ShippingWorkflowItemDetailDrawer', () => {
|
||||
expect(wrapper.emitted('close')).toBeTruthy();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('does not expose unknown workflow status or event codes', () => {
|
||||
const wrapper = mount(ShippingWorkflowItemDetailDrawer, {
|
||||
props: {
|
||||
open: true,
|
||||
item: buildItem({
|
||||
lifecycle_status: 'internal_future_status',
|
||||
current_stage: 'internal_future_status',
|
||||
events: [{
|
||||
seq_no: 1,
|
||||
event_code: 'internal_future_event',
|
||||
actor_type: 'system',
|
||||
occurred_at: '2026-07-30T10:00:00Z',
|
||||
}],
|
||||
}),
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
attachTo: document.body,
|
||||
});
|
||||
const text = drawerRoot()?.textContent || '';
|
||||
expect(text).toContain('状态待确认');
|
||||
expect(text).toContain('处理状态已更新');
|
||||
expect(text).not.toContain('internal_future_status');
|
||||
expect(text).not.toContain('internal_future_event');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
+24
-6
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingWorkflowItemDetailDrawer.vue
|
||||
* 用途:单个 WorkflowItem(PDF)详情抽屉——文件名、阶段、事件时间线、取消/重识别入口。
|
||||
* 依赖:vue-i18n、ShippingWorkflowItem / Event 类型、lucide-vue-next。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 打开;展示 filename / current_stage / events;
|
||||
* 用途:单个 WorkflowItem(PDF)详情抽屉——文件名、阶段、Process Gate 恢复、事件时间线。
|
||||
* 依赖:vue-i18n、ProcessGateRecoveryCard、ShippingWorkflowItem / Event 类型、lucide-vue-next。
|
||||
* 逻辑:由 ShippingWorkflowTimeline 打开;状态优先 display_lifecycle_status;
|
||||
* 有阻断 Gate 时内嵌 RecoveryCard(对话内完成重试/接管,不绕过后端状态机);
|
||||
* confirm_customer 向上转发由 Timeline 打开客户弹窗;
|
||||
* 取消与重识别以后端 available_actions 为准,仅 emit 由父级收集原因;
|
||||
* 禁止发明百分比与 ETA。以模态对话框语义呈现:初始焦点、Tab 陷阱、Escape/关闭后焦点恢复。
|
||||
*/
|
||||
@@ -10,6 +12,7 @@
|
||||
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { X } from 'lucide-vue-next';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import type { ShippingWorkflowEvent, ShippingWorkflowItem } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -24,6 +27,8 @@ const emit = defineEmits<{
|
||||
close: [];
|
||||
cancel: [item: ShippingWorkflowItem];
|
||||
reparse: [item: ShippingWorkflowItem];
|
||||
refreshed: [];
|
||||
confirmCustomer: [taskNo: string];
|
||||
}>();
|
||||
|
||||
const { t, te, locale } = useI18n();
|
||||
@@ -83,7 +88,7 @@ function statusLabel(status?: string | null): string {
|
||||
const normalized = String(status || '').trim();
|
||||
if (!normalized) return '';
|
||||
const key = `chat.shippingWorkflow.itemStatus.${normalized}`;
|
||||
return te(key) ? t(key) : normalized;
|
||||
return te(key) ? t(key) : t('chat.shippingWorkflow.itemStatus.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +98,7 @@ function eventLabel(event: ShippingWorkflowEvent): string {
|
||||
const code = String(event.message_code || event.event_code || '').trim();
|
||||
if (!code) return '—';
|
||||
const key = `chat.shippingWorkflow.event.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
return te(key) ? t(key) : t('chat.shippingWorkflow.event.unknown');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +246,9 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
<div class="flex justify-between gap-2">
|
||||
<dt class="text-secondary">{{ t('chat.shippingWorkflow.detail.status') }}</dt>
|
||||
<dd class="font-medium text-primary">{{ statusLabel(item.lifecycle_status) }}</dd>
|
||||
<dd class="font-medium text-primary">{{
|
||||
statusLabel(item.display_lifecycle_status || item.lifecycle_status)
|
||||
}}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-2">
|
||||
<dt class="text-secondary">{{ t('chat.shippingWorkflow.detail.stage') }}</dt>
|
||||
@@ -269,6 +276,17 @@ onBeforeUnmount(() => {
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="item.process_gate?.current_blocking_gate"
|
||||
class="mt-4"
|
||||
:summary="item.process_gate"
|
||||
:can-handle="true"
|
||||
data-testid="shipping-workflow-item-drawer-process-gate"
|
||||
@refreshed="emit('refreshed')"
|
||||
@refresh-needed="emit('refreshed')"
|
||||
@confirm-customer="(taskNo) => emit('confirmCustomer', taskNo)"
|
||||
/>
|
||||
|
||||
<section class="mt-4">
|
||||
<h3 class="text-xs font-semibold text-secondary">
|
||||
{{ t('chat.shippingWorkflow.detail.eventsTitle') }}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* features/chat/components/shipping/ShippingWorkflowTimeline.spec.ts
|
||||
* 用途:验证右侧 Workflow 时间线分组、文件名、批次切换、过滤与取消/重识别弹窗。
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、shipping.api mock。
|
||||
* 逻辑:断言 layout_parsing 可见;文件名优先;仅看待处理过滤;原因弹窗提交 cancelItem。
|
||||
* 逻辑:先展开侧栏并打开详情抽屉;断言 layout_parsing 可见;文件名优先;过滤与 cancel。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it, vi, beforeEach } from 'vitest';
|
||||
@@ -13,6 +13,12 @@ import ShippingWorkflowTimeline from './ShippingWorkflowTimeline.vue';
|
||||
import type { ShippingWorkflow, ShippingWorkflowItem } from '../../types/shipping.api.types';
|
||||
import type { UseShippingNoticeWorkflowReturn } from '../../shipping/useShippingNoticeWorkflow';
|
||||
|
||||
const routerPush = vi.fn(async () => undefined);
|
||||
vi.mock('vue-router', () => ({
|
||||
useRoute: () => ({ params: { agentId: 'agent-1' }, query: {} }),
|
||||
useRouter: () => ({ push: routerPush }),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
getWorkspaceShippingWorkflowItem: vi.fn(async (itemNo: string) => ({
|
||||
item_no: itemNo,
|
||||
@@ -105,9 +111,36 @@ function buildController(
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 展开窄侧栏并打开详情抽屉(完整列表仅在抽屉内)。
|
||||
*/
|
||||
async function openDetailsDrawer(wrapper: ReturnType<typeof mount>) {
|
||||
const toggleCollapse = wrapper.find('[data-testid="shipping-workflow-timeline"] button');
|
||||
if (toggleCollapse.exists()) {
|
||||
await toggleCollapse.trigger('click');
|
||||
await flushPromises();
|
||||
}
|
||||
const openDetails = wrapper.find('[data-testid="shipping-workflow-toggle-details"]');
|
||||
expect(openDetails.exists()).toBe(true);
|
||||
await openDetails.trigger('click');
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-details-drawer"]').exists()).toBe(true);
|
||||
}
|
||||
|
||||
const mountOptions = {
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: {
|
||||
// 抽屉/原因框经 Teleport;单测就地渲染便于查询。
|
||||
teleport: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
describe('ShippingWorkflowTimeline', () => {
|
||||
beforeEach(() => {
|
||||
document.body.innerHTML = '';
|
||||
routerPush.mockClear();
|
||||
});
|
||||
|
||||
it('shows layout_parsing items with filename before review case exists', async () => {
|
||||
@@ -122,9 +155,11 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: { plugins: [i18n] },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="shipping-workflow-pending-only-filter"]').setValue(false);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-SWI-LAYOUT"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-SWI-LAYOUT"]').text()).toContain('layout.pdf');
|
||||
expect(wrapper.text()).toContain('尚无复核单');
|
||||
@@ -139,29 +174,56 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: { plugins: [i18n] },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="shipping-workflow-pending-only-filter"]').setValue(true);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-SWI-B"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-item-SWI-A"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('opens the review workspace directly for pending review items', async () => {
|
||||
const controller = buildController([
|
||||
buildItem({
|
||||
item_no: 'SWI-REVIEW-OPEN',
|
||||
lifecycle_status: 'pending_review',
|
||||
current_run_no: 'RUN-REVIEW-1',
|
||||
current_case_no: 'CASE-REVIEW-1',
|
||||
current_document_id: 42,
|
||||
}),
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="shipping-workflow-action-open-review"]').trigger('click');
|
||||
expect(routerPush).toHaveBeenCalledWith(expect.objectContaining({
|
||||
name: 'Chat',
|
||||
params: { agentId: 'agent-1' },
|
||||
query: expect.objectContaining({
|
||||
mode: 'order-review',
|
||||
run_no: 'RUN-REVIEW-1',
|
||||
case_no: 'CASE-REVIEW-1',
|
||||
document_id: '42',
|
||||
focus: 'draft',
|
||||
}),
|
||||
}));
|
||||
});
|
||||
|
||||
it('cancels an item via in-app reason dialog', async () => {
|
||||
const controller = buildController([
|
||||
buildItem({ item_no: 'SWI-CANCEL', lifecycle_status: 'extracting', lock_version: 3 }),
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
stubs: {
|
||||
// 让 Teleport 就地渲染,便于 setValue / trigger
|
||||
teleport: true,
|
||||
},
|
||||
},
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
await wrapper.find('[data-testid="shipping-workflow-pending-only-filter"]').setValue(false);
|
||||
await wrapper.find('[data-testid="shipping-workflow-action-cancel"]').trigger('click');
|
||||
await flushPromises();
|
||||
const reasonInput = wrapper.find('[data-testid="shipping-workflow-reason-input"]');
|
||||
@@ -201,9 +263,10 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
const controller = buildController(itemsA, { workflows });
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: { plugins: [i18n] },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-batch-switcher"]').exists()).toBe(true);
|
||||
await wrapper.find('[data-testid="shipping-workflow-batch-SNWF-B"]').trigger('click');
|
||||
expect(controller.selectWorkflow).toHaveBeenCalledWith('SNWF-B');
|
||||
@@ -221,9 +284,10 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: { plugins: [i18n] },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-action-reparse"]').exists()).toBe(true);
|
||||
expect(wrapper.text()).toContain('重试失败识别');
|
||||
});
|
||||
@@ -240,9 +304,27 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
global: { plugins: [i18n] },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-action-reparse"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps sidebar width when opening details dialog overlay', async () => {
|
||||
const controller = buildController([buildItem()]);
|
||||
const wrapper = mount(ShippingWorkflowTimeline, {
|
||||
props: { conversationId: 'conv-1', controller },
|
||||
...mountOptions,
|
||||
});
|
||||
await flushPromises();
|
||||
await openDetailsDrawer(wrapper);
|
||||
const aside = wrapper.find('[data-testid="shipping-workflow-timeline"]');
|
||||
// 关键断言:弹层打开后侧栏仍固定窄宽,对话区不被列表撑开。
|
||||
expect(aside.classes().join(' ')).toContain('md:w-60');
|
||||
const overlay = wrapper.find('[data-testid="shipping-workflow-details-drawer"]');
|
||||
expect(overlay.exists()).toBe(true);
|
||||
expect(overlay.classes().join(' ')).toContain('fixed');
|
||||
expect(overlay.find('[role="dialog"]').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -1,11 +1,11 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingWorkflowTimeline.vue
|
||||
* 用途:聊天页右侧「本次处理」面板——以会话 Workflow / Items 为列表事实源。
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow(inject 或自建)、DetailDrawer、ReasonDialog。
|
||||
* 逻辑:多批次时展示切换器;Items 以文件名为主标题;
|
||||
* 分组进行中/待处理/待复核/待人工上传登记/失败/已完成(登记前不得进已完成);
|
||||
* 「仅看待处理」过滤;待复核项提供直接进入复核工作台;查看进度 / 取消 / 重试重识别;
|
||||
* 取消与重识别用应用内原因弹窗。侧栏在桌面端可收窄,在窄屏自动占满宽度。
|
||||
* 用途:聊天页右侧「本次处理中」面板——会话处理对象投影 + Workflow Items 列表。
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、conversationProcessingProjection、
|
||||
* DetailDrawer、ReasonDialog、ProcessGateRecoveryCard。
|
||||
* 逻辑:默认轻量摘要(当前对象 / Gate 恢复 / 错误);批次/统计/完整文件列表经 Teleport
|
||||
* 打开居中弹层(不改侧栏宽度、不压缩对话 flex);窄侧栏固定 md:w-60;
|
||||
* focus_task_no 聚焦;Task 留在对话侧;confirm_customer 打开对话客户弹窗。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
@@ -14,14 +14,20 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { ChevronDown, ChevronRight, RefreshCw } from 'lucide-vue-next';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import {
|
||||
getWorkspaceShippingWorkflowItem,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import type {
|
||||
ConversationProcessingObject,
|
||||
ShippingWorkflow,
|
||||
ShippingWorkflowItem,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
projectConversationProcessingObjects,
|
||||
resolveItemDisplayStatus,
|
||||
} from '@/features/chat/shipping/conversationProcessingProjection';
|
||||
import {
|
||||
SHIPPING_WORKFLOW_KEY,
|
||||
useShippingNoticeWorkflow,
|
||||
@@ -44,12 +50,20 @@ const { t, te, locale } = useI18n();
|
||||
const msg = useMessage();
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const chatPage = inject(CHAT_PAGE_KEY, null);
|
||||
|
||||
const gateNavigationContext = computed(() => ({
|
||||
agentId: String(route.params.agentId || ''),
|
||||
conversationId: String(props.conversationId || route.query.conversation_id || ''),
|
||||
}));
|
||||
|
||||
/**
|
||||
* Gate「确认客户」:打开对话叠层客户选择弹窗(非跳转复核)。
|
||||
*/
|
||||
async function onGateConfirmCustomer(taskNo: string) {
|
||||
await chatPage?.openShippingCustomerDialog?.(taskNo);
|
||||
}
|
||||
|
||||
const injected = inject(SHIPPING_WORKFLOW_KEY, null);
|
||||
/** 父级已 provide/传入时本地 composable 以空 conversationId 待机,避免双轮询。 */
|
||||
const localController = useShippingNoticeWorkflow({
|
||||
@@ -64,8 +78,13 @@ const ctl = computed((): UseShippingNoticeWorkflowReturn => (
|
||||
props.controller || injected || localController
|
||||
));
|
||||
|
||||
const collapsed = ref(false);
|
||||
const pendingOnlyFilter = ref(false);
|
||||
/** 默认收起侧栏,避免持续压缩对话区;用户可一键展开轻量摘要。 */
|
||||
const collapsed = ref(true);
|
||||
/** 默认折叠批次/统计/文件列表,保持「本次处理中」轻量(完整列表进抽屉)。 */
|
||||
const showExtendedDetails = ref(false);
|
||||
/** 复核返回对话时展示的聚焦提示(由 focus_notice 触发一次)。 */
|
||||
const focusTaskBanner = ref<string | null>(null);
|
||||
const pendingOnlyFilter = ref(true);
|
||||
const actionBusyItemNo = ref<string | null>(null);
|
||||
const detailOpen = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
@@ -100,6 +119,8 @@ async function openReview(item: ShippingWorkflowItem) {
|
||||
if (caseNo) query.case_no = caseNo;
|
||||
const conversationId = String(props.conversationId || route.query.conversation_id || '').trim();
|
||||
if (conversationId) query.conversation_id = conversationId;
|
||||
const taskNo = String(item.current_task_no || route.query.focus_task_no || '').trim();
|
||||
if (taskNo) query.focus_task_no = taskNo;
|
||||
await router.push({
|
||||
name: 'Chat',
|
||||
params: { agentId: String(route.params.agentId || '') },
|
||||
@@ -107,6 +128,67 @@ async function openReview(item: ShippingWorkflowItem) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 在对话侧聚焦 Task(不跳转 Task 工作台)。
|
||||
*/
|
||||
async function focusTaskInChat(taskNo: string) {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) return;
|
||||
const conversationId = String(props.conversationId || route.query.conversation_id || '').trim();
|
||||
await router.replace({
|
||||
name: 'Chat',
|
||||
params: { agentId: String(route.params.agentId || '') },
|
||||
query: {
|
||||
...route.query,
|
||||
conversation_id: conversationId || undefined,
|
||||
focus_task_no: normalized,
|
||||
},
|
||||
});
|
||||
await ctl.value.refresh?.();
|
||||
}
|
||||
|
||||
/**
|
||||
* 「本次处理中」对象行:Run / Candidate / Task / Process Gate。
|
||||
*/
|
||||
const processingObjects = computed((): ConversationProcessingObject[] => (
|
||||
projectConversationProcessingObjects(items.value, {
|
||||
focusTaskNo: String(route.query.focus_task_no || ''),
|
||||
focusRunNo: String(route.query.focus_run_no || route.query.run_no || ''),
|
||||
focusCandidateNo: String(route.query.focus_candidate_no || route.query.candidate || ''),
|
||||
})
|
||||
));
|
||||
|
||||
/**
|
||||
* 点击聚合对象行:Task 聚焦对话,Candidate/Run 打开复核,Gate 展开详情。
|
||||
*/
|
||||
async function onProcessingObjectClick(row: ConversationProcessingObject) {
|
||||
if (row.kind === 'task' && row.task_no) {
|
||||
await focusTaskInChat(row.task_no);
|
||||
return;
|
||||
}
|
||||
if ((row.kind === 'candidate' || row.kind === 'run') && row.run_no) {
|
||||
const match = items.value.find((item) => (
|
||||
String(item.current_run_no || '') === String(row.run_no)
|
||||
|| String(item.current_case_no || '') === String(row.case_no || '')
|
||||
));
|
||||
if (match) {
|
||||
await openReview(match);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Process Gate:对话内展开详情(含 RecoveryCard),不跳转备用深链。
|
||||
if (row.kind === 'process_gate' || row.workflow_item_no) {
|
||||
const match = items.value.find((item) => (
|
||||
item.item_no === row.workflow_item_no
|
||||
|| (row.task_no && String(item.current_task_no || '').toUpperCase() === String(row.task_no).toUpperCase())
|
||||
));
|
||||
if (match) {
|
||||
if (row.task_no) await focusTaskInChat(row.task_no);
|
||||
await openDetail(match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const counts = computed(() => workflow.value?.counts || {
|
||||
total: items.value.length,
|
||||
processing: 0,
|
||||
@@ -138,6 +220,7 @@ const FAILED_STATUSES = new Set(['failed', 'reparse_failed']);
|
||||
/** 真正完成/取消;待人工登记不是完成。 */
|
||||
const COMPLETED_STATUSES = new Set(['closed', 'cancelled']);
|
||||
const WAITING_MANUAL_UPLOAD_STATUSES = new Set(['manual_upload_pending']);
|
||||
const UPLOAD_RPA_RUNNING_STATUSES = new Set(['upload_rpa_pending', 'upload_rpa_running']);
|
||||
const PENDING_REVIEW_STATUSES = new Set(['pending_review']);
|
||||
const ACTIONABLE_FILTER_STATUSES = new Set([
|
||||
'pending_review',
|
||||
@@ -145,16 +228,39 @@ const ACTIONABLE_FILTER_STATUSES = new Set([
|
||||
'reparse_failed',
|
||||
'queued',
|
||||
'manual_upload_pending',
|
||||
'upload_rpa_pending',
|
||||
'upload_rpa_running',
|
||||
'upload_rpa_failed',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 将 Item 归入展示分组。
|
||||
* 将 Item 归入展示分组;优先 is_waiting_manual_upload / display(禁止单靠 lifecycle 推断人工待办)。
|
||||
*/
|
||||
function resolveGroup(item: ShippingWorkflowItem): ItemGroupKey {
|
||||
const display = resolveItemDisplayStatus(item);
|
||||
if (PENDING_REVIEW_STATUSES.has(display)) return 'pending_review';
|
||||
if (FAILED_STATUSES.has(display) || display === 'upload_rpa_failed') return 'failed';
|
||||
if (UPLOAD_RPA_RUNNING_STATUSES.has(display)) return 'processing';
|
||||
if (item.is_waiting_manual_upload === true || item.upload_phase === 'manual_pending') {
|
||||
return 'waiting_manual_upload';
|
||||
}
|
||||
if (WAITING_MANUAL_UPLOAD_STATUSES.has(display) && item.is_waiting_manual_upload !== false) {
|
||||
return 'waiting_manual_upload';
|
||||
}
|
||||
const status = String(item.lifecycle_status || '').trim();
|
||||
if (PENDING_REVIEW_STATUSES.has(status)) return 'pending_review';
|
||||
if (FAILED_STATUSES.has(status)) return 'failed';
|
||||
if (WAITING_MANUAL_UPLOAD_STATUSES.has(status)) return 'waiting_manual_upload';
|
||||
if (
|
||||
item.is_waiting_manual_upload !== false
|
||||
&& WAITING_MANUAL_UPLOAD_STATUSES.has(status)
|
||||
&& !UPLOAD_RPA_RUNNING_STATUSES.has(display)
|
||||
&& display !== 'upload_rpa_failed'
|
||||
&& item.upload_phase !== 'rpa_pending'
|
||||
&& item.upload_phase !== 'rpa_running'
|
||||
&& item.upload_phase !== 'rpa_failed'
|
||||
) {
|
||||
return 'waiting_manual_upload';
|
||||
}
|
||||
if (COMPLETED_STATUSES.has(status)) return 'completed';
|
||||
if (QUEUED_STATUSES.has(status)) return 'queued';
|
||||
if (PROCESSING_STATUSES.has(status)) return 'processing';
|
||||
@@ -203,9 +309,13 @@ function itemTitle(item: ShippingWorkflowItem): string {
|
||||
|
||||
const filteredItems = computed(() => {
|
||||
if (!pendingOnlyFilter.value) return items.value;
|
||||
return items.value.filter((item) =>
|
||||
ACTIONABLE_FILTER_STATUSES.has(String(item.lifecycle_status || '').trim()),
|
||||
);
|
||||
return items.value.filter((item) => {
|
||||
const display = resolveItemDisplayStatus(item);
|
||||
return (
|
||||
ACTIONABLE_FILTER_STATUSES.has(display)
|
||||
|| ACTIONABLE_FILTER_STATUSES.has(String(item.lifecycle_status || '').trim())
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
const grouped = computed(() => {
|
||||
@@ -393,12 +503,39 @@ watch(
|
||||
/* 面板内展示 network_recoverable,不弹 toast */
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* 复核返回对话:展开侧栏并短暂提示已聚焦 Task,避免误以为未打开进度。
|
||||
*/
|
||||
watch(
|
||||
() => [route.query.focus_task_no, route.query.focus_notice] as const,
|
||||
async ([taskNo, notice]) => {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) {
|
||||
focusTaskBanner.value = null;
|
||||
return;
|
||||
}
|
||||
if (String(notice || '') !== '1' && !focusTaskBanner.value) {
|
||||
// 无 focus_notice 时仍展开侧栏以便看到高亮对象。
|
||||
collapsed.value = false;
|
||||
return;
|
||||
}
|
||||
collapsed.value = false;
|
||||
focusTaskBanner.value = normalized;
|
||||
if (String(notice || '') === '1') {
|
||||
const nextQuery = { ...route.query };
|
||||
delete nextQuery.focus_notice;
|
||||
await router.replace({ query: nextQuery });
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<aside
|
||||
class="flex shrink-0 flex-col border-l border-default bg-surface shadow-[-8px_0_24px_rgba(15,23,42,0.04)] transition-[width] duration-200"
|
||||
:class="collapsed ? 'w-14 md:w-14' : 'w-full md:w-72'"
|
||||
class="flex w-full shrink-0 flex-col border-l border-default bg-surface shadow-[-8px_0_24px_rgba(15,23,42,0.04)] transition-[width] duration-200 md:w-60"
|
||||
:class="collapsed ? '!w-14' : ''"
|
||||
data-testid="shipping-workflow-timeline"
|
||||
>
|
||||
<div class="flex w-full items-center gap-1 border-b border-default px-2 py-2">
|
||||
@@ -412,7 +549,10 @@ watch(
|
||||
{{ t('chat.shippingWorkflow.title') }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-xs text-secondary">
|
||||
{{ t('chat.shippingWorkflow.pdfCount', { count: counts.total }) }}
|
||||
{{ t('chat.shippingWorkflow.compactSummary', {
|
||||
active: processingObjects.length,
|
||||
total: counts.total,
|
||||
}) }}
|
||||
</div>
|
||||
</div>
|
||||
<ChevronDown v-if="!collapsed" class="h-4 w-4 shrink-0 text-muted" />
|
||||
@@ -432,95 +572,50 @@ watch(
|
||||
|
||||
<div v-if="!collapsed" class="min-h-0 flex-1 overflow-auto p-3">
|
||||
<div
|
||||
v-if="showBatchSwitcher"
|
||||
class="mb-3 space-y-1.5"
|
||||
data-testid="shipping-workflow-batch-switcher"
|
||||
v-if="focusTaskBanner"
|
||||
class="mb-3 rounded-md border border-brand-200 bg-brand-50 px-2.5 py-2 text-[11px] text-brand-900 dark:border-brand-800 dark:bg-brand-950/40 dark:text-brand-100"
|
||||
data-testid="shipping-focus-task-banner"
|
||||
>
|
||||
<div class="text-[11px] font-semibold uppercase tracking-wide text-secondary">
|
||||
{{ t('chat.shippingWorkflow.batchSwitcherTitle') }}
|
||||
</div>
|
||||
<button
|
||||
v-for="batch in workflows"
|
||||
:key="batch.workflow_no"
|
||||
type="button"
|
||||
class="w-full rounded-lg border px-2.5 py-2 text-left transition"
|
||||
:class="batch.workflow_no === selectedWorkflowNo
|
||||
? 'border-brand-500 bg-brand-50/80 dark:border-brand-400 dark:bg-brand-950/30'
|
||||
: 'border-default bg-surface-soft/80 hover:bg-surface-muted/50'"
|
||||
:data-testid="`shipping-workflow-batch-${batch.workflow_no}`"
|
||||
@click="onSelectWorkflow(batch.workflow_no)"
|
||||
>
|
||||
<div class="truncate text-xs font-semibold text-primary">
|
||||
{{ batch.workflow_no }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-[11px] text-secondary">
|
||||
{{ statusLabel(batch.current_stage) || batch.current_stage }}
|
||||
· {{ t('chat.shippingWorkflow.batchCounts', {
|
||||
processing: batch.counts.processing,
|
||||
pending: batch.counts.pending_review,
|
||||
waiting: batch.counts.waiting_manual_upload || 0,
|
||||
failed: batch.counts.failed,
|
||||
completed: batch.counts.completed,
|
||||
}) }}
|
||||
</div>
|
||||
<div v-if="batch.last_activity_at" class="mt-0.5 text-[11px] text-muted">
|
||||
{{ formatBatchTime(batch.last_activity_at) }}
|
||||
</div>
|
||||
</button>
|
||||
{{ t('chat.shippingWorkflow.focusTaskBanner', { taskNo: focusTaskBanner }) }}
|
||||
</div>
|
||||
|
||||
<label class="mb-3 flex cursor-pointer items-center gap-2 text-[11px] text-secondary">
|
||||
<input
|
||||
v-model="pendingOnlyFilter"
|
||||
type="checkbox"
|
||||
class="rounded border-default"
|
||||
data-testid="shipping-workflow-pending-only-filter"
|
||||
/>
|
||||
{{ t('chat.shippingWorkflow.pendingOnlyFilter') }}
|
||||
</label>
|
||||
|
||||
<div class="mb-3 flex flex-wrap gap-1.5 text-[11px]">
|
||||
<span class="rounded-md bg-sky-50 px-2 py-0.5 text-sky-700 dark:bg-sky-950/40 dark:text-sky-200">
|
||||
{{ t('chat.shippingWorkflow.counts.processing', { count: counts.processing }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="counts.pending_review > 0"
|
||||
class="rounded-md bg-amber-50 px-2 py-0.5 text-amber-700 dark:bg-amber-950/40 dark:text-amber-200"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.counts.pendingReview', { count: counts.pending_review }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="(counts.waiting_manual_upload || 0) > 0"
|
||||
class="rounded-md bg-amber-50 px-2 py-0.5 text-amber-800 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.counts.waitingManualUpload', {
|
||||
count: counts.waiting_manual_upload || 0,
|
||||
}) }}
|
||||
</span>
|
||||
<span class="rounded-md bg-emerald-50 px-2 py-0.5 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-200">
|
||||
{{ t('chat.shippingWorkflow.counts.completed', { count: counts.completed }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="counts.failed > 0"
|
||||
class="rounded-md bg-rose-50 px-2 py-0.5 text-rose-700 dark:bg-rose-950/40 dark:text-rose-200"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.counts.failed', { count: counts.failed }) }}
|
||||
</span>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="mb-3 flex w-full items-center justify-between rounded-md border border-default px-2 py-1.5 text-[11px] text-secondary hover:bg-surface-muted/50"
|
||||
data-testid="shipping-workflow-toggle-details"
|
||||
@click="showExtendedDetails = true"
|
||||
>
|
||||
<span>{{ t('chat.shippingWorkflow.showDetails') }}</span>
|
||||
<ChevronRight class="h-3.5 w-3.5" />
|
||||
</button>
|
||||
|
||||
<div
|
||||
v-if="workflow?.current_stage || workflow?.last_activity_at"
|
||||
class="mb-3 text-[11px] text-secondary"
|
||||
data-testid="shipping-workflow-stage-summary"
|
||||
v-if="processingObjects.length"
|
||||
class="mb-3 space-y-1.5 rounded-lg border border-default bg-surface-soft/60 p-2"
|
||||
data-testid="shipping-processing-objects"
|
||||
>
|
||||
<span v-if="workflow?.current_stage">
|
||||
{{ t('chat.shippingWorkflow.currentStage', {
|
||||
stage: statusLabel(workflow.current_stage) || workflow.current_stage,
|
||||
}) }}
|
||||
</span>
|
||||
<span v-if="workflow?.last_activity_at" class="ml-1">
|
||||
· {{ formatUpdatedLabel(workflow.last_activity_at) }}
|
||||
</span>
|
||||
<div class="text-[11px] font-semibold text-secondary">
|
||||
{{ t('chat.shippingWorkflow.processingObjectsTitle', { count: processingObjects.length }) }}
|
||||
</div>
|
||||
<button
|
||||
v-for="row in processingObjects"
|
||||
:key="row.object_key"
|
||||
type="button"
|
||||
class="flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left text-xs transition"
|
||||
:class="row.focused
|
||||
? 'bg-brand-50 text-brand-800 dark:bg-brand-950/40 dark:text-brand-100'
|
||||
: 'hover:bg-surface-muted/70 text-primary'"
|
||||
:data-testid="`shipping-processing-object-${row.kind}`"
|
||||
@click="onProcessingObjectClick(row)"
|
||||
>
|
||||
<span class="min-w-0 truncate">
|
||||
<span class="font-semibold">{{ row.label }}</span>
|
||||
<span class="ml-1 text-muted">{{ t(`chat.shippingWorkflow.objectKind.${row.kind}`) }}</span>
|
||||
</span>
|
||||
<span class="shrink-0 text-[11px] text-secondary">
|
||||
{{ row.status_label || row.node_status || '' }}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
@@ -537,117 +632,280 @@ watch(
|
||||
{{ error }}
|
||||
</div>
|
||||
|
||||
<div v-if="!filteredItems.length" class="text-xs text-muted">
|
||||
{{ loading ? t('chat.shippingWorkflow.loading') : t('chat.shippingWorkflow.empty') }}
|
||||
<div
|
||||
v-if="!processingObjects.length"
|
||||
class="text-xs text-muted"
|
||||
>
|
||||
{{ loading ? t('chat.shippingWorkflow.loading') : t('chat.shippingWorkflow.emptyCompact') }}
|
||||
</div>
|
||||
|
||||
<template v-for="groupKey in groupOrder" :key="groupKey">
|
||||
<section
|
||||
v-if="grouped[groupKey].length"
|
||||
class="mb-3"
|
||||
:data-testid="`shipping-workflow-group-${groupKey}`"
|
||||
>
|
||||
<h3 class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-secondary">
|
||||
{{ t(`chat.shippingWorkflow.groups.${groupKey}`) }}
|
||||
</h3>
|
||||
<ul class="space-y-2">
|
||||
<li
|
||||
v-for="item in grouped[groupKey]"
|
||||
:key="item.item_no"
|
||||
class="rounded-lg border border-default bg-surface-soft/80 px-2.5 py-2"
|
||||
:data-testid="`shipping-workflow-item-${item.item_no}`"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div
|
||||
class="truncate text-xs font-semibold text-primary"
|
||||
:title="itemTitle(item)"
|
||||
data-testid="shipping-workflow-item-filename"
|
||||
>
|
||||
{{ itemTitle(item) }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-[11px] text-muted">
|
||||
{{ t('chat.shippingWorkflow.versionLabel', { version: item.current_version_no }) }}
|
||||
· {{ statusLabel(String(item.current_stage || item.lifecycle_status || '')) }}
|
||||
<span v-if="!item.current_case_no" class="ml-1 text-secondary">
|
||||
· {{ t('chat.shippingWorkflow.noReviewCaseYet') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium"
|
||||
:class="{
|
||||
'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-100':
|
||||
groupKey === 'pending_review'
|
||||
|| groupKey === 'failed'
|
||||
|| groupKey === 'waiting_manual_upload',
|
||||
'bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-100':
|
||||
groupKey === 'processing' || groupKey === 'queued',
|
||||
'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-100':
|
||||
groupKey === 'completed',
|
||||
}"
|
||||
>
|
||||
{{ statusLabel(String(item.lifecycle_status || '')) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="item.last_activity_at || item.updated_at" class="mt-0.5 text-[11px] text-muted">
|
||||
{{ formatUpdatedLabel(item.last_activity_at || item.updated_at) }}
|
||||
</div>
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="item.process_gate?.current_blocking_gate"
|
||||
class="mt-2"
|
||||
:summary="item.process_gate"
|
||||
:can-handle="true"
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="() => void ctl.refresh()"
|
||||
@refresh-needed="() => void ctl.refresh()"
|
||||
/>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="groupKey === 'pending_review' && item.current_run_no"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-md bg-brand-600 px-2.5 py-1 text-[11px] font-semibold text-white shadow-sm hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-open-review"
|
||||
@click="openReview(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.openReview') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-brand-700 hover:underline"
|
||||
data-testid="shipping-workflow-action-view"
|
||||
@click="openDetail(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.viewProgress') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canReparse(item)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-amber-800 hover:underline disabled:opacity-50 dark:text-amber-200"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-reparse"
|
||||
@click="openReparseDialog(item)"
|
||||
>
|
||||
{{ reparseActionLabel(item) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canCancel(item)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-rose-700 hover:underline disabled:opacity-50"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-cancel"
|
||||
@click="openCancelDialog(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.cancelFile') }}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</template>
|
||||
<!-- 轻量侧栏仅保留阻断 Gate;完整历史列表进抽屉,避免挤压对话区。 -->
|
||||
<div
|
||||
class="space-y-2"
|
||||
data-testid="shipping-workflow-compact-gates"
|
||||
>
|
||||
<ProcessGateRecoveryCard
|
||||
v-for="item in items.filter((row) => row.process_gate?.current_blocking_gate)"
|
||||
:key="`gate-${item.item_no}`"
|
||||
:summary="item.process_gate"
|
||||
:can-handle="true"
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="() => void ctl.refresh()"
|
||||
@refresh-needed="() => void ctl.refresh()"
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 完整详情:body 级遮罩弹层,禁止在侧栏内展开以免压缩对话区。 -->
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="showExtendedDetails"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-6"
|
||||
data-testid="shipping-workflow-details-drawer"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="absolute inset-0 bg-slate-900/45"
|
||||
:aria-label="t('chat.shippingWorkflow.hideDetails')"
|
||||
data-testid="shipping-workflow-details-backdrop"
|
||||
@click="showExtendedDetails = false"
|
||||
/>
|
||||
<section
|
||||
class="relative z-10 flex max-h-[min(88vh,52rem)] w-full max-w-2xl flex-col overflow-hidden rounded-xl border border-default bg-surface shadow-2xl"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
:aria-label="t('chat.shippingWorkflow.detailsDrawerTitle')"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2 border-b border-default px-4 py-3">
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ t('chat.shippingWorkflow.detailsDrawerTitle') }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-[11px] text-secondary">
|
||||
{{ t('chat.shippingWorkflow.detailsDrawerHint') }}
|
||||
· {{ t('chat.shippingWorkflow.compactSummary', {
|
||||
active: processingObjects.length,
|
||||
total: counts.total,
|
||||
}) }}
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-md px-2.5 py-1 text-[11px] font-medium text-secondary hover:bg-surface-muted"
|
||||
data-testid="shipping-workflow-details-close"
|
||||
@click="showExtendedDetails = false"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.hideDetails') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="min-h-0 flex-1 overflow-auto p-4">
|
||||
<div
|
||||
v-if="showBatchSwitcher"
|
||||
class="mb-3 space-y-1.5"
|
||||
data-testid="shipping-workflow-batch-switcher"
|
||||
>
|
||||
<div class="text-[11px] font-semibold uppercase tracking-wide text-secondary">
|
||||
{{ t('chat.shippingWorkflow.batchSwitcherTitle') }}
|
||||
</div>
|
||||
<button
|
||||
v-for="batch in workflows"
|
||||
:key="batch.workflow_no"
|
||||
type="button"
|
||||
class="w-full rounded-lg border px-2.5 py-2 text-left transition"
|
||||
:class="batch.workflow_no === selectedWorkflowNo
|
||||
? 'border-brand-500 bg-brand-50/80 dark:border-brand-400 dark:bg-brand-950/30'
|
||||
: 'border-default bg-surface-soft/80 hover:bg-surface-muted/50'"
|
||||
:data-testid="`shipping-workflow-batch-${batch.workflow_no}`"
|
||||
@click="onSelectWorkflow(batch.workflow_no)"
|
||||
>
|
||||
<div class="truncate text-xs font-semibold text-primary">
|
||||
{{ batch.workflow_no }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-[11px] text-secondary">
|
||||
{{ statusLabel(batch.current_stage) || batch.current_stage }}
|
||||
· {{ t('chat.shippingWorkflow.batchCounts', {
|
||||
processing: batch.counts.processing,
|
||||
pending: batch.counts.pending_review,
|
||||
waiting: batch.counts.waiting_manual_upload || 0,
|
||||
failed: batch.counts.failed,
|
||||
completed: batch.counts.completed,
|
||||
}) }}
|
||||
</div>
|
||||
<div v-if="batch.last_activity_at" class="mt-0.5 text-[11px] text-muted">
|
||||
{{ formatBatchTime(batch.last_activity_at) }}
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<label class="mb-3 flex cursor-pointer items-center gap-2 text-[11px] text-secondary">
|
||||
<input
|
||||
v-model="pendingOnlyFilter"
|
||||
type="checkbox"
|
||||
class="rounded border-default"
|
||||
data-testid="shipping-workflow-pending-only-filter"
|
||||
/>
|
||||
{{ t('chat.shippingWorkflow.pendingOnlyFilter') }}
|
||||
</label>
|
||||
|
||||
<div
|
||||
class="mb-3 flex flex-wrap gap-1.5 text-[11px]"
|
||||
data-testid="shipping-workflow-counts"
|
||||
>
|
||||
<span class="rounded-md bg-sky-50 px-2 py-0.5 text-sky-700 dark:bg-sky-950/40 dark:text-sky-200">
|
||||
{{ t('chat.shippingWorkflow.counts.processing', { count: counts.processing }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="counts.pending_review > 0"
|
||||
class="rounded-md bg-amber-50 px-2 py-0.5 text-amber-700 dark:bg-amber-950/40 dark:text-amber-200"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.counts.pendingReview', { count: counts.pending_review }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="(counts.waiting_manual_upload || 0) > 0"
|
||||
class="rounded-md bg-amber-50 px-2 py-0.5 text-amber-800 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.counts.waitingManualUpload', {
|
||||
count: counts.waiting_manual_upload || 0,
|
||||
}) }}
|
||||
</span>
|
||||
<span class="rounded-md bg-emerald-50 px-2 py-0.5 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-200">
|
||||
{{ t('chat.shippingWorkflow.counts.completed', { count: counts.completed }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="counts.failed > 0"
|
||||
class="rounded-md bg-rose-50 px-2 py-0.5 text-rose-700 dark:bg-rose-950/40 dark:text-rose-200"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.counts.failed', { count: counts.failed }) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="workflow?.current_stage || workflow?.last_activity_at"
|
||||
class="mb-3 text-[11px] text-secondary"
|
||||
data-testid="shipping-workflow-stage-summary"
|
||||
>
|
||||
<span v-if="workflow?.current_stage">
|
||||
{{ t('chat.shippingWorkflow.currentStage', {
|
||||
stage: statusLabel(workflow.current_stage) || workflow.current_stage,
|
||||
}) }}
|
||||
</span>
|
||||
<span v-if="workflow?.last_activity_at" class="ml-1">
|
||||
· {{ formatUpdatedLabel(workflow.last_activity_at) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<template v-for="groupKey in groupOrder" :key="groupKey">
|
||||
<section
|
||||
v-if="grouped[groupKey].length"
|
||||
class="mb-3"
|
||||
:data-testid="`shipping-workflow-group-${groupKey}`"
|
||||
>
|
||||
<h3 class="mb-1.5 text-[11px] font-semibold uppercase tracking-wide text-secondary">
|
||||
{{ t(`chat.shippingWorkflow.groups.${groupKey}`) }}
|
||||
</h3>
|
||||
<ul class="space-y-2">
|
||||
<li
|
||||
v-for="item in grouped[groupKey]"
|
||||
:key="item.item_no"
|
||||
class="rounded-lg border border-default bg-surface-soft/80 px-2.5 py-2"
|
||||
:data-testid="`shipping-workflow-item-${item.item_no}`"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="min-w-0">
|
||||
<div
|
||||
class="truncate text-xs font-semibold text-primary"
|
||||
:title="itemTitle(item)"
|
||||
data-testid="shipping-workflow-item-filename"
|
||||
>
|
||||
{{ itemTitle(item) }}
|
||||
</div>
|
||||
<div class="mt-0.5 text-[11px] text-muted">
|
||||
{{ t('chat.shippingWorkflow.versionLabel', { version: item.current_version_no }) }}
|
||||
· {{ statusLabel(resolveItemDisplayStatus(item)) }}
|
||||
<span v-if="!item.current_case_no" class="ml-1 text-secondary">
|
||||
· {{ t('chat.shippingWorkflow.noReviewCaseYet') }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium"
|
||||
:class="{
|
||||
'bg-amber-100 text-amber-800 dark:bg-amber-900/50 dark:text-amber-100':
|
||||
groupKey === 'pending_review'
|
||||
|| groupKey === 'failed'
|
||||
|| groupKey === 'waiting_manual_upload',
|
||||
'bg-sky-100 text-sky-800 dark:bg-sky-900/50 dark:text-sky-100':
|
||||
groupKey === 'processing' || groupKey === 'queued',
|
||||
'bg-emerald-100 text-emerald-800 dark:bg-emerald-900/50 dark:text-emerald-100':
|
||||
groupKey === 'completed',
|
||||
}"
|
||||
>
|
||||
{{ statusLabel(resolveItemDisplayStatus(item)) }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="item.last_activity_at || item.updated_at" class="mt-0.5 text-[11px] text-muted">
|
||||
{{ formatUpdatedLabel(item.last_activity_at || item.updated_at) }}
|
||||
</div>
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="item.process_gate?.current_blocking_gate"
|
||||
class="mt-2"
|
||||
:summary="item.process_gate"
|
||||
:can-handle="true"
|
||||
:navigation-context="gateNavigationContext"
|
||||
@refreshed="() => void ctl.refresh()"
|
||||
@refresh-needed="() => void ctl.refresh()"
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
<div class="mt-2 flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="groupKey === 'pending_review' && item.current_run_no"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-md bg-brand-600 px-2.5 py-1 text-[11px] font-semibold text-white shadow-sm hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-open-review"
|
||||
@click="openReview(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.openReview') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-brand-700 hover:underline"
|
||||
data-testid="shipping-workflow-action-view"
|
||||
@click="openDetail(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.viewProgress') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canReparse(item)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-amber-800 hover:underline disabled:opacity-50 dark:text-amber-200"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-reparse"
|
||||
@click="openReparseDialog(item)"
|
||||
>
|
||||
{{ reparseActionLabel(item) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canCancel(item)"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 text-[11px] font-medium text-rose-700 hover:underline disabled:opacity-50"
|
||||
:disabled="actionBusyItemNo === item.item_no"
|
||||
data-testid="shipping-workflow-action-cancel"
|
||||
@click="openCancelDialog(item)"
|
||||
>
|
||||
{{ t('chat.shippingWorkflow.actions.cancelFile') }}
|
||||
</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</Teleport>
|
||||
|
||||
<ShippingWorkflowItemDetailDrawer
|
||||
:open="detailOpen"
|
||||
:item="detailItem"
|
||||
@@ -657,6 +915,8 @@ watch(
|
||||
@close="detailOpen = false; detailItem = null"
|
||||
@cancel="openCancelDialog"
|
||||
@reparse="openReparseDialog"
|
||||
@refreshed="() => void ctl.refresh()"
|
||||
@confirm-customer="(taskNo) => void onGateConfirmCustomer(taskNo)"
|
||||
/>
|
||||
|
||||
<ShippingWorkflowReasonDialog
|
||||
|
||||
Reference in new issue
Block a user