feat(shipping-notice): 新增发货批次和任务管理功能,支持批次创建与任务处理
This commit is contained in:
1 parent
457f0f4e5e
commit
634dee4b81
81 files changed
+9088
-3625
No files matched your search
@@ -1,13 +1,17 @@
|
||||
/**
|
||||
/**
|
||||
* features/chat/api/shipping.api.ts
|
||||
* 货代发货 HTTP API:任务列表、上传库存、映射、决策、Excel 生成等。
|
||||
* 后端路由前缀为 /api/workspace/shipping-tasks,由 chat 域 Agent 流程与工作台页面共用。
|
||||
* 用途:封装发货通知相关 HTTP API,包括任务/批次查询、库存上传、映射确认、人工决策与 Excel 导出。
|
||||
* 依赖:浏览器 fetch、getAuthHeaders、shipping.api.types 类型定义。
|
||||
* 逻辑:上游由 useChatShipping 与 shipping/* handler 调用本文件;本文件统一请求工作台后端 `/api/workspace/*` 路由并抛出标准错误。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import type {
|
||||
ShippingBatchSummary,
|
||||
ShippingChatActionsResponse,
|
||||
ShippingDecisionResponse,
|
||||
ShippingInventoryUploadResponse,
|
||||
ShippingNoticeHeader,
|
||||
ShippingNoticeLine,
|
||||
ShippingNoticeUploadResponse,
|
||||
ShippingTaskCreateResponse,
|
||||
ShippingTaskDetail,
|
||||
@@ -24,6 +28,7 @@ async function getJson<T>(url: string): Promise<T> {
|
||||
}
|
||||
|
||||
export const listWorkspaceShippingTasks = (params?: { process_status?: string; limit?: number }) => {
|
||||
/** 拉取当前用户可见的发货任务列表。 */
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.process_status) sp.set('process_status', params.process_status);
|
||||
if (params?.limit) sp.set('limit', String(params.limit));
|
||||
@@ -31,17 +36,46 @@ export const listWorkspaceShippingTasks = (params?: { process_status?: string; l
|
||||
return getJson<ShippingTaskSummary[]>(`/api/workspace/shipping-tasks${qs ? '?' + qs : ''}`);
|
||||
};
|
||||
|
||||
export const listWorkspaceShippingBatches = (params?: { limit?: number }) => {
|
||||
/** 拉取当前用户的发货批次摘要列表。 */
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.limit) sp.set('limit', String(params.limit));
|
||||
const qs = sp.toString();
|
||||
return getJson<ShippingBatchSummary[]>(`/api/workspace/shipping-batches${qs ? '?' + qs : ''}`);
|
||||
};
|
||||
|
||||
/** 获取批次详情、批次任务列表与当前焦点任务。 */
|
||||
export const getWorkspaceShippingBatch = (batchNo: string) =>
|
||||
getJson<ShippingBatchSummary & { tasks?: ShippingTaskSummary[]; focus_task?: ShippingTaskSummary | null }>(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}`,
|
||||
);
|
||||
|
||||
/** 获取指定批次当前焦点任务。 */
|
||||
export const getWorkspaceShippingBatchFocusTask = (batchNo: string) =>
|
||||
getJson<ShippingTaskSummary>(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}/focus-task`,
|
||||
);
|
||||
|
||||
/** 获取单个发货任务详情。 */
|
||||
export const getWorkspaceShippingTask = (taskNo: string) =>
|
||||
getJson<ShippingTaskDetail>(`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}`);
|
||||
|
||||
/** 生成任务导出文件的前端下载 URL。 */
|
||||
export const workspaceShippingExportUrl = (taskNo: string) =>
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/export`;
|
||||
|
||||
/** 获取聊天气泡动作按钮、检查点和 human options。 */
|
||||
export const getShippingChatActions = (taskNo: string) =>
|
||||
getJson<ShippingChatActionsResponse>(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/chat-actions`,
|
||||
);
|
||||
|
||||
/**
|
||||
* 上传库存 Excel,并由后端完成解析与 schema preview 生成。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param file - 用户选择的库存文件
|
||||
* @returns 库存上传与解析结果
|
||||
*/
|
||||
export async function uploadWorkspaceShippingInventory(taskNo: string, file: File) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
@@ -58,6 +92,12 @@ export async function uploadWorkspaceShippingInventory(taskNo: string, file: Fil
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交库存字段映射。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param columnMappingJson - 前端表单确认后的 map_json
|
||||
* @returns 映射应用与库存解析结果
|
||||
*/
|
||||
export async function applyWorkspaceShippingInventoryMapping(taskNo: string, columnMappingJson: Record<string, unknown>) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/apply-inventory-mapping`,
|
||||
@@ -74,6 +114,11 @@ export async function applyWorkspaceShippingInventoryMapping(taskNo: string, col
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建单个发货任务。
|
||||
* @param params - 建单参数,可包含 source_type、conversation_id、raw_content
|
||||
* @returns 建单结果
|
||||
*/
|
||||
export async function createWorkspaceShippingTask(params?: {
|
||||
source_type?: string;
|
||||
conversation_id?: string;
|
||||
@@ -91,6 +136,12 @@ export async function createWorkspaceShippingTask(params?: {
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传单个发货通知附件并立即建单解析。
|
||||
* @param file - 发货通知文件
|
||||
* @param conversationId - 可选会话 ID,用于把任务绑定到聊天会话
|
||||
* @returns 建单与解析结果
|
||||
*/
|
||||
export async function createWorkspaceShippingTaskFromNotice(file: File, conversationId?: string) {
|
||||
const form = new FormData();
|
||||
form.append('file', file);
|
||||
@@ -109,6 +160,67 @@ export async function createWorkspaceShippingTaskFromNotice(file: File, conversa
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传多份发货通知并创建批次。
|
||||
* @param files - 发货通知附件列表
|
||||
* @param conversationId - 可选会话 ID
|
||||
* @returns 批次与任务创建结果
|
||||
*/
|
||||
export async function createWorkspaceShippingBatchFromNotices(files: File[], conversationId?: string) {
|
||||
const form = new FormData();
|
||||
files.forEach((file) => form.append('files', file));
|
||||
if (conversationId) form.append('conversation_id', conversationId);
|
||||
const headers = getAuthHeaders();
|
||||
delete (headers as Record<string, string>)['Content-Type'];
|
||||
const res = await fetch('/api/workspace/shipping-batches/create-from-notices', {
|
||||
method: 'POST',
|
||||
headers,
|
||||
body: form,
|
||||
});
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingNoticeUploadResponse & {
|
||||
error?: string;
|
||||
batch_no?: string;
|
||||
data?: unknown;
|
||||
};
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换批次当前焦点任务。
|
||||
* @param batchNo - 批次编号
|
||||
* @param taskNo - 目标任务编号
|
||||
* @returns 更新后的批次摘要与焦点任务
|
||||
*/
|
||||
export async function switchWorkspaceShippingBatchFocusTask(batchNo: string, taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-batches/${encodeURIComponent(batchNo)}/focus-task`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ task_no: taskNo }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as {
|
||||
error?: string;
|
||||
batch?: ShippingBatchSummary;
|
||||
focus_task?: ShippingTaskSummary;
|
||||
};
|
||||
if (!res.ok) {
|
||||
throw new Error(body.error || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交人工决策。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param decision - 决策 ID,如 confirm、reject、reparse
|
||||
* @param comment - 可选备注
|
||||
* @returns 决策执行结果
|
||||
*/
|
||||
export async function submitWorkspaceShippingDecision(taskNo: string, decision: string, comment?: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/submit-decision`,
|
||||
@@ -125,6 +237,121 @@ export async function submitWorkspaceShippingDecision(taskNo: string, decision:
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新发货通知单头字段。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param fields - 需要更新的单头字段
|
||||
* @param comment - 可选操作备注
|
||||
* @returns 更新结果
|
||||
*/
|
||||
export async function updateWorkspaceShippingNoticeFields(
|
||||
taskNo: string,
|
||||
fields: Partial<ShippingNoticeHeader>,
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-fields`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ fields, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新指定订单行。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param lineIndex - 订单行下标
|
||||
* @param patch - 行字段补丁
|
||||
* @param comment - 可选操作备注
|
||||
* @returns 更新结果
|
||||
*/
|
||||
export async function updateWorkspaceShippingNoticeLine(
|
||||
taskNo: string,
|
||||
lineIndex: number,
|
||||
patch: Partial<ShippingNoticeLine> & { quantity?: number },
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/update-notice-line`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ line_index: lineIndex, patch, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 为发货通知新增订单行。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param line - 新增的订单行内容
|
||||
* @param comment - 可选操作备注
|
||||
* @returns 更新结果
|
||||
*/
|
||||
export async function addWorkspaceShippingNoticeLine(
|
||||
taskNo: string,
|
||||
line: Partial<ShippingNoticeLine> & { quantity?: number },
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/add-notice-line`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ line, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定订单行。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param lineIndex - 待删除的订单行下标
|
||||
* @param comment - 可选操作备注
|
||||
* @returns 更新结果
|
||||
*/
|
||||
export async function removeWorkspaceShippingNoticeLine(
|
||||
taskNo: string,
|
||||
lineIndex: number,
|
||||
comment?: string,
|
||||
) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/remove-notice-line`,
|
||||
{
|
||||
method: 'POST',
|
||||
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ line_index: lineIndex, ...(comment ? { comment } : {}) }),
|
||||
},
|
||||
);
|
||||
const body = (await res.json().catch(() => ({}))) as ShippingDecisionResponse & { error?: string };
|
||||
if (!res.ok || body.status === 'failed') {
|
||||
throw new Error(body.error || body.message || res.statusText);
|
||||
}
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行库存匹配。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @returns 匹配结果与后续动作提示
|
||||
*/
|
||||
export async function matchWorkspaceShippingInventory(taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/match-inventory`,
|
||||
@@ -141,7 +368,12 @@ export async function matchWorkspaceShippingInventory(taskNo: string) {
|
||||
return body;
|
||||
}
|
||||
|
||||
/** Hxops 聊天兜底:等同 Dify auto_progress Tool */
|
||||
/**
|
||||
* 以用户态触发自动推进,作为聊天前端兜底入口。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @param lang - 可选语言代码
|
||||
* @returns 自动推进结果
|
||||
*/
|
||||
export async function autoProgressWorkspaceShippingTask(taskNo: string, lang?: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/auto-progress`,
|
||||
@@ -158,6 +390,11 @@ export async function autoProgressWorkspaceShippingTask(taskNo: string, lang?: s
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 标记货代系统已人工上传完成。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @returns 上传确认结果
|
||||
*/
|
||||
export async function markWorkspaceShippingManualUploaded(taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/mark-manual-uploaded`,
|
||||
@@ -174,6 +411,11 @@ export async function markWorkspaceShippingManualUploaded(taskNo: string) {
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成发货 Excel。
|
||||
* @param taskNo - 发货任务编号
|
||||
* @returns 生成结果,成功时通常会包含下载链接
|
||||
*/
|
||||
export async function generateWorkspaceShippingExcel(taskNo: string) {
|
||||
const res = await fetch(
|
||||
`/api/workspace/shipping-tasks/${encodeURIComponent(taskNo)}/generate-excel`,
|
||||
@@ -190,13 +432,18 @@ export async function generateWorkspaceShippingExcel(taskNo: string) {
|
||||
return body;
|
||||
}
|
||||
|
||||
/** 货代发货 Agent 显示名称,用于路由与 Agent 匹配 */
|
||||
/** 货代发货 Agent 显示名称,用于聊天路由与 Agent 匹配。 */
|
||||
export const SHIPPING_NOTICE_AGENT_NAME = '货代发货通知 Agent';
|
||||
|
||||
export type {
|
||||
ShippingBatchSummary,
|
||||
ShippingChatAction,
|
||||
ShippingChatActionsResponse,
|
||||
ShippingDecisionResponse,
|
||||
ShippingInventoryUploadResponse,
|
||||
ShippingMatchLineResult,
|
||||
ShippingNoticeHeader,
|
||||
ShippingNoticeLine,
|
||||
ShippingNoticeUploadResponse,
|
||||
ShippingTaskCreateResponse,
|
||||
ShippingTaskDetail,
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
/**
|
||||
/**
|
||||
* features/chat/components/ChatViewContent.vue
|
||||
* 对话页主区域:侧栏、消息列表、输入栏与内置浏览器。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { Loader2 } from 'lucide-vue-next';
|
||||
import ChatShell from '@/shared/layouts/ChatShell.vue';
|
||||
import ChatSidebar from '@/features/chat/components/ChatSidebar.vue';
|
||||
@@ -10,9 +12,68 @@ import ChatInputBar from '@/features/chat/components/ChatInputBar.vue';
|
||||
import ChatMessageList from '@/features/chat/components/ChatMessageList.vue';
|
||||
import ChatMobileHeader from '@/features/chat/components/ChatMobileHeader.vue';
|
||||
import ChatBrowserPanel from '@/features/chat/components/ChatBrowserPanel.vue';
|
||||
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
|
||||
import { useChatPageContext } from '@/features/chat/composables/chat.context';
|
||||
import { buildShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import type { ShippingTaskSummary } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const page = useChatPageContext();
|
||||
const { t } = useI18n();
|
||||
|
||||
const statusMeta = (status?: string | null) => {
|
||||
const map: Record<string, { label: string; chip: string }> = {
|
||||
created: { label: t('chat.shippingNoticeUi.status.created'), chip: 'bg-slate-100 text-slate-700' },
|
||||
waiting_inventory: { label: t('chat.shippingNoticeUi.status.waitingInventory'), chip: 'bg-amber-100 text-amber-700' },
|
||||
inventory_ready: { label: t('chat.shippingNoticeUi.status.inventoryReady'), chip: 'bg-sky-100 text-sky-700' },
|
||||
matched: { label: t('chat.shippingNoticeUi.status.matched'), chip: 'bg-emerald-100 text-emerald-700' },
|
||||
waiting_upload: { label: t('chat.shippingNoticeUi.status.waitingUpload'), chip: 'bg-orange-100 text-orange-700' },
|
||||
uploaded: { label: t('chat.shippingNoticeUi.status.uploaded'), chip: 'bg-emerald-100 text-emerald-700' },
|
||||
upload_failed: { label: t('chat.shippingNoticeUi.status.uploadFailed'), chip: 'bg-rose-100 text-rose-700' },
|
||||
rejected: { label: t('chat.shippingNoticeUi.status.rejected'), chip: 'bg-rose-100 text-rose-700' },
|
||||
closed: { label: t('chat.shippingNoticeUi.status.closed'), chip: 'bg-slate-100 text-slate-700' },
|
||||
};
|
||||
return map[String(status || '').trim()] || { label: String(status || t('chat.shippingNoticeUi.processing')), chip: 'bg-slate-100 text-slate-700' };
|
||||
};
|
||||
|
||||
const stepLabel = (step?: string | null) => {
|
||||
const map: Record<string, string> = {
|
||||
step1_notice_submit: t('chat.shippingNoticeUi.currentStep.noticeParse'),
|
||||
step2_inventory_prepare: t('chat.shippingNoticeUi.currentStep.inventoryPrepare'),
|
||||
step3_inventory_match: t('chat.shippingNoticeUi.currentStep.inventoryMatch'),
|
||||
step4_shortage_review: t('chat.shippingNoticeUi.currentStep.shortageHandle'),
|
||||
step5_export_excel: t('chat.shippingNoticeUi.currentStep.generateExcel'),
|
||||
step6_upload_freight: t('chat.shippingNoticeUi.currentStep.uploadFreight'),
|
||||
step7_finish: t('chat.shippingNoticeUi.currentStep.finishArchive'),
|
||||
};
|
||||
return map[String(step || '').trim()] || t('chat.shippingNoticeUi.processing');
|
||||
};
|
||||
|
||||
const currentShippingTask = computed<ShippingTaskSummary | null>(() => {
|
||||
const focusTaskNo = String(page.shippingBatchSummary?.current_focus_task_no || '').trim();
|
||||
if (!focusTaskNo || !Array.isArray(page.shippingBatchTasks)) return null;
|
||||
return page.shippingBatchTasks.find((task: ShippingTaskSummary) => task.task_no === focusTaskNo) || null;
|
||||
});
|
||||
|
||||
const currentShippingTaskSource = computed(() => currentShippingTask.value || page.activeShippingTaskDetail || null);
|
||||
const currentShippingSteps = computed(() => buildShippingWorkflowSteps(currentShippingTaskSource.value));
|
||||
const currentShippingBatchProgress = computed(() => {
|
||||
const task = currentShippingTask.value;
|
||||
if (!task?.batch_index || !task?.batch_total) return '';
|
||||
return t('chat.shippingNoticeUi.batchProgress', { index: task.batch_index, total: task.batch_total });
|
||||
});
|
||||
const batchCompletedCount = computed(() =>
|
||||
Number(page.shippingBatchSummary?.process_summary?.completed || 0),
|
||||
);
|
||||
const batchRunningCount = computed(() =>
|
||||
Number(page.shippingBatchSummary?.process_summary?.running || 0),
|
||||
);
|
||||
const batchFileCount = computed(() =>
|
||||
Number(page.shippingBatchSummary?.file_count || 0),
|
||||
);
|
||||
const batchCompletionPercent = computed(() => {
|
||||
if (!batchFileCount.value) return 0;
|
||||
return Math.min(100, Math.max(0, Math.round((batchCompletedCount.value / batchFileCount.value) * 100)));
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -80,6 +141,148 @@ const page = useChatPageContext();
|
||||
<template v-else>
|
||||
<div class="flex min-h-0 flex-1">
|
||||
<div class="flex min-h-0 flex-1 flex-col">
|
||||
<div
|
||||
v-if="page.isShippingNoticeAgent && (page.shippingBatchSummary || currentShippingTaskSource)"
|
||||
class="mx-4 mt-4 rounded-3xl border border-default/80 bg-[linear-gradient(135deg,rgba(255,255,255,0.96),rgba(246,248,251,0.92))] px-4 py-3 shadow-sm"
|
||||
>
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div class="space-y-1">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted">
|
||||
{{ page.shippingBatchSummary ? t('chat.shippingNoticeUi.batchTitle') : t('chat.shippingNoticeUi.taskTitle') }}
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
v-if="page.shippingBatchSummary"
|
||||
class="font-mono text-sm font-semibold text-primary"
|
||||
>
|
||||
{{ page.shippingBatchSummary.batch_no }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="currentShippingTaskSource"
|
||||
class="font-mono text-sm font-semibold text-primary"
|
||||
>
|
||||
{{ currentShippingTaskSource.task_no }}
|
||||
</span>
|
||||
<span
|
||||
v-if="page.shippingBatchSummary?.current_focus_task_no"
|
||||
class="rounded-full bg-brand-50 px-2.5 py-1 text-xs font-medium text-brand-700"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.currentTask', { taskId: page.shippingBatchSummary.current_focus_task_no }) }}
|
||||
</span>
|
||||
<span
|
||||
v-if="currentShippingBatchProgress"
|
||||
class="rounded-full bg-sky-50 px-2.5 py-1 text-xs font-medium text-sky-700"
|
||||
>
|
||||
{{ currentShippingBatchProgress }}
|
||||
</span>
|
||||
</div>
|
||||
<div v-if="currentShippingTaskSource" class="flex flex-wrap items-center gap-2 text-xs text-secondary">
|
||||
<span class="truncate font-medium text-primary">
|
||||
{{ currentShippingTaskSource.customer_name || currentShippingTaskSource.source_file_name || t('chat.shippingNoticeUi.currentNotice') }}
|
||||
</span>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 font-medium"
|
||||
:class="statusMeta(currentShippingTaskSource.process_status).chip"
|
||||
>
|
||||
{{ statusMeta(currentShippingTaskSource.process_status).label }}
|
||||
</span>
|
||||
<span class="text-muted">{{ t('chat.shippingNoticeUi.stepperTitle') }}:{{ stepLabel(currentShippingTaskSource.current_step) }}</span>
|
||||
</div>
|
||||
<ShippingWorkflowStepper
|
||||
v-if="currentShippingTaskSource"
|
||||
:steps="currentShippingSteps"
|
||||
compact
|
||||
class="pt-2"
|
||||
/>
|
||||
<div class="flex flex-wrap gap-2 pt-1 text-xs">
|
||||
<button
|
||||
v-if="page.shippingBatchSummary"
|
||||
type="button"
|
||||
class="rounded-full border border-default px-2.5 py-1 text-secondary transition hover:bg-surface-soft"
|
||||
@click="page.input = '上一票'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.prevTask') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="page.shippingBatchSummary"
|
||||
type="button"
|
||||
class="rounded-full border border-default px-2.5 py-1 text-secondary transition hover:bg-surface-soft"
|
||||
@click="page.input = '下一票'"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.nextTask') }}
|
||||
</button>
|
||||
<button
|
||||
v-if="page.shippingBatchTasks?.length > 1"
|
||||
type="button"
|
||||
class="rounded-full border border-default px-2.5 py-1 text-secondary transition hover:bg-surface-soft"
|
||||
@click="page.shippingBatchTasksExpanded = !page.shippingBatchTasksExpanded"
|
||||
>
|
||||
{{ page.shippingBatchTasksExpanded ? t('chat.shippingNoticeUi.collapseTasks') : t('chat.shippingNoticeUi.viewTasks') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="page.shippingBatchSummary" class="grid grid-cols-3 gap-2 text-right text-xs">
|
||||
<div class="rounded-2xl bg-surface px-3 py-2">
|
||||
<div class="text-muted">{{ t('chat.shippingNoticeUi.fileCount') }}</div>
|
||||
<div class="mt-1 text-sm font-semibold text-primary">{{ batchFileCount }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-surface px-3 py-2">
|
||||
<div class="text-muted">{{ t('chat.shippingNoticeUi.runningCount') }}</div>
|
||||
<div class="mt-1 text-sm font-semibold text-primary">{{ batchRunningCount }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-surface px-3 py-2">
|
||||
<div class="text-muted">{{ t('chat.shippingNoticeUi.completedCount') }}</div>
|
||||
<div class="mt-1 text-sm font-semibold text-primary">{{ batchCompletedCount }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="page.shippingBatchSummary"
|
||||
class="mt-3 space-y-1 border-t border-default/70 pt-3"
|
||||
>
|
||||
<div class="flex items-center justify-between text-[11px] text-muted">
|
||||
<span>{{ t('chat.shippingNoticeUi.batchProgressTitle') }}</span>
|
||||
<span>{{ batchCompletedCount }}/{{ batchFileCount }} · {{ batchCompletionPercent }}%</span>
|
||||
</div>
|
||||
<div class="h-2 overflow-hidden rounded-full bg-slate-200">
|
||||
<div
|
||||
class="h-full rounded-full bg-brand-500 transition-all"
|
||||
:style="{ width: `${batchCompletionPercent}%` }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="page.shippingBatchTasksExpanded && page.shippingBatchTasks?.length"
|
||||
class="mt-3 grid gap-2 border-t border-default/70 pt-3 sm:grid-cols-2 xl:grid-cols-3"
|
||||
>
|
||||
<button
|
||||
v-for="task in page.shippingBatchTasks"
|
||||
:key="task.task_no"
|
||||
type="button"
|
||||
class="rounded-2xl border px-3 py-3 text-left transition"
|
||||
:class="task.task_no === page.shippingBatchSummary?.current_focus_task_no ? 'border-brand-300 bg-brand-50/80 shadow-sm' : 'border-default bg-surface hover:bg-surface-soft'"
|
||||
@click="page.switchShippingFocusTask(task.task_no)"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<div class="font-mono text-xs font-semibold text-primary">{{ task.task_no }}</div>
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-[11px] font-medium"
|
||||
:class="statusMeta(task.process_status).chip"
|
||||
>
|
||||
{{ statusMeta(task.process_status).label }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-2 truncate text-sm font-medium text-secondary">{{ task.customer_name || task.source_file_name || '未命名通知' }}</div>
|
||||
<div class="mt-1 text-[11px] text-muted">
|
||||
{{ stepLabel(task.current_step) }}
|
||||
<span v-if="task.batch_index && task.batch_total">
|
||||
· {{ t('chat.shippingNoticeUi.batchProgress', { index: task.batch_index, total: task.batch_total }) }}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ChatMessageList
|
||||
:messages="page.messages"
|
||||
:agent-name="page.currentAgent?.name || 'AI'"
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* features/chat/components/ShippingWorkflowStepper.vue
|
||||
* 货代发货七步流程 Stepper。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingWorkflowStepItem } from '../shipping';
|
||||
|
||||
defineProps<{
|
||||
steps: ShippingWorkflowStepItem[];
|
||||
compact?: boolean;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const stepClass = (status: ShippingWorkflowStepItem['status']) => {
|
||||
if (status === 'completed') return 'border-emerald-200 bg-emerald-50 text-emerald-700';
|
||||
if (status === 'current') return 'border-brand-300 bg-brand-50 text-brand-700';
|
||||
if (status === 'blocked') return 'border-rose-200 bg-rose-50 text-rose-700';
|
||||
return 'border-default bg-surface text-muted';
|
||||
};
|
||||
|
||||
const dotClass = (status: ShippingWorkflowStepItem['status']) => {
|
||||
if (status === 'completed') return 'bg-emerald-500';
|
||||
if (status === 'current') return 'bg-brand-500';
|
||||
if (status === 'blocked') return 'bg-rose-500';
|
||||
return 'bg-slate-300';
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-2">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.18em] text-muted">{{ t('chat.shippingNoticeUi.stepperTitle') }}</div>
|
||||
<div class="grid gap-2" :class="compact ? 'sm:grid-cols-4 xl:grid-cols-7' : 'md:grid-cols-4 xl:grid-cols-7'">
|
||||
<div
|
||||
v-for="(step, index) in steps"
|
||||
:key="step.id"
|
||||
class="rounded-2xl border px-3 py-2.5 transition"
|
||||
:class="stepClass(step.status)"
|
||||
>
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="inline-flex h-5 min-w-5 items-center justify-center rounded-full text-[11px] font-semibold text-white" :class="dotClass(step.status)">
|
||||
{{ index + 1 }}
|
||||
</span>
|
||||
<span class="text-xs font-semibold">{{ t(step.label) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -7,13 +7,16 @@ import { computed } from 'vue';
|
||||
import { Check, Copy, Edit2, LayoutGrid, MessageSquareText, RotateCw } from 'lucide-vue-next';
|
||||
import LeaveMessageBlock, { type LeaveMessageHandlers } from './LeaveMessageBlock.vue';
|
||||
import ShippingInventoryMappingMessage, { type ShippingMappingHandlers } from './ShippingInventoryMappingMessage.vue';
|
||||
import ShippingMatchResultCard from './ShippingMatchResultCard.vue';
|
||||
import ShippingParseReviewMessage, { type ShippingParseReviewHandlers } from './ShippingParseReviewMessage.vue';
|
||||
import type { ChatMessage, SourceFileLink } from '../../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload } from '../../types/shipping.types';
|
||||
import type { ShippingInventoryMappingFormPayload, ShippingMatchResultPayload } from '../../types/shipping.types';
|
||||
|
||||
export interface ChatMessageBubbleHandlers {
|
||||
renderMarkdown: (text: string) => string;
|
||||
onMarkdownClick: (event: MouseEvent) => void;
|
||||
getShippingInventoryMappingPayload: (msg: ChatMessage) => ShippingInventoryMappingFormPayload | null;
|
||||
getShippingMatchResultPayload: (msg: ChatMessage) => ShippingMatchResultPayload | null;
|
||||
canOpenQueryPreview: (msg: ChatMessage) => boolean;
|
||||
getQueryPreviewSummary: (msg: ChatMessage) => string;
|
||||
openQueryPreviewDialog: (msg: ChatMessage) => void;
|
||||
@@ -77,8 +80,20 @@ const showSourceSection = computed(() => {
|
||||
});
|
||||
|
||||
const showActions = computed(() => message.type !== 'leave-form');
|
||||
const showShippingActionsPanel = computed(() =>
|
||||
isShippingNoticeAgent
|
||||
&& !!message.shipping_actions?.length
|
||||
&& message.type !== 'shipping-match-result',
|
||||
);
|
||||
const isLastMessage = computed(() => index === messageCount - 1);
|
||||
const isCopied = computed(() => copiedIndex === index);
|
||||
const shippingParseReviewHandlers = computed<ShippingParseReviewHandlers>(() => ({
|
||||
getPayload: shippingHandlers.getParseReviewPayload,
|
||||
updateHeader: shippingHandlers.updateHeader,
|
||||
updateLine: shippingHandlers.updateLine,
|
||||
addLine: shippingHandlers.addLine,
|
||||
removeLine: shippingHandlers.removeLine,
|
||||
}));
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -110,6 +125,22 @@ const isCopied = computed(() => copiedIndex === index);
|
||||
:message="message"
|
||||
:handlers="shippingHandlers"
|
||||
/>
|
||||
<ShippingParseReviewMessage
|
||||
v-else-if="message.type === 'shipping-parse-review' && shippingHandlers.getParseReviewPayload(message)"
|
||||
:message="message"
|
||||
:handlers="shippingParseReviewHandlers"
|
||||
/>
|
||||
<ShippingMatchResultCard
|
||||
v-else-if="message.type === 'shipping-match-result' && handlers.getShippingMatchResultPayload(message)"
|
||||
:task-id="handlers.getShippingMatchResultPayload(message)!.taskId"
|
||||
:match-status="handlers.getShippingMatchResultPayload(message)!.match_status"
|
||||
:line-results="handlers.getShippingMatchResultPayload(message)!.line_results"
|
||||
:shortage-lines="handlers.getShippingMatchResultPayload(message)!.shortage_lines"
|
||||
:action-buttons="handlers.getShippingMatchResultPayload(message)!.action_buttons"
|
||||
:action-busy="isThinking || message.shipping_actions_used"
|
||||
:action-button-class="handlers.shippingActionButtonClass"
|
||||
:on-action-click="(action) => handlers.onShippingActionClick(message, action)"
|
||||
/>
|
||||
<div
|
||||
v-else
|
||||
class="chat-markdown prose prose-sm max-w-none leading-7 text-primary prose-a:text-blue-600 prose-p:my-1 prose-li:my-0.5 prose-ol:my-2 prose-ul:my-2 prose-headings:my-2 prose-hr:my-3 prose-code:rounded prose-code:bg-slate-100 prose-code:px-1 prose-code:text-blue-700 prose-pre:my-3 prose-pre:border prose-pre:border-slate-700 prose-pre:bg-slate-900 prose-pre:text-slate-100 prose-th:border prose-th:border-slate-200 prose-th:bg-slate-50 prose-th:px-3 prose-th:py-2 prose-th:text-left prose-td:border prose-td:border-slate-200 prose-td:px-3 prose-td:py-2"
|
||||
@@ -132,7 +163,7 @@ const isCopied = computed(() => copiedIndex === index);
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="isShippingNoticeAgent && message.shipping_actions?.length"
|
||||
v-if="showShippingActionsPanel"
|
||||
class="mt-4 space-y-2 border-t border-default pt-4"
|
||||
>
|
||||
<div class="text-xs font-medium text-muted">{{ $t('chat.shippingNoticeActionsHint') }}</div>
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import type { ChatMessage } from '../../types/chat.types';
|
||||
import type { ShippingInventoryMappingFormPayload } from '../../types/shipping.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;
|
||||
@@ -13,6 +14,14 @@ export interface ShippingMappingHandlers {
|
||||
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<{
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
/**
|
||||
* features/chat/components/messages/ShippingMatchResultCard.vue
|
||||
* 用途:出货 Agent 对话区与工作台共用的库存匹配/缺口结果卡片。
|
||||
* 依赖:shipping.api.types、vue-i18n。
|
||||
* 逻辑:由 Chat 消息区和 ShippingNoticeView 传入匹配结果;本组件只负责结构化展示状态、缺口与操作按钮。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type {
|
||||
ShippingChatAction,
|
||||
ShippingMatchLineResult,
|
||||
} from '../../types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
taskId: string;
|
||||
matchStatus?: string | null;
|
||||
lineResults?: ShippingMatchLineResult[] | null;
|
||||
shortageLines?: ShippingMatchLineResult[] | null;
|
||||
actionButtons?: ShippingChatAction[] | null;
|
||||
actionBusy?: boolean;
|
||||
onActionClick?: (action: ShippingChatAction) => void;
|
||||
actionButtonClass?: (variant?: string) => string;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const formatQty = (value: unknown) => {
|
||||
const num = Number(value ?? 0);
|
||||
if (!Number.isFinite(num)) return '-';
|
||||
return Number.isInteger(num) ? String(num) : String(num);
|
||||
};
|
||||
|
||||
const rowStatusLabel = (status?: string | null) => {
|
||||
if (status === 'ok') return t('chat.shippingNoticeUi.rowStatus.ok');
|
||||
if (status === 'partial') return t('chat.shippingNoticeUi.rowStatus.partial');
|
||||
if (status === 'shortage') return t('chat.shippingNoticeUi.rowStatus.shortage');
|
||||
return status || '-';
|
||||
};
|
||||
|
||||
const matchStatusLabel = (status?: string | null) => {
|
||||
if (status === 'fulfillable') return t('chat.shippingNoticeUi.matchStatus.fulfillable');
|
||||
if (status === 'partial') return t('chat.shippingNoticeUi.matchStatus.partial');
|
||||
if (status === 'unfulfillable') return t('chat.shippingNoticeUi.matchStatus.unfulfillable');
|
||||
return status || t('chat.shippingNoticeUi.matchStatus.pending');
|
||||
};
|
||||
|
||||
const hasShortage = () => Array.isArray(props.shortageLines) && props.shortageLines.length > 0;
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="space-y-4 rounded-2xl border border-default bg-surface-soft/90 p-4">
|
||||
<div class="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ t('chat.shippingNoticeUi.matchResult') }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ t('chat.shippingNoticeUi.taskId', { taskId }) }}</div>
|
||||
</div>
|
||||
<span
|
||||
class="rounded-full px-2.5 py-1 text-xs font-semibold"
|
||||
:class="hasShortage()
|
||||
? 'bg-rose-100 text-rose-700'
|
||||
: 'bg-emerald-100 text-emerald-700'"
|
||||
>
|
||||
{{ matchStatusLabel(matchStatus) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div
|
||||
v-if="hasShortage()"
|
||||
class="rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.shortageBanner') }}
|
||||
</div>
|
||||
|
||||
<div v-if="lineResults?.length" class="overflow-x-auto rounded-xl border border-default">
|
||||
<table class="min-w-full text-sm">
|
||||
<thead class="bg-surface text-left text-xs text-muted">
|
||||
<tr>
|
||||
<th class="px-3 py-2">#</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingNoticeUi.reservationId') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingNoticeUi.sku') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingNoticeUi.orderDemand') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingNoticeUi.inventoryAvailable') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingNoticeUi.shortageQty') }}</th>
|
||||
<th class="px-3 py-2">{{ t('chat.shippingNoticeUi.statusLabel') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="(line, index) in lineResults"
|
||||
:key="`${taskId}-match-${index}`"
|
||||
class="border-t border-default/70"
|
||||
>
|
||||
<td class="px-3 py-2 text-secondary">{{ index + 1 }}</td>
|
||||
<td class="px-3 py-2 text-secondary">{{ line.reservation_id || '-' }}</td>
|
||||
<td class="px-3 py-2 font-mono text-secondary">{{ line.sku || '-' }}</td>
|
||||
<td class="px-3 py-2 text-secondary">{{ formatQty(line.required_qty) }}</td>
|
||||
<td class="px-3 py-2 text-secondary">{{ formatQty(line.available_qty) }}</td>
|
||||
<td class="px-3 py-2" :class="Number(line.shortage_qty || 0) > 0 ? 'font-semibold text-rose-700' : 'text-secondary'">
|
||||
{{ Number(line.shortage_qty || 0) > 0 ? formatQty(line.shortage_qty) : '-' }}
|
||||
</td>
|
||||
<td class="px-3 py-2">
|
||||
<span
|
||||
class="rounded-full px-2 py-0.5 text-xs font-medium"
|
||||
:class="line.line_status === 'ok'
|
||||
? 'bg-emerald-100 text-emerald-700'
|
||||
: line.line_status === 'partial'
|
||||
? 'bg-amber-100 text-amber-700'
|
||||
: 'bg-rose-100 text-rose-700'"
|
||||
>
|
||||
{{ rowStatusLabel(line.line_status) }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-if="shortageLines?.length" class="space-y-2">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ t('chat.shippingNoticeUi.shortageDetails') }}</div>
|
||||
<ul class="space-y-2 rounded-xl border border-rose-200 bg-rose-50/70 p-3 text-sm text-rose-700">
|
||||
<li
|
||||
v-for="(line, index) in shortageLines"
|
||||
:key="`${taskId}-shortage-${index}`"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.shortageRowDetail', { index: index + 1, reservationId: line.reservation_id || '-', sku: line.sku || '-', shortage: formatQty(line.shortage_qty) }) }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="actionButtons?.length" class="space-y-2 border-t border-default pt-4">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ t('chat.shippingNoticeUi.availableActions') }}</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="(action, index) in actionButtons"
|
||||
:key="`${taskId}-action-${action.id}-${index}`"
|
||||
type="button"
|
||||
:class="actionButtonClass
|
||||
? actionButtonClass(action.variant)
|
||||
: 'rounded-xl border border-default px-3 py-2 text-sm font-medium text-secondary hover:bg-surface'"
|
||||
:disabled="actionBusy"
|
||||
@click="onActionClick?.(action)"
|
||||
>
|
||||
{{ action.label }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,325 @@
|
||||
/**
|
||||
* features/chat/components/messages/ShippingParseReviewMessage.vue
|
||||
* 出货 Agent:parse_review 阶段订单表编辑消息 UI。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, reactive, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ChatMessage } from '../../types/chat.types';
|
||||
import type { ShippingParseReviewPayload } from '../../types/shipping.types';
|
||||
import type { ShippingNoticeHeader, ShippingNoticeLine } from '../../types/shipping.api.types';
|
||||
|
||||
export interface ShippingParseReviewHandlers {
|
||||
getPayload: (msg: ChatMessage) => ShippingParseReviewPayload | 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>;
|
||||
}
|
||||
|
||||
const { message, handlers } = defineProps<{
|
||||
message: ChatMessage;
|
||||
handlers: ShippingParseReviewHandlers;
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const editingHeader = ref(false);
|
||||
const editingLineIndex = ref<number | null>(null);
|
||||
const headerForm = reactive<ShippingNoticeHeader>({
|
||||
customer_name: '',
|
||||
customer_code: '',
|
||||
ship_to: '',
|
||||
po_number: '',
|
||||
required_date: '',
|
||||
});
|
||||
const lineForm = reactive<Partial<ShippingNoticeLine>>({
|
||||
reservation_id: '',
|
||||
sku: '',
|
||||
qty: 0,
|
||||
required_date: '',
|
||||
uom: '',
|
||||
});
|
||||
const addingLine = ref(false);
|
||||
|
||||
const payload = computed(() => handlers.getPayload(message));
|
||||
|
||||
watch(payload, (value) => {
|
||||
if (!value) return;
|
||||
headerForm.customer_name = value.header.customer_name ?? '';
|
||||
headerForm.customer_code = value.header.customer_code ?? '';
|
||||
headerForm.ship_to = value.header.ship_to ?? '';
|
||||
headerForm.po_number = value.header.po_number ?? '';
|
||||
headerForm.required_date = value.header.required_date ?? '';
|
||||
}, { immediate: true, deep: true });
|
||||
|
||||
watch(
|
||||
() => editingLineIndex.value,
|
||||
(value) => {
|
||||
if (value == null || !payload.value) return;
|
||||
const line = payload.value.lines[value];
|
||||
if (!line) return;
|
||||
lineForm.reservation_id = line.reservation_id ?? '';
|
||||
lineForm.sku = line.sku;
|
||||
lineForm.qty = line.qty;
|
||||
lineForm.required_date = line.required_date ?? '';
|
||||
lineForm.uom = line.uom ?? '';
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
const saveHeader = async () => {
|
||||
const ok = await handlers.updateHeader(message, {
|
||||
customer_name: headerForm.customer_name,
|
||||
customer_code: headerForm.customer_code,
|
||||
ship_to: headerForm.ship_to,
|
||||
po_number: headerForm.po_number,
|
||||
required_date: headerForm.required_date,
|
||||
});
|
||||
if (ok) editingHeader.value = false;
|
||||
};
|
||||
|
||||
const saveLine = async () => {
|
||||
if (editingLineIndex.value == null) return;
|
||||
const ok = await handlers.updateLine(message, editingLineIndex.value, {
|
||||
reservation_id: lineForm.reservation_id,
|
||||
sku: lineForm.sku,
|
||||
qty: Number(lineForm.qty || 0),
|
||||
required_date: lineForm.required_date,
|
||||
uom: lineForm.uom,
|
||||
});
|
||||
if (ok) editingLineIndex.value = null;
|
||||
};
|
||||
|
||||
const startAddLine = () => {
|
||||
addingLine.value = true;
|
||||
editingLineIndex.value = null;
|
||||
lineForm.reservation_id = '';
|
||||
lineForm.sku = '';
|
||||
lineForm.qty = 0;
|
||||
lineForm.required_date = '';
|
||||
lineForm.uom = '';
|
||||
};
|
||||
|
||||
const saveAddedLine = async () => {
|
||||
const ok = await handlers.addLine(message, {
|
||||
reservation_id: lineForm.reservation_id,
|
||||
sku: lineForm.sku,
|
||||
qty: Number(lineForm.qty || 0),
|
||||
required_date: lineForm.required_date,
|
||||
uom: lineForm.uom,
|
||||
});
|
||||
if (ok) addingLine.value = false;
|
||||
};
|
||||
|
||||
const removeLine = async (lineIndex: number) => {
|
||||
const ok = await handlers.removeLine(message, lineIndex);
|
||||
if (ok && editingLineIndex.value === lineIndex) {
|
||||
editingLineIndex.value = null;
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="payload" 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="flex items-start justify-between gap-4">
|
||||
<div>
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ t('chat.shippingNoticeUi.parseReviewHeader') }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ t('chat.shippingNoticeUi.taskId', { taskId: payload.taskId }) }}</div>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary transition hover:bg-surface disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="payload.saving"
|
||||
@click="editingHeader = !editingHeader"
|
||||
>
|
||||
{{ editingHeader ? t('chat.shippingNoticeUi.cancelEdit') : t('chat.shippingNoticeUi.editHeader') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="editingHeader" class="grid gap-3 md:grid-cols-2">
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.customer') }}</span>
|
||||
<input v-model="headerForm.customer_name" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.customerCode') }}</span>
|
||||
<input v-model="headerForm.customer_code" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5 md:col-span-2">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.shipTo') }}</span>
|
||||
<input v-model="headerForm.ship_to" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.poNumber') }}</span>
|
||||
<input v-model="headerForm.po_number" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.requiredDate') }}</span>
|
||||
<input v-model="headerForm.required_date" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<div class="md:col-span-2 flex justify-end gap-3">
|
||||
<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="payload.saving"
|
||||
@click="saveHeader"
|
||||
>
|
||||
{{ payload.saving ? t('chat.shippingNoticeUi.saving') : t('chat.shippingNoticeUi.saveHeader') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<table v-else class="w-full border-collapse text-sm">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.customer') }}</th>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ payload.header.customer_name || '-' }}</td>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.poNumber') }}</th>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ payload.header.po_number || '-' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.shipTo') }}</th>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ payload.header.ship_to || '-' }}</td>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.requiredDate') }}</th>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ payload.header.required_date || '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="space-y-2">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div class="text-xs font-bold uppercase tracking-wider text-muted">{{ t('chat.shippingNoticeUi.orderLines') }}</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary transition hover:bg-surface disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="payload.saving || addingLine"
|
||||
@click="startAddLine"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.addLine') }}
|
||||
</button>
|
||||
</div>
|
||||
<table class="w-full border-collapse text-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">#</th>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.reservationId') }}</th>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.sku') }}</th>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.qty') }}</th>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.requiredDate') }}</th>
|
||||
<th class="border border-default bg-surface px-3 py-2 text-left text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(line, lineIndex) in payload.lines" :key="`${payload.taskId}-${line.line_no || lineIndex}`">
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ lineIndex + 1 }}</td>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ line.reservation_id || '-' }}</td>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ line.sku }}</td>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ line.qty }}</td>
|
||||
<td class="border border-default px-3 py-2 text-secondary">{{ line.required_date || '-' }}</td>
|
||||
<td class="border border-default px-3 py-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary transition hover:bg-surface disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="payload.saving"
|
||||
@click="editingLineIndex = lineIndex"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.editLine') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="ml-2 rounded-xl border border-rose-200 px-3 py-1.5 text-xs font-medium text-rose-700 transition hover:bg-rose-50 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="payload.saving || payload.lines.length <= 1"
|
||||
@click="removeLine(lineIndex)"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.deleteLine') }}
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-if="addingLine" class="space-y-3 rounded-xl border border-emerald-200 bg-emerald-50/70 p-4">
|
||||
<div class="text-sm font-semibold text-emerald-700">{{ t('chat.shippingNoticeUi.addOrderLine') }}</div>
|
||||
<div class="grid gap-3 md:grid-cols-2">
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.reservationId') }}</span>
|
||||
<input v-model="lineForm.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" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.sku') }}</span>
|
||||
<input v-model="lineForm.sku" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.qty') }}</span>
|
||||
<input v-model.number="lineForm.qty" type="number" min="1" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.requiredDate') }}</span>
|
||||
<input v-model="lineForm.required_date" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</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 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="payload.saving"
|
||||
@click="addingLine = false"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.cancelEdit') }}
|
||||
</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="payload.saving"
|
||||
@click="saveAddedLine"
|
||||
>
|
||||
{{ payload.saving ? t('chat.shippingNoticeUi.saving') : t('chat.shippingNoticeUi.saveAddedLine') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="editingLineIndex !== null" class="space-y-3 rounded-xl border border-brand-200 bg-brand-50/70 p-4">
|
||||
<div class="text-sm font-semibold text-brand-700">{{ t('chat.shippingNoticeUi.editLineTitle', { index: editingLineIndex + 1 }) }}</div>
|
||||
<div class="grid gap-3 md:grid-cols-2">
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.reservationId') }}</span>
|
||||
<input v-model="lineForm.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" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.sku') }}</span>
|
||||
<input v-model="lineForm.sku" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.qty') }}</span>
|
||||
<input v-model.number="lineForm.qty" type="number" min="1" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</label>
|
||||
<label class="space-y-1.5">
|
||||
<span class="text-xs font-semibold text-muted">{{ t('chat.shippingNoticeUi.requiredDate') }}</span>
|
||||
<input v-model="lineForm.required_date" class="w-full rounded-xl border border-default px-3 py-2 text-sm text-secondary outline-none transition focus:border-blue-400" />
|
||||
</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 disabled:cursor-not-allowed disabled:opacity-60"
|
||||
:disabled="payload.saving"
|
||||
@click="editingLineIndex = null"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.cancelEdit') }}
|
||||
</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="payload.saving"
|
||||
@click="saveLine"
|
||||
>
|
||||
{{ payload.saving ? t('chat.shippingNoticeUi.saving') : t('chat.shippingNoticeUi.saveLineItem') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* features/chat/composables/useChatPage.ts
|
||||
* 对话页主编排:组合 SSE、Agent、附件、请假/出货、路由同步与 page/* 子模块。
|
||||
*/
|
||||
@@ -221,6 +221,7 @@ export function useChatPage() {
|
||||
onConversationLoadFailed: shipping.onConversationLoadFailed,
|
||||
isShippingNoticeAgent: shipping.isShippingNoticeAgent,
|
||||
shippingTaskIdFromQuery: shipping.shippingTaskIdFromQuery,
|
||||
shippingBatchNoFromQuery: shipping.shippingBatchNoFromQuery,
|
||||
clearHistory,
|
||||
clearAttachments: attachmentApi.clearAttachments,
|
||||
input,
|
||||
@@ -262,6 +263,7 @@ export function useChatPage() {
|
||||
getSourceMeta,
|
||||
getSourceBrief,
|
||||
getShippingInventoryMappingPayload: shipping.getShippingInventoryMappingPayload,
|
||||
getShippingMatchResultPayload: shipping.getShippingMatchResultPayload,
|
||||
canOpenQueryPreview: queryPreview.canOpen,
|
||||
getQueryPreviewSummary: queryPreview.getSummary,
|
||||
openQueryPreviewDialog: queryPreview.openDialog,
|
||||
@@ -306,6 +308,7 @@ export function useChatPage() {
|
||||
currentAgentId,
|
||||
presetQuestion,
|
||||
shippingTaskIdFromQuery: shipping.shippingTaskIdFromQuery,
|
||||
shippingBatchNoFromQuery: shipping.shippingBatchNoFromQuery,
|
||||
isShippingNoticeAgent: shipping.isShippingNoticeAgent,
|
||||
resetChatStateForAgentChange,
|
||||
cancelVoiceInput: voice.cancelVoiceInput,
|
||||
@@ -405,6 +408,11 @@ export function useChatPage() {
|
||||
handleDeleteConfirm: dialogs.handleDeleteConfirm,
|
||||
showChatRating,
|
||||
isShippingNoticeAgent: shipping.isShippingNoticeAgent,
|
||||
shippingBatchSummary: shipping.shippingBatchSummary,
|
||||
shippingBatchTasks: shipping.shippingBatchTasks,
|
||||
activeShippingTaskDetail: shipping.activeShippingTaskDetail,
|
||||
shippingBatchTasksExpanded: shipping.shippingBatchTasksExpanded,
|
||||
switchShippingFocusTask: shipping.switchShippingFocusTask,
|
||||
shippingSuggestedPrompt: shipping.shippingSuggestedPrompt,
|
||||
handleShippingInventorySelected: shipping.handleShippingInventorySelected,
|
||||
useShippingSuggestedPrompt: shipping.useShippingSuggestedPrompt,
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface UseChatRouteSyncOptions {
|
||||
currentAgentId: ComputedRef<number>;
|
||||
presetQuestion: ComputedRef<string>;
|
||||
shippingTaskIdFromQuery: ComputedRef<string | null>;
|
||||
shippingBatchNoFromQuery?: ComputedRef<string | null>;
|
||||
isShippingNoticeAgent: ComputedRef<boolean>;
|
||||
resetChatStateForAgentChange: () => void;
|
||||
cancelVoiceInput: () => void;
|
||||
@@ -38,6 +39,7 @@ export function useChatRouteSync(options: UseChatRouteSyncOptions) {
|
||||
currentAgentId,
|
||||
presetQuestion,
|
||||
shippingTaskIdFromQuery,
|
||||
shippingBatchNoFromQuery,
|
||||
resetChatStateForAgentChange,
|
||||
cancelVoiceInput,
|
||||
syncCurrentUserProfile,
|
||||
@@ -99,7 +101,7 @@ export function useChatRouteSync(options: UseChatRouteSyncOptions) {
|
||||
if (convId) {
|
||||
await loadConversation(convId, { force: true });
|
||||
if (syncToken !== routeSyncToken) return;
|
||||
} else if (shippingTaskIdFromQuery.value) {
|
||||
} else if (shippingTaskIdFromQuery.value || shippingBatchNoFromQuery?.value) {
|
||||
await resumeShippingTaskFromQuery();
|
||||
if (syncToken !== routeSyncToken) return;
|
||||
}
|
||||
@@ -120,13 +122,17 @@ export function useChatRouteSync(options: UseChatRouteSyncOptions) {
|
||||
});
|
||||
|
||||
watch(
|
||||
() => [route.params.agentId, route.query.conversation_id, route.query.preset, route.query.task_id],
|
||||
async ([nextAgentId, nextConversationId, nextPreset, nextTaskId], [prevAgentId, prevConversationId, prevPreset, prevTaskId]) => {
|
||||
() => [route.params.agentId, route.query.conversation_id, route.query.preset, route.query.task_id, route.query.batch_no],
|
||||
async (
|
||||
[nextAgentId, nextConversationId, nextPreset, nextTaskId, nextBatchNo],
|
||||
[prevAgentId, prevConversationId, prevPreset, prevTaskId, prevBatchNo],
|
||||
) => {
|
||||
if (
|
||||
nextAgentId === prevAgentId
|
||||
&& nextConversationId === prevConversationId
|
||||
&& nextPreset === prevPreset
|
||||
&& nextTaskId === prevTaskId
|
||||
&& nextBatchNo === prevBatchNo
|
||||
) {
|
||||
return;
|
||||
}
|
||||
@@ -135,6 +141,7 @@ export function useChatRouteSync(options: UseChatRouteSyncOptions) {
|
||||
nextAgentId === prevAgentId
|
||||
&& nextPreset === prevPreset
|
||||
&& nextTaskId === prevTaskId
|
||||
&& nextBatchNo === prevBatchNo
|
||||
&& nextConversationId !== prevConversationId
|
||||
) {
|
||||
if (typeof nextConversationId === 'string' && nextConversationId) {
|
||||
|
||||
@@ -1,18 +1,8 @@
|
||||
/**
|
||||
/**
|
||||
* features/chat/composables/useChatShipping.ts
|
||||
* 发货通知(出货)编排层:组合 shipping/* 子模块,对外暴露 ChatView 所需 API。
|
||||
*
|
||||
* 子模块职责:
|
||||
* shippingText / shippingMenu / shippingIntents … 纯函数
|
||||
* useChatShippingRefresh 动作按钮刷新
|
||||
* useChatShippingMappingForm 库存列映射表单
|
||||
* useChatShippingDecision 人工决策与手工上传
|
||||
* useChatShippingMenuHandler 气泡动作按钮点击
|
||||
* useChatShippingUploadHandler 文件上传与建议提示
|
||||
* useChatShippingSendHandler handleSend 前置拦截
|
||||
*
|
||||
* 消息类型约定(写入 messages 列表):
|
||||
* - shipping-inventory-mapping:库存列映射表单
|
||||
* 用途:发货通知聊天编排入口,组合 shipping/* 子模块并对 ChatView 暴露统一交互能力。
|
||||
* 依赖:shipping.api、shipping/ 下各 handler 工厂、chat.deps、chat.types、Vue refs/computed/watch。
|
||||
* 逻辑:上游由 ChatView/ChatPage 调用本 composable;本文件再把任务状态、动作刷新、文件上传、决策与发送拦截分发给 shipping 子模块。
|
||||
*/
|
||||
|
||||
import {
|
||||
@@ -31,18 +21,29 @@ import {
|
||||
createShippingLocalMessages,
|
||||
createShippingMappingFormHandlers,
|
||||
createShippingMenuHandlers,
|
||||
createShippingParseReviewHandlers,
|
||||
createShippingSendHandlers,
|
||||
createShippingUploadHandlers,
|
||||
extractShippingActionsDirective,
|
||||
findHistorySessionForShippingTask,
|
||||
findLatestShippingTaskId,
|
||||
getShippingInventoryMappingPayload,
|
||||
getShippingMatchResultPayload,
|
||||
getShippingParseReviewPayload,
|
||||
getShippingInventorySampleRowText,
|
||||
hasShippingInventorySampleRows,
|
||||
normalizeShippingHeaderForDisplay,
|
||||
sanitizeShippingConversationText,
|
||||
shippingActionButtonClass,
|
||||
} from '../shipping';
|
||||
import {
|
||||
getWorkspaceShippingBatch,
|
||||
getWorkspaceShippingTask,
|
||||
switchWorkspaceShippingBatchFocusTask,
|
||||
type ShippingBatchSummary,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
|
||||
import type { ChatUploadFileSpec, PendingAttachment } from '../types/shipping.types';
|
||||
@@ -78,6 +79,13 @@ export interface UseChatShippingOptions {
|
||||
createNewChatView: () => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装发货通知聊天所需的状态、动作处理器与发送拦截逻辑。
|
||||
*
|
||||
* 核心逻辑:统一管理当前任务/批次上下文,组合上传、映射、决策、动作刷新等子模块,并对 ChatView 暴露稳定 API。
|
||||
* @param options - 聊天页依赖与响应式状态集合
|
||||
* @returns 发货通知聊天场景所需的状态、事件处理器和工具函数
|
||||
*/
|
||||
export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const {
|
||||
deps: { t, msg, router, route },
|
||||
@@ -128,17 +136,90 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
const value = route.query.task_id;
|
||||
return typeof value === 'string' ? value.trim() : '';
|
||||
});
|
||||
const shippingBatchNoFromQuery = computed(() => {
|
||||
const value = route.query.batch_no;
|
||||
return typeof value === 'string' ? value.trim() : '';
|
||||
});
|
||||
const resolvedShippingTaskId = ref('');
|
||||
const resolvedShippingBatchNo = ref('');
|
||||
const shippingBatchSummary = ref<ShippingBatchSummary | null>(null);
|
||||
const shippingBatchTasks = ref<ShippingTaskSummary[]>([]);
|
||||
const shippingBatchTasksExpanded = ref(false);
|
||||
const activeShippingTaskDetail = ref<ShippingTaskDetail | null>(null);
|
||||
const shippingConversationTaskIdCache = ref<Record<string, string>>({});
|
||||
const shippingInventorySchemaPreviewCache = ref<Record<string, unknown>>({});
|
||||
const autoResumedShippingTasks = ref<Record<string, boolean>>({});
|
||||
|
||||
const syncShippingBatchSummary = async (batchNo: string) => {
|
||||
const normalized = String(batchNo || '').trim();
|
||||
if (!normalized) {
|
||||
shippingBatchSummary.value = null;
|
||||
shippingBatchTasks.value = [];
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const detail = await getWorkspaceShippingBatch(normalized);
|
||||
resolvedShippingBatchNo.value = detail.batch_no || normalized;
|
||||
shippingBatchTasks.value = Array.isArray(detail.tasks) ? detail.tasks : [];
|
||||
shippingBatchSummary.value = {
|
||||
id: detail.id,
|
||||
batch_no: detail.batch_no,
|
||||
conversation_id: detail.conversation_id,
|
||||
current_focus_task_no: detail.focus_task?.task_no || detail.current_focus_task_no || null,
|
||||
file_count: detail.file_count,
|
||||
process_summary: detail.process_summary || null,
|
||||
created_at: detail.created_at,
|
||||
updated_at: detail.updated_at,
|
||||
};
|
||||
if (detail.focus_task?.task_no) {
|
||||
resolvedShippingTaskId.value = String(detail.focus_task.task_no).trim();
|
||||
}
|
||||
} catch {
|
||||
// ignore summary refresh failure in chat flow
|
||||
}
|
||||
};
|
||||
|
||||
const switchShippingFocusTask = async (taskNo: string) => {
|
||||
const batchNo = getActiveShippingBatchNo();
|
||||
const normalizedTaskNo = String(taskNo || '').trim().toUpperCase();
|
||||
if (!batchNo || !normalizedTaskNo) return false;
|
||||
await switchWorkspaceShippingBatchFocusTask(batchNo, normalizedTaskNo);
|
||||
resolvedShippingTaskId.value = normalizedTaskNo;
|
||||
if (shippingBatchSummary.value) {
|
||||
shippingBatchSummary.value = {
|
||||
...shippingBatchSummary.value,
|
||||
current_focus_task_no: normalizedTaskNo,
|
||||
};
|
||||
}
|
||||
await syncShippingBatchSummary(batchNo);
|
||||
return true;
|
||||
};
|
||||
|
||||
const getActiveShippingTaskId = () =>
|
||||
findLatestShippingTaskId(messages.value)
|
||||
|| resolvedShippingTaskId.value
|
||||
|| shippingTaskIdFromQuery.value
|
||||
|| '';
|
||||
|
||||
const getActiveShippingBatchNo = () =>
|
||||
resolvedShippingBatchNo.value
|
||||
|| shippingBatchNoFromQuery.value
|
||||
|| String(shippingBatchSummary.value?.batch_no || '').trim()
|
||||
|| '';
|
||||
|
||||
const syncActiveShippingTaskDetail = async (taskId?: string) => {
|
||||
const normalized = String(taskId || getActiveShippingTaskId() || '').trim().toUpperCase();
|
||||
if (!normalized) {
|
||||
activeShippingTaskDetail.value = null;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
activeShippingTaskDetail.value = await getWorkspaceShippingTask(normalized);
|
||||
} catch {
|
||||
activeShippingTaskDetail.value = null;
|
||||
}
|
||||
};
|
||||
|
||||
const lastAssistantMessageContent = () => {
|
||||
for (let i = messages.value.length - 1; i >= 0; i -= 1) {
|
||||
const item = messages.value[i];
|
||||
@@ -208,8 +289,24 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
t,
|
||||
});
|
||||
|
||||
const {
|
||||
syncShippingParseReviewCard,
|
||||
updateShippingParseReviewHeader,
|
||||
updateShippingParseReviewLine,
|
||||
addShippingParseReviewLine,
|
||||
removeShippingParseReviewLine,
|
||||
} = createShippingParseReviewHandlers({
|
||||
messages,
|
||||
resolvedShippingTaskId,
|
||||
newLocalMessageId,
|
||||
saveLocalMessageToBackend,
|
||||
refreshShippingActions,
|
||||
msg,
|
||||
});
|
||||
|
||||
const {
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
openShippingInventoryPicker,
|
||||
handleShippingInventorySelected,
|
||||
shippingSuggestedPrompt,
|
||||
@@ -222,6 +319,8 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
shippingInventoryPickerRef,
|
||||
pendingShippingUploadTaskId,
|
||||
resolvedShippingTaskId,
|
||||
resolvedShippingBatchNo,
|
||||
shippingBatchSummary,
|
||||
shippingInventorySchemaPreviewCache,
|
||||
getActiveShippingTaskId,
|
||||
sendShippingMenuMessage,
|
||||
@@ -258,6 +357,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
attachments,
|
||||
shippingAutoFlowRequested,
|
||||
resolvedShippingTaskId,
|
||||
getActiveShippingBatchNo,
|
||||
currentAgentId,
|
||||
selectedKb,
|
||||
attachmentPolicy,
|
||||
@@ -273,6 +373,7 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
executeShippingDecision,
|
||||
executeShippingManualUpload,
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
refreshShippingActions,
|
||||
shippingSuggestedPrompt,
|
||||
msg,
|
||||
@@ -281,6 +382,13 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
|
||||
// ── 路由 / 会话生命周期 ───────────────────────────────────
|
||||
const resumeShippingTaskFromQuery = async () => {
|
||||
const batchNo = shippingBatchNoFromQuery.value;
|
||||
if (batchNo && isShippingNoticeAgent.value) {
|
||||
await syncShippingBatchSummary(batchNo);
|
||||
if (!shippingTaskIdFromQuery.value && resolvedShippingTaskId.value) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const taskId = shippingTaskIdFromQuery.value;
|
||||
if (!taskId || !isShippingNoticeAgent.value) return;
|
||||
if (route.query.conversation_id) return;
|
||||
@@ -304,13 +412,17 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
|
||||
const onConversationLoadedEmpty = async () => {
|
||||
if (!isShippingNoticeAgent.value || !shippingTaskIdFromQuery.value || isThinking.value) return;
|
||||
await router.replace({ path: route.path, query: { task_id: shippingTaskIdFromQuery.value } });
|
||||
const nextQuery: Record<string, string> = { task_id: shippingTaskIdFromQuery.value };
|
||||
if (shippingBatchNoFromQuery.value) nextQuery.batch_no = shippingBatchNoFromQuery.value;
|
||||
await router.replace({ path: route.path, query: nextQuery });
|
||||
};
|
||||
|
||||
const onConversationLoadFailed = async () => {
|
||||
if (!isShippingNoticeAgent.value || !shippingTaskIdFromQuery.value || isThinking.value) return;
|
||||
createNewChatView();
|
||||
void router.replace({ path: route.path, query: { task_id: shippingTaskIdFromQuery.value } });
|
||||
const nextQuery: Record<string, string> = { task_id: shippingTaskIdFromQuery.value };
|
||||
if (shippingBatchNoFromQuery.value) nextQuery.batch_no = shippingBatchNoFromQuery.value;
|
||||
void router.replace({ path: route.path, query: nextQuery });
|
||||
input.value = t('chat.shippingNoticeContinue', { taskId: shippingTaskIdFromQuery.value });
|
||||
await invokeHandleSend?.();
|
||||
};
|
||||
@@ -327,8 +439,22 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
].join('|');
|
||||
});
|
||||
watch([shippingActionsWatchKey, isThinking, isShippingNoticeAgent, () => currentAgent.value?.name], () => {
|
||||
void refreshShippingActions();
|
||||
void refreshShippingActions().then(async () => {
|
||||
const taskId = getActiveShippingTaskId();
|
||||
await Promise.all([
|
||||
syncShippingParseReviewCard(taskId),
|
||||
syncActiveShippingTaskDetail(taskId),
|
||||
]);
|
||||
});
|
||||
});
|
||||
watch([resolvedShippingBatchNo, shippingBatchNoFromQuery], ([batchNo, queryBatchNo]) => {
|
||||
const nextBatchNo = String(batchNo || queryBatchNo || '').trim();
|
||||
if (!nextBatchNo) {
|
||||
shippingBatchSummary.value = null;
|
||||
return;
|
||||
}
|
||||
void syncShippingBatchSummary(nextBatchNo);
|
||||
}, { immediate: true });
|
||||
|
||||
return {
|
||||
shippingBindSend,
|
||||
@@ -339,13 +465,27 @@ export function useChatShipping(options: UseChatShippingOptions) {
|
||||
pendingShippingUploadTaskId,
|
||||
allowsSendWithAttachmentsOnly,
|
||||
shippingTaskIdFromQuery,
|
||||
shippingBatchNoFromQuery,
|
||||
resolvedShippingBatchNo,
|
||||
shippingBatchSummary,
|
||||
shippingBatchTasks,
|
||||
shippingBatchTasksExpanded,
|
||||
activeShippingTaskDetail,
|
||||
getActiveShippingBatchNo,
|
||||
switchShippingFocusTask,
|
||||
resumeShippingTaskFromQuery,
|
||||
normalizeShippingHeaderForDisplay,
|
||||
getShippingInventoryMappingPayload,
|
||||
getShippingMatchResultPayload,
|
||||
getShippingParseReviewPayload,
|
||||
hasShippingInventorySampleRows,
|
||||
getShippingInventorySampleRowText,
|
||||
applyShippingInventoryMappingForm,
|
||||
reuploadShippingInventoryFromMappingForm,
|
||||
updateShippingParseReviewHeader,
|
||||
updateShippingParseReviewLine,
|
||||
addShippingParseReviewLine,
|
||||
removeShippingParseReviewLine,
|
||||
handleShippingActionClick,
|
||||
handleShippingInventorySelected,
|
||||
shippingActionButtonClass,
|
||||
|
||||
@@ -22,6 +22,7 @@ export interface ChatPageConversationContext {
|
||||
onConversationLoadFailed: () => Promise<void>;
|
||||
isShippingNoticeAgent: ComputedRef<boolean>;
|
||||
shippingTaskIdFromQuery: ComputedRef<string>;
|
||||
shippingBatchNoFromQuery?: ComputedRef<string>;
|
||||
clearHistory: () => void;
|
||||
clearAttachments: () => void;
|
||||
input: Ref<string>;
|
||||
@@ -51,7 +52,11 @@ export function createChatPageConversationApi(ctx: ChatPageConversationContext)
|
||||
} catch (e) {
|
||||
console.error('Failed to load conversation', e);
|
||||
await ctx.onConversationLoadFailed();
|
||||
if (ctx.isShippingNoticeAgent.value && ctx.shippingTaskIdFromQuery.value && !ctx.isThinking.value) {
|
||||
if (
|
||||
ctx.isShippingNoticeAgent.value
|
||||
&& (ctx.shippingTaskIdFromQuery.value || ctx.shippingBatchNoFromQuery?.value)
|
||||
&& !ctx.isThinking.value
|
||||
) {
|
||||
return;
|
||||
}
|
||||
ctx.deps.msg.warning(ctx.deps.t('chat.historyLoadFailed'));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* 对话页:子组件 inject 用的 handlers 对象打包(请假表单、出货映射、消息气泡)。
|
||||
*/
|
||||
import type { LeaveMessageHandlers } from '../components/messages/LeaveMessageBlock.vue';
|
||||
@@ -31,8 +31,14 @@ type ShippingHandlerSource = Pick<
|
||||
| 'normalizeShippingHeaderForDisplay'
|
||||
| 'hasShippingInventorySampleRows'
|
||||
| 'getShippingInventorySampleRowText'
|
||||
| 'getShippingParseReviewPayload'
|
||||
| 'getShippingMatchResultPayload'
|
||||
| 'reuploadShippingInventoryFromMappingForm'
|
||||
| 'applyShippingInventoryMappingForm'
|
||||
| 'updateShippingParseReviewHeader'
|
||||
| 'updateShippingParseReviewLine'
|
||||
| 'addShippingParseReviewLine'
|
||||
| 'removeShippingParseReviewLine'
|
||||
>;
|
||||
|
||||
/** 请假消息块 handlers(LeaveMessageBlock) */
|
||||
@@ -62,8 +68,16 @@ export function createShippingMappingHandlers(shipping: ShippingHandlerSource):
|
||||
normalizeHeader: shipping.normalizeShippingHeaderForDisplay,
|
||||
hasSampleRows: shipping.hasShippingInventorySampleRows,
|
||||
getSampleRowText: shipping.getShippingInventorySampleRowText,
|
||||
getParseReviewPayload: shipping.getShippingParseReviewPayload,
|
||||
getMatchResultPayload: shipping.getShippingMatchResultPayload,
|
||||
reupload: shipping.reuploadShippingInventoryFromMappingForm,
|
||||
apply: shipping.applyShippingInventoryMappingForm,
|
||||
updateParseReviewHeader: shipping.updateShippingParseReviewHeader,
|
||||
updateParseReviewLine: shipping.updateShippingParseReviewLine,
|
||||
updateHeader: shipping.updateShippingParseReviewHeader,
|
||||
updateLine: shipping.updateShippingParseReviewLine,
|
||||
addLine: shipping.addShippingParseReviewLine,
|
||||
removeLine: shipping.removeShippingParseReviewLine,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
/**
|
||||
/**
|
||||
* 对话页:Markdown 渲染、消息可见性判断、PLM/请假链接点击。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import { marked } from 'marked';
|
||||
import type { ChatMessageBubbleHandlers } from '../components/messages/ChatMessageBubble.vue';
|
||||
import type { ChatMessage, SourceFileLink } from '../types/chat.types';
|
||||
import type { ShippingMatchResultPayload } from '../types/shipping.types';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
marked.setOptions({ gfm: true, breaks: true });
|
||||
@@ -24,6 +25,7 @@ export interface ChatPageMarkdownContext {
|
||||
getSourceMeta: ChatMessageBubbleHandlers['getSourceMeta'];
|
||||
getSourceBrief: ChatMessageBubbleHandlers['getSourceBrief'];
|
||||
getShippingInventoryMappingPayload: ChatMessageBubbleHandlers['getShippingInventoryMappingPayload'];
|
||||
getShippingMatchResultPayload: (msg: ChatMessage) => ShippingMatchResultPayload | null;
|
||||
canOpenQueryPreview: ChatMessageBubbleHandlers['canOpenQueryPreview'];
|
||||
getQueryPreviewSummary: ChatMessageBubbleHandlers['getQueryPreviewSummary'];
|
||||
openQueryPreviewDialog: ChatMessageBubbleHandlers['openQueryPreviewDialog'];
|
||||
@@ -87,6 +89,7 @@ export function createChatPageMarkdownApi(ctx: ChatPageMarkdownContext) {
|
||||
renderMarkdown,
|
||||
onMarkdownClick: handleChatMarkdownClick,
|
||||
getShippingInventoryMappingPayload: ctx.getShippingInventoryMappingPayload,
|
||||
getShippingMatchResultPayload: ctx.getShippingMatchResultPayload,
|
||||
canOpenQueryPreview: ctx.canOpenQueryPreview,
|
||||
getQueryPreviewSummary: ctx.getQueryPreviewSummary,
|
||||
openQueryPreviewDialog: ctx.openQueryPreviewDialog,
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
/** 出货(shipping)子模块 barrel:纯函数 + handler 工厂 + 动作刷新 */
|
||||
/**
|
||||
* features/chat/shipping/index.ts
|
||||
* 用途:统一导出发货通知聊天子模块的纯函数、handler 工厂与辅助工具。
|
||||
* 依赖:shipping/* 子模块本身,不承载业务逻辑。
|
||||
* 逻辑:由 useChatShipping 作为聚合入口导入本 barrel,再分发到具体 handler/composable 文件。
|
||||
*/
|
||||
export * from './shippingText';
|
||||
export * from './shippingMenu';
|
||||
export * from './shippingIntents';
|
||||
@@ -7,10 +12,14 @@ export * from './shippingTaskId';
|
||||
export * from './shippingDownload';
|
||||
export * from './shippingDecisionFormat';
|
||||
export * from './shippingUploadPrompt';
|
||||
export * from './shippingParseReview';
|
||||
export * from './shippingMatchResult';
|
||||
export * from './shippingStepper';
|
||||
export * from './shippingLocalMessages';
|
||||
export * from './shippingConversation';
|
||||
export * from './useChatShippingRefresh';
|
||||
export * from './useChatShippingMappingForm';
|
||||
export * from './useChatShippingParseReview';
|
||||
export * from './useChatShippingDecision';
|
||||
export * from './useChatShippingMenuHandler';
|
||||
export * from './useChatShippingUploadHandler';
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
import { resolveShippingNumericChoice } from './shippingMenu';
|
||||
import type { ShippingMenuAction } from '../types/shipping.types';
|
||||
|
||||
export interface ShippingTaskSwitchIntent {
|
||||
mode: 'next' | 'prev' | 'task';
|
||||
taskNo?: string;
|
||||
}
|
||||
|
||||
export function parseShippingColumnMappingFromText(content: string): Record<string, string> | null {
|
||||
const raw = String(content || '').trim();
|
||||
if (!raw) return null;
|
||||
@@ -88,4 +93,20 @@ export function isShippingDownloadExcelIntent(text: string): boolean {
|
||||
].some((pattern) => pattern.test(normalized));
|
||||
}
|
||||
|
||||
export function parseShippingTaskSwitchIntent(text: string): ShippingTaskSwitchIntent | null {
|
||||
const normalized = String(text || '').trim();
|
||||
if (!normalized) return null;
|
||||
const taskMatch = normalized.match(/SN-\d{8}-[A-F0-9]{8}/i);
|
||||
if (taskMatch?.[0] && /(切|切到|切换|goto|go to|switch)/i.test(normalized)) {
|
||||
return { mode: 'task', taskNo: taskMatch[0].toUpperCase() };
|
||||
}
|
||||
if (/^(下一票|下一单|下一个|next)$/i.test(normalized) || /切到下一票/.test(normalized)) {
|
||||
return { mode: 'next' };
|
||||
}
|
||||
if (/^(上一票|上一单|上一个|prev|previous)$/i.test(normalized) || /切到上一票/.test(normalized)) {
|
||||
return { mode: 'prev' };
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export type { ShippingMenuAction };
|
||||
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 出货聊天:匹配结果卡片 payload 读取。
|
||||
*/
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingMatchResultPayload } from '../types/shipping.types';
|
||||
|
||||
export function getShippingMatchResultPayload(chatMsg: ChatMessage): ShippingMatchResultPayload | null {
|
||||
if (!chatMsg || chatMsg.type !== 'shipping-match-result') return null;
|
||||
const payload = chatMsg.payload;
|
||||
if (!payload || typeof payload !== 'object') return null;
|
||||
const taskId = String((payload as ShippingMatchResultPayload).taskId || '').trim();
|
||||
const lineResults = (payload as ShippingMatchResultPayload).line_results;
|
||||
if (!taskId || !Array.isArray(lineResults)) return null;
|
||||
return payload as ShippingMatchResultPayload;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 出货聊天:parse_review 订单表消息 payload 读取。
|
||||
*/
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingParseReviewPayload } from '../types/shipping.types';
|
||||
|
||||
export function getShippingParseReviewPayload(chatMsg: ChatMessage): ShippingParseReviewPayload | null {
|
||||
if (!chatMsg || chatMsg.type !== 'shipping-parse-review') return null;
|
||||
const payload = chatMsg.payload;
|
||||
if (!payload || typeof payload !== 'object') return null;
|
||||
const taskId = String((payload as ShippingParseReviewPayload).taskId || '').trim();
|
||||
const checkpoint = String((payload as ShippingParseReviewPayload).checkpoint || '').trim();
|
||||
const lines = (payload as ShippingParseReviewPayload).lines;
|
||||
if (!taskId || !checkpoint || !Array.isArray(lines)) return null;
|
||||
return payload as ShippingParseReviewPayload;
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* 出货七步 Stepper:基于现有 shipping task 状态推导前端步骤展示。
|
||||
*/
|
||||
export interface ShippingTaskStepperSource {
|
||||
process_status?: string | null;
|
||||
review_status?: string | null;
|
||||
pending_human_reason?: string | null;
|
||||
match_status?: string | null;
|
||||
export_file_name?: string | null;
|
||||
current_step?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingWorkflowStepItem {
|
||||
id: string;
|
||||
label: string;
|
||||
status: 'completed' | 'current' | 'pending' | 'blocked';
|
||||
}
|
||||
|
||||
export const SHIPPING_WORKFLOW_STEP_LABELS = [
|
||||
'chat.shippingNoticeUi.stepper.noticeSubmit',
|
||||
'chat.shippingNoticeUi.stepper.parseConfirm',
|
||||
'chat.shippingNoticeUi.stepper.inventoryPrepare',
|
||||
'chat.shippingNoticeUi.stepper.alignConfirm',
|
||||
'chat.shippingNoticeUi.stepper.matchInventory',
|
||||
'chat.shippingNoticeUi.stepper.generateFile',
|
||||
'chat.shippingNoticeUi.stepper.uploadFreight',
|
||||
] as const;
|
||||
|
||||
function deriveCurrentIndex(task: ShippingTaskStepperSource | null | undefined): number {
|
||||
const processStatus = String(task?.process_status || '').trim();
|
||||
const reviewStatus = String(task?.review_status || '').trim();
|
||||
const pendingReason = String(task?.pending_human_reason || '').trim();
|
||||
const matchStatus = String(task?.match_status || '').trim();
|
||||
const hasExport = !!String(task?.export_file_name || '').trim();
|
||||
|
||||
if (processStatus === 'uploaded' || processStatus === 'closed') return 6;
|
||||
if (processStatus === 'waiting_upload' || processStatus === 'upload_failed' || hasExport) return 5;
|
||||
if (processStatus === 'matched') return 4;
|
||||
if (reviewStatus === 'shortage_review' || pendingReason === 'shortage_review' || pendingReason === 'shortage') return 4;
|
||||
if (reviewStatus === 'align_review' || pendingReason === 'align_review') return 3;
|
||||
if (processStatus === 'inventory_ready' || matchStatus) return 4;
|
||||
if (
|
||||
processStatus === 'waiting_inventory'
|
||||
|| pendingReason === 'map_infer'
|
||||
|| pendingReason === 'rpa_pending'
|
||||
|| pendingReason === 'inv_unavail'
|
||||
|| pendingReason === 'rpa_exhausted'
|
||||
) {
|
||||
return 2;
|
||||
}
|
||||
if (
|
||||
processStatus === 'parsed'
|
||||
|| processStatus === 'pending_review'
|
||||
|| reviewStatus === 'pending_confirm'
|
||||
|| reviewStatus === 'parse_review'
|
||||
|| reviewStatus === 'rsv_required'
|
||||
|| pendingReason === 'low_confidence'
|
||||
|| pendingReason === 'rsv_required'
|
||||
) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
export function buildShippingWorkflowSteps(
|
||||
task: ShippingTaskStepperSource | null | undefined,
|
||||
): ShippingWorkflowStepItem[] {
|
||||
const currentIndex = deriveCurrentIndex(task);
|
||||
const reviewStatus = String(task?.review_status || '').trim();
|
||||
const pendingReason = String(task?.pending_human_reason || '').trim();
|
||||
const processStatus = String(task?.process_status || '').trim();
|
||||
|
||||
return SHIPPING_WORKFLOW_STEP_LABELS.map((label, index) => {
|
||||
let status: ShippingWorkflowStepItem['status'] = 'pending';
|
||||
if (index < currentIndex) {
|
||||
status = 'completed';
|
||||
} else if (index === currentIndex) {
|
||||
status = 'current';
|
||||
}
|
||||
|
||||
if (
|
||||
(index === 1 && (reviewStatus === 'parse_review' || pendingReason === 'low_confidence' || pendingReason === 'rsv_required'))
|
||||
|| (index === 3 && (reviewStatus === 'align_review' || pendingReason === 'align_review'))
|
||||
|| (index === 4 && (reviewStatus === 'shortage_review' || pendingReason === 'shortage_review' || pendingReason === 'shortage'))
|
||||
|| (index === 6 && processStatus === 'upload_failed')
|
||||
) {
|
||||
status = 'blocked';
|
||||
}
|
||||
|
||||
return {
|
||||
id: `shipping-step-${index + 1}`,
|
||||
label,
|
||||
status,
|
||||
};
|
||||
});
|
||||
}
|
||||
@@ -1,5 +1,8 @@
|
||||
/**
|
||||
* 出货聊天:人工决策提交(confirm/reject/reparse 等)与手工上传标记。
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingDecision.ts
|
||||
* 用途:封装人工决策提交与手工上传标记逻辑。
|
||||
* 依赖:shipping.api、shippingDecisionFormat、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件负责把 confirm/reject/reparse 等决策提交到后端,并生成聊天区本地消息。
|
||||
*/
|
||||
import {
|
||||
autoProgressWorkspaceShippingTask,
|
||||
@@ -26,6 +29,13 @@ export interface ShippingDecisionContext {
|
||||
t: (key: string, params?: Record<string, unknown>) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发货通知决策处理器。
|
||||
*
|
||||
* 核心逻辑:根据决策类型调用对应后端接口,同步本地用户/助手消息,并在需要时刷新历史与动作按钮。
|
||||
* @param ctx - 决策处理上下文
|
||||
* @returns 人工决策与手工上传确认处理函数
|
||||
*/
|
||||
export function createShippingDecisionHandlers(ctx: ShippingDecisionContext) {
|
||||
const syncHistoryIfNeeded = async () => {
|
||||
if (!ctx.conversationId.value && ctx.history.value.length === 0) {
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
/**
|
||||
* 出货聊天:库存列映射表单(打开、应用、重传)。
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingMappingForm.ts
|
||||
* 用途:管理库存列映射表单的打开、提交和重新上传交互。
|
||||
* 依赖:shipping.api、shippingMapping、chat.types、Vue nextTick。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件负责把 schema preview 渲染成聊天卡片,并把表单提交回后端映射接口。
|
||||
*/
|
||||
import { nextTick } from 'vue';
|
||||
import {
|
||||
@@ -25,6 +28,13 @@ export interface ShippingMappingFormContext {
|
||||
msg: { warning: (text: string) => void };
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建库存列映射表单处理器。
|
||||
*
|
||||
* 核心逻辑:按任务号打开或复用映射卡片,提交 map_json 到后端,并在成功后刷新动作按钮。
|
||||
* @param ctx - 库存映射表单上下文
|
||||
* @returns 打开、应用和重传库存映射表单的处理函数
|
||||
*/
|
||||
export function createShippingMappingFormHandlers(ctx: ShippingMappingFormContext) {
|
||||
const scrollToLastShippingInventoryMapping = async (): Promise<boolean> => {
|
||||
const container = ctx.chatScrollContainer.value;
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
/**
|
||||
* 出货聊天:消息气泡动作按钮与菜单项点击分发。
|
||||
*
|
||||
* 按 action.id 路由到 API 调用、决策提交、文件选择器或 Dify 菜单消息。
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingMenuHandler.ts
|
||||
* 用途:分发聊天气泡动作按钮点击,连接 API、决策处理、下载和文件选择器。
|
||||
* 依赖:shipping.api、shippingDownload、shipping 常量、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件根据 action.id 决定触发后端接口、本地消息落库或前端 UI 行为。
|
||||
*/
|
||||
import {
|
||||
generateWorkspaceShippingExcel,
|
||||
matchWorkspaceShippingInventory,
|
||||
type ShippingDecisionResponse,
|
||||
type ShippingMatchLineResult,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { SHIPPING_DECISION_ACTIONS } from '../constants/shipping';
|
||||
import { downloadWorkspaceShippingExcelFile } from './shippingDownload';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingMatchResultPayload } from '../types/shipping.types';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
export interface ShippingMenuHandlerContext {
|
||||
@@ -28,7 +32,39 @@ export interface ShippingMenuHandlerContext {
|
||||
t: (key: string) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发货通知动作菜单处理器。
|
||||
*
|
||||
* 核心逻辑:按 action.id 分流到生成 Excel、库存匹配、人工决策、手工上传确认等前后端动作。
|
||||
* @param ctx - 动作菜单上下文
|
||||
* @returns 菜单动作与按钮点击处理函数
|
||||
*/
|
||||
export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
const buildMatchResultPayload = (
|
||||
taskId: string,
|
||||
result: ShippingDecisionResponse & { action_buttons?: Array<{ id: string; label: string; message: string; variant?: 'primary' | 'secondary' | 'danger' }> },
|
||||
): ShippingMatchResultPayload => {
|
||||
const data = (result?.data && typeof result.data === 'object') ? result.data as Record<string, unknown> : {};
|
||||
const lineResults = Array.isArray(data.line_results)
|
||||
? data.line_results as ShippingMatchLineResult[]
|
||||
: [];
|
||||
const shortageRaw = data.shortage && typeof data.shortage === 'object'
|
||||
? data.shortage as { lines?: ShippingMatchLineResult[] }
|
||||
: null;
|
||||
return {
|
||||
taskId,
|
||||
match_status: typeof data.match_status === 'string' ? data.match_status : null,
|
||||
line_results: lineResults,
|
||||
shortage_lines: Array.isArray(shortageRaw?.lines) ? shortageRaw.lines : [],
|
||||
action_buttons: Array.isArray(result.action_buttons)
|
||||
? result.action_buttons.map((action) => ({
|
||||
...action,
|
||||
variant: action.variant || 'secondary',
|
||||
}))
|
||||
: [],
|
||||
};
|
||||
};
|
||||
|
||||
const handleShippingMenuAction = async (
|
||||
action: { id?: string; message: string },
|
||||
chatMsg?: ChatMessage & { shipping_actions_used?: boolean },
|
||||
@@ -71,11 +107,12 @@ export function createShippingMenuHandlers(ctx: ShippingMenuHandlerContext) {
|
||||
};
|
||||
const assistantMsg: ChatMessage = {
|
||||
role: 'assistant',
|
||||
type: 'text',
|
||||
type: 'shipping-match-result',
|
||||
content: [
|
||||
String(result.message || '').trim(),
|
||||
`任务编号:${taskId}`,
|
||||
].filter(Boolean).join('\n'),
|
||||
payload: buildMatchResultPayload(taskId, result),
|
||||
local_id: ctx.newLocalMessageId('shipping-assistant'),
|
||||
local_only: true,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingParseReview.ts
|
||||
* 用途:管理 parse_review 阶段的订单表卡片,包括打开、同步和增删改保存。
|
||||
* 依赖:shipping.api、shippingParseReview、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件在聊天区维护解析复核卡片,并把用户修订同步回后端 notice 编辑接口。
|
||||
*/
|
||||
import {
|
||||
addWorkspaceShippingNoticeLine,
|
||||
getShippingChatActions,
|
||||
getWorkspaceShippingTask,
|
||||
removeWorkspaceShippingNoticeLine,
|
||||
updateWorkspaceShippingNoticeFields,
|
||||
updateWorkspaceShippingNoticeLine,
|
||||
type ShippingNoticeHeader,
|
||||
type ShippingNoticeLine,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { getShippingParseReviewPayload } from './shippingParseReview';
|
||||
import type { ChatMessage } from '../types/chat.types';
|
||||
import type { ShippingParseReviewPayload } from '../types/shipping.types';
|
||||
import type { Ref } from 'vue';
|
||||
|
||||
export interface ShippingParseReviewContext {
|
||||
messages: Ref<ChatMessage[]>;
|
||||
resolvedShippingTaskId: Ref<string>;
|
||||
newLocalMessageId: (prefix: string) => string;
|
||||
saveLocalMessageToBackend: (msg: ChatMessage, userQuery?: string) => Promise<void>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
msg: { warning: (text: string) => void };
|
||||
}
|
||||
|
||||
function buildParseReviewPayload(
|
||||
taskId: string,
|
||||
detail: Awaited<ReturnType<typeof getWorkspaceShippingTask>>,
|
||||
checkpoint: string,
|
||||
): ShippingParseReviewPayload {
|
||||
return {
|
||||
taskId,
|
||||
checkpoint,
|
||||
header: {
|
||||
customer_name: detail.customer_name ?? null,
|
||||
customer_code: detail.customer_code ?? null,
|
||||
ship_to: detail.ship_to ?? null,
|
||||
po_number: detail.po_number ?? null,
|
||||
required_date: detail.required_date ?? null,
|
||||
},
|
||||
lines: Array.isArray(detail.lines) ? detail.lines : [],
|
||||
saving: false,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发货通知 parse review 卡片处理器。
|
||||
*
|
||||
* 核心逻辑:根据任务详情与 checkpoint 维护本地复核卡片,并把单头/订单行编辑回写到后端。
|
||||
* @param ctx - parse review 卡片上下文
|
||||
* @returns 复核卡片同步与编辑处理函数集合
|
||||
*/
|
||||
export function createShippingParseReviewHandlers(ctx: ShippingParseReviewContext) {
|
||||
const removeParseReviewMessageForTask = (taskId: string) => {
|
||||
const normalized = String(taskId || '').trim().toUpperCase();
|
||||
if (!normalized) return;
|
||||
ctx.messages.value = ctx.messages.value.filter((msg) => {
|
||||
const payload = getShippingParseReviewPayload(msg);
|
||||
return payload?.taskId?.trim().toUpperCase() !== normalized;
|
||||
});
|
||||
};
|
||||
|
||||
const upsertParseReviewMessage = async (payload: ShippingParseReviewPayload) => {
|
||||
const normalized = String(payload.taskId || '').trim().toUpperCase();
|
||||
const existing = ctx.messages.value.find((msg) => {
|
||||
const current = getShippingParseReviewPayload(msg);
|
||||
return current?.taskId?.trim().toUpperCase() === normalized;
|
||||
});
|
||||
if (existing) {
|
||||
existing.content = `请确认或修订以下解析结果。\n任务编号:${normalized}`;
|
||||
existing.payload = payload;
|
||||
existing.local_only = true;
|
||||
return;
|
||||
}
|
||||
const reviewMsg: ChatMessage = {
|
||||
role: 'assistant',
|
||||
type: 'shipping-parse-review',
|
||||
content: `请确认或修订以下解析结果。\n任务编号:${normalized}`,
|
||||
payload,
|
||||
local_id: ctx.newLocalMessageId('shipping-parse-review'),
|
||||
local_only: true,
|
||||
};
|
||||
ctx.messages.value.push(reviewMsg);
|
||||
await ctx.saveLocalMessageToBackend(reviewMsg);
|
||||
};
|
||||
|
||||
const syncShippingParseReviewCard = async (taskId?: string): Promise<boolean> => {
|
||||
const normalized = String(taskId || ctx.resolvedShippingTaskId.value || '').trim().toUpperCase();
|
||||
if (!normalized) return false;
|
||||
try {
|
||||
const [detail, actions] = await Promise.all([
|
||||
getWorkspaceShippingTask(normalized),
|
||||
getShippingChatActions(normalized),
|
||||
]);
|
||||
const checkpoint = String(actions.checkpoint || '').trim();
|
||||
if (checkpoint !== 'parse_review') {
|
||||
removeParseReviewMessageForTask(normalized);
|
||||
return false;
|
||||
}
|
||||
await upsertParseReviewMessage(buildParseReviewPayload(normalized, detail, checkpoint));
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
const updateShippingParseReviewHeader = async (
|
||||
msgObj: ChatMessage,
|
||||
fields: Partial<ShippingNoticeHeader>,
|
||||
) => {
|
||||
const payload = getShippingParseReviewPayload(msgObj);
|
||||
if (!payload || payload.saving) return false;
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeFields(taskId, fields, '聊天区订单表修订');
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '更新解析结果失败');
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
if (current) current.saving = false;
|
||||
}
|
||||
};
|
||||
|
||||
const updateShippingParseReviewLine = async (
|
||||
msgObj: ChatMessage,
|
||||
lineIndex: number,
|
||||
patch: Partial<ShippingNoticeLine>,
|
||||
) => {
|
||||
const payload = getShippingParseReviewPayload(msgObj);
|
||||
if (!payload || payload.saving) return false;
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeLine(taskId, lineIndex, patch, '聊天区订单表修订');
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '更新解析结果失败');
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
if (current) current.saving = false;
|
||||
}
|
||||
};
|
||||
|
||||
const addShippingParseReviewLine = async (
|
||||
msgObj: ChatMessage,
|
||||
line: Partial<ShippingNoticeLine>,
|
||||
) => {
|
||||
const payload = getShippingParseReviewPayload(msgObj);
|
||||
if (!payload || payload.saving) return false;
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await addWorkspaceShippingNoticeLine(taskId, line, '聊天区订单表新增行');
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '新增订单行失败');
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
if (current) current.saving = false;
|
||||
}
|
||||
};
|
||||
|
||||
const removeShippingParseReviewLine = async (
|
||||
msgObj: ChatMessage,
|
||||
lineIndex: number,
|
||||
) => {
|
||||
const payload = getShippingParseReviewPayload(msgObj);
|
||||
if (!payload || payload.saving) return false;
|
||||
payload.saving = true;
|
||||
const taskId = String(payload.taskId || '').trim().toUpperCase();
|
||||
try {
|
||||
await removeWorkspaceShippingNoticeLine(taskId, lineIndex, '聊天区订单表删除行');
|
||||
await syncShippingParseReviewCard(taskId);
|
||||
await ctx.refreshShippingActions();
|
||||
return true;
|
||||
} catch (e: unknown) {
|
||||
ctx.msg.warning(e instanceof Error ? e.message : '删除订单行失败');
|
||||
return false;
|
||||
} finally {
|
||||
const current = getShippingParseReviewPayload(msgObj);
|
||||
if (current) current.saving = false;
|
||||
}
|
||||
};
|
||||
|
||||
return {
|
||||
getShippingParseReviewPayload,
|
||||
syncShippingParseReviewCard,
|
||||
updateShippingParseReviewHeader,
|
||||
updateShippingParseReviewLine,
|
||||
addShippingParseReviewLine,
|
||||
removeShippingParseReviewLine,
|
||||
};
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* 出货聊天:助手消息动作按钮刷新(有状态 composable 工厂)。
|
||||
*
|
||||
* 按 taskId 拉取 getShippingChatActions,写入 messages[].shipping_actions;
|
||||
* 终态 checkpoint 时清除所有按钮。
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingRefresh.ts
|
||||
* 用途:刷新聊天区发货通知动作按钮,把后端 checkpoint/action_buttons 同步到消息气泡。
|
||||
* 依赖:shipping.api、shippingMenu、shippingTaskId、shippingNoticeActions 常量、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件根据当前 taskId 拉取动作配置并回写到 messages[].shipping_actions。
|
||||
*/
|
||||
import {
|
||||
getShippingChatActions,
|
||||
@@ -27,10 +27,23 @@ export interface ShippingRefreshContext {
|
||||
shippingConversationTaskIdCache: Ref<Record<string, string>>;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断某条助手消息后面是否已经出现新的用户回复。
|
||||
* @param msgs - 当前消息列表
|
||||
* @param index - 目标助手消息索引
|
||||
* @returns `true` 表示该消息已被后续用户输入“盖住”
|
||||
*/
|
||||
export function assistantMessageHasLaterUserReply(msgs: Array<{ role?: string }>, index: number): boolean {
|
||||
return msgs.slice(index + 1).some((item) => item.role === 'user');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发货通知动作按钮刷新器。
|
||||
*
|
||||
* 核心逻辑:优先按 taskId 拉取后端 action_buttons,失败时回退到消息文本指令解析,并在终态 checkpoint 清空旧按钮。
|
||||
* @param ctx - 发货通知聊天上下文
|
||||
* @returns 动作刷新函数
|
||||
*/
|
||||
export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
|
||||
let shippingActionsRequestSeq = 0;
|
||||
|
||||
@@ -145,6 +158,9 @@ export function createShippingActionsRefresher(ctx: ShippingRefreshContext) {
|
||||
}
|
||||
buttons = resolved.buttons;
|
||||
}
|
||||
if (chatMsg.type === 'shipping-match-result' && chatMsg.payload && typeof chatMsg.payload === 'object') {
|
||||
(chatMsg.payload as { action_buttons?: ShippingActionButton[] }).action_buttons = buttons;
|
||||
}
|
||||
chatMsg.shipping_actions = buttons.length ? buttons : undefined;
|
||||
});
|
||||
};
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
/**
|
||||
* 出货聊天:handleSend 前置拦截(菜单数字、决策文本、列映射、附件自动流程)。
|
||||
*
|
||||
* 返回 true 表示已消费本次发送,ChatView 不再走默认 Dify 流程。
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingSendHandler.ts
|
||||
* 用途:在聊天发送前拦截发货通知专属意图,如切票、决策文本、列映射和附件自动流程。
|
||||
* 依赖:shipping.api、shippingIntents、shippingMenu、shippingMapping、shippingDownload、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件优先消费 shipping 领域意图,只有未命中时才放行到默认 Dify 对话链路。
|
||||
*/
|
||||
import { applyWorkspaceShippingInventoryMapping, generateWorkspaceShippingExcel } from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
applyWorkspaceShippingInventoryMapping,
|
||||
generateWorkspaceShippingExcel,
|
||||
getWorkspaceShippingBatch,
|
||||
switchWorkspaceShippingBatchFocusTask,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { SHIPPING_MENU_ACTION_SPECS } from '../constants/shipping';
|
||||
import { buildShippingFieldAlignmentText } from './shippingMapping';
|
||||
import { downloadWorkspaceShippingExcelFile } from './shippingDownload';
|
||||
@@ -12,12 +18,12 @@ import {
|
||||
isShippingGenerateExcelIntent,
|
||||
isShippingInventoryUploadIntent,
|
||||
isShippingManualUploadIntent,
|
||||
parseShippingTaskSwitchIntent,
|
||||
parseShippingColumnMappingFromText,
|
||||
} from './shippingIntents';
|
||||
import { resolveShippingDecisionFromText, resolveShippingNumericChoice } from './shippingMenu';
|
||||
import { classifyShippingUploadFile } from './shippingUploadPrompt';
|
||||
import { extractExt } from '../constants/shipping';
|
||||
import { ensureShippingHistorySynced } from './shippingConversation';
|
||||
import type { ChatMessage, ChatSessionItem } from '../types/chat.types';
|
||||
import type { ChatUploadFileSpec, PendingAttachment } from '../types/shipping.types';
|
||||
import type { ComputedRef, Ref } from 'vue';
|
||||
@@ -33,6 +39,7 @@ export interface ShippingSendHandlerContext {
|
||||
attachments: Ref<PendingAttachment[]>;
|
||||
shippingAutoFlowRequested: Ref<boolean>;
|
||||
resolvedShippingTaskId: Ref<string>;
|
||||
getActiveShippingBatchNo: () => string;
|
||||
currentAgentId: ComputedRef<number>;
|
||||
selectedKb: Ref<string>;
|
||||
attachmentPolicy: ComputedRef<{ anyEnabled: boolean }>;
|
||||
@@ -53,13 +60,66 @@ export interface ShippingSendHandlerContext {
|
||||
executeShippingDecision: (decision: string, displayText?: string) => Promise<boolean>;
|
||||
executeShippingManualUpload: (taskId: string, displayText?: string) => Promise<boolean>;
|
||||
handleShippingAutoUploadFile: (file: File) => Promise<void>;
|
||||
handleShippingAutoUploadNoticeBatch: (files: File[]) => Promise<void>;
|
||||
refreshShippingActions: () => Promise<void>;
|
||||
shippingSuggestedPrompt: ComputedRef<string>;
|
||||
msg: { warning: (text: string) => void; info: (text: string) => void };
|
||||
t: (key: string) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发货通知发送拦截器。
|
||||
*
|
||||
* 核心逻辑:识别切换任务、数字菜单、决策文本、映射文本、上传/导出意图,并在命中时直接走本地前后端流程。
|
||||
* @param ctx - 发送拦截上下文
|
||||
* @returns 发送前文本与附件自动流程处理函数;返回 true 表示已消费本次发送
|
||||
*/
|
||||
export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
const trySwitchShippingTask = async (content: string): Promise<boolean> => {
|
||||
const intent = parseShippingTaskSwitchIntent(content);
|
||||
if (!intent) return false;
|
||||
const batchNo = ctx.getActiveShippingBatchNo();
|
||||
if (!batchNo) {
|
||||
ctx.msg.warning('当前没有可切换的批次');
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
const detail = await getWorkspaceShippingBatch(batchNo);
|
||||
const tasks = Array.isArray(detail.tasks) ? detail.tasks : [];
|
||||
if (tasks.length <= 1) {
|
||||
ctx.msg.info('当前批次只有 1 票,无需切换');
|
||||
return true;
|
||||
}
|
||||
const focusTaskNo = String(detail.focus_task?.task_no || detail.current_focus_task_no || '').trim().toUpperCase();
|
||||
const currentIndex = Math.max(tasks.findIndex((item) => String(item.task_no || '').trim().toUpperCase() === focusTaskNo), 0);
|
||||
let targetTaskNo = '';
|
||||
if (intent.mode === 'task') {
|
||||
targetTaskNo = String(intent.taskNo || '').trim().toUpperCase();
|
||||
} else if (intent.mode === 'next') {
|
||||
targetTaskNo = String(tasks[Math.min(currentIndex + 1, tasks.length - 1)]?.task_no || '').trim().toUpperCase();
|
||||
} else {
|
||||
targetTaskNo = String(tasks[Math.max(currentIndex - 1, 0)]?.task_no || '').trim().toUpperCase();
|
||||
}
|
||||
if (!targetTaskNo) {
|
||||
ctx.msg.warning('未找到要切换的任务');
|
||||
return true;
|
||||
}
|
||||
if (targetTaskNo === focusTaskNo) {
|
||||
ctx.msg.info(intent.mode === 'next' ? '已经是最后一票' : intent.mode === 'prev' ? '已经是第一票' : '已在当前任务');
|
||||
return true;
|
||||
}
|
||||
await switchWorkspaceShippingBatchFocusTask(batchNo, targetTaskNo);
|
||||
ctx.resolvedShippingTaskId.value = targetTaskNo;
|
||||
await ctx.pushShippingLocalUserMessage(content.trim());
|
||||
await ctx.pushShippingLocalAssistantMessage(`已切换到任务 ${targetTaskNo},请继续当前票处理。`);
|
||||
void ctx.refreshShippingActions();
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '切换任务失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
const tryHandleShippingAttachmentAutoFlow = async (
|
||||
textOrEvent: string | Event | undefined,
|
||||
_content: string,
|
||||
@@ -93,29 +153,16 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
return true;
|
||||
}
|
||||
if (!trimmed) {
|
||||
const prompt = ctx.shippingSuggestedPrompt.value || '解析发货通知并创建任务';
|
||||
let files: ChatUploadFileSpec[] = [];
|
||||
if (ctx.attachmentPolicy.value.anyEnabled && ctx.attachments.value.length > 0) {
|
||||
try {
|
||||
files = await ctx.buildFileSpecsForSend();
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : 'unknown error';
|
||||
ctx.msg.warning(`附件处理失败:${errorMessage}`);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
await ctx.sendMessage(prompt, ctx.currentAgentId.value, ctx.selectedKb.value, files);
|
||||
await ensureShippingHistorySynced({
|
||||
conversationId: ctx.conversationId,
|
||||
history: ctx.history,
|
||||
loadHistory: ctx.loadHistory,
|
||||
getActiveShippingTaskId: ctx.getActiveShippingTaskId,
|
||||
currentAgentId: ctx.currentAgentId,
|
||||
selectedKb: ctx.selectedKb,
|
||||
sendMessage: ctx.sendMessage,
|
||||
});
|
||||
try {
|
||||
const prompt = ctx.shippingSuggestedPrompt.value || '解析发货通知并创建任务';
|
||||
await ctx.pushShippingLocalUserMessage(prompt);
|
||||
await ctx.handleShippingAutoUploadNoticeBatch(localFiles.map((item) => item.file));
|
||||
} catch (e: unknown) {
|
||||
const errorMessage = e instanceof Error ? e.message : '文件处理失败';
|
||||
ctx.msg.warning(errorMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -127,6 +174,11 @@ export function createShippingSendHandlers(ctx: ShippingSendHandlerContext) {
|
||||
_trimmed: string,
|
||||
): Promise<boolean> => {
|
||||
if (!ctx.isShippingNoticeAgent.value) return false;
|
||||
if (await trySwitchShippingTask(content)) {
|
||||
if (typeof textOrEvent !== 'string') ctx.input.value = '';
|
||||
ctx.attachments.value = [];
|
||||
return true;
|
||||
}
|
||||
const assistantCtx = ctx.lastAssistantMessageContent();
|
||||
const menuChoice = resolveShippingNumericChoice(content, assistantCtx);
|
||||
if (menuChoice) {
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
/**
|
||||
* 出货聊天:库存/发货通知文件上传、隐藏 file input、附件建议提示。
|
||||
/**
|
||||
* features/chat/shipping/useChatShippingUploadHandler.ts
|
||||
* 用途:处理发货通知与库存文件上传、批量建单和附件建议提示。
|
||||
* 依赖:shipping.api、shippingUploadPrompt、shipping 常量、chat.types。
|
||||
* 逻辑:由 useChatShipping 调用本文件;本文件识别附件类型后决定是创建任务/批次还是上传库存,并把结果同步到聊天上下文。
|
||||
*/
|
||||
import { computed } from 'vue';
|
||||
import {
|
||||
createWorkspaceShippingBatchFromNotices,
|
||||
createWorkspaceShippingTask,
|
||||
createWorkspaceShippingTaskFromNotice,
|
||||
uploadWorkspaceShippingInventory,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { extractExt } from '../constants/shipping';
|
||||
@@ -20,6 +23,8 @@ export interface ShippingUploadHandlerContext {
|
||||
shippingInventoryPickerRef: Ref<HTMLInputElement | null>;
|
||||
pendingShippingUploadTaskId: Ref<string>;
|
||||
resolvedShippingTaskId: Ref<string>;
|
||||
resolvedShippingBatchNo: Ref<string>;
|
||||
shippingBatchSummary: Ref<unknown | null>;
|
||||
shippingInventorySchemaPreviewCache: Ref<Record<string, unknown>>;
|
||||
getActiveShippingTaskId: () => string;
|
||||
sendShippingMenuMessage: (message: string) => Promise<void>;
|
||||
@@ -29,6 +34,13 @@ export interface ShippingUploadHandlerContext {
|
||||
t: (key: string) => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建发货通知上传处理器。
|
||||
*
|
||||
* 核心逻辑:识别附件属于发货通知还是库存文件,分别触发建单/建批或库存上传,并维护 task/batch 本地上下文。
|
||||
* @param ctx - 上传处理上下文
|
||||
* @returns 自动上传、文件选择器和建议提示相关处理函数
|
||||
*/
|
||||
export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext) {
|
||||
const continueShippingInventoryUploadWithDify = async (
|
||||
taskId: string,
|
||||
@@ -47,6 +59,25 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
await ctx.sendShippingMenuMessage(buildShippingInventoryUploadPrompt(result, fileName));
|
||||
};
|
||||
|
||||
const syncBatchContextFromNoticeResponse = (result: Record<string, unknown> | null | undefined) => {
|
||||
const batchNo = String(
|
||||
(result?.batch_no as string | undefined)
|
||||
|| ((result?.data as { batch?: { batch_no?: string } } | undefined)?.batch?.batch_no)
|
||||
|| '',
|
||||
).trim();
|
||||
const focusTaskNo = String(
|
||||
((result?.data as { focus_task?: { task_no?: string } } | undefined)?.focus_task?.task_no)
|
||||
|| (result?.task_id as string | undefined)
|
||||
|| '',
|
||||
).trim();
|
||||
const batchSummary = ((result?.data as { batch?: unknown } | undefined)?.batch) || null;
|
||||
if (batchNo) ctx.resolvedShippingBatchNo.value = batchNo;
|
||||
if (focusTaskNo) ctx.resolvedShippingTaskId.value = focusTaskNo;
|
||||
if (batchSummary && typeof batchSummary === 'object') {
|
||||
ctx.shippingBatchSummary.value = batchSummary;
|
||||
}
|
||||
};
|
||||
|
||||
const handleShippingAutoUploadFile = async (file: File) => {
|
||||
const kind = classifyShippingUploadFile(file, extractExt);
|
||||
if (kind === 'inventory') {
|
||||
@@ -67,18 +98,28 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
await continueShippingInventoryUploadWithDify(taskId, result as unknown as Record<string, unknown>, file.name);
|
||||
return;
|
||||
}
|
||||
const result = await createWorkspaceShippingTaskFromNotice(
|
||||
file,
|
||||
const result = await createWorkspaceShippingBatchFromNotices(
|
||||
[file],
|
||||
String(ctx.conversationId.value || '').trim() || undefined,
|
||||
);
|
||||
const taskId = String(result.task_id || '').trim();
|
||||
if (taskId) ctx.resolvedShippingTaskId.value = taskId;
|
||||
syncBatchContextFromNoticeResponse(result as unknown as Record<string, unknown>);
|
||||
const taskId = String(
|
||||
((result.data as { focus_task?: { task_no?: string } } | undefined)?.focus_task?.task_no)
|
||||
|| result.task_id
|
||||
|| '',
|
||||
).trim();
|
||||
const batchNo = String(
|
||||
result.batch_no
|
||||
|| ((result.data as { batch?: { batch_no?: string } } | undefined)?.batch?.batch_no)
|
||||
|| '',
|
||||
).trim();
|
||||
const hint = String(result.message || '').trim();
|
||||
const status = String((result as { status?: string }).status || '').trim();
|
||||
const tail = status === 'needs_human' ? '请根据提示进行确认/驳回。' : '';
|
||||
await ctx.pushShippingLocalAssistantMessage(
|
||||
[
|
||||
hint || `已处理发货通知附件:${file.name}`,
|
||||
batchNo ? `批次编号:${batchNo}` : '',
|
||||
taskId ? `任务编号:${taskId}` : '',
|
||||
tail,
|
||||
].filter(Boolean).join('\n'),
|
||||
@@ -86,6 +127,51 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
void ctx.refreshShippingActions();
|
||||
};
|
||||
|
||||
const handleShippingAutoUploadNoticeBatch = async (files: File[]) => {
|
||||
const noticeFiles = files.filter(Boolean);
|
||||
if (!noticeFiles.length) return;
|
||||
const result = await createWorkspaceShippingBatchFromNotices(
|
||||
noticeFiles,
|
||||
String(ctx.conversationId.value || '').trim() || undefined,
|
||||
);
|
||||
syncBatchContextFromNoticeResponse(result as unknown as Record<string, unknown>);
|
||||
const taskId = String(
|
||||
((result.data as { focus_task?: { task_no?: string } } | undefined)?.focus_task?.task_no)
|
||||
|| result.task_id
|
||||
|| '',
|
||||
).trim();
|
||||
const batchNo = String(
|
||||
result.batch_no
|
||||
|| ((result.data as { batch?: { batch_no?: string } } | undefined)?.batch?.batch_no)
|
||||
|| '',
|
||||
).trim();
|
||||
const batch = (result.data as {
|
||||
batch?: { file_count?: number };
|
||||
tasks?: Array<{ batch_index?: number; batch_total?: number }>;
|
||||
} | undefined)?.batch;
|
||||
const tasks = Array.isArray((result.data as { tasks?: unknown[] } | undefined)?.tasks)
|
||||
? (result.data as { tasks: Array<{ batch_index?: number; batch_total?: number }> }).tasks
|
||||
: [];
|
||||
const focusTask = tasks[0];
|
||||
const focusProgress = focusTask?.batch_index && focusTask?.batch_total
|
||||
? `当前第 ${focusTask.batch_index}/${focusTask.batch_total} 票`
|
||||
: '';
|
||||
const fileCount = Number(batch?.file_count || noticeFiles.length || 0);
|
||||
const hint = String(result.message || '').trim();
|
||||
const status = String((result as { status?: string }).status || '').trim();
|
||||
const tail = status === 'needs_human' ? '请根据提示进行确认/驳回。' : '';
|
||||
await ctx.pushShippingLocalAssistantMessage(
|
||||
[
|
||||
hint || `已处理 ${fileCount} 份发货通知附件`,
|
||||
batchNo ? `批次编号:${batchNo}` : '',
|
||||
taskId ? `当前任务:${taskId}` : '',
|
||||
focusProgress,
|
||||
tail,
|
||||
].filter(Boolean).join('\n'),
|
||||
);
|
||||
void ctx.refreshShippingActions();
|
||||
};
|
||||
|
||||
const openShippingInventoryPicker = (): boolean => {
|
||||
const taskId = ctx.getActiveShippingTaskId();
|
||||
if (!taskId) {
|
||||
@@ -132,6 +218,7 @@ export function createShippingUploadHandlers(ctx: ShippingUploadHandlerContext)
|
||||
|
||||
return {
|
||||
handleShippingAutoUploadFile,
|
||||
handleShippingAutoUploadNoticeBatch,
|
||||
openShippingInventoryPicker,
|
||||
handleShippingInventorySelected,
|
||||
shippingSuggestedPrompt,
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface RetrieverResource {
|
||||
export interface ChatMessage {
|
||||
role: 'user' | 'assistant';
|
||||
content: string;
|
||||
type?: 'text' | 'leave-form' | 'leave-confirmation' | 'leave-result' | 'shipping-inventory-mapping';
|
||||
type?: 'text' | 'leave-form' | 'leave-confirmation' | 'leave-result' | 'shipping-inventory-mapping' | 'shipping-parse-review' | 'shipping-match-result';
|
||||
retriever_resources?: RetrieverResource[];
|
||||
attribution_parts?: string[];
|
||||
chat_log_id?: number;
|
||||
|
||||
@@ -5,11 +5,20 @@
|
||||
export interface ShippingTaskSummary {
|
||||
id: number;
|
||||
task_no: string;
|
||||
batch_no?: string | null;
|
||||
source_type: string;
|
||||
source_file_name?: string | null;
|
||||
source_file_type?: string | null;
|
||||
batch_index?: number | null;
|
||||
batch_total?: number | null;
|
||||
customer_name?: string | null;
|
||||
current_step?: string | null;
|
||||
process_status: string;
|
||||
review_status?: string | null;
|
||||
match_status?: string | null;
|
||||
upload_status?: string | null;
|
||||
upload_mode?: string | null;
|
||||
upload_attempt?: number | null;
|
||||
pending_human_reason?: string | null;
|
||||
conversation_id?: string | null;
|
||||
export_file_name?: string | null;
|
||||
@@ -24,14 +33,48 @@ export interface ShippingTaskEvent {
|
||||
created_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingNoticeHeader {
|
||||
customer_name?: string | null;
|
||||
customer_code?: string | null;
|
||||
ship_to?: string | null;
|
||||
po_number?: string | null;
|
||||
required_date?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingNoticeLine {
|
||||
sku: string;
|
||||
reservation_id?: string | null;
|
||||
qty: number;
|
||||
required_date?: string | null;
|
||||
uom?: string | null;
|
||||
line_no?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingMatchLineResult {
|
||||
sku: string;
|
||||
reservation_id?: string | null;
|
||||
required_qty: number;
|
||||
available_qty: number;
|
||||
shortage_qty: number;
|
||||
line_status: 'ok' | 'partial' | 'shortage' | string;
|
||||
}
|
||||
|
||||
export interface ShippingShortageSummary {
|
||||
lines?: ShippingMatchLineResult[];
|
||||
}
|
||||
|
||||
export interface ShippingTaskDetail extends ShippingTaskSummary {
|
||||
customer_code?: string | null;
|
||||
ship_to?: string | null;
|
||||
po_number?: string | null;
|
||||
required_date?: string | null;
|
||||
lines: Array<Record<string, unknown>>;
|
||||
shortage?: Record<string, unknown> | null;
|
||||
line_results?: Array<Record<string, unknown>>;
|
||||
step_payload?: Record<string, unknown>;
|
||||
upload_receipt?: Record<string, unknown>;
|
||||
export_version?: number | null;
|
||||
idempotency_key?: string | null;
|
||||
lines: ShippingNoticeLine[];
|
||||
shortage?: ShippingShortageSummary | null;
|
||||
line_results?: ShippingMatchLineResult[];
|
||||
parse_confidence?: number | null;
|
||||
error_message?: string | null;
|
||||
events: ShippingTaskEvent[];
|
||||
@@ -53,6 +96,17 @@ export interface ShippingChatActionsResponse {
|
||||
action_buttons: ShippingChatAction[];
|
||||
}
|
||||
|
||||
export interface ShippingBatchSummary {
|
||||
id: number;
|
||||
batch_no: string;
|
||||
conversation_id?: string | null;
|
||||
current_focus_task_no?: string | null;
|
||||
file_count?: number | null;
|
||||
process_summary?: Record<string, unknown> | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingInventoryUploadResponse {
|
||||
status: string;
|
||||
message?: string;
|
||||
@@ -73,8 +127,13 @@ export interface ShippingNoticeUploadResponse {
|
||||
status: string;
|
||||
message?: string;
|
||||
task_id?: string;
|
||||
batch_no?: string;
|
||||
checkpoint?: string;
|
||||
data?: Record<string, unknown>;
|
||||
data?: Record<string, unknown> & {
|
||||
batch?: ShippingBatchSummary;
|
||||
focus_task?: ShippingTaskSummary | null;
|
||||
tasks?: Array<Record<string, unknown>>;
|
||||
};
|
||||
human_options?: string[];
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,54 @@ export interface ShippingInventoryMappingFormPayload {
|
||||
applying?: boolean;
|
||||
}
|
||||
|
||||
export interface ShippingParseReviewPayload {
|
||||
taskId: string;
|
||||
checkpoint: string;
|
||||
header: {
|
||||
customer_name?: string | null;
|
||||
customer_code?: string | null;
|
||||
ship_to?: string | null;
|
||||
po_number?: string | null;
|
||||
required_date?: string | null;
|
||||
};
|
||||
lines: Array<{
|
||||
sku: string;
|
||||
reservation_id?: string | null;
|
||||
qty: number;
|
||||
required_date?: string | null;
|
||||
uom?: string | null;
|
||||
line_no?: string | null;
|
||||
}>;
|
||||
saving?: boolean;
|
||||
}
|
||||
|
||||
export interface ShippingMatchResultPayload {
|
||||
taskId: string;
|
||||
match_status?: string | null;
|
||||
line_results: Array<{
|
||||
sku: string;
|
||||
reservation_id?: string | null;
|
||||
required_qty: number;
|
||||
available_qty: number;
|
||||
shortage_qty: number;
|
||||
line_status: 'ok' | 'partial' | 'shortage' | string;
|
||||
}>;
|
||||
shortage_lines?: Array<{
|
||||
sku: string;
|
||||
reservation_id?: string | null;
|
||||
required_qty: number;
|
||||
available_qty: number;
|
||||
shortage_qty: number;
|
||||
line_status: 'ok' | 'partial' | 'shortage' | string;
|
||||
}>;
|
||||
action_buttons?: Array<{
|
||||
id: string;
|
||||
label: string;
|
||||
message: string;
|
||||
variant: 'primary' | 'secondary' | 'danger';
|
||||
}>;
|
||||
}
|
||||
|
||||
export interface ShippingActionButton {
|
||||
id: string;
|
||||
label: string;
|
||||
|
||||
@@ -1,21 +1,44 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/views/ShippingNoticeView.vue
|
||||
* 货代发货任务只读工作台:列表筛选、详情、跳转 Chat 继续处理。
|
||||
* 用途:货代发货任务只读工作台,提供任务筛选、详情查看与跳转 Chat 继续处理入口。
|
||||
* 依赖:ShippingWorkflowStepper、ShippingParseReviewMessage、ShippingMatchResultCard、shipping.api。
|
||||
* 逻辑:先拉取任务列表与详情,再复用 Chat 区的发货组件展示步骤、匹配结果和 parse review。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { ArrowLeft, Download, ExternalLink, RefreshCw } from 'lucide-vue-next';
|
||||
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
|
||||
import ShippingParseReviewMessage, {
|
||||
type ShippingParseReviewHandlers,
|
||||
} from '@/features/chat/components/messages/ShippingParseReviewMessage.vue';
|
||||
import ShippingMatchResultCard from '@/features/chat/components/messages/ShippingMatchResultCard.vue';
|
||||
import {
|
||||
addWorkspaceShippingNoticeLine,
|
||||
autoProgressWorkspaceShippingTask,
|
||||
generateWorkspaceShippingExcel,
|
||||
getShippingChatActions,
|
||||
getWorkspaceShippingTask,
|
||||
listWorkspaceShippingTasks,
|
||||
markWorkspaceShippingManualUploaded,
|
||||
matchWorkspaceShippingInventory,
|
||||
removeWorkspaceShippingNoticeLine,
|
||||
SHIPPING_NOTICE_AGENT_NAME,
|
||||
submitWorkspaceShippingDecision,
|
||||
updateWorkspaceShippingNoticeFields,
|
||||
updateWorkspaceShippingNoticeLine,
|
||||
workspaceShippingExportUrl,
|
||||
type ShippingChatAction,
|
||||
type ShippingNoticeHeader,
|
||||
type ShippingNoticeLine,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import type { ChatMessage } from '@/features/chat/types/chat.types';
|
||||
import type { ShippingParseReviewPayload } from '@/features/chat/types/shipping.types';
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { buildShippingWorkflowSteps, shippingActionButtonClass } from '@/features/chat/shipping';
|
||||
|
||||
const props = defineProps<{
|
||||
embedded?: boolean;
|
||||
@@ -29,8 +52,18 @@ const detailLoading = ref(false);
|
||||
const tasks = ref<ShippingTaskSummary[]>([]);
|
||||
const selectedTaskNo = ref<string | null>(null);
|
||||
const detail = ref<ShippingTaskDetail | null>(null);
|
||||
const detailSaving = ref(false);
|
||||
const detailActionBusy = ref(false);
|
||||
const detailActionButtons = ref<ShippingChatAction[]>([]);
|
||||
const statusFilter = ref('all');
|
||||
const chatAgentId = ref<number | null>(null);
|
||||
const batchProgressLabel = computed(() => {
|
||||
if (!detail.value?.batch_index || !detail.value?.batch_total) return '';
|
||||
return t('chat.shippingNoticeUi.batchProgress', {
|
||||
index: detail.value.batch_index,
|
||||
total: detail.value.batch_total,
|
||||
});
|
||||
});
|
||||
|
||||
const statusOptions = computed(() => [
|
||||
{ value: 'all', label: t('workspace.shippingNotice.status.all') },
|
||||
@@ -56,6 +89,8 @@ const statusBadge = (status: string) => {
|
||||
return map[status] || { cls: 'bg-slate-100 text-secondary', label: status };
|
||||
};
|
||||
|
||||
const detailWorkflowSteps = computed(() => buildShippingWorkflowSteps(detail.value));
|
||||
|
||||
const loadCases = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -73,9 +108,15 @@ const loadCases = async () => {
|
||||
const loadDetail = async (taskNo: string) => {
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
detail.value = await getWorkspaceShippingTask(taskNo);
|
||||
const [taskDetail, chatActions] = await Promise.all([
|
||||
getWorkspaceShippingTask(taskNo),
|
||||
getShippingChatActions(taskNo).catch(() => null),
|
||||
]);
|
||||
detail.value = taskDetail;
|
||||
detailActionButtons.value = chatActions?.action_buttons || [];
|
||||
} catch {
|
||||
detail.value = null;
|
||||
detailActionButtons.value = [];
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
@@ -93,9 +134,11 @@ const resolveChatAgent = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
const openInChat = (taskNo: string, conversationId?: string | null) => {
|
||||
const openInChat = (taskNo: string, conversationId?: string | null, batchNo?: string | null) => {
|
||||
if (!chatAgentId.value) return;
|
||||
const query: Record<string, string> = { task_id: taskNo };
|
||||
const normalizedBatchNo = String(batchNo || '').trim();
|
||||
if (normalizedBatchNo) query.batch_no = normalizedBatchNo;
|
||||
const cid = String(conversationId || '').trim();
|
||||
if (/^[0-9a-f]{32}$/i.test(cid)) query.conversation_id = cid;
|
||||
router.push({ path: `/chat/${chatAgentId.value}`, query });
|
||||
@@ -113,6 +156,133 @@ const downloadExport = async (taskNo: string) => {
|
||||
URL.revokeObjectURL(a.href);
|
||||
};
|
||||
|
||||
const parseReviewPayload = computed<ShippingParseReviewPayload | null>(() => {
|
||||
if (!detail.value || detail.value.review_status !== 'pending_confirm') return null;
|
||||
return {
|
||||
taskId: detail.value.task_no,
|
||||
checkpoint: 'parse_review',
|
||||
header: {
|
||||
customer_name: detail.value.customer_name ?? null,
|
||||
customer_code: detail.value.customer_code ?? null,
|
||||
ship_to: detail.value.ship_to ?? null,
|
||||
po_number: detail.value.po_number ?? null,
|
||||
required_date: detail.value.required_date ?? null,
|
||||
},
|
||||
lines: Array.isArray(detail.value.lines) ? detail.value.lines : [],
|
||||
saving: detailSaving.value,
|
||||
};
|
||||
});
|
||||
|
||||
const parseReviewMessage = computed<ChatMessage>(() => ({
|
||||
role: 'assistant',
|
||||
type: 'shipping-parse-review',
|
||||
content: `${t('chat.shippingNoticeUi.parseReviewIntro')}\n${t('chat.shippingNoticeUi.taskId', { taskId: detail.value?.task_no || '' })}`.trim(),
|
||||
payload: parseReviewPayload.value || undefined,
|
||||
}));
|
||||
|
||||
const parseReviewHandlers: ShippingParseReviewHandlers = {
|
||||
getPayload: () => parseReviewPayload.value,
|
||||
updateHeader: async (_msg, fields: Partial<ShippingNoticeHeader>) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeFields(detail.value.task_no, fields, '工作台订单表修订');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
updateLine: async (_msg, lineIndex: number, patch: Partial<ShippingNoticeLine>) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await updateWorkspaceShippingNoticeLine(detail.value.task_no, lineIndex, patch, '工作台订单表修订');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
addLine: async (_msg, line: Partial<ShippingNoticeLine>) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await addWorkspaceShippingNoticeLine(detail.value.task_no, line, '工作台订单表新增行');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
removeLine: async (_msg, lineIndex: number) => {
|
||||
if (!detail.value || detailSaving.value) return false;
|
||||
detailSaving.value = true;
|
||||
try {
|
||||
await removeWorkspaceShippingNoticeLine(detail.value.task_no, lineIndex, '工作台订单表删除行');
|
||||
await Promise.all([loadDetail(detail.value.task_no), loadCases()]);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
} finally {
|
||||
detailSaving.value = false;
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const shortageLines = computed(() => detail.value?.shortage?.lines || []);
|
||||
const hasMatchCard = computed(() =>
|
||||
!!detail.value && (
|
||||
(Array.isArray(detail.value.line_results) && detail.value.line_results.length > 0)
|
||||
|| shortageLines.value.length > 0
|
||||
),
|
||||
);
|
||||
|
||||
const handleWorkspaceAction = async (action: ShippingChatAction) => {
|
||||
if (!detail.value || detailActionBusy.value) return;
|
||||
const taskNo = detail.value.task_no;
|
||||
detailActionBusy.value = true;
|
||||
try {
|
||||
if (action.id === 'download_excel') {
|
||||
await downloadExport(taskNo);
|
||||
return;
|
||||
}
|
||||
if (action.id === 'generate_excel') {
|
||||
await generateWorkspaceShippingExcel(taskNo);
|
||||
} else if (action.id === 'match_inventory') {
|
||||
await matchWorkspaceShippingInventory(taskNo);
|
||||
} else if (action.id === 'mark_manual_uploaded') {
|
||||
await markWorkspaceShippingManualUploaded(taskNo);
|
||||
} else if (action.id === 'refresh') {
|
||||
await loadDetail(taskNo);
|
||||
return;
|
||||
} else if (action.id === 'confirm_inventory_mapping') {
|
||||
await autoProgressWorkspaceShippingTask(taskNo);
|
||||
} else if ([
|
||||
'confirm',
|
||||
'reject',
|
||||
'reparse',
|
||||
'correct_inventory_mapping',
|
||||
'reparse_inventory',
|
||||
'rematch',
|
||||
].includes(action.id)) {
|
||||
await submitWorkspaceShippingDecision(taskNo, action.id);
|
||||
} else {
|
||||
openInChat(taskNo, detail.value.conversation_id, detail.value.batch_no);
|
||||
return;
|
||||
}
|
||||
await Promise.all([loadDetail(taskNo), loadCases()]);
|
||||
} finally {
|
||||
detailActionBusy.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
watch(selectedTaskNo, (val) => {
|
||||
if (val) loadDetail(val);
|
||||
else detail.value = null;
|
||||
@@ -189,7 +359,12 @@ onMounted(async () => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 truncate text-sm text-secondary">{{ item.customer_name || '—' }}</div>
|
||||
<div class="mt-1 text-xs text-muted">{{ item.created_at || '' }}</div>
|
||||
<div class="mt-1 flex flex-wrap items-center gap-2 text-xs text-muted">
|
||||
<span>{{ item.created_at || '' }}</span>
|
||||
<span v-if="item.batch_index && item.batch_total" class="rounded-full bg-sky-50 px-2 py-0.5 font-medium text-sky-700">
|
||||
{{ t('chat.shippingNoticeUi.batchProgress', { index: item.batch_index, total: item.batch_total }) }}
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -207,14 +382,19 @@ onMounted(async () => {
|
||||
<div class="flex flex-wrap items-center justify-between gap-3">
|
||||
<div>
|
||||
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
|
||||
<div class="text-sm text-muted">{{ detail.customer_name }} · {{ detail.customer_code || '—' }}</div>
|
||||
<div class="flex flex-wrap items-center gap-2 text-sm text-muted">
|
||||
<span>{{ detail.customer_name }} · {{ detail.customer_code || '—' }}</span>
|
||||
<span v-if="batchProgressLabel" class="rounded-full bg-sky-50 px-2 py-0.5 text-xs font-medium text-sky-700">
|
||||
{{ batchProgressLabel }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-if="chatAgentId"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-brand-300 bg-brand-50 px-3 py-1.5 text-sm font-medium text-brand-700 hover:bg-brand-100"
|
||||
@click="openInChat(detail.task_no, detail.conversation_id)"
|
||||
@click="openInChat(detail.task_no, detail.conversation_id, detail.batch_no)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.openChat') }}
|
||||
@@ -231,6 +411,8 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ShippingWorkflowStepper :steps="detailWorkflowSteps" />
|
||||
|
||||
<dl class="grid gap-3 sm:grid-cols-2 text-sm">
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.status') }}</dt><dd>{{ detail.process_status }}</dd></div>
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.match') }}</dt><dd>{{ detail.match_status || '—' }}</dd></div>
|
||||
@@ -242,7 +424,26 @@ onMounted(async () => {
|
||||
{{ detail.error_message }}
|
||||
</div>
|
||||
|
||||
<div v-if="detail.lines?.length">
|
||||
<ShippingMatchResultCard
|
||||
v-if="hasMatchCard"
|
||||
:task-id="detail.task_no"
|
||||
:match-status="detail.match_status"
|
||||
:line-results="detail.line_results"
|
||||
:shortage-lines="shortageLines"
|
||||
:action-buttons="detailActionButtons"
|
||||
:action-busy="detailActionBusy"
|
||||
:action-button-class="shippingActionButtonClass"
|
||||
:on-action-click="handleWorkspaceAction"
|
||||
/>
|
||||
|
||||
<div v-if="parseReviewPayload">
|
||||
<ShippingParseReviewMessage
|
||||
:message="parseReviewMessage"
|
||||
:handlers="parseReviewHandlers"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-else-if="detail.lines?.length">
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">{{ $t('workspace.shippingNotice.lines') }}</h3>
|
||||
<div class="overflow-x-auto rounded-xl border border-default">
|
||||
<table class="min-w-full text-sm">
|
||||
@@ -254,8 +455,8 @@ onMounted(async () => {
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(line, idx) in detail.lines" :key="idx" class="border-t border-default/60">
|
||||
<td class="px-3 py-2 font-mono">{{ line.sku || line.part_no || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.qty ?? line.quantity ?? '—' }}</td>
|
||||
<td class="px-3 py-2 font-mono">{{ line.sku || '—' }}</td>
|
||||
<td class="px-3 py-2">{{ line.qty ?? '—' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@@ -40,6 +40,96 @@
|
||||
"empty": "(empty)",
|
||||
"unrecognized": "(unrecognized)"
|
||||
},
|
||||
"shippingNoticeUi": {
|
||||
"parseReviewIntro": "Please confirm or revise the parsed result below.",
|
||||
"parseReviewHeader": "Parsed notice header",
|
||||
"taskId": "Task ID: {taskId}",
|
||||
"editHeader": "Edit header",
|
||||
"cancelEdit": "Cancel edit",
|
||||
"customer": "Customer",
|
||||
"customerCode": "Customer code",
|
||||
"shipTo": "Ship to",
|
||||
"poNumber": "PO number",
|
||||
"requiredDate": "Required date",
|
||||
"saveHeader": "Save header",
|
||||
"saving": "Saving...",
|
||||
"orderLines": "Order lines",
|
||||
"addLine": "Add line",
|
||||
"reservationId": "Reservation ID",
|
||||
"sku": "SKU",
|
||||
"qty": "Qty",
|
||||
"actions": "Actions",
|
||||
"editLine": "Edit",
|
||||
"deleteLine": "Delete",
|
||||
"addOrderLine": "Add order line",
|
||||
"saveAddedLine": "Save new line",
|
||||
"editLineTitle": "Edit line {index}",
|
||||
"saveLineItem": "Save line item",
|
||||
"matchResult": "Inventory match result",
|
||||
"orderDemand": "Order demand",
|
||||
"inventoryAvailable": "Inventory available",
|
||||
"shortageQty": "Shortage",
|
||||
"statusLabel": "Status",
|
||||
"shortageBanner": "Inventory shortage exists. Do not continue to freight upload yet. Resolve the shortage first, or use the available actions to confirm partial shipment / retry matching.",
|
||||
"shortageDetails": "Shortage details",
|
||||
"shortageRowDetail": "Line {index}: Reservation ID {reservationId}, SKU {sku}, shortage {shortage}",
|
||||
"availableActions": "Available actions",
|
||||
"stepperTitle": "Workflow steps",
|
||||
"batchTitle": "Shipping batch",
|
||||
"taskTitle": "Shipping task",
|
||||
"currentTask": "Current task {taskId}",
|
||||
"batchProgress": "Item {index}/{total}",
|
||||
"currentNotice": "Current notice",
|
||||
"prevTask": "Previous",
|
||||
"nextTask": "Next",
|
||||
"collapseTasks": "Hide tasks",
|
||||
"viewTasks": "View tasks",
|
||||
"fileCount": "Files",
|
||||
"runningCount": "Running",
|
||||
"completedCount": "Completed",
|
||||
"batchProgressTitle": "Batch progress",
|
||||
"processing": "Processing",
|
||||
"status": {
|
||||
"created": "Pending parse",
|
||||
"waitingInventory": "Waiting inventory",
|
||||
"inventoryReady": "Inventory ready",
|
||||
"matched": "Matched",
|
||||
"waitingUpload": "Waiting upload",
|
||||
"uploaded": "Completed",
|
||||
"uploadFailed": "Upload failed",
|
||||
"rejected": "Rejected",
|
||||
"closed": "Closed"
|
||||
},
|
||||
"currentStep": {
|
||||
"noticeParse": "Notice parsing",
|
||||
"inventoryPrepare": "Inventory prep",
|
||||
"inventoryMatch": "Inventory match",
|
||||
"shortageHandle": "Shortage handling",
|
||||
"generateExcel": "Generate Excel",
|
||||
"uploadFreight": "Upload to freight",
|
||||
"finishArchive": "Archive"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "Fully fulfillable",
|
||||
"partial": "Partially fulfillable",
|
||||
"unfulfillable": "Unfulfillable",
|
||||
"pending": "Pending match"
|
||||
},
|
||||
"rowStatus": {
|
||||
"ok": "Enough",
|
||||
"partial": "Partial",
|
||||
"shortage": "Shortage"
|
||||
},
|
||||
"stepper": {
|
||||
"noticeSubmit": "Submit notice",
|
||||
"parseConfirm": "Confirm parsing",
|
||||
"inventoryPrepare": "Get inventory",
|
||||
"alignConfirm": "Confirm mapping",
|
||||
"matchInventory": "Match inventory",
|
||||
"generateFile": "Generate shipment file",
|
||||
"uploadFreight": "Upload freight"
|
||||
}
|
||||
},
|
||||
"clearAll": "Clear All",
|
||||
"clearOneRecord": "Clear This Record",
|
||||
"agents": "Agents",
|
||||
|
||||
@@ -40,6 +40,96 @@
|
||||
"empty": "(ว่าง)",
|
||||
"unrecognized": "(ไม่รู้จัก)"
|
||||
},
|
||||
"shippingNoticeUi": {
|
||||
"parseReviewIntro": "โปรดยืนยันหรือแก้ไขผลการแยกข้อมูลด้านล่าง",
|
||||
"parseReviewHeader": "หัวข้อมูลที่แยกแล้ว",
|
||||
"taskId": "รหัสงาน: {taskId}",
|
||||
"editHeader": "แก้ไขส่วนหัว",
|
||||
"cancelEdit": "ยกเลิกการแก้ไข",
|
||||
"customer": "ลูกค้า",
|
||||
"customerCode": "รหัสลูกค้า",
|
||||
"shipTo": "ผู้รับสินค้า",
|
||||
"poNumber": "เลขที่ PO",
|
||||
"requiredDate": "วันที่ต้องการ",
|
||||
"saveHeader": "บันทึกส่วนหัว",
|
||||
"saving": "กำลังบันทึก...",
|
||||
"orderLines": "รายการคำสั่งซื้อ",
|
||||
"addLine": "เพิ่มแถว",
|
||||
"reservationId": "Reservation ID",
|
||||
"sku": "SKU",
|
||||
"qty": "จำนวน",
|
||||
"actions": "การทำงาน",
|
||||
"editLine": "แก้ไข",
|
||||
"deleteLine": "ลบ",
|
||||
"addOrderLine": "เพิ่มรายการคำสั่งซื้อ",
|
||||
"saveAddedLine": "บันทึกรายการใหม่",
|
||||
"editLineTitle": "แก้ไขแถวที่ {index}",
|
||||
"saveLineItem": "บันทึกรายการ",
|
||||
"matchResult": "ผลการจับคู่สต็อก",
|
||||
"orderDemand": "ความต้องการตามคำสั่งซื้อ",
|
||||
"inventoryAvailable": "สต็อกที่ใช้ได้",
|
||||
"shortageQty": "จำนวนที่ขาด",
|
||||
"statusLabel": "สถานะ",
|
||||
"shortageBanner": "มีสต็อกขาดอยู่ จึงยังไม่ควรอัปโหลดไปยังผู้ให้บริการขนส่งต่อ กรุณาจัดการส่วนที่ขาดก่อน หรือใช้ปุ่มที่มีให้เพื่อยืนยันการส่งบางส่วน / จับคู่ใหม่",
|
||||
"shortageDetails": "รายละเอียดส่วนขาด",
|
||||
"shortageRowDetail": "แถว {index}: Reservation ID {reservationId}, SKU {sku}, ขาด {shortage}",
|
||||
"availableActions": "การทำงานที่ใช้ได้",
|
||||
"stepperTitle": "ขั้นตอนการทำงาน",
|
||||
"batchTitle": "ชุดงานจัดส่ง",
|
||||
"taskTitle": "งานจัดส่ง",
|
||||
"currentTask": "งานปัจจุบัน {taskId}",
|
||||
"batchProgress": "รายการ {index}/{total}",
|
||||
"currentNotice": "ใบแจ้งปัจจุบัน",
|
||||
"prevTask": "ก่อนหน้า",
|
||||
"nextTask": "ถัดไป",
|
||||
"collapseTasks": "ซ่อนงาน",
|
||||
"viewTasks": "ดูงาน",
|
||||
"fileCount": "จำนวนไฟล์",
|
||||
"runningCount": "กำลังดำเนินการ",
|
||||
"completedCount": "เสร็จแล้ว",
|
||||
"batchProgressTitle": "ความคืบหน้าของชุดงาน",
|
||||
"processing": "กำลังดำเนินการ",
|
||||
"status": {
|
||||
"created": "รอแยกข้อมูล",
|
||||
"waitingInventory": "รอสต็อก",
|
||||
"inventoryReady": "สต็อกพร้อม",
|
||||
"matched": "จับคู่แล้ว",
|
||||
"waitingUpload": "รออัปโหลด",
|
||||
"uploaded": "เสร็จสมบูรณ์",
|
||||
"uploadFailed": "อัปโหลดล้มเหลว",
|
||||
"rejected": "ถูกปฏิเสธ",
|
||||
"closed": "ปิดแล้ว"
|
||||
},
|
||||
"currentStep": {
|
||||
"noticeParse": "แยกใบแจ้ง",
|
||||
"inventoryPrepare": "เตรียมสต็อก",
|
||||
"inventoryMatch": "จับคู่สต็อก",
|
||||
"shortageHandle": "จัดการส่วนขาด",
|
||||
"generateExcel": "สร้าง Excel",
|
||||
"uploadFreight": "อัปโหลดผู้ให้บริการขนส่ง",
|
||||
"finishArchive": "เก็บงาน"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "จัดส่งได้ครบ",
|
||||
"partial": "จัดส่งได้บางส่วน",
|
||||
"unfulfillable": "จัดส่งไม่ได้",
|
||||
"pending": "รอจับคู่"
|
||||
},
|
||||
"rowStatus": {
|
||||
"ok": "เพียงพอ",
|
||||
"partial": "บางส่วน",
|
||||
"shortage": "ขาด"
|
||||
},
|
||||
"stepper": {
|
||||
"noticeSubmit": "ส่งใบแจ้ง",
|
||||
"parseConfirm": "ยืนยันผลแยก",
|
||||
"inventoryPrepare": "เตรียมสต็อก",
|
||||
"alignConfirm": "ยืนยันการจับคู่คอลัมน์",
|
||||
"matchInventory": "จับคู่สต็อก",
|
||||
"generateFile": "สร้างไฟล์จัดส่ง",
|
||||
"uploadFreight": "อัปโหลดผู้ให้บริการขนส่ง"
|
||||
}
|
||||
},
|
||||
"clearAll": "ล้างทั้งหมด",
|
||||
"clearOneRecord": "ลบรายการนี้",
|
||||
"agents": "ตัวแทน",
|
||||
|
||||
@@ -40,6 +40,96 @@
|
||||
"empty": "(空)",
|
||||
"unrecognized": "(未识别)"
|
||||
},
|
||||
"shippingNoticeUi": {
|
||||
"parseReviewIntro": "请确认或修订以下解析结果。",
|
||||
"parseReviewHeader": "解析结果单头",
|
||||
"taskId": "任务编号:{taskId}",
|
||||
"editHeader": "编辑单头",
|
||||
"cancelEdit": "取消编辑",
|
||||
"customer": "客户",
|
||||
"customerCode": "客户编码",
|
||||
"shipTo": "收货方",
|
||||
"poNumber": "采购单号",
|
||||
"requiredDate": "需求日期",
|
||||
"saveHeader": "保存单头",
|
||||
"saving": "保存中...",
|
||||
"orderLines": "订单行",
|
||||
"addLine": "新增一行",
|
||||
"reservationId": "预订单号",
|
||||
"sku": "料号",
|
||||
"qty": "数量",
|
||||
"actions": "操作",
|
||||
"editLine": "编辑",
|
||||
"deleteLine": "删除",
|
||||
"addOrderLine": "新增订单行",
|
||||
"saveAddedLine": "保存新增行",
|
||||
"editLineTitle": "编辑第 {index} 行",
|
||||
"saveLineItem": "保存行项目",
|
||||
"matchResult": "库存匹配结果",
|
||||
"orderDemand": "订单需求",
|
||||
"inventoryAvailable": "库存可用",
|
||||
"shortageQty": "缺口",
|
||||
"statusLabel": "状态",
|
||||
"shortageBanner": "存在库存缺口,当前不能直接继续上传货代。请先处理缺口,或按可用按钮确认部分发货 / 重新匹配。",
|
||||
"shortageDetails": "缺口明细",
|
||||
"shortageRowDetail": "第 {index} 行:预订单号 {reservationId},料号 {sku},缺口 {shortage}",
|
||||
"availableActions": "可用操作",
|
||||
"stepperTitle": "流程步骤",
|
||||
"batchTitle": "发货批次",
|
||||
"taskTitle": "发货任务",
|
||||
"currentTask": "当前任务 {taskId}",
|
||||
"batchProgress": "第 {index}/{total} 票",
|
||||
"currentNotice": "当前通知",
|
||||
"prevTask": "上一票",
|
||||
"nextTask": "下一票",
|
||||
"collapseTasks": "收起任务",
|
||||
"viewTasks": "查看任务",
|
||||
"fileCount": "文件数",
|
||||
"runningCount": "处理中",
|
||||
"completedCount": "已完成",
|
||||
"batchProgressTitle": "批次进度",
|
||||
"processing": "处理中",
|
||||
"status": {
|
||||
"created": "待解析",
|
||||
"waitingInventory": "待库存",
|
||||
"inventoryReady": "库存就绪",
|
||||
"matched": "已匹配",
|
||||
"waitingUpload": "待上传",
|
||||
"uploaded": "已完成",
|
||||
"uploadFailed": "上传失败",
|
||||
"rejected": "已驳回",
|
||||
"closed": "已关闭"
|
||||
},
|
||||
"currentStep": {
|
||||
"noticeParse": "通知解析",
|
||||
"inventoryPrepare": "库存准备",
|
||||
"inventoryMatch": "库存匹配",
|
||||
"shortageHandle": "缺口处理",
|
||||
"generateExcel": "生成 Excel",
|
||||
"uploadFreight": "上传货代",
|
||||
"finishArchive": "完成归档"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "可全部发货",
|
||||
"partial": "部分满足",
|
||||
"unfulfillable": "无法满足",
|
||||
"pending": "待匹配"
|
||||
},
|
||||
"rowStatus": {
|
||||
"ok": "充足",
|
||||
"partial": "部分满足",
|
||||
"shortage": "缺口"
|
||||
},
|
||||
"stepper": {
|
||||
"noticeSubmit": "提交通知",
|
||||
"parseConfirm": "确认解析",
|
||||
"inventoryPrepare": "获取库存",
|
||||
"alignConfirm": "确认字段对齐",
|
||||
"matchInventory": "匹配库存",
|
||||
"generateFile": "生成发货文件",
|
||||
"uploadFreight": "上传货代"
|
||||
}
|
||||
},
|
||||
"clearAll": "清空全部",
|
||||
"clearOneRecord": "清除该记录",
|
||||
"agents": "智能体",
|
||||
|
||||
@@ -14,6 +14,122 @@
|
||||
"thinking": "正在生成回答...",
|
||||
"disclaimer": "AI 可能會犯錯,請核實重要信息。",
|
||||
"createNewChat": "建立新對話",
|
||||
"shippingNoticeContinue": "請繼續處理發貨任務 {taskId}。請先呼叫 get_task_status,再告訴我下一步。",
|
||||
"shippingNoticeActionsHint": "請選擇操作:",
|
||||
"shippingNoticeMissingTaskId": "找不到任務編號,請先完成發貨通知解析。",
|
||||
"shippingNoticeUploadDone": "庫存檔案已上傳:{fileName}。",
|
||||
"shippingNoticeUploadOk": "上傳成功。",
|
||||
"shippingNoticeUploadFailed": "庫存檔案上傳失敗。",
|
||||
"shippingNoticePasteHint": "請在輸入框貼上庫存小表內容後送出。",
|
||||
"shippingNoticeDecisionDone": "操作已完成。",
|
||||
"shippingNoticeMapping": {
|
||||
"inventoryHeaders": "庫存表頭",
|
||||
"headerRow": "表頭列:{row}",
|
||||
"sample": "樣例",
|
||||
"orderDetails": "訂單明細",
|
||||
"orderRowCount": "訂單行數:{count}",
|
||||
"orderSkuPreview": "SKU(前{count}):{skus}",
|
||||
"skuColumnRequired": "SKU 欄位(必填)",
|
||||
"availableQtyColumnRequired": "可用數量欄位(必填)",
|
||||
"reservationIdColumnOptional": "Reservation ID 欄位(選填)",
|
||||
"selectHeader": "請選擇表頭欄位",
|
||||
"reservationIdNotUsed": "(不使用 Reservation ID)",
|
||||
"reupload": "重新上傳",
|
||||
"applying": "套用中...",
|
||||
"applyAndParse": "套用映射並解析",
|
||||
"empty": "(空)",
|
||||
"unrecognized": "(未辨識)"
|
||||
},
|
||||
"shippingNoticeUi": {
|
||||
"parseReviewIntro": "請確認或修訂以下解析結果。",
|
||||
"parseReviewHeader": "解析結果單頭",
|
||||
"taskId": "任務編號:{taskId}",
|
||||
"editHeader": "編輯單頭",
|
||||
"cancelEdit": "取消編輯",
|
||||
"customer": "客戶",
|
||||
"customerCode": "客戶代碼",
|
||||
"shipTo": "收貨方",
|
||||
"poNumber": "採購單號",
|
||||
"requiredDate": "需求日期",
|
||||
"saveHeader": "儲存單頭",
|
||||
"saving": "儲存中...",
|
||||
"orderLines": "訂單行",
|
||||
"addLine": "新增一行",
|
||||
"reservationId": "預訂單號",
|
||||
"sku": "料號",
|
||||
"qty": "數量",
|
||||
"actions": "操作",
|
||||
"editLine": "編輯",
|
||||
"deleteLine": "刪除",
|
||||
"addOrderLine": "新增訂單行",
|
||||
"saveAddedLine": "儲存新增行",
|
||||
"editLineTitle": "編輯第 {index} 行",
|
||||
"saveLineItem": "儲存行項目",
|
||||
"matchResult": "庫存匹配結果",
|
||||
"orderDemand": "訂單需求",
|
||||
"inventoryAvailable": "庫存可用",
|
||||
"shortageQty": "缺口",
|
||||
"statusLabel": "狀態",
|
||||
"shortageBanner": "存在庫存缺口,目前不能直接繼續上傳貨代。請先處理缺口,或依可用按鈕確認部分發貨 / 重新匹配。",
|
||||
"shortageDetails": "缺口明細",
|
||||
"shortageRowDetail": "第 {index} 行:預訂單號 {reservationId},料號 {sku},缺口 {shortage}",
|
||||
"availableActions": "可用操作",
|
||||
"stepperTitle": "流程步驟",
|
||||
"batchTitle": "發貨批次",
|
||||
"taskTitle": "發貨任務",
|
||||
"currentTask": "當前任務 {taskId}",
|
||||
"batchProgress": "第 {index}/{total} 票",
|
||||
"currentNotice": "當前通知",
|
||||
"prevTask": "上一票",
|
||||
"nextTask": "下一票",
|
||||
"collapseTasks": "收起任務",
|
||||
"viewTasks": "查看任務",
|
||||
"fileCount": "檔案數",
|
||||
"runningCount": "處理中",
|
||||
"completedCount": "已完成",
|
||||
"batchProgressTitle": "批次進度",
|
||||
"processing": "處理中",
|
||||
"status": {
|
||||
"created": "待解析",
|
||||
"waitingInventory": "待庫存",
|
||||
"inventoryReady": "庫存就緒",
|
||||
"matched": "已匹配",
|
||||
"waitingUpload": "待上傳",
|
||||
"uploaded": "已完成",
|
||||
"uploadFailed": "上傳失敗",
|
||||
"rejected": "已駁回",
|
||||
"closed": "已關閉"
|
||||
},
|
||||
"currentStep": {
|
||||
"noticeParse": "通知解析",
|
||||
"inventoryPrepare": "庫存準備",
|
||||
"inventoryMatch": "庫存匹配",
|
||||
"shortageHandle": "缺口處理",
|
||||
"generateExcel": "生成 Excel",
|
||||
"uploadFreight": "上傳貨代",
|
||||
"finishArchive": "完成歸檔"
|
||||
},
|
||||
"matchStatus": {
|
||||
"fulfillable": "可全部發貨",
|
||||
"partial": "部分滿足",
|
||||
"unfulfillable": "無法滿足",
|
||||
"pending": "待匹配"
|
||||
},
|
||||
"rowStatus": {
|
||||
"ok": "充足",
|
||||
"partial": "部分滿足",
|
||||
"shortage": "缺口"
|
||||
},
|
||||
"stepper": {
|
||||
"noticeSubmit": "提交通知",
|
||||
"parseConfirm": "確認解析",
|
||||
"inventoryPrepare": "獲取庫存",
|
||||
"alignConfirm": "確認欄位對齊",
|
||||
"matchInventory": "匹配庫存",
|
||||
"generateFile": "生成發貨文件",
|
||||
"uploadFreight": "上傳貨代"
|
||||
}
|
||||
},
|
||||
"clearAll": "清空全部",
|
||||
"clearOneRecord": "清除此記錄",
|
||||
"agents": "智能體",
|
||||
|
||||
Reference in new issue
Block a user