!15 perf(shipping-notice): 优化发货任务性能,修复上传流程与终态问题

Merge pull request !15 from 曹惠鹏/hugo-shipping-notice
This commit is contained in:
sophie authored and Gitee committed 2026-08-27 11:40:31 +00:00
commit 09deada712
29 files changed
+1074 -128

No files matched your search

@@ -16,8 +16,63 @@ vi.mock('@/shared/api/client', () => ({
import {
getWorkspaceShippingOrderExtractionRun,
getWorkspaceShippingProcessing,
getWorkspaceShippingTask,
} from './shipping.api';
describe('getWorkspaceShippingTask', () => {
beforeEach(() => {
requestJson.mockReset();
});
it('coalesces concurrent reads of the same task detail into one HTTP request', async () => {
let resolveRequest!: (value: { task_no: string }) => void;
requestJson.mockImplementationOnce(() => new Promise((resolve) => {
resolveRequest = resolve;
}));
const first = getWorkspaceShippingTask('SN-DEDUPE-1');
const second = getWorkspaceShippingTask('SN-DEDUPE-1');
// 关键断言:重型任务详情在途时,同 task_no 的并行消费者(工作台 loadFormalTaskDetail
// 与对话侧 syncActiveShippingTaskDetail)必须复用一个网络请求,禁止重复拉取。
expect(requestJson).toHaveBeenCalledTimes(1);
resolveRequest({ task_no: 'SN-DEDUPE-1' });
await expect(Promise.all([first, second])).resolves.toEqual([
{ task_no: 'SN-DEDUPE-1' },
{ task_no: 'SN-DEDUPE-1' },
]);
});
it('does not cache a completed task detail across a later read', async () => {
requestJson.mockResolvedValueOnce({ task_no: 'SN-FRESH-1' });
requestJson.mockResolvedValueOnce({ task_no: 'SN-FRESH-1' });
// 单飞去重只合并「在途」请求;完成后不得返回过期快照,保证 Gate 动作后的新鲜重读。
await getWorkspaceShippingTask('SN-FRESH-1');
await getWorkspaceShippingTask('SN-FRESH-1');
expect(requestJson).toHaveBeenCalledTimes(2);
});
it('keys dedup by view so workbench and full projections do not merge', async () => {
requestJson.mockResolvedValue({ task_no: 'SN-VIEW-1' });
// 关键断言:workbench(裁剪)与 full 是两个不同响应体,缺省 view 与 view=workbench
// 共享同一个 task_no 时不能合并成一个请求,否则会把裁剪版响应交给 full 消费者。
const full = getWorkspaceShippingTask('SN-VIEW-1');
const wb = getWorkspaceShippingTask('SN-VIEW-1', { view: 'workbench' });
const wbAgain = getWorkspaceShippingTask('SN-VIEW-1', { view: 'workbench' });
// 两个视图各一次、workbench 同视图合并:共 2 次底层请求。
expect(requestJson).toHaveBeenCalledTimes(2);
expect(requestJson).toHaveBeenNthCalledWith(1, '/api/workspace/shipping-tasks/SN-VIEW-1');
expect(requestJson).toHaveBeenNthCalledWith(
2,
'/api/workspace/shipping-tasks/SN-VIEW-1?view=workbench',
);
await Promise.allSettled([full, wb, wbAgain]);
});
});
describe('getWorkspaceShippingOrderExtractionRun', () => {
beforeEach(() => {
requestJson.mockReset();
+39 -3
View File
@@ -118,9 +118,45 @@ export const listWorkspaceShippingTasks = (params?: {
/** 拉取用户可见 Agent 列表,供发货工作台跳转 Chat 时定位目标 Agent。 */
export const listShippingChatAgents = () => requestJson<ShippingChatAgentOption[]>('/api/agents');
/** 获取单个发货任务详情。 */
export const getWorkspaceShippingTask = (taskNo: string) =>
requestJson<ShippingTaskDetail>(`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}`);
/** 任务详情单飞去重:同一瞬间并发的同一 task_no 详情只发一次网络请求。
* [PERF] 订单生命周期工作台首屏会由 hasFormalOt / confirmedNoticeTaskNo 两个
* immediate watcher 同时触发 loadFormalTaskDetail,加上对话侧 syncActiveShippingTaskDetail,
* 会在同一时刻并发拉取同一任务详情;单飞将多次并发请求合并为一次,
* 显著削减 /shipping-tasks/:task_no 的重型重复请求。
* 只对「在途」请求去重、不缓存完成结果:保留 Gate 动作后的新鲜重读,
* 避免把写操作后的过期详情误当作最新状态。
* 去重键含 view:workbench(裁剪)与 full 是两个不同响应体,不能相互合并。 */
export type ShippingTaskDetailView = 'full' | 'workbench';
const shippingTaskDetailRequests = new Map<string, Promise<ShippingTaskDetail>>();
/** 获取单个发货任务详情。@param options.view 「workbench」返回订单生命周期工作台首屏裁剪版。 */
export const getWorkspaceShippingTask = (
taskNo: string,
options?: { view?: ShippingTaskDetailView },
) => {
const normalized = String(taskNo || '').trim();
if (!normalized) {
return Promise.reject(new BusinessError({
message: 'task_no is required',
code: 'SHIPPING.TASK_REQUIRED',
status: 400,
}));
}
const view = options?.view === 'workbench' ? 'workbench' : 'full';
const cacheKey = `${normalized}|${view}`;
const existing = shippingTaskDetailRequests.get(cacheKey);
if (existing) return existing;
const url = view === 'workbench'
? `/api/workspace/shipping-tasks/${encodeURIComponent(normalized)}?view=workbench`
: `/api/workspace/shipping-tasks/${encodeURIComponent(normalized)}`;
const request = requestJson<ShippingTaskDetail>(url).finally(() => {
if (shippingTaskDetailRequests.get(cacheKey) === request) {
shippingTaskDetailRequests.delete(cacheKey);
}
});
shippingTaskDetailRequests.set(cacheKey, request);
return request;
};
/** 读取当前 PO 下按 business_no 聚合的货代上传 Notice。 */
export const getWorkspaceShippingFreightNoticeGroups = (taskNo: string) =>
@@ -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"]');
@@ -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>
@@ -522,7 +522,8 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
showWorkflowProgress.value = true;
workflowProgressPolling.value = true;
// RPA 超时、可重试失败和人工复核都可能被后续回调推进,页面留存期间持续读取 Projection。
const UNIFIED_TERMINAL = new Set(['completed', 'cancelled']);
// needs_human(等待人工)视为线性终态:结果不会自行变化,继续轮询浪费资源。
const UNIFIED_TERMINAL = new Set(['completed', 'cancelled', 'needs_human']);
let lastUnifiedStatus = '';
let lastLifecycleFingerprint = '';
const RUN_TERMINAL = new Set(['completed', 'partially_completed', 'failed', 'cancelled']);
@@ -153,6 +153,26 @@ describe('useShippingNoticeWorkflow helpers', () => {
history: [],
})).toBe(true);
});
it('keeps polling after an RPA upload succeeds while a later task step is processing', () => {
expect(shouldContinueProcessingPolling({
summary: { total_tasks: 1, processing: 1, needs_action: 0, history: 0 },
processing: [{
user_task_no: 'OT-RPA-SUCCEEDED',
group: 'processing',
can_append: false,
status_label: 'processing',
ui_state: {
status: 'running',
stage: 'post_upload_processing',
lifecycle_stage: 'freight_upload',
},
facts: { upload_state: 'succeeded' },
}],
needs_action: [],
history: [],
})).toBe(true);
});
});
describe('useShippingNoticeWorkflow', () => {
@@ -663,6 +663,8 @@ async function mountView(query: Record<string, string> = {}) {
uploadComplete: {
title: '通知完成',
subtitle: '上传成功证据已核验。',
uploadModeManual: '人工确认',
uploadModeRpa: 'RPA 上传',
},
upload: {
receipt: '货代回执:{value}',
@@ -2830,7 +2832,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
po_number: 'PO-100',
items: [
{ business_no: 'WYC26082401', po_number: 'PO-100', upload_status: 'uploaded', export_file_name: 'WYC26082401.xlsx', lines: [
{ business_no: 'WYC26082401', po_number: 'PO-100', upload_status: 'uploaded', upload_mode: 'manual', export_file_name: 'WYC26082401.xlsx', lines: [
{ line_no: '00010', part_number: 'PART-A', reservation_id: 'RSV-A', qty: '2' },
] },
{ business_no: 'WYC26082402', po_number: 'PO-100', upload_status: 'pending', export_file_name: 'WYC26082402.xlsx', lines: [] },
@@ -2847,8 +2849,44 @@ describe('ShippingOrderReviewView layout phase 1', () => {
// 人工确认不再展示或依赖货代回执号,即使历史投影仍带有 freight_ref_no。
expect(evidence.text()).not.toContain('LEGACY-REF-MUST-NOT-BE-SHOWN');
expect(evidence.text()).not.toContain('LATEST-FAILED');
// 上传来源徽标:成功事实取自 ShippingUploadAttempt 的 mode=manual。
expect(wrapper.find('[data-testid="review-upload-complete-mode"]').text()).toContain(
'人工确认',
);
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
expect(wrapper.get('[data-testid="review-current-processing-card"]').text()).toContain('已完成');
expect(wrapper.get('[data-testid="review-current-processing-card"]').text()).not.toContain('状态待确认');
expect(wrapper.find('[data-testid="review-current-task-next-step-section"]').exists()).toBe(false);
});
it('allows inspecting a completed order-review stage without allowing edits', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-COMPLETED-REVIEW', confirmed_task_id: 23, has_formal_ot: true,
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-COMPLETED-REVIEW', status: 'completed', upload_status: 'uploaded', lines: [], events: [],
ui_state: {
lifecycle_stage: 'upload_complete',
lifecycle_entries: [
{ code: 'intake_parse', state: 'available' },
{ code: 'order_review', state: 'available' },
{ code: 'fulfillment_prep', state: 'available' },
{ code: 'freight_upload', state: 'available' },
{ code: 'upload_complete', state: 'current' },
],
actions: { primary: null, secondary: [] }, summary: {}, steps: [],
},
} as any);
const wrapper = await mountView({ lifecycle_stage: 'order_review' });
await flushPromises();
expect(wrapper.find('[data-testid="review-editor-body"]').exists()).toBe(true);
expect(wrapper.get('[data-testid="shipping-order-review-view"]').attributes('data-readonly')).toBe('true');
expect(wrapper.find('[data-testid="review-header-field-input"]').attributes('disabled')).toBeDefined();
});
it('aggregates freight upload by business_no and keeps one Excel action per notice', async () => {
@@ -2907,22 +2945,46 @@ describe('ShippingOrderReviewView layout phase 1', () => {
await flushPromises();
await wrapper.get('[aria-label="WYC26082411"]').setValue(true);
await wrapper.get('[aria-label="WYC26082412"]').setValue(true);
const buttons = wrapper.get('[data-testid="review-freight-upload-batch-toolbar"]').findAll('button');
await buttons[0].trigger('click');
await wrapper.get('[data-testid="review-freight-upload-batch-toolbar"]').find('button').trigger('click');
await flushPromises();
expect(downloadFreightArchiveMock).toHaveBeenCalledWith(['WYC26082411', 'WYC26082412']);
await wrapper.get('[aria-label="WYC26082411"]').setValue(true);
await wrapper.get('[aria-label="WYC26082412"]').setValue(true);
await buttons[1].trigger('click');
await wrapper.get('[data-testid="review-freight-upload-batch-rpa"]').trigger('click');
await flushPromises();
expect(batchRpaFreightMock).toHaveBeenCalledWith(['WYC26082411', 'WYC26082412']);
await wrapper.get('[aria-label="WYC26082411"]').setValue(true);
await wrapper.get('[aria-label="WYC26082412"]').setValue(true);
await buttons[2].trigger('click');
await wrapper.get('[data-testid="review-freight-upload-batch-confirm"]').trigger('click');
await flushPromises();
expect(batchConfirmFreightMock).toHaveBeenCalledWith(['WYC26082411', 'WYC26082412']);
});
it('disables upload batch actions and hides more actions when an uploaded notice is selected', async () => {
activeCase.value = { ...activeCase.value, status: 'confirmed', confirmed_task_no: 'SN-PO-UPLOADED', confirmed_task_id: 24, has_formal_ot: true };
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-PO-UPLOADED', status: 'processing', lines: [], events: [],
ui_state: { lifecycle_stage: 'freight_upload', lifecycle_entries: [], actions: { primary: null, secondary: [] }, stage_context: { upload: {} } },
} as any);
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
po_number: 'PO-UPLOADED', items: [
{ business_no: 'WYC-UPLOADED', po_number: 'PO-UPLOADED', upload_status: 'uploaded', lines: [] },
{ business_no: 'WYC-PENDING', po_number: 'PO-UPLOADED', upload_status: 'pending', lines: [] },
],
} as any);
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
await flushPromises();
await wrapper.get('[aria-label="WYC-UPLOADED"]').setValue(true);
await wrapper.get('[aria-label="WYC-PENDING"]').setValue(true);
// 已上传项混入选择集时,批量写入不允许部分静默提交,必须让用户显式取消选择。
expect(wrapper.get('[data-testid="review-freight-upload-batch-rpa"]').attributes('disabled')).toBeDefined();
expect(wrapper.get('[data-testid="review-freight-upload-batch-confirm"]').attributes('disabled')).toBeDefined();
expect(wrapper.findAll('[data-testid="review-freight-upload-more"]')).toHaveLength(0);
});
it('does not place internal inventory hint fields in the primary line table', async () => {
const wrapper = await mountView();
const inputs = wrapper.findAll('[data-testid="review-line-field-input"]');
@@ -198,6 +198,11 @@ const msg = useMessage();
* 无论哪一路都带 label_key,禁止把 code 当用户文案。
*/
const currentProcessingStageDisplay = computed(() => {
// 正式任务已明确通知完成时,该终态优先于可能迟到的 Processing 投影,
// 右侧不能再退化为“处理中 / 待机”。此处直接读取详情,避免引用后方生命周期 computed。
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') {
return { code: 'completed', labelKey: 'completed', inconsistent: false };
}
const projection = shippingProcessingProjection.value;
if (projection?.stage) {
return {
@@ -309,7 +314,10 @@ const lifecycleActiveStageCode = computed<ReviewLifecycleStageCode | null>(() =>
if (requested === 'intake_parse' && lifecycleUiState.value.intakeParseAuthorized === true) {
return 'intake_parse';
}
return lifecycleEntryIsEnterable(entry) ? requested : lifecycleCurrentStageCode.value;
const current = lifecycleCurrentStageCode.value;
// 用户可回看后端已授权的 available 前置阶段;自动推进由下方 watcher 在
// 「路由仍停留原 current 阶段且用户未固定查看」时处理,不能在这里抢占用户选择。
return lifecycleEntryIsEnterable(entry) ? requested : current;
});
/** 当前后端投影明确在自动推进时,五阶段导航只为该阶段展示 Spinner,不改变授权。 */
const lifecycleProcessingStageCode = computed<ReviewLifecycleStageCode | null>(() => {
@@ -376,6 +384,17 @@ const isLifecycleIntakeParse = computed(() => (
const isLifecycleFulfillmentPrep = computed(() => lifecycleActiveStageCode.value === 'fulfillment_prep');
const isLifecycleFreightUpload = computed(() => lifecycleActiveStageCode.value === 'freight_upload');
const isLifecycleUploadComplete = computed(() => lifecycleActiveStageCode.value === 'upload_complete');
/** 正式任务已通知完成时,即使用户回看前置阶段也只能查看,不能再修改已产出通知。 */
const isCompletedFormalTask = computed(() => lifecycleCurrentStageCode.value === 'upload_complete');
const isReviewContentReadOnly = computed(() => isReadOnly.value || isCompletedFormalTask.value);
/**
* 统一字段写权限,确保通知完成后的前置阶段回看不会绕过只读边界。
* @param fieldId - 后端 Schema 下发的字段标识。
* @returns 当前字段是否允许编辑。
*/
function canEditReviewField(fieldId: string): boolean {
return !isReviewContentReadOnly.value && isFieldEditable(fieldId);
}
/** 当前阶段重试只取 Case 的服务端授权,不从输入框附件卡或本地状态推断。 */
const intakeParseRetryAvailable = computed(() => (
isLifecycleIntakeParse.value
@@ -451,7 +470,7 @@ async function syncPendingReleaseAutoAdvance(): Promise<boolean> {
async function selectLifecycleStage(code: ReviewLifecycleStageCode, options: { replace?: boolean } = {}) {
const target = lifecycleStageItems.value.find((item) => item.code === code);
if (!target || target.state === 'blocked') return;
// 用户主动回看已完成阶段时,异步投影抵达不得将其强制带回当前阶段。
// 用户主动回看后端 available 或已完成阶段时,异步投影抵达不得将其强制带回当前阶段。
// 自动推进均使用 replace,不会写入该意图。
if (!options.replace) {
const caseNo = String(activeCase.value?.case_no || '').trim() || null;
@@ -675,6 +694,7 @@ const currentTaskPrimaryAction = computed(() => {
return null;
});
const currentTaskUserStatus = computed(() => {
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') return 'completed';
// 已确认 OT 且权威投影在途时,先消费后端 automation 运行态(queued/running → running,
// failed/manual_fallback → failed),状态行即显真实值,不应退回「正在获取最新状态」骨架;
// authority 仍以右侧投影为准,投影到达后覆盖。
@@ -686,11 +706,13 @@ const currentTaskUserStatus = computed(() => {
return null;
});
const currentTaskBlockingReason = computed(() => {
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') return null;
if (formalTaskProjectionPending.value) return null;
return currentTaskUiState.value?.blocking_reason ?? null;
});
/** 当前 Gate 状态必须与右栏动作同源,均来自统一处理 Projection。 */
const currentTaskGateStatus = computed(() => {
if (formalTaskDetail.value?.ui_state?.lifecycle_stage === 'upload_complete') return null;
if (formalTaskProjectionPending.value) return null;
const projection = shippingProcessingProjection.value;
if (projection?.currentGate?.status) return projection.currentGate.status;
@@ -728,13 +750,13 @@ const currentTaskRecoveryActions = computed(() => {
* @returns 当前工作面允许交给 ReviewCurrentProcessingCard 展示的动作。
*/
const visibleCurrentTaskPrimaryAction = computed(() => (
isLifecycleUploadComplete.value ? null : currentTaskPrimaryAction.value
isCompletedFormalTask.value ? null : currentTaskPrimaryAction.value
));
const visibleCurrentTaskRecoveryActions = computed(() => (
isLifecycleUploadComplete.value ? [] : currentTaskRecoveryActions.value
isCompletedFormalTask.value ? [] : currentTaskRecoveryActions.value
));
const visibleCurrentTaskRetryable = computed(() => (
isLifecycleUploadComplete.value ? false : currentTaskRetryable.value
isCompletedFormalTask.value ? false : currentTaskRetryable.value
));
/** 管理员诊断:后端 technical_progress / automation.technical 仅 admin 投影。 */
@@ -1156,6 +1178,8 @@ const onExceptionNavKeydown = (event: KeyboardEvent) => {
onMounted(() => {
document.addEventListener('keydown', onExceptionNavKeydown, true);
// [PERF] 深链进入时尽早并行发起任务详情,与 load() 重叠,削减首屏串行加载。
prefetchDeepLinkedTaskDetail();
});
onBeforeUnmount(() => {
@@ -1899,9 +1923,9 @@ const canEnterInventory = computed(() => {
});
const availableActions = computed(() => activeCase.value?.available_actions || []);
/** 订单处理工作台写权限(只读查看 / Case 切换中为 false)。 */
/** 订单处理工作台写权限(历史查看、通知完成回看或 Case 切换中均为 false)。 */
const workbenchActionsExecutable = computed(() => (
!isReadOnly.value
!isReviewContentReadOnly.value
&& !runLoading.value
&& !caseSwitchLoading.value
&& !progressRetrying.value
@@ -2246,6 +2270,19 @@ const formalTaskDetailLoadFailed = ref(false);
*/
let formalTaskDetailGeneration = 0;
const manualUploadRegistrationOpen = ref(false);
/** 深链预取:批次进度中心已带 task_no 时,挂载即并行发起任务详情读取,与 load() 重叠。
* [PERF] 订单生命周期工作台首屏的关键路径是 load() 完成后才轮到 loadFormalTaskDetail
* (getWorkspaceShippingTask)。提前发起让这两个重型请求并行,消除串行叠加;
* 结果仅在被 loadFormalTaskDetail 认领且任务号一致时使用,避免双源身份。 */
const deepLinkTaskPrefetch = ref<{ taskNo: string; promise: Promise<ShippingTaskDetail | null> } | null>(null);
function prefetchDeepLinkedTaskDetail() {
const taskNo = String(route.query.task_no || route.query.task_id || '').trim();
if (!taskNo) return;
const promise = getWorkspaceShippingTask(taskNo, { view: 'workbench' })
.then((detail) => detail)
.catch(() => null);
deepLinkTaskPrefetch.value = { taskNo, promise };
}
/**
* 通知准备优先消费正式任务 ui_state;详情摘要暂时为空时,仅回退到当前 Case 的
@@ -2462,10 +2499,28 @@ async function loadFormalTaskDetail() {
if (formalTaskDetail.value?.task_no !== taskNo) {
formalTaskDetail.value = null;
}
// [PERF] 复用深链预取的任务详情:首次进入时它与 load() 并行发起,避免任务详情在
// load() 完成之后再串行重拉;仅当预取与当前确认任务号一致时使用,用完即清空,
// 后续 Gate 动作后的写后刷新仍走正常网络读取,保证新鲜度。
const prefetch = deepLinkTaskPrefetch.value;
if (prefetch && prefetch.taskNo === taskNo) {
deepLinkTaskPrefetch.value = null;
const prefetched = await prefetch.promise;
if (
prefetched
&& String(prefetched.task_no || '').trim() === taskNo
&& generation === formalTaskDetailGeneration
) {
formalTaskDetail.value = prefetched;
formalTaskDetailLoadFailed.value = false;
formalTaskDetailLoading.value = false;
return;
}
}
formalTaskDetailLoadFailed.value = false;
formalTaskDetailLoading.value = true;
try {
const detail = await getWorkspaceShippingTask(taskNo);
const detail = await getWorkspaceShippingTask(taskNo, { view: 'workbench' });
if (generation !== formalTaskDetailGeneration) return;
// 同代也必须核对任务身份;服务端异常返回或旧请求均不能成为当前生命周期事实。
if (String(detail?.task_no || '').trim() !== taskNo) {
@@ -2511,12 +2566,83 @@ async function loadFreightNoticeGroups(taskNo: string) {
}
}
// [STEP] 货代上传面板独立、轻量轮询(解耦):仅货代上传工作面激活时每 5s 重拉,达到终态即停。
// 各数据源独立轮询,避免把两个网络请求串进同一个 tick(串行 await 会拖慢单个轮询)。
const FREIGHT_GROUPS_POLL_MS = 5000;
const freightGroupsPollTimer = ref<ReturnType<typeof window.setInterval> | null>(null);
function stopFreightGroupsPolling() {
if (freightGroupsPollTimer.value != null) {
window.clearInterval(freightGroupsPollTimer.value);
freightGroupsPollTimer.value = null;
}
}
function startFreightGroupsPolling() {
stopFreightGroupsPolling();
if (!isLifecycleFreightUpload.value) return;
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
if (!taskNo) return;
const tick = () => {
if (freightNoticeGroupsLoading.value) return;
const no = String(confirmedNoticeTaskNo.value || '').trim();
if (no) void loadFreightNoticeGroups(no);
};
tick();
freightGroupsPollTimer.value = window.setInterval(tick, FREIGHT_GROUPS_POLL_MS);
}
// 货代上传工作面激活/切出时启停独立轮询。
watch(isLifecycleFreightUpload, (active) => {
if (active) startFreightGroupsPolling();
else stopFreightGroupsPolling();
});
// 货代分组达到终态后只停止分组轮询。RPA 回调成功/失败不代表整个任务结束,
// 后续 Gate 仍可能自动推进,任务级工作流轮询必须继续由统一投影裁决。
watch(freightNoticeGroups, (groups) => {
if (!isLifecycleFreightUpload.value || !groups.length) return;
const terminal = groups.every((group) => {
const st = String(group.upload_status || '').trim().toLowerCase();
const reason = group.upload_error_message || group.upload_error_code || null;
if (['uploaded', 'succeeded', 'success'].includes(st)) return true;
if (st === 'failed') return true;
return Boolean(reason);
});
if (terminal) {
stopFreightGroupsPolling();
}
});
onBeforeUnmount(() => stopFreightGroupsPolling());
function toggleFreightNoticeSelection(businessNo: string, checked: boolean) {
selectedFreightBusinessNos.value = checked
? Array.from(new Set([...selectedFreightBusinessNos.value, businessNo]))
: selectedFreightBusinessNos.value.filter((item) => item !== businessNo);
}
/**
* 判断通知单是否已有后端确认的上传成功事实。
* 核心逻辑:仅消费当前分组的 upload_status;已上传通知不得再次发起 RPA 或人工确认。
* @param group - 后端下发的发货通知单聚合行。
* @returns 是否已上传成功。
*/
function isFreightNoticeUploaded(group: ShippingFreightNoticeGroup): boolean {
return ['uploaded', 'succeeded', 'success'].includes(
String(group.upload_status || '').trim().toLowerCase(),
);
}
/** 已选通知单中任一已上传时,批量写入动作必须 fail-closed,避免重复提交成功通知。 */
const selectedFreightNoticesContainUploaded = computed(() => {
const selected = new Set(selectedFreightBusinessNos.value);
return freightNoticeGroups.value.some((group) => (
selected.has(group.business_no) && isFreightNoticeUploaded(group)
));
});
async function downloadFreightNotice(businessNo: string) {
try {
await downloadWorkspaceShippingNoticeExcelFile(businessNo);
@@ -2527,6 +2653,7 @@ async function downloadFreightNotice(businessNo: string) {
async function runFreightBatchAction(action: 'download' | 'confirm' | 'rpa') {
if (!selectedFreightBusinessNos.value.length || freightBatchBusy.value) return;
if (action !== 'download' && selectedFreightNoticesContainUploaded.value) return;
freightBatchBusy.value = action;
try {
if (action === 'download') {
@@ -2540,6 +2667,9 @@ async function runFreightBatchAction(action: 'download' | 'confirm' | 'rpa') {
if (action === 'confirm' || action === 'rpa') {
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
if (taskNo) await loadFreightNoticeGroups(taskNo);
// 启动 5 秒轮询:RPA 上传结果/失败原因异步回传后自动刷新,无需手动刷新页面。
startWorkflowProgressPolling();
startFreightGroupsPolling();
}
await Promise.all([loadFormalTaskDetail(), refreshShippingProcessing()]);
} catch (error) {
@@ -2561,6 +2691,7 @@ async function runFreightNoticeAction(
action: 'confirm' | 'rpa' | 'regenerate',
) {
if (freightBatchBusy.value) return;
if (action !== 'regenerate' && isFreightNoticeUploaded(group)) return;
freightBatchBusy.value = action;
try {
if (action === 'confirm') {
@@ -2575,6 +2706,9 @@ async function runFreightNoticeAction(
// 确认/RPA 后重拉同 PO 通知聚合,使通知完成面能立即呈现最新 uploaded 状态。
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
if (taskNo) await loadFreightNoticeGroups(taskNo);
// 启动 5 秒轮询:RPA 上传结果/失败原因异步回传后自动刷新,无需手动刷新页面。
startWorkflowProgressPolling();
startFreightGroupsPolling();
await Promise.all([loadFormalTaskDetail(), refreshShippingProcessing()]);
} catch (error) {
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
@@ -2592,6 +2726,19 @@ function canRegenerateFreightNotice(group: ShippingFreightNoticeGroup): boolean
));
}
/**
* 判断单条通知单是否存在可展开的更多操作。
* 核心逻辑:已上传通知一律不展示更多按钮;其他状态仅在后端授权了至少一个动作时展示,避免空白菜单。
* @param group - 当前发货通知单聚合行。
* @returns 是否显示更多操作入口。
*/
function hasFreightNoticeMoreActions(group: ShippingFreightNoticeGroup): boolean {
if (isFreightNoticeUploaded(group)) return false;
return canRunFreightNoticeAction(group, 'retry_freight_upload_rpa')
|| canRunFreightNoticeAction(group, 'mark_manual_uploaded')
|| canRegenerateFreightNotice(group);
}
/** 仅展示 Notice 聚合接口下发的已授权动作;最终写入仍由对应 API 二次校验。 */
function canRunFreightNoticeAction(group: ShippingFreightNoticeGroup, actionCode: string): boolean {
return (group.available_actions || []).includes(actionCode);
@@ -2837,6 +2984,19 @@ function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
};
}
/**
* 通知完成面:解析上传成功证据的来源方式(人工确认 / RPA),用于徽标展示。
* 核心逻辑:upload_mode 为后端从 ShippingUploadAttempt 权威事实解析的 rpa|manual;
* 仅该两值可映射,未知/空一律返回 null,避免把历史遗留或未知模式伪装成人话。
* @param mode - 后端解析出的上传方式(rpa / manual / 空)。
*/
function freightUploadModeLabel(mode: string | null | undefined): string | null {
const value = String(mode || '').trim().toLowerCase();
if (value === 'rpa') return t('chat.shippingOrderReview.lifecycle.uploadComplete.uploadModeRpa');
if (value === 'manual') return t('chat.shippingOrderReview.lifecycle.uploadComplete.uploadModeManual');
return null;
}
async function confirmPreparationWave() {
const caseNo = String(activeCase.value?.case_no || '').trim();
const draftVersion = activeCase.value?.draft?.draft_version;
@@ -3919,7 +4079,7 @@ watch(
<main
class="flex h-full min-h-0 flex-1 flex-col overflow-hidden bg-slate-50 text-slate-900 dark:bg-slate-950 dark:text-slate-100"
data-testid="shipping-order-review-view"
:data-readonly="isReadOnly ? 'true' : 'false'"
:data-readonly="isReviewContentReadOnly ? 'true' : 'false'"
:data-workbench-mode="workbenchMode"
>
<ReviewWorkbenchHeader
@@ -3930,7 +4090,7 @@ watch(
:saving="saving"
:save-failed="saveFailed"
:draft-conflict="Boolean(draftConflict)"
:is-read-only="isReadOnly"
:is-read-only="isReviewContentReadOnly"
:show-version-history="Boolean(activeCase)"
:show-audit-trail="Boolean(activeCase)"
@back="back"
@@ -4281,16 +4441,20 @@ watch(
<div v-else-if="freightNoticeGroups.length" class="mt-3 space-y-3" data-testid="review-freight-upload-groups">
<div class="flex flex-wrap items-center justify-between gap-2 rounded-lg border border-default bg-surface-muted/30 px-3 py-2 text-xs" data-testid="review-freight-upload-batch-toolbar">
<span class="text-secondary">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.selected', { count: selectedFreightBusinessNos.length }) }}</span>
<div class="flex flex-wrap gap-2"><button type="button" class="rounded border border-default px-2 py-1 disabled:opacity-50" :disabled="!selectedFreightBusinessNos.length || freightBatchBusy !== null" @click="void runFreightBatchAction('download')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchDownload') }}</button><button type="button" class="rounded border border-default px-2 py-1 disabled:opacity-50" :disabled="!selectedFreightBusinessNos.length || freightBatchBusy !== null" @click="void runFreightBatchAction('rpa')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchRpa') }}</button><button type="button" class="rounded border border-default px-2 py-1 disabled:opacity-50" :disabled="!selectedFreightBusinessNos.length || freightBatchBusy !== null" @click="void runFreightBatchAction('confirm')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchConfirm') }}</button></div>
<div class="flex flex-wrap gap-2">
<button type="button" class="rounded border border-default px-2 py-1 disabled:opacity-50" :disabled="!selectedFreightBusinessNos.length || freightBatchBusy !== null" @click="void runFreightBatchAction('download')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchDownload') }}</button>
<button type="button" class="rounded border border-default px-2 py-1 disabled:opacity-50" data-testid="review-freight-upload-batch-rpa" :disabled="!selectedFreightBusinessNos.length || selectedFreightNoticesContainUploaded || freightBatchBusy !== null" @click="void runFreightBatchAction('rpa')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchRpa') }}</button>
<button type="button" class="rounded border border-default px-2 py-1 disabled:opacity-50" data-testid="review-freight-upload-batch-confirm" :disabled="!selectedFreightBusinessNos.length || selectedFreightNoticesContainUploaded || freightBatchBusy !== null" @click="void runFreightBatchAction('confirm')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchConfirm') }}</button>
</div>
</div>
<div v-for="group in freightNoticeGroups" :key="group.business_no" class="rounded-lg border border-default" data-testid="review-freight-upload-notice">
<div class="flex flex-wrap items-center justify-between gap-3 border-b border-default bg-surface-muted/40 px-3 py-2 text-xs">
<label class="flex items-center gap-2 font-semibold text-primary"><input type="checkbox" :checked="selectedFreightBusinessNos.includes(group.business_no)" :aria-label="group.business_no" @change="toggleFreightNoticeSelection(group.business_no, ($event.target as HTMLInputElement).checked)"><span>{{ group.business_no }}</span></label>
<span class="text-secondary">PO: {{ group.po_number || '—' }} · {{ group.export_file_name || '—' }}</span>
<div class="flex items-center gap-2">
<span :class="freightUploadStatusDisplay(group).chipClass" class="rounded-full px-2 py-0.5 font-medium">{{ freightUploadStatusDisplay(group).label }}</span>
<span :class="freightUploadStatusDisplay(group).chipClass" :title="freightUploadStatusDisplay(group).reason || undefined" class="rounded-full px-2 py-0.5 font-medium cursor-help" tabindex="0">{{ freightUploadStatusDisplay(group).label }}</span>
<button type="button" class="rounded border border-brand-200 px-2 py-1 font-medium text-brand-700 hover:bg-brand-50" data-testid="review-freight-upload-download" :disabled="saving" @click="void downloadFreightNotice(group.business_no)">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.download') }}</button>
<details class="relative">
<details v-if="hasFreightNoticeMoreActions(group)" class="relative" data-testid="review-freight-upload-more">
<summary class="list-none rounded border border-default p-1 text-secondary hover:bg-surface" :aria-label="t('chat.shippingProcessing.action.more')"><MoreHorizontal class="h-3.5 w-3.5" aria-hidden="true" /></summary>
<div class="absolute right-0 top-7 z-10 flex min-w-40 flex-col gap-1 rounded border border-default bg-surface p-1 shadow-lg">
<button v-if="canRunFreightNoticeAction(group, 'retry_freight_upload_rpa')" type="button" class="rounded px-2 py-1 text-left text-[11px] text-primary hover:bg-surface-muted disabled:opacity-50" :disabled="freightBatchBusy !== null" @click="void runFreightNoticeAction(group, 'rpa')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchRpa') }}</button>
@@ -4300,7 +4464,6 @@ watch(
</details>
</div>
</div>
<div v-if="freightUploadStatusDisplay(group).reason" class="border-b border-default bg-rose-50/50 px-3 py-2 text-xs text-rose-700 dark:bg-rose-950/10 dark:text-rose-300" data-testid="review-freight-upload-error">{{ freightUploadStatusDisplay(group).reason }}</div>
<table class="min-w-full text-left text-xs"><thead class="border-b border-default bg-surface-muted/30"><tr><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.lineNo') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th></tr></thead><tbody><tr v-for="line in group.lines" :key="`${group.business_no}-${line.line_no}-${line.part_number}`" class="border-b border-default last:border-0" data-testid="review-freight-upload-line"><td class="px-3 py-2"><span :class="freightLineNoDisplay(line).muted ? 'text-muted' : ''" :title="freightLineNoDisplay(line).title">{{ freightLineNoDisplay(line).text }}</span></td><td class="px-3 py-2">{{ line.part_number || '—' }}</td><td class="px-3 py-2">{{ line.reservation_id || '—' }}</td><td class="px-3 py-2">{{ line.shipment_qty || '—' }}</td></tr></tbody></table>
</div>
</div>
@@ -4346,6 +4509,13 @@ watch(
<Check class="h-3.5 w-3.5" aria-hidden="true" />
{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.uploaded') }}
</span>
<span
v-if="freightUploadModeLabel(group.upload_mode)"
class="inline-flex items-center gap-1 rounded-full border border-emerald-300/60 bg-emerald-100/60 px-2 py-0.5 font-medium text-emerald-700 dark:border-emerald-700/60 dark:bg-emerald-950/40 dark:text-emerald-300"
data-testid="review-upload-complete-mode"
>
{{ freightUploadModeLabel(group.upload_mode) }}
</span>
<span class="text-secondary">{{ group.po_number ? `PO: ${group.po_number}` : '' }}</span>
</div>
<div class="flex items-center gap-2">
@@ -4452,7 +4622,7 @@ watch(
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.orderFields') }}</h2>
<p class="mt-1 text-xs text-slate-500">{{ t('chat.shippingOrderReview.schemaVersion', { version: displayCase?.schema.schema_version_id || '-' }) }}</p>
</div>
<span v-if="isReadOnly" class="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-600 dark:bg-slate-800 dark:text-slate-300">
<span v-if="isReviewContentReadOnly" class="rounded-full bg-slate-100 px-2 py-0.5 text-xs text-slate-600 dark:bg-slate-800 dark:text-slate-300">
{{ t('chat.shippingOrderReview.readOnly') }}
</span>
</div>
@@ -4476,7 +4646,7 @@ watch(
</div>
<input
:value="draftValue(displayHeaderValues, field.field_id)"
:disabled="caseContentSkeleton || !isFieldEditable(field.field_id) || saving"
:disabled="caseContentSkeleton || !canEditReviewField(field.field_id) || saving"
class="mt-1 w-full rounded-md border border-slate-300 bg-white px-2.5 py-2 text-sm dark:border-slate-600 dark:bg-slate-950"
:class="{
'border-sky-400 ring-2 ring-sky-300 dark:border-sky-500 dark:ring-sky-700': isEvidenceLinkedField(field.field_id),
@@ -4490,7 +4660,7 @@ watch(
>
<div class="mt-1 flex items-center justify-between gap-2 text-[11px] text-slate-500">
<span>{{ valueSourceLabel(draftFieldMeta(displayHeaderValues as Record<string, unknown> | undefined, field.field_id).value_source) }}</span>
<button v-if="!caseContentSkeleton && isFieldEditable(field.field_id)" type="button" class="hover:text-sky-600" @click="reportSave(() => patchHeader(field.field_id, null, true))">
<button v-if="!caseContentSkeleton && canEditReviewField(field.field_id)" type="button" class="hover:text-sky-600" @click="reportSave(() => patchHeader(field.field_id, null, true))">
<Undo2 class="mr-1 inline h-3 w-3" />{{ t('chat.shippingOrderReview.restoreMachine') }}
</button>
</div>
@@ -4599,7 +4769,7 @@ watch(
<div class="relative flex min-w-0 items-center gap-1">
<input
:value="lineFieldDisplayValue(line, field)"
:disabled="!isFieldEditable(field.field_id) || saving || (field.field_code === 'line_no' && Boolean(draftFieldMeta(line, field.field_id).locked))"
:disabled="!canEditReviewField(field.field_id) || saving || (field.field_code === 'line_no' && Boolean(draftFieldMeta(line, field.field_id).locked))"
class="min-w-0 flex-1 rounded border border-slate-300 bg-white px-1.5 py-1 text-xs dark:border-slate-600 dark:bg-slate-950"
:class="{
'border-amber-400 ring-1 ring-amber-300 dark:border-amber-500': field.field_code === 'line_no'
@@ -5030,7 +5200,7 @@ watch(
:show-stp-retry="showObjectRetryOnFooter"
:auto-gate-hint="t(autoGateHintKey)"
:saving="saving"
:is-read-only="isReadOnly"
:is-read-only="isReviewContentReadOnly"
:has-draft="Boolean(displayCase?.draft) || isLifecycleIntakeParse"
:unsaved-count="unsavedEditCount"
:flow-presentation="flowPresentation"
@@ -529,6 +529,10 @@ function openOrderProcessing(
if (cid) query.conversation_id = cid;
const caseNo = String(item.review_case_no || '').trim();
if (caseNo) query.case_no = caseNo;
// [PERF] 深链携带正式任务号,工作台挂载即可并行拉取任务详情,与 load() 重叠,
// 消除「load() 完成后才轮到任务详情」的串行叠加。
const taskNo = String(item.task_no || '').trim();
if (taskNo) query.task_no = taskNo;
void router.push({ path: `/chat/${agentId}`, query });
}