perf(shipping-notice): 优化发货任务性能,修复上传流程与终态问题
This commit is contained in:
1 parent
434c04ed2d
commit
bcdd8285ae
29 files changed
+1074
-128
No files matched your search
+23
@@ -111,6 +111,29 @@ describe('ReviewLifecycleStageNavigation', () => {
|
||||
expect(stage.find('[data-testid="review-lifecycle-stage-spinner"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('renders the current upload-complete stage as completed instead of running', () => {
|
||||
const wrapper = mount(ReviewLifecycleStageNavigation, {
|
||||
props: {
|
||||
stages: [
|
||||
{ code: 'intake_parse', label: '接收解析', state: 'completed' },
|
||||
{ code: 'order_review', label: '订单复核', state: 'completed' },
|
||||
{ code: 'fulfillment_prep', label: '通知准备', state: 'completed' },
|
||||
{ code: 'freight_upload', label: '货代上传', state: 'completed' },
|
||||
{ code: 'upload_complete', label: '通知完成', state: 'current' },
|
||||
],
|
||||
activeCode: 'upload_complete',
|
||||
// 迟到的运行态不能覆盖后端已裁决的通知完成终态。
|
||||
processingCode: 'upload_complete',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
const stage = wrapper.get('[data-testid="review-lifecycle-stage-upload_complete"]');
|
||||
expect(stage.find('.text-emerald-600').exists()).toBe(true);
|
||||
expect(stage.find('.bg-brand-600').exists()).toBe(false);
|
||||
expect(stage.find('[data-testid="review-lifecycle-stage-spinner"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('disables a future stage and does not emit a selection', async () => {
|
||||
const wrapper = mountNavigation();
|
||||
const future = wrapper.get('[data-testid="review-lifecycle-stage-upload_complete"]');
|
||||
|
||||
+15
-7
@@ -42,8 +42,16 @@ function canRetryParse(stage: ReviewLifecycleStageItem): boolean {
|
||||
&& (props.availableActions || []).includes('retry_parse');
|
||||
}
|
||||
|
||||
/** 通知完成是当前生命周期终态,不是仍在执行的当前工作阶段。 */
|
||||
function isCompletedStage(stage: ReviewLifecycleStageItem): boolean {
|
||||
return stage.state === 'completed' || (
|
||||
stage.code === 'upload_complete' && stage.state === 'current'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 阶段导航只允许进入当前或已完成阶段;blocked 仅说明前置条件,不替代后端 Gate 判定。
|
||||
* 阶段导航只允许进入后端下发为 current / available / completed 的阶段;
|
||||
* blocked 仅说明前置条件,不替代后端 Gate 判定。
|
||||
*/
|
||||
function selectStage(stage: ReviewLifecycleStageItem) {
|
||||
if (stage.state === 'blocked') return;
|
||||
@@ -73,12 +81,12 @@ function selectStage(stage: ReviewLifecycleStageItem) {
|
||||
>
|
||||
<span class="flex items-center gap-2 text-sm font-semibold">
|
||||
<RefreshCw
|
||||
v-if="stage.code === props.processingCode"
|
||||
v-if="stage.code === props.processingCode && !isCompletedStage(stage)"
|
||||
class="h-4 w-4 shrink-0 animate-spin text-brand-600"
|
||||
data-testid="review-lifecycle-stage-spinner"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Check v-if="stage.state === 'completed'" class="h-4 w-4 shrink-0 text-emerald-600" />
|
||||
<Check v-if="isCompletedStage(stage)" class="h-4 w-4 shrink-0 text-emerald-600" />
|
||||
<LockKeyhole v-else-if="stage.state === 'blocked'" class="h-4 w-4 shrink-0 text-muted" />
|
||||
<span v-else class="h-2 w-2 shrink-0 rounded-full bg-brand-600" aria-hidden="true" />
|
||||
<button
|
||||
@@ -96,13 +104,13 @@ function selectStage(stage: ReviewLifecycleStageItem) {
|
||||
:disabled="stage.state === 'blocked'"
|
||||
@click="selectStage(stage)"
|
||||
>
|
||||
{{ stage.state === 'current'
|
||||
{{ isCompletedStage(stage)
|
||||
? $t('chat.shippingOrderReview.lifecycle.completed')
|
||||
: stage.state === 'current'
|
||||
? (stage.code === props.processingCode
|
||||
? $t('chat.shippingOrderReview.lifecycle.processing')
|
||||
: $t('chat.shippingOrderReview.lifecycle.current'))
|
||||
: stage.state === 'completed'
|
||||
? $t('chat.shippingOrderReview.lifecycle.completed')
|
||||
: (stage.reason || $t('chat.shippingOrderReview.lifecycle.blocked')) }}
|
||||
: (stage.reason || $t('chat.shippingOrderReview.lifecycle.blocked')) }}
|
||||
</button>
|
||||
<button
|
||||
v-if="canRetryParse(stage)"
|
||||
|
||||
@@ -353,6 +353,36 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).not.toContain('stale.pdf');
|
||||
});
|
||||
|
||||
it('renders a completed non-order attachment without a spinner', async () => {
|
||||
const child = {
|
||||
workItemNo: 'DOCUMENT:NON-ORDER', sourceSummary: { filename: 'not-an-order.pdf', documentId: 1 },
|
||||
status: 'completed', stage: 'completed', userStatus: 'completed', userStage: 'completed',
|
||||
facts: { uploadState: 'not_created' }, uiState: { status: 'completed', stage: 'completed' },
|
||||
} as any;
|
||||
const task = {
|
||||
user_task_no: 'INTAKE:SNI-NON-ORDER', title: 'mail.eml', file_count: 1,
|
||||
userGroup: 'completed', group: 'completed', aggregateChildren: [child],
|
||||
aggregateSummary: { intakeNo: 'SNI-NON-ORDER', total: 1, completed: 1, processing: 0, needsAction: 0, failed: 0, stages: ['completed'], reasonCodes: [] },
|
||||
} as any;
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState({ status: 'completed' }) },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: {
|
||||
processing: ref({
|
||||
ui_state: { status: 'completed' },
|
||||
summary: { total_files: 1, completed_files: 1, waiting_human_files: 0, failed_files: 0 },
|
||||
status_groups: { failed: [], waiting_human: [], processing: [], completed: [task], cancelled: [], archived: [] },
|
||||
}),
|
||||
processingWorkItems: ref([]),
|
||||
} } },
|
||||
});
|
||||
|
||||
await wrapper.get('[data-testid="shipping-order-extraction-status-groups"] section button').trigger('click');
|
||||
await wrapper.get('[data-testid="shipping-order-extraction-eml-completed-INTAKE:SNI-NON-ORDER"] button').trigger('click');
|
||||
|
||||
expect(wrapper.findAll('.animate-spin')).toHaveLength(0);
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-child-status-DOCUMENT:NON-ORDER"]').text()).not.toContain('处理中');
|
||||
});
|
||||
|
||||
it('uses the authoritative attachment total when a historical message only carries the EML task count', () => {
|
||||
const task = {
|
||||
user_task_no: 'INTAKE:SNI-MAILS', title: 'mail-batch.eml', file_count: 30,
|
||||
|
||||
@@ -126,6 +126,7 @@ function taskFileCount(task: { aggregateChildren?: ShippingProcessingProjection[
|
||||
function childStatusLabel(child: ShippingProcessingProjection) {
|
||||
const status = displayProjectionStatus(child);
|
||||
if (status === 'completed' && child.facts?.uploadState === 'succeeded') return t('chat.shippingProcessing.aggregate.completed', { count: 1 });
|
||||
if (status === 'completed') return t('chat.shippingProcessing.groupRecordCompleted');
|
||||
if (status === 'failed' || status === 'retryable') return t('chat.shippingProcessing.aggregate.failed', { count: 1 });
|
||||
if (status === 'waiting_human') return t('chat.shippingProcessing.aggregate.needsAction', { count: 1 });
|
||||
return t('chat.shippingProcessing.aggregate.processing', { count: 1 });
|
||||
@@ -149,7 +150,7 @@ function isWaitingProjection(item: ShippingProcessingProjection): boolean {
|
||||
return displayProjectionStatus(item) === 'waiting_human';
|
||||
}
|
||||
function isCompletedProjection(item: ShippingProcessingProjection): boolean {
|
||||
return displayProjectionStatus(item) === 'completed' && item.facts?.uploadState === 'succeeded';
|
||||
return displayProjectionStatus(item) === 'completed';
|
||||
}
|
||||
function taskReason(task: { uiState?: { blocking_reason: import('../../types/shipping.api.types').ShippingProcessingBlockingReason | null }; blockingReason?: import('../../types/shipping.api.types').ShippingProcessingBlockingReason | null }) {
|
||||
return task.uiState ? task.uiState.blocking_reason : task.blockingReason;
|
||||
@@ -223,6 +224,7 @@ function aggregateStageLabel(item: ShippingProcessingProjection): string {
|
||||
function aggregateChildStatusLabel(item: ShippingProcessingProjection): string {
|
||||
const status = displayProjectionStatus(item);
|
||||
if (status === 'completed' && item.facts?.uploadState === 'succeeded') return t('chat.shippingProcessing.aggregate.completed', { count: 1 });
|
||||
if (status === 'completed') return t('chat.shippingProcessing.groupRecordCompleted');
|
||||
if (status === 'failed' || status === 'retryable') return t('chat.shippingProcessing.aggregate.failed', { count: 1 });
|
||||
if (status === 'waiting_human') return t('chat.shippingProcessing.aggregate.needsAction', { count: 1 });
|
||||
return t('chat.shippingProcessing.aggregate.processing', { count: 1 });
|
||||
@@ -654,7 +656,7 @@ async function onPrimaryChatAction() {
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="flex items-center gap-2 text-lg font-semibold">
|
||||
<LoaderCircle v-if="hasConversationStatusGroups ? conversationProcessing?.ui_state?.status === 'running' : emlAggregate ? emlAggregate.userStatus === 'running' : state.status === 'queued' || state.status === 'processing'" class="h-5 w-5 animate-spin text-blue-600" />
|
||||
<CheckCircle2 v-else-if="hasConversationStatusGroups ? conversationProcessing?.ui_state?.status === 'completed' : emlAggregate ? emlAggregate.userStatus === 'completed' && emlAggregate.facts?.uploadState === 'succeeded' : state.status === 'completed'" class="h-5 w-5 text-emerald-500" />
|
||||
<CheckCircle2 v-else-if="hasConversationStatusGroups ? conversationProcessing?.ui_state?.status === 'completed' : emlAggregate ? emlAggregate.userStatus === 'completed' : state.status === 'completed'" class="h-5 w-5 text-emerald-500" />
|
||||
<TriangleAlert v-else class="h-5 w-5 text-amber-500" />
|
||||
<span>{{ t('chat.shippingProcessing.multiPdfTaskTitle') }}</span>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user