Merge branch 'hugo-shipping-notice' into dev
# Conflicts: # frontend/src/features/chat/components/ChatViewContent.vue
This commit is contained in:
commit
80d78130f8
121 files changed
+9621
-1263
No files matched your search
@@ -166,6 +166,16 @@ export const getWorkspaceShippingFreightNoticeGroups = (taskNo: string) =>
|
||||
{ priority: 'low' },
|
||||
);
|
||||
|
||||
/** 整单 ODM 裁决:保存行级选择(同快照文件行后端同步),随后可重试生成 Excel。 */
|
||||
export const setWorkspaceShippingTaskOdmChoice = (
|
||||
taskNo: string,
|
||||
payload: { snapshot_line_id: string | number; odm_id: string },
|
||||
) =>
|
||||
requestJson<{ task_id: number; odm_id: string; synced_line_count: number; odm_values: string[] }>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/odm-choice`,
|
||||
jsonPost(payload),
|
||||
);
|
||||
|
||||
/**
|
||||
* 分页拉取任务工作台统一审计时间线(ShippingAuditEvent 单源)。
|
||||
*/
|
||||
|
||||
@@ -54,7 +54,6 @@ const {
|
||||
pinMessagesToBottom?: boolean;
|
||||
/** 供父级滚动逻辑绑定 main 元素 */
|
||||
scrollContainerHolder: { el: Ref<HTMLElement | null> };
|
||||
compactShippingProgress?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
@@ -68,7 +67,6 @@ const emit = defineEmits<{
|
||||
'maintenance-edit-record': [record: MaintenanceRecord];
|
||||
'maintenance-view-record-history': [device: MaintenanceDevice];
|
||||
'maintenance-create-record-for-device': [device: MaintenanceDevice];
|
||||
'open-batch-workbench': [];
|
||||
/** 在途仓自动调拨:业务流激活时向上冒泡,父级据此隐藏聊天输入框。 */
|
||||
'transfer-flow-active': [active: boolean];
|
||||
}>();
|
||||
@@ -207,7 +205,6 @@ const hasFollowingShippingProgressCard = (items: ChatMessage[], index: number):
|
||||
:leave-handlers="leaveHandlers"
|
||||
:shipping-handlers="shippingHandlers"
|
||||
:training-handlers="trainingHandlers"
|
||||
:compact-shipping-progress="compactShippingProgress"
|
||||
:attachment-summary-only="hasFollowingShippingProgressCard(messages, index)"
|
||||
@copy="emit('copy', { message: msg, index })"
|
||||
@edit="emit('edit', $event)"
|
||||
@@ -217,7 +214,6 @@ const hasFollowingShippingProgressCard = (items: ChatMessage[], index: number):
|
||||
@maintenance-edit-record="emit('maintenance-edit-record', $event)"
|
||||
@maintenance-view-record-history="emit('maintenance-view-record-history', $event)"
|
||||
@maintenance-create-record-for-device="emit('maintenance-create-record-for-device', $event)"
|
||||
@open-batch-workbench="emit('open-batch-workbench')"
|
||||
/>
|
||||
<ToolRunProgressCard
|
||||
v-if="shouldRenderMessage(msg) && shouldShowToolRunProgressAfterMessage(msg, index)"
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
* 逻辑:本文件只做页面结构编排;货代 Chat 仅上传/进度通知,履约写操作不在本页;
|
||||
* 右侧「本次处理」由 conversationId 驱动 Workflow projection,extractionRunNo 仅作进度装饰;
|
||||
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、立账凭证 Agent 用 Tab 作业面替换消息列表与输入框。
|
||||
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、立账凭证 Agent 用 Tab 作业面替换消息列表与输入框;
|
||||
* 货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框,会话标题取自侧栏历史并传给中心。
|
||||
|
||||
*/
|
||||
|
||||
@@ -34,6 +35,8 @@ import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
|
||||
|
||||
import ShippingWorkflowTimeline from '@/features/chat/components/shipping/ShippingWorkflowTimeline.vue';
|
||||
|
||||
import { shouldShowShippingWorkbench } from '@/features/chat/shipping/shippingWorkbenchLayout';
|
||||
|
||||
import TrainingWorkspacePanel from '@/features/chat/components/TrainingWorkspacePanel.vue';
|
||||
|
||||
import LedgerConfigPanel from '@/features/maintenance/components/LedgerConfigPanel.vue';
|
||||
@@ -135,38 +138,19 @@ const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value ||
|
||||
const transferFlowActive = ref(false);
|
||||
watch(isInTransitTransferAgent, (isTransfer) => { if (!isTransfer) transferFlowActive.value = false; });
|
||||
|
||||
/** 批次进度工作台按需打开;关闭时不占用对话区右侧布局。 */
|
||||
const batchWorkbenchOpen = ref(false);
|
||||
|
||||
|
||||
|
||||
const showShippingWorkflowTimeline = computed(() => (
|
||||
page.isShippingNoticeAgent
|
||||
&& batchWorkbenchOpen.value
|
||||
&& Boolean(activeShippingConversationId.value)
|
||||
));
|
||||
|
||||
const compactShippingProgress = computed(() => batchWorkbenchOpen.value);
|
||||
|
||||
function openBatchWorkbench() {
|
||||
batchWorkbenchOpen.value = true;
|
||||
}
|
||||
|
||||
function closeBatchWorkbench() {
|
||||
batchWorkbenchOpen.value = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批次中心只服务于用户主动打开时所在的会话。切换历史会话或 Agent 后必须关闭,
|
||||
* 否则旧会话的右侧投影会短暂占用新会话的对话区并造成“本次处理”串批错觉。
|
||||
* 货代发货会话主区域规则(方案 A):
|
||||
* 有会话 ID → 全屏批次进度中心(常驻不可关闭);无会话 → 欢迎页 + 输入框(唯一提交入口)。
|
||||
*/
|
||||
watch(
|
||||
() => [activeShippingConversationId.value, Number(page.currentAgentId || 0)] as const,
|
||||
(next, previous) => {
|
||||
if (!previous || next[0] === previous[0] && next[1] === previous[1]) return;
|
||||
batchWorkbenchOpen.value = false;
|
||||
},
|
||||
);
|
||||
const showShippingWorkflowTimeline = computed(() => shouldShowShippingWorkbench({
|
||||
isShippingNoticeAgent: page.isShippingNoticeAgent,
|
||||
conversationId: activeShippingConversationId.value,
|
||||
}));
|
||||
|
||||
/** 侧栏历史项中的会话标题;批次中心头部直接复用,保持侧栏与中心一致。 */
|
||||
const activeShippingConversationTitle = computed(() => (
|
||||
page.displayHistory.find((item) => item.conversation_id === activeShippingConversationId.value)?.title || ''
|
||||
));
|
||||
|
||||
const embeddedIframeSrc = computed(() => {
|
||||
|
||||
@@ -498,9 +482,10 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
<VoucherCheckChatPanel v-else-if="isVoucherCheckAgentPage" />
|
||||
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1" :class="showShippingWorkflowTimeline ? 'shipping-workbench-layout' : ''">
|
||||
<div v-else class="flex min-h-0 min-w-0 flex-1">
|
||||
|
||||
<div class="flex min-h-0 min-w-0 flex-1 flex-col" :class="showShippingWorkflowTimeline ? 'shipping-chat-column' : ''">
|
||||
<!-- 中心展示时对话列整体隐藏(含输入框),新文件提交走新建对话(spec 方案 A 硬性决策)。 -->
|
||||
<div v-show="!showShippingWorkflowTimeline" class="flex min-h-0 min-w-0 flex-1 flex-col">
|
||||
|
||||
<TrainingWorkspacePanel
|
||||
|
||||
@@ -580,8 +565,6 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
:scroll-container-holder="page.scrollContainerHolder"
|
||||
|
||||
:compact-shipping-progress="compactShippingProgress"
|
||||
|
||||
@copy="page.copyToClipboard($event.message, $event.index)"
|
||||
|
||||
@edit="page.input = $event"
|
||||
@@ -602,8 +585,6 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
@maintenance-create-record-for-device="openMaintenanceRecordCreate"
|
||||
|
||||
@open-batch-workbench="openBatchWorkbench"
|
||||
|
||||
@transfer-flow-active="transferFlowActive = $event"
|
||||
|
||||
/>
|
||||
@@ -692,10 +673,9 @@ watch(() => page.currentAgentId, () => {
|
||||
<ShippingWorkflowTimeline
|
||||
v-if="showShippingWorkflowTimeline"
|
||||
:conversation-id="activeShippingConversationId"
|
||||
:conversation-title="activeShippingConversationTitle"
|
||||
:refresh-trigger="page.workflowRefreshTrigger"
|
||||
:controller="shippingProcessing"
|
||||
|
||||
@close="closeBatchWorkbench"
|
||||
/>
|
||||
|
||||
|
||||
@@ -846,16 +826,3 @@ watch(() => page.currentAgentId, () => {
|
||||
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/** 打开批次工作台后,左侧对话保留为压缩入口,右侧取得主工作区宽度。 */
|
||||
@media (min-width: 1024px) {
|
||||
.shipping-workbench-layout {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.shipping-chat-column {
|
||||
flex: 0 0 clamp(360px, 32vw, 520px);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -75,7 +75,6 @@ const {
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMessageHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
compactShippingProgress?: boolean;
|
||||
/** 下方已有货代进度卡时,用户气泡附件只显示摘要。 */
|
||||
attachmentSummaryOnly?: boolean;
|
||||
}>();
|
||||
@@ -89,7 +88,6 @@ const emit = defineEmits<{
|
||||
'maintenance-edit-record': [record: MaintenanceRecord];
|
||||
'maintenance-view-record-history': [device: MaintenanceDevice];
|
||||
'maintenance-create-record-for-device': [device: MaintenanceDevice];
|
||||
'open-batch-workbench': [];
|
||||
}>();
|
||||
|
||||
const authStore = useAuthStore();
|
||||
@@ -747,11 +745,9 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
:retrying="retryingOrderExtraction"
|
||||
:refreshing="refreshingOrderExtraction"
|
||||
:cancelling="cancellingOrderExtraction"
|
||||
:compact-progress="compactShippingProgress"
|
||||
@retry="retryShippingOrderExtraction"
|
||||
@refresh="refreshShippingOrderExtraction"
|
||||
@cancel="cancelShippingOrderExtraction"
|
||||
@open-batch-workbench="emit('open-batch-workbench')"
|
||||
/>
|
||||
<LeaveMessageBlock
|
||||
v-if="isLeaveMessage"
|
||||
|
||||
+54
@@ -22,6 +22,7 @@ const i18n = createI18n({
|
||||
actionCodes: {
|
||||
reload_inventory_result: '重新读取库存结果',
|
||||
retry_inventory_preparation: '重新获取库存',
|
||||
confirm_customer: '确认客户',
|
||||
},
|
||||
inventoryActions: {
|
||||
reloadInventoryResult: '重新读取库存结果',
|
||||
@@ -337,4 +338,57 @@ describe('ReviewCurrentProcessingCard', () => {
|
||||
// 关键断言:无 statusDetail 时说明行完全不渲染,不留空壳。
|
||||
expect(wrapper.find('[data-testid="review-current-task-status-detail"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders the suggested next action instead of the reason text when next_action is present', () => {
|
||||
// v4 语义分离:「下一步」给建议动作(确认客户),原因文案(客户尚未确认)
|
||||
// 属于阻塞原因位,不得再挤进下一步槽位。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
nextAction: 'confirm_customer',
|
||||
} as any,
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-next-step-text"]').text()).toBe('确认客户');
|
||||
});
|
||||
|
||||
it('hides the generic run-level status detail when a specific blocking reason is shown', () => {
|
||||
// v4 去重:具体阻断原因已由「下一步」承载时,泛化的「当前步骤需要人工处理」属纯重复。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
nextAction: 'confirm_customer',
|
||||
} as any,
|
||||
statusDetail: { text: '当前步骤需要人工处理' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="review-current-task-status-detail"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the run-level status detail when the blocking reason is generic', () => {
|
||||
// 无具体原因(未知码、无契约文案)时,Run 级等待说明仍是唯一信息,必须保留。
|
||||
const wrapper = mount(ReviewCurrentProcessingCard, {
|
||||
props: {
|
||||
stageCode: 'order_review',
|
||||
userStatus: 'waiting_human',
|
||||
blockingReason: { code: 'internal_gate_reason' } as any,
|
||||
statusDetail: { text: '当前步骤需要人工处理' },
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="review-current-task-status-detail"]').text()).toBe('当前步骤需要人工处理');
|
||||
});
|
||||
});
|
||||
+27
-6
@@ -10,7 +10,9 @@
|
||||
禁止把读取占位误述为「系统处理中」,也不做骨架→真值的二次刷新;
|
||||
loading 仅在挂载期抑制可执行动作,等权威投影到达后再放行(fail-closed);
|
||||
由 ShippingOrderReviewView 在 mountCurrentProcessingCard 时挂载;
|
||||
v2 新增 statusDetail:状态块内嵌动态说明(隐藏裁决在视图侧,见 spec §5.2)。
|
||||
v2 新增 statusDetail:状态块内嵌动态说明(隐藏裁决在视图侧,见 spec §5.2);
|
||||
v4 语义分离:下一步优先消费 blocking_reason.next_action 的建议动作文案,
|
||||
且具体阻断原因在场时隐藏泛化 statusDetail(防同卡三行「待人工」空话)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
@@ -20,7 +22,10 @@ import type {
|
||||
ShippingProcessingBlockingReason,
|
||||
ShippingProcessingPrimaryAction,
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
import { resolveShippingProcessingStageLabel } from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import {
|
||||
isGenericBlockingReason,
|
||||
resolveShippingProcessingStageLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
|
||||
import { lookupWorkbenchAction, shouldRenderWorkbenchAction } from '@/features/shipping-progress/workbenchActionRegistry';
|
||||
import { inventoryActionLabelKey, isInternalInventoryAction } from '@/features/shipping-progress/actionPresentation';
|
||||
@@ -147,9 +152,15 @@ const nextStepText = computed(() => {
|
||||
// 其余按 user_status/blocking_reason 照常渲染,空态自然落在「状态待确认」,不做骨架二次刷新。
|
||||
const automationMessage = props.loading ? safeMessage(props.automation?.message) : '';
|
||||
if (automationMessage) return automationMessage;
|
||||
// 1) blocking_reason → 用后端给的 i18n_key 渲染具体阻断
|
||||
// 1) blocking_reason → 先给契约注册的「建议动作」(下一步=做什么),
|
||||
// 再回退原因文案(i18n_key / Gate 命名空间);禁止裸露内部原因码。
|
||||
const br = props.blockingReason;
|
||||
if (br) {
|
||||
const nextAction = String(br.nextAction || br.next_action || '').trim();
|
||||
const actionKey = nextAction
|
||||
? `workspace.shippingNotice.processGate.actionCodes.${nextAction}`
|
||||
: '';
|
||||
if (actionKey && te(actionKey)) return t(actionKey);
|
||||
const i18nKey = String(br.i18nKey || '').trim();
|
||||
if (i18nKey && te(i18nKey)) {
|
||||
return t(i18nKey);
|
||||
@@ -205,6 +216,15 @@ const showNextStep = computed(() => {
|
||||
return !['completed', 'cancelled'].includes(status);
|
||||
});
|
||||
|
||||
/**
|
||||
* 状态块内嵌动态说明的显隐:具体阻断原因已由「下一步」承载时,
|
||||
* Run 级泛化等待说明(如「当前步骤需要人工处理」)属纯重复,隐藏。
|
||||
*/
|
||||
const showStatusDetail = computed(() => {
|
||||
if (!props.statusDetail?.text) return false;
|
||||
return isGenericBlockingReason(props.blockingReason, te);
|
||||
});
|
||||
|
||||
/**
|
||||
* 判断当前工作台是否应隐藏后端下发的纯导航动作。
|
||||
* 批次中心可用它打开工作台;进入工作台后必须复用注册表规则,避免当前阶段再次显示
|
||||
@@ -382,13 +402,14 @@ type ReviewCurrentUserStatus =
|
||||
/>
|
||||
{{ statusLabel }}
|
||||
</dd>
|
||||
<!-- v2:状态块内嵌动态说明(弱文本一行,不加标题/图标/区块;显隐裁决在视图侧)。 -->
|
||||
<!-- v2:状态块内嵌动态说明(弱文本一行,不加标题/图标/区块;
|
||||
v4:blocking_reason 已含具体原因时隐藏,避免与「下一步」重复)。 -->
|
||||
<p
|
||||
v-if="statusDetail?.text"
|
||||
v-if="showStatusDetail"
|
||||
class="w-full text-[11px] leading-4 text-muted"
|
||||
data-testid="review-current-task-status-detail"
|
||||
aria-live="polite"
|
||||
>{{ statusDetail.text }}</p>
|
||||
>{{ statusDetail?.text }}</p>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
|
||||
+61
@@ -173,3 +173,64 @@ describe('ReviewDocumentNavigation', () => {
|
||||
narrow.unmount();
|
||||
});
|
||||
});
|
||||
|
||||
describe('ReviewDocumentNavigation queue row status icons', () => {
|
||||
/**
|
||||
* 以指定字段挂载单行侧栏队列,返回该行按钮包装器。
|
||||
*/
|
||||
function mountRow(item: Partial<ReviewDocumentNavItem>) {
|
||||
return mount(ReviewDocumentNavigation, {
|
||||
props: {
|
||||
items: [{ case_no: 'C-1', file_name: 'f1.pdf', status: 'draft', ...item }],
|
||||
activeCaseNo: 'C-1',
|
||||
navAriaLabel: 'nav',
|
||||
forceMode: 'sidebar',
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
}).get('[data-testid="review-doc-nav-C-1"]');
|
||||
}
|
||||
|
||||
it('renders confirmed cases as in-progress spinner instead of done check', () => {
|
||||
const row = mountRow({ status: 'confirmed' });
|
||||
// 关键断言:已创建任务是系统在办中间态,必须转圈而非绿勾。
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(true);
|
||||
expect(row.find('svg.text-emerald-500').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders ready-to-confirm cases as amber attention icon', () => {
|
||||
const row = mountRow({ status: 'ready' });
|
||||
// 关键断言:可确认是等人操作,属于待办而非完成。
|
||||
expect(row.find('svg.text-amber-500').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('renders backend gate-blocked cases as amber attention icon', () => {
|
||||
const row = mountRow({ status: 'confirmed', needs_attention: true });
|
||||
// 关键断言:needs_attention 是后端门禁裁决,优先于中间态转圈。
|
||||
expect(row.find('svg.text-amber-500').exists()).toBe(true);
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('reserves the green check for terminal upload_complete', () => {
|
||||
const row = mountRow({ status: 'confirmed', lifecycle_stage: 'upload_complete' });
|
||||
expect(row.find('svg.text-emerald-500').exists()).toBe(true);
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('renders failed and neutral states as before', () => {
|
||||
expect(mountRow({ status: 'failed' }).find('svg.text-rose-500').exists()).toBe(true);
|
||||
const idle = mountRow({ status: 'non_order' });
|
||||
expect(idle.find('svg.text-muted').exists()).toBe(true);
|
||||
expect(idle.find('svg.animate-spin').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the truthful state icon on the selected row', () => {
|
||||
const row = mountRow({ status: 'draft' });
|
||||
// 关键断言:选中态由行高亮表达,图标不再被 active 覆盖成灰圈。
|
||||
expect(row.find('svg.text-amber-500').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('treats missing needs_attention as false for old queue payloads', () => {
|
||||
const row = mountRow({ status: 'confirmed', needs_attention: undefined });
|
||||
expect(row.find('svg.animate-spin').exists()).toBe(true);
|
||||
});
|
||||
});
|
||||
+25
-10
@@ -11,6 +11,7 @@ import {
|
||||
ChevronLeft,
|
||||
ChevronRight,
|
||||
Circle,
|
||||
LoaderCircle,
|
||||
Search,
|
||||
TriangleAlert,
|
||||
X,
|
||||
@@ -23,10 +24,12 @@ export type ReviewDocumentNavItem = {
|
||||
file_name?: string | null;
|
||||
status: string;
|
||||
issue_count?: number;
|
||||
/** 队列接口按当前门禁裁决的"需人工"标志(blocked_manual/blocked_retryable/failed_terminal);前端禁止自行推断阻塞。 */
|
||||
needs_attention?: boolean | null;
|
||||
po_number?: string | null;
|
||||
customer_name?: string | null;
|
||||
stage_label?: string | null;
|
||||
/** 队列接口下发的生命周期码;仅用于本地化展示,不参与阶段裁决。 */
|
||||
/** 队列接口下发的生命周期码;用于阶段文字展示与终态(upload_complete)绿勾判定,不参与阶段裁决。 */
|
||||
lifecycle_stage?: ReviewLifecycleStageCode | null;
|
||||
};
|
||||
|
||||
@@ -118,17 +121,20 @@ function lifecycleStageLabel(item: ReviewDocumentNavItem): string | null {
|
||||
}
|
||||
|
||||
/**
|
||||
* 导航状态图标语义。
|
||||
* 队列状态图标语义,按优先级命中即停:
|
||||
* 失败 → 需人工(草稿问题数 / needs_attention 门禁阻塞)→ 终态绿勾
|
||||
* → 等人状态 ⚠ → 系统在办转圈 → 中性灰圈 → 兜底转圈。
|
||||
* 绿勾只属于终态(upload_complete / closed / completed);选中态由行高亮表达,
|
||||
* 本函数不感知选中,图标永远如实反映状态。
|
||||
*/
|
||||
function navIconKind(item: ReviewDocumentNavItem): 'active' | 'alert' | 'processing' | 'done' | 'failed' | 'idle' {
|
||||
if (props.activeCaseNo === item.case_no) return 'active';
|
||||
function navIconKind(item: ReviewDocumentNavItem): 'alert' | 'done' | 'failed' | 'processing' | 'idle' {
|
||||
const status = String(item.status || '').toLowerCase();
|
||||
if (item.issue_count && item.issue_count > 0) return 'alert';
|
||||
if (status === 'failed' || status === 'error') return 'failed';
|
||||
if (status === 'confirmed' || status === 'completed' || status === 'ready' || status === 'closed') return 'done';
|
||||
if (status === 'processing' || status === 'reparse_pending' || status === 'queued') return 'processing';
|
||||
if (status === 'non_order' || status === 'cancelled' || status === 'superseded') return 'idle';
|
||||
if (status === 'draft' || status === 'pending_review' || status === 'waiting_review') return 'alert';
|
||||
if ((item.issue_count && item.issue_count > 0) || item.needs_attention === true) return 'alert';
|
||||
if (item.lifecycle_stage === 'upload_complete' || status === 'completed' || status === 'closed') return 'done';
|
||||
if (['draft', 'ready', 'unreviewed', 'quality_issue', 'pending_review', 'waiting_review'].includes(status)) return 'alert';
|
||||
if (['confirmed', 'confirming', 'processing', 'reparse_pending', 'queued'].includes(status)) return 'processing';
|
||||
if (['non_order', 'cancelled', 'superseded'].includes(status)) return 'idle';
|
||||
return 'processing';
|
||||
}
|
||||
|
||||
@@ -139,7 +145,7 @@ function matchesStatusFilter(item: ReviewDocumentNavItem): boolean {
|
||||
if (statusFilter.value === 'all') return true;
|
||||
const kind = navIconKind(item);
|
||||
if (statusFilter.value === 'needs_action') return kind === 'alert';
|
||||
if (statusFilter.value === 'processing') return kind === 'processing' || kind === 'active';
|
||||
if (statusFilter.value === 'processing') return kind === 'processing';
|
||||
if (statusFilter.value === 'done') return kind === 'done';
|
||||
if (statusFilter.value === 'failed') return kind === 'failed';
|
||||
return true;
|
||||
@@ -218,6 +224,11 @@ function onSelect(caseNo: string) {
|
||||
class="h-3.5 w-3.5 shrink-0 text-rose-500"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<LoaderCircle
|
||||
v-else-if="navIconKind(item) === 'processing'"
|
||||
class="h-3.5 w-3.5 shrink-0 animate-spin text-brand-600"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Circle
|
||||
v-else
|
||||
class="h-3 w-3 shrink-0 text-muted"
|
||||
@@ -329,6 +340,10 @@ function onSelect(caseNo: string) {
|
||||
v-else-if="navIconKind(item) === 'failed'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 text-rose-500"
|
||||
/>
|
||||
<LoaderCircle
|
||||
v-else-if="navIconKind(item) === 'processing'"
|
||||
class="mt-0.5 h-3.5 w-3.5 shrink-0 animate-spin text-brand-600"
|
||||
/>
|
||||
<Circle
|
||||
v-else
|
||||
class="mt-0.5 h-3 w-3 shrink-0 text-muted"
|
||||
|
||||
+82
@@ -1184,4 +1184,86 @@ describe('ShippingConversationProcessingCard', () => {
|
||||
const row = wrapper.find('[data-testid="shipping-processing-file-DOC-10"]');
|
||||
expect(row.findAll('button')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('shows a specific blocking reason once per waiting-human card without header duplication', async () => {
|
||||
// v4 去重:具体原因由文件行页脚独家承载;任务卡头不再重复同一句。
|
||||
// ui_state 挂在任务条目上(与后端 EML 聚合下发形态一致:任务级为代表子项原因)。
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'waiting_human', [{
|
||||
user_task_no: 'OT-REASON-ONCE', group: 'waiting_human', status_label: 'pending_review',
|
||||
file_count: 1, run_no: 'RUN-REASON-ONCE', can_append: false,
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'customer_unresolved', message: '客户尚未确认' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-REASON', label: 'reason.pdf', filename: 'reason.pdf',
|
||||
document_id: 91, root_document_id: 91, status_label: 'pending_review',
|
||||
}],
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-REASON-ONCE', {
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'reason.pdf', documentId: 91,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-REASON',
|
||||
},
|
||||
status: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'customer_unresolved', message: '客户尚未确认' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
// 关键断言:具体原因全文只出现一次,且带「阻塞原因:」前缀落在文件行页脚。
|
||||
const matches = wrapper.text().match(/客户尚未确认/g) || [];
|
||||
expect(matches.length).toBe(1);
|
||||
expect(wrapper.text()).toContain('阻塞原因:客户尚未确认');
|
||||
});
|
||||
|
||||
it('hides the blocker line when the backend only provides a generic fallback reason', async () => {
|
||||
// v4:未知原因码不得渲染成「当前步骤需要人工处理」空话;状态芯片已表达待人工。
|
||||
const projection = buildProjection();
|
||||
setStatusGroup(projection, 'waiting_human', [{
|
||||
user_task_no: 'OT-REASON-GENERIC', group: 'waiting_human', status_label: 'pending_review',
|
||||
file_count: 1, run_no: 'RUN-REASON-GENERIC', can_append: false,
|
||||
objects: [{
|
||||
kind: 'document', object_key: 'DOC-GENERIC', label: 'generic.pdf', filename: 'generic.pdf',
|
||||
document_id: 92, root_document_id: 92, status_label: 'pending_review',
|
||||
}],
|
||||
}]);
|
||||
const workItem = buildWorkItem('OT-REASON-GENERIC', {
|
||||
sourceSummary: {
|
||||
emailSubject: null, filename: 'generic.pdf', documentId: 92,
|
||||
documentCount: 1, parsedDocumentCount: 1, candidateCount: 1,
|
||||
customerName: null, poNumber: 'PO-GENERIC',
|
||||
},
|
||||
status: 'waiting_human',
|
||||
uiState: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: { code: 'mystery_internal_code' },
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
});
|
||||
const wrapper = mount(ShippingConversationProcessingCard, {
|
||||
props: { projection, workItems: [workItem], workbenchMode: true },
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.text()).not.toContain('阻塞原因');
|
||||
expect(wrapper.text()).not.toContain('当前步骤需要人工处理');
|
||||
});
|
||||
});
|
||||
+16
-7
@@ -30,8 +30,8 @@ import {
|
||||
toggleTaskDetails,
|
||||
} from '@/features/chat/shipping/conversationProcessingState';
|
||||
import {
|
||||
resolveBlockingReasonText,
|
||||
resolveShippingProcessingMessage,
|
||||
resolveShippingProcessingReasonLabel,
|
||||
resolveShippingProcessingStageLabel,
|
||||
resolveShippingProcessingStatusLabel,
|
||||
} from '@/features/chat/shipping/shippingProcessingLabels';
|
||||
@@ -593,7 +593,8 @@ function workbenchFileReason(file: WorkbenchFileRow, task: ConversationProcessin
|
||||
const reason = file.projection.uiState
|
||||
? file.projection.uiState.blocking_reason
|
||||
: file.projection.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
// v4:具体原因才展示(Gate 命名空间/契约 message 可解析),通用兜底返回空串隐藏。
|
||||
return resolveBlockingReasonText(reason, te, t);
|
||||
}
|
||||
return taskReasonLabel(task);
|
||||
}
|
||||
@@ -686,12 +687,20 @@ function stageLabel(task: ConversationProcessingUserTask): string {
|
||||
return intakeStageLabel(projection);
|
||||
}
|
||||
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;i18n 仅负责翻译,不映射或猜测业务原因。 */
|
||||
/** 展示后端 ui_state 已裁决的阻断原因;v4:具体原因才展示,通用兜底返回空串。 */
|
||||
function taskReasonLabel(task: ConversationProcessingUserTask): string {
|
||||
const reason = task.uiState
|
||||
? task.uiState.blocking_reason
|
||||
: task.blockingReason;
|
||||
return resolveShippingProcessingReasonLabel(reason, te, t);
|
||||
return resolveBlockingReasonText(reason, te, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务卡头原因行显隐:workbench 模式下文件行页脚已逐文件承载原因,
|
||||
* 卡头不再重复同一句;非 workbench(折叠聚合卡)仍由卡头独家展示。
|
||||
*/
|
||||
function taskHeaderReasonVisible(task: ConversationProcessingUserTask): boolean {
|
||||
return !props.workbenchMode || visibleWorkbenchFileRows(task).length === 0;
|
||||
}
|
||||
|
||||
/** 同一 EML 聚合卡状态计数;仅用后端下发的 aggregateSummary,不从 UI 状态推导。 */
|
||||
@@ -960,7 +969,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
{{ taskReasonLabel(task) }}
|
||||
</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">
|
||||
@@ -1056,7 +1065,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
<div v-if="!workbenchMode" class="mt-0.5 flex flex-wrap gap-x-2 gap-y-0.5 text-[11px] text-secondary">
|
||||
<span v-if="fileCountLabel(task)">{{ fileCountLabel(task) }}</span>
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">{{ taskReasonLabel(task) }}</div>
|
||||
<div v-if="aggregateStatusLabel(task)" class="mt-1 text-[11px] text-secondary">{{ aggregateStatusLabel(task) }}</div>
|
||||
</button>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-amber-200/70 pt-2">
|
||||
@@ -1323,7 +1332,7 @@ function intakeStageLabel(item: ShippingProcessingProjection): string {
|
||||
>
|
||||
{{ primaryFileLabel(task) }}
|
||||
</div>
|
||||
<div v-if="taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
<div v-if="taskHeaderReasonVisible(task) && taskReasonLabel(task)" class="mt-1 text-[11px] text-rose-600 dark:text-rose-300">
|
||||
{{ taskReasonLabel(task) }}
|
||||
</div>
|
||||
<div v-if="workbenchMode" class="mt-3 space-y-2 border-t border-emerald-200/70 pt-2">
|
||||
|
||||
+12
-16
@@ -74,7 +74,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
});
|
||||
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not present historical handling items or CTA as current work when the live projection exists', () => {
|
||||
@@ -115,16 +116,6 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('collapses file-level progress when the batch workbench is open', () => {
|
||||
const wrapper = mount(ShippingOrderExtractionCard, {
|
||||
props: { state: buildState(), runNo: 'SNER-COMPACT', compactProgress: true },
|
||||
global: { plugins: [i18n], provide: { [SHIPPING_WORKFLOW_KEY as symbol]: { processingWorkItems: ref([]) } } },
|
||||
});
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-status-groups"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('uses unified EML aggregation and keeps candidate creation out of completed', async () => {
|
||||
const aggregate = {
|
||||
workItemType: 'order_task', workItemNo: 'INTAKE:SNI-1', sourceType: 'eml', rootOrderTaskNo: 'OT-1',
|
||||
@@ -643,7 +634,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
expect(wrapper.text()).toContain('3 个文件');
|
||||
expect(wrapper.text()).toContain('系统处理中');
|
||||
expect(wrapper.text()).toContain('处理时间偏长');
|
||||
expect(wrapper.text()).toContain('打开批次进度中心');
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.text()).not.toContain('打开批次进度中心');
|
||||
expect(wrapper.text()).not.toContain('刷新状态');
|
||||
expect(wrapper.text()).not.toContain('取消本次识别');
|
||||
expect(wrapper.text()).not.toContain('PO-450003.pdf');
|
||||
@@ -731,7 +723,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
expect(wrapper.text()).toContain('订单候选已生成');
|
||||
expect(wrapper.text()).toContain('候选待人工确认 · 2 项');
|
||||
expect(wrapper.text()).toContain('打开批次进度中心');
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.text()).not.toContain('打开批次进度中心');
|
||||
expect(wrapper.text()).not.toContain('部分附件需人工处理');
|
||||
expect(wrapper.findAll('[data-testid="shipping-order-extraction-handling-item"]').length).toBe(0);
|
||||
});
|
||||
@@ -826,7 +819,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-view-details"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render multi-OT ChatProgressSummary list', () => {
|
||||
@@ -914,7 +908,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-primary-action"]').exists()).toBe(false);
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('does not render the removed view details link', () => {
|
||||
@@ -956,7 +951,8 @@ describe('ShippingOrderExtractionCard', () => {
|
||||
},
|
||||
},
|
||||
});
|
||||
expect(wrapper.get('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(true);
|
||||
// 方案 A:中心常驻后,对话流不再提供「打开批次进度中心」入口(回归保护:按钮不得复活)。
|
||||
expect(wrapper.find('[data-testid="shipping-order-extraction-open-batch-workbench"]').exists()).toBe(false);
|
||||
expect(wrapper.text()).toContain('共 1 个文件');
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/**
|
||||
* features/chat/components/shipping/ShippingOrderExtractionCard.vue
|
||||
* 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、唯一主 CTA、查看详情。
|
||||
* 用途:聊天主区「本次订单文件处理」摘要卡——标题、文件数+状态、一行 handling 摘要、无对话流 CTA(批次中心常驻,方案 A)。
|
||||
* 依赖:订单抽取 Run 状态卡 DTO、shipping.api 文档/进度接口、ShippingOrderExtractionDetailsDrawer、vue-router、vue-i18n。
|
||||
* 逻辑:对话区默认展示状态-EML 聚合;批次工作台打开后切换为紧凑摘要,长进度/Gate/刷新取消由工作台承接。
|
||||
* 逻辑:对话区默认展示状态-EML 聚合;无对话流 CTA(批次中心常驻,方案 A),长进度/Gate/刷新取消由工作台承接。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { AlertCircle, ArrowRight, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
|
||||
import { AlertCircle, CheckCircle2, ChevronDown, CircleX, FileText, LoaderCircle, Mail, RefreshCw, TriangleAlert } from 'lucide-vue-next';
|
||||
import type {
|
||||
ShippingOrderExtractionHandlingItemState,
|
||||
ShippingOrderExtractionFileState,
|
||||
@@ -44,15 +44,12 @@ const props = defineProps<{
|
||||
readonlyReason?: string | null;
|
||||
/** 可选统一投影;摘要卡不再渲染进度,仅保留 prop 兼容宿主。 */
|
||||
processingProjection?: ShippingProcessingProjection | null;
|
||||
/** 批次工作台打开时,左侧只保留摘要,避免与工作台重复展示文件明细。 */
|
||||
compactProgress?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
retry: [];
|
||||
refresh: [];
|
||||
cancel: [reason?: string];
|
||||
'open-batch-workbench': [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -425,7 +422,6 @@ const hasAnyStatusGroupTask = computed(() => (
|
||||
*/
|
||||
const recognizingPlaceholderVisible = computed(() => (
|
||||
hasConversationStatusGroups.value
|
||||
&& !props.compactProgress
|
||||
&& !hasAnyStatusGroupTask.value
|
||||
&& (submittedFileCount.value ?? 0) > 0
|
||||
));
|
||||
@@ -850,7 +846,7 @@ async function onPrimaryChatAction() {
|
||||
<div v-if="handlingSummaryLine && !hasConversationStatusGroups" class="mt-1 text-sm text-secondary">{{ handlingSummaryLine }}</div>
|
||||
</div>
|
||||
|
||||
<div v-if="hasConversationStatusGroups && !compactProgress" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
|
||||
<div v-if="hasConversationStatusGroups" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-status-groups">
|
||||
<div v-if="recognizingPlaceholderVisible" class="flex items-center gap-2 rounded-lg border border-default bg-surface p-3 text-sm text-muted">
|
||||
<LoaderCircle class="h-4 w-4 animate-spin text-brand-500" />
|
||||
<span data-testid="shipping-order-extraction-recognizing-placeholder">{{ t('chat.shippingProcessing.recognizingAttachments') }}</span>
|
||||
@@ -899,7 +895,7 @@ async function onPrimaryChatAction() {
|
||||
</section>
|
||||
</template>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress && emlAggregate" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
|
||||
<div v-else-if="emlAggregate" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30" data-testid="shipping-order-extraction-eml-aggregate">
|
||||
<article class="overflow-hidden rounded-lg border border-default bg-surface shadow-sm">
|
||||
<div class="flex items-start gap-3 border-b border-default bg-surface-soft p-3 dark:bg-slate-950/30">
|
||||
<Mail class="mt-0.5 h-5 w-5 text-brand-500" />
|
||||
@@ -926,7 +922,7 @@ async function onPrimaryChatAction() {
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
<div v-else-if="!compactProgress" class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30">
|
||||
<div v-else class="flex flex-col gap-2 bg-surface-soft p-2 dark:bg-slate-950/30">
|
||||
<div v-for="row in activeEmailRows" :key="row.unitId" class="overflow-hidden rounded-lg border border-default bg-surface shadow-sm">
|
||||
<div class="flex items-start gap-3 border-b border-default bg-surface-soft p-3 dark:bg-slate-950/30"><Mail class="mt-0.5 h-5 w-5 text-brand-500" /><div class="min-w-0 flex-1"><div class="flex items-center justify-between gap-3"><span class="font-medium">{{ t('chat.shippingProcessing.emailPrefix') }}{{ row.fileName }}</span><span class="rounded border px-2 py-0.5 text-xs" :class="isFailedParseRow(row) || emailHasFailedChild(row) ? 'border-rose-200 bg-rose-100/70 text-rose-600' : emailIsCompleted(row) ? 'border-emerald-200 bg-emerald-100/70 text-emerald-600' : 'border-brand-200 bg-brand-100/70 text-brand-600'">{{ isFailedParseRow(row) || emailHasFailedChild(row) ? t('chat.shippingProcessing.batchException') : emailIsCompleted(row) ? t('chat.shippingProcessing.batchExtracted') : t('chat.shippingProcessing.parsingAttachments') }}</span></div><span class="mt-1 block font-mono text-xs text-muted">{{ t('chat.shippingProcessing.emailMeta') }}</span></div></div>
|
||||
<div class="mx-4 my-2 flex flex-col gap-2 border-l-2 border-default bg-surface-soft p-3 pl-4 dark:border-slate-700 dark:bg-slate-950/30"><div v-for="child in childRows(row)" :key="`child-${child.unitId}`" class="flex items-center justify-between gap-3 text-sm"><span class="flex min-w-0 items-center gap-2"><CheckCircle2 v-if="child.status === 'candidate_ready'" class="h-4 w-4 text-emerald-500" /><LoaderCircle v-else-if="!isFailedParseRow(child)" class="h-4 w-4 animate-spin text-brand-500" /><AlertCircle v-else class="h-4 w-4 text-rose-500" /><span class="truncate">{{ child.fileName }}</span></span><span :class="rowStatusClass(child)">{{ rowStatusLabel(child) }}</span></div></div>
|
||||
@@ -936,20 +932,6 @@ async function onPrimaryChatAction() {
|
||||
<div v-for="row in failedRows" :key="`failed-${row.unitId}`" class="rounded-lg border border-rose-200 bg-rose-50 p-3 dark:border-rose-800 dark:bg-rose-950/30"><div class="flex items-center justify-between text-rose-600"><span class="flex items-center gap-2 font-medium"><AlertCircle class="h-5 w-5" />{{ row.fileName }}</span><span class="rounded bg-rose-100 px-2 py-0.5 text-xs">{{ t('chat.shippingProcessing.batchException') }}</span></div><p class="mt-2 pl-7 text-sm">{{ row.explainability?.message || t('chat.shippingProcessing.batchManualVerify') }}</p></div>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end border-t border-default bg-brand-50/60 p-3 dark:bg-brand-950/20">
|
||||
<div class="flex items-center gap-3">
|
||||
<button
|
||||
v-if="!compactProgress && (hasConversationStatusGroups || String(props.runNo || '').trim())"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-2 rounded-lg bg-brand-600 px-5 py-2.5 text-sm font-medium text-white shadow-sm hover:bg-brand-700"
|
||||
data-testid="shipping-order-extraction-open-batch-workbench"
|
||||
@click="emit('open-batch-workbench')"
|
||||
>
|
||||
{{ t('chat.shippingProcessing.openBatchWorkbench') }}
|
||||
<ArrowRight class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="false" class="flex items-start gap-3">
|
||||
<CircleX class="mt-0.5 h-4 w-4 shrink-0" />
|
||||
<div class="min-w-0 flex-1">
|
||||
|
||||
@@ -104,10 +104,11 @@ function buildController(
|
||||
function mountTimeline(
|
||||
processing = processingProjection(),
|
||||
workItems: ShippingProcessingProjection[] = [],
|
||||
extraProps: Record<string, unknown> = {},
|
||||
) {
|
||||
return mount(ShippingWorkflowTimeline, {
|
||||
attachTo: document.body,
|
||||
props: { conversationId: 'conv-1', controller: buildController(processing, workItems) },
|
||||
props: { conversationId: 'conv-1', controller: buildController(processing, workItems), ...extraProps },
|
||||
global: { plugins: [i18n], stubs: { teleport: true } },
|
||||
});
|
||||
}
|
||||
@@ -124,6 +125,24 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
gateRecovery.submitPrimaryAction.mockClear();
|
||||
});
|
||||
|
||||
it('has no close button and reuses the conversation title in the header', () => {
|
||||
const wrapper = mountTimeline(processingProjection(), [], { conversationTitle: 'PO#6075309 09-15' });
|
||||
|
||||
// 中心常驻不可关闭(方案 A):关闭按钮必须消失。
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-close"]').exists()).toBe(false);
|
||||
|
||||
// 会话标题直接复用侧栏命名,保持两处一致。
|
||||
const titleNode = wrapper.find('[data-testid="shipping-workflow-conversation-title"]');
|
||||
expect(titleNode.exists()).toBe(true);
|
||||
expect(titleNode.text()).toContain('PO#6075309 09-15');
|
||||
});
|
||||
|
||||
it('omits the title node when no conversation title is provided', () => {
|
||||
const wrapper = mountTimeline(processingProjection(), []);
|
||||
|
||||
expect(wrapper.find('[data-testid="shipping-workflow-conversation-title"]').exists()).toBe(false);
|
||||
});
|
||||
|
||||
it('prefers backend five-stage lifecycle nodes and shows the authorized download toolbar in freight upload', async () => {
|
||||
const processing = processingProjection({
|
||||
lifecycle_nodes: [
|
||||
@@ -205,25 +224,6 @@ describe('ShippingWorkflowTimeline', () => {
|
||||
expect(wrapper.find('[data-testid="shipping-processing-file-DOC-9"]').exists()).toBe(true);
|
||||
});
|
||||
|
||||
it('labels a manually actionable batch as action needed instead of processing', async () => {
|
||||
const task = { ...processingProjection().processing[0], group: 'needs_action' };
|
||||
const processing = processingProjection({
|
||||
summary: { total_files: 1, processing_files: 0, completed_files: 0, waiting_human_files: 1, failed_files: 0 },
|
||||
needs_action: [task], processing: [],
|
||||
status_groups: { failed: [], waiting_human: [task], processing: [], completed: [], cancelled: [], archived: [] },
|
||||
} as Partial<ConversationProcessingProjection>);
|
||||
const wrapper = mountTimeline(processing, [fileProjection({
|
||||
uiState: {
|
||||
status: 'waiting_human', stage: 'order_review', lifecycleStage: 'order_review',
|
||||
lifecycleEntries: [], blocking_reason: null, primary_action: null, secondary_actions: [],
|
||||
},
|
||||
})]);
|
||||
await flushPromises();
|
||||
|
||||
// 关键断言:锁定表示仍有待办,不得与「处理中 0」形成视觉矛盾。
|
||||
expect(wrapper.get('[data-testid="shipping-workflow-panel-pinned"]').text()).toBe('待处理');
|
||||
});
|
||||
|
||||
it('navigates only through the backend lifecycle entry', async () => {
|
||||
const file = fileProjection({
|
||||
uiState: {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* 用途:聊天页右侧「批次进度中心」——后端批次投影、五阶段进度和文件行操作。
|
||||
* 依赖:vue-i18n、useMessage、useShippingNoticeWorkflow、ShippingConversationProcessingCard、
|
||||
* ReasonDialog、ProcessGateRecoveryCard。
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;标题栏仅保留批次名称、加载与截断提示,
|
||||
* 逻辑:顶层以 OT / ShippingProcessing 为主路径;标题栏保留批次名称、会话标题、加载与截断提示;中心常驻不可关闭(方案 A),
|
||||
* 文件总览和进度仅消费后端批次 summary;
|
||||
* 文件清单消费后端 conversation_processing.status_groups;work_items 仅用于定位同一
|
||||
* 展示 DTO 的操作对象;整批操作走 Run API,单文件取消走 Unit API;
|
||||
@@ -14,7 +14,7 @@
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ChevronDown, ChevronRight, Lock, RefreshCw } from 'lucide-vue-next';
|
||||
import { RefreshCw } from 'lucide-vue-next';
|
||||
import {
|
||||
downloadWorkspaceShippingExcelFile,
|
||||
downloadWorkspaceShippingExportArchive,
|
||||
@@ -59,10 +59,8 @@ const props = defineProps<{
|
||||
refreshTrigger?: number;
|
||||
/** 测试或父级注入时可直接传入控制器,跳过自建轮询。 */
|
||||
controller?: UseShippingNoticeWorkflowReturn | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
/** 当前会话标题;父级从侧栏历史匹配传入,中心头部直接复用(无新增接口)。 */
|
||||
conversationTitle?: string | null;
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -91,11 +89,6 @@ const ctl = computed((): UseShippingNoticeWorkflowReturn => (
|
||||
props.controller || injected || localController
|
||||
));
|
||||
|
||||
/**
|
||||
* 侧栏折叠态:默认展开。
|
||||
* 有处理中/待处理/未查看完成任务时强制展开,仅允许收起文件详情。
|
||||
*/
|
||||
const collapsed = ref(false);
|
||||
/** 复核返回对话时展示的聚焦提示(由 focus_notice 触发一次)。 */
|
||||
const focusTaskBanner = ref<string | null>(null);
|
||||
const actionBusyItemNo = ref<string | null>(null);
|
||||
@@ -249,34 +242,6 @@ const initialLoading = computed(() => Boolean(ctl.value.initialLoading?.value));
|
||||
const manualRefreshing = computed(() => Boolean(ctl.value.manualRefreshing?.value));
|
||||
const isRefreshing = computed(() => Boolean(ctl.value.isRefreshing?.value));
|
||||
const error = computed(() => ctl.value.error.value);
|
||||
/**
|
||||
* 右侧仍有用户必须持续可见的任务时,禁止收起整个处理面板。
|
||||
* 核心逻辑:处理中 / 待处理 / 未查看完成均属活跃可见任务;无此类任务才允许收起侧栏。
|
||||
*/
|
||||
const hasPinnedProcessingTasks = computed(() => {
|
||||
const projection = displayProcessing.value;
|
||||
if (!projection) return false;
|
||||
return statusGroupTasks('failed', 'waiting_human', 'processing', 'completed').length > 0;
|
||||
});
|
||||
|
||||
/**
|
||||
* 切换侧栏折叠:活跃任务存在时强制保持展开。
|
||||
*/
|
||||
function togglePanelCollapsed() {
|
||||
if (hasPinnedProcessingTasks.value) {
|
||||
collapsed.value = false;
|
||||
return;
|
||||
}
|
||||
collapsed.value = !collapsed.value;
|
||||
}
|
||||
|
||||
watch(
|
||||
hasPinnedProcessingTasks,
|
||||
(pinned) => {
|
||||
if (pinned) collapsed.value = false;
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/**
|
||||
* 移除右侧常驻「批次与文件列表」长列表抽屉(UI-REFACTOR 方案 7)。
|
||||
@@ -839,7 +804,6 @@ watch(
|
||||
return;
|
||||
}
|
||||
if (!focusedTaskExists.value) return;
|
||||
collapsed.value = false;
|
||||
focusTaskBanner.value = normalized;
|
||||
// [UI-01/UI-02] 真正选中进度卡,禁止只显示提示条。
|
||||
await onProcessingFocus(normalized);
|
||||
@@ -856,31 +820,12 @@ watch(
|
||||
|
||||
<template>
|
||||
<aside
|
||||
class="flex min-w-0 flex-1 shrink-0 flex-col border-l border-default bg-surface shadow-[-16px_0_40px_rgba(15,23,42,0.10)] transition-[width] duration-200"
|
||||
:class="collapsed ? '!w-14' : ''"
|
||||
class="flex min-w-0 flex-1 shrink-0 flex-col bg-surface"
|
||||
data-testid="shipping-workflow-timeline"
|
||||
>
|
||||
<div class="flex w-full items-center gap-1 border-b border-default px-2 py-2">
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary"
|
||||
data-testid="shipping-workflow-close"
|
||||
:title="t('chat.shippingProcessing.closeWorkbench')"
|
||||
@click="emit('close')"
|
||||
>
|
||||
×
|
||||
</button>
|
||||
<component
|
||||
:is="hasPinnedProcessingTasks ? 'div' : 'button'"
|
||||
:type="hasPinnedProcessingTasks ? undefined : 'button'"
|
||||
class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left"
|
||||
:class="hasPinnedProcessingTasks
|
||||
? 'cursor-default'
|
||||
: 'hover:bg-surface-muted/60'"
|
||||
data-testid="shipping-workflow-panel-toggle"
|
||||
@click="togglePanelCollapsed"
|
||||
>
|
||||
<div v-if="!collapsed" class="min-w-0">
|
||||
<div class="flex min-w-0 flex-1 items-center justify-between gap-2 rounded-md px-1 py-1 text-left">
|
||||
<div class="min-w-0">
|
||||
<div class="flex items-center gap-1.5">
|
||||
<div class="text-sm font-semibold text-primary">
|
||||
{{ te('chat.shippingProcessing.panelTitle')
|
||||
@@ -888,14 +833,11 @@ watch(
|
||||
: t('chat.shippingProcessing.title') }}
|
||||
</div>
|
||||
<span
|
||||
v-if="hasPinnedProcessingTasks"
|
||||
class="inline-flex items-center gap-0.5 rounded bg-surface-muted px-1.5 py-0.5 text-[10px] font-medium text-secondary"
|
||||
data-testid="shipping-workflow-panel-pinned"
|
||||
:title="t('chat.shippingProcessing.panelPinnedHint')"
|
||||
>
|
||||
<Lock class="h-3 w-3 shrink-0" aria-hidden="true" />
|
||||
{{ t('chat.shippingProcessing.panelPinnedLabel') }}
|
||||
</span>
|
||||
v-if="conversationTitle"
|
||||
class="min-w-0 truncate rounded bg-surface-muted px-1.5 py-0.5 text-xs text-secondary"
|
||||
data-testid="shipping-workflow-conversation-title"
|
||||
:title="conversationTitle"
|
||||
>{{ conversationTitle }}</span>
|
||||
</div>
|
||||
<div class="mt-0.5 space-y-0.5 text-xs text-secondary" data-testid="shipping-workflow-panel-summary">
|
||||
<template v-if="initialLoading && !displayProcessing">
|
||||
@@ -918,12 +860,7 @@ watch(
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
<ChevronDown
|
||||
v-if="!collapsed && !hasPinnedProcessingTasks"
|
||||
class="h-4 w-4 shrink-0 text-muted"
|
||||
/>
|
||||
<ChevronRight v-else-if="collapsed" class="h-4 w-4 shrink-0 text-muted" />
|
||||
</component>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="shrink-0 rounded-md p-1.5 text-muted hover:bg-surface-muted hover:text-primary disabled:opacity-50"
|
||||
@@ -939,7 +876,7 @@ watch(
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="!collapsed" class="min-h-0 flex-1 overflow-y-auto p-5">
|
||||
<div class="min-h-0 flex-1 overflow-y-auto p-5">
|
||||
<div
|
||||
v-if="initialLoading && !displayProcessing"
|
||||
class="mb-4 space-y-3"
|
||||
|
||||
@@ -649,6 +649,42 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.intakeParseLoadFailed.value).toBe(true);
|
||||
});
|
||||
|
||||
it('loads intake parse context for a formal-downstream Case while activeCase stays unloaded', async () => {
|
||||
// 选法 2:正式下游(货代上传等)切 PDF 不拉 Case/Evidence,activeCase 保持 null。
|
||||
// 关键断言:接收解析工作面回看已完成阶段时,上下文仍必须按 requestedCaseNo 拉取,
|
||||
// 不得因 activeCase 为 null 静默跳过(否则面板渲染成空白)。
|
||||
api.getQueue.mockResolvedValue({
|
||||
summary: { total: 1, needs_action: 0, processing: 0, completed: 1 },
|
||||
items: [{
|
||||
case_no: 'CASE-2', document_id: 2, status: 'confirmed',
|
||||
has_formal_ot: true,
|
||||
lifecycle_stage: 'freight_upload',
|
||||
lifecycle_entries: [
|
||||
{ code: 'intake_parse', state: 'available' },
|
||||
{ code: 'order_review', state: 'available' },
|
||||
{ code: 'fulfillment_prep', state: 'available' },
|
||||
{ code: 'freight_upload', state: 'current' },
|
||||
],
|
||||
}],
|
||||
});
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-2');
|
||||
|
||||
api.getCase.mockClear();
|
||||
api.getEvidence.mockClear();
|
||||
await review.selectCase('CASE-2');
|
||||
// 选法 2 关键断言:正式下游切换不拉复核 Case/Evidence,activeCase 为空。
|
||||
expect(api.getCase).not.toHaveBeenCalled();
|
||||
expect(review.activeCase.value).toBeNull();
|
||||
expect(review.requestedCaseNo.value).toBe('CASE-2');
|
||||
|
||||
await expect(review.ensureIntakeParseContextLoaded('CASE-2')).resolves.toBe(true);
|
||||
expect(api.getIntakeParseContext).toHaveBeenLastCalledWith('CASE-2');
|
||||
expect(review.intakeParseContext.value?.case_no).toBe('CASE-2');
|
||||
expect(review.intakeParseLoading.value).toBe(false);
|
||||
expect(review.intakeParseLoadFailed.value).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps the latest same-Case intake context when an older success resolves last', async () => {
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1');
|
||||
@@ -771,6 +807,48 @@ describe('useShippingOrderReview build eligibility writes', () => {
|
||||
expect(review.reviewProgressContext.value?.user_task_authoritative).toBe(false);
|
||||
});
|
||||
|
||||
it('beginCrossRunSwitch drops the previous file intake context and rejects its stale success', async () => {
|
||||
// 关键断言:跨 Run 切文件(如 PO_6075309 → PO_6075316)切换即清空接收解析上下文,
|
||||
// 迟到的旧 Case 上下文成功响应也不得把旧附件名/邮件正文写回新文件工作面。
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1');
|
||||
await review.ensureIntakeParseContextLoaded('CASE-1');
|
||||
expect(review.intakeParseContext.value?.attachment.filename).toBe('order.pdf');
|
||||
|
||||
let resolveStale: ((value: Record<string, unknown>) => void) | null = null;
|
||||
api.getIntakeParseContext.mockImplementationOnce(
|
||||
() => new Promise((resolve) => { resolveStale = resolve; }),
|
||||
);
|
||||
const pendingStale = review.ensureIntakeParseContextLoaded('CASE-1');
|
||||
review.beginCrossRunSwitch('CASE-2');
|
||||
|
||||
expect(review.intakeParseContext.value).toBeNull();
|
||||
expect(review.intakeParseLoading.value).toBe(false);
|
||||
expect(review.intakeParseLoadFailed.value).toBe(false);
|
||||
resolveStale?.({
|
||||
case_no: 'CASE-1',
|
||||
attachment: { document_id: 1, filename: 'order.pdf', mime_type: 'application/pdf', preview_kind: 'pdf' },
|
||||
email: null,
|
||||
});
|
||||
await pendingStale;
|
||||
expect(review.intakeParseContext.value).toBeNull();
|
||||
});
|
||||
|
||||
it('load fast path drops the stale intake context when the target Case changes', async () => {
|
||||
// 关键断言:稳定工作台直达 load 换 Case(重解析落位/重试等入口)同样撤销旧上下文。
|
||||
const review = useShippingOrderReview();
|
||||
await review.load('RUN-1', 'CASE-1');
|
||||
await review.ensureIntakeParseContextLoaded('CASE-1');
|
||||
expect(review.intakeParseContext.value?.case_no).toBe('CASE-1');
|
||||
|
||||
api.getCase.mockResolvedValue(buildCase({ case_no: 'CASE-2', document: { id: 2, file_name: 'second.pdf' } }));
|
||||
await review.load('RUN-1', 'CASE-2');
|
||||
|
||||
expect(review.activeCase.value?.case_no).toBe('CASE-2');
|
||||
expect(review.intakeParseContext.value).toBeNull();
|
||||
expect(review.intakeParseLoading.value).toBe(false);
|
||||
});
|
||||
|
||||
it('discards stale selectCase responses when switching PDFs quickly', async () => {
|
||||
// 关键断言:A 后发先至不得覆盖后选的 B;切换时先清空瞬态。
|
||||
let resolveA: ((value: ShippingOrderReviewCase) => void) | null = null;
|
||||
|
||||
@@ -993,10 +993,13 @@ export function useShippingOrderReview(options: {
|
||||
/**
|
||||
* 仅在用户打开接收解析工作面时按需读取当前 Case 的附件与邮件正文。
|
||||
* Case/代次双校验避免迟到响应把旧附件或 EML 写回当前工作面;失败保持空上下文。
|
||||
* 选法 2(正式下游)下 activeCase 刻意为 null,此时以 requestedCaseNo 校验目标,
|
||||
* 与 ensurePreviewLoaded 的兜底口径一致;否则回看已完成接收解析阶段会静默跳过加载。
|
||||
*/
|
||||
const ensureIntakeParseContextLoaded = async (caseNo: string): Promise<boolean> => {
|
||||
const target = String(caseNo || '').trim();
|
||||
if (!target || activeCase.value?.case_no !== target) {
|
||||
const expectedCaseNo = String(requestedCaseNo.value || activeCase.value?.case_no || '').trim();
|
||||
if (!target || target !== expectedCaseNo) {
|
||||
++intakeParseRequestGeneration;
|
||||
intakeParseContext.value = null;
|
||||
intakeParseLoading.value = false;
|
||||
@@ -1014,7 +1017,7 @@ export function useShippingOrderReview(options: {
|
||||
if (
|
||||
requestGeneration !== intakeParseRequestGeneration
|
||||
|| generation !== caseLoadGeneration
|
||||
|| activeCase.value?.case_no !== target
|
||||
|| String(requestedCaseNo.value || activeCase.value?.case_no || '').trim() !== target
|
||||
) return false;
|
||||
intakeParseContext.value = context;
|
||||
return true;
|
||||
@@ -1022,7 +1025,7 @@ export function useShippingOrderReview(options: {
|
||||
if (
|
||||
requestGeneration === intakeParseRequestGeneration
|
||||
&& generation === caseLoadGeneration
|
||||
&& activeCase.value?.case_no === target
|
||||
&& String(requestedCaseNo.value || activeCase.value?.case_no || '').trim() === target
|
||||
) {
|
||||
intakeParseContext.value = null;
|
||||
intakeParseLoadFailed.value = true;
|
||||
@@ -1032,7 +1035,7 @@ export function useShippingOrderReview(options: {
|
||||
if (
|
||||
requestGeneration === intakeParseRequestGeneration
|
||||
&& generation === caseLoadGeneration
|
||||
&& activeCase.value?.case_no === target
|
||||
&& String(requestedCaseNo.value || activeCase.value?.case_no || '').trim() === target
|
||||
) {
|
||||
intakeParseLoading.value = false;
|
||||
}
|
||||
@@ -1096,6 +1099,13 @@ export function useShippingOrderReview(options: {
|
||||
// 已有稳定工作台且路由明确目标 PDF 时,目标详情是用户切换的关键路径;
|
||||
// Run/Queue 只负责后续更新导航和阶段摘要,不能用其慢投影阻塞当前文件显示。
|
||||
if (hasStableWorkbench && preferredCaseNo) {
|
||||
// 稳定工作台直达 load 换 Case 时(如重解析落位/重试),同样必须撤销旧文件的
|
||||
// 接收解析上下文;新上下文由视图层 Case 变化 watcher 按目标 Case 重载。
|
||||
if (String(preferredCaseNo || '').trim() !== String(activeCase.value?.case_no || '').trim()) {
|
||||
intakeParseContext.value = null;
|
||||
intakeParseLoading.value = false;
|
||||
intakeParseLoadFailed.value = false;
|
||||
}
|
||||
const [caseSnapshot, caseEvidence] = await Promise.all([
|
||||
getWorkspaceShippingOrderReviewCase(preferredCaseNo),
|
||||
getWorkspaceShippingOrderReviewEvidence(preferredCaseNo),
|
||||
@@ -1189,6 +1199,8 @@ export function useShippingOrderReview(options: {
|
||||
* 核心逻辑:保留 activeCase/工作台壳(避免大骨架闪动),但清空 user_task_no,
|
||||
* 让 shippingProcessingProjection 立即丢弃上一份 PDF 的右卡/库存态;目标 Case
|
||||
* 仍由随后的 load(preferredCaseNo) 目标优先路径写入。
|
||||
* 接收解析上下文必须与预览一并撤销:Run 变更即 Case 变更,旧文件的附件名/邮件正文
|
||||
* 不得残留在新文件工作面(新上下文由视图层 Case 变化 watcher 重载)。
|
||||
* @param caseNo - 目标复核 Case 编号
|
||||
*/
|
||||
const beginCrossRunSwitch = (caseNo: string) => {
|
||||
@@ -1212,6 +1224,9 @@ export function useShippingOrderReview(options: {
|
||||
};
|
||||
}
|
||||
clearPreview();
|
||||
intakeParseContext.value = null;
|
||||
intakeParseLoading.value = false;
|
||||
intakeParseLoadFailed.value = false;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -108,6 +108,46 @@ describe('normalizeShippingProcessingProjection', () => {
|
||||
expect(normalized?.stageNodes?.[1]?.absoluteIndex).toBe(2);
|
||||
});
|
||||
|
||||
it('preserves explainability message and next_action on blocking_reason', () => {
|
||||
// v4 阻塞原因具体化:冻结 explainability 契约透传的 message / next_action
|
||||
// 是「阻塞原因行」与「下一步建议动作」的数据源,归一化不得剥离。
|
||||
const normalized = normalizeShippingProcessingProjection({
|
||||
work_item_no: 'OT-REASON',
|
||||
work_item_type: 'order_task',
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
ui_state: {
|
||||
status: 'waiting_human',
|
||||
stage: 'order_review',
|
||||
blocking_reason: {
|
||||
code: 'customer_unresolved',
|
||||
message: '客户尚未确认',
|
||||
next_action: 'confirm_customer',
|
||||
},
|
||||
primary_action: null,
|
||||
secondary_actions: [],
|
||||
},
|
||||
source_summary: {
|
||||
email_subject: null,
|
||||
filename: 'reason.pdf',
|
||||
document_id: 91,
|
||||
document_count: 1,
|
||||
parsed_document_count: 1,
|
||||
candidate_count: 1,
|
||||
customer_name: null,
|
||||
po_number: null,
|
||||
failure_reason_code: null,
|
||||
parse_attempt_count: 0,
|
||||
asset_status: 'ready',
|
||||
},
|
||||
child_order_tasks: [],
|
||||
});
|
||||
const reason = normalized?.uiState?.blocking_reason;
|
||||
expect(reason?.code).toBe('customer_unresolved');
|
||||
expect(reason?.message).toBe('客户尚未确认');
|
||||
expect(reason?.nextAction).toBe('confirm_customer');
|
||||
});
|
||||
|
||||
it('normalizes the EML status-partition file count', () => {
|
||||
const normalized = normalizeShippingProcessingProjection({
|
||||
work_item_no: 'INTAKE:SNI-EML',
|
||||
|
||||
@@ -108,12 +108,16 @@ function normalizeStageNode(raw: unknown): ShippingProcessingStageNode | null {
|
||||
|
||||
/**
|
||||
* [T9 用户态 Projection] 规范 blocking_reason(后端 snake_case {code, i18n_key, details})。
|
||||
* v4:保留冻结 explainability 契约透传的 message(中文兜底文案)与
|
||||
* next_action(下一步建议动作码,camel/snake 兼容),供「阻塞原因行」与
|
||||
* 「下一步」槽位消费;禁止剥离,否则 UI 退化为通用状态文案。
|
||||
*/
|
||||
function normalizeBlockingReason(raw: unknown): ShippingProcessingBlockingReason | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const item = raw as Record<string, unknown>;
|
||||
const code = String(item.code ?? '').trim();
|
||||
if (!code) return null;
|
||||
const nextAction = item.next_action ?? item.nextAction;
|
||||
return {
|
||||
code,
|
||||
i18nKey: item.i18n_key != null ? String(item.i18n_key) : null,
|
||||
@@ -121,6 +125,8 @@ function normalizeBlockingReason(raw: unknown): ShippingProcessingBlockingReason
|
||||
typeof item.details === 'object' && item.details != null
|
||||
? (item.details as Record<string, unknown>)
|
||||
: {},
|
||||
message: item.message != null ? String(item.message) : null,
|
||||
nextAction: nextAction != null ? String(nextAction) : null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
extractExtractionProgressReasonCode,
|
||||
isGenericBlockingReason,
|
||||
isRedundantExtractionDetail,
|
||||
resolveBlockingReasonText,
|
||||
resolveExtractionActivityMessage,
|
||||
resolveRunLifecycleUserStatus,
|
||||
resolveShippingProcessingReasonLabel,
|
||||
@@ -175,3 +177,38 @@ describe('extraction lifecycle display (v2 状态展示统一)', () => {
|
||||
expect(isRedundantExtractionDetail('', 'waiting_human')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('blocking reason text resolution (v4 阻塞原因具体化)', () => {
|
||||
// 仅登记通用兜底与一个 Gate 命名空间码,验证解析链与隐藏判定
|
||||
const REASON_TEXT: Record<string, string> = {
|
||||
'chat.shippingProcessing.reasonCode.unknown': '当前步骤需要人工处理',
|
||||
'workspace.shippingNotice.processGate.reasons.customer_unresolved': '客户尚未确认',
|
||||
};
|
||||
const te = (key: string) => key in REASON_TEXT;
|
||||
const t = (key: string) => REASON_TEXT[key] ?? key;
|
||||
|
||||
it('resolveBlockingReasonText:Gate 命名空间可解析的原因码返回具体文案', () => {
|
||||
expect(resolveBlockingReasonText({ code: 'customer_unresolved' }, te, t)).toBe('客户尚未确认');
|
||||
});
|
||||
|
||||
it('resolveBlockingReasonText:命名空间未命中时回退契约透传 message', () => {
|
||||
// 关键断言:后端 explainability.message 是 i18n 之后的最后兜底,不是首选
|
||||
expect(resolveBlockingReasonText({
|
||||
code: 'budget_stopped',
|
||||
message: '订单识别预算已用尽,请检查文档后进入复核',
|
||||
}, te, t)).toBe('订单识别预算已用尽,请检查文档后进入复核');
|
||||
});
|
||||
|
||||
it('resolveBlockingReasonText:通用兜底返回空串,调用方据此隐藏原因行', () => {
|
||||
expect(resolveBlockingReasonText({ code: 'internal_gate_reason' }, te, t)).toBe('');
|
||||
expect(resolveBlockingReasonText(null, te, t)).toBe('');
|
||||
expect(resolveBlockingReasonText(undefined, te, t)).toBe('');
|
||||
});
|
||||
|
||||
it('isGenericBlockingReason:Gate 命名空间可解析即非通用;仅未知码为通用', () => {
|
||||
// 关键断言:i18n 命名空间可解析(四语言齐备)才算具体原因
|
||||
expect(isGenericBlockingReason({ code: 'customer_unresolved' }, te)).toBe(false);
|
||||
expect(isGenericBlockingReason({ code: 'internal_gate_reason' }, te)).toBe(true);
|
||||
expect(isGenericBlockingReason(null, te)).toBe(true);
|
||||
});
|
||||
});
|
||||
@@ -87,6 +87,44 @@ export function resolveShippingProcessingReasonLabel(
|
||||
return te(unknownKey) ? t(unknownKey) : '当前步骤需要人工处理';
|
||||
}
|
||||
|
||||
/** Gate 原因码的多命名空间查找键(与 resolveGateReasonLabel 保持同源顺序)。 */
|
||||
function gateReasonNamespaceKeys(code: string): string[] {
|
||||
return [
|
||||
`chat.shippingProcessing.gateReasons.${code}`,
|
||||
`workspace.shippingNotice.workflowReasons.${code}`,
|
||||
`workspace.shippingNotice.processGate.reasons.${code}`,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析批次中心行内「阻塞原因」文案;通用兜底返回空串(调用方隐藏原因行)。
|
||||
* 核心逻辑:i18n_key → reasonCode 专用键 → Gate 三命名空间 → 契约透传 message;
|
||||
* 与 isGenericBlockingReason 同一判据,保证「隐藏的」与「展示的」口径一致。
|
||||
*/
|
||||
export function resolveBlockingReasonText(
|
||||
reason: {
|
||||
code?: string | null;
|
||||
i18nKey?: string | null;
|
||||
i18n_key?: string | null;
|
||||
message?: string | null;
|
||||
} | null | undefined,
|
||||
te: (key: string) => boolean,
|
||||
t: (key: string) => string,
|
||||
): string {
|
||||
if (isGenericBlockingReason(reason, te)) return '';
|
||||
const i18nKey = String(reason?.i18nKey || reason?.i18n_key || '').trim();
|
||||
if (i18nKey && te(i18nKey)) return t(i18nKey);
|
||||
const code = String(reason?.code || '').trim();
|
||||
if (code) {
|
||||
const reasonCodeKey = `chat.shippingProcessing.reasonCode.${code}`;
|
||||
if (te(reasonCodeKey)) return t(reasonCodeKey);
|
||||
for (const key of gateReasonNamespaceKeys(code)) {
|
||||
if (te(key)) return t(key);
|
||||
}
|
||||
}
|
||||
return String(reason?.message || '').trim();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析统一处理文案。
|
||||
*
|
||||
@@ -197,22 +235,33 @@ export function resolveShippingLifecycleStageLabel(
|
||||
/**
|
||||
* 判定阻塞原因是否为「通用兜底」(应在行内隐藏,避免与状态芯片重复)。
|
||||
*
|
||||
* 三方约定:仅当下发到具体、非兜底的阻塞原因(有真实 i18n 文案)才展示原因行;
|
||||
* 进到 reasonCode.unknown / 无 i18n_key 的通用码一律视为重复信息。
|
||||
* 三方约定:仅当下发到具体、非兜底的阻塞原因才展示原因行。具体判据:
|
||||
* i18n_key 命中、reasonCode 专用键命中、Gate 三命名空间任一命中
|
||||
* (四语言齐备),或契约透传了具体 message(无命名空间时的最后兜底)。
|
||||
* 进到 unknown / 全部未命中的一律视为重复信息。
|
||||
*
|
||||
* @param reason - 后端 blocking_reason(code / i18n_key)
|
||||
* @param reason - 后端 blocking_reason(code / i18n_key / message)
|
||||
* @param te - i18n te
|
||||
* @returns true=通用兜底(应隐藏)
|
||||
*/
|
||||
export function isGenericBlockingReason(
|
||||
reason: { code?: string | null; i18nKey?: string | null; i18n_key?: string | null } | null | undefined,
|
||||
reason: {
|
||||
code?: string | null;
|
||||
i18nKey?: string | null;
|
||||
i18n_key?: string | null;
|
||||
message?: string | null;
|
||||
} | null | undefined,
|
||||
te: (key: string) => boolean,
|
||||
): boolean {
|
||||
if (!reason) return true;
|
||||
const i18nKey = String(reason.i18nKey || reason.i18n_key || '').trim();
|
||||
if (i18nKey && te(i18nKey)) return false;
|
||||
const code = String(reason.code || '').trim();
|
||||
if (code && code !== 'unknown' && te(`chat.shippingProcessing.reasonCode.${code}`)) return false;
|
||||
if (code && code !== 'unknown') {
|
||||
if (te(`chat.shippingProcessing.reasonCode.${code}`)) return false;
|
||||
if (gateReasonNamespaceKeys(code).some((key) => te(key))) return false;
|
||||
}
|
||||
if (String(reason.message || '').trim()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingWorkbenchLayout.spec.ts
|
||||
* 用途:锁定货代会话主区域显隐规则(有会话即全屏批次进度中心,方案 A)。
|
||||
* 依赖:Vitest、纯函数。
|
||||
* 逻辑:判定必须同时满足货代智能体与非空会话 ID;普通智能体与新会话一律回落欢迎页。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { shouldShowShippingWorkbench } from './shippingWorkbenchLayout';
|
||||
|
||||
describe('shouldShowShippingWorkbench', () => {
|
||||
it('renders the workbench for the shipping agent once a conversation exists', () => {
|
||||
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: 'conv-1' })).toBe(true);
|
||||
});
|
||||
|
||||
it('keeps the welcome composer before a conversation is created', () => {
|
||||
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: '' })).toBe(false);
|
||||
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: true, conversationId: null })).toBe(false);
|
||||
});
|
||||
|
||||
it('never switches other agents to the workbench', () => {
|
||||
expect(shouldShowShippingWorkbench({ isShippingNoticeAgent: false, conversationId: 'conv-1' })).toBe(false);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingWorkbenchLayout.ts
|
||||
* 用途:货代发货会话主区域显隐判定(批次进度中心优先,方案 A)。
|
||||
* 依赖:无(纯函数)。
|
||||
* 逻辑:货代智能体且存在非空会话 ID 时全屏渲染批次进度中心;
|
||||
* 否则(新会话欢迎页)显示欢迎页 + 输入框(唯一附件提交入口)。
|
||||
*/
|
||||
|
||||
export interface ShippingWorkbenchLayoutInput {
|
||||
isShippingNoticeAgent: boolean;
|
||||
conversationId: string | null | undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判定是否以批次进度中心作为会话主区域。
|
||||
* @param input - 智能体身份与当前会话 ID(路由 query 与 page 回填同源优先级)。
|
||||
* @returns true 表示全屏渲染批次进度中心;false 表示欢迎页 + 输入框。
|
||||
*/
|
||||
export function shouldShowShippingWorkbench(input: ShippingWorkbenchLayoutInput): boolean {
|
||||
return Boolean(input.isShippingNoticeAgent && String(input.conversationId || '').trim());
|
||||
}
|
||||
@@ -167,6 +167,11 @@ export interface ShippingProcessingBlockingReason {
|
||||
code: string;
|
||||
i18nKey?: string | null;
|
||||
details?: Record<string, unknown>;
|
||||
/** 建单前资格快照回退透传(冻结 explainability 契约):中文兜底文案,前端优先 i18n。 */
|
||||
message?: string | null;
|
||||
/** 契约注册的下一步动作码(processGate.actionCodes.*),camel/snake 兼容读取。 */
|
||||
nextAction?: string | null;
|
||||
next_action?: string | null;
|
||||
}
|
||||
/**
|
||||
* 用户态统一 Projection 主动作(T8 决策 F2;后端对象 {code, i18n_key, parameters})。
|
||||
@@ -955,7 +960,8 @@ export interface ShippingRpaRuntime {
|
||||
}
|
||||
|
||||
export interface ShippingCurrentStepProgress {
|
||||
step_key?: string;
|
||||
/** 15 阶契约阶段码(CheckPoint 时代 stepN_* 遗留键已清除)。 */
|
||||
stage?: string;
|
||||
step_title?: string;
|
||||
status?: 'running' | 'completed' | 'needs_human' | 'pending' | string;
|
||||
message?: string;
|
||||
@@ -1498,6 +1504,15 @@ export interface ShippingTaskUiState {
|
||||
}>;
|
||||
/** 人工覆写库存源(方案 3·放开):全部已启用源,供行级下拉人工指定。 */
|
||||
source_options?: Array<{ source_code?: string | null; display_name?: string | null }>;
|
||||
/**
|
||||
* 整单 ODM 裁决摘要:conflict=true 表示范围限定后仍有多行存在多值,
|
||||
* 由行内 odm 下发候选,用户改任一行后同一快照文件的其他行同步。
|
||||
*/
|
||||
odm_options?: {
|
||||
conflict?: boolean;
|
||||
customer_odm_ids?: Array<string>;
|
||||
whitelist_applied?: boolean;
|
||||
};
|
||||
/** 阶段能力(Task 2 下发);prep 工作台能力工具条消费,scope=task 级。 */
|
||||
capabilities?: ShippingStageCapability[];
|
||||
/** 仅当前任务活动关联的库存快照才可下载。 */
|
||||
@@ -1523,6 +1538,10 @@ export interface ShippingTaskUiState {
|
||||
/** 多文件冲突行(D5):候选源列表供行内下拉,选定后走 override_line_inventory_source。 */
|
||||
source_ambiguous?: boolean;
|
||||
source_candidates?: Array<string>;
|
||||
/** 整单 ODM 裁决:本行候选(经客户范围过滤);同快照文件行同步同一 chosen 值。 */
|
||||
odm_values?: Array<string>;
|
||||
chosen_odm_id?: string | null;
|
||||
odm_conflict?: boolean;
|
||||
}>;
|
||||
artifact?: { file_name?: string | null; status?: string | null } | null;
|
||||
} | null;
|
||||
@@ -2307,6 +2326,8 @@ export interface ShippingOrderReviewCaseSummary {
|
||||
intake_parse_authorized?: boolean;
|
||||
draft_version?: number | null;
|
||||
issue_count: number;
|
||||
/** 队列后端按当前门禁裁决:blocked_manual/blocked_retryable/failed_terminal 为 true;前端禁止自行推断阻塞。 */
|
||||
needs_attention?: boolean;
|
||||
available_actions: string[];
|
||||
/** 仅 parse_failed 时由后端下发,供当前阶段卡调用原 Intake retry API。 */
|
||||
intake_no?: string | null;
|
||||
|
||||
@@ -993,6 +993,47 @@ describe('ShippingOrderReviewView layout phase 1', () => {
|
||||
}
|
||||
});
|
||||
|
||||
it('reloads the intake parse context by requested Case when activeCase is unloaded (formal downstream)', async () => {
|
||||
// 用户场景:正式下游文件(货代上传 · 已创建任务)切进后 activeCase 为 null(选法 2),
|
||||
// 此时回看「接收解析」已完成阶段,上下文必须按 requestedCaseNo 发起请求;
|
||||
// 静默跳过会让 ReviewIntakeParsePanel 以空 context 渲染成整块空白。
|
||||
const originalQueue = reviewQueue.value;
|
||||
const originalActiveCase = activeCase.value;
|
||||
const originalRequested = requestedCaseNo.value;
|
||||
try {
|
||||
reviewQueue.value = {
|
||||
...reviewQueue.value,
|
||||
items: [{
|
||||
...reviewQueue.value.items[0],
|
||||
has_formal_ot: true,
|
||||
lifecycle_stage: 'freight_upload',
|
||||
lifecycle_entries: [
|
||||
{ code: 'intake_parse', state: 'available' },
|
||||
{ code: 'order_review', state: 'available' },
|
||||
{ code: 'fulfillment_prep', state: 'available' },
|
||||
{ code: 'freight_upload', state: 'current' },
|
||||
],
|
||||
}],
|
||||
};
|
||||
activeCase.value = null;
|
||||
requestedCaseNo.value = 'CASE-1';
|
||||
const wrapper = await mountView({ lifecycle_stage: 'freight_upload' });
|
||||
|
||||
ensureIntakeParseContextLoaded.mockClear();
|
||||
await (wrapper.vm as any).selectLifecycleStage('intake_parse');
|
||||
await flushPromises();
|
||||
|
||||
expect((wrapper.vm as { $route: { query: Record<string, string> } }).$route.query.lifecycle_stage)
|
||||
.toBe('intake_parse');
|
||||
// 关键断言:activeCase 为 null 时不得跳过上下文加载,且以目标 Case 请求。
|
||||
expect(ensureIntakeParseContextLoaded).toHaveBeenCalledWith('CASE-1');
|
||||
} finally {
|
||||
reviewQueue.value = originalQueue;
|
||||
activeCase.value = originalActiveCase;
|
||||
requestedCaseNo.value = originalRequested;
|
||||
}
|
||||
});
|
||||
|
||||
it('stops the pending reparse navigation when the user selects another PDF', async () => {
|
||||
const originalQueue = reviewQueue.value;
|
||||
try {
|
||||
|
||||
@@ -38,6 +38,7 @@ import {
|
||||
retryShippingNoticeIntake,
|
||||
decideWorkspaceShippingOrderReviewLineFulfillment,
|
||||
waveWorkspaceShippingOrderReviewLineFulfillment,
|
||||
setWorkspaceShippingTaskOdmChoice,
|
||||
viewWorkspaceShippingOrderReviewHighlightDiagnostic,
|
||||
} from '../api/shipping.api';
|
||||
import type {
|
||||
@@ -325,7 +326,9 @@ const lifecycleUiState = computed(() => {
|
||||
};
|
||||
}
|
||||
// [STEP 3] 建单前:Run/Queue 项仍由后端下发生命周期入口。
|
||||
const currentCaseNo = String(activeCase.value?.case_no || '').trim();
|
||||
// 选法 2(正式下游回看)下 activeCase 刻意为 null,此时以切换管线的 requestedCaseNo
|
||||
// 定位队列项,否则 entries 永远为空、阶段导航整体退化为 blocked。
|
||||
const currentCaseNo = String(activeCase.value?.case_no || requestedCaseNo.value || '').trim();
|
||||
const reviewEntry = (reviewQueue.value?.items || reviewRun.value?.items || []).find(
|
||||
(item) => String(item.case_no || '').trim() === currentCaseNo,
|
||||
);
|
||||
@@ -398,6 +401,13 @@ const intakeParseContextAuthorized = computed(() => {
|
||||
|| lifecycleEntryIsEnterable(entry)
|
||||
);
|
||||
});
|
||||
/**
|
||||
* 接收解析工作面的目标 Case:选法 2(正式下游回看)下 activeCase 刻意为 null,
|
||||
* 必须以切换管线的 requestedCaseNo 兜底,否则上下文加载会被静默跳过(面板空白)。
|
||||
*/
|
||||
const intakeTargetCaseNo = computed(() => (
|
||||
String(activeCase.value?.case_no || requestedCaseNo.value || '').trim()
|
||||
));
|
||||
const lifecycleStageItems = computed<ReviewLifecycleStageItem[]>(() => {
|
||||
const blocker = lifecycleUiState.value.blocker;
|
||||
const entries = lifecycleUiState.value.entries;
|
||||
@@ -483,8 +493,8 @@ async function retryCurrentIntakeParse(): Promise<void> {
|
||||
await Promise.all([
|
||||
reloadLatestDraft(),
|
||||
refreshShippingProcessing(),
|
||||
activeCase.value?.case_no
|
||||
? ensureIntakeParseContextLoaded(activeCase.value.case_no)
|
||||
intakeTargetCaseNo.value
|
||||
? ensureIntakeParseContextLoaded(intakeTargetCaseNo.value)
|
||||
: Promise.resolve(false),
|
||||
]);
|
||||
} catch (error) {
|
||||
@@ -575,8 +585,8 @@ async function selectLifecycleStage(code: ReviewLifecycleStageCode, options: { r
|
||||
pendingReleaseAutoAdvanceCaseNo.value = null;
|
||||
}
|
||||
}
|
||||
if (code === 'intake_parse' && intakeParseContextAuthorized.value && activeCase.value?.case_no) {
|
||||
void ensureIntakeParseContextLoaded(activeCase.value.case_no);
|
||||
if (code === 'intake_parse' && intakeParseContextAuthorized.value && intakeTargetCaseNo.value) {
|
||||
void ensureIntakeParseContextLoaded(intakeTargetCaseNo.value);
|
||||
}
|
||||
const mode: ReviewWorkbenchMode = code === 'order_review' || code === 'intake_parse'
|
||||
? 'standard'
|
||||
@@ -2643,6 +2653,38 @@ async function submitOverrideSource(line: { snapshot_line_id?: number | null; li
|
||||
}
|
||||
}
|
||||
|
||||
/** 整单 ODM 裁决列可见性:任一行候选多于一个时展示(候选已经客户范围过滤)。 */
|
||||
const formalPreparationOdmColumnVisible = computed(() =>
|
||||
(formalPreparationContext.value?.lines || []).some((line) => (line.odm_values?.length || 0) > 1),
|
||||
);
|
||||
const lineOdmSelections = ref<Record<string, string>>({});
|
||||
const lineOdmBusy = ref(false);
|
||||
|
||||
/**
|
||||
* 提交行级 ODM 选择:后端把同一快照文件的全部当前匹配行同步为同一值,
|
||||
* 刷新详情后其他行回显同步结果,并在门禁仍授权时自动重试生成 Excel。
|
||||
*/
|
||||
async function submitLineOdmChoice(line: { snapshot_line_id?: number | null }) {
|
||||
const selectionKey = String(line.snapshot_line_id ?? '');
|
||||
const odmId = String(lineOdmSelections.value[selectionKey] || '').trim();
|
||||
const taskNo = String(confirmedNoticeTaskNo.value || '').trim();
|
||||
if (!odmId || !taskNo || lineOdmBusy.value) return;
|
||||
lineOdmBusy.value = true;
|
||||
try {
|
||||
await setWorkspaceShippingTaskOdmChoice(taskNo, { snapshot_line_id: selectionKey, odm_id: odmId });
|
||||
delete lineOdmSelections.value[selectionKey];
|
||||
await loadFormalTaskDetail();
|
||||
const canRegenerate = formalTaskActions.value.some(
|
||||
(action) => action.enabled && String(action.code || '').trim() === 'regenerate_excel_artifact',
|
||||
);
|
||||
if (canRegenerate) await submitFormalGateAction('regenerate_excel_artifact');
|
||||
} catch (error) {
|
||||
msg.error(resolveReviewErrorMessage(error));
|
||||
} finally {
|
||||
lineOdmBusy.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function formalPreparationLineAllows(
|
||||
line: { snapshot_line_id?: number | null },
|
||||
action: 'retry_inventory_preparation' | 'retry_inventory_matching' | 'close_unfulfillable' | 'release_inventory_shortage',
|
||||
@@ -4397,7 +4439,14 @@ watch(
|
||||
);
|
||||
|
||||
watch(
|
||||
[lifecycleActiveStageCode, hasFormalOt, intakeParseContextAuthorized],
|
||||
[
|
||||
lifecycleActiveStageCode,
|
||||
hasFormalOt,
|
||||
intakeParseContextAuthorized,
|
||||
// 接收解析文件互切时 stage/授权通常不变;必须以 Case 变化触发新附件/邮件上下文重载,
|
||||
// 否则接收解析工作面停留上一份 PDF 的附件名且预览不再自动加载。
|
||||
() => String(activeCase.value?.case_no || '').trim(),
|
||||
],
|
||||
([code, , intakeAuthorized]) => {
|
||||
// 确认进度是当前阶段内的短暂辅助视图,不由生命周期页签覆盖。
|
||||
if (workbenchMode.value === 'confirm_progress') return;
|
||||
@@ -4405,8 +4454,8 @@ watch(
|
||||
// surface 反向成为前端阶段裁决。
|
||||
if (code === null) return;
|
||||
syncLifecycleWorkbenchMode(code);
|
||||
if (code === 'intake_parse' && intakeAuthorized && activeCase.value?.case_no) {
|
||||
void ensureIntakeParseContextLoaded(activeCase.value.case_no);
|
||||
if (code === 'intake_parse' && intakeAuthorized && intakeTargetCaseNo.value) {
|
||||
void ensureIntakeParseContextLoaded(intakeTargetCaseNo.value);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
@@ -4487,10 +4536,15 @@ function retryFormalTaskDetail() {
|
||||
*/
|
||||
const REVIEW_EDITOR_NEEDED_STAGES: ReviewLifecycleStageCode[] = ['intake_parse', 'order_review', 'fulfillment_prep'];
|
||||
watch(
|
||||
lifecycleCurrentStageCode,
|
||||
// 用户查看面(含回看已完成阶段)驱动 Case 懒加载:选法 2 正式下游切 PDF 后 activeCase
|
||||
// 为 null,回看接收解析/订单复核/通知准备时必须按需补拉目标 Case,否则这些工作面
|
||||
// 只能渲染空白或残留上一份 PDF 的数据。
|
||||
lifecycleActiveStageCode,
|
||||
(stage) => {
|
||||
if (!stage || !REVIEW_EDITOR_NEEDED_STAGES.includes(stage)) return;
|
||||
const caseNo = String(displayCase.value?.case_no || '').trim();
|
||||
// 禁止使用 displayCase 兜底:它可能停留在上一份 PDF 的快照上造成串味;
|
||||
// 目标一律取当前工作面的 activeCase 或切换管线的 requestedCaseNo。
|
||||
const caseNo = String(activeCase.value?.case_no || requestedCaseNo.value || '').trim();
|
||||
if (!caseNo) return;
|
||||
if (stage === 'fulfillment_prep') {
|
||||
if (activeCase.value) return;
|
||||
@@ -4857,12 +4911,12 @@ watch(
|
||||
class="rounded-full bg-brand-50 px-2.5 py-1 text-xs font-medium text-brand-700 dark:bg-brand-950/30 dark:text-brand-300"
|
||||
>{{ formalPreparationStatusLabel(formalPreparationContext?.status) }}</span>
|
||||
</div>
|
||||
<div v-if="formalPreparationDisplayLines.length" class="review-fulfillment-prep-workspace mt-4 rounded-lg border border-default" data-testid="review-fulfillment-prep-workspace">
|
||||
<!-- 标题与选行操作条固定不参与横向滚动,仅表头/表体横向滑动。 -->
|
||||
<div class="flex items-center justify-between gap-3 border-b border-default bg-surface-muted/30 px-3 py-2">
|
||||
<div class="text-xs font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.prepare.matchWorkspace') }}</div>
|
||||
<span class="text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineCount', { count: formalPreparationDisplayLines.length }) }}</span>
|
||||
</div>
|
||||
<div v-if="formalPreparationDisplayLines.length" class="review-fulfillment-prep-workspace mt-4 rounded-lg border border-default" data-testid="review-fulfillment-prep-workspace">
|
||||
<!-- 标题与选行操作条固定不参与横向滚动,仅表头/表体横向滑动。 -->
|
||||
<div class="flex items-center justify-between gap-3 border-b border-default bg-surface-muted/30 px-3 py-2">
|
||||
<div class="text-xs font-semibold text-primary">{{ t('chat.shippingOrderReview.lifecycle.prepare.matchWorkspace') }}</div>
|
||||
<span class="text-xs text-secondary">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineCount', { count: formalPreparationDisplayLines.length }) }}</span>
|
||||
</div>
|
||||
<div v-if="preparationEditable && formalHeaderEditable()" class="flex flex-wrap items-center justify-between gap-2 border-b border-default bg-brand-50/50 px-3 py-2 text-xs dark:bg-brand-950/20">
|
||||
<div class="flex items-center gap-3 text-secondary">
|
||||
<span class="font-medium">{{ t('chat.shippingOrderReview.fulfillmentDecision.selectReady') }}</span>
|
||||
@@ -4872,8 +4926,8 @@ watch(
|
||||
</div>
|
||||
<div class="overflow-x-auto overscroll-x-contain" data-testid="review-fulfillment-prep-table-scroll">
|
||||
<table class="review-fulfillment-prep-table min-w-[1060px] text-xs">
|
||||
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
|
||||
<tbody><tr v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.selected_source_code || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) }}</span></td><td class="whitespace-nowrap px-3 py-2">{{ line.available_qty ?? '—' }}</td><td class="whitespace-nowrap px-3 py-2 font-medium" :class=Line truncated
|
||||
<thead class="border-b border-default bg-surface-muted/50 text-left"><tr><th v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="allPreparationWaveSelected" :disabled="!preparationWaveSelectableLines.length || preparationWaveBusy" :aria-label="t('chat.shippingOrderReview.fulfillmentDecision.selectReady')" @change="toggleAllPreparationLineSelection(($event.target as HTMLInputElement).checked)"></th><th v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationCustomerPoLineLabel() }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultReservation') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.workbench.resultPartNumber') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.requiredQty') }}</th><th class="px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.inventorySource') }}</th><th v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.odmConflict.column') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.availableQty') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.fulfillmentDecision.shortage') }}</th><th class="whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lifecycle.prepare.lineStatus') }}</th><th class="review-fulfillment-sticky-action-head whitespace-nowrap px-3 py-2">{{ t('chat.shippingOrderReview.lineOps.moreActions') }}</th></tr></thead>
|
||||
<tbody><tr v-for="(line, lineIndex) in formalPreparationDisplayLines" :key="line.snapshot_line_id || `${line.reservation_id}-${line.part_number}`" :class="Number(line.shortage_qty || 0) > 0 ? 'border-b border-amber-100 bg-amber-50/40 last:border-0 dark:border-amber-950 dark:bg-amber-950/10' : 'border-b border-default last:border-0'"><td v-if="preparationEditable" class="w-10 px-3 py-2"><input type="checkbox" class="rounded border-default" :checked="selectedPreparationSnapshotLineIds.includes(String(line.snapshot_line_id))" :disabled="preparationWaveBusy || !preparationWaveSelectableLines.some((item) => String(item.snapshot_line_id) === String(line.snapshot_line_id))" :aria-label="`${t('chat.shippingOrderReview.fulfillmentDecision.selectReady')}: ${preparationLineCustomerPoLine(line)}`" :data-testid="`review-fulfillment-line-select-${line.snapshot_line_id || lineIndex}`" @change="togglePreparationLineSelection(String(line.snapshot_line_id || lineIndex), ($event.target as HTMLInputElement).checked)"></td><td v-if="preparationCustomerPoLineVisible" class="whitespace-nowrap px-3 py-2">{{ preparationLineCustomerPoLine(line) }}</td><td class="whitespace-nowrap px-3 py-2 font-medium text-primary">{{ line.reservation_id || '—' }}</td><td class="max-w-[220px] truncate px-3 py-2" :title="line.part_number || '—'">{{ line.part_number || '—' }}</td><td class="whitespace-nowrap px-3 py-2">{{ line.required_qty ?? '—' }}</td><td class="max-w-[220px] px-3 py-2"><div v-if="line.source_ambiguous && !formalPreparationSourceLocked" class="flex items-center gap-1" :data-testid="`review-line-source-ambiguous-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceAmbiguous')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.source_code || ''" @change="lineSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="code in line.source_candidates || []" :key="code" :value="code">{{ lineSourceOptionLabel(code) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!lineSourceSelections[String(line.snapshot_line_id || lineIndex)] || lineSourceBusy || !preparationEditable" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" @click="submitLineSourceSelection(line)"><Check class="h-3.5 w-3.5" /></button></div><span v-else-if="line.source_ambiguous && formalPreparationSourceLocked" class="text-xs text-secondary" :title="t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked')">{{ t('chat.shippingOrderReview.lifecycle.prepare.sourceLocked') }}</span><span v-else-if="!formalPreparationSourceLocked && formSourceOptions.length" class="flex items-center gap-1" :data-testid="`review-line-source-override-${line.snapshot_line_id || lineIndex}`" :title="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')"><select class="min-w-0 flex-1 rounded border border-default bg-surface px-1.5 py-1 text-xs" :data-testid="`review-line-source-override-select-${line.snapshot_line_id || lineIndex}`" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :value="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || line.selected_source_code || line.source_code || ''" @change="overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] = ($event.target as HTMLSelectElement).value"><option value="" disabled>{{ t('chat.shippingOrderReview.lifecycle.prepare.selectSource') }}</option><option v-for="s in formSourceOptions" :key="String(s.source_code)" :value="String(s.source_code)">{{ overrideSourceOptionLabel(String(s.source_code)) }}</option></select><button type="button" class="rounded bg-brand-600 px-2 py-1 text-xs font-medium text-white disabled:opacity-50" :data-testid="`review-line-source-override-confirm-${line.snapshot_line_id || lineIndex}`" :disabled="!overrideSourceSelections[String(line.snapshot_line_id || lineIndex)] || overrideSourceBusy" :aria-label="t('chat.shippingOrderReview.lifecycle.prepare.selectSource')" :data-line-index="lineIndex" @click="submitOverrideSource(line)"><Check class="h-3.5 w-3.5" /></button></span><span v-else class="block max-w-[220px] truncate" :title="formalPreparationLineSource(line)">{{ formalPreparationLineSource(line) }}</span></td><td v-if="formalPreparationOdmColumnVisible" class="whitespace-nowrap px-3 py-2"><div v-if="(line.odm_values?.length || 0) > 1 && !formalLine truncated
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
@@ -5079,8 +5133,8 @@ watch(
|
||||
:load-failed="intakeParseLoadFailed"
|
||||
:preview-url="previewUrl || null"
|
||||
:preview-loading="previewLoading"
|
||||
@retry-context="() => { if (activeCase?.case_no) void ensureIntakeParseContextLoaded(activeCase.case_no); }"
|
||||
@load-preview="() => { if (activeCase?.case_no) void ensurePreviewLoaded(activeCase.case_no); }"
|
||||
@retry-context="() => { if (intakeTargetCaseNo) void ensureIntakeParseContextLoaded(intakeTargetCaseNo); }"
|
||||
@load-preview="() => { if (intakeTargetCaseNo) void ensurePreviewLoaded(intakeTargetCaseNo); }"
|
||||
/>
|
||||
<!-- 仅「固定为侧栏」时 PDF 占网格列;默认浮窗挂在根节点,不挤压订单区。 -->
|
||||
<div
|
||||
|
||||
@@ -58,16 +58,21 @@ onMounted(() => { void Promise.all([admin.loadCustomers(), admin.loadShadowRepor
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.name') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.shortCode') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.status') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.odmIds') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.identityEvidences') }}</th>
|
||||
<th class="px-5 py-4 text-left">{{ t('admin.shippingCustomers.headers.notices') }}</th>
|
||||
<th class="px-5 py-4 text-right">{{ t('admin.shippingCustomers.headers.actions') }}</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-if="admin.customers.value.length === 0"><td colspan="6" class="admin-table-empty px-5">{{ t('admin.shippingCustomers.empty') }}</td></tr>
|
||||
<tr v-if="admin.customers.value.length === 0"><td colspan="7" class="admin-table-empty px-5">{{ t('admin.shippingCustomers.empty') }}</td></tr>
|
||||
<tr v-for="customer in admin.customers.value" :key="customer.id">
|
||||
<td class="px-5 py-4"><div class="font-medium text-primary">{{ customer.standard_name }}</div><div v-if="customer.remark" class="text-xs text-muted truncate max-w-sm">{{ customer.remark }}</div></td>
|
||||
<td class="px-5 py-4 font-mono text-sm">{{ customer.short_code }}</td>
|
||||
<td class="px-5 py-4"><span class="text-sm" :class="customer.status === 'active' ? 'text-emerald-600' : 'text-muted'">{{ t(`admin.shippingCustomers.status.${customer.status}`) }}</span></td>
|
||||
<td class="px-5 py-4 text-sm">
|
||||
<span v-if="customer.odm_ids?.length" class="font-mono text-xs">{{ customer.odm_ids.join(', ') }}</span>
|
||||
<span v-else class="text-xs text-muted">{{ t('admin.shippingCustomers.fields.odmIdsUnlimited') }}</span>
|
||||
</td>
|
||||
<td class="px-5 py-4 text-sm">{{ customer.identity_evidence_count || 0 }}</td>
|
||||
<td class="px-5 py-4 text-sm">{{ customer.notice_count }}</td>
|
||||
<td class="px-5 py-4"><div class="flex justify-end gap-1">
|
||||
|
||||
@@ -42,6 +42,16 @@ const { t } = useI18n();
|
||||
<span class="label-field">{{ t('admin.shippingCustomers.fields.remark') }}</span>
|
||||
<textarea v-model="form.remark" rows="3" class="input-field text-sm resize-y" />
|
||||
</label>
|
||||
<label class="block space-y-1.5">
|
||||
<span class="label-field">{{ t('admin.shippingCustomers.fields.odmIds') }}</span>
|
||||
<textarea
|
||||
v-model="form.odm_ids_text"
|
||||
rows="3"
|
||||
class="input-field text-sm resize-y font-mono"
|
||||
:placeholder="t('admin.shippingCustomers.fields.odmIdsHint')"
|
||||
/>
|
||||
<span class="text-xs text-muted">{{ t('admin.shippingCustomers.fields.odmIdsHint') }}</span>
|
||||
</label>
|
||||
<label v-if="form.id" class="block space-y-1.5">
|
||||
<span class="label-field">{{ t('admin.shippingCustomers.fields.changeReason') }}</span>
|
||||
<textarea v-model="form.reason" rows="2" class="input-field text-sm resize-y" :placeholder="t('admin.shippingCustomers.fields.changeReasonHint')" />
|
||||
|
||||
+10
@@ -158,11 +158,21 @@ export function useShippingCustomersAdmin() {
|
||||
}
|
||||
isSaving.value = true;
|
||||
try {
|
||||
// ODM ID 清单:文本域逐行解析,去空去重;整体为空提交 null 表示不限定。
|
||||
const odmIds = Array.from(
|
||||
new Set(
|
||||
form.odm_ids_text
|
||||
.split(/\r?\n/)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean),
|
||||
),
|
||||
);
|
||||
const payload = {
|
||||
standard_name: form.standard_name.trim(),
|
||||
short_code: form.short_code.trim().toUpperCase(),
|
||||
status: form.status,
|
||||
remark: form.remark.trim(),
|
||||
odm_ids: odmIds.length ? odmIds : null,
|
||||
reason: form.reason.trim(),
|
||||
};
|
||||
if (form.id) await updateShippingCustomer(form.id, payload);
|
||||
|
||||
@@ -29,6 +29,8 @@ export interface ShippingCustomerRow {
|
||||
status: ShippingCustomerStatus;
|
||||
merged_into_customer_id?: number | null;
|
||||
remark?: string | null;
|
||||
/** 客户可用的 ODM ID 清单;null/空数组表示不限定。 */
|
||||
odm_ids?: string[] | null;
|
||||
notice_count: number;
|
||||
identifier_count: number;
|
||||
identity_evidence_count?: number;
|
||||
@@ -282,6 +284,8 @@ export interface ShippingCustomerFormState {
|
||||
short_code: string;
|
||||
status: ShippingCustomerStatus;
|
||||
remark: string;
|
||||
/** 文本域原文:每行一个 ODM ID;保存时解析为 odm_ids 数组。 */
|
||||
odm_ids_text: string;
|
||||
reason: string;
|
||||
}
|
||||
|
||||
@@ -309,6 +313,7 @@ export const createEmptyShippingCustomerForm = (): ShippingCustomerFormState =>
|
||||
short_code: '',
|
||||
status: 'active',
|
||||
remark: '',
|
||||
odm_ids_text: '',
|
||||
reason: '',
|
||||
});
|
||||
|
||||
@@ -319,6 +324,7 @@ export const shippingCustomerToForm = (customer: ShippingCustomerRow): ShippingC
|
||||
short_code: customer.short_code,
|
||||
status: customer.status,
|
||||
remark: customer.remark || '',
|
||||
odm_ids_text: (customer.odm_ids || []).join('\n'),
|
||||
reason: '',
|
||||
});
|
||||
|
||||
|
||||
@@ -24,11 +24,57 @@ export interface ShippingMyTodosCount {
|
||||
processing: number;
|
||||
done: number;
|
||||
total_pending_badge: number;
|
||||
/** 待处理桶按可动作生命周期阶段的全量聚合计数(阶段筛选 tab)。 */
|
||||
stage_counts?: {
|
||||
intake_parse: number;
|
||||
order_review: number;
|
||||
fulfillment_prep: number;
|
||||
freight_upload: number;
|
||||
};
|
||||
/** done 桶终态拆分:通知完成 vs 复核驳回/作废。 */
|
||||
done_counts?: {
|
||||
upload_complete: number;
|
||||
reject_void: number;
|
||||
};
|
||||
}
|
||||
|
||||
/** 已完成通知明细行(通知完成报表):标准 12 字段 + 溯源编号。 */
|
||||
export interface ShippingDoneLineItem {
|
||||
task_no: string;
|
||||
business_no: string | null;
|
||||
customer_name: string | null;
|
||||
customer_code: string | null;
|
||||
order_date: string | null;
|
||||
line_no: number;
|
||||
part_number: string | null;
|
||||
qty: number | null;
|
||||
required_date: string | null;
|
||||
customer_po_number: string | null;
|
||||
/** 无数据源,契约占位恒为 null(页面与导出留空)。 */
|
||||
used_qty: number | null;
|
||||
open_qty: number | null;
|
||||
source_order_number: string | null;
|
||||
unit_price: number | null;
|
||||
}
|
||||
|
||||
export interface ShippingDoneLinesPage {
|
||||
items: ShippingDoneLineItem[];
|
||||
page: number;
|
||||
page_size: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ShippingDoneLineFilters {
|
||||
customer?: string;
|
||||
part_number?: string;
|
||||
notice_date_from?: string;
|
||||
notice_date_to?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取「我的待办」。
|
||||
* @param params.bucket - pending | processing | done
|
||||
* @param params.terminal_kind - done 桶终态子视图(upload_complete | reject_void)
|
||||
*/
|
||||
export function listWorkspaceShippingMyTodos(params?: {
|
||||
bucket?: 'pending' | 'processing' | 'done' | string;
|
||||
@@ -37,6 +83,7 @@ export function listWorkspaceShippingMyTodos(params?: {
|
||||
todo_category?: string;
|
||||
customer?: string;
|
||||
task_no?: string;
|
||||
terminal_kind?: string;
|
||||
}) {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.bucket) sp.set('bucket', params.bucket);
|
||||
@@ -45,6 +92,7 @@ export function listWorkspaceShippingMyTodos(params?: {
|
||||
if (params?.todo_category) sp.set('todo_category', params.todo_category);
|
||||
if (params?.customer) sp.set('customer', params.customer);
|
||||
if (params?.task_no) sp.set('task_no', params.task_no);
|
||||
if (params?.terminal_kind) sp.set('terminal_kind', params.terminal_kind);
|
||||
const q = sp.toString();
|
||||
return requestJson<ShippingMyTodosPage>(
|
||||
`/api/workspace/shipping-tasks/my-todos${q ? `?${q}` : ''}`,
|
||||
@@ -58,6 +106,68 @@ export function countWorkspaceShippingMyTodos() {
|
||||
return requestJson<ShippingMyTodosCount>('/api/workspace/shipping-tasks/my-todos/count');
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取已完成通知的平铺明细行(通知完成报表)。
|
||||
* 明细行跨 Notice 混排、不按 OT 聚合,仅含已核验上传成功的通知。
|
||||
*/
|
||||
export function listWorkspaceShippingDoneLines(params?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
} & ShippingDoneLineFilters) {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.page) sp.set('page', String(params.page));
|
||||
if (params?.page_size) sp.set('page_size', String(params.page_size));
|
||||
if (params?.customer) sp.set('customer', params.customer);
|
||||
if (params?.part_number) sp.set('part_number', params.part_number);
|
||||
if (params?.notice_date_from) sp.set('notice_date_from', params.notice_date_from);
|
||||
if (params?.notice_date_to) sp.set('notice_date_to', params.notice_date_to);
|
||||
const q = sp.toString();
|
||||
return requestJson<ShippingDoneLinesPage>(
|
||||
`/api/workspace/shipping-tasks/my-todos/done-lines${q ? `?${q}` : ''}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载当前筛选下的已完成通知明细 Excel(固定 12 列标准格式,不含 OT 编号)。
|
||||
* 核心逻辑:浏览器受控 a[download] 下载,后端复核可见性与筛选参数。
|
||||
*/
|
||||
export async function downloadWorkspaceShippingDoneLinesExcel(
|
||||
filters?: ShippingDoneLineFilters,
|
||||
): Promise<void> {
|
||||
const sp = new URLSearchParams();
|
||||
if (filters?.customer) sp.set('customer', filters.customer);
|
||||
if (filters?.part_number) sp.set('part_number', filters.part_number);
|
||||
if (filters?.notice_date_from) sp.set('notice_date_from', filters.notice_date_from);
|
||||
if (filters?.notice_date_to) sp.set('notice_date_to', filters.notice_date_to);
|
||||
const q = sp.toString();
|
||||
const url = `/api/workspace/shipping-tasks/my-todos/done-lines/export${q ? `?${q}` : ''}`;
|
||||
const { getAuthHeaders } = await import('@/shared/utils/auth');
|
||||
const res = await fetch(url, { headers: getAuthHeaders() });
|
||||
if (!res.ok) {
|
||||
const body = await res.json().catch(() => ({}));
|
||||
throw new Error(
|
||||
(body as { error?: string; message?: string })?.error
|
||||
|| (body as { message?: string })?.message
|
||||
|| res.statusText,
|
||||
);
|
||||
}
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
const blob = await res.blob();
|
||||
const objectUrl = URL.createObjectURL(blob);
|
||||
const anchor = document.createElement('a');
|
||||
anchor.href = objectUrl;
|
||||
const rawName = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || 'done-lines.xlsx';
|
||||
try {
|
||||
anchor.download = decodeURIComponent(rawName);
|
||||
} catch {
|
||||
anchor.download = rawName;
|
||||
}
|
||||
document.body.appendChild(anchor);
|
||||
anchor.click();
|
||||
document.body.removeChild(anchor);
|
||||
URL.revokeObjectURL(objectUrl);
|
||||
}
|
||||
|
||||
export {
|
||||
downloadWorkspaceShippingExcelFile,
|
||||
markWorkspaceShippingManualUploaded,
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingDoneLineReport.vue
|
||||
用途:已完成桶「通知完成」子视图——跨 OT 平铺的明细行报表(13 列 + 筛选 + 导出)。
|
||||
依赖:shipping-tasks.api 类型;导出下载由父级执行。
|
||||
逻辑:只读报表(无抽屉、无行操作);首列 OT/business 编号仅页面展示,
|
||||
导出为固定 12 列标准格式(后端裁决);分页按明细行计。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { Download } from 'lucide-vue-next';
|
||||
import type { ShippingDoneLineItem } from '@/features/workspace/api/shipping-tasks.api';
|
||||
import type { ShippingDoneLineFilters } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
const props = defineProps<{
|
||||
items: ShippingDoneLineItem[];
|
||||
total: number;
|
||||
page: number;
|
||||
pageSize: number;
|
||||
loading?: boolean;
|
||||
exportBusy?: boolean;
|
||||
filters?: ShippingDoneLineFilters;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:filters', value: ShippingDoneLineFilters): void;
|
||||
(event: 'apply'): void;
|
||||
(event: 'page-change', page: number): void;
|
||||
(event: 'export'): void;
|
||||
}>();
|
||||
|
||||
const totalPages = () => Math.max(1, Math.ceil(props.total / props.pageSize));
|
||||
|
||||
function setFilter(key: keyof ShippingDoneLineFilters, event: Event) {
|
||||
const value = String((event.target as HTMLInputElement).value || '');
|
||||
emit('update:filters', { ...props.filters, [key]: value });
|
||||
}
|
||||
|
||||
function onExport(): void {
|
||||
emit('export');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-3">
|
||||
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-3">
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.customer') }}</span>
|
||||
<input
|
||||
type="text"
|
||||
class="input-field text-sm min-w-[10rem]"
|
||||
:value="filters?.customer || ''"
|
||||
:placeholder="$t('workspace.shippingNotice.myTodos.filters.customerPlaceholder')"
|
||||
data-testid="done-lines-filter-customer"
|
||||
@change="setFilter('customer', $event)"
|
||||
@keyup.enter="emit('apply')"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.partNumber') }}</span>
|
||||
<input
|
||||
type="text"
|
||||
class="input-field text-sm min-w-[10rem]"
|
||||
:value="filters?.part_number || ''"
|
||||
data-testid="done-lines-filter-part"
|
||||
@change="setFilter('part_number', $event)"
|
||||
@keyup.enter="emit('apply')"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.dateFrom') }}</span>
|
||||
<input
|
||||
type="date"
|
||||
class="input-field text-sm"
|
||||
:value="filters?.notice_date_from || ''"
|
||||
data-testid="done-lines-filter-date-from"
|
||||
@change="setFilter('notice_date_from', $event)"
|
||||
>
|
||||
</label>
|
||||
<label class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.doneReport.filters.dateTo') }}</span>
|
||||
<input
|
||||
type="date"
|
||||
class="input-field text-sm"
|
||||
:value="filters?.notice_date_to || ''"
|
||||
data-testid="done-lines-filter-date-to"
|
||||
@change="setFilter('notice_date_to', $event)"
|
||||
>
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="loading"
|
||||
@click="emit('apply')"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.filters.apply') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-brand-300 px-3 py-1.5 text-sm font-medium text-brand-700 hover:bg-brand-50 disabled:opacity-50"
|
||||
:disabled="exportBusy || loading || !total"
|
||||
data-testid="done-lines-export"
|
||||
@click="onExport"
|
||||
>
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.doneReport.export') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!items.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.empty') }}
|
||||
</div>
|
||||
<div v-else class="overflow-x-auto rounded-2xl border border-default bg-surface">
|
||||
<table class="w-full min-w-[1200px] border-collapse text-[13px]" data-testid="done-lines-table">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft/60 text-left text-xs text-muted">
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.taskNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.customer') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.customerCode') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.orderDate') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.lineNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.partNumber') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.qty') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.requiredDate') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.customerPo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.usedQty') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.openQty') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.sourceOrderNo') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.doneReport.columns.unitPrice') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="line in items"
|
||||
:key="`${line.task_no}-${line.line_no}`"
|
||||
class="border-b border-[#f0f3f8]"
|
||||
>
|
||||
<td class="px-3 py-2 font-mono text-xs font-semibold text-primary">
|
||||
{{ line.business_no || line.task_no }}
|
||||
</td>
|
||||
<td class="px-3 py-2">{{ line.customer_name || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.customer_code || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.order_date || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.line_no }}</td>
|
||||
<td class="px-3 py-2 font-mono">{{ line.part_number || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.qty ?? '' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.required_date || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.customer_po_number || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.used_qty ?? '' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.open_qty ?? '' }}</td>
|
||||
<td class="px-3 py-2 font-mono">{{ line.source_order_number || '—' }}</td>
|
||||
<td class="px-3 py-2 tabular-nums">{{ line.unit_price ?? '' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-if="totalPages() > 1" class="flex items-center justify-between gap-2 text-xs text-muted">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
|
||||
:disabled="page <= 1 || loading"
|
||||
@click="emit('page-change', page - 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.previous') }}
|
||||
</button>
|
||||
<span>{{ page }}/{{ totalPages() }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
|
||||
:disabled="page >= totalPages() || loading"
|
||||
@click="emit('page-change', page + 1)"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,63 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingStageTabs.vue
|
||||
用途:阶段筛选 tab(全部 + 四个可动作阶段),计数来自后端全量聚合。
|
||||
依赖:shippingTaskCenterShared 的 ACTIONABLE_TODO_STAGES 口径。
|
||||
逻辑:点击切换筛选并向上同步;「通知完成」不再作为筛选维度(归 done 桶终态子视图)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ACTIONABLE_TODO_STAGES, type LifecycleStageCode } from './shippingTaskCenterShared';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
modelValue: 'all' | LifecycleStageCode;
|
||||
/** 后端聚合的阶段计数(缺省按 0 展示)。 */
|
||||
counts?: Partial<Record<LifecycleStageCode, number>>;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:modelValue', value: 'all' | LifecycleStageCode): void;
|
||||
}>();
|
||||
|
||||
function countOf(stage: LifecycleStageCode): number {
|
||||
return Number(props.counts?.[stage] ?? 0);
|
||||
}
|
||||
|
||||
function stageLabel(stage: LifecycleStageCode): string {
|
||||
return t(`workspace.shippingNotice.myTodos.lifecycleStages.${stage}`);
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
class="flex flex-wrap gap-2"
|
||||
data-testid="my-todos-lifecycle-stage-filter"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-3.5 py-1.5 text-sm font-medium transition-colors"
|
||||
:class="modelValue === 'all'
|
||||
? 'bg-brand-600 text-white'
|
||||
: 'border border-default text-secondary hover:bg-surface-soft'"
|
||||
data-testid="my-todos-stage-filter-all"
|
||||
@click="emit('update:modelValue', 'all')"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.filters.all') }}
|
||||
</button>
|
||||
<button
|
||||
v-for="stage in ACTIONABLE_TODO_STAGES"
|
||||
:key="stage"
|
||||
type="button"
|
||||
class="rounded-full px-3.5 py-1.5 text-sm font-medium transition-colors"
|
||||
:class="modelValue === stage
|
||||
? 'bg-brand-600 text-white'
|
||||
: 'border border-default text-secondary hover:bg-surface-soft'"
|
||||
:data-testid="`my-todos-stage-filter-${stage}`"
|
||||
@click="emit('update:modelValue', stage)"
|
||||
>
|
||||
{{ stageLabel(stage) }}
|
||||
<span class="ml-1 font-mono text-xs opacity-80">{{ countOf(stage) }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</template>
|
||||
+151
-30
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskCenterPage.notice-batch.spec.ts
|
||||
* 用途:验收任务中心只按发货通知单 business_no 展示与执行货代批量操作。
|
||||
* 用途:验收任务中心改版——紧凑表格、货代上传阶段限定批量、阶段 tab 后端计数、
|
||||
* done 桶子视图(通知完成明细报表 / 驳回作废任务表)与详情抽屉。
|
||||
* 依赖:ShippingTaskCenterPage、货代 API、我的待办 API、Vue Test Utils。
|
||||
* 逻辑:正式 Notice 可选择并传 business_nos;Review/Intake 不能进入选择集;列表行只显示服务端投影的通知明细。
|
||||
* 逻辑:批量仅正式 Notice 且货代上传阶段可选;明细行详情进抽屉(Teleport 到 body);
|
||||
* 通知完成子视图消费 done-lines 平铺报表;驳回作废子视图带 terminal_kind 过滤。
|
||||
*/
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { flushPromises, mount } from '@vue/test-utils';
|
||||
@@ -14,6 +16,11 @@ const batchConfirm = vi.fn(async () => ({ results: [{ status: 'confirmed' }] }))
|
||||
const batchRpa = vi.fn(async () => ({ results: [{ status: 'accepted' }] }));
|
||||
const downloadArchive = vi.fn(async () => undefined);
|
||||
const listTodos = vi.fn(async () => ({ items: [], page: 1, page_size: 20, total: 0 }));
|
||||
const listDoneLines = vi.fn(async () => ({ items: [], page: 1, page_size: 50, total: 0 }));
|
||||
const downloadDoneLinesExcel = vi.fn(async () => undefined);
|
||||
const countTodos = vi.fn(async () => ({
|
||||
pending: 0, processing: 0, done: 0, total_pending_badge: 0,
|
||||
}));
|
||||
|
||||
vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
SHIPPING_NOTICE_AGENT_CODE: 'shipping_notice',
|
||||
@@ -26,7 +33,9 @@ vi.mock('@/features/chat/api/shipping.api', () => ({
|
||||
|
||||
vi.mock('@/features/workspace/api/shipping-tasks.api', () => ({
|
||||
listWorkspaceShippingMyTodos: (...args: unknown[]) => listTodos(...args),
|
||||
countWorkspaceShippingMyTodos: vi.fn(async () => ({ pending: 0, processing: 0, done: 0, total_pending_badge: 0 })),
|
||||
countWorkspaceShippingMyTodos: (...args: unknown[]) => countTodos(...args),
|
||||
listWorkspaceShippingDoneLines: (...args: unknown[]) => listDoneLines(...args),
|
||||
downloadWorkspaceShippingDoneLinesExcel: (...args: unknown[]) => downloadDoneLinesExcel(...args),
|
||||
}));
|
||||
|
||||
vi.mock('@/features/workspace/composables/useShippingTodoBadge', () => ({
|
||||
@@ -53,6 +62,7 @@ const i18n = createI18n({
|
||||
subtitle: '按文件查看进度',
|
||||
lifecycleStages: {
|
||||
filterLabel: '阶段',
|
||||
viewStage: '查看阶段',
|
||||
intake_parse: '接收解析',
|
||||
order_review: '订单复核',
|
||||
fulfillment_prep: '通知准备',
|
||||
@@ -60,6 +70,12 @@ const i18n = createI18n({
|
||||
upload_complete: '通知完成',
|
||||
},
|
||||
buckets: { pending: '待处理', processing: '处理中', done: '已完成' },
|
||||
subTabs: { uploadComplete: '通知完成', rejectVoid: '复核驳回 / 已作废' },
|
||||
table: {
|
||||
no: '编号', stage: '阶段', summary: '状态摘要', lines: '项次',
|
||||
lineUnit: '项', shortage: '缺 {count}', freightStatus: '货代状态',
|
||||
},
|
||||
terminal: { uploadComplete: '上传完成', rejectVoid: '复核驳回' },
|
||||
filters: {
|
||||
todoCategory: '待办类型', all: '全部', review: '待复核', exception: '异常',
|
||||
manualUpload: '人工上传', intakeParse: '接收解析', customer: '客户',
|
||||
@@ -75,9 +91,44 @@ const i18n = createI18n({
|
||||
intakeParseBadge: '材料解析',
|
||||
progressSummary: '当前阶段:{stage}',
|
||||
progressBlocker: '当前阻断:{reason}',
|
||||
viewStage: '查看阶段',
|
||||
drawer: {
|
||||
details: '逐行明细',
|
||||
files: '文件',
|
||||
close: '关闭',
|
||||
exportExcel: '导出 Excel',
|
||||
lineTable: {
|
||||
lineNo: '行', partNumber: '料号', customerPartNumber: '客户料号',
|
||||
reservationId: '预约号', shipmentQty: '本次发货', availableQty: '可用库存',
|
||||
shortageQty: '缺口', status: '状态',
|
||||
},
|
||||
},
|
||||
doneReport: {
|
||||
export: '导出 Excel(当前筛选)',
|
||||
exportStarted: '已开始下载',
|
||||
filters: { customer: '客户', partNumber: '料号', dateFrom: '通知日期起', dateTo: '通知日期止' },
|
||||
columns: {
|
||||
taskNo: 'OT 编号', customer: '客户', customerCode: '客户编号', orderDate: '订单日期',
|
||||
lineNo: '订单项次', partNumber: '料号', qty: '数量', requiredDate: '约定出货日期',
|
||||
customerPo: '客户PO', usedQty: '已用数量', openQty: 'open qty',
|
||||
sourceOrderNo: '订单单号', unitPrice: '单价',
|
||||
},
|
||||
},
|
||||
},
|
||||
openChat: '打开对话',
|
||||
batch: {
|
||||
selectAll: '全选当前页通知单',
|
||||
selected: '已选 {count} 张',
|
||||
download: '批量下载 Excel',
|
||||
confirm: '批量确认已上传',
|
||||
rpa: '批量发起 RPA',
|
||||
clearSelection: '清除选择',
|
||||
downloadStarted: '已开始下载',
|
||||
success: '成功 {count} 张',
|
||||
partialResult: '部分成功 {accepted}/{accepted}/{blocked}',
|
||||
},
|
||||
todo: { adminViewOnlyShort: '只读' },
|
||||
actions: { failed: '操作失败' },
|
||||
pagination: { previous: '上一页', next: '下一页' },
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -90,12 +141,17 @@ const routes = [{
|
||||
component: ShippingTaskCenterPage,
|
||||
}];
|
||||
|
||||
/** 待处理货代上传阶段 Notice:批量可选 + 列表投影。 */
|
||||
function notice(businessNo: string, poNumber: string, partNumber: string) {
|
||||
return {
|
||||
id: Number(businessNo.slice(-2)), task_no: `SN-${businessNo}`, business_no: businessNo,
|
||||
item_kind: 'task', todo_ref: `SN-${businessNo}`, source_type: 'post_ot_fulfillment_wave',
|
||||
po_number: poNumber, customer_name: 'Customer', upload_status: 'pending',
|
||||
notice_line_summary: [{ line_no: '10', part_number: partNumber, shipment_qty: '4', available_qty: '9' }],
|
||||
ui_state: { stage: { code: 'freight_upload', label: '货代上传' }, lifecycle_entries: [] },
|
||||
notice_line_summary: [
|
||||
{ line_no: '10', part_number: partNumber, shipment_qty: '4', available_qty: '9' },
|
||||
{ line_no: '20', part_number: `${partNumber}-B`, shipment_qty: '2', available_qty: '9', shortage_qty: 1 },
|
||||
],
|
||||
artifact_summary: { export_file_name: `${businessNo}.xlsx` },
|
||||
};
|
||||
}
|
||||
@@ -115,12 +171,17 @@ async function mountPage() {
|
||||
});
|
||||
}
|
||||
|
||||
function drawerText(): string {
|
||||
return document.body.querySelector('[data-testid="my-todos-drawer"]')?.textContent || '';
|
||||
}
|
||||
|
||||
describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
afterEach(() => {
|
||||
vi.clearAllMocks();
|
||||
document.body.innerHTML = '';
|
||||
});
|
||||
|
||||
it('only makes formal Notices selectable and displays each Notice projection', async () => {
|
||||
it('only makes freight-upload Notices selectable and shows line details in drawer', async () => {
|
||||
listTodos.mockResolvedValueOnce({
|
||||
items: [
|
||||
notice('WYC26082301', 'PO-100', 'PART-A'),
|
||||
@@ -132,13 +193,20 @@ describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
// 断言:货代上传阶段 Notice 可勾选;Review/Intake 行无复选框。
|
||||
expect(wrapper.get('[aria-label="WYC26082301"]').exists()).toBe(true);
|
||||
expect(wrapper.get('[aria-label="WYC26082302"]').exists()).toBe(true);
|
||||
expect(wrapper.find('[aria-label="SNRC-30"]').exists()).toBe(false);
|
||||
// 断言:表格副行展示 客户 · PO · 文件。
|
||||
expect(wrapper.text()).toContain('PO-100');
|
||||
expect(wrapper.text()).toContain('PART-A');
|
||||
expect(wrapper.text()).toContain('PART-B');
|
||||
expect(wrapper.text()).toContain('WYC26082301.xlsx');
|
||||
// 断言:点行打开抽屉,逐行明细承载料号(列表不再堆明细)。
|
||||
await wrapper.get('[data-testid="my-todos-row-WYC26082301"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(document.body.querySelector('[data-testid="my-todos-drawer"]')).not.toBeNull();
|
||||
const drawer = drawerText();
|
||||
expect(drawer).toContain('PART-A');
|
||||
expect(drawer).toContain('PART-A-B');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
@@ -152,53 +220,106 @@ describe('ShippingTaskCenterPage notice batch operations', () => {
|
||||
await wrapper.get('[aria-label="WYC26082301"]').setValue(true);
|
||||
await wrapper.get('[aria-label="WYC26082302"]').setValue(true);
|
||||
|
||||
const toolbar = wrapper.get('[data-testid="shipping-notice-batch-toolbar"]');
|
||||
const buttons = toolbar.findAll('button');
|
||||
// 断言:勾选后浮出操作条,三个动作按序对应 download/confirm/rpa。
|
||||
// 每次 action 后列表会静默重载(表格重挂载),因此逐次重新查询按钮。
|
||||
const toolbarButtons = () => wrapper
|
||||
.get('[data-testid="shipping-notice-batch-toolbar"]')
|
||||
.findAll('button');
|
||||
const buttons = toolbarButtons();
|
||||
expect(buttons.length).toBeGreaterThanOrEqual(3);
|
||||
await buttons[0].trigger('click');
|
||||
expect(downloadArchive).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
|
||||
await buttons[1].trigger('click');
|
||||
await flushPromises();
|
||||
await toolbarButtons()[1].trigger('click');
|
||||
await flushPromises();
|
||||
expect(batchConfirm).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
|
||||
await buttons[2].trigger('click');
|
||||
await toolbarButtons()[2].trigger('click');
|
||||
await flushPromises();
|
||||
expect(batchRpa).toHaveBeenCalledWith(['WYC26082301', 'WYC26082302']);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('keeps all five lifecycle stage filters on one wide-screen row', async () => {
|
||||
it('renders one row of stage tabs covering all plus four actionable stages', async () => {
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
const track = wrapper.get('[data-testid="my-todos-lifecycle-stage-filter"]');
|
||||
expect(track.classes()).toContain('xl:grid-cols-5');
|
||||
// 断言:全部 + 四个可动作阶段;「通知完成」不再是筛选维度。
|
||||
expect(track.findAll('button')).toHaveLength(5);
|
||||
expect(track.text()).toContain('货代上传');
|
||||
expect(track.text()).not.toContain('通知完成');
|
||||
expect(track.text()).not.toContain('workspace.shippingNotice.myTodos.lifecycleStages.freight_upload');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('counts a pending review item from its backend stage even without an enterable lifecycle entry', async () => {
|
||||
listTodos.mockResolvedValueOnce({
|
||||
items: [{
|
||||
item_kind: 'review_case',
|
||||
task_no: '',
|
||||
review_run_no: 'RUN-1',
|
||||
review_case_no: 'CASE-1',
|
||||
ui_state: {
|
||||
stage: { code: 'order_review', label: '订单复核', index: 2, total: 5 },
|
||||
lifecycle_entries: [],
|
||||
},
|
||||
}],
|
||||
page: 1,
|
||||
page_size: 20,
|
||||
total: 1,
|
||||
it('shows backend aggregated stage counts instead of current-page counting', async () => {
|
||||
countTodos.mockResolvedValueOnce({
|
||||
pending: 13, processing: 0, done: 0, total_pending_badge: 13,
|
||||
stage_counts: { intake_parse: 2, order_review: 4, fulfillment_prep: 3, freight_upload: 4 },
|
||||
done_counts: { upload_complete: 0, reject_void: 0 },
|
||||
});
|
||||
listTodos.mockResolvedValueOnce({ items: [], page: 1, page_size: 20, total: 0 });
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-order_review"]').text()).toContain('1');
|
||||
// 断言:阶段计数来自后端聚合(当前页为空列表也显示全量计数)。
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-order_review"]').text()).toContain('4');
|
||||
expect(wrapper.get('[data-testid="my-todos-stage-filter-fulfillment_prep"]').text()).toContain('3');
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('defaults done bucket to the flat done-lines report and exports current filters', async () => {
|
||||
listDoneLines.mockResolvedValue({
|
||||
items: [{
|
||||
task_no: 'SN-DONE-1', business_no: 'BIZ-1', customer_name: 'HYVE CS', customer_code: 'HC001',
|
||||
order_date: '2026-06-01', line_no: 1, part_number: 'B3-A08AR1', qty: 80,
|
||||
required_date: '2026-06-15', customer_po_number: '306085', used_qty: null,
|
||||
open_qty: null, source_order_number: '8301-1', unit_price: 1525.08,
|
||||
}],
|
||||
page: 1, page_size: 50, total: 1,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
await wrapper.get('[data-testid="my-todos-bucket-done"]').trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 断言:done 桶默认进入通知完成明细报表,消费 done-lines 接口。
|
||||
expect(listDoneLines).toHaveBeenCalled();
|
||||
const table = wrapper.get('[data-testid="done-lines-table"]');
|
||||
expect(table.text()).toContain('B3-A08AR1');
|
||||
expect(table.text()).toContain('8301-1');
|
||||
// 断言:导出按钮把当前筛选交给受控下载。
|
||||
await wrapper.get('[data-testid="done-lines-export"]').trigger('click');
|
||||
await flushPromises();
|
||||
expect(downloadDoneLinesExcel).toHaveBeenCalled();
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('loads reject_void sub tab with terminal_kind filter and badges rows', async () => {
|
||||
listTodos.mockResolvedValue({
|
||||
items: [{
|
||||
id: 41, task_no: 'SN-REJ-1', business_no: 'BIZ-R1', item_kind: 'task',
|
||||
todo_ref: 'SN-REJ-1', todo_category: 'done',
|
||||
ui_state: { stage: { code: 'upload_complete', label: '通知完成' }, lifecycle_entries: [] },
|
||||
}],
|
||||
page: 1, page_size: 20, total: 1,
|
||||
});
|
||||
const wrapper = await mountPage();
|
||||
await flushPromises();
|
||||
await wrapper.get('[data-testid="my-todos-bucket-done"]').trigger('click');
|
||||
await flushPromises();
|
||||
const subtabs = wrapper.findAll('[data-testid="my-todos-done-subtabs"] button');
|
||||
await subtabs[1].trigger('click');
|
||||
await flushPromises();
|
||||
|
||||
// 断言:驳回/作废子视图按 terminal_kind 拉任务表,行带终态角标。
|
||||
expect(listTodos).toHaveBeenCalledWith(expect.objectContaining({
|
||||
bucket: 'done',
|
||||
terminal_kind: 'reject_void',
|
||||
}));
|
||||
expect(wrapper.get('[data-testid="my-todos-row-BIZ-R1"]').text()).toContain('复核驳回');
|
||||
wrapper.unmount();
|
||||
});
|
||||
});
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,390 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingTaskDrawer.vue
|
||||
用途:任务详情抽屉——分诊决策面板(头部阻断 + 逐行明细 + 文件 + 底部操作)。
|
||||
依赖:shippingTaskCenterShared(阶段口径)、gateReasonLabel。
|
||||
逻辑:review/intake/task 三分支迁移自原任务中心右侧入口卡,行为与深链契约不变;
|
||||
深链/重试只向上 emit,由页面统一执行;阶段目标下拉仍由后端
|
||||
ui_state.lifecycle_entries 裁决(current/available 才可进)。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Download, ExternalLink, RefreshCw, X } from 'lucide-vue-next';
|
||||
import type {
|
||||
ShippingTaskDetail,
|
||||
ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
canOpenIntakeParse,
|
||||
defaultLifecycleTarget,
|
||||
lifecycleEntriesOf,
|
||||
lifecycleEntryFor,
|
||||
lifecycleEntryIsEnterable,
|
||||
todoBlockerText,
|
||||
todoDisplayNo,
|
||||
type LifecycleStageCode,
|
||||
type TodoLike,
|
||||
} from './shippingTaskCenterShared';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
item: ShippingTaskSummary | ShippingTaskDetail | null;
|
||||
loading?: boolean;
|
||||
chatAgentId: number | null;
|
||||
/** 重试 STP 进行中(页面持有状态)。 */
|
||||
stpRetrying?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'close'): void;
|
||||
(event: 'open-intake', item: TodoLike): void;
|
||||
(event: 'open-processing', item: TodoLike, stage: Exclude<LifecycleStageCode, 'intake_parse'>): void;
|
||||
(event: 'open-chat', item: TodoLike): void;
|
||||
(event: 'retry-stp', item: TodoLike): void;
|
||||
}>();
|
||||
|
||||
type EnterableStage = Exclude<LifecycleStageCode, 'intake_parse'>;
|
||||
const stageTarget = ref<EnterableStage>('order_review');
|
||||
|
||||
const isReviewItem = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
if (!item) return false;
|
||||
return item.item_kind === 'review_case' || Boolean(item.review_run_no && !item.task_no);
|
||||
});
|
||||
const isIntakeItem = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
if (!item) return false;
|
||||
return item.item_kind === 'order_intake'
|
||||
|| Boolean(item.intake_no && !item.task_no && !item.review_run_no);
|
||||
});
|
||||
|
||||
const displayNo = computed(() => {
|
||||
if (!props.item) return '—';
|
||||
if ('task_no' in props.item && props.item.task_no
|
||||
&& !isReviewItem.value && !isIntakeItem.value) {
|
||||
return String(props.item.task_no);
|
||||
}
|
||||
return todoDisplayNo(props.item as ShippingTaskSummary);
|
||||
});
|
||||
|
||||
const subTitle = computed(() => {
|
||||
const item = props.item;
|
||||
if (!item) return '';
|
||||
const segments = [
|
||||
String(item.customer_name || '').trim(),
|
||||
String(item.po_number || '').trim() ? `PO ${String(item.po_number).trim()}` : '',
|
||||
String(item.source_file_name || '').trim()
|
||||
|| String(item.artifact_summary?.export_file_name || '').trim(),
|
||||
].filter(Boolean);
|
||||
return segments.join(' · ');
|
||||
});
|
||||
|
||||
const stageLabel = computed(() => {
|
||||
const item = props.item;
|
||||
if (!item) return '';
|
||||
const code = String(item.ui_state?.stage?.code || '').trim();
|
||||
const key = code ? `workspace.shippingNotice.myTodos.lifecycleStages.${code}` : '';
|
||||
if (key && te(key)) return t(key);
|
||||
return String(item.ui_state?.stage?.label || '');
|
||||
});
|
||||
|
||||
const blocker = computed(() => (props.item ? todoBlockerText(props.item, t, te) : ''));
|
||||
|
||||
const summaryMessage = computed(() => String(
|
||||
props.item?.ui_state?.summary?.message
|
||||
|| props.item?.ui_state?.summary?.current_todo
|
||||
|| '',
|
||||
));
|
||||
|
||||
const stageTargetOptions = computed(() => {
|
||||
if (!props.item) return [];
|
||||
return lifecycleEntriesOf(props.item)
|
||||
.filter((entry) => entry.code !== 'intake_parse')
|
||||
.map((entry) => ({
|
||||
code: entry.code as EnterableStage,
|
||||
disabled: entry.state !== 'current' && entry.state !== 'available',
|
||||
}));
|
||||
});
|
||||
|
||||
/** 后端仅授权 current/available;目标不可进时主按钮禁用。 */
|
||||
function canOpenProcessing(stage: EnterableStage | null): boolean {
|
||||
const item = props.item;
|
||||
if (!item) return false;
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
const agentId = Number(item.owner_agent_id || props.chatAgentId || 0);
|
||||
const target = stage || defaultLifecycleTarget(item);
|
||||
if (!target) return false;
|
||||
return Boolean(runNo && agentId && lifecycleEntryIsEnterable(lifecycleEntryFor(item, target)));
|
||||
}
|
||||
|
||||
const canOpenIntake = computed(() => canOpenIntakeParse(props.item, props.chatAgentId));
|
||||
|
||||
/** 摘要允许动作里是否含 STP 自动推进重试(与工作台底栏同一契约)。 */
|
||||
const canRetryStp = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
if (!item || item.can_handle === false) return false;
|
||||
if (!String(item.review_case_no || '').trim()) return false;
|
||||
const summaryActions = item.ui_state?.summary?.allowed_actions || [];
|
||||
const actions = [item.ui_state?.actions?.primary, ...(item.ui_state?.actions?.secondary || [])]
|
||||
.filter(Boolean)
|
||||
.map((action) => String(action?.code || ''));
|
||||
return summaryActions.includes('retry_stp_auto_create') || actions.includes('retry_stp_auto_create');
|
||||
});
|
||||
|
||||
const exportFileName = computed(() => String(
|
||||
props.item?.artifact_summary?.export_file_name || '',
|
||||
));
|
||||
|
||||
const lineRows = computed(() => {
|
||||
const item = props.item as ShippingTaskSummary | null;
|
||||
return Array.isArray(item?.notice_line_summary) ? item!.notice_line_summary : [];
|
||||
});
|
||||
|
||||
watch(() => props.item, (item) => {
|
||||
if (!item) return;
|
||||
const stage = defaultLifecycleTarget(item);
|
||||
if (stage) stageTarget.value = stage;
|
||||
}, { immediate: true });
|
||||
|
||||
function onEsc(event: KeyboardEvent) {
|
||||
if (event.key === 'Escape') emit('close');
|
||||
}
|
||||
|
||||
// Esc 关闭抽屉;打开时挂监听,关闭/卸载时移除,避免监听串扰。
|
||||
watch(() => props.open, (open) => {
|
||||
if (open) document.addEventListener('keydown', onEsc);
|
||||
else document.removeEventListener('keydown', onEsc);
|
||||
}, { immediate: true });
|
||||
|
||||
onBeforeUnmount(() => document.removeEventListener('keydown', onEsc));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex"
|
||||
data-testid="my-todos-drawer"
|
||||
>
|
||||
<div
|
||||
class="flex-1 bg-[rgba(23,32,51,0.35)]"
|
||||
data-testid="my-todos-drawer-scrim"
|
||||
@click="emit('close')"
|
||||
/>
|
||||
<aside class="flex w-[34rem] max-w-[94vw] flex-col bg-surface shadow-2xl">
|
||||
<div class="border-b border-default px-5 py-4">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<h3 class="break-all font-mono text-base font-bold text-primary" data-testid="my-todos-drawer-title">
|
||||
{{ displayNo }}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg bg-surface-soft px-2 py-1 text-xs text-secondary hover:bg-surface-soft/70"
|
||||
:aria-label="$t('workspace.shippingNotice.myTodos.drawer.close')"
|
||||
data-testid="my-todos-drawer-close"
|
||||
@click="emit('close')"
|
||||
>
|
||||
<X class="h-4 w-4" />
|
||||
</button>
|
||||
</div>
|
||||
<p v-if="subTitle" class="mt-1 text-xs text-muted">{{ subTitle }}</p>
|
||||
<div class="mt-2 flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
v-if="stageLabel"
|
||||
class="rounded-full bg-brand-50 px-2.5 py-0.5 text-xs font-medium text-brand-800"
|
||||
data-testid="my-todos-drawer-stage"
|
||||
>
|
||||
{{ stageLabel }}
|
||||
</span>
|
||||
<span
|
||||
v-if="isReviewItem"
|
||||
class="rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700"
|
||||
>{{ $t('workspace.shippingNotice.myTodos.openReview') }}</span>
|
||||
<span
|
||||
v-else-if="isIntakeItem"
|
||||
class="rounded bg-violet-50 px-1.5 py-0.5 text-[10px] text-violet-700"
|
||||
>{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex-1 overflow-y-auto px-5 py-4">
|
||||
<div v-if="loading" class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<template v-else-if="item">
|
||||
<div
|
||||
v-if="blocker"
|
||||
class="mb-4 rounded-xl border border-red-200 bg-red-50 px-3.5 py-2.5 text-[13px] text-red-700"
|
||||
data-testid="my-todos-progress-blocker"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.progressBlocker', { reason: blocker }) }}
|
||||
</div>
|
||||
<p
|
||||
v-if="stageLabel"
|
||||
class="mb-2 text-sm font-medium text-primary"
|
||||
data-testid="my-todos-progress-summary"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.progressSummary', { stage: stageLabel }) }}
|
||||
</p>
|
||||
<p v-if="summaryMessage" class="text-sm text-secondary">{{ summaryMessage }}</p>
|
||||
|
||||
<template v-if="lineRows.length">
|
||||
<h4 class="mb-2 mt-5 text-[13px] font-bold text-primary">
|
||||
{{ $t('workspace.shippingNotice.myTodos.drawer.details') }}
|
||||
</h4>
|
||||
<div class="overflow-x-auto rounded-xl border border-default">
|
||||
<table class="w-full border-collapse text-xs" data-testid="my-todos-drawer-lines">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft/60 text-left text-muted">
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.lineNo') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.partNumber') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.customerPartNumber') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.reservationId') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shipmentQty') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.availableQty') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.shortageQty') }}</th>
|
||||
<th class="px-2.5 py-2 font-medium">{{ $t('workspace.shippingNotice.myTodos.drawer.lineTable.status') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="line in lineRows"
|
||||
:key="`${line.line_no}-${line.part_number}`"
|
||||
class="border-b border-[#f0f3f8]"
|
||||
>
|
||||
<td class="px-2.5 py-2 font-mono">{{ line.line_no }}</td>
|
||||
<td class="px-2.5 py-2 font-mono">{{ line.part_number || '—' }}</td>
|
||||
<td class="px-2.5 py-2">{{ line.customer_part_number || '—' }}</td>
|
||||
<td class="px-2.5 py-2 font-mono">{{ line.reservation_id || '—' }}</td>
|
||||
<td class="px-2.5 py-2 tabular-nums">{{ line.shipment_qty ?? '—' }}</td>
|
||||
<td class="px-2.5 py-2 tabular-nums">{{ line.available_qty ?? '—' }}</td>
|
||||
<td
|
||||
class="px-2.5 py-2 tabular-nums"
|
||||
:class="Number(line.shortage_qty || 0) > 0 ? 'font-bold text-red-600' : ''"
|
||||
>
|
||||
{{ line.shortage_qty ?? '—' }}
|
||||
</td>
|
||||
<td class="px-2.5 py-2">{{ line.inventory_status || '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template v-if="exportFileName">
|
||||
<h4 class="mb-2 mt-5 text-[13px] font-bold text-primary">
|
||||
{{ $t('workspace.shippingNotice.myTodos.drawer.files') }}
|
||||
</h4>
|
||||
<div class="rounded-xl border border-default px-3 py-2 text-[13px] text-secondary">
|
||||
<span class="mr-2 rounded bg-brand-50 px-1.5 py-0.5 text-[10px] text-brand-800">Excel</span>
|
||||
{{ exportFileName }}
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<p class="mt-5 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.openProcessingHint') }}
|
||||
</p>
|
||||
</template>
|
||||
<div v-else class="py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.selectCase') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="item && !loading" class="space-y-2.5 border-t border-default px-5 py-4">
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<label class="sr-only" for="drawer-stage-target">{{ $t('workspace.shippingNotice.myTodos.lifecycleStages.viewStage') }}</label>
|
||||
<select
|
||||
v-if="stageTargetOptions.length"
|
||||
id="drawer-stage-target"
|
||||
v-model="stageTarget"
|
||||
class="input-field max-w-40 text-sm"
|
||||
data-testid="my-todos-lifecycle-stage-target"
|
||||
>
|
||||
<option
|
||||
v-for="option in stageTargetOptions"
|
||||
:key="option.code"
|
||||
:value="option.code"
|
||||
:disabled="option.disabled"
|
||||
>
|
||||
{{ $t(`workspace.shippingNotice.myTodos.lifecycleStages.${option.code}`) }}
|
||||
</option>
|
||||
</select>
|
||||
<button
|
||||
v-if="canOpenIntake"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
data-testid="my-todos-open-intake-parse"
|
||||
@click="emit('open-intake', item)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openIntakeParse') }}
|
||||
</button>
|
||||
<button
|
||||
v-else-if="!isIntakeItem"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!canOpenProcessing(stageTarget)"
|
||||
data-testid="my-todos-open-order-processing"
|
||||
@click="emit('open-processing', item, stageTarget)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openLifecycleWorkbench') }}
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!(item.owner_agent_id || chatAgentId)"
|
||||
data-testid="my-todos-open-intake-conversation"
|
||||
@click="emit('open-chat', item)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openConversation') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="chatAgentId && !isIntakeItem"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary hover:bg-surface-soft"
|
||||
@click="emit('open-chat', item)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.openChat') }}
|
||||
</button>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button
|
||||
v-if="canRetryStp"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-amber-400 bg-amber-50 px-4 py-2 text-sm font-medium text-amber-950 hover:bg-amber-100 disabled:opacity-50 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-100"
|
||||
:disabled="stpRetrying"
|
||||
data-testid="my-todos-retry-stp-auto-create"
|
||||
@click="emit('retry-stp', item)"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ $t('chat.shippingOrderReview.autoProgress.retryStp') }}
|
||||
</button>
|
||||
<a
|
||||
v-if="exportFileName"
|
||||
class="inline-flex cursor-pointer items-center gap-1 text-xs text-brand-700 hover:underline"
|
||||
:href="`/api/workspace/shipping-notices/${encodeURIComponent(String(item.business_no || ''))}/export`"
|
||||
target="_blank"
|
||||
rel="noopener"
|
||||
>
|
||||
<Download class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.drawer.exportExcel') }}
|
||||
</a>
|
||||
<p
|
||||
v-if="!canOpenIntake && !canOpenProcessing(stageTarget) && !isIntakeItem"
|
||||
class="text-xs text-amber-700 dark:text-amber-300"
|
||||
data-testid="my-todos-open-processing-unavailable"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.openProcessingUnavailable') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
@@ -0,0 +1,240 @@
|
||||
<!--
|
||||
features/workspace/shipping-task-center/ShippingTaskTable.vue
|
||||
用途:任务中心紧凑表格(一行一待办):编号/阶段/状态摘要/项次缺口/货代状态。
|
||||
依赖:shippingTaskCenterShared(编号、阶段、批量可选口径)。
|
||||
逻辑:行点击向上冒泡选中;复选框仅「货代上传」阶段的正式 Notice 行存在;
|
||||
勾选 ≥1 后浮出深色批量操作条(低频操作不常驻);分页由父级渲染。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { CheckSquare, Download, Upload, X } from 'lucide-vue-next';
|
||||
import type { ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
isFreightUploadRow,
|
||||
lifecycleStageCodeOf,
|
||||
todoBlockerText,
|
||||
todoDisplayNo,
|
||||
todoItemKey,
|
||||
todoLineBrief,
|
||||
todoSubTitleText,
|
||||
todoTitleText,
|
||||
} from './shippingTaskCenterShared';
|
||||
|
||||
const { t, te } = useI18n();
|
||||
|
||||
const props = defineProps<{
|
||||
items: ShippingTaskSummary[];
|
||||
/** 当前选中行主键(抽屉联动)。 */
|
||||
selectedKey?: string | null;
|
||||
/** 是否渲染复选框列(仅待处理桶)。 */
|
||||
selectable?: boolean;
|
||||
/** 已勾选 business_no 集合。 */
|
||||
selectedBusinessNos?: string[];
|
||||
/** 批量动作进行中标记,禁用按钮。 */
|
||||
batchBusy?: 'download' | 'confirm' | 'rpa' | null;
|
||||
/** done 桶行统一终态角标(驳回/作废子视图由服务端过滤保证)。 */
|
||||
terminalBadge?: 'upload_complete' | 'reject_void' | null;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'select', item: ShippingTaskSummary): void;
|
||||
(event: 'toggle', item: ShippingTaskSummary): void;
|
||||
(event: 'toggle-all'): void;
|
||||
(event: 'clear-selection'): void;
|
||||
(event: 'batch', action: 'download' | 'confirm' | 'rpa'): void;
|
||||
}>();
|
||||
|
||||
const selectedSet = computed(() => new Set(props.selectedBusinessNos || []));
|
||||
const selectableRows = computed(() => props.items.filter((item) => isFreightUploadRow(item)));
|
||||
const hasSelection = computed(() => (props.selectedBusinessNos?.length || 0) > 0);
|
||||
const allSelectableChecked = computed(() => (
|
||||
selectableRows.value.length > 0
|
||||
&& selectableRows.value.every((item) => selectedSet.value.has(String(item.business_no)))
|
||||
));
|
||||
|
||||
/** 阶段徽章文案:优先本地化阶段名,后端 label 兜底。 */
|
||||
function stageLabel(item: ShippingTaskSummary): string {
|
||||
const code = lifecycleStageCodeOf(item);
|
||||
const key = code ? `workspace.shippingNotice.myTodos.lifecycleStages.${code}` : '';
|
||||
if (key && te(key)) return t(key);
|
||||
return String(item.ui_state?.stage?.label || '—');
|
||||
}
|
||||
|
||||
function rowTitle(item: ShippingTaskSummary): string {
|
||||
return todoTitleText(item);
|
||||
}
|
||||
|
||||
function rowBlocker(item: ShippingTaskSummary): string {
|
||||
return todoBlockerText(item, t, te);
|
||||
}
|
||||
|
||||
function lineBriefText(item: ShippingTaskSummary): string {
|
||||
const brief = todoLineBrief(item);
|
||||
if (!brief.total) return '—';
|
||||
return `${brief.total} ${t('workspace.shippingNotice.myTodos.table.lineUnit')}`;
|
||||
}
|
||||
|
||||
function onToggleAll(): void {
|
||||
emit('toggle-all');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="overflow-hidden rounded-2xl border border-default bg-surface">
|
||||
<div
|
||||
v-if="hasSelection"
|
||||
class="flex flex-wrap items-center gap-2 bg-[#1b2740] px-4 py-2.5 text-sm text-slate-100"
|
||||
data-testid="shipping-notice-batch-toolbar"
|
||||
>
|
||||
<span class="rounded-full bg-brand-600 px-3 py-0.5 text-xs font-semibold">
|
||||
{{ $t('workspace.shippingNotice.batch.selected', { count: selectedBusinessNos?.length || 0 }) }}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
|
||||
:disabled="Boolean(batchBusy)"
|
||||
@click="emit('batch', 'download')"
|
||||
>
|
||||
<Download class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.download') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
|
||||
:disabled="Boolean(batchBusy)"
|
||||
@click="emit('batch', 'confirm')"
|
||||
>
|
||||
<CheckSquare class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.confirm') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-white/20 px-2.5 py-1 text-xs hover:bg-white/10 disabled:opacity-50"
|
||||
:disabled="Boolean(batchBusy)"
|
||||
@click="emit('batch', 'rpa')"
|
||||
>
|
||||
<Upload class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.rpa') }}
|
||||
</button>
|
||||
<span class="flex-1" />
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg px-2.5 py-1 text-xs text-slate-300 hover:text-white"
|
||||
@click="emit('clear-selection')"
|
||||
>
|
||||
<X class="mr-1 inline h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.batch.clearSelection') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<thead>
|
||||
<tr class="border-b border-default bg-surface-soft/60 text-left text-xs text-muted">
|
||||
<th v-if="selectable" class="w-10 px-3 py-2.5">
|
||||
<input
|
||||
type="checkbox"
|
||||
:checked="allSelectableChecked"
|
||||
:aria-label="$t('workspace.shippingNotice.batch.selectAll')"
|
||||
@change="onToggleAll"
|
||||
>
|
||||
</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.no') }}</th>
|
||||
<th class="w-24 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.stage') }}</th>
|
||||
<th class="px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.summary') }}</th>
|
||||
<th class="w-28 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.lines') }}</th>
|
||||
<th class="w-24 px-3 py-2.5 font-medium">{{ $t('workspace.shippingNotice.myTodos.table.freightStatus') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="item in items"
|
||||
:key="todoItemKey(item)"
|
||||
class="cursor-pointer border-b border-[#f0f3f8] transition-colors hover:bg-brand-50/40"
|
||||
:class="selectedKey === todoItemKey(item) ? 'bg-brand-50/70 dark:bg-brand-950/30' : ''"
|
||||
:data-testid="`my-todos-row-${todoDisplayNo(item)}`"
|
||||
@click="emit('select', item)"
|
||||
>
|
||||
<td v-if="selectable" class="px-3 py-2.5 align-middle">
|
||||
<input
|
||||
v-if="isFreightUploadRow(item)"
|
||||
type="checkbox"
|
||||
:checked="selectedSet.has(String(item.business_no))"
|
||||
:aria-label="String(item.business_no)"
|
||||
@click.stop
|
||||
@change="emit('toggle', item)"
|
||||
>
|
||||
</td>
|
||||
<td class="max-w-[22rem] px-3 py-2.5 align-middle">
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="truncate font-mono text-[13px] font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
|
||||
<span
|
||||
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
|
||||
class="shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.todo_category === 'intake_parse' || item.item_kind === 'order_intake'"
|
||||
class="shrink-0 rounded bg-violet-50 px-1.5 py-0.5 text-[10px] text-violet-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.intakeParseBadge') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.can_handle === false"
|
||||
class="shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] text-slate-600"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="terminalBadge === 'upload_complete'"
|
||||
class="shrink-0 rounded bg-emerald-50 px-1.5 py-0.5 text-[10px] text-emerald-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.terminal.uploadComplete') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="terminalBadge === 'reject_void'"
|
||||
class="shrink-0 rounded bg-red-50 px-1.5 py-0.5 text-[10px] text-red-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.terminal.rejectVoid') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-0.5 truncate text-xs text-muted">{{ todoSubTitleText(item) || '—' }}</div>
|
||||
</td>
|
||||
<td class="px-3 py-2.5 align-middle">
|
||||
<span class="whitespace-nowrap rounded-full bg-brand-50 px-2 py-0.5 text-xs text-brand-800">
|
||||
{{ stageLabel(item) }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="max-w-[18rem] px-3 py-2.5 align-middle">
|
||||
<div class="truncate text-[13px] text-secondary">{{ rowTitle(item) }}</div>
|
||||
<div
|
||||
v-if="rowBlocker(item)"
|
||||
class="mt-0.5 truncate text-xs text-red-600"
|
||||
data-testid="my-todos-row-blocker"
|
||||
>
|
||||
{{ rowBlocker(item) }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-3 py-2.5 align-middle text-xs">
|
||||
<template v-if="item.business_no">
|
||||
<span>{{ lineBriefText(item) }}</span>
|
||||
<span
|
||||
v-if="todoLineBrief(item).shortage"
|
||||
class="ml-1 font-semibold text-red-600"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.table.shortage', { count: todoLineBrief(item).shortage }) }}
|
||||
</span>
|
||||
</template>
|
||||
<span v-else class="text-muted">—</span>
|
||||
</td>
|
||||
<td class="px-3 py-2.5 align-middle text-xs text-secondary">
|
||||
{{ item.business_no ? (item.upload_status || '—') : '—' }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,174 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/shippingTaskCenterShared.ts
|
||||
* 用途:任务中心列表 / 表格 / 抽屉共用的纯函数与类型(阶段口径、编号、选择)。
|
||||
* 依赖:chat shipping.api 类型、gateReasonLabel。
|
||||
* 逻辑:阶段只消费后端 ui_state.lifecycle_entries / ui_state.stage(与页面同口径);
|
||||
* 本模块不发起请求、不操作路由,供 TaskTable / Drawer / Page 复用。
|
||||
*/
|
||||
import type { ShippingTaskDetail, ShippingTaskSummary } from '@/features/chat/api/shipping.api';
|
||||
import { resolveGateReasonLabel } from '@/features/shipping-progress/gateReasonLabel';
|
||||
|
||||
export type LifecycleStageCode = 'intake_parse' | 'order_review' | 'fulfillment_prep'
|
||||
| 'freight_upload' | 'upload_complete';
|
||||
|
||||
/** 五阶段完整序列(抽屉阶段下拉消费后端 entries,仍需全集做过滤)。 */
|
||||
export const LIFECYCLE_STAGES: LifecycleStageCode[] = [
|
||||
'intake_parse',
|
||||
'order_review',
|
||||
'fulfillment_prep',
|
||||
'freight_upload',
|
||||
'upload_complete',
|
||||
];
|
||||
|
||||
/** 阶段筛选 tab 仅覆盖四个可动作阶段;「通知完成」归 done 桶终态。 */
|
||||
export const ACTIONABLE_TODO_STAGES: Exclude<LifecycleStageCode, 'upload_complete'>[] = [
|
||||
'intake_parse',
|
||||
'order_review',
|
||||
'fulfillment_prep',
|
||||
'freight_upload',
|
||||
];
|
||||
|
||||
export type TodoLike = ShippingTaskSummary | ShippingTaskDetail;
|
||||
|
||||
/**
|
||||
* 待办列表项稳定主键:复核用 case_no,Intake 用 intake_no,任务用 task_no。
|
||||
*/
|
||||
export function todoItemKey(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.todo_ref || item.review_case_no || item.review_run_no || '');
|
||||
}
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.todo_ref || item.intake_no || '');
|
||||
}
|
||||
return String(item.todo_ref || item.task_no || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表展示编号:复核显示 case_no,Intake 显示 intake_no,任务显示业务编号/SN。
|
||||
*/
|
||||
export function todoDisplayNo(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.review_case_no || item.review_run_no || item.todo_ref || '—');
|
||||
}
|
||||
if (item.item_kind === 'order_intake' || item.intake_no) {
|
||||
return String(item.intake_no || item.todo_ref || '—');
|
||||
}
|
||||
return String(item.business_no || item.task_no || item.todo_ref || '—');
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取后端已裁决的生命周期入口;缺失即无授权,绝不按 task/case/intake 身份补造入口。
|
||||
*/
|
||||
export function lifecycleEntriesOf(item: TodoLike) {
|
||||
const entries = item.ui_state?.lifecycle_entries;
|
||||
if (!Array.isArray(entries)) return [];
|
||||
return entries.filter((entry) => LIFECYCLE_STAGES.includes(entry.code as LifecycleStageCode));
|
||||
}
|
||||
|
||||
/** 当前阶段只取后端标为 current 的入口,必要时回退 ui_state.stage(仅统计口径)。 */
|
||||
export function lifecycleStageCodeOf(item: TodoLike): LifecycleStageCode | null {
|
||||
const current = lifecycleEntriesOf(item).find((entry) => entry.state === 'current');
|
||||
if (current) return current.code as LifecycleStageCode;
|
||||
// [AUTHORITY] 待人工处理的 Review Case 可能没有可进入工作台的 lifecycle entry,
|
||||
// 但后端仍会下发 ui_state.stage 作为当前业务阶段;统计与筛选必须保留该阶段。
|
||||
const stage = String(item.ui_state?.stage?.code || '').trim();
|
||||
return LIFECYCLE_STAGES.includes(stage as LifecycleStageCode)
|
||||
? stage as LifecycleStageCode
|
||||
: null;
|
||||
}
|
||||
|
||||
/** 可进入工作台的业务阶段仅由后端 entry.state 授权。 */
|
||||
export function lifecycleEntryFor(
|
||||
item: TodoLike,
|
||||
stage: Exclude<LifecycleStageCode, 'intake_parse'>,
|
||||
) {
|
||||
return lifecycleEntriesOf(item).find((entry) => entry.code === stage) || null;
|
||||
}
|
||||
|
||||
/** 后端仅以 current / available 表示可进入工作台;未知状态一律拒绝深链。 */
|
||||
export function lifecycleEntryIsEnterable(
|
||||
entry: ReturnType<typeof lifecycleEntryFor>,
|
||||
): boolean {
|
||||
return entry?.state === 'current' || entry?.state === 'available';
|
||||
}
|
||||
|
||||
/** 阶段目标下拉默认值:优先 current,其次 available。 */
|
||||
export function defaultLifecycleTarget(
|
||||
item: TodoLike,
|
||||
): Exclude<LifecycleStageCode, 'intake_parse'> | null {
|
||||
const current = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'current',
|
||||
);
|
||||
const available = lifecycleEntriesOf(item).find(
|
||||
(entry) => entry.code !== 'intake_parse' && entry.state === 'available',
|
||||
);
|
||||
return (current || available)?.code as Exclude<LifecycleStageCode, 'intake_parse'> | undefined || null;
|
||||
}
|
||||
|
||||
/** 接收解析入口只消费后端独立授权 + run/agent 前提,不从阶段名称推导可写权限。 */
|
||||
export function canOpenIntakeParse(item: TodoLike | null, chatAgentId: number | null): boolean {
|
||||
if (!item) return false;
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId || 0);
|
||||
return Boolean(
|
||||
runNo
|
||||
&& agentId
|
||||
&& item.ui_state?.intake_parse_authorized === true,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行状态摘要标题:后端待办标题优先,逐级回退到阶段标签。
|
||||
*/
|
||||
export function todoTitleText(item: ShippingTaskSummary): string {
|
||||
return String(
|
||||
item.ui_state?.todo?.title
|
||||
|| item.ui_state?.summary?.current_todo
|
||||
|| item.ui_state?.summary?.title
|
||||
|| item.ui_state?.stage?.label
|
||||
|| '—',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 行阻断原因文本:优先后端 reason.message,其次 Gate 原因码的本地化标签。
|
||||
* 空串表示当前无阻断(调用方据此决定红色高亮)。
|
||||
*/
|
||||
export function todoBlockerText(
|
||||
item: TodoLike,
|
||||
t: (key: string, named?: Record<string, unknown>) => string,
|
||||
te: (key: string) => boolean,
|
||||
): string {
|
||||
const reason = item.ui_state?.reason;
|
||||
const text = String(reason?.message || '').trim();
|
||||
if (text) return text;
|
||||
const code = String(reason?.code || '').trim();
|
||||
if (!code) return '';
|
||||
return resolveGateReasonLabel(code, { t, te });
|
||||
}
|
||||
|
||||
/** 表格副行:客户 · PO · 源文件/导出文件,缺省段自动跳过。 */
|
||||
export function todoSubTitleText(item: ShippingTaskSummary): string {
|
||||
const segments = [
|
||||
String(item.customer_name || '').trim(),
|
||||
String(item.po_number || '').trim() ? `PO ${String(item.po_number).trim()}` : '',
|
||||
String(item.source_file_name || '').trim()
|
||||
|| String(item.artifact_summary?.export_file_name || '').trim(),
|
||||
].filter(Boolean);
|
||||
return segments.join(' · ');
|
||||
}
|
||||
|
||||
/** 项次/缺口摘要:total 项 + 缺 n(缺口>0 的行数)。 */
|
||||
export function todoLineBrief(item: ShippingTaskSummary): { total: number; shortage: number } {
|
||||
const lines = Array.isArray(item.notice_line_summary) ? item.notice_line_summary : [];
|
||||
const shortage = lines.filter((line) => Number(line.shortage_qty || 0) > 0).length;
|
||||
return { total: lines.length, shortage };
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量可选行:正式 Notice 且处于货代上传阶段(业务约束:批量操作仅该阶段可用)。
|
||||
*/
|
||||
export function isFreightUploadRow(item: ShippingTaskSummary): boolean {
|
||||
return Boolean(String(item.business_no || '').trim())
|
||||
&& lifecycleStageCodeOf(item) === 'freight_upload';
|
||||
}
|
||||
Reference in new issue
Block a user