feat(shipping-notice): 落地字段资产治理与唯一 Schema,自动建单随版本冻结
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b7307fc573
commit
3a1dbf7ce5
144 files changed
+15167
-4480
No files matched your search
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* features/workspace/api/shipping-tasks.api.ts
|
||||
* 用途:工作台发货任务 / 我的待办 API 客户端。
|
||||
* 依赖:shared/api/client、chat shipping.api(履约写操作暂复用)。
|
||||
* 逻辑:My Todos 与徽标走本文件;submit-decision / 下载 / 人工上传仍委托 shipping.api。
|
||||
*/
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import type { ShippingTaskSummary } from '@/features/chat/types/shipping.api.types';
|
||||
import {
|
||||
markWorkspaceShippingManualUploaded,
|
||||
submitWorkspaceShippingDecision,
|
||||
workspaceShippingExportUrl,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/chat/shipping/shippingDownload';
|
||||
|
||||
export interface ShippingMyTodosPage {
|
||||
items: ShippingTaskSummary[];
|
||||
page: number;
|
||||
page_size: number;
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface ShippingMyTodosCount {
|
||||
pending: number;
|
||||
processing: number;
|
||||
done: number;
|
||||
total_pending_badge: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页拉取「我的待办」。
|
||||
* @param params.bucket - pending | processing | done
|
||||
*/
|
||||
export function listWorkspaceShippingMyTodos(params?: {
|
||||
bucket?: 'pending' | 'processing' | 'done' | string;
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
todo_category?: string;
|
||||
customer?: string;
|
||||
task_no?: string;
|
||||
}) {
|
||||
const sp = new URLSearchParams();
|
||||
if (params?.bucket) sp.set('bucket', params.bucket);
|
||||
if (params?.page) sp.set('page', String(params.page));
|
||||
if (params?.page_size) sp.set('page_size', String(params.page_size));
|
||||
if (params?.todo_category) sp.set('todo_category', params.todo_category);
|
||||
if (params?.customer) sp.set('customer', params.customer);
|
||||
if (params?.task_no) sp.set('task_no', params.task_no);
|
||||
const q = sp.toString();
|
||||
return requestJson<ShippingMyTodosPage>(
|
||||
`/api/workspace/shipping-tasks/my-todos${q ? `?${q}` : ''}`,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取待办徽标计数。
|
||||
*/
|
||||
export function countWorkspaceShippingMyTodos() {
|
||||
return requestJson<ShippingMyTodosCount>('/api/workspace/shipping-tasks/my-todos/count');
|
||||
}
|
||||
|
||||
export {
|
||||
downloadWorkspaceShippingExcelFile,
|
||||
markWorkspaceShippingManualUploaded,
|
||||
submitWorkspaceShippingDecision,
|
||||
workspaceShippingExportUrl,
|
||||
};
|
||||
@@ -3,14 +3,15 @@
|
||||
* features/workspace/components/WorkspaceSidebar.vue
|
||||
* 工作台左侧导航:业务一级/二级目录、返回聊天与退出登录。
|
||||
*/
|
||||
import { computed, inject, ref, watch } from 'vue';
|
||||
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import {
|
||||
LayoutGrid, Bot, FileText, User, LogOut, Edit, Megaphone, Clock, Package, PanelLeftClose, PanelLeftOpen,
|
||||
ChevronDown, ChevronRight, ContactRound, ListChecks,
|
||||
ChevronDown, ChevronRight, ContactRound, ListChecks, Inbox,
|
||||
} from 'lucide-vue-next';
|
||||
import { WORKSPACE_PATHS } from '../constants/routes';
|
||||
import { WORKSPACE_KEY } from '../composables/workspace.context';
|
||||
import { useShippingTodoBadge } from '../composables/useShippingTodoBadge';
|
||||
|
||||
const props = defineProps<{
|
||||
collapsed?: boolean;
|
||||
@@ -18,9 +19,10 @@ const props = defineProps<{
|
||||
|
||||
const ws = inject(WORKSPACE_KEY)! as any;
|
||||
const route = useRoute();
|
||||
const shippingRouteNames = ['workspace-shipping-customers', 'workspace-shipping-tasks'] as const;
|
||||
const shippingRouteNames = ['workspace-shipping-customers', 'workspace-shipping-tasks', 'workspace-shipping-my-tasks'] as const;
|
||||
const shippingExpanded = ref(false);
|
||||
const isAdmin = computed(() => String(ws.currentUser?.role || '').trim().toLowerCase() === 'admin');
|
||||
const { pendingBadge, startShippingTodoBadgePolling, stopShippingTodoBadgePolling } = useShippingTodoBadge();
|
||||
|
||||
const primaryLinkItems = [
|
||||
{ path: WORKSPACE_PATHS.profile, labelKey: 'workspace.nav.profile', icon: User, match: ['workspace-profile'] },
|
||||
@@ -48,14 +50,22 @@ watch(
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
/** 展开或收起货代发货目录;侧栏折叠时图标直接进入发货任务。 */
|
||||
/** 展开或收起货代发货目录;侧栏折叠时图标直接进入我的待办。 */
|
||||
const toggleShippingMenu = (): void => {
|
||||
if (props.collapsed) {
|
||||
void ws.router.push(WORKSPACE_PATHS.shippingNoticeTasks);
|
||||
void ws.router.push(WORKSPACE_PATHS.shippingNoticeMyTasks);
|
||||
return;
|
||||
}
|
||||
shippingExpanded.value = !shippingExpanded.value;
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
startShippingTodoBadgePolling();
|
||||
});
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopShippingTodoBadgePolling();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -130,6 +140,20 @@ const toggleShippingMenu = (): void => {
|
||||
<component v-if="!collapsed" :is="shippingExpanded ? ChevronDown : ChevronRight" class="h-4 w-4" />
|
||||
</button>
|
||||
<div v-if="!collapsed && shippingExpanded" class="mt-1 space-y-1 pl-5">
|
||||
<RouterLink
|
||||
:to="WORKSPACE_PATHS.shippingNoticeMyTasks"
|
||||
class="ws-nav-btn py-2.5 text-[13px]"
|
||||
:class="{ 'ws-nav-btn--active': isActive(['workspace-shipping-my-tasks']) }"
|
||||
>
|
||||
<Inbox class="h-4 w-4" />
|
||||
<span class="flex-1">{{ $t('workspace.nav.shippingMyTasks') }}</span>
|
||||
<span
|
||||
v-if="pendingBadge > 0"
|
||||
class="inline-flex min-w-[1.25rem] items-center justify-center rounded-full bg-rose-500 px-1.5 text-[10px] font-semibold text-white"
|
||||
>
|
||||
{{ pendingBadge > 99 ? '99+' : pendingBadge }}
|
||||
</span>
|
||||
</RouterLink>
|
||||
<RouterLink
|
||||
v-if="isAdmin"
|
||||
:to="WORKSPACE_PATHS.shippingNoticeCustomers"
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
|
||||
* features/workspace/composables/useShippingTodoBadge.ts
|
||||
|
||||
* 用途:工作台导航「我的待办」徽标计数(TTL 缓存 + 可选轮询)。
|
||||
|
||||
* 依赖:shipping-tasks.api.countWorkspaceShippingMyTodos。
|
||||
|
||||
* 逻辑:WorkspaceSidebar 挂载时拉取并启动轮询;15s 内复用缓存,避免频繁请求。
|
||||
|
||||
*/
|
||||
|
||||
import { ref } from 'vue';
|
||||
|
||||
import { countWorkspaceShippingMyTodos } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
|
||||
|
||||
const BADGE_CACHE_TTL_MS = 15_000;
|
||||
|
||||
const DEFAULT_POLL_INTERVAL_MS = 15_000;
|
||||
|
||||
const pendingBadge = ref(0);
|
||||
|
||||
let lastFetchedAt = 0;
|
||||
|
||||
let inFlight: Promise<void> | null = null;
|
||||
|
||||
let pollTimer: ReturnType<typeof setInterval> | null = null;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 刷新待办徽标;命中 TTL 时跳过网络请求。
|
||||
|
||||
* @param force - 为 true 时忽略 TTL 强制拉取
|
||||
|
||||
* @returns 当前徽标数字
|
||||
|
||||
*/
|
||||
|
||||
export async function refreshShippingTodoBadge(force = false): Promise<number> {
|
||||
|
||||
const now = Date.now();
|
||||
|
||||
if (!force && now - lastFetchedAt < BADGE_CACHE_TTL_MS && lastFetchedAt > 0) {
|
||||
|
||||
return pendingBadge.value;
|
||||
|
||||
}
|
||||
|
||||
if (inFlight) {
|
||||
|
||||
await inFlight;
|
||||
|
||||
return pendingBadge.value;
|
||||
|
||||
}
|
||||
|
||||
inFlight = (async () => {
|
||||
|
||||
try {
|
||||
|
||||
const res = await countWorkspaceShippingMyTodos();
|
||||
|
||||
pendingBadge.value = Number(res.total_pending_badge || res.pending || 0);
|
||||
|
||||
lastFetchedAt = Date.now();
|
||||
|
||||
} catch {
|
||||
|
||||
/* 徽标失败不阻断导航 */
|
||||
|
||||
} finally {
|
||||
|
||||
inFlight = null;
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
await inFlight;
|
||||
|
||||
return pendingBadge.value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 启动徽标轮询;每次 tick 强制刷新,便于跨会话待办变化及时反映。
|
||||
|
||||
* @param intervalMs - 轮询间隔,默认 15s
|
||||
|
||||
*/
|
||||
|
||||
export function startShippingTodoBadgePolling(intervalMs = DEFAULT_POLL_INTERVAL_MS): void {
|
||||
|
||||
stopShippingTodoBadgePolling();
|
||||
|
||||
void refreshShippingTodoBadge(true);
|
||||
|
||||
pollTimer = setInterval(() => {
|
||||
|
||||
void refreshShippingTodoBadge(true);
|
||||
|
||||
}, intervalMs);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 停止徽标轮询;侧栏卸载时调用,避免泄漏定时器。
|
||||
|
||||
*/
|
||||
|
||||
export function stopShippingTodoBadgePolling(): void {
|
||||
|
||||
if (pollTimer !== null) {
|
||||
|
||||
clearInterval(pollTimer);
|
||||
|
||||
pollTimer = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 暴露响应式徽标数字与刷新/轮询控制。
|
||||
|
||||
*/
|
||||
|
||||
export function useShippingTodoBadge() {
|
||||
|
||||
return {
|
||||
|
||||
pendingBadge,
|
||||
|
||||
refreshShippingTodoBadge,
|
||||
|
||||
startShippingTodoBadgePolling,
|
||||
|
||||
stopShippingTodoBadgePolling,
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ const ROUTE_NAME_TO_SIDEBAR: Record<string, WorkspaceSidebarItem> = {
|
||||
'workspace-schedule-runs': 'schedule_runs',
|
||||
'workspace-shipping-customers': 'shipping_notice',
|
||||
'workspace-shipping-tasks': 'shipping_notice',
|
||||
'workspace-shipping-my-tasks': 'shipping_notice',
|
||||
'workspace-feedback': 'feedback',
|
||||
'workspace-history': 'history',
|
||||
};
|
||||
|
||||
@@ -9,9 +9,10 @@ export const WORKSPACE_PATHS = {
|
||||
updates: '/workspace/updates',
|
||||
knowledgeBase: '/workspace/knowledge-base',
|
||||
scheduleRuns: '/workspace/schedule-runs',
|
||||
shippingNotice: '/workspace/shipping-notice/tasks',
|
||||
shippingNotice: '/workspace/shipping-notice/my-tasks',
|
||||
shippingNoticeCustomers: '/workspace/shipping-notice/customers',
|
||||
shippingNoticeTasks: '/workspace/shipping-notice/tasks',
|
||||
shippingNoticeMyTasks: '/workspace/shipping-notice/my-tasks',
|
||||
feedback: '/workspace/feedback',
|
||||
history: '/workspace/history',
|
||||
} as const;
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
* features/workspace/pages/ShippingMyTasksPage.vue
|
||||
* 「我的待办」嵌入页,挂载 ShippingTaskCenterPage。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import ShippingTaskCenterPage from '../shipping-task-center/ShippingTaskCenterPage.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ShippingTaskCenterPage />
|
||||
</template>
|
||||
@@ -1,11 +1,11 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/pages/ShippingNoticePage.vue
|
||||
* 货代发货通知嵌入页,复用 ShippingNoticeView 的 embedded 模式。
|
||||
* 货代发货任务处理工作台嵌入页,复用 ShippingTaskCenterPage。
|
||||
*/
|
||||
import ShippingNoticeView from '../views/ShippingNoticeView.vue';
|
||||
<script setup lang="ts">
|
||||
import ShippingTaskCenterPage from '../shipping-task-center/ShippingTaskCenterPage.vue';
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<ShippingNoticeView :embedded="true" />
|
||||
<ShippingTaskCenterPage />
|
||||
</template>
|
||||
@@ -0,0 +1,128 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/InventorySourceSelectDialog.vue
|
||||
* 用途:确认库存查询来源——展示 resolution 候选列表或手动输入 source_code。
|
||||
* 依赖:ShippingInventorySourceCandidate、vue-i18n。
|
||||
* 逻辑:由 TaskTodoPanel 在 confirm_inventory_source 动作时打开;emit confirm(sourceCode)。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import type { ShippingInventorySourceCandidate } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
candidates?: ShippingInventorySourceCandidate[] | null;
|
||||
initialCode?: string;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:open': [boolean];
|
||||
confirm: [sourceCode: string];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const selectedCode = ref('');
|
||||
const manualCode = ref('');
|
||||
const useManual = ref(false);
|
||||
|
||||
const candidateList = computed(() =>
|
||||
Array.isArray(props.candidates) ? props.candidates.filter((item) => item?.source_code) : [],
|
||||
);
|
||||
const hasCandidates = computed(() => candidateList.value.length > 0);
|
||||
|
||||
/**
|
||||
* 关闭对话框并重置本地选择状态。
|
||||
*/
|
||||
function close() {
|
||||
emit('update:open', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交选中的库存源编码;候选模式取 radio,否则取手动输入。
|
||||
*/
|
||||
function submit() {
|
||||
const code = useManual.value || !hasCandidates.value
|
||||
? manualCode.value.trim().toUpperCase()
|
||||
: selectedCode.value.trim().toUpperCase();
|
||||
if (!code) return;
|
||||
emit('confirm', code);
|
||||
close();
|
||||
}
|
||||
|
||||
/** 每次打开时初始化选择与输入模式。 */
|
||||
watch(() => props.open, (open) => {
|
||||
if (!open) return;
|
||||
selectedCode.value = '';
|
||||
manualCode.value = String(props.initialCode || '').trim().toUpperCase();
|
||||
useManual.value = !hasCandidates.value;
|
||||
if (candidateList.value.length === 1) {
|
||||
selectedCode.value = candidateList.value[0]!.source_code;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="admin-modal-overlay animate-fade-in items-center z-[170]"
|
||||
@click.self="close"
|
||||
>
|
||||
<div class="admin-modal-panel max-w-xl max-h-[90vh] scale-100">
|
||||
<div class="px-6 py-5 border-b border-subtle">
|
||||
<h3 class="section-title">{{ t('workspace.shippingNotice.inventorySourceDialog.title') }}</h3>
|
||||
<p class="section-desc mt-1">{{ t('workspace.shippingNotice.inventorySourceDialog.hint') }}</p>
|
||||
</div>
|
||||
<div class="px-6 py-5 space-y-4 overflow-y-auto">
|
||||
<div v-if="hasCandidates && !useManual" class="space-y-2 max-h-80 overflow-y-auto">
|
||||
<label
|
||||
v-for="candidate in candidateList"
|
||||
:key="candidate.source_code"
|
||||
class="flex items-start gap-3 rounded-xl border border-default p-3 cursor-pointer hover:border-brand-300"
|
||||
>
|
||||
<input v-model="selectedCode" type="radio" :value="candidate.source_code" class="mt-1" />
|
||||
<span class="flex-1 min-w-0">
|
||||
<span class="font-mono text-sm font-semibold text-primary">{{ candidate.source_code }}</span>
|
||||
<span v-if="candidate.display_name" class="ml-2 text-sm text-secondary">{{ candidate.display_name }}</span>
|
||||
<span
|
||||
v-if="candidate.warehouse_id"
|
||||
class="mt-0.5 block text-xs text-muted"
|
||||
>
|
||||
{{ t('workspace.shippingNotice.inventorySource.warehouseId') }}: {{ candidate.warehouse_id }}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="hasCandidates" class="flex items-center gap-2">
|
||||
<input
|
||||
id="inventory-source-manual-toggle"
|
||||
v-model="useManual"
|
||||
type="checkbox"
|
||||
class="rounded border-default"
|
||||
/>
|
||||
<label for="inventory-source-manual-toggle" class="text-sm text-secondary cursor-pointer">
|
||||
{{ t('workspace.shippingNotice.inventorySourceDialog.manualEntry') }}
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="useManual || !hasCandidates">
|
||||
<input
|
||||
v-model="manualCode"
|
||||
class="input-field text-sm w-full font-mono uppercase"
|
||||
:placeholder="t('workspace.shippingNotice.actions.inventorySourcePrompt')"
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="admin-modal-footer">
|
||||
<button type="button" class="btn-ghost" @click="close">{{ t('common.cancel') }}</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-primary"
|
||||
:disabled="!(useManual || !hasCandidates ? manualCode.trim() : selectedCode.trim())"
|
||||
@click="submit"
|
||||
>
|
||||
{{ t('workspace.shippingNotice.inventorySourceDialog.confirm') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,136 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ManualUploadEvidenceDialog.vue
|
||||
* 用途:人工上传凭据对话框;截图/PDF 证据必填,回执号可选。
|
||||
* 依赖:uploadFileAsset、workspace shipping-tasks.api。
|
||||
* 逻辑:由 TaskTodoPanel 在 mark_manual_uploaded 动作时打开;禁止触发 RPA 上传。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { uploadFileAsset } from '@/shared/api/file-assets.api';
|
||||
import { markWorkspaceShippingManualUploaded } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
const props = defineProps<{
|
||||
open: boolean;
|
||||
taskNo: string;
|
||||
artifactId?: number | null;
|
||||
disabled?: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:open': [boolean];
|
||||
success: [];
|
||||
}>();
|
||||
|
||||
const { t } = useI18n();
|
||||
const busy = ref(false);
|
||||
const error = ref('');
|
||||
const evidenceFile = ref<File | null>(null);
|
||||
const freightRefNo = ref('');
|
||||
|
||||
/**
|
||||
* 关闭对话框并清空本地表单。
|
||||
*/
|
||||
function close() {
|
||||
if (busy.value) return;
|
||||
evidenceFile.value = null;
|
||||
freightRefNo.value = '';
|
||||
error.value = '';
|
||||
emit('update:open', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 选择证据文件(截图或 PDF)。
|
||||
*/
|
||||
function onFileChange(event: Event) {
|
||||
const input = event.target as HTMLInputElement;
|
||||
evidenceFile.value = input.files?.[0] || null;
|
||||
error.value = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传证据资产并登记人工上传完成。
|
||||
*/
|
||||
async function submit() {
|
||||
if (props.disabled || busy.value) return;
|
||||
if (!evidenceFile.value) {
|
||||
error.value = t('workspace.shippingNotice.manualUpload.evidenceRequired');
|
||||
return;
|
||||
}
|
||||
busy.value = true;
|
||||
error.value = '';
|
||||
try {
|
||||
const asset = await uploadFileAsset(evidenceFile.value);
|
||||
await markWorkspaceShippingManualUploaded(props.taskNo, {
|
||||
evidence_asset_no: asset.asset_no,
|
||||
...(props.artifactId ? { artifact_id: props.artifactId } : {}),
|
||||
...(freightRefNo.value.trim() ? { freight_ref_no: freightRefNo.value.trim() } : {}),
|
||||
});
|
||||
emit('success');
|
||||
close();
|
||||
} catch (e: unknown) {
|
||||
error.value = e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed');
|
||||
} finally {
|
||||
busy.value = false;
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div
|
||||
v-if="open"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4"
|
||||
@click.self="close"
|
||||
>
|
||||
<div class="w-full max-w-md rounded-2xl border border-default bg-surface p-5 shadow-xl">
|
||||
<h3 class="text-base font-semibold text-primary">
|
||||
{{ $t('workspace.shippingNotice.manualUpload.title') }}
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.manualUpload.hint') }}
|
||||
</p>
|
||||
|
||||
<label class="mt-4 block text-xs font-medium text-muted">
|
||||
{{ $t('workspace.shippingNotice.manualUpload.evidenceLabel') }}
|
||||
<input
|
||||
type="file"
|
||||
accept="image/*,application/pdf"
|
||||
class="mt-1 block w-full text-sm"
|
||||
:disabled="busy || disabled"
|
||||
@change="onFileChange"
|
||||
>
|
||||
</label>
|
||||
|
||||
<label class="mt-3 block text-xs font-medium text-muted">
|
||||
{{ $t('workspace.shippingNotice.manualUpload.freightRefOptional') }}
|
||||
<input
|
||||
v-model="freightRefNo"
|
||||
type="text"
|
||||
class="mt-1 w-full rounded-xl border border-default bg-surface px-3 py-2 text-sm"
|
||||
:disabled="busy || disabled"
|
||||
>
|
||||
</label>
|
||||
|
||||
<p v-if="error" class="mt-3 text-sm text-rose-600">{{ error }}</p>
|
||||
|
||||
<div class="mt-5 flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-3 py-1.5 text-sm"
|
||||
:disabled="busy"
|
||||
@click="close"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.manualUpload.cancel') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="busy || disabled || !evidenceFile"
|
||||
@click="submit"
|
||||
>
|
||||
{{ busy ? $t('workspace.shippingNotice.manualUpload.submitting') : $t('workspace.shippingNotice.manualUpload.submit') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,484 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskCenterPage.vue
|
||||
* 用途:发货「我的待办」壳——Pending|Processing|Done + 右侧任务工作台或复核深链。
|
||||
* 依赖:shipping-tasks.api(my-todos)、shipping.api 详情、ShippingTaskWorkbench、useShippingTodoBadge。
|
||||
* 逻辑:review_case 项用 review_run_no 打开人工复核;task 项打开任务处理工作台。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { ExternalLink, RefreshCw } from 'lucide-vue-next';
|
||||
import {
|
||||
getWorkspaceShippingTask,
|
||||
listShippingChatAgents,
|
||||
SHIPPING_NOTICE_AGENT_CODE,
|
||||
type ShippingTaskDetail,
|
||||
type ShippingTaskSummary,
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
import {
|
||||
countWorkspaceShippingMyTodos,
|
||||
listWorkspaceShippingMyTodos,
|
||||
type ShippingMyTodosCount,
|
||||
} from '@/features/workspace/api/shipping-tasks.api';
|
||||
import { useShippingTodoBadge } from '../composables/useShippingTodoBadge';
|
||||
import ShippingTaskWorkbench from './ShippingTaskWorkbench.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const { refreshShippingTodoBadge } = useShippingTodoBadge();
|
||||
|
||||
const bucket = ref<'pending' | 'processing' | 'done'>('pending');
|
||||
const filterTodoCategory = ref<'all' | 'review' | 'exception' | 'manual_upload'>('all');
|
||||
const filterCustomer = ref('');
|
||||
const filterTaskNo = ref('');
|
||||
const appliedFilters = ref({
|
||||
todo_category: '',
|
||||
customer: '',
|
||||
task_no: '',
|
||||
});
|
||||
const loading = ref(false);
|
||||
const detailLoading = ref(false);
|
||||
const tasks = ref<ShippingTaskSummary[]>([]);
|
||||
const selectedRef = ref<string | null>(null);
|
||||
const detail = ref<ShippingTaskDetail | null>(null);
|
||||
const currentPage = ref(1);
|
||||
const pageSize = 20;
|
||||
const totalTasks = ref(0);
|
||||
const bucketCounts = ref<ShippingMyTodosCount>({
|
||||
pending: 0,
|
||||
processing: 0,
|
||||
done: 0,
|
||||
total_pending_badge: 0,
|
||||
});
|
||||
const chatAgentId = ref<number | null>(null);
|
||||
|
||||
const totalPages = computed(() => Math.max(1, Math.ceil(totalTasks.value / pageSize)));
|
||||
const canHandle = computed(() => detail.value?.can_handle !== false);
|
||||
const preferredTaskNo = computed(() =>
|
||||
String(route.params.taskNo || route.query.task_no || '').trim().toUpperCase(),
|
||||
);
|
||||
const preferredReviewRun = computed(() => String(route.query.run_no || '').trim());
|
||||
|
||||
const selectedItem = computed(() =>
|
||||
tasks.value.find((item) => todoItemKey(item) === selectedRef.value) || null,
|
||||
);
|
||||
const isReviewSelection = computed(() => selectedItem.value?.item_kind === 'review_case'
|
||||
|| Boolean(selectedItem.value?.review_run_no && !selectedItem.value?.task_no));
|
||||
|
||||
/**
|
||||
* 待办列表项稳定主键:复核用 case_no,任务用 task_no。
|
||||
*/
|
||||
function todoItemKey(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.todo_ref || item.review_case_no || item.review_run_no || '');
|
||||
}
|
||||
return String(item.todo_ref || item.task_no || '');
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表展示编号:复核显示 case_no,任务显示 SN。
|
||||
*/
|
||||
function todoDisplayNo(item: ShippingTaskSummary): string {
|
||||
if (item.item_kind === 'review_case' || item.review_case_no) {
|
||||
return String(item.review_case_no || item.review_run_no || item.todo_ref || '—');
|
||||
}
|
||||
return String(item.task_no || item.todo_ref || '—');
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析货代 Chat Agent,供复核/会话深链。
|
||||
*/
|
||||
async function resolveChatAgent() {
|
||||
try {
|
||||
const agents = await listShippingChatAgents();
|
||||
const found = agents.find((a) => String(a.agent_code || '').trim() === SHIPPING_NOTICE_AGENT_CODE);
|
||||
if (found) chatAgentId.value = found.id;
|
||||
} catch {
|
||||
/* ignore */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新各 bucket 计数与导航徽标。
|
||||
*/
|
||||
async function loadCounts() {
|
||||
try {
|
||||
bucketCounts.value = await countWorkspaceShippingMyTodos();
|
||||
await refreshShippingTodoBadge(true);
|
||||
} catch {
|
||||
/* 计数失败不阻断列表 */
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将筛选表单同步为已应用条件并重置到第 1 页。
|
||||
*/
|
||||
function applyFilters() {
|
||||
appliedFilters.value = {
|
||||
todo_category: bucket.value === 'pending' && filterTodoCategory.value !== 'all'
|
||||
? filterTodoCategory.value
|
||||
: '',
|
||||
customer: filterCustomer.value.trim(),
|
||||
task_no: filterTaskNo.value.trim().toUpperCase(),
|
||||
};
|
||||
void loadTodos(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空筛选条件并重新拉取列表。
|
||||
*/
|
||||
function resetFilters() {
|
||||
filterTodoCategory.value = 'all';
|
||||
filterCustomer.value = '';
|
||||
filterTaskNo.value = '';
|
||||
appliedFilters.value = { todo_category: '', customer: '', task_no: '' };
|
||||
void loadTodos(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 按当前 bucket 分页拉取「我的待办」;优先选中路由 task_no / run_no。
|
||||
*/
|
||||
async function loadTodos(resetPage = false) {
|
||||
if (resetPage) currentPage.value = 1;
|
||||
loading.value = true;
|
||||
try {
|
||||
const res = await listWorkspaceShippingMyTodos({
|
||||
bucket: bucket.value,
|
||||
page: currentPage.value,
|
||||
page_size: pageSize,
|
||||
...(appliedFilters.value.todo_category ? { todo_category: appliedFilters.value.todo_category } : {}),
|
||||
...(appliedFilters.value.customer ? { customer: appliedFilters.value.customer } : {}),
|
||||
...(appliedFilters.value.task_no ? { task_no: appliedFilters.value.task_no } : {}),
|
||||
});
|
||||
tasks.value = res.items || [];
|
||||
totalTasks.value = Number(res.total || 0);
|
||||
const byTask = preferredTaskNo.value
|
||||
? tasks.value.find((item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value)
|
||||
: null;
|
||||
const byRun = preferredReviewRun.value
|
||||
? tasks.value.find((item) => String(item.review_run_no || '') === preferredReviewRun.value)
|
||||
: null;
|
||||
const preferred = byTask || byRun;
|
||||
if (preferred) {
|
||||
selectedRef.value = todoItemKey(preferred);
|
||||
} else if (selectedRef.value && !tasks.value.some((item) => todoItemKey(item) === selectedRef.value)) {
|
||||
selectedRef.value = tasks.value[0] ? todoItemKey(tasks.value[0]) : null;
|
||||
} else if (!selectedRef.value && tasks.value[0]) {
|
||||
selectedRef.value = todoItemKey(tasks.value[0]);
|
||||
}
|
||||
} catch {
|
||||
tasks.value = [];
|
||||
totalTasks.value = 0;
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取任务详情;复核项不拉 Task API。
|
||||
*/
|
||||
async function loadDetail(taskNo: string) {
|
||||
detailLoading.value = true;
|
||||
try {
|
||||
detail.value = await getWorkspaceShippingTask(taskNo);
|
||||
} catch {
|
||||
detail.value = null;
|
||||
} finally {
|
||||
detailLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表与详情联动刷新。
|
||||
*/
|
||||
async function refreshAll() {
|
||||
await Promise.all([loadTodos(), loadCounts()]);
|
||||
const item = selectedItem.value;
|
||||
if (item?.task_no && item.item_kind !== 'review_case') {
|
||||
await loadDetail(item.task_no);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开人工复核工作台(Chat 主区替换为 order-review 模式)。
|
||||
*/
|
||||
function openReview(item: ShippingTaskSummary) {
|
||||
const runNo = String(item.review_run_no || '').trim();
|
||||
if (!runNo) return;
|
||||
const agentId = Number(item.owner_agent_id || chatAgentId.value || 0);
|
||||
if (!agentId) return;
|
||||
const query: Record<string, string> = {
|
||||
mode: 'order-review',
|
||||
run_no: runNo,
|
||||
};
|
||||
const cid = String(item.conversation_id || '').trim();
|
||||
if (cid) query.conversation_id = cid;
|
||||
const caseNo = String(item.review_case_no || '').trim();
|
||||
if (caseNo) query.case_no = caseNo;
|
||||
void router.push({ path: `/chat/${agentId}`, query });
|
||||
}
|
||||
|
||||
/**
|
||||
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
|
||||
*/
|
||||
function openInChat() {
|
||||
if (!chatAgentId.value || !detail.value) return;
|
||||
const query: Record<string, string> = { task_id: detail.value.task_no };
|
||||
const batchNo = String(detail.value.batch_no || '').trim();
|
||||
if (batchNo) query.batch_no = batchNo;
|
||||
const cid = String(detail.value.conversation_id || '').trim();
|
||||
if (/^[0-9a-f]{32}$/i.test(cid)) query.conversation_id = cid;
|
||||
void router.push({ path: `/chat/${chatAgentId.value}`, query });
|
||||
}
|
||||
|
||||
/**
|
||||
* 选中列表项:复核显示入口卡;任务加载工作台详情。
|
||||
*/
|
||||
async function selectTodo(item: ShippingTaskSummary) {
|
||||
selectedRef.value = todoItemKey(item);
|
||||
const nextQuery: Record<string, string> = { ...route.query as Record<string, string> };
|
||||
if (item.item_kind === 'review_case' || item.review_run_no) {
|
||||
delete nextQuery.task_no;
|
||||
if (item.review_run_no) nextQuery.run_no = String(item.review_run_no);
|
||||
detail.value = null;
|
||||
} else if (item.task_no) {
|
||||
delete nextQuery.run_no;
|
||||
nextQuery.task_no = item.task_no;
|
||||
await loadDetail(item.task_no);
|
||||
}
|
||||
void router.replace({
|
||||
name: route.name || 'workspace-shipping-my-tasks',
|
||||
params: route.params,
|
||||
query: nextQuery,
|
||||
});
|
||||
}
|
||||
|
||||
watch(bucket, () => {
|
||||
selectedRef.value = null;
|
||||
detail.value = null;
|
||||
filterTodoCategory.value = 'all';
|
||||
appliedFilters.value = {
|
||||
...appliedFilters.value,
|
||||
todo_category: '',
|
||||
};
|
||||
void loadTodos(true);
|
||||
});
|
||||
|
||||
watch(selectedItem, (item) => {
|
||||
if (!item) {
|
||||
detail.value = null;
|
||||
return;
|
||||
}
|
||||
if (item.item_kind === 'review_case' || (item.review_run_no && !item.task_no)) {
|
||||
detail.value = null;
|
||||
return;
|
||||
}
|
||||
if (item.task_no && detail.value?.task_no !== item.task_no) {
|
||||
void loadDetail(item.task_no);
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([resolveChatAgent(), loadCounts(), loadTodos()]);
|
||||
if (preferredTaskNo.value) {
|
||||
const hit = tasks.value.find((item) => String(item.task_no || '').toUpperCase() === preferredTaskNo.value);
|
||||
if (!hit) {
|
||||
selectedRef.value = preferredTaskNo.value;
|
||||
await loadDetail(preferredTaskNo.value);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-5 animate-fade-in-up">
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 class="text-2xl font-bold text-primary">{{ $t('workspace.shippingNotice.myTodos.title') }}</h2>
|
||||
<p class="text-sm text-muted">{{ $t('workspace.shippingNotice.myTodos.subtitle') }}</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft"
|
||||
@click="refreshAll"
|
||||
>
|
||||
<RefreshCw class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.refresh') }}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
v-for="key in (['pending', 'processing', 'done'] as const)"
|
||||
:key="key"
|
||||
type="button"
|
||||
class="rounded-xl px-3 py-1.5 text-sm font-medium"
|
||||
:class="bucket === key ? 'bg-brand-600 text-white' : 'border border-default text-secondary hover:bg-surface-soft'"
|
||||
@click="bucket = key"
|
||||
>
|
||||
{{ $t(`workspace.shippingNotice.myTodos.buckets.${key}`) }}
|
||||
<span class="ml-1 opacity-80">({{ bucketCounts[key] }})</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-end gap-3 rounded-2xl border border-default bg-surface px-4 py-3">
|
||||
<label v-if="bucket === 'pending'" class="space-y-1">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.todoCategory') }}</span>
|
||||
<select v-model="filterTodoCategory" class="input-field text-sm min-w-[9rem]">
|
||||
<option value="all">{{ $t('workspace.shippingNotice.myTodos.filters.all') }}</option>
|
||||
<option value="review">{{ $t('workspace.shippingNotice.myTodos.filters.review') }}</option>
|
||||
<option value="exception">{{ $t('workspace.shippingNotice.myTodos.filters.exception') }}</option>
|
||||
<option value="manual_upload">{{ $t('workspace.shippingNotice.myTodos.filters.manualUpload') }}</option>
|
||||
</select>
|
||||
</label>
|
||||
<label class="space-y-1 flex-1 min-w-[10rem]">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.customer') }}</span>
|
||||
<input
|
||||
v-model="filterCustomer"
|
||||
type="text"
|
||||
class="input-field text-sm w-full"
|
||||
:placeholder="$t('workspace.shippingNotice.myTodos.filters.customerPlaceholder')"
|
||||
@keyup.enter="applyFilters"
|
||||
/>
|
||||
</label>
|
||||
<label class="space-y-1 flex-1 min-w-[10rem]">
|
||||
<span class="text-xs font-medium text-muted">{{ $t('workspace.shippingNotice.myTodos.filters.taskNo') }}</span>
|
||||
<input
|
||||
v-model="filterTaskNo"
|
||||
type="text"
|
||||
class="input-field text-sm w-full font-mono uppercase"
|
||||
:placeholder="$t('workspace.shippingNotice.myTodos.filters.taskNoPlaceholder')"
|
||||
@keyup.enter="applyFilters"
|
||||
/>
|
||||
</label>
|
||||
<div class="flex gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="loading"
|
||||
@click="applyFilters"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.filters.apply') }}
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-xl border border-default px-3 py-1.5 text-sm font-medium text-secondary hover:bg-surface-soft disabled:opacity-50"
|
||||
:disabled="loading"
|
||||
@click="resetFilters"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.filters.reset') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 lg:grid-cols-[minmax(18rem,0.85fr)_minmax(0,2.15fr)]">
|
||||
<div class="space-y-2">
|
||||
<div v-if="loading" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!tasks.length" class="rounded-2xl border border-dashed border-default py-10 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.empty') }}
|
||||
</div>
|
||||
<button
|
||||
v-for="item in tasks"
|
||||
:key="todoItemKey(item)"
|
||||
type="button"
|
||||
class="w-full rounded-2xl border px-4 py-3 text-left transition-colors"
|
||||
:class="selectedRef === todoItemKey(item) ? 'border-brand-400 bg-brand-50/60' : 'border-default hover:bg-surface-soft/70'"
|
||||
@click="selectTodo(item)"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="font-mono text-sm font-semibold text-primary">{{ todoDisplayNo(item) }}</span>
|
||||
<span
|
||||
v-if="item.todo_category === 'review' || item.item_kind === 'review_case'"
|
||||
class="rounded-full bg-amber-50 px-2 py-0.5 text-[10px] text-amber-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</span>
|
||||
<span
|
||||
v-else-if="item.can_handle === false"
|
||||
class="rounded-full bg-slate-100 px-2 py-0.5 text-[10px] text-slate-600"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnlyShort') }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 truncate text-sm text-secondary">
|
||||
{{ item.ui_state?.summary?.current_todo || item.ui_state?.summary?.title || item.process_status }}
|
||||
</div>
|
||||
<div class="mt-1 truncate text-xs text-muted">
|
||||
{{ item.customer_name || item.source_file_name || item.review_run_no || '—' }}
|
||||
</div>
|
||||
</button>
|
||||
<div v-if="totalPages > 1" class="flex items-center justify-between gap-2 pt-2 text-xs text-muted">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
|
||||
:disabled="currentPage <= 1 || loading"
|
||||
@click="currentPage -= 1; loadTodos()"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.previous') }}
|
||||
</button>
|
||||
<span>{{ currentPage }}/{{ totalPages }}</span>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-lg border border-default px-2 py-1 disabled:opacity-50"
|
||||
:disabled="currentPage >= totalPages || loading"
|
||||
@click="currentPage += 1; loadTodos()"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.pagination.next') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div
|
||||
v-if="isReviewSelection && selectedItem"
|
||||
class="space-y-4 rounded-2xl border border-default bg-surface p-6"
|
||||
>
|
||||
<div class="font-mono text-lg font-bold text-primary">{{ todoDisplayNo(selectedItem) }}</div>
|
||||
<p class="text-sm text-secondary">
|
||||
{{ selectedItem.ui_state?.summary?.message || selectedItem.ui_state?.summary?.current_todo }}
|
||||
</p>
|
||||
<p v-if="selectedItem.source_file_name" class="text-xs text-muted">
|
||||
{{ selectedItem.source_file_name }}
|
||||
<span v-if="selectedItem.review_run_no"> · {{ selectedItem.review_run_no }}</span>
|
||||
</p>
|
||||
<button
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1.5 rounded-xl bg-brand-600 px-4 py-2 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
|
||||
:disabled="!selectedItem.review_run_no || !(selectedItem.owner_agent_id || chatAgentId)"
|
||||
@click="openReview(selectedItem)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.myTodos.openReview') }}
|
||||
</button>
|
||||
</div>
|
||||
<div v-else-if="detailLoading" class="rounded-2xl border border-dashed border-default py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.loading') }}
|
||||
</div>
|
||||
<div v-else-if="!detail" class="rounded-2xl border border-dashed border-default py-16 text-center text-sm text-muted">
|
||||
{{ $t('workspace.shippingNotice.selectCase') }}
|
||||
</div>
|
||||
<div v-else class="space-y-3">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
<div class="font-mono text-lg font-bold text-primary">{{ detail.task_no }}</div>
|
||||
<button
|
||||
v-if="chatAgentId"
|
||||
type="button"
|
||||
class="inline-flex items-center gap-1 rounded-xl border border-default px-3 py-1.5 text-xs font-medium text-secondary hover:bg-surface-soft"
|
||||
@click="openInChat"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.openChat') }}
|
||||
</button>
|
||||
</div>
|
||||
<ShippingTaskWorkbench
|
||||
:detail="detail"
|
||||
:can-handle="canHandle"
|
||||
@refreshed="refreshAll"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,102 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/ShippingTaskWorkbench.vue
|
||||
* 用途:发货任务处理主区——当前待办栏、订单概览、时间线;履约写操作入口。
|
||||
* 依赖:TaskTodoPanel、TaskProgressTimeline、ShippingTaskParsedResultCard、ShippingWorkflowStepper。
|
||||
* 逻辑:由 ShippingTaskCenterPage 选中任务后挂载;只消费后端 ui_state,不发明进度百分比。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { computed } from 'vue';
|
||||
import ShippingWorkflowStepper from '@/features/chat/components/ShippingWorkflowStepper.vue';
|
||||
import ShippingMatchResultCard from '@/features/chat/components/messages/ShippingMatchResultCard.vue';
|
||||
import ShippingTaskParsedResultCard from '@/features/chat/components/ShippingTaskParsedResultCard.vue';
|
||||
import { resolveShippingWorkflowSteps } from '@/features/chat/shipping';
|
||||
import type { ShippingTaskDetail } from '@/features/chat/types/shipping.api.types';
|
||||
import TaskTodoPanel from './TaskTodoPanel.vue';
|
||||
import TaskProgressTimeline from './TaskProgressTimeline.vue';
|
||||
|
||||
const props = defineProps<{
|
||||
detail: ShippingTaskDetail;
|
||||
canHandle: boolean;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
refreshed: [];
|
||||
}>();
|
||||
|
||||
const workflowSteps = computed(() => resolveShippingWorkflowSteps(props.detail));
|
||||
const shortageLines = computed(() => props.detail.shortage?.lines || []);
|
||||
const hasMatchCard = computed(() =>
|
||||
(Array.isArray(props.detail.line_results) && props.detail.line_results.length > 0)
|
||||
|| shortageLines.value.length > 0,
|
||||
);
|
||||
const events = computed(() => props.detail.events || []);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="space-y-4">
|
||||
<TaskTodoPanel
|
||||
:detail="detail"
|
||||
:can-handle="canHandle"
|
||||
@refreshed="emit('refreshed')"
|
||||
/>
|
||||
|
||||
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
|
||||
<div class="mb-3 text-xs font-semibold uppercase tracking-wide text-muted">
|
||||
{{ $t('workspace.shippingNotice.todo.workflow') }}
|
||||
</div>
|
||||
<ShippingWorkflowStepper :steps="workflowSteps" />
|
||||
</section>
|
||||
|
||||
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
|
||||
<h3 class="mb-3 text-sm font-semibold text-secondary">
|
||||
{{ $t('workspace.shippingNotice.todo.orderOverview') }}
|
||||
</h3>
|
||||
<dl class="grid gap-3 text-sm sm:grid-cols-2">
|
||||
<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>
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.shipTo') }}</dt>
|
||||
<dd>{{ detail.ship_to || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt>
|
||||
<dd>{{ detail.freight_ref_no || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</section>
|
||||
|
||||
<ShippingTaskParsedResultCard
|
||||
:task-no="detail.task_no"
|
||||
:po-number="String(detail.po_number || '')"
|
||||
:lines="detail.lines || []"
|
||||
:order-header="detail.order_header"
|
||||
:order-header-fields="detail.order_header_fields"
|
||||
:order-line-fields="detail.order_line_fields"
|
||||
:parse-validation="detail.step_payload?.parse_validation || detail.parse_validation"
|
||||
:process-field-gate="detail.process_field_gate"
|
||||
:source-candidate="detail.source_candidate"
|
||||
:field-conflicts="detail.field_conflicts"
|
||||
:order-data-version="detail.order_data_version"
|
||||
:default-expanded="true"
|
||||
@refreshed="emit('refreshed')"
|
||||
/>
|
||||
|
||||
<ShippingMatchResultCard
|
||||
v-if="hasMatchCard"
|
||||
:task-id="detail.task_no"
|
||||
:match-status="detail.match_status"
|
||||
:line-results="detail.line_results"
|
||||
:shortage-lines="shortageLines"
|
||||
:action-buttons="[]"
|
||||
:action-busy="false"
|
||||
/>
|
||||
|
||||
<TaskProgressTimeline :events="events" />
|
||||
</div>
|
||||
</template>
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* features/workspace/shipping-task-center/TaskProgressTimeline.vue
|
||||
* 用途:展示任务事件时间线(只读),不发明进度百分比。
|
||||
* 依赖:ShippingTaskEvent、dateTime 工具。
|
||||
* 逻辑:由 ShippingTaskWorkbench 传入 detail.events。
|
||||
*/
|
||||
<script setup lang="ts">
|
||||
import { formatLocalDateTime } from '@/shared/utils/dateTime';
|
||||
import type { ShippingTaskEvent } from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
defineProps<{
|
||||
events: ShippingTaskEvent[];
|
||||
}>();
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3 text-sm">
|
||||
<h3 class="mb-2 text-sm font-semibold text-secondary">
|
||||
{{ $t('workspace.shippingNotice.events') }}
|
||||
</h3>
|
||||
<div v-if="!events.length" class="py-4 text-center text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.timeline.empty') }}
|
||||
</div>
|
||||
<div
|
||||
v-for="(event, index) in events"
|
||||
:key="`${event.event_type}-${index}`"
|
||||
class="border-t border-default/70 py-2 first:border-t-0 first:pt-0"
|
||||
>
|
||||
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
|
||||
<span class="font-medium text-secondary">{{ event.event_type }}</span>
|
||||
<span class="text-muted">{{ formatLocalDateTime(event.created_at) }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -0,0 +1,753 @@
|
||||
/**
|
||||
|
||||
* features/workspace/shipping-task-center/TaskTodoPanel.vue
|
||||
|
||||
* 用途:仅渲染后端 ui_state.action_buttons / summary.allowed_actions 对应的当前待办动作。
|
||||
|
||||
* 依赖:shipping.api 履约写接口、shipping-tasks.api 下载/人工上传、各确认对话框。
|
||||
|
||||
* 逻辑:禁止按 process_status 二次推导按钮;管理员 can_handle=false 时只读。
|
||||
|
||||
*/
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
|
||||
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
|
||||
|
||||
import ShippingCustomerConfirmDialog from '@/features/chat/components/ShippingCustomerConfirmDialog.vue';
|
||||
|
||||
import type {
|
||||
|
||||
ShippingChatAction,
|
||||
|
||||
ShippingCustomerOption,
|
||||
|
||||
ShippingInventorySourceCandidate,
|
||||
|
||||
ShippingTaskDetail,
|
||||
|
||||
} from '@/features/chat/types/shipping.api.types';
|
||||
|
||||
import {
|
||||
|
||||
confirmWorkspaceShippingCustomer,
|
||||
|
||||
confirmWorkspaceShippingInventorySource,
|
||||
|
||||
freezeWorkspaceShippingOrder,
|
||||
|
||||
generateWorkspaceShippingExcel,
|
||||
|
||||
listWorkspaceShippingCustomerOptions,
|
||||
|
||||
matchWorkspaceShippingInventory,
|
||||
|
||||
retryWorkspaceShippingUpload,
|
||||
|
||||
submitWorkspaceShippingDecision,
|
||||
|
||||
} from '@/features/chat/api/shipping.api';
|
||||
|
||||
import { downloadWorkspaceShippingExcelFile } from '@/features/workspace/api/shipping-tasks.api';
|
||||
|
||||
import { refreshShippingTodoBadge } from '@/features/workspace/composables/useShippingTodoBadge';
|
||||
|
||||
import InventorySourceSelectDialog from './InventorySourceSelectDialog.vue';
|
||||
|
||||
import ManualUploadEvidenceDialog from './ManualUploadEvidenceDialog.vue';
|
||||
|
||||
|
||||
|
||||
const props = defineProps<{
|
||||
|
||||
detail: ShippingTaskDetail;
|
||||
|
||||
canHandle: boolean;
|
||||
|
||||
}>();
|
||||
|
||||
|
||||
|
||||
const emit = defineEmits<{
|
||||
|
||||
refreshed: [];
|
||||
|
||||
}>();
|
||||
|
||||
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const msg = useMessage();
|
||||
|
||||
const busyId = ref<string | null>(null);
|
||||
|
||||
const manualUploadOpen = ref(false);
|
||||
|
||||
|
||||
|
||||
const customerDialogOpen = ref(false);
|
||||
|
||||
const customerOptions = ref<ShippingCustomerOption[]>([]);
|
||||
|
||||
const customerLoading = ref(false);
|
||||
|
||||
|
||||
|
||||
const freezeDialogOpen = ref(false);
|
||||
|
||||
const pendingFreezeVersion = ref<number | null>(null);
|
||||
|
||||
|
||||
|
||||
const inventorySourceDialogOpen = ref(false);
|
||||
|
||||
const inventorySourceCandidates = ref<ShippingInventorySourceCandidate[]>([]);
|
||||
|
||||
const inventorySourceInitialCode = ref('');
|
||||
|
||||
|
||||
|
||||
const summary = computed(() => props.detail.ui_state?.summary || {});
|
||||
|
||||
const actionButtons = computed(() => props.detail.ui_state?.action_buttons || []);
|
||||
|
||||
const checkpointKind = computed(() => String(props.detail.ui_state?.checkpoint_kind || ''));
|
||||
|
||||
/** auto_continue 仅保留刷新;正常 STP 由后台自动推进。 */
|
||||
const AUTO_CONTINUE_ACTIONS = new Set(['refresh']);
|
||||
|
||||
/** wait_manual_upload 仅允许下载/导出/人工上传确认。 */
|
||||
const WAIT_MANUAL_UPLOAD_ACTIONS = new Set(['download_excel', 'export', 'mark_manual_uploaded', 'refresh']);
|
||||
|
||||
/** must_human 保留例外处理动作,禁止 Chat 侧履约写路径。 */
|
||||
const MUST_HUMAN_ACTIONS = new Set([
|
||||
'confirm',
|
||||
'reject',
|
||||
'reparse',
|
||||
'replace_notice_file',
|
||||
'rematch',
|
||||
'retry_rpa',
|
||||
'confirm_inventory_source',
|
||||
'retry_resolve_inventory_source',
|
||||
'confirm_customer',
|
||||
'freeze_order',
|
||||
'upload_inventory_file',
|
||||
'match_inventory',
|
||||
'refresh',
|
||||
]);
|
||||
|
||||
/**
|
||||
* 按 STP checkpoint_kind 过滤工作台动作,避免 auto_continue 误点写操作。
|
||||
*/
|
||||
function isActionAllowedForCheckpoint(actionId: string, kind: string): boolean {
|
||||
if (!kind || kind === 'complete') return actionId === 'refresh';
|
||||
if (kind === 'auto_continue') return AUTO_CONTINUE_ACTIONS.has(actionId);
|
||||
if (kind === 'wait_manual_upload') return WAIT_MANUAL_UPLOAD_ACTIONS.has(actionId);
|
||||
if (kind === 'must_human') return MUST_HUMAN_ACTIONS.has(actionId);
|
||||
return true;
|
||||
}
|
||||
|
||||
const allowedIds = computed(() => {
|
||||
|
||||
const fromSummary = summary.value.allowed_actions;
|
||||
|
||||
if (Array.isArray(fromSummary) && fromSummary.length) return new Set(fromSummary.map(String));
|
||||
|
||||
return new Set(actionButtons.value.map((item) => item.id));
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
const visibleActions = computed(() =>
|
||||
|
||||
actionButtons.value.filter((action) => {
|
||||
const id = String(action.id || '');
|
||||
return allowedIds.value.has(id) && isActionAllowedForCheckpoint(id, checkpointKind.value);
|
||||
}),
|
||||
|
||||
);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 动作成功后刷新详情并更新导航徽标。
|
||||
|
||||
*/
|
||||
|
||||
async function afterSuccess() {
|
||||
|
||||
await refreshShippingTodoBadge(true);
|
||||
|
||||
emit('refreshed');
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 从任务上下文解析唯一库存源编码;多候选或无候选时返回空字符串。
|
||||
|
||||
*/
|
||||
|
||||
function resolveSingleInventorySourceCode(action: ShippingChatAction): string {
|
||||
|
||||
const fromAction = String(action.source_code || '').trim().toUpperCase();
|
||||
|
||||
if (fromAction) return fromAction;
|
||||
|
||||
const resolution = props.detail.inventory_source_resolution;
|
||||
|
||||
const candidates = resolution && typeof resolution === 'object'
|
||||
|
||||
? (resolution as { candidates?: unknown }).candidates
|
||||
|
||||
: null;
|
||||
|
||||
if (Array.isArray(candidates) && candidates.length === 1) {
|
||||
|
||||
const only = candidates[0];
|
||||
|
||||
if (only && typeof only === 'object') {
|
||||
|
||||
return String((only as { source_code?: unknown }).source_code || '').trim().toUpperCase();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 打开库存源选择对话框;若已能唯一解析则直接提交。
|
||||
|
||||
*/
|
||||
|
||||
async function runConfirmInventorySource(action: ShippingChatAction) {
|
||||
|
||||
const directCode = resolveSingleInventorySourceCode(action);
|
||||
|
||||
if (directCode) {
|
||||
|
||||
busyId.value = 'confirm_inventory_source';
|
||||
|
||||
try {
|
||||
|
||||
await confirmWorkspaceShippingInventorySource(props.detail.task_no, directCode);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
const resolution = props.detail.inventory_source_resolution;
|
||||
|
||||
const raw = resolution && typeof resolution === 'object'
|
||||
|
||||
? (resolution as { candidates?: unknown }).candidates
|
||||
|
||||
: null;
|
||||
|
||||
inventorySourceCandidates.value = Array.isArray(raw)
|
||||
|
||||
? raw.filter((item): item is ShippingInventorySourceCandidate =>
|
||||
|
||||
Boolean(item && typeof item === 'object' && (item as ShippingInventorySourceCandidate).source_code))
|
||||
|
||||
: [];
|
||||
|
||||
inventorySourceInitialCode.value = String(action.source_code || '').trim().toUpperCase();
|
||||
|
||||
inventorySourceDialogOpen.value = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 对话框确认库存源后提交后端。
|
||||
|
||||
*/
|
||||
|
||||
async function onInventorySourceConfirm(sourceCode: string) {
|
||||
|
||||
if (!sourceCode.trim()) {
|
||||
|
||||
msg.warning(t('workspace.shippingNotice.actions.inventorySourcePrompt'));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
busyId.value = 'confirm_inventory_source';
|
||||
|
||||
try {
|
||||
|
||||
await confirmWorkspaceShippingInventorySource(props.detail.task_no, sourceCode.trim().toUpperCase());
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 打开客户确认对话框并加载启用标准客户。
|
||||
|
||||
*/
|
||||
|
||||
async function openCustomerDialog() {
|
||||
|
||||
customerDialogOpen.value = true;
|
||||
|
||||
customerLoading.value = true;
|
||||
|
||||
try {
|
||||
|
||||
customerOptions.value = await listWorkspaceShippingCustomerOptions();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
customerOptions.value = [];
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.customerNotFound'));
|
||||
|
||||
} finally {
|
||||
|
||||
customerLoading.value = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 按关键词刷新客户选项。
|
||||
|
||||
*/
|
||||
|
||||
async function searchCustomers(query: string) {
|
||||
|
||||
customerLoading.value = true;
|
||||
|
||||
try {
|
||||
|
||||
customerOptions.value = await listWorkspaceShippingCustomerOptions(query.trim());
|
||||
|
||||
if (!customerOptions.value.length) {
|
||||
|
||||
msg.warning(t('workspace.shippingNotice.actions.customerNotFound'));
|
||||
|
||||
}
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.customerNotFound'));
|
||||
|
||||
} finally {
|
||||
|
||||
customerLoading.value = false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 确认客户后刷新任务详情。
|
||||
|
||||
*/
|
||||
|
||||
async function onCustomerConfirm(customerId: number) {
|
||||
|
||||
busyId.value = 'confirm_customer';
|
||||
|
||||
try {
|
||||
|
||||
await confirmWorkspaceShippingCustomer(props.detail.task_no, customerId);
|
||||
|
||||
customerDialogOpen.value = false;
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 校验版本并打开冻结确认对话框。
|
||||
|
||||
*/
|
||||
|
||||
function openFreezeDialog() {
|
||||
|
||||
const version = Number(props.detail.order_data_version);
|
||||
|
||||
if (!Number.isInteger(version) || version < 1) {
|
||||
|
||||
msg.warning(t('workspace.shippingNotice.actions.freezeFailed'));
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
pendingFreezeVersion.value = version;
|
||||
|
||||
freezeDialogOpen.value = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 确认冻结后提交后端。
|
||||
|
||||
*/
|
||||
|
||||
async function onFreezeConfirm() {
|
||||
|
||||
const version = pendingFreezeVersion.value;
|
||||
|
||||
if (version == null) return;
|
||||
|
||||
busyId.value = 'freeze_order';
|
||||
|
||||
try {
|
||||
|
||||
await freezeWorkspaceShippingOrder(props.detail.task_no, version);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
pendingFreezeVersion.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
* 执行后端允许的动作;人工上传/客户/库存源/冻结走对话框,其余走对应工作台 API。
|
||||
|
||||
*/
|
||||
|
||||
async function runAction(action: ShippingChatAction) {
|
||||
|
||||
if (!props.canHandle || busyId.value) return;
|
||||
|
||||
const id = String(action.id || '');
|
||||
|
||||
|
||||
|
||||
if (id === 'mark_manual_uploaded') {
|
||||
|
||||
manualUploadOpen.value = true;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'refresh') {
|
||||
|
||||
emit('refreshed');
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'confirm_customer') {
|
||||
|
||||
await openCustomerDialog();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'confirm_inventory_source') {
|
||||
|
||||
await runConfirmInventorySource(action);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'freeze_order') {
|
||||
|
||||
openFreezeDialog();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
busyId.value = id;
|
||||
|
||||
try {
|
||||
|
||||
if (id === 'download_excel' || id === 'export') {
|
||||
|
||||
await downloadWorkspaceShippingExcelFile(props.detail.task_no);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'generate_excel') {
|
||||
|
||||
await generateWorkspaceShippingExcel(props.detail.task_no);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'match_inventory' || id === 'rematch') {
|
||||
|
||||
await matchWorkspaceShippingInventory(props.detail.task_no);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if (id === 'retry_upload') {
|
||||
|
||||
await retryWorkspaceShippingUpload(props.detail.task_no);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
await submitWorkspaceShippingDecision(props.detail.task_no, id);
|
||||
|
||||
await afterSuccess();
|
||||
|
||||
} catch (e: unknown) {
|
||||
|
||||
msg.warning(e instanceof Error ? e.message : t('workspace.shippingNotice.actions.failed'));
|
||||
|
||||
} finally {
|
||||
|
||||
busyId.value = null;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
<template>
|
||||
|
||||
<section class="rounded-2xl border border-brand-200/80 bg-brand-50/40 px-4 py-3">
|
||||
|
||||
<div class="mb-1 text-xs font-semibold uppercase tracking-wide text-brand-700">
|
||||
|
||||
{{ $t('workspace.shippingNotice.todo.currentTodo') }}
|
||||
|
||||
</div>
|
||||
|
||||
<h3 class="text-sm font-semibold text-primary">
|
||||
|
||||
{{ summary.current_todo || summary.title || $t('workspace.shippingNotice.todo.noActionTitle') }}
|
||||
|
||||
</h3>
|
||||
|
||||
<p class="mt-1 text-sm text-secondary">
|
||||
|
||||
{{ summary.message || $t('workspace.shippingNotice.todo.noActionMessage') }}
|
||||
|
||||
</p>
|
||||
|
||||
<p v-if="summary.pause_reason" class="mt-1 text-xs text-amber-700">
|
||||
|
||||
{{ summary.pause_reason }}
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div v-if="!canHandle" class="mt-3 text-xs text-muted">
|
||||
|
||||
{{ $t('workspace.shippingNotice.todo.adminViewOnly') }}
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div v-else-if="visibleActions.length" class="mt-3 flex flex-wrap gap-2">
|
||||
|
||||
<button
|
||||
|
||||
v-for="action in visibleActions"
|
||||
|
||||
:key="action.id"
|
||||
|
||||
type="button"
|
||||
|
||||
class="rounded-xl px-3 py-1.5 text-sm font-medium transition-colors disabled:opacity-50"
|
||||
|
||||
:class="action.variant === 'danger'
|
||||
|
||||
? 'bg-rose-600 text-white hover:bg-rose-700'
|
||||
|
||||
: action.variant === 'secondary'
|
||||
|
||||
? 'border border-default bg-surface text-secondary hover:bg-surface-soft'
|
||||
|
||||
: 'bg-brand-600 text-white hover:bg-brand-700'"
|
||||
|
||||
:disabled="busyId === action.id"
|
||||
|
||||
@click="runAction(action)"
|
||||
|
||||
>
|
||||
|
||||
{{ action.label }}
|
||||
|
||||
</button>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<ManualUploadEvidenceDialog
|
||||
|
||||
v-model:open="manualUploadOpen"
|
||||
|
||||
:task-no="detail.task_no"
|
||||
|
||||
:artifact-id="detail.export_artifacts?.[0]?.id"
|
||||
|
||||
:disabled="!canHandle"
|
||||
|
||||
@success="afterSuccess"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<ShippingCustomerConfirmDialog
|
||||
|
||||
:open="customerDialogOpen"
|
||||
|
||||
:options="customerOptions"
|
||||
|
||||
:loading="customerLoading"
|
||||
|
||||
@close="customerDialogOpen = false"
|
||||
|
||||
@search="searchCustomers"
|
||||
|
||||
@confirm="onCustomerConfirm"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<InventorySourceSelectDialog
|
||||
|
||||
v-model:open="inventorySourceDialogOpen"
|
||||
|
||||
:candidates="inventorySourceCandidates"
|
||||
|
||||
:initial-code="inventorySourceInitialCode"
|
||||
|
||||
@confirm="onInventorySourceConfirm"
|
||||
|
||||
/>
|
||||
|
||||
|
||||
|
||||
<DeleteConfirmDialog
|
||||
|
||||
v-model="freezeDialogOpen"
|
||||
|
||||
confirm-tone="primary"
|
||||
|
||||
:title="$t('workspace.shippingNotice.actions.freezeOrder')"
|
||||
|
||||
:message="$t('workspace.shippingNotice.actions.freezeConfirm')"
|
||||
|
||||
:confirm-text="$t('workspace.shippingNotice.actions.freezeOrder')"
|
||||
|
||||
:confirm-loading="busyId === 'freeze_order'"
|
||||
|
||||
@confirm="onFreezeConfirm"
|
||||
|
||||
/>
|
||||
|
||||
</section>
|
||||
|
||||
</template>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script setup lang="ts">
|
||||
/**
|
||||
* features/workspace/views/ShippingNoticeView.vue
|
||||
* 用途:货代发货任务工作台,提供任务筛选、履约审计与跳转对话入口。
|
||||
* 用途:遗留货代任务列表视图;主写入口已迁至 shipping-task-center 工作台。
|
||||
* 依赖:ShippingWorkflowStepper、ShippingMatchResultCard、ShippingTaskParsedResultCard、shipping.api。
|
||||
* 逻辑:先拉取任务列表与详情,再展示步骤、匹配结果、解析行和事件记录;所有用户写操作仅由对话界面执行。
|
||||
* 逻辑:保留只读审计浏览;履约写操作请使用 ShippingTaskCenterPage / ShippingTaskWorkbench。
|
||||
*/
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
@@ -125,9 +125,6 @@ const detailStepProgress = computed<ShippingCurrentStepProgress | null>(() => {
|
||||
const progress = (payload as Record<string, unknown>).current_step_progress;
|
||||
return progress && typeof progress === 'object' ? progress as ShippingCurrentStepProgress : null;
|
||||
});
|
||||
const detailStepHasPercent = computed(() =>
|
||||
typeof detailStepProgress.value?.progress_percent === 'number',
|
||||
);
|
||||
const detailStepMessage = computed(() =>
|
||||
sanitizeShippingRuntimeStatusText(String(detailStepProgress.value?.message || '').trim()),
|
||||
);
|
||||
@@ -153,10 +150,6 @@ const detailTodoMessage = computed(() => (
|
||||
|| detailIssues.value[0]
|
||||
|| t('workspace.shippingNotice.todo.noActionMessage')
|
||||
));
|
||||
const detailTodoActionLabel = computed(() => (
|
||||
String(detail.value?.ui_state?.action_buttons?.[0]?.label || '').trim()
|
||||
));
|
||||
const detailHasTodo = computed(() => !!detailTodoActionLabel.value);
|
||||
|
||||
const inventorySnapshotLabel = (triggerType?: string | null) => {
|
||||
const key = String(triggerType || 'on_demand');
|
||||
@@ -253,6 +246,9 @@ const resolveChatAgent = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 可选深链:打开 Chat 会话查看上下文(非履约写入口)。
|
||||
*/
|
||||
const openInChat = (taskNo: string, conversationId?: string | null, batchNo?: string | null) => {
|
||||
if (!chatAgentId.value) return;
|
||||
const query: Record<string, string> = { task_id: taskNo };
|
||||
@@ -434,23 +430,16 @@ onMounted(async () => {
|
||||
</div>
|
||||
|
||||
<section class="rounded-2xl border border-brand-200 bg-brand-50/50 p-4">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div class="min-w-0">
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-brand-700">
|
||||
{{ $t('workspace.shippingNotice.todo.label') }}
|
||||
</div>
|
||||
<h3 class="mt-1 text-base font-semibold text-primary">{{ detailTodoTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-secondary">{{ detailTodoMessage }}</p>
|
||||
<div class="min-w-0">
|
||||
<div class="text-xs font-semibold uppercase tracking-wide text-brand-700">
|
||||
{{ $t('workspace.shippingNotice.todo.currentTodo') }}
|
||||
</div>
|
||||
<button
|
||||
v-if="chatAgentId && detailHasTodo"
|
||||
type="button"
|
||||
class="inline-flex shrink-0 items-center gap-1 rounded-xl bg-brand-600 px-3 py-2 text-sm font-medium text-white hover:bg-brand-700"
|
||||
@click="openInChat(detail.task_no, detail.conversation_id, detail.batch_no)"
|
||||
>
|
||||
<ExternalLink class="h-3.5 w-3.5" />
|
||||
{{ $t('workspace.shippingNotice.todo.handleInChat', { action: detailTodoActionLabel }) }}
|
||||
</button>
|
||||
<h3 class="mt-1 text-base font-semibold text-primary">{{ detailTodoTitle }}</h3>
|
||||
<p class="mt-1 text-sm text-secondary">{{ detailTodoMessage }}</p>
|
||||
<p class="mt-2 text-xs text-muted">
|
||||
{{ $t('workspace.shippingNotice.myTodos.openTask') }}:
|
||||
{{ $t('workspace.shippingNotice.subtitle') }}
|
||||
</p>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -462,38 +451,18 @@ onMounted(async () => {
|
||||
</section>
|
||||
|
||||
<div
|
||||
v-if="detailStepProgress"
|
||||
v-if="detailStepProgress && (detailStepMessage || detailStepDetail)"
|
||||
class="rounded-2xl border border-default/80 bg-surface px-4 py-3"
|
||||
>
|
||||
<div class="flex items-center justify-between gap-3 text-xs">
|
||||
<div class="font-medium text-primary">
|
||||
{{ detailStepProgress.step_title || t('chat.shippingNoticeUi.stepDetail.title') }}
|
||||
</div>
|
||||
<div v-if="detailStepHasPercent" class="text-muted">
|
||||
{{ detailStepProgress.progress_percent }}%
|
||||
</div>
|
||||
<div class="text-xs font-medium text-primary">
|
||||
{{ detailStepProgress.step_title || t('chat.shippingNoticeUi.stepDetail.title') }}
|
||||
</div>
|
||||
<div class="mt-1 text-sm text-secondary">
|
||||
{{ detailStepMessage || t('chat.shippingNoticeUi.processing') }}
|
||||
<div v-if="detailStepMessage" class="mt-1 text-sm text-secondary">
|
||||
{{ detailStepMessage }}
|
||||
</div>
|
||||
<div v-if="detailStepDetail" class="mt-1 text-xs text-muted">
|
||||
{{ detailStepDetail }}
|
||||
</div>
|
||||
<div
|
||||
v-if="detailStepProgress.current && detailStepProgress.total"
|
||||
class="mt-1 text-xs text-muted"
|
||||
>
|
||||
{{ t('chat.shippingNoticeUi.stepDetail.counter', { current: detailStepProgress.current, total: detailStepProgress.total }) }}
|
||||
</div>
|
||||
<div
|
||||
v-if="detailStepHasPercent"
|
||||
class="mt-2 h-2 overflow-hidden rounded-full bg-slate-200"
|
||||
>
|
||||
<div
|
||||
class="h-full rounded-full bg-sky-500 transition-all"
|
||||
:style="{ width: `${detailStepProgress.progress_percent}%` }"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<section class="rounded-2xl border border-default/80 bg-surface px-4 py-3">
|
||||
|
||||
Reference in new issue
Block a user