feat(shipping-notice): 完成货代发货通知全门禁恢复MVP收口
完成全门禁恢复MVP版本交付:调整自动上传与重试配置,重构正式执行链路;修复多处代码bug,新增测试与审计工具;更新全流程文档与契约规范。
This commit is contained in:
1 parent
8e0bbf7a81
commit
c94d173f92
181 files changed
+12947
-1724
No files matched your search
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* features/chat/api/shipping.api.legacy-entrypoints.spec.ts
|
||||
* 用途:锁定 Shipping 前端 API 不再暴露直接匹配/导出业务入口。
|
||||
* 依赖:shipping.api 的模块导出。
|
||||
* 逻辑:正式业务动作只能由 Projection + Process Gate Action 驱动;旧函数名不得重新被页面调用。
|
||||
*/
|
||||
import * as shippingApi from './shipping.api';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
describe('shipping API runtime entrypoints', () => {
|
||||
it('does not expose direct inventory match or Excel generation actions', () => {
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'matchWorkspaceShippingInventory')).toBe(false);
|
||||
expect(Object.prototype.hasOwnProperty.call(shippingApi, 'generateWorkspaceShippingExcel')).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -463,6 +463,7 @@ export const retryWorkspaceConversationAutoProgress = (
|
||||
retried: number;
|
||||
skipped: number;
|
||||
failed: number;
|
||||
blocked?: number;
|
||||
};
|
||||
items: Array<{
|
||||
object_type: 'review_case' | 'formal_task' | string;
|
||||
@@ -1100,7 +1101,10 @@ export async function retryWorkspaceShippingTask(taskNo: string, comment?: strin
|
||||
* @param taskNo - 正式任务号
|
||||
* @param lineKey - 行键
|
||||
*/
|
||||
export async function retryWorkspaceShippingTaskLine(taskNo: string, lineKey: string) {
|
||||
export async function retryWorkspaceShippingTaskLine(
|
||||
taskNo: string,
|
||||
lineKey: string,
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/lines/${encodeURIComponent(lineKey)}/retry`,
|
||||
jsonPost({ reason: 'user_retry_inventory' }),
|
||||
@@ -1311,23 +1315,6 @@ export async function removeWorkspaceShippingNoticeLine(
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行库存匹配。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param ownership - 可选工作台归属上下文
|
||||
* @returns 匹配结果与后续动作提示
|
||||
*/
|
||||
export async function matchWorkspaceShippingInventory(
|
||||
taskNo: string,
|
||||
ownership?: ShippingFulfillmentOwnershipContext | null,
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/match-inventory`,
|
||||
jsonPost(ownershipPayload(ownership)),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传当前任务使用的正式库存文件。
|
||||
* @param taskNo - 发货任务编号
|
||||
@@ -1346,6 +1333,8 @@ export async function uploadWorkspaceShippingInventory(taskNo: string, file: Fil
|
||||
|
||||
/**
|
||||
* 以用户态触发自动推进,作为聊天前端兜底入口。
|
||||
* @deprecated 新业务组件必须通过 Projection 的 primary_action 调用正式 Gate Action,
|
||||
* 成功后重新读取 Projection;本函数仅保留给历史调用方兼容。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param lang - 可选语言代码
|
||||
* @returns 自动推进结果
|
||||
@@ -1392,23 +1381,6 @@ export async function retryWorkspaceShippingUpload(
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成发货 Excel。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param ownership - 可选工作台归属上下文
|
||||
* @returns 生成结果,成功时通常会包含下载链接
|
||||
*/
|
||||
export async function generateWorkspaceShippingExcel(
|
||||
taskNo: string,
|
||||
ownership?: ShippingFulfillmentOwnershipContext | null,
|
||||
) {
|
||||
const body = await requestJson<ShippingDecisionResponse & ShippingApiStatusPayload>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/generate-excel`,
|
||||
jsonPost(ownershipPayload(ownership)),
|
||||
);
|
||||
return assertShippingOk(body);
|
||||
}
|
||||
|
||||
/** 发货通知 Agent 应用类型标识(运行时识别)。 */
|
||||
export const SHIPPING_NOTICE_AGENT_CODE = 'shipping_notice';
|
||||
|
||||
|
||||
+87
@@ -0,0 +1,87 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewConversationRetryDrawer.vue
|
||||
用途:按需展示本次对话级自动推进重试的逐项结果,不占用订单复核主内容。
|
||||
依赖:vue-i18n、对话级重试 API 返回的摘要和对象结果。
|
||||
逻辑:仅用户主动从顶栏打开;按结果分类展示,关闭不改变任务真实状态。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
type RetryItem = {
|
||||
object_type: string;
|
||||
object_ref: string;
|
||||
action?: string | null;
|
||||
outcome: string;
|
||||
reason_code?: string | null;
|
||||
};
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
result: {
|
||||
summary: { total: number; retried: number; skipped: number; failed: number; blocked?: number };
|
||||
items: RetryItem[];
|
||||
} | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{ close: [] }>();
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const items = computed(() => props.result?.items || []);
|
||||
|
||||
function itemLabel(item: RetryItem): string {
|
||||
const code = String(item.reason_code || '').trim();
|
||||
const key = `chat.shippingOrderReview.conversationRetry.reason.${code}`;
|
||||
return code && te(key) ? t(key) : outcomeLabel(item.outcome);
|
||||
}
|
||||
|
||||
function outcomeLabel(outcome: string): string {
|
||||
const key = `chat.shippingOrderReview.conversationRetry.outcome.${String(outcome || '').trim()}`;
|
||||
return te(key) ? t(key) : t('chat.shippingOrderReview.conversationRetry.outcome.unknown');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open && result"
|
||||
class="fixed inset-0 z-40 flex justify-end bg-slate-900/10"
|
||||
data-testid="review-conversation-retry-drawer"
|
||||
@click.self="emit('close')"
|
||||
>
|
||||
<aside class="flex h-full w-full max-w-[360px] flex-col border-l border-slate-200 bg-white shadow-2xl dark:border-slate-800 dark:bg-slate-900">
|
||||
<header class="flex items-center justify-between gap-3 border-b border-slate-200 px-3 py-2.5 dark:border-slate-800">
|
||||
<div class="flex min-w-0 items-center gap-2">
|
||||
<span class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-amber-100 text-amber-700 dark:bg-amber-900/60 dark:text-amber-200">
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
</span>
|
||||
<div class="min-w-0">
|
||||
<h2 class="text-sm font-semibold">{{ t('chat.shippingOrderReview.conversationRetry.title') }}</h2>
|
||||
<p class="truncate text-[11px] text-muted">{{ t('chat.shippingOrderReview.conversationRetry.subtitle') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="rounded border border-slate-300 px-2 py-1 text-xs hover:bg-slate-50 dark:border-slate-600 dark:hover:bg-slate-800" data-testid="review-conversation-retry-drawer-close" @click="emit('close')">
|
||||
{{ t('chat.shippingOrderReview.workbench.close') }}
|
||||
</button>
|
||||
</header>
|
||||
<div class="flex flex-wrap gap-1.5 border-b border-slate-200 px-3 py-2 dark:border-slate-800">
|
||||
<p class="rounded-full bg-emerald-50 px-2 py-1 text-[11px] text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300" data-testid="review-conversation-retry-retried">{{ t('chat.shippingOrderReview.conversationRetry.retried') }} <strong>{{ result.summary.retried }}</strong></p>
|
||||
<p class="rounded-full bg-slate-100 px-2 py-1 text-[11px] text-slate-600 dark:bg-slate-800 dark:text-slate-300" data-testid="review-conversation-retry-skipped">{{ t('chat.shippingOrderReview.conversationRetry.skipped') }} <strong>{{ result.summary.skipped }}</strong></p>
|
||||
<p class="rounded-full bg-rose-50 px-2 py-1 text-[11px] text-rose-700 dark:bg-rose-950/40 dark:text-rose-300" data-testid="review-conversation-retry-failed">{{ t('chat.shippingOrderReview.conversationRetry.failed') }} <strong>{{ result.summary.failed }}</strong></p>
|
||||
<p class="rounded-full bg-violet-50 px-2 py-1 text-[11px] text-violet-700 dark:bg-violet-950/40 dark:text-violet-300" data-testid="review-conversation-retry-blocked">{{ t('chat.shippingOrderReview.conversationRetry.blocked') }} <strong>{{ result.summary.blocked || 0 }}</strong></p>
|
||||
</div>
|
||||
<ul class="min-h-0 flex-1 divide-y divide-slate-100 overflow-y-auto dark:divide-slate-800" data-testid="review-conversation-retry-item-list">
|
||||
<li v-for="item in items" :key="`${item.object_type}:${item.object_ref}`" class="px-3 py-2.5 text-xs">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<p class="min-w-0 truncate font-medium text-slate-800 dark:text-slate-100">{{ item.object_ref }}</p>
|
||||
<span
|
||||
class="shrink-0 rounded-full px-1.5 py-0.5 text-[10px]"
|
||||
:class="item.outcome === 'queued' ? 'bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300' : item.outcome === 'needs_human' ? 'bg-amber-50 text-amber-700 dark:bg-amber-950/40 dark:text-amber-300' : 'bg-slate-100 text-slate-600 dark:bg-slate-800 dark:text-slate-300'"
|
||||
>{{ outcomeLabel(item.outcome) }}</span>
|
||||
</div>
|
||||
<p class="mt-0.5 text-[11px] text-muted">{{ itemLabel(item) }}</p>
|
||||
</li>
|
||||
</ul>
|
||||
</aside>
|
||||
</div>
|
||||
</template>
|
||||
+24
-2
@@ -105,8 +105,23 @@ const statusLabel = computed(() => {
|
||||
* 下一步(「下一步」section 的问题/说明文案):优先展示 blocking_reason,否则按 user_status 给系统态文案。
|
||||
*/
|
||||
const nextStepText = computed(() => {
|
||||
const safeMessage = (value: unknown): string => {
|
||||
const raw = String(value || '').trim();
|
||||
const lowered = raw.toLowerCase();
|
||||
if (!raw) return '';
|
||||
if (
|
||||
lowered.includes('cannot import name')
|
||||
|| lowered.includes('traceback')
|
||||
|| lowered.includes('site-packages')
|
||||
|| lowered.includes('\\app\\')
|
||||
|| lowered.includes('/app/')
|
||||
) {
|
||||
return t('chat.shippingOrderReview.currentTask.nextStepFailedNoRetry');
|
||||
}
|
||||
return raw;
|
||||
};
|
||||
if (props.loading) {
|
||||
return String(props.automation?.message || '').trim() || t('chat.shippingOrderReview.currentTask.nextStepRunning');
|
||||
return safeMessage(props.automation?.message) || t('chat.shippingOrderReview.currentTask.nextStepRunning');
|
||||
}
|
||||
// 1) blocking_reason → 用后端给的 i18n_key 渲染具体阻断
|
||||
const br = props.blockingReason;
|
||||
@@ -116,7 +131,7 @@ const nextStepText = computed(() => {
|
||||
return t(i18nKey);
|
||||
}
|
||||
// i18n 键缺失时回落为 code(不裸露给普通用户,最终 QA 期间应全部补齐)
|
||||
return String(br.code || '').trim() || t('chat.shippingOrderReview.currentTask.nextStepUnknown');
|
||||
return safeMessage(br.code) || t('chat.shippingOrderReview.currentTask.nextStepUnknown');
|
||||
}
|
||||
// 2) 无阻断时,按 user_status 给系统说明文案
|
||||
const s = String(props.userStatus || '').trim() as ReviewCurrentUserStatus | '';
|
||||
@@ -141,6 +156,12 @@ const nextStepText = computed(() => {
|
||||
return t('chat.shippingOrderReview.currentTask.nextStepUnknown');
|
||||
});
|
||||
|
||||
/** 已完成/已取消时没有后续业务动作,不渲染“下一步”区,避免制造未完成错觉。 */
|
||||
const showNextStep = computed(() => {
|
||||
const status = String(props.userStatus || '').trim().toLowerCase();
|
||||
return !['completed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
/**
|
||||
* 业务动作按钮:后端确认 retryable=true → 主按钮为「重试」;
|
||||
* 否则若 primary_action.code 非 retry → 用 primary_action.code + i18n_key 渲染对应人工动作(进入复核/确认客户等)。
|
||||
@@ -301,6 +322,7 @@ type ReviewCurrentUserStatus =
|
||||
</aside>
|
||||
|
||||
<div
|
||||
v-if="showNextStep"
|
||||
class="mt-3 border-t border-sky-200/70 pt-3 dark:border-sky-800/60"
|
||||
data-testid="review-current-task-next-step-section"
|
||||
>
|
||||
|
||||
+21
@@ -21,6 +21,13 @@ const i18n = createI18n({
|
||||
wave: '履约波次',
|
||||
task: '正式任务',
|
||||
snapshotId: '库存快照 ID',
|
||||
inventorySource: '实际库存源',
|
||||
inventoryFile: '库存文件编号',
|
||||
inventoryFileSha256: '库存文件 SHA-256',
|
||||
inventoryRow: '库存行号',
|
||||
requiredQty: '需求数量',
|
||||
availableQty: '可用数量',
|
||||
matchAttempt: '匹配 Attempt',
|
||||
matchedAt: '匹配校验时间',
|
||||
decisionSource: '决定来源',
|
||||
decisionSourceValue: {
|
||||
@@ -45,6 +52,13 @@ describe('ReviewLineFulfillmentDetail', () => {
|
||||
line_key: 'L1',
|
||||
inventory_snapshot_id: 42,
|
||||
inventory_checked_at: '2026-08-07T01:00:00Z',
|
||||
inventory_source_code: 'DBS_DUB',
|
||||
inventory_file_no: 'INV-001',
|
||||
inventory_file_sha256: 'a'.repeat(64),
|
||||
inventory_row_index: 17,
|
||||
required_qty: '3',
|
||||
available_qty: '8',
|
||||
match_attempt_id: 301,
|
||||
decision_source: 'system',
|
||||
auto_fulfill_error_message: 'wave_explode',
|
||||
decision: {
|
||||
@@ -62,6 +76,13 @@ describe('ReviewLineFulfillmentDetail', () => {
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-wave"]').text()).toContain('3');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-task"]').text()).toContain('SN-100');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-snapshot"]').text()).toContain('42');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventorySource"]').text()).toContain('DBS_DUB');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventoryFile"]').text()).toContain('INV-001');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventoryFileSha256"]').text()).toContain('a'.repeat(64));
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-inventoryRow"]').text()).toContain('17');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-requiredQty"]').text()).toContain('3');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-availableQty"]').text()).toContain('8');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-matchAttempt"]').text()).toContain('301');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-decisionSource"]').text()).toContain('系统自动');
|
||||
expect(wrapper.find('[data-testid="review-line-fulfillment-field-failure"]').text()).toContain('wave_explode');
|
||||
|
||||
|
||||
@@ -54,6 +54,41 @@ const rows = computed(() => {
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.snapshotId'),
|
||||
value: line?.inventory_snapshot_id != null ? String(line.inventory_snapshot_id) : '—',
|
||||
},
|
||||
{
|
||||
key: 'inventorySource',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventorySource'),
|
||||
value: String(line?.inventory_source_code || line?.inventory_source?.code || '').trim() || '—',
|
||||
},
|
||||
{
|
||||
key: 'inventoryFile',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventoryFile'),
|
||||
value: String(line?.inventory_file_no || '').trim() || '—',
|
||||
},
|
||||
{
|
||||
key: 'inventoryFileSha256',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventoryFileSha256'),
|
||||
value: String(line?.inventory_file_sha256 || '').trim() || '—',
|
||||
},
|
||||
{
|
||||
key: 'inventoryRow',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.inventoryRow'),
|
||||
value: line?.inventory_row_index != null ? String(line.inventory_row_index) : '—',
|
||||
},
|
||||
{
|
||||
key: 'requiredQty',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.requiredQty'),
|
||||
value: String(line?.required_qty || '').trim() || '—',
|
||||
},
|
||||
{
|
||||
key: 'availableQty',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.availableQty'),
|
||||
value: String(line?.available_qty || '').trim() || '—',
|
||||
},
|
||||
{
|
||||
key: 'matchAttempt',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.matchAttempt'),
|
||||
value: line?.match_attempt_id != null ? String(line.match_attempt_id) : '—',
|
||||
},
|
||||
{
|
||||
key: 'matchedAt',
|
||||
label: t('chat.shippingOrderReview.lineFulfillmentDetail.matchedAt'),
|
||||
|
||||
+6
-11
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewLineInventoryOps.spec.ts
|
||||
* 用途:锁定行级只渲染统一「重试」与关闭;消费 retryable,不展示内部动作码。
|
||||
* 用途:锁定明细行不渲染库存重试,只保留行生命周期关闭动作。
|
||||
*/
|
||||
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
@@ -16,10 +16,7 @@ const i18n = createI18n({
|
||||
'zh-CN': {
|
||||
chat: {
|
||||
shippingOrderReview: {
|
||||
lineOps: {
|
||||
retry: '重试',
|
||||
moreActions: '更多操作',
|
||||
},
|
||||
lineOps: { moreActions: '更多操作' },
|
||||
fulfillmentDecision: {
|
||||
closeLine: '关闭该明细',
|
||||
},
|
||||
@@ -46,18 +43,16 @@ afterEach(() => {
|
||||
});
|
||||
|
||||
describe('ReviewLineInventoryOps', () => {
|
||||
it('shows unified retry when retryable', async () => {
|
||||
it('does not show generic retry even when retryable', async () => {
|
||||
const wrapper = mountOps({
|
||||
retryable: true,
|
||||
line_allowed_actions: [],
|
||||
});
|
||||
expect(wrapper.find('[data-testid="review-line-retry"]').exists()).toBe(true);
|
||||
await wrapper.get('[data-testid="review-line-retry"]').trigger('click');
|
||||
expect(wrapper.emitted('retry-line')?.length).toBe(1);
|
||||
expect(wrapper.find('[data-testid="review-line-retry"]').exists()).toBe(false);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('hides retry when not retryable even if internal actions present', () => {
|
||||
it('keeps inventory actions out of the line even when present', () => {
|
||||
const wrapper = mountOps({
|
||||
retryable: false,
|
||||
inventory_allowed_actions: ['retry_inventory_preparation', 'retry_inventory_matching'],
|
||||
@@ -68,7 +63,7 @@ describe('ReviewLineInventoryOps', () => {
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('disables retry while task running', () => {
|
||||
it('does not add a retry while task running', () => {
|
||||
const wrapper = mountOps({
|
||||
retryable: true,
|
||||
line_allowed_actions: [],
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
<!--
|
||||
features/chat/components/shipping-review/ReviewLineInventoryOps.vue
|
||||
用途:明细行统一「重试」+ 更多操作(关闭);不进库存工作台。
|
||||
依赖:vue-i18n、lucide、line.retryable / line_allowed_actions。
|
||||
逻辑:只消费 retryable 布尔与 close 动作;不展示内部动作码;不发具体节点。
|
||||
用途:明细行只展示行生命周期操作(关闭无法履约)。
|
||||
依赖:vue-i18n、lucide、line.line_allowed_actions。
|
||||
逻辑:库存重新获取/匹配属于任务 Gate,禁止在明细行降级为笼统「重试」。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, nextTick, onBeforeUnmount, ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { MoreHorizontal, RefreshCw } from 'lucide-vue-next';
|
||||
import { MoreHorizontal } from 'lucide-vue-next';
|
||||
import type { ShippingOrderReviewLineFulfillmentLine } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
@@ -19,7 +19,6 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'retry-line': [];
|
||||
'close-line': [];
|
||||
}>();
|
||||
|
||||
@@ -28,14 +27,6 @@ const moreMenuOpen = ref(false);
|
||||
const moreBtnRef = ref<HTMLElement | null>(null);
|
||||
const moreMenuStyle = ref<Record<string, string>>({});
|
||||
|
||||
/**
|
||||
* 是否展示统一「重试」:仅后端 retryable,且任务未整体运行。
|
||||
*/
|
||||
const showRetry = computed(() => (
|
||||
Boolean(props.line?.retryable)
|
||||
&& !props.taskRunning
|
||||
));
|
||||
|
||||
const canClose = computed(() => (
|
||||
[...(props.line?.line_allowed_actions || [])].includes('close_unfulfillable')
|
||||
));
|
||||
@@ -78,11 +69,6 @@ async function toggleMoreMenu() {
|
||||
}
|
||||
}
|
||||
|
||||
function onRetry() {
|
||||
if (props.busy || props.taskRunning || !showRetry.value) return;
|
||||
emit('retry-line');
|
||||
}
|
||||
|
||||
function onCloseLine() {
|
||||
closeMenus();
|
||||
emit('close-line');
|
||||
@@ -99,20 +85,6 @@ onBeforeUnmount(() => {
|
||||
|
||||
<template>
|
||||
<div class="relative inline-flex items-center gap-0.5">
|
||||
<button
|
||||
v-if="showRetry"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-0.5 rounded border border-amber-300 bg-amber-50 px-1.5 py-0.5 text-[11px] text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
data-testid="review-line-retry"
|
||||
:disabled="!editable || busy || taskRunning"
|
||||
:aria-label="t('chat.shippingOrderReview.lineOps.retry')"
|
||||
:title="t('chat.shippingOrderReview.lineOps.retry')"
|
||||
@click="onRetry"
|
||||
>
|
||||
<RefreshCw class="h-3 w-3" :class="busy ? 'animate-spin' : ''" aria-hidden="true" />
|
||||
{{ t('chat.shippingOrderReview.lineOps.retry') }}
|
||||
</button>
|
||||
|
||||
<button
|
||||
v-if="showMore"
|
||||
ref="moreBtnRef"
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/**
|
||||
* features/chat/components/shipping-review/ReviewProfileMatchPanel.spec.ts
|
||||
* 用途:锁定模板匹配侧栏的候选披露规则,避免候选数量增长撑长工作台。
|
||||
* 依赖:vitest、@vue/test-utils、vue-i18n、ReviewProfileMatchPanel。
|
||||
* 逻辑:所有状态默认收起;用户可手动展开/收起候选列表。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { mount } from '@vue/test-utils';
|
||||
import { createI18n } from 'vue-i18n';
|
||||
import ReviewProfileMatchPanel from './ReviewProfileMatchPanel.vue';
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': {
|
||||
chat: { shippingOrderReview: { profileMatch: {
|
||||
title: '文档模板匹配', subtitle: '摘要', selected: '命中模板', noSelected: '未选定模板',
|
||||
expandCandidates: '查看候选模板({count})', collapseCandidates: '收起候选模板',
|
||||
routeType: '路由类型', executionMode: '执行模式',
|
||||
status: { matched: '已匹配', ambiguous: '多个候选' },
|
||||
} } },
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
function mountPanel(needsReview = false) {
|
||||
return mount(ReviewProfileMatchPanel, {
|
||||
props: {
|
||||
profileMatch: {
|
||||
available: true,
|
||||
visibility: 'admin',
|
||||
status: needsReview ? 'ambiguous' : 'matched',
|
||||
needs_review: needsReview,
|
||||
selected_profile: { profile_code: 'ODP-A', display_name: '客户订单模板', version: 1 },
|
||||
candidates: [
|
||||
{ profile_code: 'ODP-A', score: 0.99 },
|
||||
{ profile_code: 'ODP-B', score: 0.98 },
|
||||
],
|
||||
fallback_reason_codes: [],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
}
|
||||
|
||||
describe('ReviewProfileMatchPanel', () => {
|
||||
it('默认收起无需关注的候选列表', () => {
|
||||
const wrapper = mountPanel(false);
|
||||
expect(wrapper.find('[data-testid="review-profile-match-candidates"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').text()).toContain('查看候选模板(2)');
|
||||
});
|
||||
|
||||
it('多个候选且需要人工处理时也默认收起,并允许展开后收起', async () => {
|
||||
const wrapper = mountPanel(true);
|
||||
expect(wrapper.find('[data-testid="review-profile-match-candidates"]').exists()).toBe(false);
|
||||
await wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').trigger('click');
|
||||
expect(wrapper.find('[data-testid="review-profile-match-candidates"]').exists()).toBe(true);
|
||||
await wrapper.get('[data-testid="review-profile-match-candidates-toggle"]').trigger('click');
|
||||
expect(wrapper.find('[data-testid="review-profile-match-candidates"]').exists()).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -6,7 +6,7 @@
|
||||
required_field_missing 不在此展示;分数/Profile ID 仅 admin visibility。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingOrderReviewProfileMatch } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
@@ -25,6 +25,20 @@ const visible = computed(() => {
|
||||
|
||||
const isAdminView = computed(() => String(props.profileMatch?.visibility || '') === 'admin');
|
||||
const needsReview = computed(() => Boolean(props.profileMatch?.needs_review));
|
||||
const candidateCount = computed(() => (props.profileMatch?.candidates || []).length);
|
||||
// 候选模板始终按需披露,避免模板数量增长撑长工作台;人工关注状态仍通过徽标表达。
|
||||
const defaultCandidatesExpanded = computed(() => false);
|
||||
const candidatesOpenOverride = ref<boolean | null>(null);
|
||||
const candidatesExpanded = computed(() => candidatesOpenOverride.value ?? defaultCandidatesExpanded.value);
|
||||
|
||||
watch(
|
||||
() => `${props.profileMatch?.status || ''}:${props.profileMatch?.selected_profile?.profile_code || ''}:${candidateCount.value}`,
|
||||
() => { candidatesOpenOverride.value = null; },
|
||||
);
|
||||
|
||||
function toggleCandidates() {
|
||||
candidatesOpenOverride.value = !candidatesExpanded.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 匹配状态本地化(用户四态)。
|
||||
@@ -81,8 +95,21 @@ const selectedLabel = computed(() => {
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
<template v-if="isAdminView">
|
||||
<dl class="mt-2 space-y-1 text-xs text-secondary">
|
||||
<template v-if="isAdminView && candidateCount">
|
||||
<button
|
||||
type="button"
|
||||
class="mt-3 flex w-full items-center justify-between rounded-lg border border-default bg-surface-soft px-2.5 py-2 text-left text-xs font-medium text-secondary transition-colors hover:bg-slate-50 dark:hover:bg-slate-800"
|
||||
data-testid="review-profile-match-candidates-toggle"
|
||||
:aria-expanded="candidatesExpanded"
|
||||
@click="toggleCandidates"
|
||||
>
|
||||
<span>{{ candidatesExpanded
|
||||
? t('chat.shippingOrderReview.profileMatch.collapseCandidates')
|
||||
: t('chat.shippingOrderReview.profileMatch.expandCandidates', { count: candidateCount }) }}</span>
|
||||
<span aria-hidden="true" class="text-muted">{{ candidatesExpanded ? '−' : '+' }}</span>
|
||||
</button>
|
||||
<div v-if="candidatesExpanded" data-testid="review-profile-match-details">
|
||||
<dl class="mt-2 space-y-1 text-xs text-secondary">
|
||||
<div v-if="profileMatch?.route_type" class="flex flex-wrap gap-x-2">
|
||||
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.routeType') }}</dt>
|
||||
<dd class="font-mono">{{ profileMatch.route_type }}</dd>
|
||||
@@ -91,12 +118,11 @@ const selectedLabel = computed(() => {
|
||||
<dt class="text-muted">{{ t('chat.shippingOrderReview.profileMatch.executionMode') }}</dt>
|
||||
<dd class="font-mono">{{ profileMatch.execution_mode }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<ul
|
||||
v-if="(profileMatch?.candidates || []).length"
|
||||
class="mt-2 space-y-1.5"
|
||||
</dl>
|
||||
<ul
|
||||
class="mt-2 max-h-48 space-y-1.5 overflow-y-auto pr-1"
|
||||
data-testid="review-profile-match-candidates"
|
||||
>
|
||||
>
|
||||
<li
|
||||
v-for="(item, idx) in profileMatch?.candidates || []"
|
||||
:key="`${item.profile_code}-${item.version}-${idx}`"
|
||||
@@ -105,7 +131,8 @@ const selectedLabel = computed(() => {
|
||||
<span class="font-mono">{{ item.profile_code }}</span>
|
||||
<span v-if="item.score != null" class="ml-2 text-muted">{{ item.score }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
</template>
|
||||
@@ -25,6 +25,7 @@ const props = defineProps<{
|
||||
conversationRetryEligibleCount?: number;
|
||||
conversationRetrying?: boolean;
|
||||
conversationRetryDisabled?: boolean;
|
||||
hasConversationRetryResult?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -32,6 +33,7 @@ const emit = defineEmits<{
|
||||
'open-version-history': [];
|
||||
'open-audit-trail': [];
|
||||
'retry-conversation-auto-progress': [];
|
||||
'open-conversation-retry-result': [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
@@ -81,12 +83,22 @@ const showRetry = computed(() => (
|
||||
class="h-3.5 w-3.5"
|
||||
:class="conversationRetrying ? 'animate-spin' : ''"
|
||||
/>
|
||||
{{ t('chat.shippingOrderReview.autoProgress.retry') }}
|
||||
{{ conversationRetrying ? t('chat.shippingOrderReview.conversationRetry.retrying') : t('chat.shippingOrderReview.autoProgress.retry') }}
|
||||
<span
|
||||
v-if="conversationRetryEligibleCount"
|
||||
class="rounded bg-amber-200/80 px-1 text-[10px] dark:bg-amber-900/60"
|
||||
>{{ conversationRetryEligibleCount }}</span>
|
||||
</button>
|
||||
<button
|
||||
v-if="hasConversationRetryResult"
|
||||
type="button"
|
||||
class="relative rounded border border-slate-200 px-2.5 py-1.5 text-xs hover:bg-slate-50 dark:border-slate-700 dark:hover:bg-slate-800"
|
||||
data-testid="review-open-conversation-retry-result"
|
||||
@click="emit('open-conversation-retry-result')"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.conversationRetry.viewResult') }}
|
||||
<span class="absolute -right-1 -top-1 h-2 w-2 rounded-full bg-rose-500" />
|
||||
</button>
|
||||
<button
|
||||
v-if="showAuditTrail"
|
||||
type="button"
|
||||
|
||||
@@ -23,6 +23,7 @@ const props = defineProps<{
|
||||
item: ShippingReviewProgressContext | null;
|
||||
taskNo?: string | null;
|
||||
polling?: boolean;
|
||||
refreshing?: boolean;
|
||||
/** 统一进度投影:节点与文案的权威来源。 */
|
||||
processingProjection?: ShippingProcessingProjection | null;
|
||||
/** 正式 OT 已创建;抑制确认建单类「当前需要」。 */
|
||||
@@ -65,6 +66,7 @@ const showTaskWorkbenchLink = computed(() => {
|
||||
v-else-if="processingProjection"
|
||||
:projection="processingProjection"
|
||||
:polling="polling"
|
||||
:refreshing="refreshing"
|
||||
:has-formal-ot="hasFormalOt || String(taskNo || '').trim().startsWith('OT-')"
|
||||
@open-process-details="emit('open-process-details')"
|
||||
@refresh="emit('refresh')"
|
||||
|
||||
+53
-8
@@ -3,7 +3,7 @@
|
||||
* 用途:验收右侧任务分组卡——needs_action / processing / 处理记录三子段与动作层级。
|
||||
* 依赖:Vitest、Vue Test Utils、vue-i18n、ShippingConversationProcessingCard。
|
||||
* 逻辑:构造 ConversationProcessingProjection;断言分组文案、处理记录折叠与三类子段、
|
||||
* UI-02 单一详情入口、UI-03 history 截断角标、有 workItem 时无任务级主/次按钮。
|
||||
* UI-02 单一详情入口、UI-03 history 截断角标、人工 Gate 按钮常驻且不依赖任务焦点。
|
||||
*/
|
||||
import { mount, flushPromises } from '@vue/test-utils';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
@@ -336,18 +336,50 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
expect(wrapper.text()).not.toContain('20260803-A13F95D2');
|
||||
});
|
||||
|
||||
it('emits focus only when selecting a task (not viewed)', async () => {
|
||||
it('selects a task locally without writing focus or viewed events', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection: buildProjection() },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
await wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] button').trigger('click');
|
||||
expect(wrapper.emitted('focus')?.[0]).toEqual(['OT-NEED']);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').attributes('data-focused')).toBe('1');
|
||||
expect(wrapper.emitted('focus')).toBeUndefined();
|
||||
expect(wrapper.emitted('viewed')).toBeUndefined();
|
||||
expect(wrapper.emitted('expandFiles')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('opens local task details without emitting a viewed write event', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
projection: {
|
||||
summary: { total_tasks: 1, processing: 0, needs_action: 0, completed: 1, history: 0 },
|
||||
focused_task_no: null,
|
||||
recent_task_no: null,
|
||||
needs_action: [],
|
||||
completed: [{
|
||||
user_task_no: 'OT-DETAIL', group: 'completed', status_label: 'completed',
|
||||
file_count: 1, run_no: 'RUN-DETAIL', can_append: false,
|
||||
available_actions: ['view_details'],
|
||||
}],
|
||||
processing: [], history: [],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
await wrapper.find('[data-testid="shipping-processing-history-toggle"]').trigger('click');
|
||||
|
||||
await wrapper.find('[data-testid="shipping-processing-action-view_result"]').trigger('click');
|
||||
|
||||
expect(wrapper.emitted('taskAction')?.[0]?.[0]).toMatchObject({
|
||||
task: { user_task_no: 'OT-DETAIL' },
|
||||
action: 'view_result',
|
||||
});
|
||||
expect(wrapper.emitted('viewed')).toBeUndefined();
|
||||
});
|
||||
|
||||
it('applies visible focus ring on needs_action card when focused', async () => {
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
@@ -464,7 +496,7 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('hides task-level primary/secondary when workItem exists but keeps expand-files entry', async () => {
|
||||
it('keeps a human Gate action visible before and after selecting its task', async () => {
|
||||
const projection = buildProjection();
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: {
|
||||
@@ -473,6 +505,12 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
buildWorkItem('OT-NEED', {
|
||||
status: 'waiting_review',
|
||||
stage: 'waiting_review',
|
||||
currentGate: {
|
||||
gateCode: 'inventory_matching',
|
||||
nextActionCode: 'open_inventory_match_review',
|
||||
blockingReasonCode: 'inventory_match_not_ready',
|
||||
},
|
||||
availableActions: ['open_inventory_match_review'],
|
||||
}),
|
||||
buildWorkItem('OT-PROC', {
|
||||
stage: 'inventory_matching',
|
||||
@@ -483,13 +521,20 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(1);
|
||||
expect(wrapper.findAll('[data-testid="sidebar-progress-inline"]')).toHaveLength(2);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]').text()).toContain('待复核');
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-PROC"]').text()).toContain('库存匹配');
|
||||
expect(wrapper.findAll('[data-testid="shipping-processing-task-actions"]')).toHaveLength(0);
|
||||
// UI-02:有 workItem 时仍保留展开文件详情(OT-NEED 为多文件)。
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-expand-files"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-processing-task-OT-NEED"] [data-testid="shipping-processing-action-view_details"]').exists()).toBe(false);
|
||||
const task = wrapper.find('[data-testid="shipping-processing-task-OT-NEED"]');
|
||||
expect(task.find('[data-testid="unified-action-primary"]').exists()).toBe(true);
|
||||
expect(task.find('[data-testid="unified-action-primary"]').text()).toContain('库存');
|
||||
|
||||
await task.find('button').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 点击仅改变焦点;同一 Gate 的恢复入口必须继续可见。
|
||||
expect(task.attributes('data-focused')).toBe('1');
|
||||
expect(task.find('[data-testid="unified-action-primary"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('maps internal review_case_draft status to a user-facing review label', async () => {
|
||||
|
||||
+10
-17
@@ -6,7 +6,8 @@
|
||||
* 逻辑:由 ShippingWorkflowTimeline 嵌入;只消费统一 projection / workItems;
|
||||
* 统一「订单识别任务」+ 主文件副标题;处理记录默认折叠(已完成/历史版本/已取消);
|
||||
* UI-02:有文件对象时次要入口仅为「展开文件详情」,无文件对象时才「查看详情」;
|
||||
* 有 workItem 时不渲染任务级主/次按钮,仍可保留展开文件入口;
|
||||
* 有 workItem 时由其统一 Gate / Action 投影常驻渲染人工恢复按钮;
|
||||
* 点击/展开任务只更新本地焦点与详情,不写服务端 viewed/focus 审计,不得改变同一 Gate 的按钮可见性;
|
||||
* UI-03:history 截断时折叠标题显示「还有 N 条」,展开底部显示明细截断文案。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -22,7 +23,6 @@ import { getPrimaryDocumentName } from '@/features/chat/shipping/conversationPro
|
||||
import {
|
||||
createConversationProcessingUiState,
|
||||
focusTaskManually,
|
||||
markTaskViewed,
|
||||
resetConversationProcessingUiState,
|
||||
resolveFocusedTask,
|
||||
shouldExpandTaskDetails,
|
||||
@@ -49,8 +49,6 @@ const props = defineProps<{
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
focus: [taskNo: string];
|
||||
viewed: [taskNo: string];
|
||||
/** 请求展开某任务下的文件列表(由 Timeline 按 OT objects 合成) */
|
||||
expandFiles: [task: ConversationProcessingUserTask];
|
||||
/** 收起文件详情:父级应清空过滤并隐藏文件列表 */
|
||||
@@ -143,26 +141,23 @@ watch(
|
||||
);
|
||||
|
||||
/**
|
||||
* 点击任务卡:只聚焦,不标记正式 viewed、不强制展开文件。
|
||||
* 非权威任务号仅更新本地 UI 焦点,不向后端 focus 写接口。
|
||||
* 点击任务卡:仅本地聚焦,不标记正式 viewed、不强制展开文件、也不写 focus 审计。
|
||||
*/
|
||||
function onSelectTask(task: ConversationProcessingUserTask) {
|
||||
const taskNo = String(task.user_task_no || '').trim();
|
||||
if (!taskNo) return;
|
||||
focusTaskManually(uiState, taskNo, { expandDetails: false });
|
||||
if (task.user_task_authoritative === false) return;
|
||||
emit('focus', taskNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换文件详情展开;展开时通知父级过滤,收起时清空过滤。
|
||||
* viewed 会回写 Run.seen_at 并重算业务投影,右侧纯展示不得调用。
|
||||
*/
|
||||
function onToggleDetails(task: ConversationProcessingUserTask) {
|
||||
const taskNo = String(task.user_task_no || '').trim();
|
||||
if (!taskNo) return;
|
||||
toggleTaskDetails(uiState, taskNo);
|
||||
if (uiState.expandedDetailTaskNo === taskNo) {
|
||||
markTaskViewed(uiState, taskNo);
|
||||
emit('expandFiles', task);
|
||||
} else {
|
||||
emit('collapseFiles');
|
||||
@@ -188,12 +183,15 @@ function canExpandFileDetails(task: ConversationProcessingUserTask): boolean {
|
||||
}
|
||||
|
||||
/**
|
||||
* 活跃卡进度:聚焦全量 / 未聚焦紧凑;处理记录(completed/history)永不展实时进度。
|
||||
* 活跃卡进度:人工待办始终完整展示 Gate 动作;处理中聚焦全量 / 未聚焦紧凑;
|
||||
* 处理记录(completed/history)永不展实时进度。
|
||||
*/
|
||||
function progressModeForTask(task: ConversationProcessingUserTask): 'full' | 'compact' | 'hidden' {
|
||||
if (!projectionForTask(task)) return 'hidden';
|
||||
const group = String(task.group || '').trim();
|
||||
if (group === 'completed' || group === 'history') return 'hidden';
|
||||
// [STEP] 人工 Gate 的动作必须由门禁状态决定,不能因用户尚未点击任务而隐藏。
|
||||
if (group === 'needs_action') return 'full';
|
||||
const focused = focusedTaskNo.value === task.user_task_no;
|
||||
if (focused) return 'full';
|
||||
return 'compact';
|
||||
@@ -371,7 +369,7 @@ function presentationActionLabel(task: ConversationProcessingUserTask, item: Act
|
||||
|
||||
/**
|
||||
* 执行任务级动作:view_details / focus_task 本地聚焦;其余交给父级。
|
||||
* 非权威任务号禁止向后端 focus/viewed 写接口。
|
||||
* focus / view_details 仅影响右侧 UI;禁止写 viewed 审计,避免重算任务分组。
|
||||
*/
|
||||
function onTaskAction(task: ConversationProcessingUserTask, action: string) {
|
||||
const code = String(action || '').trim();
|
||||
@@ -379,13 +377,8 @@ function onTaskAction(task: ConversationProcessingUserTask, action: string) {
|
||||
if (code === 'view_details' || code === 'focus_task') {
|
||||
focusTaskManually(uiState, task.user_task_no, { expandDetails: code === 'view_details' });
|
||||
if (code === 'view_details') {
|
||||
markTaskViewed(uiState, task.user_task_no);
|
||||
emit('expandFiles', task);
|
||||
}
|
||||
if (task.user_task_authoritative !== false) {
|
||||
emit('focus', task.user_task_no);
|
||||
if (code === 'view_details') emit('viewed', task.user_task_no);
|
||||
}
|
||||
return;
|
||||
}
|
||||
emit('taskAction', { task, action: code });
|
||||
@@ -610,7 +603,7 @@ function onIntakeAction(item: ShippingProcessingProjection, action: string) {
|
||||
{{ t('chat.shippingProcessing.progress.currentNeedLabel') }}{{ currentNeedLabel(task) }}
|
||||
</div>
|
||||
<SidebarProgressInline
|
||||
v-if="task.group === 'processing' && progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
v-if="progressModeForTask(task) !== 'hidden' && projectionForTask(task)"
|
||||
class="mt-1.5 border-t border-current/10 pt-1.5"
|
||||
:projection="projectionForTask(task)!"
|
||||
:compact="progressModeForTask(task) === 'compact'"
|
||||
|
||||
@@ -52,14 +52,15 @@ const events = computed((): ShippingWorkflowEvent[] => (
|
||||
|
||||
const canCancel = computed(() => {
|
||||
const actions = props.item?.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('cancel');
|
||||
if (Array.isArray(actions)) return actions.includes('cancel') || Boolean(props.item);
|
||||
const status = String(props.item?.lifecycle_status || '').trim();
|
||||
return Boolean(props.item) && !['closed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
const canReparse = computed(() => {
|
||||
const actions = props.item?.available_actions;
|
||||
if (Array.isArray(actions)) return actions.includes('reparse');
|
||||
if (Array.isArray(actions)) return actions.includes('reparse')
|
||||
|| ['failed', 'reparse_failed'].includes(String(props.item?.lifecycle_status || '').trim());
|
||||
// 无契约时 fail-closed,禁止仅凭 pending_review 展示。
|
||||
return false;
|
||||
});
|
||||
@@ -75,7 +76,11 @@ const canOpenReview = computed(() => {
|
||||
if (!props.item) return false;
|
||||
const actions = props.item.available_actions;
|
||||
const status = String(props.item.lifecycle_status || '').trim();
|
||||
if (Array.isArray(actions)) return actions.includes('view_details') || actions.includes('enter_manual_review');
|
||||
if (Array.isArray(actions)) {
|
||||
return actions.includes('view_details')
|
||||
|| actions.includes('enter_manual_review')
|
||||
|| status === 'pending_review';
|
||||
}
|
||||
return status === 'pending_review';
|
||||
});
|
||||
|
||||
|
||||
@@ -399,6 +399,7 @@ async function openDetailsDrawer(
|
||||
|
||||
|
||||
const mountOptions = {
|
||||
attachTo: document.body,
|
||||
|
||||
global: {
|
||||
|
||||
@@ -623,7 +624,7 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
expect(reasonInput).not.toBeNull();
|
||||
expect(reasonConfirm).not.toBeNull();
|
||||
|
||||
(reasonInput as HTMLInputElement | null)?.setAttribute('value', 'cancel reason');
|
||||
if (reasonInput) (reasonInput as HTMLTextAreaElement).value = 'cancel reason';
|
||||
(reasonInput as HTMLInputElement | null)?.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
|
||||
reasonConfirm?.dispatchEvent(new Event('click', { bubbles: true }));
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;面板摘要为双行「N 任务 · M 文件」+
|
||||
* 「待我处理 / 系统处理中」;截断时展示 has_more 提示;
|
||||
* mapUserTaskObjectsToFileRows 合成文件行;取消/重识别走 Run API;
|
||||
* 路由 focus_task_no / 服务端 focused_task_no 驱动选中卡;
|
||||
* 路由 focus_task_no / 服务端 focused_task_no 驱动本地选中卡;
|
||||
* 详情抽屉仅用列表投影,不再请求 WorkflowItem 详情 API。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
@@ -284,22 +284,14 @@ const counts = computed(() => ({
|
||||
}));
|
||||
|
||||
/**
|
||||
* 任务卡已查看:空号或非权威号不写后端。
|
||||
*/
|
||||
async function onProcessingViewed(taskNo: string) {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) return;
|
||||
await ctl.value.markConversationTaskViewed?.(normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务卡聚焦:写审计、同步页面焦点,并按 run 过滤文件列表。
|
||||
* 任务卡聚焦:仅同步页面本地焦点,并按 run 过滤文件列表。
|
||||
* 右侧选中是展示状态,不能因普通点击反复写 conversation-task focus 审计。
|
||||
*/
|
||||
async function onProcessingFocus(taskNo: string) {
|
||||
const normalized = String(taskNo || '').trim();
|
||||
if (!normalized) return;
|
||||
chatPage?.setFocusedConversationTaskNo?.(normalized);
|
||||
await ctl.value.focusConversationTask?.(normalized);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -320,14 +312,7 @@ async function onExpandTaskFiles(task: ConversationProcessingUserTask) {
|
||||
detailOpen.value = true;
|
||||
}
|
||||
}
|
||||
// 走原有工作台入口,保持与「继续处理」按钮一致;失败则静默(仍保留本地聚焦)。
|
||||
if (runNo) {
|
||||
try {
|
||||
await openReviewFromTask(task);
|
||||
} catch {
|
||||
/* 路由失败不阻塞,交由上层统一错误处理。 */
|
||||
}
|
||||
}
|
||||
// 仅展开本地详情;进入订单处理工作台由抽屉中的显式「打开复核」动作触发。
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -366,6 +351,7 @@ async function onProcessingIntakeAction(payload: {
|
||||
|
||||
/**
|
||||
* 任务级权威操作:查看详情 / 复核 / 取消 / 重试失败文件。
|
||||
* 查看详情仅打开本地抽屉,禁止写 viewed 后重算右侧业务投影。
|
||||
*/
|
||||
async function onProcessingTaskAction(payload: {
|
||||
task: ConversationProcessingUserTask;
|
||||
@@ -376,9 +362,6 @@ async function onProcessingTaskAction(payload: {
|
||||
const runNo = String(task.run_no || '').trim();
|
||||
if (action === 'view_details') {
|
||||
onExpandTaskFiles(task);
|
||||
if (task.user_task_authoritative !== false) {
|
||||
await onProcessingViewed(String(task.user_task_no || '').trim());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (
|
||||
@@ -599,9 +582,6 @@ async function onTaskProjectionAction(payload: {
|
||||
if (task) {
|
||||
await onProcessingFocus(taskNo);
|
||||
await onExpandTaskFiles(task);
|
||||
if (task.user_task_authoritative !== false) {
|
||||
await onProcessingViewed(taskNo);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -764,8 +744,6 @@ watch(
|
||||
:work-items="processingWorkItems"
|
||||
:conversation-id="conversationId"
|
||||
:has-more-history="Boolean(displayProcessing?.summary?.has_more_history)"
|
||||
@focus="(taskNo) => void onProcessingFocus(taskNo)"
|
||||
@viewed="(taskNo) => void onProcessingViewed(taskNo)"
|
||||
@expand-files="onExpandTaskFiles"
|
||||
@collapse-files="onCollapseTaskFiles"
|
||||
@task-action="(payload) => void onProcessingTaskAction(payload)"
|
||||
|
||||
@@ -457,7 +457,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
|
||||
const pending = review.selectCase('CASE-NEW');
|
||||
expect(review.caseSwitchLoading.value).toBe(true);
|
||||
expect(review.activeCase.value).toBeNull();
|
||||
// 切换期间保留已确认快照,避免整个工作台清空。
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-OLD');
|
||||
expect(review.requestedCaseNo.value).toBe('CASE-NEW');
|
||||
|
||||
resolveCase?.(caseNew);
|
||||
@@ -477,7 +478,8 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
api.getEvidence.mockRejectedValueOnce(new Error('boom'));
|
||||
await review.selectCase('CASE-FAIL');
|
||||
expect(review.caseSwitchFailed.value).toBe(true);
|
||||
expect(review.activeCase.value).toBeNull();
|
||||
// 新请求失败时仍保留最近一次稳定 Case,避免白屏。
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-OLD');
|
||||
expect(review.requestedCaseNo.value).toBe('CASE-FAIL');
|
||||
});
|
||||
|
||||
|
||||
@@ -947,8 +947,6 @@ export function useShippingOrderReview() {
|
||||
requestedCaseNo.value = target;
|
||||
caseSwitchLoading.value = true;
|
||||
caseSwitchFailed.value = false;
|
||||
// [STEP 1] 清空完整业务 Case 与瞬态,禁止旧字段/Gate/issues 继续渲染。
|
||||
resetCaseTransientState();
|
||||
try {
|
||||
const [detail, result] = await Promise.all([
|
||||
getWorkspaceShippingOrderReviewCase(target),
|
||||
@@ -957,18 +955,24 @@ export function useShippingOrderReview() {
|
||||
// [STEP 2] 代次与目标 Case 双校验;过期响应一律丢弃。
|
||||
if (generation !== caseLoadGeneration) return;
|
||||
if (requestedCaseNo.value !== target) return;
|
||||
// [STEP 1] 目标快照到齐后一次性替换,切换期间保留旧内容,避免工作台白屏/大骨架闪烁。
|
||||
clearPreview();
|
||||
applyCaseSnapshot(detail);
|
||||
evidence.value = result.items;
|
||||
focusedFieldId.value = null;
|
||||
focusedLineKey.value = null;
|
||||
evidenceDrawerFocus.value = null;
|
||||
draftConflict.value = null;
|
||||
saveFailed.value = false;
|
||||
loadFailed.value = false;
|
||||
statusMessage.value = null;
|
||||
// Case 切换后必须按新 Candidate/Child OT 重建进度上下文,不能继续沿用首个 PDF 的 OT。
|
||||
await refreshWorkItemContext();
|
||||
refreshStatusMessage();
|
||||
} catch {
|
||||
if (generation !== caseLoadGeneration) return;
|
||||
if (requestedCaseNo.value !== target) return;
|
||||
// [STEP 3] 失败保持空骨架,禁止回显切换前 Case。
|
||||
activeCase.value = null;
|
||||
caseProjectionVersion.value = null;
|
||||
caseLoadingContext.value = null;
|
||||
evidence.value = [];
|
||||
llmSuggestions.value = [];
|
||||
// [STEP 3] 失败保留上一份稳定快照,用户仍可继续查看/编辑,不回退成空白工作台。
|
||||
caseSwitchFailed.value = true;
|
||||
} finally {
|
||||
if (generation === caseLoadGeneration) {
|
||||
|
||||
@@ -94,6 +94,12 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
i18n_key: 'workspace.shippingNotice.processGate.reasons.inventory_candidates_missing',
|
||||
},
|
||||
facts: {
|
||||
inventory_milestones: {
|
||||
candidates_calculated: 'completed',
|
||||
candidates_frozen: 'completed',
|
||||
snapshots_ready: 'pending',
|
||||
matched: 'pending',
|
||||
},
|
||||
candidate_set_id: 12,
|
||||
candidate_set_version: 3,
|
||||
candidate_set_status: 'frozen',
|
||||
@@ -117,6 +123,12 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
expect(projection?.facts?.sourceAttempts).toEqual({
|
||||
DBS_DUB: { status: 'consumed', attempt_no: 1 },
|
||||
});
|
||||
expect(projection?.facts?.inventoryMilestones).toEqual({
|
||||
candidatesCalculated: 'completed',
|
||||
candidatesFrozen: 'completed',
|
||||
snapshotsReady: 'pending',
|
||||
matched: 'pending',
|
||||
});
|
||||
expect(projection?.blockingReason?.code).toBe('inventory_candidates_missing');
|
||||
});
|
||||
|
||||
|
||||
@@ -162,6 +162,19 @@ function normalizeFacts(raw: unknown): ShippingProcessingFacts | undefined {
|
||||
? String(item.inventorySourceStatus)
|
||||
: null;
|
||||
}
|
||||
if ('inventory_milestones' in item || 'inventoryMilestones' in item) {
|
||||
const rawMilestones = item.inventory_milestones ?? item.inventoryMilestones;
|
||||
if (rawMilestones && typeof rawMilestones === 'object') {
|
||||
const milestones = rawMilestones as Record<string, unknown>;
|
||||
const state = (value: unknown): 'pending' | 'completed' => value === 'completed' ? 'completed' : 'pending';
|
||||
out.inventoryMilestones = {
|
||||
candidatesCalculated: state(milestones.candidates_calculated ?? milestones.candidatesCalculated),
|
||||
candidatesFrozen: state(milestones.candidates_frozen ?? milestones.candidatesFrozen),
|
||||
snapshotsReady: state(milestones.snapshots_ready ?? milestones.snapshotsReady),
|
||||
matched: state(milestones.matched),
|
||||
};
|
||||
}
|
||||
}
|
||||
if ('candidate_set_id' in item || 'candidateSetId' in item) {
|
||||
const v = item.candidate_set_id ?? item.candidateSetId;
|
||||
out.candidateSetId = v == null || v === '' ? null : Number(v);
|
||||
|
||||
@@ -23,7 +23,6 @@ export type FulfillmentProgressNodeKey = typeof FULFILLMENT_PROGRESS_NODES[numbe
|
||||
export const MANUAL_UPLOAD_GATE_ACTIONS = new Set([
|
||||
'wait_manual_upload',
|
||||
'mark_manual_uploaded',
|
||||
'regenerate_manual_upload_todo',
|
||||
]);
|
||||
|
||||
/** 统一 ShippingProcessing 终态 status(停止轮询)。 */
|
||||
|
||||
@@ -81,7 +81,7 @@ describe('useChatShippingMenuHandler', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses explicit taskId for generate_excel via Chat Turn', async () => {
|
||||
it('does not dispatch legacy generate_excel Chat Turn', async () => {
|
||||
const ctx = createContext();
|
||||
const { handleShippingMenuAction } = createShippingMenuHandlers(ctx);
|
||||
|
||||
@@ -91,14 +91,22 @@ describe('useChatShippingMenuHandler', () => {
|
||||
{ taskId: 'sn-target-777' },
|
||||
);
|
||||
|
||||
expect(ctx.startChatTurn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
inputType: 'action',
|
||||
actionType: 'shipping.generate_excel',
|
||||
payload: { task_no: 'SN-TARGET-777' },
|
||||
refs: expect.objectContaining({ task_no: 'SN-TARGET-777' }),
|
||||
}),
|
||||
expect(ctx.startChatTurn).not.toHaveBeenCalled();
|
||||
expect(ctx.refreshShippingActions).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('does not dispatch legacy match_inventory Chat Turn', async () => {
|
||||
const ctx = createContext();
|
||||
const { handleShippingMenuAction } = createShippingMenuHandlers(ctx);
|
||||
|
||||
await handleShippingMenuAction(
|
||||
{ id: 'match_inventory', label: '匹配库存', message: '请匹配库存' },
|
||||
undefined,
|
||||
{ taskId: 'sn-target-778' },
|
||||
);
|
||||
|
||||
expect(ctx.startChatTurn).not.toHaveBeenCalled();
|
||||
expect(ctx.refreshShippingActions).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('reads the displayed order version before freezing through Chat Turn', async () => {
|
||||
|
||||
@@ -152,6 +152,14 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 旧匹配/Excel 动作仅保留历史文案兼容;业务执行必须由 Projection
|
||||
// 下发的正式 Gate Action 驱动,Chat 不得再创建 legacy Turn。
|
||||
if (action.id === 'match_inventory' || action.id === 'generate_excel') {
|
||||
await ctx.refreshShippingActions();
|
||||
ctx.msg.info(ctx.t('chat.shippingNoticeRefreshDone'));
|
||||
return;
|
||||
}
|
||||
|
||||
const chatTurnActionIds = new Set([
|
||||
'freeze_order',
|
||||
'generate_excel',
|
||||
|
||||
@@ -212,6 +212,24 @@ describe('useShippingNoticeWorkflow', () => {
|
||||
ctl.stop();
|
||||
});
|
||||
|
||||
it('ignores external refresh triggers once only manual Gate tasks remain', async () => {
|
||||
const refreshTrigger = ref(0);
|
||||
api.getShippingProcessing.mockResolvedValue(buildUnifiedProcessing());
|
||||
const ctl = useShippingNoticeWorkflow({ conversationId: ref('conv-1'), refreshTrigger });
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
await nextTick();
|
||||
await Promise.resolve();
|
||||
|
||||
expect(api.getShippingProcessing).toHaveBeenCalledTimes(1);
|
||||
refreshTrigger.value += 1;
|
||||
await nextTick();
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
|
||||
// 仅待人工处理时,Run 轮询的旁路 refreshTrigger 不得重复唤醒右侧 GET。
|
||||
expect(api.getShippingProcessing).toHaveBeenCalledTimes(1);
|
||||
ctl.stop();
|
||||
});
|
||||
|
||||
it('uses unified work_items as the sole processing read source', async () => {
|
||||
api.getShippingProcessing.mockResolvedValue({
|
||||
conversation_id: 'conv-1',
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 逻辑:由 ChatViewContent / ShippingWorkflowTimeline 消费;仅读 shipping-processing;
|
||||
* focus/viewed 写路径优先应用响应中的 work_items;
|
||||
* 前台 2s / 后台 8s;请求 10s AbortController 超时;失败指数退避至 8s;
|
||||
* 分层轮询:系统处理中 2s 轮询,待复核 30s 轮询;
|
||||
* 分层轮询:仅系统处理中 2s 轮询;外部 Run 轮询不会在待人工处理时反复唤醒本读接口;
|
||||
* 区分 initialLoading / manualRefreshing / polling 三种 loading 态;
|
||||
* 语义签名比较:业务状态未变化时不替换投影对象,防止按钮闪烁与 DOM 重建。
|
||||
*/
|
||||
@@ -450,6 +450,9 @@ export function useShippingNoticeWorkflow(
|
||||
() => readOption(options.refreshTrigger ?? 0),
|
||||
() => {
|
||||
if (!normalizedConversationId.value) return;
|
||||
// [STEP] Run 轮询也会递增 refreshTrigger。右侧已进入人工 Gate 时状态不会
|
||||
// 自动变化,禁止每次 Run 轮询都重拉同一会话投影;首次尚无投影时仍允许恢复。
|
||||
if (processing.value && !shouldContinueProcessingPolling(processing.value)) return;
|
||||
pollingStopped = false;
|
||||
schedulePoll(pollGeneration, 0);
|
||||
},
|
||||
|
||||
@@ -60,6 +60,7 @@ export function useShippingProcessingWorkItem(
|
||||
let timer: ReturnType<typeof window.setTimeout> | null = null;
|
||||
let generation = 0;
|
||||
let stopped = false;
|
||||
let refreshInFlight: { no: string; promise: Promise<void> } | null = null;
|
||||
const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
|
||||
const monotonic = Boolean(options.monotonicProgressVersion);
|
||||
|
||||
@@ -87,6 +88,10 @@ export function useShippingProcessingWorkItem(
|
||||
*/
|
||||
async function refresh(): Promise<void> {
|
||||
const no = String(toValue(workItemNo) || '').trim();
|
||||
if (refreshInFlight?.no === no) {
|
||||
await refreshInFlight.promise;
|
||||
return;
|
||||
}
|
||||
const enabled = options.enabled == null ? true : Boolean(toValue(options.enabled));
|
||||
if (!enabled || !no) {
|
||||
projection.value = null;
|
||||
@@ -96,7 +101,8 @@ export function useShippingProcessingWorkItem(
|
||||
}
|
||||
const gen = generation;
|
||||
loading.value = true;
|
||||
try {
|
||||
const request = (async () => {
|
||||
try {
|
||||
const raw = await getWorkspaceShippingProcessingWorkItem(workItemType, no);
|
||||
if (stopped || gen !== generation) return;
|
||||
const normalized = normalizeShippingProcessingProjection(raw);
|
||||
@@ -112,7 +118,7 @@ export function useShippingProcessingWorkItem(
|
||||
void refresh();
|
||||
}, pollMs);
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (err) {
|
||||
if (stopped || gen !== generation) return;
|
||||
// 404 / 业务不存在:清空投影但不抛到页面主流程。
|
||||
if (err instanceof BusinessError && (err.status === 404 || err.code?.includes('NOT_FOUND'))) {
|
||||
@@ -128,8 +134,15 @@ export function useShippingProcessingWorkItem(
|
||||
void refresh();
|
||||
}, pollMs);
|
||||
}
|
||||
} finally {
|
||||
} finally {
|
||||
if (gen === generation) loading.value = false;
|
||||
}
|
||||
})();
|
||||
refreshInFlight = { no, promise: request };
|
||||
try {
|
||||
await request;
|
||||
} finally {
|
||||
if (refreshInFlight?.promise === request) refreshInFlight = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,6 +160,9 @@ export function useShippingProcessingWorkItem(
|
||||
error.value = null;
|
||||
return;
|
||||
}
|
||||
// OT/PDF 切换时先清空旧投影,避免新请求完成前继续展示第一份 PDF 的状态。
|
||||
projection.value = null;
|
||||
error.value = null;
|
||||
void refresh();
|
||||
},
|
||||
{ immediate: true },
|
||||
|
||||
@@ -162,6 +162,12 @@ export interface ShippingProcessingPrimaryAction {
|
||||
* 用户态统一 Projection facts(T8 决策 F2;子状态事实字典)。
|
||||
*/
|
||||
export interface ShippingProcessingFacts {
|
||||
inventoryMilestones?: {
|
||||
candidatesCalculated: 'pending' | 'completed';
|
||||
candidatesFrozen: 'pending' | 'completed';
|
||||
snapshotsReady: 'pending' | 'completed';
|
||||
matched: 'pending' | 'completed';
|
||||
};
|
||||
inventorySourceStatus?: string | null;
|
||||
candidateSetId?: number | null;
|
||||
candidateSetVersion?: number | null;
|
||||
@@ -183,7 +189,20 @@ export interface ShippingProcessingFacts {
|
||||
transactionErrorCode?: string | null;
|
||||
callbackReceivedAt?: string | null;
|
||||
}>;
|
||||
lineResolutions?: Record<string, unknown>[];
|
||||
lineResolutions?: Array<{
|
||||
lineIndex?: number | null;
|
||||
lineKey?: string | null;
|
||||
disposition?: string | null;
|
||||
resolvedInventorySourceCode?: string | null;
|
||||
inventoryFileNo?: string | null;
|
||||
inventoryFileSha256?: string | null;
|
||||
inventoryRowIndex?: number | null;
|
||||
matchAttemptId?: number | null;
|
||||
requiredQty?: string | number | null;
|
||||
matchedQty?: string | number | null;
|
||||
shortageQty?: string | number | null;
|
||||
[key: string]: unknown;
|
||||
}>;
|
||||
exportState?: string;
|
||||
uploadState?: string;
|
||||
switchState?: string;
|
||||
@@ -937,6 +956,9 @@ export type ShippingProcessGateActionCode =
|
||||
| 'retry_inventory_field_mapping'
|
||||
| 'confirm_inventory_field_mapping'
|
||||
| 'retry_inventory_matching'
|
||||
| 'retry_inventory_from_preparation'
|
||||
| 'retry_inventory_from_field_mapping'
|
||||
| 'retry_inventory_from_matching'
|
||||
| 'open_inventory_match_review'
|
||||
| 'recheck_inventory_sufficiency'
|
||||
| 'open_shortage_review'
|
||||
@@ -965,13 +987,44 @@ export interface ShippingProcessGateProjection {
|
||||
blocking_reason?: Record<string, unknown> | null;
|
||||
findings?: Array<Record<string, unknown>>;
|
||||
next_action_code?: ShippingProcessGateActionCode | string | null;
|
||||
allowed_actions?: string[];
|
||||
action_presentation?: ShippingProcessGateActionPresentation[];
|
||||
recovery_targets?: ShippingProcessRecoveryTarget[];
|
||||
passed_at?: string | null;
|
||||
latest_attempt?: {
|
||||
id?: number;
|
||||
attempt_no?: number;
|
||||
status?: string;
|
||||
error_code?: string | null;
|
||||
error_summary?: string | null;
|
||||
} | null;
|
||||
implementation_status?: ShippingProcessGateImplementationStatus;
|
||||
}
|
||||
|
||||
export interface ShippingProcessGateActionPresentation {
|
||||
code: string;
|
||||
label_key: string;
|
||||
kind: 'current_gate' | 'recovery' | 'view' | string;
|
||||
dispatch: 'navigation' | 'mutation' | 'refresh' | string;
|
||||
}
|
||||
|
||||
/** 服务端 RecoveryPlan 只读目标;target_gate 由后端合同推导,客户端不得提交覆盖。 */
|
||||
export interface ShippingProcessRecoveryTarget {
|
||||
action_code: ShippingProcessGateActionCode | string;
|
||||
target_gate: ShippingProcessGateCode | string;
|
||||
resume_after_gate?: ShippingProcessGateCode | string | null;
|
||||
allowed_intermediate_gates?: Array<ShippingProcessGateCode | string>;
|
||||
invalidates?: string[];
|
||||
permission?: string | null;
|
||||
}
|
||||
|
||||
export type ShippingProcessGateImplementationStatus =
|
||||
| 'supported'
|
||||
| 'implemented'
|
||||
| 'adapter_required'
|
||||
| 'blocked'
|
||||
| string;
|
||||
|
||||
/** Execution 用户 Gate 摘要(ui_state.process_gate / GET execution 对齐)。 */
|
||||
export interface ShippingProcessGateUserSummary {
|
||||
execution_no: string;
|
||||
@@ -979,6 +1032,8 @@ export interface ShippingProcessGateUserSummary {
|
||||
current_blocking_gate?: ShippingProcessGateProjection | null;
|
||||
blocking_reason_code?: string | null;
|
||||
blocking_message?: string | null;
|
||||
/** 当前 Gate 最近一次失败的脱敏执行详情;仅用于用户排查,不是 API action。 */
|
||||
failure_detail?: string | null;
|
||||
/** 统一可解释性投影(与 build_explainability_reason 对齐) */
|
||||
explainability?: ShippingExplainabilityReason | null;
|
||||
next_action_code?: ShippingProcessGateActionCode | string | null;
|
||||
@@ -1006,6 +1061,19 @@ export interface ShippingProcessGateUserSummary {
|
||||
sequence_no: number;
|
||||
}>;
|
||||
current_findings?: Array<Record<string, unknown>>;
|
||||
recovery_targets?: ShippingProcessRecoveryTarget[];
|
||||
primary_action?: ShippingProcessGateActionPresentation | null;
|
||||
allowed_actions?: string[];
|
||||
action_presentation?: ShippingProcessGateActionPresentation[];
|
||||
view_actions?: ShippingProcessGateActionPresentation[];
|
||||
active_recovery_plans?: Array<{
|
||||
plan_no: string;
|
||||
action_code: string;
|
||||
current_gate: string;
|
||||
target_gate: string;
|
||||
resume_after_gate?: string | null;
|
||||
status: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface ShippingFieldEvidenceItem {
|
||||
@@ -1217,6 +1285,9 @@ export interface ShippingStpFacts {
|
||||
part_number?: string | null;
|
||||
resolved_inventory_source_code?: string | null;
|
||||
inventory_file_no?: string | null;
|
||||
inventory_file_sha256?: string | null;
|
||||
inventory_row_index?: number | null;
|
||||
match_attempt_id?: number | null;
|
||||
inventory_row_ref?: {
|
||||
reservation_id?: string | null;
|
||||
part_number?: string | null;
|
||||
@@ -2744,6 +2815,10 @@ export interface ShippingOrderReviewLineFulfillmentLine {
|
||||
inventory_snapshot_id?: number | null;
|
||||
inventory_checked_at?: string | null;
|
||||
inventory_source_code?: string | null;
|
||||
inventory_file_no?: string | null;
|
||||
inventory_file_sha256?: string | null;
|
||||
inventory_row_index?: number | null;
|
||||
match_attempt_id?: number | null;
|
||||
inventory_source?: ({
|
||||
code?: string | null;
|
||||
label?: string | null;
|
||||
|
||||
@@ -718,6 +718,37 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
expect(wrapper.find('[data-testid="review-confirm-create"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders a persistent result panel for a completed formal task', async () => {
|
||||
activeCase.value = {
|
||||
...activeCase.value,
|
||||
status: 'confirmed',
|
||||
confirmed_task_no: 'SN-MOCK',
|
||||
confirmed_task_id: 1,
|
||||
has_formal_ot: true,
|
||||
current_stage: { code: 'completed', label_key: 'completed' },
|
||||
automation: { status: 'completed', can_auto_create: false, can_build: false },
|
||||
};
|
||||
const taskApi = await import('@/features/chat/api/shipping.api');
|
||||
vi.mocked(taskApi.getWorkspaceShippingTask).mockResolvedValueOnce({
|
||||
task_no: 'SN-MOCK',
|
||||
status: 'completed',
|
||||
process_status: 'uploaded',
|
||||
upload_status: 'uploaded',
|
||||
lines: [],
|
||||
line_results: [{
|
||||
part_number: 'PN-1', reservation_id: 'RES-1', required_qty: 2,
|
||||
available_qty: 2, shortage_qty: 0, line_status: 'ok',
|
||||
}],
|
||||
export_artifacts: [{ id: 1, artifact_no: 'EXP-1', status: 'ready', file_name: 'result.xlsx' }],
|
||||
events: [],
|
||||
ui_state: { action_buttons: [], summary: {}, process_gate: null },
|
||||
} as any);
|
||||
const wrapper = await mountView();
|
||||
expect(wrapper.find('[data-testid="review-formal-task-result-region"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[data-testid="review-formal-task-result-panel"]').text()).toContain('PN-1');
|
||||
expect(wrapper.find('[data-testid="review-formal-task-result-download"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('renders empty optional schema fields as editable line columns', async () => {
|
||||
const wrapper = await mountView();
|
||||
const inputs = wrapper.findAll('[data-testid="review-line-field-input"]');
|
||||
|
||||
@@ -19,7 +19,7 @@ import { computed, defineAsyncComponent, nextTick, onBeforeUnmount, onMounted, r
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { Check, CircleX, Crosshair, Plus, RefreshCw, Undo2, Copy, Trash2 } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError, resolveLocalizedErrorMessage } from '@/shared/api/client';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
import {
|
||||
@@ -35,7 +35,6 @@ import {
|
||||
retryWorkspaceConversationAutoProgress,
|
||||
retryWorkspaceShippingOrderStpAutoCreate,
|
||||
retryWorkspaceShippingTask,
|
||||
retryWorkspaceShippingTaskLine,
|
||||
viewWorkspaceShippingOrderReviewHighlightDiagnostic,
|
||||
} from '../api/shipping.api';
|
||||
import type {
|
||||
@@ -55,6 +54,7 @@ import ReviewInventoryIssueFallbackCard from '../components/shipping-review/Revi
|
||||
import ReviewAuditTrailDrawer from '../components/shipping-review/ReviewAuditTrailDrawer.vue';
|
||||
import ReviewCompletedChecksPanel from '../components/shipping-review/ReviewCompletedChecksPanel.vue';
|
||||
import ReviewCurrentProcessingCard from '../components/shipping-review/ReviewCurrentProcessingCard.vue';
|
||||
import ReviewConversationRetryDrawer from '../components/shipping-review/ReviewConversationRetryDrawer.vue';
|
||||
import ReviewDocumentNavigation, {
|
||||
type ReviewDocumentNavMode,
|
||||
} from '../components/shipping-review/ReviewDocumentNavigation.vue';
|
||||
@@ -66,6 +66,7 @@ import ReviewWorkbenchModeToggle from '../components/shipping-review/ReviewWorkb
|
||||
import ReviewUnsavedSwitchDialog from '../components/shipping-review/ReviewUnsavedSwitchDialog.vue';
|
||||
import ProcessGateRecoveryCard from '@/features/shipping-process-gates/components/ProcessGateRecoveryCard.vue';
|
||||
import TaskTodoPanel from '@/features/workspace/shipping-task-center/TaskTodoPanel.vue';
|
||||
import ManualUploadEvidenceDialog from '@/features/workspace/shipping-task-center/ManualUploadEvidenceDialog.vue';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import ReviewLineNoOverrideDialog, {
|
||||
type LineNoOverridePayload,
|
||||
@@ -111,6 +112,7 @@ const {
|
||||
shippingProcessingProjection,
|
||||
authoritativeOrderTaskNo,
|
||||
refreshShippingProcessing,
|
||||
shippingProcessingLoading,
|
||||
workflowProgressPolling,
|
||||
versions,
|
||||
statusMessage,
|
||||
@@ -285,7 +287,8 @@ const displayHeaderValues = computed(() => (
|
||||
const displayDraftLines = computed(() => displayCase.value?.draft?.lines || []);
|
||||
|
||||
const showWorkbenchCaseShell = computed(() => Boolean(displayCase.value));
|
||||
const caseContentSkeleton = computed(() => caseSwitchLoading.value || caseSwitchFailed.value);
|
||||
/** 切换期间和失败回退均保留旧快照;无稳定 Case 时才进入空状态骨架。 */
|
||||
const caseContentSkeleton = computed(() => caseSwitchFailed.value && !activeCase.value);
|
||||
|
||||
/** can_build && can_auto_create 时底栏隐藏「确认建单」;文案仅表示资格达标等待入队,不等于正在推进。 */
|
||||
/** queued|running|已有正式 OT|task_missing 时隐藏「确认并创建任务」。 */
|
||||
@@ -459,9 +462,12 @@ const confirmSuccess = ref<{
|
||||
} | null>(null);
|
||||
const progressRetrying = ref(false);
|
||||
const conversationRetrying = ref(false);
|
||||
const conversationRetryResultOpen = ref(false);
|
||||
const conversationRetryDrawerOpen = ref(false);
|
||||
const conversationRetryToastOpen = ref(false);
|
||||
let conversationRetryToastTimer: ReturnType<typeof window.setTimeout> | undefined;
|
||||
const conversationRetryError = ref('');
|
||||
const conversationRetryResult = ref<{
|
||||
summary: { total: number; retried: number; skipped: number; failed: number };
|
||||
summary: { total: number; retried: number; skipped: number; failed: number; blocked?: number };
|
||||
items: Array<{
|
||||
object_type: string;
|
||||
object_ref: string;
|
||||
@@ -471,6 +477,19 @@ const conversationRetryResult = ref<{
|
||||
}>;
|
||||
} | null>(null);
|
||||
|
||||
const hasConversationRetryAttention = computed(() => (
|
||||
Number(conversationRetryResult.value?.summary.failed || 0) > 0
|
||||
|| Number(conversationRetryResult.value?.summary.blocked || 0) > 0
|
||||
));
|
||||
|
||||
function showConversationRetryToast() {
|
||||
if (conversationRetryToastTimer) window.clearTimeout(conversationRetryToastTimer);
|
||||
conversationRetryToastOpen.value = true;
|
||||
conversationRetryToastTimer = window.setTimeout(() => {
|
||||
conversationRetryToastOpen.value = false;
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
/**
|
||||
* 题9A:already_running 响应本地冷却(任务号 → 过期毫秒时间戳)。
|
||||
* 当服务端返回 noop.already_running 时写对应 task 条目;按钮禁用在此有效期内叠加,避免「投影 refresh 有 2-3s 滞后期间用户再次点击」。
|
||||
@@ -1165,104 +1184,7 @@ function displayAvailableQty(line: ShippingOrderReviewLineFulfillmentLine | null
|
||||
return String(line.available_qty);
|
||||
}
|
||||
|
||||
const lineOpsBusyKey = ref<string | null>(null);
|
||||
|
||||
/** 任务整体 queued/running:行级写操作隐藏/禁用。 */
|
||||
const taskAutomationRunning = computed(() => {
|
||||
const status = String(activeCase.value?.automation?.status || '').trim().toLowerCase();
|
||||
return ['queued', 'running', 'processing', 'automating'].includes(status);
|
||||
});
|
||||
|
||||
/**
|
||||
* 明细行统一「重试」:POST .../lines/{line_key}/retry;不传内部动作码。
|
||||
* 题3B / 题10A:行 REMATCH 不受整单 running 源阻塞;但此处仍按行按钮互斥和行冷却独立判断。
|
||||
*/
|
||||
async function retryLineUnified(lineKey: string) {
|
||||
const key = String(lineKey || '').trim();
|
||||
if (!key || caseSwitchLoading.value) {
|
||||
msg.warning(t('chat.shippingOrderReview.lineOps.retryRpaUnavailable'));
|
||||
return;
|
||||
}
|
||||
// 题3B:整单正在 running → 仅 fetch_inventory(缺快照) 受影响;此处仅用 inventory_source_unstable 或 task_missing 全局阻塞
|
||||
if (Boolean(activeCase.value?.task_missing)) {
|
||||
msg.warning(t('chat.shippingOrderReview.lineOps.retryRpaUnavailable'));
|
||||
return;
|
||||
}
|
||||
const taskNo = String(
|
||||
confirmedNoticeTaskNo.value
|
||||
|| activeCase.value?.confirmed_task_no
|
||||
|| formalOtRetryTaskNo.value
|
||||
|| '',
|
||||
).trim();
|
||||
if (!taskNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.lineOps.retryRpaUnavailable'));
|
||||
return;
|
||||
}
|
||||
if (lineOpsBusyKey.value) return;
|
||||
// 行级冷却:taskNo + lineKey
|
||||
if (isLineRunningCooldownActive(taskNo, key)) {
|
||||
msg.warning(t('chat.shippingOrderReview.lineOps.retryAlreadyRunning', { lineKey: key }));
|
||||
return;
|
||||
}
|
||||
lineOpsBusyKey.value = key;
|
||||
try {
|
||||
const result = await retryWorkspaceShippingTaskLine(taskNo, key);
|
||||
const status = String(result?.status || '').trim().toLowerCase();
|
||||
const reasonCode = String(result?.reason_code || '').trim().toLowerCase();
|
||||
if (status === 'noop' && reasonCode === 'already_running') {
|
||||
markLineRunningCooldown(taskNo, key, TASK_RUNNING_COOLDOWN_MS);
|
||||
msg.warning(
|
||||
String(result?.message || t('chat.shippingOrderReview.lineOps.retryAlreadyRunning', { lineKey: key })),
|
||||
);
|
||||
void refreshShippingProcessing();
|
||||
return;
|
||||
}
|
||||
if (status === 'needs_human') {
|
||||
msg.warning(String(result?.message || t('chat.shippingOrderReview.autoProgress.status.needs_human')));
|
||||
} else if (status === 'failed') {
|
||||
msg.warning(String(result?.message || t('chat.shippingOrderReview.lineOps.retryRpaFailed')));
|
||||
} else {
|
||||
msg.success(t('chat.shippingOrderReview.lineOps.retryRpaSubmitted'));
|
||||
}
|
||||
await reloadLatestDraft();
|
||||
void refreshShippingProcessing();
|
||||
} catch (error) {
|
||||
msg.error(
|
||||
error instanceof BusinessError
|
||||
? resolveLocalizedErrorMessage(error.code, error.message)
|
||||
: t('chat.shippingOrderReview.lineOps.retryRpaFailed'),
|
||||
);
|
||||
} finally {
|
||||
lineOpsBusyKey.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
/** 行级 already_running 冷却(taskNo + lineKey 组合 → 过期毫秒)。 */
|
||||
const lineRunningCooldownUntilMs = ref<Record<string, number>>({});
|
||||
|
||||
function markLineRunningCooldown(taskNo: string | null | undefined, lineKey: string | null | undefined, durationMs: number = TASK_RUNNING_COOLDOWN_MS) {
|
||||
const t = String(taskNo || '').trim();
|
||||
const l = String(lineKey || '').trim();
|
||||
if (!t || !l) return;
|
||||
const key = `${t}::${l}`;
|
||||
lineRunningCooldownUntilMs.value = {
|
||||
...lineRunningCooldownUntilMs.value,
|
||||
[key]: Date.now() + durationMs,
|
||||
};
|
||||
}
|
||||
|
||||
function isLineRunningCooldownActive(taskNo: string | null | undefined, lineKey: string | null | undefined): boolean {
|
||||
const t = String(taskNo || '').trim();
|
||||
const l = String(lineKey || '').trim();
|
||||
if (!t || !l) return false;
|
||||
const key = `${t}::${l}`;
|
||||
const until = Number(lineRunningCooldownUntilMs.value[key] || 0) || 0;
|
||||
return until > Date.now();
|
||||
}
|
||||
|
||||
/**
|
||||
* Case 级库存兜底卡「重试」:走任务级统一决策器(无行键时)。
|
||||
*/
|
||||
/** Case 级库存兜底卡:统一由当前 Gate 卡提供精确动作。 */
|
||||
async function retryCaseInventoryFallback() {
|
||||
await retryFormalOtAutoProgress();
|
||||
}
|
||||
@@ -1325,6 +1247,24 @@ async function handleCurrentTaskAction(
|
||||
) {
|
||||
const params = (parameters || {}) as Record<string, unknown>;
|
||||
switch (code) {
|
||||
case 'download_excel': {
|
||||
const taskNo = (params.task_no as string | undefined) || confirmedNoticeTaskNo.value;
|
||||
if (!taskNo) {
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return;
|
||||
}
|
||||
await downloadWorkspaceShippingExcelFile(taskNo);
|
||||
msg.success(t('chat.shippingOrderReview.workbench.actionSuccess'));
|
||||
break;
|
||||
}
|
||||
case 'view_result':
|
||||
case 'open_fulfillment':
|
||||
case 'view_details':
|
||||
workbenchMode.value = 'formal_task';
|
||||
if (!(await ensureFormalTaskDetailReady())) return;
|
||||
await nextTick();
|
||||
scrollWorkbenchAnchor('review-formal-task-result-region');
|
||||
break;
|
||||
case 'open_inventory_source_review':
|
||||
if (hasCreatedShippingTask.value) {
|
||||
workbenchMode.value = 'formal_task';
|
||||
@@ -1364,6 +1304,9 @@ async function handleCurrentTaskAction(
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'mark_manual_uploaded':
|
||||
await formalTodoPanelRef.value?.invokeActionByCode('mark_manual_uploaded');
|
||||
break;
|
||||
default:
|
||||
msg.info(t('chat.shippingOrderReview.currentTask.actionUnknown', { code }));
|
||||
}
|
||||
@@ -1659,6 +1602,51 @@ const confirmedNoticeTaskNo = computed(() => String(
|
||||
/** 确认后履约待办详情;任务中心不再挂工作台,由本工作台承接。 */
|
||||
const formalTaskDetail = ref<ShippingTaskDetail | null>(null);
|
||||
const formalTaskDetailLoading = ref(false);
|
||||
const manualUploadRegistrationOpen = ref(false);
|
||||
|
||||
/** 完成态结果摘要:与正式 ShippingTask 详情同源,禁止从进度条重新推导业务结果。 */
|
||||
const formalResultLineResults = computed(() => formalTaskDetail.value?.line_results || []);
|
||||
const formalResultShortageCount = computed(() => formalResultLineResults.value.filter(
|
||||
(line) => Number(line.shortage_qty || 0) > 0 || String(line.line_status || '').toLowerCase() === 'shortage',
|
||||
).length);
|
||||
const formalResultMatchedCount = computed(() => formalResultLineResults.value.filter(
|
||||
(line) => Number(line.shortage_qty || 0) <= 0 && String(line.line_status || '').toLowerCase() !== 'shortage',
|
||||
).length);
|
||||
const formalResultArtifact = computed(() => formalTaskDetail.value?.export_artifacts?.[0] || null);
|
||||
const formalResultCompletedAt = computed(() => (
|
||||
formalTaskDetail.value?.upload_attempts?.find((attempt) => String(attempt.status || '').toLowerCase() === 'succeeded')?.finished_at
|
||||
|| formalTaskDetail.value?.updated_at
|
||||
|| formalTaskDetail.value?.created_at
|
||||
|| null
|
||||
));
|
||||
const formalResultIsCompleted = computed(() => {
|
||||
const status = String(formalTaskDetail.value?.process_status || '').toLowerCase();
|
||||
return ['completed', 'uploaded', 'closed'].includes(status)
|
||||
|| String(formalTaskDetail.value?.upload_status || '').toLowerCase() === 'uploaded';
|
||||
});
|
||||
|
||||
/** 直接在订单复核页打开人工上传登记,避免依赖仅在 formal_task 模式挂载的 TaskTodoPanel ref。 */
|
||||
function openManualUploadRegistration() {
|
||||
if (!confirmedNoticeTaskNo.value) {
|
||||
msg.warning(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
return;
|
||||
}
|
||||
manualUploadRegistrationOpen.value = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工上传登记成功后刷新完整工作台状态。
|
||||
* 先重新拉取 Review Case(顶部阶段与 Gate 的权威投影),再刷新任务详情和统一处理投影;
|
||||
* 不能只刷新 OT 详情,否则登记已落库但页面仍会显示旧的人工上传阻断状态。
|
||||
*/
|
||||
async function handleManualUploadSuccess() {
|
||||
manualUploadRegistrationOpen.value = false;
|
||||
await reloadLatestDraft();
|
||||
await Promise.all([
|
||||
loadFormalTaskDetail(),
|
||||
refreshShippingProcessing(),
|
||||
]);
|
||||
}
|
||||
const formalTodoPanelRef = ref<{
|
||||
invokeActionByCode: (actionId: string) => Promise<void>;
|
||||
openCustomerDialog: () => Promise<void>;
|
||||
@@ -1686,7 +1674,9 @@ async function loadFormalTaskDetail() {
|
||||
watch(
|
||||
[confirmedNoticeTaskNo, workbenchMode, hasCreatedShippingTask],
|
||||
([taskNo, mode, created]) => {
|
||||
if (taskNo && created && (mode === 'formal_task' || mode === 'confirm_progress')) {
|
||||
const completed = String(displayCase.value?.current_stage?.code || '').trim().toLowerCase() === 'completed'
|
||||
|| String(displayCase.value?.user_status || '').trim().toLowerCase() === 'completed';
|
||||
if (taskNo && created && (mode === 'formal_task' || mode === 'confirm_progress' || completed)) {
|
||||
void loadFormalTaskDetail();
|
||||
return;
|
||||
}
|
||||
@@ -2115,50 +2105,33 @@ const retryStpAutoCreate = async () => {
|
||||
|
||||
/**
|
||||
* 对话级「重试自动推进」:扫描会话下可恢复 Case/正式 OT。
|
||||
* 核心逻辑:调用 retryWorkspaceConversationAutoProgress;打开结果弹窗;刷新草稿与处理投影。
|
||||
* 核心逻辑:调用 retryWorkspaceConversationAutoProgress;以内嵌摘要展示逐项结果;刷新草稿与处理投影。
|
||||
*/
|
||||
const retryConversationAutoProgress = async () => {
|
||||
const id = String(conversationId.value || '').trim();
|
||||
if (!id || conversationRetrying.value || !showConversationRetry.value) return;
|
||||
if (caseSwitchLoading.value || progressRetrying.value) return;
|
||||
conversationRetrying.value = true;
|
||||
conversationRetryError.value = '';
|
||||
try {
|
||||
const result = await retryWorkspaceConversationAutoProgress(id);
|
||||
conversationRetryResult.value = {
|
||||
summary: result.summary,
|
||||
items: result.items || [],
|
||||
};
|
||||
conversationRetryResultOpen.value = true;
|
||||
// 结果只以短暂提示反馈;逐项详情由用户主动打开右侧抽屉,避免占用复核主内容。
|
||||
showConversationRetryToast();
|
||||
await reloadLatestDraft();
|
||||
await refreshShippingProcessing();
|
||||
} catch (error) {
|
||||
msg.error(resolveReviewErrorMessage(error));
|
||||
// 批量动作失败只影响本次扫描;错误以内嵌提示展示,避免 toast 遮挡并允许继续切换任务。
|
||||
conversationRetryError.value = resolveReviewErrorMessage(error);
|
||||
showConversationRetryToast();
|
||||
} finally {
|
||||
conversationRetrying.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 「关闭并刷新」:关闭对话级重试结果弹窗并重新拉取工作台投影。
|
||||
*/
|
||||
const closeConversationRetryResult = async () => {
|
||||
conversationRetryResultOpen.value = false;
|
||||
conversationRetryResult.value = null;
|
||||
await reloadLatestDraft();
|
||||
await refreshShippingProcessing();
|
||||
};
|
||||
|
||||
/**
|
||||
* 对话级重试跳过原因文案:优先 i18n reason.*,否则回退原始 reason_code。
|
||||
* @param reasonCode - 后端 reason_code
|
||||
*/
|
||||
const conversationRetrySkipReasonLabel = (reasonCode?: string | null) => {
|
||||
const code = String(reasonCode || '').trim();
|
||||
if (!code) return '';
|
||||
const key = `chat.shippingOrderReview.conversationRetry.reason.${code}`;
|
||||
return te(key) ? t(key) : code;
|
||||
};
|
||||
|
||||
/**
|
||||
* 滚动到工作台锚点(data-testid)。
|
||||
*/
|
||||
@@ -2319,6 +2292,7 @@ const onUnifiedProcessingAction = async (item: ActionPresentationItem) => {
|
||||
const resultEl = document.querySelector('[data-testid="review-formal-task-result-region"]');
|
||||
if (resultEl) {
|
||||
resultEl.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
msg.info(t('chat.shippingOrderReview.workbench.actionSuccess'));
|
||||
} else {
|
||||
scrollWorkbenchAnchor('review-formal-task-todo-panel');
|
||||
msg.info(t('chat.shippingOrderReview.workbench.resultNotReady'));
|
||||
@@ -2353,10 +2327,14 @@ const onUnifiedProcessingAction = async (item: ActionPresentationItem) => {
|
||||
}
|
||||
|
||||
if (behavior === 'todo_panel') {
|
||||
const todoCode = entry.todoActionCode || item.actionCode;
|
||||
if (todoCode === 'mark_manual_uploaded') {
|
||||
openManualUploadRegistration();
|
||||
return;
|
||||
}
|
||||
workbenchMode.value = 'formal_task';
|
||||
if (!(await ensureFormalTaskDetailReady())) return;
|
||||
scrollWorkbenchAnchor(entry.scrollTestId || 'review-formal-task-todo-panel');
|
||||
const todoCode = entry.todoActionCode || item.actionCode;
|
||||
await formalTodoPanelRef.value?.invokeActionByCode(todoCode);
|
||||
return;
|
||||
}
|
||||
@@ -2877,10 +2855,12 @@ watch(
|
||||
:conversation-retry-eligible-count="conversationRetryEligibleCount"
|
||||
:conversation-retrying="conversationRetrying"
|
||||
:conversation-retry-disabled="caseSwitchLoading || progressRetrying"
|
||||
:has-conversation-retry-result="hasConversationRetryAttention"
|
||||
@back="back"
|
||||
@open-version-history="openVersionHistory"
|
||||
@open-audit-trail="openAuditTrail"
|
||||
@retry-conversation-auto-progress="() => void retryConversationAutoProgress()"
|
||||
@open-conversation-retry-result="conversationRetryDrawerOpen = true"
|
||||
/>
|
||||
|
||||
<div
|
||||
@@ -2991,6 +2971,7 @@ watch(
|
||||
:item="reviewProgressContext"
|
||||
:task-no="authoritativeOrderTaskNo"
|
||||
:polling="workflowProgressPolling"
|
||||
:refreshing="shippingProcessingLoading"
|
||||
:processing-projection="shippingProcessingProjection"
|
||||
:has-formal-ot="hasFormalOt"
|
||||
data-testid="review-shipping-processing-strip"
|
||||
@@ -2999,7 +2980,7 @@ watch(
|
||||
/>
|
||||
|
||||
<section
|
||||
v-if="hasCreatedShippingTask && workbenchMode === 'formal_task' && formalTaskDetail"
|
||||
v-if="hasCreatedShippingTask && formalTaskDetail && (workbenchMode === 'formal_task' || formalResultIsCompleted)"
|
||||
class="rounded-xl border border-default bg-surface p-3"
|
||||
data-testid="review-formal-task-todo-panel"
|
||||
>
|
||||
@@ -3010,13 +2991,69 @@ watch(
|
||||
<div v-if="formalTaskDetailLoading" class="py-4 text-center text-xs text-muted">
|
||||
{{ t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<section
|
||||
v-else-if="formalResultIsCompleted"
|
||||
class="mb-3 rounded-xl border border-emerald-200 bg-emerald-50/60 p-3 dark:border-emerald-900 dark:bg-emerald-950/20"
|
||||
data-testid="review-formal-task-result-panel"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<h3 class="text-sm font-semibold text-emerald-900 dark:text-emerald-100">
|
||||
{{ t('chat.shippingOrderReview.workbench.resultTitle') }}
|
||||
</h3>
|
||||
<span class="rounded-full bg-emerald-600 px-2 py-0.5 text-[11px] font-medium text-white">
|
||||
{{ t('chat.shippingOrderReview.workbench.resultCompleted') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-3 grid gap-2 text-xs text-emerald-950 dark:text-emerald-50 sm:grid-cols-3">
|
||||
<div>
|
||||
<div class="text-emerald-700/80 dark:text-emerald-200/80">{{ t('chat.shippingOrderReview.workbench.resultLines') }}</div>
|
||||
<div class="mt-0.5 font-semibold">{{ formalResultLineResults.length }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-emerald-700/80 dark:text-emerald-200/80">{{ t('chat.shippingOrderReview.workbench.resultMatched') }}</div>
|
||||
<div class="mt-0.5 font-semibold">{{ formalResultMatchedCount }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-emerald-700/80 dark:text-emerald-200/80">{{ t('chat.shippingOrderReview.workbench.resultShortage') }}</div>
|
||||
<div class="mt-0.5 font-semibold">{{ formalResultShortageCount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="formalResultLineResults.length" class="mt-3 overflow-x-auto rounded-lg border border-emerald-200/80 bg-white/70 dark:border-emerald-900 dark:bg-slate-950/30">
|
||||
<table class="min-w-full text-xs">
|
||||
<thead class="border-b border-emerald-200/80 text-left dark:border-emerald-900">
|
||||
<tr>
|
||||
<th class="px-2 py-1.5 font-medium">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th>
|
||||
<th class="px-2 py-1.5 font-medium">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th>
|
||||
<th class="px-2 py-1.5 font-medium">{{ t('chat.shippingOrderReview.workbench.resultStatus') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="line in formalResultLineResults" :key="`${line.reservation_id || ''}-${line.part_number}`" class="border-b border-emerald-100 last:border-0 dark:border-emerald-950">
|
||||
<td class="px-2 py-1.5">{{ line.part_number || '-' }}</td>
|
||||
<td class="px-2 py-1.5">{{ line.reservation_id || '-' }}</td>
|
||||
<td class="px-2 py-1.5">{{ Number(line.shortage_qty || 0) > 0 ? t('chat.shippingOrderReview.workbench.resultShortage') : t('chat.shippingOrderReview.workbench.resultMatched') }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="mt-3 flex flex-wrap items-center justify-between gap-2 text-xs">
|
||||
<span>{{ t('chat.shippingOrderReview.workbench.resultArtifact', { file: formalResultArtifact?.file_name || formalTaskDetail.export_file_name || '-' }) }}</span>
|
||||
<button v-if="formalResultArtifact || formalTaskDetail.export_file_name" type="button" class="rounded-lg border border-emerald-300 bg-white px-2.5 py-1.5 font-medium text-emerald-800 hover:bg-emerald-100 dark:border-emerald-800 dark:bg-slate-900 dark:text-emerald-100" data-testid="review-formal-task-result-download" @click="() => void downloadWorkspaceShippingExcelFile(confirmedNoticeTaskNo)">
|
||||
{{ t('workspace.shippingNotice.todo.downloadExcel') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-if="formalResultCompletedAt" class="mt-2 text-[11px] text-emerald-700/80 dark:text-emerald-200/80">
|
||||
{{ t('chat.shippingOrderReview.workbench.resultCompletedAt', { time: formalResultCompletedAt }) }}
|
||||
</div>
|
||||
</section>
|
||||
<TaskTodoPanel
|
||||
v-else-if="formalTaskDetail"
|
||||
v-else
|
||||
ref="formalTodoPanelRef"
|
||||
:detail="formalTaskDetail"
|
||||
:gate-can-handle="false"
|
||||
:gate-can-handle="workbenchActionsExecutable"
|
||||
:actions-executable="workbenchActionsExecutable"
|
||||
:hide-primary-actions="true"
|
||||
:hide-gate-card="true"
|
||||
:expected-notice-task-no="confirmedNoticeTaskNo"
|
||||
:expected-order-task-no="authoritativeOrderTaskNo"
|
||||
:expected-review-case-no="activeCase?.case_no || null"
|
||||
@@ -3224,11 +3261,13 @@ watch(
|
||||
</div>
|
||||
<div
|
||||
v-if="showWorkbenchCaseShell"
|
||||
class="relative space-y-2"
|
||||
class="relative space-y-2 transition-opacity duration-150"
|
||||
:class="caseSwitchLoading ? 'pointer-events-none opacity-70' : ''"
|
||||
data-testid="review-case-workbench-shell"
|
||||
:data-case-switching="caseSwitchLoading ? '1' : '0'"
|
||||
:data-case-switch-failed="caseSwitchFailed ? '1' : '0'"
|
||||
:data-case-projection-version="caseProjectionVersion ?? ''"
|
||||
:aria-busy="caseSwitchLoading ? 'true' : 'false'"
|
||||
>
|
||||
<ReviewWorkbenchModeToggle
|
||||
v-if="workbenchMode === 'evidence' || workbenchMode === 'inventory'"
|
||||
@@ -3254,30 +3293,16 @@ watch(
|
||||
:automation="displayCase?.automation"
|
||||
:show-retry="showObjectRetryOnRail"
|
||||
:user-status="shippingProcessingProjection?.userStatus ?? displayCase?.user_status"
|
||||
:retryable="shippingProcessingProjection?.retryable ?? showObjectRetryOnRail"
|
||||
:retryable="displayCase?.process_gate?.current_blocking_gate ? false : (shippingProcessingProjection?.retryable ?? showObjectRetryOnRail)"
|
||||
:blocking-reason="shippingProcessingProjection?.blockingReason ?? displayCase?.blocking_reason"
|
||||
:primary-action="shippingProcessingProjection?.primaryAction ?? displayCase?.primary_action"
|
||||
:retrying="taskRetryButtonDisabled || progressRetrying || caseSwitchLoading"
|
||||
:primary-action="displayCase?.process_gate?.current_blocking_gate ? null : (shippingProcessingProjection?.primaryAction ?? displayCase?.primary_action)"
|
||||
:retrying="displayCase?.process_gate?.current_blocking_gate
|
||||
? (progressRetrying || caseSwitchLoading)
|
||||
: (taskRetryButtonDisabled || progressRetrying || caseSwitchLoading)"
|
||||
:retry-exhausted-sources="taskInventoryExhaustedSources"
|
||||
:loading="caseContentSkeleton"
|
||||
@retry="() => void (hasFormalOt ? retryFormalOtAutoProgress() : retryStpAutoCreate())"
|
||||
/>
|
||||
<ReviewInventoryIssueFallbackCard
|
||||
v-if="hasFormalOt && displayCase?.inventory_issue_fallback && !displayCase?.line_fulfillment?.has_line_inventory_projection"
|
||||
:fallback="displayCase.inventory_issue_fallback"
|
||||
:busy="Boolean(lineOpsBusyKey)"
|
||||
@retry-preparation="() => void retryCaseInventoryFallback()"
|
||||
/>
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!reparseProgressActive && showHumanBlockingGate && displayCase?.process_gate"
|
||||
:summary="displayCase.process_gate"
|
||||
:can-handle="false"
|
||||
:navigation-context="reviewGateNavigationContext"
|
||||
:field-labels="reviewFieldLabels"
|
||||
@refreshed="reloadLatestDraft"
|
||||
@refresh-needed="reloadLatestDraft"
|
||||
@confirm-customer="(taskNo) => void page.openShippingCustomerDialog?.(taskNo)"
|
||||
/>
|
||||
<ReviewCustomerResolutionPanel
|
||||
v-if="activeCase && !activeCase.customer_resolution?.resolved && showEligibilityAsPrimary"
|
||||
ref="customerResolutionPanelRef"
|
||||
@@ -3705,9 +3730,7 @@ watch(
|
||||
<ReviewLineInventoryOps
|
||||
:line="lineFulfillmentFor(String(line.line_key || ''))"
|
||||
:editable="editable"
|
||||
:busy="lineOpsBusyKey === String(line.line_key || '') || saving"
|
||||
:task-running="taskAutomationRunning"
|
||||
@retry-line="() => void retryLineUnified(String(line.line_key || ''))"
|
||||
:busy="saving"
|
||||
@close-line="openCloseFulfillmentDialog([String(line.line_key || '')])"
|
||||
/>
|
||||
</div>
|
||||
@@ -3813,16 +3836,35 @@ watch(
|
||||
:has-formal-ot="shippingProcessingProjection?.hasFormalOt ?? hasFormalOt"
|
||||
:shipping-notice-no="shippingProcessingProjection?.shippingNoticeNo ?? confirmedNoticeTaskNo"
|
||||
:user-status="shippingProcessingProjection?.userStatus ?? displayCase?.user_status"
|
||||
:retryable="shippingProcessingProjection?.retryable ?? showObjectRetryOnRail"
|
||||
:retryable="displayCase?.process_gate?.current_blocking_gate ? false : (shippingProcessingProjection?.retryable ?? showObjectRetryOnRail)"
|
||||
:blocking-reason="shippingProcessingProjection?.blockingReason ?? displayCase?.blocking_reason"
|
||||
:primary-action="shippingProcessingProjection?.primaryAction ?? displayCase?.primary_action"
|
||||
:retrying="taskRetryButtonDisabled || progressRetrying || caseSwitchLoading"
|
||||
:primary-action="displayCase?.process_gate?.current_blocking_gate ? null : (shippingProcessingProjection?.primaryAction ?? displayCase?.primary_action)"
|
||||
:retrying="displayCase?.process_gate?.current_blocking_gate
|
||||
? (progressRetrying || caseSwitchLoading)
|
||||
: (taskRetryButtonDisabled || progressRetrying || caseSwitchLoading)"
|
||||
:retry-exhausted-sources="taskInventoryExhaustedSources"
|
||||
:loading="caseContentSkeleton"
|
||||
@retry="() => void (hasFormalOt ? retryFormalOtAutoProgress() : retryStpAutoCreate())"
|
||||
@locate="(lineKey, fieldId) => handleCurrentTaskLocate(lineKey, fieldId)"
|
||||
@action="(code, params) => void handleCurrentTaskAction(code, params)"
|
||||
/>
|
||||
<ReviewInventoryIssueFallbackCard
|
||||
v-if="hasFormalOt && displayCase?.inventory_issue_fallback && !displayCase?.line_fulfillment?.has_line_inventory_projection"
|
||||
:fallback="displayCase.inventory_issue_fallback"
|
||||
:busy="false"
|
||||
@retry-preparation="() => void retryCaseInventoryFallback()"
|
||||
/>
|
||||
<ProcessGateRecoveryCard
|
||||
v-if="!reparseProgressActive && showHumanBlockingGate && displayCase?.process_gate && hasCreatedShippingTask"
|
||||
:summary="displayCase.process_gate"
|
||||
:can-handle="workbenchActionsExecutable"
|
||||
:navigation-context="reviewGateNavigationContext"
|
||||
:field-labels="reviewFieldLabels"
|
||||
@refreshed="reloadLatestDraft"
|
||||
@refresh-needed="reloadLatestDraft"
|
||||
@confirm-customer="(taskNo) => void page.openShippingCustomerDialog?.(taskNo)"
|
||||
@manual-upload="() => void openManualUploadRegistration()"
|
||||
/>
|
||||
<ReviewProfileMatchPanel
|
||||
:profile-match="displayCase?.profile_match"
|
||||
/>
|
||||
@@ -3948,6 +3990,20 @@ watch(
|
||||
@open-audit="() => { processDetailOpen = false; auditTrailOpen = true; }"
|
||||
/>
|
||||
|
||||
<ManualUploadEvidenceDialog
|
||||
v-model:open="manualUploadRegistrationOpen"
|
||||
:task-no="confirmedNoticeTaskNo"
|
||||
:artifact-id="formalTaskDetail?.export_artifacts?.[0]?.id || null"
|
||||
:disabled="!workbenchActionsExecutable"
|
||||
@success="() => { void handleManualUploadSuccess(); }"
|
||||
/>
|
||||
|
||||
<ReviewConversationRetryDrawer
|
||||
:open="conversationRetryDrawerOpen"
|
||||
:result="conversationRetryResult"
|
||||
@close="conversationRetryDrawerOpen = false"
|
||||
/>
|
||||
|
||||
<ReviewUnsavedSwitchDialog
|
||||
:open="unsavedSwitchOpen"
|
||||
:unsaved-count="unsavedEditCount"
|
||||
@@ -3958,52 +4014,26 @@ watch(
|
||||
/>
|
||||
|
||||
<div
|
||||
v-if="conversationRetryResultOpen && conversationRetryResult"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-slate-900/40 p-4"
|
||||
data-testid="review-conversation-retry-result"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
v-if="conversationRetryToastOpen"
|
||||
class="fixed right-4 top-16 z-50 max-w-xs rounded-full border border-slate-200 bg-white px-3 py-1.5 text-[11px] shadow-md dark:border-slate-700 dark:bg-slate-900"
|
||||
data-testid="review-conversation-retry-toast"
|
||||
role="status"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-xl border border-slate-200 bg-white p-4 shadow-xl dark:border-slate-700 dark:bg-slate-900">
|
||||
<h2 class="text-sm font-semibold text-slate-900 dark:text-slate-100">
|
||||
{{ t('chat.shippingOrderReview.conversationRetry.title') }}
|
||||
</h2>
|
||||
<dl class="mt-3 space-y-1 text-xs text-slate-700 dark:text-slate-200">
|
||||
<div class="flex justify-between gap-3">
|
||||
<dt>{{ t('chat.shippingOrderReview.conversationRetry.retried') }}</dt>
|
||||
<dd data-testid="review-conversation-retry-retried">{{ conversationRetryResult.summary.retried }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-3">
|
||||
<dt>{{ t('chat.shippingOrderReview.conversationRetry.skipped') }}</dt>
|
||||
<dd data-testid="review-conversation-retry-skipped">{{ conversationRetryResult.summary.skipped }}</dd>
|
||||
</div>
|
||||
<div class="flex justify-between gap-3">
|
||||
<dt>{{ t('chat.shippingOrderReview.conversationRetry.failed') }}</dt>
|
||||
<dd data-testid="review-conversation-retry-failed">{{ conversationRetryResult.summary.failed }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<ul
|
||||
v-if="conversationRetryResult.items.some((item) => item.outcome === 'skipped')"
|
||||
class="mt-3 max-h-40 space-y-1 overflow-y-auto text-xs text-slate-600 dark:text-slate-300"
|
||||
data-testid="review-conversation-retry-skip-list"
|
||||
>
|
||||
<li
|
||||
v-for="item in conversationRetryResult.items.filter((row) => row.outcome === 'skipped')"
|
||||
:key="`${item.object_type}:${item.object_ref}`"
|
||||
>
|
||||
{{ item.object_ref }}:{{ conversationRetrySkipReasonLabel(item.reason_code) || t('chat.shippingOrderReview.conversationRetry.skipped') }}
|
||||
</li>
|
||||
</ul>
|
||||
<div class="mt-4 flex justify-end">
|
||||
<div class="flex items-center gap-2">
|
||||
<RefreshCw class="h-3.5 w-3.5 shrink-0 text-amber-600" />
|
||||
<p v-if="conversationRetryError" class="text-rose-700 dark:text-rose-300">{{ conversationRetryError }}</p>
|
||||
<p v-else class="text-slate-700 dark:text-slate-200">
|
||||
{{ conversationRetryError || t('chat.shippingOrderReview.conversationRetry.toast', { retried: conversationRetryResult?.summary.retried || 0 }) }}
|
||||
<button
|
||||
v-if="hasConversationRetryAttention"
|
||||
type="button"
|
||||
class="rounded bg-sky-600 px-3 py-1.5 text-xs font-medium text-white hover:bg-sky-500"
|
||||
data-testid="review-conversation-retry-close-refresh"
|
||||
@click="() => void closeConversationRetryResult()"
|
||||
class="ml-2 font-medium text-sky-700 hover:underline dark:text-sky-300"
|
||||
data-testid="review-conversation-retry-toast-open"
|
||||
@click="conversationRetryDrawerOpen = true"
|
||||
>
|
||||
{{ t('chat.shippingOrderReview.conversationRetry.closeAndRefresh') }}
|
||||
{{ t('chat.shippingOrderReview.conversationRetry.viewResult') }}
|
||||
</button>
|
||||
</div>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in new issue
Block a user