feat(shipping-notice): 新增临时库存管理功能,支持创建会话、获取分析结果及字段映射建议
This commit is contained in:
1 parent
46eb63f5bb
commit
e9bdd81f1a
320 files changed
+28361
-10487
No files matched your search
@@ -437,7 +437,7 @@ watch(
|
||||
:ref="bindShippingPickerRef"
|
||||
type="file"
|
||||
class="hidden"
|
||||
accept=".xlsx,.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv"
|
||||
accept=".xls,.xlsx,.csv,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,text/csv"
|
||||
@change="emit('shipping-inventory-selected', $event)"
|
||||
/>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import ChatThinkingBubble from './ChatThinkingBubble.vue';
|
||||
import ChatMessageBubble, { type ChatMessageBubbleHandlers } from './messages/ChatMessageBubble.vue';
|
||||
import ToolRunProgressCard from './ToolRunProgressCard.vue';
|
||||
import type { LeaveMessageHandlers } from './messages/LeaveMessageBlock.vue';
|
||||
import type { ShippingMappingHandlers } from './messages/ShippingInventoryMappingMessage.vue';
|
||||
import type { ShippingMessageHandlers } from './messages/shippingMessageHandlers';
|
||||
import type { TrainingHandlers } from './messages/TrainingExamQuestionMessage.vue';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ToolRunProgress } from '../api/toolRunProgress.api';
|
||||
@@ -34,7 +34,7 @@ const {
|
||||
isShippingNoticeAgent: boolean;
|
||||
handlers: ChatMessageBubbleHandlers;
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMappingHandlers;
|
||||
shippingHandlers: ShippingMessageHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
shouldRenderMessage: (msg: ChatMessage) => boolean;
|
||||
shouldShowToolRunProgressAfterMessage: (msg: ChatMessage, index: number) => boolean;
|
||||
|
||||
@@ -233,7 +233,7 @@ watch(() => page.currentAgentId, () => {
|
||||
:is-shipping-notice-agent="page.isShippingNoticeAgent"
|
||||
:handlers="page.messageBubbleHandlers"
|
||||
:leave-handlers="page.leaveMessageHandlers"
|
||||
:shipping-handlers="page.shippingMappingHandlers"
|
||||
:shipping-handlers="page.shippingMessageHandlers"
|
||||
:training-handlers="page.trainingHandlers"
|
||||
:should-render-message="page.shouldRenderMessage"
|
||||
:should-show-tool-run-progress-after-message="page.shouldShowToolRunProgressAfterMessage"
|
||||
|
||||
@@ -337,12 +337,6 @@ const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
advice: t('chat.shippingNoticeUi.diagnosisInventoryRpaAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'align_review' || reviewStatus === 'align_review') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisAlignReviewTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisAlignReviewAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'low_confidence' || reviewStatus === 'parse_review') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisParseReviewTitle'),
|
||||
@@ -370,7 +364,7 @@ const resolveTaskDiagnosis = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
: 'chat.shippingNoticeUi.diagnosisInventorySourceAdvice'),
|
||||
};
|
||||
}
|
||||
if (reason === 'map_infer' || processStatus === 'waiting_inventory') {
|
||||
if (processStatus === 'waiting_inventory') {
|
||||
return {
|
||||
title: t('chat.shippingNoticeUi.diagnosisInventoryWaitingTitle'),
|
||||
advice: t('chat.shippingNoticeUi.diagnosisInventoryWaitingAdvice'),
|
||||
@@ -392,9 +386,6 @@ const resolveSuggestedAction = (task: ShippingTaskSummary | ShippingTaskDetail)
|
||||
if (hasShortageLines(task) || reason === 'shortage' || reviewStatus === 'shortage_review') {
|
||||
return t('chat.shippingNoticeUi.suggestShortageActions');
|
||||
}
|
||||
if (reason === 'align_review' || reviewStatus === 'align_review') {
|
||||
return t('chat.shippingNoticeUi.suggestConfirmMapping');
|
||||
}
|
||||
if (reason === 'low_confidence' || reviewStatus === 'parse_review') {
|
||||
return t('chat.shippingNoticeUi.suggestReviewParse');
|
||||
}
|
||||
|
||||
@@ -148,6 +148,11 @@ function displayCell(value: unknown): string {
|
||||
return text || '—';
|
||||
}
|
||||
|
||||
/** 将客户匹配状态转换为面向业务用户的文案。 */
|
||||
function customerMatchStatus(status: string): string {
|
||||
return t(`chat.shippingCustomerMatch.status.${status}`);
|
||||
}
|
||||
|
||||
/** 对当前首个重复目标应用决策;强制新建时要求填写原因。 */
|
||||
function resolveDuplicate(candidateNo: string, action: ShippingDuplicateAction): void {
|
||||
const candidate = candidates.value.find((item) => item.candidateNo === candidateNo);
|
||||
@@ -225,6 +230,36 @@ function submitForceCreate(candidateNo: string): void {
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="candidate.customerMatches?.length"
|
||||
class="mt-2 overflow-x-auto rounded-lg border border-default bg-surface"
|
||||
>
|
||||
<div class="border-b border-default bg-surface-soft px-2 py-1.5 font-semibold text-primary">
|
||||
{{ t('chat.shippingCustomerMatch.title') }}
|
||||
</div>
|
||||
<table class="min-w-full text-[11px]">
|
||||
<thead class="text-left text-muted">
|
||||
<tr>
|
||||
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.role') }}</th>
|
||||
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.rawName') }}</th>
|
||||
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.standardName') }}</th>
|
||||
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.shortCode') }}</th>
|
||||
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.site') }}</th>
|
||||
<th class="px-2 py-1">{{ t('chat.shippingCustomerMatch.statusLabel') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="match in candidate.customerMatches" :key="match.role" class="border-t border-default/60">
|
||||
<td class="px-2 py-1 font-medium">{{ t(`chat.shippingCustomerMatch.roles.${match.role}`) }}</td>
|
||||
<td class="px-2 py-1">{{ displayCell(match.raw_name) }}</td>
|
||||
<td class="px-2 py-1">{{ displayCell(match.standard_name) }}</td>
|
||||
<td class="px-2 py-1 font-mono">{{ displayCell(match.short_code) }}</td>
|
||||
<td class="px-2 py-1">{{ displayCell(match.candidates?.find((item) => item.site_id === match.site_id)?.site_name) }}</td>
|
||||
<td class="px-2 py-1">{{ customerMatchStatus(match.status) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div
|
||||
v-if="editingCandidateNo !== candidate.candidateNo && readonlyLines(candidate).length"
|
||||
class="mt-2 overflow-x-auto rounded-lg border border-default bg-surface"
|
||||
|
||||
@@ -25,15 +25,15 @@ import { useAuthStore } from '@/features/auth/stores/auth.store';
|
||||
import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBlock.vue';
|
||||
import ChatMessageAttachmentList from './ChatMessageAttachmentList.vue';
|
||||
import MaintenanceDeviceResultCard from './MaintenanceDeviceResultCard.vue';
|
||||
import ShippingInventoryMappingMessage, { type ShippingMappingHandlers } from './ShippingInventoryMappingMessage.vue';
|
||||
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
|
||||
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
|
||||
import type { ShippingMessageHandlers } from './shippingMessageHandlers';
|
||||
import TrainingExamQuestionMessage, { type TrainingHandlers } from './TrainingExamQuestionMessage.vue';
|
||||
import TrainingVideoMessage from './TrainingVideoMessage.vue';
|
||||
import TrainingSummaryMessage from './TrainingSummaryMessage.vue';
|
||||
import TrainingResultCard from './TrainingResultCard.vue';
|
||||
import type { ChatMessage, InlineDownloadFile, SourceFileLink } from '../../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload, ShippingMatchResultPayload } from '../../types/shipping.types';
|
||||
import type { ShippingMatchResultPayload } from '../../types/shipping.types';
|
||||
import type { MaintenanceDevice } from '@/features/maintenance/types/ledger.types';
|
||||
import type { MaintenanceRecord } from '@/features/maintenance/types/record.types';
|
||||
|
||||
@@ -44,7 +44,6 @@ export interface ChatMessageBubbleHandlers {
|
||||
openAssetImage: (assetId: string, assetName?: string) => void;
|
||||
getInlineDownloadFiles: (text: string) => { cleanedText: string; files: InlineDownloadFile[] };
|
||||
downloadInlineFile: (file: InlineDownloadFile) => void;
|
||||
getShippingInventoryMappingPayload: (msg: ChatMessage) => ShippingInventoryMappingFormPayload | null;
|
||||
getShippingMatchResultPayload: (msg: ChatMessage) => ShippingMatchResultPayload | null;
|
||||
canOpenQueryPreview: (msg: ChatMessage) => boolean;
|
||||
getQueryPreviewSummary: (msg: ChatMessage) => string;
|
||||
@@ -83,7 +82,7 @@ const {
|
||||
isLatestAssistantMessage: boolean;
|
||||
handlers: ChatMessageBubbleHandlers;
|
||||
leaveHandlers: LeaveMessageHandlers;
|
||||
shippingHandlers: ShippingMappingHandlers;
|
||||
shippingHandlers: ShippingMessageHandlers;
|
||||
trainingHandlers: TrainingHandlers;
|
||||
}>();
|
||||
|
||||
@@ -752,13 +751,8 @@ function handleInlineDownload(file: InlineDownloadFile): void {
|
||||
:index="index"
|
||||
:handlers="leaveHandlers"
|
||||
/>
|
||||
<ShippingInventoryMappingMessage
|
||||
v-else-if="message.type === 'shipping-inventory-mapping' && handlers.getShippingInventoryMappingPayload(message)"
|
||||
:message="message"
|
||||
:handlers="shippingHandlers"
|
||||
/>
|
||||
<ShippingParseReviewMessage
|
||||
v-else-if="message.type === 'shipping-parse-review' && shippingHandlers.getParseReviewPayload(message)"
|
||||
v-if="message.type === 'shipping-parse-review' && shippingHandlers.getParseReviewPayload(message)"
|
||||
:message="message"
|
||||
:handlers="shippingParseReviewHandlers"
|
||||
/>
|
||||
|
||||
@@ -1,122 +0,0 @@
|
||||
/**
|
||||
* features/chat/components/messages/ShippingInventoryMappingMessage.vue
|
||||
* 用途:发货 Agent 库存 Excel 列映射表单消息 UI。
|
||||
* 依赖:chat.types、shipping.api.types、shipping.types。
|
||||
* 逻辑:ChatView 渲染 mapping 类型消息时挂载;通过 ShippingMappingHandlers 与 useChatShipping 交互。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import type { ChatMessage } from '../../types/chat.types';
|
||||
import type { ShippingNoticeHeader, ShippingNoticeLine } from '../../types/shipping.api.types';
|
||||
import type { ShippingInventoryMappingFormPayload, ShippingMatchResultPayload, ShippingParseReviewPayload } from '../../types/shipping.types';
|
||||
|
||||
export interface ShippingMappingHandlers {
|
||||
getPayload: (msg: ChatMessage) => ShippingInventoryMappingFormPayload | null;
|
||||
normalizeHeader: (header: string) => string;
|
||||
hasSampleRows: (msg: ChatMessage) => boolean;
|
||||
getSampleRowText: (msg: ChatMessage) => string;
|
||||
reupload: (msg: ChatMessage) => void;
|
||||
apply: (msg: ChatMessage) => void;
|
||||
getParseReviewPayload: (msg: ChatMessage) => ShippingParseReviewPayload | null;
|
||||
getMatchResultPayload: (msg: ChatMessage) => ShippingMatchResultPayload | null;
|
||||
updateParseReviewHeader: (msg: ChatMessage, fields: Partial<ShippingNoticeHeader>) => Promise<boolean>;
|
||||
updateParseReviewLine: (msg: ChatMessage, lineIndex: number, patch: Partial<ShippingNoticeLine>) => Promise<boolean>;
|
||||
updateHeader: (msg: ChatMessage, fields: Partial<ShippingNoticeHeader>) => Promise<boolean>;
|
||||
updateLine: (msg: ChatMessage, lineIndex: number, patch: Partial<ShippingNoticeLine>) => Promise<boolean>;
|
||||
addLine: (msg: ChatMessage, line: Partial<ShippingNoticeLine>) => Promise<boolean>;
|
||||
removeLine: (msg: ChatMessage, lineIndex: number) => Promise<boolean>;
|
||||
}
|
||||
|
||||
const { message, handlers } = defineProps<{
|
||||
message: ChatMessage;
|
||||
handlers: ShippingMappingHandlers;
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="handlers.getPayload(message)" class="space-y-4">
|
||||
<div class="whitespace-pre-wrap text-sm font-medium text-secondary">{{ message.content }}</div>
|
||||
<div class="space-y-4 rounded-2xl border border-default bg-surface-soft/90 p-4">
|
||||
<div class="space-y-2">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ $t('chat.shippingNoticeMapping.inventoryHeaders') }}</div>
|
||||
<div class="text-xs text-muted">
|
||||
{{ $t('chat.shippingNoticeMapping.headerRow', { row: handlers.getPayload(message)!.schema_preview.header_row_index || 1 }) }}
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span
|
||||
v-for="h in (handlers.getPayload(message)!.schema_preview.headers || [])"
|
||||
:key="`inv-h-${h}`"
|
||||
class="rounded-full border border-default bg-surface px-3 py-1 text-xs text-secondary"
|
||||
>{{ handlers.normalizeHeader(h) || $t('chat.shippingNoticeMapping.empty') }}</span>
|
||||
</div>
|
||||
<div
|
||||
v-if="handlers.hasSampleRows(message)"
|
||||
class="whitespace-pre-wrap text-xs text-muted"
|
||||
>
|
||||
{{ $t('chat.shippingNoticeMapping.sample') }}:{{ handlers.getSampleRowText(message) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ $t('chat.shippingNoticeMapping.orderDetails') }}</div>
|
||||
<div class="text-xs text-muted">
|
||||
{{ $t('chat.shippingNoticeMapping.orderRowCount', { count: handlers.getPayload(message)!.order.line_count }) }};{{ $t('chat.shippingNoticeMapping.orderPartNumberPreview', { count: handlers.getPayload(message)!.order.part_numbers.length, partNumbers: handlers.getPayload(message)!.order.part_numbers.join(',') || $t('chat.shippingNoticeMapping.unrecognized') }) }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 md:grid-cols-2">
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.shippingNoticeMapping.partNumberColumnRequired') }}</span>
|
||||
<select
|
||||
v-model="handlers.getPayload(message)!.form.part_number"
|
||||
class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400"
|
||||
:disabled="handlers.getPayload(message)!.applying"
|
||||
>
|
||||
<option value="" disabled>{{ $t('chat.shippingNoticeMapping.selectHeader') }}</option>
|
||||
<option v-for="h in (handlers.getPayload(message)!.schema_preview.headers || [])" :key="`part-number-${h}`" :value="h">{{ handlers.normalizeHeader(h) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.shippingNoticeMapping.availableQtyColumnRequired') }}</span>
|
||||
<select
|
||||
v-model="handlers.getPayload(message)!.form.available_qty"
|
||||
class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400"
|
||||
:disabled="handlers.getPayload(message)!.applying"
|
||||
>
|
||||
<option value="" disabled>{{ $t('chat.shippingNoticeMapping.selectHeader') }}</option>
|
||||
<option v-for="h in (handlers.getPayload(message)!.schema_preview.headers || [])" :key="`qty-${h}`" :value="h">{{ handlers.normalizeHeader(h) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1.5 md:col-span-2">
|
||||
<span class="text-xs font-semibold text-muted">{{ $t('chat.shippingNoticeMapping.reservationIdColumnRequired') }}</span>
|
||||
<select
|
||||
v-model="handlers.getPayload(message)!.form.reservation_id"
|
||||
class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400"
|
||||
:disabled="handlers.getPayload(message)!.applying"
|
||||
>
|
||||
<option value="" disabled>{{ $t('chat.shippingNoticeMapping.selectHeader') }}</option>
|
||||
<option v-for="h in (handlers.getPayload(message)!.schema_preview.headers || [])" :key="`rid-${h}`" :value="h">{{ handlers.normalizeHeader(h) }}</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-3">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-4 py-2 text-sm font-medium text-secondary transition hover:bg-surface-soft disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="handlers.getPayload(message)!.applying"
|
||||
@click="handlers.reupload(message)"
|
||||
>
|
||||
{{ $t('chat.shippingNoticeMapping.reupload') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-emerald-600 px-4 py-2 text-sm font-medium text-white transition hover:bg-emerald-700 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="handlers.getPayload(message)!.applying"
|
||||
@click="handlers.apply(message)"
|
||||
>
|
||||
{{ handlers.getPayload(message)!.applying ? $t('chat.shippingNoticeMapping.applying') : $t('chat.shippingNoticeMapping.applyAndParse') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* features/chat/components/messages/shippingMessageHandlers.ts
|
||||
* 用途:定义发货通知订单复核与库存匹配消息共用的页面处理器契约。
|
||||
* 依赖:chat.types、shipping.api.types、shipping.types。
|
||||
* 逻辑:页面组合处理器后传给消息列表;不包含已下线的任务级库存列映射能力。
|
||||
*/
|
||||
import type { ChatMessage } from '../../types/chat.types';
|
||||
import type { ShippingNoticeHeader, ShippingNoticeLine } from '../../types/shipping.api.types';
|
||||
import type { ShippingMatchResultPayload, ShippingParseReviewPayload } from '../../types/shipping.types';
|
||||
|
||||
export interface ShippingMessageHandlers {
|
||||
getParseReviewPayload: (msg: ChatMessage) => ShippingParseReviewPayload | null;
|
||||
getMatchResultPayload: (msg: ChatMessage) => ShippingMatchResultPayload | null;
|
||||
updateHeader: (msg: ChatMessage, fields: Partial<ShippingNoticeHeader>) => Promise<boolean>;
|
||||
updateLine: (msg: ChatMessage, lineIndex: number, patch: Partial<ShippingNoticeLine>) => Promise<boolean>;
|
||||
addLine: (msg: ChatMessage, line: Partial<ShippingNoticeLine>) => Promise<boolean>;
|
||||
removeLine: (msg: ChatMessage, lineIndex: number) => Promise<boolean>;
|
||||
}
|
||||
Reference in new issue
Block a user