!13 feat(shipping-freight-auto-upload): 新增货代发货Excel连接级自动上传全链路功能
Merge pull request !13 from 曹惠鹏/hugo-shipping-notice
This commit is contained in:
93 files changed
+4867
-601
No files matched your search
@@ -126,6 +126,8 @@ export const getWorkspaceShippingTask = (taskNo: string) =>
|
||||
export const getWorkspaceShippingFreightNoticeGroups = (taskNo: string) =>
|
||||
requestJson<ShippingFreightNoticeGroupsResponse>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/freight-notice-groups`,
|
||||
// [PERF] Priority Hints:货代上传聚合仅在对应阶段工作面展示,非首屏关键路径。
|
||||
{ priority: 'low' },
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -316,7 +318,8 @@ export const getWorkspaceShippingProcessingWorkItem = async (
|
||||
) => {
|
||||
const raw = await requestJson<Record<string, unknown>>(
|
||||
`/api/workspace/shipping-processing/work-items/${encodeURIComponent(workItemType)}/${encodeURIComponent(workItemNo)}`,
|
||||
{ signal },
|
||||
// [PERF] Priority Hints:轮询接口让位于首屏关键请求(run/case/task 详情)。
|
||||
{ signal, priority: 'low' },
|
||||
);
|
||||
const normalized = normalizeShippingProcessingProjection(raw);
|
||||
if (!normalized) {
|
||||
@@ -752,7 +755,8 @@ export const reparseWorkspaceShippingOrderReviewDocument = (caseNo: string, reas
|
||||
export const getWorkspaceShippingOrderReviewEvidence = (caseNo: string, signal?: AbortSignal) =>
|
||||
requestJson<{ case_no: string; items: ShippingOrderReviewEvidence[] }>(
|
||||
`/api/workspace/shipping-notice/order-review-cases/${encodeURIComponent(caseNo)}/evidence`,
|
||||
{ signal },
|
||||
// [PERF] Priority Hints:证据摘要非首屏关键路径,让位于 run/case/task 详情。
|
||||
{ signal, priority: 'low' },
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -972,6 +976,8 @@ export const getWorkspaceShippingOrderReviewIntakeParseContext = (caseNo: string
|
||||
export const getWorkspaceShippingOrderReviewQueue = (runNo: string) =>
|
||||
requestJson<ShippingOrderReviewQueue>(
|
||||
`/api/workspace/shipping-notice/order-review-queue/${encodeURIComponent(runNo)}`,
|
||||
// [PERF] Priority Hints:队列仅驱动导航/阶段摘要,非主编辑区关键路径。
|
||||
{ priority: 'low' },
|
||||
);
|
||||
|
||||
/** 用户展开状态卡时获取脱敏进度时间线;不返回节点或Workflow诊断数据。 */
|
||||
|
||||
+77
-1
@@ -2,7 +2,8 @@
|
||||
* features/chat/components/shipping-review/ReviewCurrentProcessingCard.spec.ts
|
||||
* 用途:验证工作台右侧当前任务卡只在需要人工处理时渲染业务动作。
|
||||
* 依赖:Vitest、Vue Test Utils、Vue I18n、ReviewCurrentProcessingCard。
|
||||
* 逻辑:库存自动处理中即使遗留 primary_action,也不得显示编辑正式任务;可重试状态仍保留重试入口。
|
||||
* 逻辑:库存自动处理中即使遗留 primary_action,也不得显示编辑正式任务;可重试状态仍保留重试入口;
|
||||
* loading 是「权威投影读取中」占位:已知阶段照常展示,状态/下一步给中性加载文案(非系统处理中)。
|
||||
*/
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
@@ -38,9 +39,25 @@ const i18n = createI18n({
|
||||
saveOrderAndValidate: '提交订单',
|
||||
currentProcessing: {
|
||||
waitingStart: '等待系统启动',
|
||||
stageLoading: '正在获取最新状态…',
|
||||
statusIdle: '待机',
|
||||
status: '状态',
|
||||
stages: {
|
||||
excel_generating: 'Excel 生成',
|
||||
},
|
||||
},
|
||||
currentTask: {
|
||||
title: '当前任务',
|
||||
labelStage: '当前门禁',
|
||||
statusRunning: '系统处理中',
|
||||
statusWaitingHuman: '待人工处理',
|
||||
statusRetryable: '可重试',
|
||||
statusFailed: '自动处理失败',
|
||||
statusCompleted: '已完成',
|
||||
statusCancelled: '已取消',
|
||||
nextStepTitle: '下一步',
|
||||
nextStepRunning: '系统正在处理,暂不需要人工操作',
|
||||
nextStepUnknown: '状态待确认',
|
||||
nextStepWaitingExternal: '等待外部系统回执,暂不需要人工操作',
|
||||
},
|
||||
},
|
||||
@@ -180,6 +197,23 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
expect(wrapper.text()).not.toContain('edit_draft');
|
||||
});
|
||||
|
||||
it('hides an unlabeled primary action instead of rendering an icon-only ghost button', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'fulfillment_prep',
|
||||
userStatus: 'waiting_human',
|
||||
// 后端下发了动作码,但前端无受控文案(缺失 i18n 映射 / 未登记),
|
||||
// 必须整体隐藏按钮,不能渲染成只有 Bot/RefreshCw 图标的“幽灵按钮”。
|
||||
primaryAction: { code: 'unknown_system_action', i18nKey: 'workspace.shippingNotice.processGate.actionCodes.unknown_system_action' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-actions"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).not.toContain('unknown_system_action');
|
||||
});
|
||||
|
||||
it('renders a localized reason instead of an internal blocking code in the next step', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
@@ -233,4 +267,46 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
['retry_inventory_preparation', {}],
|
||||
]);
|
||||
});
|
||||
|
||||
it('keeps the known stage and status while the authoritative projection is still loading', () => {
|
||||
// Case 先到、Projection 后到的过渡窗口:阶段与投影同源(project_stage_for_task),
|
||||
// status 也来自后端 automation 运行态,必须照常展示,不能退回骨架/「正在更新状态」占位。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
loading: true,
|
||||
stageCode: 'excel_generating',
|
||||
stageLabelKey: 'excel_generating',
|
||||
userStatus: 'running',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toBe('Excel 生成');
|
||||
// loading 只抑制动作,不掩盖真值:运行态照常显示「系统处理中」。
|
||||
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toBe('系统处理中');
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text())
|
||||
.toBe('系统正在处理,暂不需要人工操作');
|
||||
});
|
||||
|
||||
it('shows the neutral idle value instead of a skeleton when nothing is actionable yet', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: { loading: true, stageCode: 'excel_generating', stageLabelKey: 'excel_generating' },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
// 空用户态自然落到「待机 / 状态待确认」,与投影稳态一致——不做骨架→真值的二次刷新。
|
||||
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toBe('Excel 生成');
|
||||
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toBe('待机');
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('状态待确认');
|
||||
});
|
||||
|
||||
it('falls back to a neutral stage placeholder only when no stage is known', () => {
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: { loading: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toBe('正在获取最新状态…');
|
||||
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toBe('待机');
|
||||
});
|
||||
});
|
||||
+26
-21
@@ -4,6 +4,11 @@
|
||||
依赖:vue-i18n、ShippingProcessingBlockingReason/PrimaryAction 类型、resolveShippingProcessingStageLabel。
|
||||
逻辑:主卡内部 section = 「当前阶段/状态/正式OT → 下一步 → 动作区」;
|
||||
状态文案严格绑定 user_status;blocking_reason 只作下一步问题说明;按钮显隐由后端 retryable + primary_action.parameters 决定;
|
||||
主动作按钮文案 fail-closed:后端下发动作码但无受控 i18n 文案时整体隐藏该按钮(含图标),禁止渲染无文字裸按钮;
|
||||
loading 仅代表「权威投影读取中」而非系统运行态:已知阶段/状态/阻断仍照常展示
|
||||
(与投影同源或后端 automation 运行态),空态自然落到「待机/状态待确认」,
|
||||
禁止把读取占位误述为「系统处理中」,也不做骨架→真值的二次刷新;
|
||||
loading 仅在挂载期抑制可执行动作,等权威投影到达后再放行(fail-closed);
|
||||
由 ShippingOrderReviewView 在 mountCurrentProcessingCard 时挂载。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -24,9 +29,6 @@ const props = defineProps<{
|
||||
stageLabelKey?: string | null;
|
||||
stageInconsistent?: boolean;
|
||||
|
||||
hasFormalOt?: boolean;
|
||||
shippingNoticeNo?: string | null;
|
||||
|
||||
userStatus?:
|
||||
| 'running'
|
||||
| 'waiting_human'
|
||||
@@ -70,10 +72,16 @@ const { t, te } = useI18n();
|
||||
|
||||
/**
|
||||
* 当前阶段展示文案:优先消费 stage_label_key,禁止直接展示 stage 码。
|
||||
* 核心逻辑:loading 是「权威投影读取中」占位,不是业务运行态——只要已有可展示的
|
||||
* 阶段(Case 快照 current_stage 与投影同源,见 currentProcessingStageDisplay),
|
||||
* 照常展示真实阶段;仅在连降级阶段都没有时才回退 stageLoading 占位文案。
|
||||
*/
|
||||
const stageLabel = computed(() => {
|
||||
if (props.loading) {
|
||||
return t('chat.shippingOrderReview.caseSwitchLoading');
|
||||
const hasKnownStage = Boolean(
|
||||
String(props.stageCode || '').trim() || String(props.stageLabelKey || '').trim(),
|
||||
);
|
||||
if (props.loading && !hasKnownStage) {
|
||||
return t('chat.shippingOrderReview.currentProcessing.stageLoading');
|
||||
}
|
||||
if (props.stageInconsistent) {
|
||||
return t('chat.shippingOrderReview.currentProcessing.stateInconsistent');
|
||||
@@ -88,11 +96,11 @@ const stageLabel = computed(() => {
|
||||
|
||||
/**
|
||||
* 「状态」行用户态文案:严格绑定 user_status,不再由前端推断。
|
||||
* loading 只是「权威投影读取中」:只要已有后端下发的 user_status(如 Case automation
|
||||
* 运行态)就照常展示真实/待机文案,禁止再退回「正在获取最新状态」骨架造成二次刷新
|
||||
* (状态空时 statusIdle 即中性「待机」,与投影稳态一致)。
|
||||
*/
|
||||
const statusLabel = computed(() => {
|
||||
if (props.loading) {
|
||||
return t('chat.shippingOrderReview.currentTask.statusRunning');
|
||||
}
|
||||
const s = String(props.userStatus || '').trim() as ReviewCurrentUserStatus | '';
|
||||
const map: Record<ReviewCurrentUserStatus, string> = {
|
||||
running: t('chat.shippingOrderReview.currentTask.statusRunning'),
|
||||
@@ -132,9 +140,10 @@ const nextStepText = computed(() => {
|
||||
}
|
||||
return raw;
|
||||
};
|
||||
if (props.loading) {
|
||||
return safeMessage(props.automation?.message) || t('chat.shippingOrderReview.currentTask.nextStepRunning');
|
||||
}
|
||||
// 加载占位不等于系统运行态:只透传后端 automation.message(若有);
|
||||
// 其余按 user_status/blocking_reason 照常渲染,空态自然落在「状态待确认」,不做骨架二次刷新。
|
||||
const automationMessage = props.loading ? safeMessage(props.automation?.message) : '';
|
||||
if (automationMessage) return automationMessage;
|
||||
// 1) blocking_reason → 用后端给的 i18n_key 渲染具体阻断
|
||||
const br = props.blockingReason;
|
||||
if (br) {
|
||||
@@ -219,6 +228,10 @@ function isNonTaskCapabilityAction(code: string): boolean {
|
||||
|
||||
/**
|
||||
* 业务动作按钮只消费 primary_action;retryable 是状态,不是授权。
|
||||
*
|
||||
* 核心逻辑:除既有授权过滤外,文案必须是后端下发且经受控映射解析出的非空文案
|
||||
* (businessActionLabel 已 fail-closed 为 '');无文案时整体隐藏按钮,防止
|
||||
* 渲染成只有图标/空壳的“幽灵按钮”误导用户以为是开关或其他控件。
|
||||
*/
|
||||
const showBusinessAction = computed(() => {
|
||||
if (props.loading) return false;
|
||||
@@ -233,6 +246,8 @@ const showBusinessAction = computed(() => {
|
||||
if (isHiddenWorkbenchNavigationAction(code)) return false;
|
||||
// 无对象边界的泛化 retry 永不展示。
|
||||
if (code === 'retry') return false;
|
||||
// [AUTHORITY] 无受控文案的动作码 fail-closed:连图标一起隐藏,不渲染空壳按钮。
|
||||
if (!businessActionLabel.value) return false;
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -365,16 +380,6 @@ type ReviewCurrentUserStatus =
|
||||
{{ statusLabel }}
|
||||
</dd>
|
||||
</div>
|
||||
<div
|
||||
v-if="hasFormalOt && shippingNoticeNo"
|
||||
class="flex flex-wrap gap-x-2"
|
||||
>
|
||||
<dt class="text-muted">{{ t('chat.shippingOrderReview.currentTask.labelFormalSn') }}</dt>
|
||||
<dd
|
||||
class="font-mono"
|
||||
data-testid="review-current-processing-ot"
|
||||
>{{ shippingNoticeNo }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<p
|
||||
|
||||
@@ -168,8 +168,11 @@ function drawEvidenceHighlight(
|
||||
context.strokeStyle = 'rgba(202, 138, 4, 0.95)';
|
||||
context.setLineDash([]);
|
||||
} else {
|
||||
context.fillStyle = 'rgba(244, 63, 94, 0.18)';
|
||||
context.strokeStyle = 'rgba(225, 29, 72, 0.95)';
|
||||
// unavailable / invalid 证据高亮统一使用品牌色(对齐编辑画布匹配锚点的 sky/brand 蓝),
|
||||
// 避免在纯文档预览上出现刺眼的红色,导致「模板预览图标颜色不一致」的观感。
|
||||
// 说明:质量仅影响可信度提示,不改变「该处确有取值位置」的语义,故不再用警示红。
|
||||
context.fillStyle = 'rgba(14, 165, 233, 0.22)';
|
||||
context.strokeStyle = 'rgba(2, 132, 199, 0.95)';
|
||||
context.setLineDash([3, 3]);
|
||||
}
|
||||
context.lineWidth = 2;
|
||||
|
||||
@@ -23,6 +23,8 @@ import {
|
||||
|
||||
REVIEW_DRAFT_VERSION_MISMATCH,
|
||||
|
||||
PROGRESS_POLL_MS,
|
||||
|
||||
summarizeDraftConflictDiff,
|
||||
|
||||
useShippingOrderReview,
|
||||
@@ -924,7 +926,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.workflowProgressPolling.value).toBe(true);
|
||||
expect(api.getProcessingWorkItem).toHaveBeenCalled();
|
||||
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
expect(review.workflowProgressPolling.value).toBe(false);
|
||||
|
||||
@@ -971,7 +973,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
|
||||
await review.confirm();
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
|
||||
// 关键断言:活动窗口内同步刷新 Case 与队列,让顶部五阶段读取到后端已推进的通知准备。
|
||||
expect(api.getCase.mock.calls.length).toBeGreaterThanOrEqual(2);
|
||||
@@ -1008,13 +1010,13 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
const review = useShippingOrderReview({ onWorkflowRefresh });
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'WFI-1' });
|
||||
await review.confirm();
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(onWorkflowRefresh).toHaveBeenCalled();
|
||||
// RPA 可重试失败不是工作流关闭;必须继续读取后续成功回调的 Projection。
|
||||
expect(review.workflowProgressPolling.value).toBe(true);
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
expect(review.workflowProgressPolling.value).toBe(false);
|
||||
review.stopWorkflowProgressPolling();
|
||||
@@ -1118,7 +1120,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
await review.load('RUN-1', 'CASE-1', { conversationId: 'conv-1', itemNo: 'SWI-1' });
|
||||
await review.reparseDocument('document_quality');
|
||||
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-2');
|
||||
@@ -1240,7 +1242,7 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
await review.reparseDocument('document_quality');
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await Promise.resolve();
|
||||
await vi.advanceTimersByTimeAsync(2600);
|
||||
await vi.advanceTimersByTimeAsync(PROGRESS_POLL_MS + 100);
|
||||
await Promise.resolve();
|
||||
|
||||
expect(review.reviewRun.value?.run_no).toBe('RUN-1');
|
||||
|
||||
@@ -71,6 +71,12 @@ export const REVIEW_DRAFT_VERSION_MISMATCH = 'SHIPPING.REVIEW_DRAFT_VERSION_MISM
|
||||
/** ?????????? confirm ????? */
|
||||
export const REVIEW_BUILD_ELIGIBILITY_BLOCKED = 'SHIPPING.REVIEW_BUILD_ELIGIBILITY_BLOCKED';
|
||||
|
||||
/**
|
||||
* 自动推进轮询基础间隔:5 秒。自动化推进通常是分钟级,原 2.5 秒会对
|
||||
* 单线程/低并发后端造成持续请求排队;页面不可见时轮询另会暂停。
|
||||
*/
|
||||
export const PROGRESS_POLL_MS = 5000;
|
||||
|
||||
/** ????????????/??????????? Case ??? */
|
||||
export type DraftVersionConflict = {
|
||||
localVersion: number;
|
||||
@@ -394,7 +400,6 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
|
||||
let contextItemNo = '';
|
||||
let progressPollTimer: ReturnType<typeof window.setInterval> | null = null;
|
||||
let reparseCaseRefreshTimer: ReturnType<typeof window.setInterval> | null = null;
|
||||
const PROGRESS_POLL_MS = 2500;
|
||||
|
||||
/**
|
||||
* 应用后端返回的完整 Case 快照。
|
||||
@@ -435,6 +440,8 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
|
||||
const targetDocumentId = currentStreamDocumentId();
|
||||
if (!targetRunNo) return;
|
||||
const tick = async () => {
|
||||
// 页面不可见时暂停轮询(返回前台后下一拍自动恢复),避免后台标签持续占用服务端。
|
||||
if (typeof document !== 'undefined' && document.hidden) return;
|
||||
try {
|
||||
const run = await getWorkspaceShippingOrderExtractionRun(targetRunNo);
|
||||
extractionLifecycleProgress.value = run.lifecycle_progress || null;
|
||||
@@ -520,6 +527,8 @@ export function useShippingOrderReview(options: { onWorkflowRefresh?: () => void
|
||||
let lastLifecycleFingerprint = '';
|
||||
const RUN_TERMINAL = new Set(['completed', 'partially_completed', 'failed', 'cancelled']);
|
||||
const tick = async () => {
|
||||
// 页面不可见时暂停轮询(返回前台后下一拍自动恢复),避免后台标签持续占用服务端。
|
||||
if (typeof document !== 'undefined' && document.hidden) return;
|
||||
try {
|
||||
if (authoritativeOrderTaskNo.value) {
|
||||
await refreshShippingProcessing();
|
||||
|
||||
@@ -828,7 +828,10 @@ export interface ShippingTaskSummary {
|
||||
business_no?: string | null;
|
||||
/** 通知单列表只读行摘要;库存数据由后端当前匹配事实投影,前端不得自行计算。 */
|
||||
notice_line_summary?: Array<{
|
||||
/** 项次展示值;来源由 line_no_source 标注,前端不得按行号自行回退。 */
|
||||
line_no?: string | number | null;
|
||||
/** 项次来源:field=冻结字段,customer_po_line_no=客户 PO 行号,sequence=系统行序。 */
|
||||
line_no_source?: 'field' | 'customer_po_line_no' | 'sequence' | string | null;
|
||||
part_number?: string | null;
|
||||
customer_part_number?: string | null;
|
||||
reservation_id?: string | null;
|
||||
@@ -1483,6 +1486,10 @@ export interface ShippingTaskUiState {
|
||||
/** 冻结订单行始终可读;不依赖库存文件或匹配结果。 */
|
||||
frozen_order_lines?: Array<{
|
||||
line_key?: string | null;
|
||||
/** 项次展示值;来源由 line_no_source 标注。 */
|
||||
line_no?: string | number | null;
|
||||
/** 项次来源:field=冻结字段,customer_po_line_no=客户 PO 行号,sequence=系统行序。 */
|
||||
line_no_source?: 'field' | 'customer_po_line_no' | 'sequence' | string | null;
|
||||
reservation_id?: string | null;
|
||||
part_number?: string | null;
|
||||
required_qty?: string | number | null;
|
||||
@@ -1500,6 +1507,10 @@ export interface ShippingTaskUiState {
|
||||
has_match_result?: boolean;
|
||||
lines?: Array<{
|
||||
line_key?: string | null;
|
||||
/** 项次展示值;来源由 line_no_source 标注。 */
|
||||
line_no?: string | number | null;
|
||||
/** 项次来源:field=冻结字段,customer_po_line_no=客户 PO 行号,sequence=系统行序。 */
|
||||
line_no_source?: 'field' | 'customer_po_line_no' | 'sequence' | string | null;
|
||||
reservation_id?: string | null;
|
||||
part_number?: string | null;
|
||||
required_qty?: string | number | null;
|
||||
@@ -1619,10 +1630,23 @@ export interface ShippingFreightNoticeGroup {
|
||||
business_no: string;
|
||||
po_number: string | null;
|
||||
upload_status?: string | null;
|
||||
/** 上传方式:rpa / manual,用于逐单状态展示。 */
|
||||
upload_mode?: string | null;
|
||||
/** 已发起的上传尝试次数,用于逐单状态展示。 */
|
||||
upload_attempt?: number | null;
|
||||
/** 最近一次上传的稳定错误码(如 RPA_UPLOAD_FAILED / FREIGHT_REJECTED / UPLOAD_RESULT_UNKNOWN)。 */
|
||||
upload_error_code?: string | null;
|
||||
/** 最近一次上传的用户可见失败原因;仅后端事实,禁止前端按状态猜测。 */
|
||||
upload_error_message?: string | null;
|
||||
/** 需人工接管的原因码(如 upload_rpa_pending / manual_upload_pending)。 */
|
||||
pending_human_reason?: string | null;
|
||||
export_file_name?: string | null;
|
||||
available_actions?: string[];
|
||||
lines: Array<{
|
||||
/** 项次展示值;来源由 line_no_source 标注,前端不得按行号自行回退。 */
|
||||
line_no?: string | number | null;
|
||||
/** 项次来源:field=冻结字段,customer_po_line_no=客户 PO 行号,sequence=系统行序。 */
|
||||
line_no_source?: 'field' | 'customer_po_line_no' | 'sequence' | string | null;
|
||||
part_number?: string | null;
|
||||
reservation_id?: string | null;
|
||||
shipment_qty?: string | number | null;
|
||||
|
||||
@@ -594,6 +594,7 @@ async function mountView(query: Record<string, string> = {}) {
|
||||
waiting_to_start: '等待系统启动',
|
||||
order_creating: '等待系统启动',
|
||||
inventory_matching: '库存匹配',
|
||||
excel_generating: 'Excel 生成',
|
||||
},
|
||||
},
|
||||
currentTask: {
|
||||
@@ -680,7 +681,14 @@ async function mountView(query: Record<string, string> = {}) {
|
||||
},
|
||||
progress: {
|
||||
step: { profile_matching: '正在匹配订单模板' },
|
||||
lifecycleReason: { processing_slow: '当前步骤耗时较长,系统仍在继续。' },
|
||||
lifecycleReason: {
|
||||
processing_slow: '当前步骤耗时较长,系统仍在继续。',
|
||||
review_required: '当前结果需要人工复核。',
|
||||
failed: '当前步骤处理失败,请查看详情后重试。',
|
||||
cancelled: '本次处理已取消。',
|
||||
},
|
||||
systemProcessingNeed: '系统正在自动处理,请稍候或刷新进度',
|
||||
lifecycleWaitingNeed: '当前步骤需要人工处理',
|
||||
},
|
||||
},
|
||||
shippingSessionWorkItem: {
|
||||
@@ -873,6 +881,54 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(wrapper.get('[data-testid="review-run-lifecycle-progress"]').text()).toContain('正在匹配订单模板');
|
||||
});
|
||||
|
||||
it('does not claim automatic processing when the run is waiting at a human gate', async () => {
|
||||
// 关键断言:门禁待机(waiting)时不得声称「系统正在自动处理」,也不得渲染呼吸点;
|
||||
// 后端此时通常没有 current_step_i18n_key,旧逻辑会落入自动处理兜底文案。
|
||||
activeCase.value = null as any;
|
||||
reviewRun.value = { run_no: 'RUN-WAITING-GATE', items: [] };
|
||||
extractionLifecycleProgress.value = {
|
||||
lifecycle_stage: 'order_review', lifecycle_status: 'waiting',
|
||||
current_step_i18n_key: null,
|
||||
blocking_reason_i18n_key: 'chat.shippingProcessing.progress.lifecycleReason.review_required',
|
||||
completed_step_codes: [], health_status: 'normal',
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
const banner = wrapper.get('[data-testid="review-run-lifecycle-current-step"]');
|
||||
expect(banner.text()).not.toContain('系统正在自动处理');
|
||||
expect(banner.text()).toContain('当前结果需要人工复核');
|
||||
expect(banner.html()).not.toContain('animate-pulse');
|
||||
});
|
||||
|
||||
it('shows a waiting fallback without the auto-processing claim when no reason is provided', async () => {
|
||||
// 关键断言:waiting 且后端未给原因/步骤时,只展示「需要人工处理」,禁止回到自动处理文案。
|
||||
activeCase.value = null as any;
|
||||
reviewRun.value = { run_no: 'RUN-WAITING-FALLBACK', items: [] };
|
||||
extractionLifecycleProgress.value = {
|
||||
lifecycle_stage: 'order_review', lifecycle_status: 'waiting',
|
||||
current_step_i18n_key: null,
|
||||
blocking_reason_i18n_key: null,
|
||||
completed_step_codes: [], health_status: 'normal',
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
const banner = wrapper.get('[data-testid="review-run-lifecycle-current-step"]');
|
||||
expect(banner.text()).not.toContain('系统正在自动处理');
|
||||
expect(banner.text()).toContain('当前步骤需要人工处理');
|
||||
});
|
||||
|
||||
it('does not render the run progress banner for a completed run', async () => {
|
||||
// 关键断言:Run 已完成时无待办,横幅直接隐藏,避免「已完成仍显示处理中」的矛盾。
|
||||
activeCase.value = null as any;
|
||||
reviewRun.value = { run_no: 'RUN-COMPLETED', items: [] };
|
||||
extractionLifecycleProgress.value = {
|
||||
lifecycle_stage: 'order_review', lifecycle_status: 'completed',
|
||||
current_step_i18n_key: null,
|
||||
blocking_reason_i18n_key: null,
|
||||
completed_step_codes: ['review_ready'], health_status: 'normal',
|
||||
};
|
||||
const wrapper = await mountView();
|
||||
expect(wrapper.find('[data-testid="review-run-lifecycle-current-step"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('loads a cross-Run file once through the route watcher', async () => {
|
||||
const originalQueue = reviewQueue.value;
|
||||
try {
|
||||
@@ -1211,6 +1267,30 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(wrapper.find('[data-testid="review-current-task-primary-action"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the known Case stage while the authoritative projection is still loading', async () => {
|
||||
// Case 先到、Projection 后到的过渡窗口:阶段与投影同源(project_stage_for_task),
|
||||
// 必须直接展示「Excel 生成」,禁止退回自动建单阶段或“正在更新状态”占位。
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
status: 'confirmed',
|
||||
has_formal_ot: true,
|
||||
task_missing: false,
|
||||
confirmed_task_id: 91,
|
||||
confirmed_task_no: 'SN-STAGE-PENDING',
|
||||
current_stage: { code: 'excel_generating', label_key: 'excel_generating', inconsistent: false },
|
||||
automation: { status: 'running', retryable: false, can_auto_create: false, can_build: true },
|
||||
};
|
||||
shippingProcessingProjection.value = null;
|
||||
shippingProcessingLoading.value = true;
|
||||
|
||||
const wrapper = await mountView();
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-stage"]').text()).toContain('Excel 生成');
|
||||
// 状态列:loading 只抑制动作,不掩盖后端 automation 运行态真值(系统处理中)。
|
||||
expect(wrapper.get('[data-testid="review-current-task-status"]').text()).toContain('系统处理中');
|
||||
});
|
||||
|
||||
it('does not render legacy reparse failure stage as a separate progress source', async () => {
|
||||
reviewProgressContext.value = {
|
||||
item_no: 'WFI-1',
|
||||
@@ -2047,6 +2127,120 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(startWorkflowProgressPollingMock).toHaveBeenCalledTimes(2);
|
||||
});
|
||||
|
||||
it('advances to freight upload after an accepted shortage release', async () => {
|
||||
const taskApi = await import('@/features/chat/api/shipping.api');
|
||||
let releaseAccepted = false;
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
status: 'confirmed', confirmed_task_id: 903, confirmed_task_no: 'SN-FROZEN', has_formal_ot: true,
|
||||
line_fulfillment: {
|
||||
lines: [{
|
||||
line_key: 'line-frozen',
|
||||
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
}],
|
||||
},
|
||||
};
|
||||
vi.mocked(taskApi.decideWorkspaceShippingOrderReviewLineFulfillment).mockImplementation(async () => {
|
||||
releaseAccepted = true;
|
||||
return { status: 'ok' } as any;
|
||||
});
|
||||
vi.mocked(taskApi.getWorkspaceShippingTask).mockImplementation(async () => ({
|
||||
task_no: 'SN-FROZEN', status: 'waiting_human', lines: [], events: [],
|
||||
ui_state: {
|
||||
process_gate: {
|
||||
execution_no: 'EXEC-FROZEN-LINE',
|
||||
current_blocking_gate: { gate_code: 'manual_upload_handoff', status: 'blocked_manual' },
|
||||
},
|
||||
actions: { primary: null, secondary: [] },
|
||||
lifecycle_stage: releaseAccepted ? 'freight_upload' : 'fulfillment_prep',
|
||||
lifecycle_entries: releaseAccepted
|
||||
? [
|
||||
{ code: 'fulfillment_prep', state: 'available' },
|
||||
{ code: 'freight_upload', state: 'current' },
|
||||
]
|
||||
: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
stage_context: { upload: {} },
|
||||
},
|
||||
} as any));
|
||||
|
||||
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
|
||||
await flushPromises();
|
||||
await wrapper.get('[data-testid="review-fulfillment-line-release-line-frozen"]').trigger('click');
|
||||
const dialog = wrapper.get('[data-testid="review-release-inventory-dialog"]');
|
||||
await dialog.find('textarea').setValue('客户确认分批发货');
|
||||
await dialog.find('input').setValue('A-01');
|
||||
await dialog.get('button.bg-amber-600').trigger('click');
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
|
||||
// 放行后的首个权威刷新抵达目标阶段时,页面必须同步深链。
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBe('freight_upload');
|
||||
});
|
||||
|
||||
it('keeps notification preparation when the user navigates there while a shortage release is advancing', async () => {
|
||||
const taskApi = await import('@/features/chat/api/shipping.api');
|
||||
let releaseAccepted = false;
|
||||
let resolvePostReleaseTask: ((detail: any) => void) | null = null;
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
status: 'confirmed', confirmed_task_id: 904, confirmed_task_no: 'SN-MANUAL', has_formal_ot: true,
|
||||
line_fulfillment: {
|
||||
lines: [{
|
||||
line_key: 'line-manual',
|
||||
inventory_source: { code: 'DBS', label: 'DBS', status: 'resolved' },
|
||||
line_allowed_actions: ['release_inventory_shortage'],
|
||||
release_template_fields: [
|
||||
{ field_id: '101', display_name: 'ODM ID', value: 'ODM-001', value_source: 'inventory_snapshot', requires_manual: false },
|
||||
{ field_id: '102', display_name: '库位', value: null, value_source: 'manual_required', requires_manual: true },
|
||||
],
|
||||
release_required_fields: [{ field_id: '102', display_name: '库位' }],
|
||||
}],
|
||||
},
|
||||
};
|
||||
const taskDetail = () => ({
|
||||
task_no: 'SN-MANUAL', status: 'waiting_human', lines: [], events: [],
|
||||
ui_state: {
|
||||
process_gate: { execution_no: 'EXEC-MANUAL-LINE', current_blocking_gate: { gate_code: 'manual_upload_handoff', status: 'blocked_manual' } },
|
||||
actions: { primary: null, secondary: [] },
|
||||
lifecycle_stage: releaseAccepted ? 'freight_upload' : 'fulfillment_prep',
|
||||
lifecycle_entries: releaseAccepted
|
||||
? [{ code: 'fulfillment_prep', state: 'available' }, { code: 'freight_upload', state: 'current' }]
|
||||
: [{ code: 'fulfillment_prep', state: 'current' }],
|
||||
stage_context: { upload: {} },
|
||||
},
|
||||
});
|
||||
vi.mocked(taskApi.decideWorkspaceShippingOrderReviewLineFulfillment).mockImplementation(async () => {
|
||||
releaseAccepted = true;
|
||||
return { status: 'ok' } as any;
|
||||
});
|
||||
vi.mocked(taskApi.getWorkspaceShippingTask).mockImplementation(async () => {
|
||||
if (!releaseAccepted) return taskDetail() as any;
|
||||
return new Promise((resolve) => { resolvePostReleaseTask = resolve; });
|
||||
});
|
||||
|
||||
const wrapper = await mountView({ lifecycle_stage: 'fulfillment_prep' });
|
||||
await wrapper.get('[data-testid="review-fulfillment-line-release-line-manual"]').trigger('click');
|
||||
const dialog = wrapper.get('[data-testid="review-release-inventory-dialog"]');
|
||||
await dialog.find('textarea').setValue('客户确认分批发货');
|
||||
await dialog.find('input').setValue('A-01');
|
||||
await dialog.get('button.bg-amber-600').trigger('click');
|
||||
await wrapper.get('[data-testid="review-lifecycle-stage-fulfillment_prep"]').findAll('button')[1].trigger('click');
|
||||
resolvePostReleaseTask?.(taskDetail());
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 0));
|
||||
await nextTick();
|
||||
|
||||
// 用户显式回看通知准备会消费本次自动推进许可,后端异步投影不得抢回焦点。
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBe('fulfillment_prep');
|
||||
});
|
||||
|
||||
it('keeps the manual notice-generation entry in the main workspace for an editable formal task', async () => {
|
||||
const taskApi = await import('@/features/chat/api/shipping.api');
|
||||
reviewEditable.value = false;
|
||||
@@ -2632,16 +2826,27 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
summary: {}, steps: [],
|
||||
},
|
||||
} as any);
|
||||
// 完成面改版后按「已上传通知聚合」消费同一份 freight groups;仅 uploaded 通知进入完成面。
|
||||
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: [
|
||||
{ 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: [] },
|
||||
],
|
||||
} as any);
|
||||
|
||||
const wrapper = await mountView({ lifecycle_stage: 'upload_complete' });
|
||||
await flushPromises();
|
||||
|
||||
const evidence = wrapper.get('[data-testid="review-lifecycle-upload-complete"]');
|
||||
expect(evidence.text()).toContain('succeeded');
|
||||
expect(evidence.text()).not.toContain('LATEST-FAILED');
|
||||
// 只展示已上传通知(uploaded),未上传(pending)不进入完成面。
|
||||
expect(evidence.text()).toContain('WYC26082401');
|
||||
expect(evidence.text()).not.toContain('WYC26082402');
|
||||
// 人工确认不再展示或依赖货代回执号,即使历史投影仍带有 freight_ref_no。
|
||||
expect(evidence.text()).not.toContain('LEGACY-REF-MUST-NOT-BE-SHOWN');
|
||||
expect(evidence.text()).not.toContain('failed');
|
||||
expect(evidence.text()).not.toContain('LATEST-FAILED');
|
||||
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);
|
||||
});
|
||||
@@ -2894,7 +3099,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
expect(wrapper.find('[data-testid="review-confirm-outcome"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="retry-auto-progress-after-confirm"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-RECOVER-1');
|
||||
// 发货通知单号与订单明细行绑定,不在任务级整单显示;当前任务卡不展示单条通知单号。
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').exists()).toBe(false);
|
||||
}, 15000);
|
||||
|
||||
it('does not submit an action before the formal OT Gate projection arrives (UI-01)', async () => {
|
||||
@@ -3168,7 +3374,8 @@ describe('ShippingOrderReviewView audit and progress recovery', () => {
|
||||
await flushPromises();
|
||||
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-retry"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').text()).toContain('SN-CONFIRM-PROGRESS-FAIL');
|
||||
// 发货通知单号随订单明细绑定,不在任务级整单展示;当前任务卡不含单条通知单号。
|
||||
expect(wrapper.find('[data-testid="review-current-processing-ot"]').exists()).toBe(false);
|
||||
}, 15000);
|
||||
});
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { Bot, Check, Crosshair, Download, MoreHorizontal, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { Bot, Check, ChevronDown, Crosshair, Download, MoreHorizontal, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
@@ -193,7 +193,8 @@ const {
|
||||
const msg = useMessage();
|
||||
|
||||
/**
|
||||
* 右侧主卡阶段:优先 Progress 投影(与顶部同源);Case current_stage 仅降级。
|
||||
* 右侧主卡阶段:优先 Progress 投影(与顶部同源);正式 OT 投影未到时用
|
||||
* Case.current_stage(与投影同源 project_stage_for_task),建单前 automation 仅作降级。
|
||||
* 无论哪一路都带 label_key,禁止把 code 当用户文案。
|
||||
*/
|
||||
const currentProcessingStageDisplay = computed(() => {
|
||||
@@ -206,6 +207,19 @@ const currentProcessingStageDisplay = computed(() => {
|
||||
inconsistent: false,
|
||||
};
|
||||
}
|
||||
const caseStage = activeCase.value?.current_stage;
|
||||
const caseCode = String(caseStage?.code || '').trim();
|
||||
// 正式 OT 的 Case.current_stage 与统一投影同源(project_stage_for_task):
|
||||
// 投影读取中(正式任务已存在、投影在途)也必须先展示真实阶段,
|
||||
// 禁止被下方 automation 分支降级为“创建正式订单”自动建单阶段。
|
||||
if (hasFormalOt.value && caseCode) {
|
||||
return {
|
||||
code: caseCode,
|
||||
labelKey: caseStage?.label_key
|
||||
|| (caseCode === 'order_creating' ? 'waiting_system_start' : caseCode),
|
||||
inconsistent: Boolean(caseStage?.inconsistent),
|
||||
};
|
||||
}
|
||||
// STP 建单前尚无正式 OT/processing projection;自动建单 Job 仍属于“创建正式订单”阶段。
|
||||
const automationStatus = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
|
||||
if (['queued', 'running', 'failed', 'manual_fallback'].includes(automationStatus)) {
|
||||
@@ -215,12 +229,10 @@ const currentProcessingStageDisplay = computed(() => {
|
||||
inconsistent: false,
|
||||
};
|
||||
}
|
||||
const caseStage = activeCase.value?.current_stage;
|
||||
const code = String(caseStage?.code || '').trim() || null;
|
||||
return {
|
||||
code,
|
||||
code: caseCode || null,
|
||||
labelKey: caseStage?.label_key
|
||||
|| (code === 'order_creating' ? 'waiting_system_start' : code),
|
||||
|| (caseCode === 'order_creating' ? 'waiting_system_start' : caseCode),
|
||||
inconsistent: Boolean(caseStage?.inconsistent),
|
||||
};
|
||||
});
|
||||
@@ -407,6 +419,34 @@ async function retryCurrentIntakeParse(): Promise<void> {
|
||||
* 只切换前端工作面并同步可分享深链;禁止在导航点击中修改任何订单生命周期字段。
|
||||
*/
|
||||
const lifecycleStagePinnedByUserForCase = ref<string | null>(null);
|
||||
/** 仅库存短缺放行可建立一次性自动推进许可,避免通用 Gate 恢复抢占用户导航。 */
|
||||
const pendingReleaseAutoAdvanceCaseNo = ref<string | null>(null);
|
||||
|
||||
/**
|
||||
* 消费库存短缺放行后的自动推进许可。
|
||||
*
|
||||
* 仅当同一 Case 仍停留在放行前的通知准备路由、用户未在放行后手动选阶段,且后端
|
||||
* 权威投影已推进时替换深链。异步 Job 的首个投影可直接到目标阶段,不能依赖 watch
|
||||
* 是否曾观察到旧阶段。
|
||||
*/
|
||||
async function syncPendingReleaseAutoAdvance(): Promise<boolean> {
|
||||
const caseNo = String(activeCase.value?.case_no || '').trim();
|
||||
if (!caseNo || pendingReleaseAutoAdvanceCaseNo.value !== caseNo) return false;
|
||||
const requested = String(route.query.lifecycle_stage || '').trim();
|
||||
if (
|
||||
requested !== 'fulfillment_prep'
|
||||
|| lifecycleStagePinnedByUserForCase.value === caseNo
|
||||
) {
|
||||
pendingReleaseAutoAdvanceCaseNo.value = null;
|
||||
return false;
|
||||
}
|
||||
const current = lifecycleCurrentStageCode.value;
|
||||
const currentIndex = current ? LIFECYCLE_STAGE_CODES.indexOf(current) : -1;
|
||||
if (currentIndex <= LIFECYCLE_STAGE_CODES.indexOf('fulfillment_prep')) return false;
|
||||
pendingReleaseAutoAdvanceCaseNo.value = null;
|
||||
await selectLifecycleStage(current!, { replace: true });
|
||||
return true;
|
||||
}
|
||||
|
||||
async function selectLifecycleStage(code: ReviewLifecycleStageCode, options: { replace?: boolean } = {}) {
|
||||
const target = lifecycleStageItems.value.find((item) => item.code === code);
|
||||
@@ -414,7 +454,11 @@ async function selectLifecycleStage(code: ReviewLifecycleStageCode, options: { r
|
||||
// 用户主动回看已完成阶段时,异步投影抵达不得将其强制带回当前阶段。
|
||||
// 自动推进均使用 replace,不会写入该意图。
|
||||
if (!options.replace) {
|
||||
lifecycleStagePinnedByUserForCase.value = String(activeCase.value?.case_no || '').trim() || null;
|
||||
const caseNo = String(activeCase.value?.case_no || '').trim() || null;
|
||||
lifecycleStagePinnedByUserForCase.value = caseNo;
|
||||
if (pendingReleaseAutoAdvanceCaseNo.value === caseNo) {
|
||||
pendingReleaseAutoAdvanceCaseNo.value = null;
|
||||
}
|
||||
}
|
||||
if (code === 'intake_parse' && intakeParseContextAuthorized.value && activeCase.value?.case_no) {
|
||||
void ensureIntakeParseContextLoaded(activeCase.value.case_no);
|
||||
@@ -472,7 +516,10 @@ watch(activeCase, (value) => {
|
||||
watch(
|
||||
() => String(activeCase.value?.case_no || '').trim(),
|
||||
(caseNo, previousCaseNo) => {
|
||||
if (caseNo !== previousCaseNo) lifecycleStagePinnedByUserForCase.value = null;
|
||||
if (caseNo !== previousCaseNo) {
|
||||
lifecycleStagePinnedByUserForCase.value = null;
|
||||
pendingReleaseAutoAdvanceCaseNo.value = null;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
@@ -628,7 +675,9 @@ const currentTaskPrimaryAction = computed(() => {
|
||||
return null;
|
||||
});
|
||||
const currentTaskUserStatus = computed(() => {
|
||||
if (formalTaskProjectionPending.value) return null;
|
||||
// 已确认 OT 且权威投影在途时,先消费后端 automation 运行态(queued/running → running,
|
||||
// failed/manual_fallback → failed),状态行即显真实值,不应退回「正在获取最新状态」骨架;
|
||||
// authority 仍以右侧投影为准,投影到达后覆盖。
|
||||
if (currentTaskUiState.value?.status) return currentTaskUiState.value.status;
|
||||
// 建单前没有正式 OT 投影时,直接消费后端 Case automation 状态,避免页面看起来卡死。
|
||||
const status = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
|
||||
@@ -1458,16 +1507,23 @@ async function retryFormalUploadRpa(taskNo: string) {
|
||||
* 处理 Gate 恢复已被后端受理后的页面同步。
|
||||
*
|
||||
* 核心逻辑:恢复 Job 尚未完成时立即恢复用户交互,并重启五阶段轮询;三个只读投影
|
||||
* 在后台刷新,避免把网络读取时间误表现为“恢复按钮卡住”。
|
||||
* 在后台刷新,避免把网络读取时间误表现为“恢复按钮卡住”。库存短缺放行可额外建立
|
||||
* 一次性自动推进许可,待后端生命周期投影确认后才更新深链。
|
||||
*/
|
||||
function handleGateRecoveryAccepted() {
|
||||
function handleGateRecoveryAccepted(options: { releaseAutoAdvance?: boolean } = {}) {
|
||||
const caseNo = String(activeCase.value?.case_no || '').trim();
|
||||
if (options.releaseAutoAdvance && caseNo) {
|
||||
// 放行前可能是用户手动进入通知准备;该历史意图不能阻止本次放行后的自动推进。
|
||||
lifecycleStagePinnedByUserForCase.value = null;
|
||||
pendingReleaseAutoAdvanceCaseNo.value = caseNo;
|
||||
}
|
||||
page.bumpWorkflowRefresh?.();
|
||||
startWorkflowProgressPolling();
|
||||
void Promise.allSettled([
|
||||
loadFormalTaskDetail(),
|
||||
reloadLatestDraft(),
|
||||
refreshShippingProcessing(),
|
||||
]);
|
||||
]).then(() => { void syncPendingReleaseAutoAdvance(); });
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1998,6 +2054,48 @@ const lifecycleProgressReasonText = computed(() => {
|
||||
if (!progress?.blocking_reason_i18n_key || !te(progress.blocking_reason_i18n_key)) return null;
|
||||
return t(progress.blocking_reason_i18n_key);
|
||||
});
|
||||
/**
|
||||
* Run 级进度横幅的统一展示消息。
|
||||
*
|
||||
* 核心逻辑:只有后端裁决 lifecycle_status == 'running' 才能声称「系统正在自动处理」;
|
||||
* waiting(门禁待机)/ failed / cancelled 只展示等待/失败原因或步骤文本,禁止自动处理文案
|
||||
* 与门禁状态自相矛盾;completed 时 Run 已无待办,横幅直接隐藏。
|
||||
* 注意:后端仅在 running 下才有 current_step_i18n_key,因此旧逻辑在 waiting 时
|
||||
* 会落入「系统正在自动处理」兜底文案,这正是本函数要消除的错误展示。
|
||||
* 该横幅是「提取 Run(建单前流水线)」的运行提示,只在未有正式 OT 时展示
|
||||
* (模板 v-if !hasFormalOt);正式 OT 后进度与操作指引由右栏当前任务卡承载。
|
||||
*/
|
||||
const lifecycleProgressMessage = computed<{
|
||||
auto: boolean;
|
||||
text: string;
|
||||
reason: string | null;
|
||||
} | null>(() => {
|
||||
const progress = lifecycleProgressForView.value;
|
||||
if (!progress) return null;
|
||||
const status = String(progress.lifecycle_status || '').trim().toLowerCase();
|
||||
const stepText = lifecycleProgressStepText.value;
|
||||
const reasonText = lifecycleProgressReasonText.value;
|
||||
if (status === 'running') {
|
||||
return {
|
||||
auto: true,
|
||||
text: stepText || t('chat.shippingProcessing.progress.systemProcessingNeed'),
|
||||
reason: reasonText,
|
||||
};
|
||||
}
|
||||
if (status === 'completed') return null;
|
||||
if (status === 'failed') {
|
||||
return { auto: false, text: reasonText || t('chat.shippingProcessing.progress.lifecycleReason.failed'), reason: null };
|
||||
}
|
||||
if (status === 'cancelled') {
|
||||
return { auto: false, text: reasonText || t('chat.shippingProcessing.progress.lifecycleReason.cancelled'), reason: null };
|
||||
}
|
||||
// waiting 或未知状态:绝不声称自动处理,优先展示后端原因,其次步骤文本。
|
||||
return {
|
||||
auto: false,
|
||||
text: reasonText || stepText || t('chat.shippingProcessing.progress.lifecycleWaitingNeed'),
|
||||
reason: null,
|
||||
};
|
||||
});
|
||||
const lifecycleProgressActiveCode = computed<ReviewLifecycleStageCode | null>(() => {
|
||||
const code = lifecycleProgressForView.value?.lifecycle_stage;
|
||||
return LIFECYCLE_STAGE_CODES.includes(code as ReviewLifecycleStageCode)
|
||||
@@ -2107,14 +2205,39 @@ const freightNoticeGroups = ref<ShippingFreightNoticeGroup[]>([]);
|
||||
const freightNoticeGroupsLoading = ref(false);
|
||||
const freightNoticeGroupsReason = ref<string | null>(null);
|
||||
const freightNoticeGroupsLoadFailed = ref(false);
|
||||
/** 右栏业务主身份必须是 business_no;技术 OT 仅用于内部追踪。 */
|
||||
const currentShippingBusinessNo = computed(() => (
|
||||
String(formalTaskDetail.value?.business_no || '').trim()
|
||||
|| String(shippingProcessingProjection.value?.shippingNoticeNo || '').trim()
|
||||
|| null
|
||||
));
|
||||
const selectedFreightBusinessNos = ref<string[]>([]);
|
||||
const freightBatchBusy = ref<'download' | 'confirm' | 'rpa' | 'regenerate' | null>(null);
|
||||
/**
|
||||
* 通知完成面的只读聚合:同 PO 中已有上传成功证据(upload_status=uploaded)的发货通知。
|
||||
* 核心逻辑:与货代上传面消费同一份 freightNoticeGroups,仅按终态过滤;未上传的
|
||||
* 通知仍留在货代上传面处理,完成面不出现混淆态。
|
||||
*/
|
||||
const uploadedFreightNoticeGroups = computed(() =>
|
||||
freightNoticeGroups.value.filter((item) =>
|
||||
String(item.upload_status || '').trim().toLowerCase() === 'uploaded',
|
||||
),
|
||||
);
|
||||
/** 批次留底下载:把已完成通知全部打包为 ZIP(复用后端 /shipping-notices/batch/export)。 */
|
||||
const uploadingBatchArchive = ref(false);
|
||||
async function downloadCompletedBatchArchive() {
|
||||
const businessNos = uploadedFreightNoticeGroups.value
|
||||
.map((item) => String(item.business_no || '').trim())
|
||||
.filter(Boolean);
|
||||
if (!businessNos.length || uploadingBatchArchive.value) return;
|
||||
uploadingBatchArchive.value = true;
|
||||
try {
|
||||
await downloadWorkspaceShippingNoticeExportArchive(businessNos);
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
uploadingBatchArchive.value = false;
|
||||
}
|
||||
}
|
||||
/** 通知完成面的展开明细:同一时刻只展开一张通知(与货代上传面交互一致)。 */
|
||||
const expandedCompletedNoticeNo = ref<string | null>(null);
|
||||
function toggleCompletedNoticeLine(businessNo: string) {
|
||||
expandedCompletedNoticeNo.value = expandedCompletedNoticeNo.value === businessNo ? null : businessNo;
|
||||
}
|
||||
const formalTaskDetailLoading = ref(false);
|
||||
const formalTaskDetailLoadFailed = ref(false);
|
||||
/**
|
||||
@@ -2136,7 +2259,10 @@ const formalPreparationContext = computed(() => {
|
||||
if (!fallbackLines.length) return preparation;
|
||||
return {
|
||||
...(preparation || {}),
|
||||
status: preparation?.status || 'processing',
|
||||
// [B1] 回退展示(任务详情未到、仅有 Case line_fulfillment)时不得伪造 status='processing':
|
||||
// 那会让「processing → ready / blocked」看起来像二次刷新;真实状态由任务详情到达后显示,
|
||||
// 徽章在状态为空时保持隐藏。
|
||||
status: preparation?.status ?? null,
|
||||
frozen_order: preparation?.frozen_order || {
|
||||
task_no: confirmedNoticeTaskNo.value || null,
|
||||
snapshot_id: null,
|
||||
@@ -2249,7 +2375,7 @@ async function confirmReleaseInventoryShortage() {
|
||||
// 放行写入成功即结束用户交互;Notice/Excel 由后端 Job 异步创建,不能让只读刷新
|
||||
// 持续占用确认按钮。重启工作台轮询以立即接住新 Notice 的处理投影。
|
||||
releaseInventoryBusy.value = false;
|
||||
handleGateRecoveryAccepted();
|
||||
handleGateRecoveryAccepted({ releaseAutoAdvance: true });
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
} finally {
|
||||
@@ -2331,8 +2457,11 @@ async function loadFormalTaskDetail() {
|
||||
formalTaskDetailLoadFailed.value = false;
|
||||
return;
|
||||
}
|
||||
// 请求在途期间不保留上一文件详情,生命周期导航会自然回退至当前 Case/实时 Projection。
|
||||
formalTaskDetail.value = null;
|
||||
// 仅任务切换时清空旧详情。同一任务的刷新若先清空,会让 lifecycle_stage 在
|
||||
// freight_upload 与空值之间来回跳,进而触发工作面 watcher 的重复拉取循环。
|
||||
if (formalTaskDetail.value?.task_no !== taskNo) {
|
||||
formalTaskDetail.value = null;
|
||||
}
|
||||
formalTaskDetailLoadFailed.value = false;
|
||||
formalTaskDetailLoading.value = true;
|
||||
try {
|
||||
@@ -2407,6 +2536,11 @@ async function runFreightBatchAction(action: 'download' | 'confirm' | 'rpa') {
|
||||
} else {
|
||||
await batchStartWorkspaceShippingNoticeRpaUpload(selectedFreightBusinessNos.value);
|
||||
}
|
||||
// 确认/RPA 后重拉同 PO 通知聚合,使通知完成面能立即呈现最新 uploaded 状态。
|
||||
if (action === 'confirm' || action === 'rpa') {
|
||||
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (taskNo) await loadFreightNoticeGroups(taskNo);
|
||||
}
|
||||
await Promise.all([loadFormalTaskDetail(), refreshShippingProcessing()]);
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
@@ -2438,6 +2572,9 @@ async function runFreightNoticeAction(
|
||||
await submitFormalGateAction('regenerate_excel_artifact');
|
||||
return;
|
||||
}
|
||||
// 确认/RPA 后重拉同 PO 通知聚合,使通知完成面能立即呈现最新 uploaded 状态。
|
||||
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (taskNo) await loadFreightNoticeGroups(taskNo);
|
||||
await Promise.all([loadFormalTaskDetail(), refreshShippingProcessing()]);
|
||||
} catch (error) {
|
||||
msg.warning(error instanceof Error ? error.message : t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
@@ -2461,13 +2598,14 @@ function canRunFreightNoticeAction(group: ShippingFreightNoticeGroup, actionCode
|
||||
}
|
||||
|
||||
watch(
|
||||
[confirmedNoticeTaskNo, workbenchMode, hasCreatedShippingTask, isLifecycleFreightUpload],
|
||||
([taskNo, mode, created, isFreightUpload]) => {
|
||||
[confirmedNoticeTaskNo, workbenchMode, hasCreatedShippingTask, isLifecycleFreightUpload, isLifecycleUploadComplete],
|
||||
([taskNo, mode, created, isFreightUpload, isUploadComplete]) => {
|
||||
const completed = String(displayCase.value?.current_stage?.code || '').trim().toLowerCase() === 'completed'
|
||||
|| String(displayCase.value?.user_status || '').trim().toLowerCase() === 'completed';
|
||||
// Notice 聚合只服务货代上传工作面;通知准备/文件切换不能为此扫描同 PO 全部 Notice。
|
||||
if (taskNo && created && isFreightUpload) void loadFreightNoticeGroups(taskNo);
|
||||
if (!isFreightUpload) {
|
||||
// Notice 聚合服务货代上传与通知完成两个工作面;通知准备/文件切换不扫描同 PO 全部 Notice。
|
||||
const needsNoticeGroups = isFreightUpload || isUploadComplete;
|
||||
if (taskNo && created && needsNoticeGroups) void loadFreightNoticeGroups(taskNo);
|
||||
if (!needsNoticeGroups) {
|
||||
freightNoticeGroups.value = [];
|
||||
selectedFreightBusinessNos.value = [];
|
||||
}
|
||||
@@ -2603,6 +2741,102 @@ function preparationLineCustomerPoLine(line: { line_key?: string | null; custome
|
||||
return draftValueText || String(line.customer_po_line_no || '').trim() || '—';
|
||||
}
|
||||
|
||||
/**
|
||||
* 通知行项次展示:按后端 line_no_source 区分渲染。
|
||||
* 核心逻辑:field=冻结字段真实值(普通展示);customer_po_line_no=客户 PO 行号(普通展示,
|
||||
* 附带来源提示);sequence=系统行序(弱化样式 + 来源提示);缺失直接显示 —。
|
||||
* 禁止前端按 position/序号自行推导业务项次。
|
||||
*/
|
||||
function freightLineNoDisplay(line: { line_no?: string | number | null; line_no_source?: string | null }): {
|
||||
text: string;
|
||||
muted: boolean;
|
||||
title: string;
|
||||
} {
|
||||
const value = line.line_no ?? null;
|
||||
if (value === null || value === '') return { text: '—', muted: false, title: '' };
|
||||
const source = String(line.line_no_source || '').trim();
|
||||
if (source === 'sequence') {
|
||||
return {
|
||||
text: String(value),
|
||||
muted: true,
|
||||
title: t('chat.shippingOrderReview.lifecycle.freightUpload.lineNoSourceSequence'),
|
||||
};
|
||||
}
|
||||
if (source === 'customer_po_line_no') {
|
||||
return {
|
||||
text: String(value),
|
||||
muted: false,
|
||||
title: t('chat.shippingOrderReview.lifecycle.freightUpload.lineNoSourceCustomerPo'),
|
||||
};
|
||||
}
|
||||
return { text: String(value), muted: false, title: '' };
|
||||
}
|
||||
|
||||
/**
|
||||
* 逐发货通知单的货代上传状态展示。
|
||||
* 核心逻辑:upload_status 为后端事实;把 uploaded/uploading/failed/pending 映射为文案与色阶,
|
||||
* 并携带 upload_error_code/upload_error_message 作为逐单失败原因。前端禁止按 upload_status 之外的状态猜原因,
|
||||
* 未知状态一律回落 pending,避免把内部执行字段当作用户原因。
|
||||
* @param group - 当前发货通知单聚合行(含 upload_status 与逐单错误字段)。
|
||||
*/
|
||||
function freightUploadStatusDisplay(group: ShippingFreightNoticeGroup): {
|
||||
state: 'uploaded' | 'uploading' | 'failed' | 'needs_human' | 'pending';
|
||||
label: string;
|
||||
chipClass: string;
|
||||
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)) {
|
||||
return {
|
||||
state: 'uploaded',
|
||||
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.uploaded'),
|
||||
chipClass: 'bg-emerald-100 text-emerald-800 dark:bg-emerald-950/50 dark:text-emerald-200',
|
||||
reason: null,
|
||||
};
|
||||
}
|
||||
if (status === 'failed') {
|
||||
return {
|
||||
state: 'failed',
|
||||
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.failed'),
|
||||
chipClass: 'bg-rose-100 text-rose-700 dark:bg-rose-950/50 dark:text-rose-300',
|
||||
reason: reason ? t('chat.shippingOrderReview.lifecycle.freightUpload.uploadError', { reason }) : null,
|
||||
};
|
||||
}
|
||||
// 存在错误码但状态未置 failed(如超时/结果未知):按“需人工”展示并始终带出逐单原因。
|
||||
if (reason) {
|
||||
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: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadError', { reason }),
|
||||
};
|
||||
}
|
||||
if (['uploading', 'upload_rpa_pending'].includes(status) || pendingHuman === 'upload_rpa_pending') {
|
||||
return {
|
||||
state: 'uploading',
|
||||
label: t('chat.shippingOrderReview.lifecycle.freightUpload.uploadStatus.uploading'),
|
||||
chipClass: 'bg-blue-100 text-blue-800 dark:bg-blue-950/50 dark:text-blue-200',
|
||||
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'),
|
||||
chipClass: 'bg-slate-100 text-slate-600 dark:bg-slate-800/60 dark:text-slate-300',
|
||||
reason: null,
|
||||
};
|
||||
}
|
||||
|
||||
async function confirmPreparationWave() {
|
||||
const caseNo = String(activeCase.value?.case_no || '').trim();
|
||||
const draftVersion = activeCase.value?.draft?.draft_version;
|
||||
@@ -3601,6 +3835,7 @@ watch(
|
||||
watch(
|
||||
lifecycleCurrentStageCode,
|
||||
async (current, previous) => {
|
||||
if (await syncPendingReleaseAutoAdvance()) return;
|
||||
if (!current || !previous || current === previous) return;
|
||||
// 只响应后端 current 阶段的真实推进:用户点击已完成阶段只会改路由,
|
||||
// 绝不能触发自动跳转而被带回当前阶段。
|
||||
@@ -3826,15 +4061,18 @@ watch(
|
||||
@retry-parse="() => void retryCurrentIntakeParse()"
|
||||
/>
|
||||
<p
|
||||
v-if="lifecycleProgressForView"
|
||||
v-if="lifecycleProgressMessage && !hasFormalOt"
|
||||
class="mt-2 rounded-md border-l-2 border-brand-500 bg-surface-soft px-2.5 py-1.5 text-xs text-secondary"
|
||||
data-testid="review-run-lifecycle-current-step"
|
||||
aria-live="polite"
|
||||
>
|
||||
<span class="mr-1 inline-block h-2 w-2 animate-pulse rounded-full bg-brand-500" aria-hidden="true" />
|
||||
<span v-if="lifecycleProgressStepText">{{ lifecycleProgressStepText }}</span>
|
||||
<span v-else>{{ t('chat.shippingProcessing.progress.systemProcessingNeed') }}</span>
|
||||
<span v-if="lifecycleProgressReasonText" class="ml-1 text-warning">· {{ lifecycleProgressReasonText }}</span>
|
||||
<span
|
||||
v-if="lifecycleProgressMessage.auto"
|
||||
class="mr-1 inline-block h-2 w-2 animate-pulse rounded-full bg-brand-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span>{{ lifecycleProgressMessage.text }}</span>
|
||||
<span v-if="lifecycleProgressMessage.reason" class="ml-1 text-warning">· {{ lifecycleProgressMessage.reason }}</span>
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
@@ -3973,9 +4211,10 @@ watch(
|
||||
<h3 class="text-sm font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.prepare.title') }}</h3>
|
||||
<p class="mt-1 text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.prepare.subtitle') }}</p>
|
||||
</div>
|
||||
<span 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>
|
||||
<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>
|
||||
</div>
|
||||
<div v-if="formalPreparationContext.has_match_result && formalPreparationLines.length" class="review-fulfillment-prep-workspace mt-4 overflow-x-auto 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">
|
||||
@@ -4035,15 +4274,7 @@ watch(
|
||||
<h2 class="text-sm font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.title') }}</h2>
|
||||
<p class="mt-1 text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.subtitle') }}</p>
|
||||
</div>
|
||||
<span class="rounded-full bg-surface-muted px-2 py-1 text-xs text-secondary">{{ formalTaskDetail.upload_status || '-' }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="formalTaskDetail.ui_state?.stage_context?.upload?.latest_attempt || formalTaskDetail.ui_state?.stage_context?.upload?.latest_attempt?.error_code"
|
||||
class="mt-3 rounded-lg border border-default bg-surface-muted/50 p-3 text-xs text-secondary"
|
||||
data-testid="review-upload-attempt-summary"
|
||||
>
|
||||
<p v-if="formalTaskDetail.ui_state?.stage_context?.upload?.latest_attempt" class="mt-1">{{ t('chat.shippingOrderReview.lifecycle.upload.attempt', { status: formalTaskDetail.ui_state.stage_context.upload.latest_attempt.status || '-', mode: formalTaskDetail.ui_state.stage_context.upload.latest_attempt.mode || '-' }) }}</p>
|
||||
<p v-if="formalTaskDetail.ui_state?.stage_context?.upload?.latest_attempt?.error_code" class="mt-1 text-rose-700 dark:text-rose-300">{{ formalTaskDetail.ui_state.stage_context.upload.latest_attempt.error_code }}</p>
|
||||
<span class="rounded-full bg-surface-muted px-2 py-1 text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.noticeCount', { count: freightNoticeGroups.length }) }}</span>
|
||||
</div>
|
||||
<div v-if="freightNoticeGroupsLoading" class="mt-3 text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.loading') }}</div>
|
||||
<p v-else-if="freightNoticeGroupsLoadFailed" class="mt-3 rounded-lg border border-rose-200 bg-rose-50/70 p-3 text-xs text-rose-700 dark:border-rose-900 dark:bg-rose-950/20 dark:text-rose-200">{{ t('chat.shippingOrderReview.lifecycle.freightUpload.loadFailed') }}</p>
|
||||
@@ -4055,8 +4286,9 @@ watch(
|
||||
<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.upload_status || '—' }} · {{ group.export_file_name || '—' }}</span>
|
||||
<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>
|
||||
<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">
|
||||
<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>
|
||||
@@ -4068,7 +4300,8 @@ watch(
|
||||
</details>
|
||||
</div>
|
||||
</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">{{ line.line_no || '—' }}</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 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>
|
||||
<p v-else class="mt-3 rounded-lg border border-default bg-surface-muted/50 p-3 text-xs text-secondary">{{ freightNoticeGroupsReason === 'po_missing' ? t('chat.shippingOrderReview.lifecycle.freightUpload.poMissing') : t('chat.shippingOrderReview.lifecycle.freightUpload.empty') }}</p>
|
||||
@@ -4081,9 +4314,88 @@ watch(
|
||||
>
|
||||
<h2 class="text-sm font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.title') }}</h2>
|
||||
<p class="mt-1 text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.subtitle') }}</p>
|
||||
<div class="mt-3 rounded-lg border border-emerald-200 bg-surface/70 p-3 text-xs text-secondary dark:border-emerald-900">
|
||||
<p v-if="formalTaskDetail.ui_state?.stage_context?.upload?.succeeded_attempt" class="mt-1">{{ t('chat.shippingOrderReview.lifecycle.upload.attempt', { status: formalTaskDetail.ui_state.stage_context.upload.succeeded_attempt.status || '-', mode: formalTaskDetail.ui_state.stage_context.upload.succeeded_attempt.mode || '-' }) }}</p>
|
||||
|
||||
<!-- 聚合头:本批已上传数量 + 留底下载(ZIP 打包全部已完成通知) -->
|
||||
<div class="mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border border-emerald-200 bg-surface px-3 py-2 text-xs dark:border-emerald-900" data-testid="review-upload-complete-toolbar">
|
||||
<span class="font-medium text-emerald-900 dark:text-emerald-100">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.batchCount', { count: uploadedFreightNoticeGroups.length }) }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-emerald-300 px-2 py-1 font-medium text-emerald-700 hover:bg-emerald-50 disabled:opacity-50 dark:border-emerald-700 dark:text-emerald-200 dark:hover:bg-emerald-950/40"
|
||||
:disabled="!uploadedFreightNoticeGroups.length || uploadingBatchArchive"
|
||||
data-testid="review-upload-complete-batch-download"
|
||||
@click="void downloadCompletedBatchArchive()"
|
||||
>
|
||||
{{ uploadingBatchArchive
|
||||
? t('chat.shippingOrderReview.lifecycle.uploadComplete.batchDownloading')
|
||||
: t('chat.shippingOrderReview.lifecycle.uploadComplete.batchDownload') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="uploadedFreightNoticeGroups.length" class="mt-3 space-y-3" data-testid="review-upload-complete-groups">
|
||||
<div
|
||||
v-for="group in uploadedFreightNoticeGroups"
|
||||
:key="group.business_no"
|
||||
class="rounded-lg border border-emerald-200 bg-surface/70 dark:border-emerald-900"
|
||||
data-testid="review-upload-complete-notice"
|
||||
>
|
||||
<!-- 单据行:identity + 状态 + 单张下载 + 展开明细 -->
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 border-b border-emerald-200/70 px-3 py-2 text-xs dark:border-emerald-900/70">
|
||||
<div class="flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1">
|
||||
<span class="font-semibold text-primary">{{ group.business_no }}</span>
|
||||
<span class="inline-flex items-center gap-1 font-medium text-emerald-700 dark:text-emerald-300">
|
||||
<Check class="h-3.5 w-3.5" aria-hidden="true" />
|
||||
{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.uploaded') }}
|
||||
</span>
|
||||
<span class="text-secondary">{{ group.po_number ? `PO: ${group.po_number}` : '' }}</span>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded border border-emerald-300 px-2 py-1 font-medium text-emerald-700 hover:bg-emerald-50 dark:border-emerald-700 dark:text-emerald-200 dark:hover:bg-emerald-950/40"
|
||||
data-testid="review-upload-complete-download"
|
||||
@click="void downloadFreightNotice(group.business_no)"
|
||||
>{{ t('chat.shippingOrderReview.lifecycle.freightUpload.download') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded border border-default px-2 py-1 font-medium text-primary hover:bg-surface disabled:opacity-50"
|
||||
:aria-expanded="expandedCompletedNoticeNo === group.business_no"
|
||||
:aria-label="expandedCompletedNoticeNo === group.business_no
|
||||
? t('chat.shippingOrderReview.lifecycle.uploadComplete.collapse')
|
||||
: t('chat.shippingOrderReview.lifecycle.uploadComplete.expand')"
|
||||
data-testid="review-upload-complete-toggle-lines"
|
||||
@click="toggleCompletedNoticeLine(group.business_no)"
|
||||
>
|
||||
{{ expandedCompletedNoticeNo === group.business_no
|
||||
? t('chat.shippingOrderReview.lifecycle.uploadComplete.collapse')
|
||||
: t('chat.shippingOrderReview.lifecycle.uploadComplete.expand') }}
|
||||
<ChevronDown class="h-3.5 w-3.5 transition-transform" :class="{ 'rotate-180': expandedCompletedNoticeNo === group.business_no }" aria-hidden="true" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="expandedCompletedNoticeNo === group.business_no" class="space-y-2 px-3 pb-3 pt-2 text-xs" data-testid="review-upload-complete-lines">
|
||||
<p v-if="group.export_file_name" class="text-secondary">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.exportFile', { file: group.export_file_name }) }}</p>
|
||||
<table class="min-w-full text-left">
|
||||
<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-upload-complete-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>
|
||||
</div>
|
||||
<p v-else class="mt-3 rounded-lg border border-emerald-200 bg-surface/70 p-3 text-xs text-secondary dark:border-emerald-900">{{ t('chat.shippingOrderReview.lifecycle.uploadComplete.empty') }}</p>
|
||||
</section>
|
||||
|
||||
<ReviewIntakeParsePanel
|
||||
@@ -4514,8 +4826,6 @@ watch(
|
||||
:task-no="displayCase?.confirmed_task_no || displayCase?.post_confirm_auto_progress?.task_no"
|
||||
:confirmed-task-id="displayCase?.confirmed_task_id"
|
||||
:show-admin-diagnosis="showAdminTaskMissingDiagnosis"
|
||||
:has-formal-ot="shippingProcessingProjection?.hasFormalOt ?? hasFormalOt"
|
||||
:shipping-notice-no="currentShippingBusinessNo"
|
||||
:user-status="currentTaskUserStatus"
|
||||
:retryable="visibleCurrentTaskRetryable"
|
||||
:blocking-reason="currentTaskBlockingReason"
|
||||
|
||||
Reference in new issue
Block a user