feat(shipping-notice): 收敛订单处理状态与履约门禁

This commit is contained in:
hugo committed 2026-09-07 09:42:12 +08:00
1 parent bffcd55b40
commit 70dd0051b8
153 files changed
+10916 -4296

No files matched your search

@@ -13,6 +13,7 @@ import { createRouter, createMemoryHistory } from 'vue-router';
import ShippingOrderReviewView from './ShippingOrderReviewView.vue';
import ReviewCurrentProcessingCard from '../components/shipping-review/ReviewCurrentProcessingCard.vue';
import ReviewFieldConflictPanel from '../components/shipping-review/ReviewFieldConflictPanel.vue';
import ManualUploadEvidenceDialog from '@/features/workspace/shipping-task-center/ManualUploadEvidenceDialog.vue';
import { CHAT_PAGE_KEY } from '@/features/chat/composables/chat.context';
import {
auditWorkspaceShippingOrderReviewEligibilityDetails,
@@ -54,10 +55,12 @@ vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
const focusSuggestionField = vi.fn();
const load = vi.fn().mockResolvedValue(undefined);
const selectCase = vi.fn().mockResolvedValue(undefined);
const beginCrossRunSwitch = vi.fn();
const ensureIntakeParseContextLoaded = vi.fn().mockResolvedValue(true);
/** 确认建单 mock:用例可改写返回值以断言 confirm_outcome / auto_progress 解析。 */
const confirmMock = vi.fn();
const reloadLatestDraftMock = vi.fn().mockResolvedValue(undefined);
const refreshReviewQueueMock = vi.fn().mockResolvedValue(true);
const refreshShippingProcessingMock = vi.fn().mockResolvedValue(undefined);
const startWorkflowProgressPollingMock = vi.fn();
const stopWorkflowProgressPollingMock = vi.fn();
@@ -302,9 +305,11 @@ function createReviewComposableMock() {
load,
loadReviewCase: vi.fn().mockResolvedValue(undefined),
selectCase,
beginCrossRunSwitch,
refreshWorkItemContext: vi.fn(),
openCurrentVersion: vi.fn(),
reloadLatestDraft: reloadLatestDraftMock,
refreshReviewQueue: refreshReviewQueueMock,
toggleConflictDiff: vi.fn(),
patchHeader: vi.fn(),
patchLine: patchLineMock,
@@ -578,7 +583,7 @@ async function mountView(query: Record<string, string> = {}) {
autoProgress: {
status: { unknown: '', needs_retry: '待重试', needs_human: '需要人工处理' },
result: '{status}',
checkpoint: '{checkpoint}',
position: '{position}',
viewTask: '返回对话查看进度',
returnToChat: '返回对话查看进度',
retry: '重试自动推进',
@@ -1171,11 +1176,13 @@ describe('ShippingOrderReviewView layout phase 1', () => {
};
const wrapper = await mountView();
load.mockClear();
beginCrossRunSwitch.mockClear();
await wrapper.get('[data-testid="review-doc-nav-CASE-RUN-2"]').trigger('click');
await flushPromises();
// 路由变更是唯一加载所有者,不能在 select 中再次请求相同 Run/Case。
// 跨 Run 先清旧 OT 投影权威,再只由路由 watcher 触发一次 load。
expect(beginCrossRunSwitch).toHaveBeenCalledWith('CASE-RUN-2');
expect(load).toHaveBeenCalledTimes(1);
expect(load).toHaveBeenCalledWith('RUN-2', 'CASE-RUN-2', {
conversationId: 'conv-1', itemNo: undefined,
@@ -2511,12 +2518,14 @@ describe('ShippingOrderReviewView layout phase 1', () => {
// 关键断言:订单基线列和库存事实合为唯一行级工作表,库存源不得退化为任务级 CRANE。
const workspace = wrapper.get('[data-testid="review-fulfillment-prep-workspace"]');
// 关键交互断言:明细在窄视口保持横向可读,行级操作列固定在右侧。
// 关键交互断言:标题/选行条不滚动;仅表体横向可读,行级操作列固定在右侧。
expect(workspace.classes()).toContain('review-fulfillment-prep-workspace');
expect(workspace.classes()).toContain('overflow-x-auto');
expect(workspace.get('table').classes()).toContain('review-fulfillment-prep-table');
expect(workspace.get('thead th:last-child').classes()).toContain('review-fulfillment-sticky-action-head');
expect(workspace.get('tbody tr:first-child td:last-child').classes()).toContain('review-fulfillment-sticky-action-cell');
expect(workspace.classes()).not.toContain('overflow-x-auto');
const tableScroll = workspace.get('[data-testid="review-fulfillment-prep-table-scroll"]');
expect(tableScroll.classes()).toContain('overflow-x-auto');
expect(tableScroll.get('table').classes()).toContain('review-fulfillment-prep-table');
expect(tableScroll.get('thead th:last-child').classes()).toContain('review-fulfillment-sticky-action-head');
expect(tableScroll.get('tbody tr:first-child td:last-child').classes()).toContain('review-fulfillment-sticky-action-cell');
expect(workspace.text()).toContain('RSV-FROZEN');
expect(workspace.text()).toContain('PN-FROZEN');
expect(workspace.text()).toContain('DBS');
@@ -3165,6 +3174,37 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.find('[data-testid="manual-upload-evidence-dialog"]').exists()).toBe(false);
});
it('refreshes left-nav queue after manual upload confirmation success', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-UPLOAD-QUEUE', confirmed_task_id: 21, has_formal_ot: true,
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-UPLOAD-QUEUE', status: 'completed', business_no: 'WYC26082499',
lines: [], events: [], export_artifacts: [{ id: 1 }],
ui_state: { lifecycle_stage: 'upload_complete', actions: { primary: null, secondary: [] }, summary: {}, steps: [] },
} as any);
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
po_number: 'PO-QUEUE',
items: [{ business_no: 'WYC26082499', po_number: 'PO-QUEUE', lines: [] }],
} as any);
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
await flushPromises();
reloadLatestDraftMock.mockClear();
refreshReviewQueueMock.mockClear();
refreshShippingProcessingMock.mockClear();
wrapper.findComponent(ManualUploadEvidenceDialog).vm.$emit('success');
await flushPromises();
// 确认上传后五阶段会到「通知完成」;左侧本批队列必须同步重拉 lifecycle_stage。
expect(reloadLatestDraftMock).toHaveBeenCalled();
expect(refreshReviewQueueMock).toHaveBeenCalled();
expect(refreshShippingProcessingMock).toHaveBeenCalled();
});
it('renders one Notice card and one business_no Excel download for freight upload', async () => {
activeCase.value = {
...activeCase.value,
@@ -3475,7 +3515,8 @@ describe('ShippingOrderReviewView layout phase 1', () => {
summary: {}, steps: [],
},
} as any);
// 完成面改版后按「已上传通知聚合」消费同一份 freight groups;仅 uploaded 通知进入完成面。
// 完成面按「已上传通知聚合」消费同一份 freight groups。
// 契约:聚合接口 upload_status 已经投影归一,成功终态为 uploaded。
vi.mocked(taskApi.getWorkspaceShippingFreightNoticeGroups).mockResolvedValue({
po_number: 'PO-100',
items: [
@@ -3490,7 +3531,8 @@ describe('ShippingOrderReviewView layout phase 1', () => {
await flushPromises();
const evidence = wrapper.get('[data-testid="review-lifecycle-upload-complete"]');
// 只展示已上传通知(uploaded),未上传(pending)不进入完成面。
// 只展示已成功上传通知(uploaded),未上传(pending)不进入完成面。
expect(wrapper.get('[data-testid="review-upload-complete-toolbar"]').text()).toContain('本批已上传 1 张发货通知');
expect(evidence.text()).toContain('WYC26082401');
expect(evidence.text()).not.toContain('WYC26082402');
// 人工确认不再展示或依赖货代回执号,即使历史投影仍带有 freight_ref_no。
@@ -3545,6 +3587,7 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.find('[data-testid="review-upload-complete-toolbar"]').exists()).toBe(false);
// 分组到达后:loading 让位,batchCount 工具栏与已上传列表恢复渲染。
// 契约:后端 Notice 面 upload_status 已投影为 uploaded。
resolveGroups({
po_number: 'PO-UPCOMPLETE',
items: [{
@@ -3625,6 +3668,38 @@ describe('ShippingOrderReviewView layout phase 1', () => {
expect(wrapper.findAll('[data-testid="review-freight-upload-download-SN-PO-WAVE-1"]')).toHaveLength(0);
});
it('shows inline RPA and confirm actions when freight notice groups authorize them', async () => {
activeCase.value = {
...activeCase.value,
status: 'confirmed', confirmed_task_no: 'SN-PO-ACTIONS', confirmed_task_id: 25, has_formal_ot: true,
};
const taskApi = await import('@/features/chat/api/shipping.api');
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValue({
task_no: 'SN-PO-ACTIONS', business_no: 'WYC-ACTIONS', 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-ACTIONS',
items: [{
business_no: 'WYC-ACTIONS',
po_number: 'PO-ACTIONS',
upload_status: 'pending',
export_file_name: 'WYC-ACTIONS.xlsx',
available_actions: ['download_excel', 'retry_freight_upload_rpa', 'mark_manual_uploaded'],
lines: [],
}],
} as any);
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
await flushPromises();
// 关键断言:后端授权后的 RPA/确认必须作为行内主按钮出现,不能再藏进空白「更多」菜单。
expect(wrapper.find('[data-testid="review-freight-upload-download"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-freight-upload-rpa"]').exists()).toBe(true);
expect(wrapper.find('[data-testid="review-freight-upload-confirm"]').exists()).toBe(true);
expect(wrapper.findAll('[data-testid="review-freight-upload-more"]')).toHaveLength(0);
});
it('sends selected business_nos for freight batch actions', async () => {
activeCase.value = { ...activeCase.value, status: 'confirmed', confirmed_task_no: 'SN-PO-BATCH', confirmed_task_id: 23, has_formal_ot: true };
const taskApi = await import('@/features/chat/api/shipping.api');
@@ -11,7 +11,8 @@
正式任务动作直接提交后端 Gate,避免以无界面组件充当隐藏执行器;
逻辑:建单前订单检查为主卡;正式 OT 后保持 standard,不自动切 formal_task 空壳;
当前 Case 的明确恢复动作优先右栏 CurrentProcessingCard,
不回落至底栏;库存动作仅明细行浮层;表单保存校验仅底栏。
不回落至底栏;库存动作仅明细行浮层;表单保存校验仅底栏;
货代上传确认成功后须 refreshReviewQueue,左侧本批阶段与五阶段对齐。
-->
<script setup lang="ts">
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
@@ -173,10 +174,12 @@ const {
ensureIntakeParseContextLoaded,
load,
selectCase,
beginCrossRunSwitch,
requestedCaseNo,
refreshWorkItemContext,
openCurrentVersion,
reloadLatestDraft,
refreshReviewQueue,
toggleConflictDiff,
patchHeader,
patchLine,
@@ -209,7 +212,14 @@ const {
onReparseCaseReady: handleReparseCaseReady,
// [选法 2] 正式任务下游阶段不再反推复核 Case;OT 号改由已拉取的任务详情提供,
// 使 work-item 统一投影能在 activeCase 为空时仍正常加载。
externalOrderTaskNo: () => String(formalTaskDetail.value?.order_task_no || '').trim() || null,
// order_task_no 优先;若后端 enrich 曾把 OT 自序列化的 order_task_no 冲成 null,
// 则当 task_no 本身是 OT- 前缀时回退 task_no(禁止把 SN 号当 work-item 键)。
externalOrderTaskNo: () => {
const orderTaskNo = String(formalTaskDetail.value?.order_task_no || '').trim();
if (orderTaskNo) return orderTaskNo;
const taskNo = String(formalTaskDetail.value?.task_no || '').trim();
return taskNo.startsWith('OT-') ? taskNo : null;
},
});
const msg = useMessage();
@@ -263,10 +273,48 @@ const LIFECYCLE_STAGE_CODES: ReviewLifecycleStageCode[] = [
/**
* 生命周期阶段只描述用户工作 surface;订单、库存、上传状态仍由后端 Projection/Gate 裁决。
* 读序(契约 §1.1 / §6):正式 OT 优先 A → A 未就绪降级 B → 建单前 reviewQueue/Run → A 兜底。
*/
const lifecycleUiState = computed(() => {
const processing = shippingProcessingProjection.value?.uiState;
const formal = formalTaskDetail.value?.ui_state;
const formalOtReady = Boolean(
activeCase.value?.has_formal_ot
|| (
activeCase.value?.confirmed_task_id
&& String(activeCase.value?.confirmed_task_no || '').trim()
&& !activeCase.value?.task_missing
),
);
const aHasLifecycle = Boolean(
processing?.lifecycleStage
|| (Array.isArray(processing?.lifecycleEntries) && processing.lifecycleEntries.length > 0),
);
/**
* 将 A.blocking_reason 解析为页签阻断文案;无 i18n 时退回 code/message。
* @returns 可展示的阻断说明;无可展示内容时为空串
*/
const resolveBlockerFromProcessing = (): string => {
const reason = processing?.blocking_reason;
if (!reason) return '';
const key = String(reason.i18nKey || '').trim();
if (key && te(key)) {
return String(t(key, (reason.details || {}) as Record<string, unknown>)).trim();
}
return String(reason.code || '').trim();
};
// [STEP 1] 正式 OT:页签 stage/entries/blocker 认 A(与右卡同源)。
if (formalOtReady && aHasLifecycle) {
return {
stage: processing?.lifecycleStage || null,
entries: processing?.lifecycleEntries || [],
blocker: resolveBlockerFromProcessing(),
intakeParseAuthorized: false,
};
}
// [STEP 2] A 轮询未落位时短暂降级 B,避免页签空窗。
if (formal?.lifecycle_stage || formal?.lifecycle_entries?.length) {
return {
stage: formal.lifecycle_stage || null,
@@ -275,8 +323,7 @@ const lifecycleUiState = computed(() => {
intakeParseAuthorized: false,
};
}
// Review Case 尚未建正式任务时,Run/Queue 项仍由后端下发生命周期入口;
// 不得因 formal task 缺失而回退到前端默认订单复核。
// [STEP 3] 建单前:Run/Queue 项仍由后端下发生命周期入口。
const currentCaseNo = String(activeCase.value?.case_no || '').trim();
const reviewEntry = (reviewQueue.value?.items || reviewRun.value?.items || []).find(
(item) => String(item.case_no || '').trim() === currentCaseNo,
@@ -840,11 +887,10 @@ const currentTaskRetryable = computed(() => (
const currentTaskRecoveryActions = computed(() => {
if (formalTaskProjectionPending.value) return [];
if (hasFormalOt.value) {
// [§2.4 单源] 恢复动作从 A(shippingProcessingProjection.ui_state.secondary_actions)读,
// 不再从 B(formalTaskDetail.ui_state.actions)slice。能力仍取任务级
// stage_context.preparation.capabilities(B 工作面事实,§2 保留)。动作码同源(A==C==B),
// 该改动纯收敛。行级库存选源动作只在表格逐行处理,禁止作为任务级按钮出现在右侧卡。
const gateRecovery = (currentTaskUiState.value?.secondary_actions || [])
// [§2.4 单源] 任务级恢复按钮只读 A.secondary_actions;不再叠加 B.capabilities。
// capabilities 仍可作点击执行的 stageCapabilityBypass 查找(见 handleCurrentTaskAction),
// 但不得单独渲成右卡按钮——能力要展示须先并进 A。行级选源禁止出现在右卡。
return (currentTaskUiState.value?.secondary_actions || [])
.filter((action) => action.enabled
&& String(action.code || '').trim() !== 'download_excel'
&& !isNoticeScopedAction(action))
@@ -853,21 +899,10 @@ const currentTaskRecoveryActions = computed(() => {
// 统一右卡 domain:actionCodes.<code>(见 currentTaskPrimaryAction 注;A 的 i18nKey 可能是 chat 域)。
i18nKey: `workspace.shippingNotice.processGate.actionCodes.${String(action.code || '').trim()}`,
}))
.filter((action): action is { code: string; i18nKey: string } => Boolean(action.code));
const capabilityActions = (formalPreparationContext.value?.capabilities || [])
.filter((cap) => cap.scope === 'task' && cap.enabled && String(cap.action_code || '').trim())
.map((cap) => ({
code: String(cap.action_code).trim(),
i18nKey: `chat.shippingOrderReview.lifecycle.prepare.capability.${cap.code}`,
}));
const seen = new Set<string>();
return [...gateRecovery, ...capabilityActions].filter((action) => {
const code = String(action.code || '').trim();
if (!code || seen.has(code)) return false;
if (LINE_SCOPE_INVENTORY_ACTIONS.has(code)) return false;
seen.add(code);
return true;
});
.filter((action): action is { code: string; i18nKey: string } => {
const code = String(action.code || '').trim();
return Boolean(code) && !LINE_SCOPE_INVENTORY_ACTIONS.has(code);
});
}
const projection = shippingProcessingProjection.value;
if (projection) {
@@ -978,7 +1013,8 @@ const confirmSuccess = ref<{
progressFailed: boolean;
progressStatus: string;
progressMessage: string;
checkpoint: string;
/** Gate 位置标签(derive_position) */
position: string;
/** 来自 Case 投影的刷新恢复(非本次确认即时响应) */
restoredFromProjection?: boolean;
} | null>(null);
@@ -1026,7 +1062,7 @@ function hydrateConfirmProgressFromCase() {
progressFailed: true,
progressStatus: String(progress.status || 'needs_retry'),
progressMessage: String(progress.message || ''),
checkpoint: '',
position: '',
restoredFromProjection: true,
};
}
@@ -2383,14 +2419,23 @@ const freightGroupsInFlight = ref(false);
const selectedFreightBusinessNos = ref<string[]>([]);
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | null>(null);
/**
* 通知完成面的只读聚合:同 PO 中已有上传成功证据(upload_status=uploaded)的发货通知。
* 判断货代通知聚合行是否已具备上传成功事实。
* 核心逻辑:聚合接口 upload_status 已经过后端 project_notice_upload_status 归一,
* 成功终态只认 uploaded;禁止再扩 succeeded/success 同义词兜底。
* @param group - 当前发货通知单聚合行。
* @returns 是否已上传成功。
*/
function isFreightNoticeUploaded(group: ShippingFreightNoticeGroup): boolean {
return String(group.upload_status || '').trim().toLowerCase() === 'uploaded';
}
/**
* 通知完成面的只读聚合:同 PO 中已有上传成功证据的发货通知。
* 核心逻辑:与货代上传面消费同一份 freightNoticeGroups,仅按终态过滤;未上传的
* 通知仍留在货代上传面处理,完成面不出现混淆态。
*/
const uploadedFreightNoticeGroups = computed(() =>
freightNoticeGroups.value.filter((item) =>
String(item.upload_status || '').trim().toLowerCase() === 'uploaded',
),
freightNoticeGroups.value.filter((item) => isFreightNoticeUploaded(item)),
);
/** 批次留底下载:把已完成通知全部打包为 ZIP(复用后端 /shipping-notices/batch/export)。 */
const uploadingBatchArchive = ref(false);
@@ -2500,11 +2545,26 @@ function formalPreparationLineFulfillment(line: { snapshot_line_id?: number | nu
return preparationLineFulfillmentFor(line.snapshot_line_id);
}
function formalPreparationLineSource(line: { snapshot_line_id?: number | null; source_code?: string | null }): string {
/**
* 行「库存源」只读展示文案:Match 正式源优先,其次 CandidateSet 取数目标。
* 核心逻辑:不把任务级 inventory_sources 回填到行;无正式/选中源时显示 —。
*/
function formalPreparationLineSource(line: {
snapshot_line_id?: number | null;
source_code?: string | null;
selected_source_code?: string | null;
}): string {
const fulfillment = formalPreparationLineFulfillment(line);
const source = fulfillment?.inventory_source;
const label = String(source?.label || '').trim();
const code = String(source?.code || line.source_code || fulfillment?.inventory_source_code || '').trim();
// 展示优先级:Match 正式源 → CandidateSet 取数目标 → fulfillment 兼容字段。
const code = String(
source?.code
|| line.source_code
|| line.selected_source_code
|| fulfillment?.inventory_source_code
|| '',
).trim();
if (label && code) return `${label}(${code})`;
return label || code || '—';
}
@@ -2587,22 +2647,38 @@ function formalPreparationLineAllows(
return Boolean(fulfillment?.inventory_allowed_actions?.includes(action));
}
/**
* 通知准备行匹配状态文案:后端 status 现为 user_line_status(如 inventory_matched),
* 优先履约用户态文案,再回退 prepare.matchStatus;禁止把原始码直接展示给用户。
*/
function formalPreparationLineStatusLabel(line: { snapshot_line_id?: number | null; status?: string | null; shortage_qty?: string | number | null }): string {
const fulfillment = formalPreparationLineFulfillment(line);
if (fulfillment?.decision?.decision_code === 'release_inventory_shortage') {
return t('chat.shippingOrderReview.lifecycle.prepare.releaseShortage');
}
const status = String(line.status || '').trim().toLowerCase();
if (status === 'matched' && Number(line.shortage_qty || 0) <= 0) {
if ((status === 'matched' || status === 'inventory_matched') && Number(line.shortage_qty || 0) <= 0) {
return t('chat.shippingOrderReview.lifecycle.prepare.matched');
}
if (status === 'shortage' || Number(line.shortage_qty || 0) > 0) {
return t('chat.shippingOrderReview.lifecycle.prepare.shortage');
}
const userKey = `chat.shippingOrderReview.fulfillmentDecision.userLineStatus.${status}`;
if (status && te(userKey)) return t(userKey);
const key = `chat.shippingOrderReview.lifecycle.prepare.matchStatus.${status || 'unknown'}`;
return te(key) ? t(key) : status || '—';
}
/**
* 通知准备区右上角阶段徽标:后端下发 ready/processing/blocked,必须走 i18n。
*/
function formalPreparationStatusLabel(status?: string | null): string {
const code = String(status || '').trim().toLowerCase();
if (!code) return '';
const key = `chat.shippingOrderReview.lifecycle.prepare.status.${code}`;
return te(key) ? t(key) : code;
}
const releaseInventoryLine = ref<ShippingOrderReviewLineFulfillmentLine | null>(null);
const releaseInventoryReason = ref('');
const releaseInventoryFieldValues = ref<Record<string, string>>({});
@@ -2698,12 +2774,16 @@ function openManualUploadRegistration() {
/**
* 人工上传登记成功后刷新完整工作台状态。
* 先重新拉取 Review Case(顶部阶段与 Gate 的权威投影),再刷新任务详情和统一处理投影;
* 不能只刷新 OT 详情,否则登记已落库但页面仍会显示旧的人工上传阻断状态。
* 先重新拉取 Review Case(顶部阶段与 Gate 的权威投影),再刷新左侧本批队列生命周期、
* 任务详情和统一处理投影;不能只刷新 OT 详情,否则登记已落库但页面仍会显示旧的人工上传阻断状态;
* 也不能省略 refreshReviewQueue,否则五阶段已到「通知完成」而左侧仍停在「货代上传」。
*/
async function handleManualUploadSuccess() {
manualUploadRegistrationOpen.value = false;
await reloadLatestDraft();
await Promise.all([
reloadLatestDraft(),
refreshReviewQueue(),
]);
await Promise.all([
loadFormalTaskDetail(),
refreshShippingProcessing(),
@@ -2821,8 +2901,9 @@ function isFreightUploadProjectionTerminal(): boolean {
}
/**
* 投影到达货代上传终态时刷新一次分组列表(幂等守卫,防止投影在途反复触发)。
* 核心逻辑:只在“上传行为已结束”时写列表;uploading 期间不产生任何额外请求。
* 投影到达货代上传终态时刷新一次分组列表与左侧队列(幂等守卫,防止投影在途反复触发)。
* 核心逻辑:只在“上传行为已结束”时写列表;uploading 期间不产生任何额外请求;
* 同时 refreshReviewQueue,使 RPA 自动完成路径下左侧 lifecycle_stage 与五阶段一致。
*/
function maybeRefreshFreightGroupsOnTerminal() {
if (!isLifecycleFreightUpload.value && !isLifecycleUploadComplete.value) return;
@@ -2832,6 +2913,7 @@ function maybeRefreshFreightGroupsOnTerminal() {
if (!isFreightUploadProjectionTerminal()) return;
freightNoticeGroupsFinalized = true;
void loadFreightNoticeGroups(taskNo);
void refreshReviewQueue();
}
// [PERF] 以任务级处理投影为唯一终态信号,替代独立的 5s 分组轮询:进入货代上传时的初始拉取由
@@ -2851,14 +2933,14 @@ watch(
{ immediate: true },
);
// [PERF] 货代上传分组是否正在等待异步 RPA 回调(uploading / upload_rpa_pending)。
// 只有该状态才需要轮询投影去感知回调落地;空闲(pending,自动上传关闭待人工)、已终态
// (uploaded / failed)都不会自行变化,不应轮询。
/**
* 货代上传分组是否正在等待异步 RPA 回调。
* 核心逻辑:只认投影后的 upload_status(uploading);禁止再读 OT 人工原因列。
*/
function hasFreightGroupsInFlightRpa(groups: ShippingFreightNoticeGroup[]): boolean {
return (groups || []).some((group) => {
const st = String(group.upload_status || '').trim().toLowerCase();
const pendingHuman = String(group.pending_human_reason || '').trim().toLowerCase();
return st === 'uploading' || st === 'upload_rpa_pending' || pendingHuman === 'upload_rpa_pending';
return st === 'uploading';
});
}
@@ -2923,18 +3005,6 @@ function toggleFreightNoticeSelection(businessNo: string, checked: boolean) {
: 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);
@@ -3031,15 +3101,14 @@ function canRegenerateFreightNotice(group: ShippingFreightNoticeGroup): boolean
/**
* 判断单条通知单是否存在可展开的更多操作。
* 核心逻辑:已上传通知一律不展示更多按钮;其他状态仅在后端授权了至少一个动作时展示,避免空白菜单。
* 核心逻辑:已上传通知一律不展示更多按钮;RPA/确认已提到行内主按钮,
* 更多菜单仅承载低频的 Excel 重生,避免空白菜单。
* @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);
return canRegenerateFreightNotice(group);
}
/** 仅展示 Notice 聚合接口下发的已授权动作;最终写入仍由对应 API 二次校验。 */
@@ -3209,9 +3278,7 @@ function freightLineNoDisplay(line: { line_no?: string | number | null }): {
/**
* 逐发货通知单的货代上传状态展示。
* 核心逻辑:upload_status 为后端事实;把 uploaded/uploading/failed/pending 映射为文案与色阶,
* 并携带 upload_error_code/upload_error_message 作为逐单失败原因。前端禁止按 upload_status 之外的状态猜原因,
* 未知状态一律回落 pending,避免把内部执行字段当作用户原因。
* 核心逻辑:只认投影后的 upload_status 与 upload_error_*;禁止读 OT 人工原因列。
* @param group - 当前发货通知单聚合行(含 upload_status 与逐单错误字段)。
*/
function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
@@ -3221,9 +3288,8 @@ function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
reason: string | null;
} {
const status = String(group.upload_status || '').trim().toLowerCase();
const pendingHuman = String(group.pending_human_reason || '').trim().toLowerCase();
const reason = group.upload_error_message || group.upload_error_code || null;
if (['uploaded', 'succeeded', 'success'].includes(status)) {
if (status === 'uploaded') {
return {
state: 'uploaded',
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.uploaded'),
@@ -3248,7 +3314,7 @@ function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
reason: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadError', { reason }),
};
}
if (['uploading', 'upload_rpa_pending'].includes(status) || pendingHuman === 'upload_rpa_pending') {
if (status === 'uploading') {
return {
state: 'uploading',
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.uploading'),
@@ -3256,14 +3322,6 @@ function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
reason: null,
};
}
if (pendingHuman) {
return {
state: 'needs_human',
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.needsHuman'),
chipClass: 'bg-amber-100 text-amber-800 dark:bg-amber-950/50 dark:text-amber-200',
reason: reason ? t('chat.shippingOrderReview.lifecycle.freightUpload.uploadError', { reason }) : null,
};
}
return {
state: 'pending',
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.pending'),
@@ -3915,7 +3973,7 @@ const submitPendingAction = async (payload: ReviewConfirmPayload) => {
progressFailed: parsed.progressFailed,
progressStatus: parsed.progressStatus,
progressMessage: parsed.progressMessage,
checkpoint: parsed.checkpoint,
position: parsed.position,
restoredFromProjection: false,
};
if (parsed.progressFailed) {
@@ -3971,7 +4029,7 @@ const closeAuxiliaryPanelsForCaseSwitch = () => {
};
// [NO-OPTIMISTIC MEMORY] 行级选源/覆写是「点保存才生效」的实提交,未保存的暂存选择
// 不得跨文件/切换残留(否则会把上一文件的未保存意图带进新行)。切换即清空暂存,
// 行回到后端真实 source_code 状态,用户须重新选择并点保存。
// 行回到后端 selected_source_code / source_code,用户须重新选择并点保存。
lineSourceSelections.value = {};
lineSourceBusy.value = false;
overrideSourceSelections.value = {};
@@ -4078,6 +4136,13 @@ const select = async (caseNo: string) => {
if (sourceRunNo && sourceRunNo !== String(reviewRun.value?.run_no || '').trim()) {
pendingCrossRunCaseNo.value = caseNo;
try {
// 先进入切换态并清掉上一 OT 投影权威,再改路由;否则 load() 完成前会出现
// 「文件 B 高亮 + 库存/右卡仍是 A」的串味。工作台壳仍保留(无大骨架)。
beginCrossRunSwitch(caseNo);
formalTaskDetailGeneration += 1;
formalTaskDetail.value = null;
formalTaskDetailLoadFailed.value = false;
formalTaskDetailLoading.value = false;
// 先原子提交目标 Run/Case/阶段深链,再读取目标 Case。否则 load() 期间旧文件的
// lifecycle watcher 会把 target stage 写回,形成“文件 B + 阶段 A”的错误组合。
await router.replace({ query: {
@@ -4398,16 +4463,22 @@ function retryFormalTaskDetail() {
* 需要 case_no + draft_version,preparationWaveSelectableLines 读 displayCase.line_fulfillment。
* 该自动补拉是写路径必需的已知暂留债务;根治 = 后续计划「波次出单写路径改源到任务级」,
* 完成后随任务把 fulfillment_prep 一并移出本集合;
* - watch 行为本身不变:集合内阶段 + activeCase 为空 → loadReviewCase 补拉 Case 快照。
* - 通知准备只补 Case、不补 Evidence;订单复核/接收解析补 Case+Evidence(含从准备切回时补证据)。
*/
const REVIEW_EDITOR_NEEDED_STAGES: ReviewLifecycleStageCode[] = ['intake_parse', 'order_review', 'fulfillment_prep'];
watch(
lifecycleCurrentStageCode,
(stage) => {
if (!stage || !REVIEW_EDITOR_NEEDED_STAGES.includes(stage)) return;
if (activeCase.value) return;
const caseNo = String(displayCase.value?.case_no || '').trim();
if (caseNo) void loadReviewCase(caseNo);
if (!caseNo) return;
if (stage === 'fulfillment_prep') {
if (activeCase.value) return;
void loadReviewCase(caseNo, { includeEvidence: false });
return;
}
// intake_parse / order_review:需要复核编辑器(Case + Evidence)
void loadReviewCase(caseNo, { includeEvidence: true });
},
);
@@ -4764,9 +4835,10 @@ watch(
<span
v-if="formalPreparationContext?.status"
class="rounded-full bg-brand-50 px-2.5 py-1 text-xs font-medium text-brand-700 dark:bg-brand-950/30 dark:text-brand-300"
>{{ formalPreparationContext?.status }}</span>
>{{ formalPreparationStatusLabel(formalPreparationContext?.status) }}</span>
</div>
<div v-if="formalPreparationDisplayLines.length" class="review-fulfillment-prep-workspace mt-4 overflow-x-auto rounded-lg border border-default" data-testid="review-fulfillment-prep-workspace">
<div v-if="formalPreparationDisplayLines.length" class="review-fulfillment-prep-workspace mt-4 rounded-lg border border-default" data-testid="review-fulfillment-prep-workspace">
<!-- 标题与选行操作条固定不参与横向滚动,仅表头/表体横向滑动。 -->
<div class="flex items-center justify-between gap-3 border-b border-default bg-surface-muted/30 px-3 py-2">
<div class="text-xs font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.prepare.matchWorkspace') }}</div>
<span class="text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineCount', { count: formalPreparationDisplayLines.length }) }}</span>
@@ -4778,10 +4850,12 @@ watch(
</div>
<button type="button" class="rounded-lg bg-emerald-600 px-3 py-1.5 font-medium text-white disabled:opacity-50" data-testid="review-fulfillment-prep-confirm-wave" :disabled="preparationWaveBusy || !selectedPreparationSnapshotLineIds.length" @click="confirmPreparationWave">{{ preparationWaveBusy ? t('chat.shippingOrderReview.fulfillmentDecision.waving') : t('chat.shippingOrderReview.fulfillmentDecision.confirmWave', { count: selectedPreparationSnapshotLineIds.length }) }}</button>
</div>
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
<tbody><tr v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) }}</span></td><td class="whitespace-nowrap px-3 py-2">{{ line.available_qty ?? '—' }}</td><td class="whitespace-nowrap px-3 py-2 font-medium" :class="Number(line.shortage_qty || 0)Line truncated
</table>
<div class="overflow-x-auto overscroll-x-contain" data-testid="review-fulfillment-prep-table-scroll">
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
<tbody><tr v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.selected_source_code || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) }}</span></td><td class="whitespace-nowrap px-3 py-2">{{ line.available_qty ?? '—' }}</td><td class="whitespace-nowrap px-3 py-2 font-medium" :class=Line truncated
</table>
</div>
</div>
<p v-else class="mt-3 rounded-lg border border-default bg-surface-muted/50 p-3 text-xs text-secondary" data-testid="review-fulfillment-prep-pending">
{{ t('chat.shippingOrderReview.lifecycle.prepare.pending') }}
@@ -4844,11 +4918,25 @@ watch(
<div class="flex items-center gap-2">
<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>
<button
v-if="canRunFreightNoticeAction(group, 'retry_freight_upload_rpa')"
type="button"
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
data-testid="review-freight-upload-rpa"
:disabled="freightBatchBusy !== null"
@click="void runFreightNoticeAction(group, 'rpa')"
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.rpa') }}</button>
<button
v-if="canRunFreightNoticeAction(group, 'mark_manual_uploaded')"
type="button"
class="rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface-muted disabled:opacity-50"
data-testid="review-freight-upload-confirm"
:disabled="freightBatchBusy !== null"
@click="void runFreightNoticeAction(group, 'confirm')"
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.confirm') }}</button>
<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>
<button v-if="canRunFreightNoticeAction(group, 'mark_manual_uploaded')" 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, 'confirm')">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.batchConfirm') }}</button>
<button v-if="canRegenerateFreightNotice(group)" type="button" class="rounded px-2 py-1 text-left text-[11px] text-primary hover:bg-surface-muted disabled:opacity-50" :disabled="freightBatchBusy !== null" data-testid="review-freight-upload-regenerate" @click="void runFreightNoticeAction(group, 'regenerate')">{{ t('workspace.shippingNotice.processGate.actionCodes.regenerate_excel_artifact') }}</button>
</div>
</details>
@@ -5634,7 +5722,7 @@ watch(
/**
* 用途:库存匹配明细在窄工作区保留业务列宽,且行级授权操作始终可用。
* 依赖:formalPreparationLines 与后端下发的 inventory_allowed_actions。
* 逻辑:容器负责横向滚动,右侧单个操作单元格 sticky,不改变操作授权或状态判断。
* 逻辑:仅表头/表体容器横向滚动(标题与选行条固定),右侧操作列 sticky。
*/
.review-fulfillment-prep-table {
width: max-content;