feat(shipping-notice): 新增发货批次和任务管理功能,支持批次创建与任务处理
This commit is contained in:
1 parent
457f0f4e5e
commit
634dee4b81
81 files changed
+9088
-3625
No files matched your search
@@ -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'"
|
||||
|
||||
Reference in new issue
Block a user