feat(shipping-notice): 新增库存快照管理与RPA批量导出功能
This commit is contained in:
1 parent
fc694a8f43
commit
d54f51ddc3
48 files changed
+4970
-543
No files matched your search
@@ -108,9 +108,9 @@ const rpaRuntimeBadgeClass = (task: ShippingTaskSummary | ShippingTaskDetail) =>
|
||||
*/
|
||||
const resolveWorkspaceAssistButtonClass = (kind: 'focus' | 'shortage') => {
|
||||
if (kind === 'shortage') {
|
||||
return 'inline-flex min-h-[38px] items-center justify-center gap-1.5 rounded-xl border border-amber-200 bg-amber-50/90 px-3 py-2 text-xs font-semibold text-amber-700 transition-all hover:border-amber-300 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60';
|
||||
return 'inline-flex min-h-[32px] items-center justify-center gap-1.5 rounded-lg border border-amber-200 bg-amber-50/90 px-2.5 py-1.5 text-xs font-semibold text-amber-700 transition-all hover:border-amber-300 hover:bg-amber-100 disabled:cursor-not-allowed disabled:opacity-60';
|
||||
}
|
||||
return 'inline-flex min-h-[38px] items-center justify-center gap-1.5 rounded-xl border border-slate-200 bg-slate-50/90 px-3 py-2 text-xs font-semibold text-slate-700 transition-all hover:border-brand-200 hover:bg-white hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-60';
|
||||
return 'inline-flex min-h-[32px] items-center justify-center gap-1.5 rounded-lg border border-slate-200 bg-slate-50/90 px-2.5 py-1.5 text-xs font-semibold text-slate-700 transition-all hover:border-brand-200 hover:bg-white hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-60';
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -123,12 +123,12 @@ const resolveWorkspaceAssistButtonClass = (kind: 'focus' | 'shortage') => {
|
||||
const resolveWorkspaceTaskActionClass = (action: ShippingChatAction, total: number) => {
|
||||
const spanClass = action.variant === 'primary' || total === 1 ? 'col-span-2' : 'col-span-1';
|
||||
if (action.variant === 'primary') {
|
||||
return `${spanClass} inline-flex min-h-[42px] items-center justify-center rounded-xl bg-gradient-to-r from-brand-600 to-sky-500 px-4 py-2.5 text-sm font-semibold text-white shadow-[0_10px_24px_rgba(14,116,144,0.24)] transition-all hover:-translate-y-[1px] hover:from-brand-700 hover:to-sky-600 disabled:cursor-not-allowed disabled:opacity-60`;
|
||||
return `${spanClass} inline-flex min-h-[36px] items-center justify-center rounded-lg bg-gradient-to-r from-brand-600 to-sky-500 px-3 py-1.5 text-sm font-semibold text-white shadow-sm transition-all hover:-translate-y-[1px] hover:from-brand-700 hover:to-sky-600 disabled:cursor-not-allowed disabled:opacity-60`;
|
||||
}
|
||||
if (action.variant === 'danger') {
|
||||
return `${spanClass} inline-flex min-h-[42px] items-center justify-center rounded-xl border border-rose-200 bg-rose-50 px-4 py-2.5 text-sm font-semibold text-rose-700 transition-all hover:border-rose-300 hover:bg-rose-100 disabled:cursor-not-allowed disabled:opacity-60`;
|
||||
return `${spanClass} inline-flex min-h-[36px] items-center justify-center rounded-lg border border-rose-200 bg-rose-50 px-3 py-1.5 text-sm font-semibold text-rose-700 transition-all hover:border-rose-300 hover:bg-rose-100 disabled:cursor-not-allowed disabled:opacity-60`;
|
||||
}
|
||||
return `${spanClass} inline-flex min-h-[42px] items-center justify-center rounded-xl border border-slate-200 bg-white px-4 py-2.5 text-sm font-semibold text-slate-700 shadow-sm transition-all hover:border-brand-200 hover:bg-brand-50 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-60`;
|
||||
return `${spanClass} inline-flex min-h-[36px] items-center justify-center rounded-lg border border-slate-200 bg-white px-3 py-1.5 text-sm font-semibold text-slate-700 shadow-sm transition-all hover:border-brand-200 hover:bg-brand-50 hover:text-brand-700 disabled:cursor-not-allowed disabled:opacity-60`;
|
||||
};
|
||||
|
||||
// #region debug-point A:workspace-action
|
||||
@@ -569,7 +569,7 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
{{ resolveSuggestedAction(task) }}
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="grid grid-cols-2 gap-1.5">
|
||||
<button
|
||||
v-if="hasShortageLines(task)"
|
||||
type="button"
|
||||
@@ -590,11 +590,11 @@ const handleSwitchBatch = (batchNo: string) => {
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div v-if="resolveWorkspaceActionButtons(task).length" class="mt-2 rounded-2xl border border-slate-200/80 bg-slate-50/70 p-2.5">
|
||||
<div class="mb-2 px-1 text-[11px] font-semibold uppercase tracking-[0.08em] text-slate-500">
|
||||
<div v-if="resolveWorkspaceActionButtons(task).length" class="mt-2 rounded-xl border border-slate-200/80 bg-slate-50/70 p-2">
|
||||
<div class="mb-1.5 px-1 text-[10px] font-semibold uppercase tracking-[0.08em] text-slate-500">
|
||||
{{ t('chat.shippingNoticeActionsHint') }}
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
<div class="grid grid-cols-2 gap-1.5">
|
||||
<button
|
||||
v-for="action in resolveWorkspaceActionButtons(task)"
|
||||
:key="`${task.task_no}-workspace-action-${action.id}-${action.source_code || ''}`"
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* features/chat/shipping/shippingStepper.spec.ts
|
||||
* 用途:验证发货通知七步 Stepper 的本地兜底状态映射。
|
||||
* 依赖:shippingStepper 纯函数、vitest。
|
||||
* 逻辑:后端 UI State 缺失时,前端仍需把关键人工介入态渲染为 blocked。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { buildShippingWorkflowSteps } from './shippingStepper';
|
||||
|
||||
describe('shippingStepper', () => {
|
||||
it('marks inventory step as blocked when RPA inventory is exhausted', () => {
|
||||
// 关键断言:库存 RPA 获取失败是业务阻断态,不能在步骤条里继续显示为普通 current。
|
||||
const steps = buildShippingWorkflowSteps({
|
||||
process_status: 'waiting_inventory',
|
||||
pending_human_reason: 'rpa_exhausted',
|
||||
current_step: 'step3_inventory_prepare',
|
||||
});
|
||||
|
||||
expect(steps[2]?.status).toBe('blocked');
|
||||
});
|
||||
|
||||
it('marks inventory step as blocked when inventory source is unavailable', () => {
|
||||
// 关键断言:库存触发失败需要用户上传库存或重试,同样应在第 3 步显示异常。
|
||||
const steps = buildShippingWorkflowSteps({
|
||||
process_status: 'waiting_inventory',
|
||||
pending_human_reason: 'inv_unavail',
|
||||
current_step: 'step3_inventory_prepare',
|
||||
});
|
||||
|
||||
expect(steps[2]?.status).toBe('blocked');
|
||||
});
|
||||
});
|
||||
@@ -160,6 +160,7 @@ export function buildShippingWorkflowSteps(
|
||||
|
||||
if (
|
||||
(index === 1 && (reviewStatus === 'parse_review' || pendingReason === 'low_confidence' || pendingReason === 'rsv_required'))
|
||||
|| (index === 2 && (pendingReason === 'inv_unavail' || pendingReason === 'rpa_exhausted'))
|
||||
|| (index === 3 && (reviewStatus === 'align_review' || pendingReason === 'align_review'))
|
||||
|| (index === 4 && (reviewStatus === 'shortage_review' || pendingReason === 'shortage_review' || pendingReason === 'shortage'))
|
||||
|| (index === 6 && processStatus === 'upload_failed')
|
||||
|
||||
@@ -84,12 +84,11 @@ describe('shippingText', () => {
|
||||
it('hides manual retry count in user-facing runtime copy', () => {
|
||||
// 关键断言:前台状态文案不暴露“第几次重试”,只保留当前状态本身。
|
||||
const result = sanitizeShippingConversationText(
|
||||
'已手动重新触发 RPA 库存导出(手动第 2 次)。\n任务编号:SN-002',
|
||||
'已重新触发库存获取(第 2 次)。\n任务编号:SN-002',
|
||||
true,
|
||||
);
|
||||
|
||||
expect(result).toContain('已重新触发库存获取。');
|
||||
expect(result).not.toContain('手动第 2 次');
|
||||
expect(result).not.toContain('第 2 次');
|
||||
});
|
||||
|
||||
|
||||
@@ -45,6 +45,14 @@ export function sanitizeShippingRuntimeStatusText(text: string): string {
|
||||
/已手动重新触发\s*RPA\s*库存导出\s*[((]\s*(?:手动第\s*\d+\s*次(?:尝试)?|第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?)\s*[))]\s*[。.]?/gi,
|
||||
'已重新触发库存获取。',
|
||||
)
|
||||
.replace(
|
||||
/已重新触发库存获取\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'已重新触发库存获取。',
|
||||
)
|
||||
.replace(
|
||||
/已触发库存获取\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'已触发库存获取。',
|
||||
)
|
||||
.replace(
|
||||
/已触发\s*RPA\s*库存导出\s*[((]\s*第\s*\d+(?:\s*\/\s*\d+)?\s*次(?:尝试)?\s*[))]\s*[。.]?/gi,
|
||||
'已触发库存获取。',
|
||||
|
||||
@@ -4,6 +4,21 @@
|
||||
* 依赖:无(纯类型模块)。
|
||||
* 逻辑:shipping.api.ts 与 Chat/工作台组件统一引用本文件 DTO 类型。
|
||||
*/
|
||||
export interface ShippingInventorySnapshot {
|
||||
inventory_file_no?: string | null;
|
||||
source_code?: string | null;
|
||||
warehouse_id?: string | null;
|
||||
warehouse_code?: string | null;
|
||||
exported_at?: string | null;
|
||||
expires_at?: string | null;
|
||||
snapshot_status?: string | null;
|
||||
is_fresh?: boolean;
|
||||
link_reason?: string | null;
|
||||
snapshot_age_seconds?: number | null;
|
||||
trigger_type?: string | null;
|
||||
rpa_run_no?: string | null;
|
||||
}
|
||||
|
||||
export interface ShippingTaskSummary {
|
||||
id: number;
|
||||
task_no: string;
|
||||
@@ -34,6 +49,7 @@ export interface ShippingTaskSummary {
|
||||
rpa_runtime?: ShippingRpaRuntime | null;
|
||||
rpa_inventory_source?: Record<string, unknown> | null;
|
||||
inventory_source_resolution?: Record<string, unknown> | null;
|
||||
inventory_snapshot?: ShippingInventorySnapshot | null;
|
||||
created_at?: string | null;
|
||||
updated_at?: string | null;
|
||||
ui_state?: ShippingTaskUiState;
|
||||
|
||||
@@ -131,6 +131,16 @@ const detailErrorMessage = computed(() =>
|
||||
sanitizeShippingRuntimeStatusText(String(detail.value?.error_message || '').trim()),
|
||||
);
|
||||
|
||||
const inventorySnapshotLabel = (triggerType?: string | null) => {
|
||||
const key = String(triggerType || 'on_demand');
|
||||
const map: Record<string, string> = {
|
||||
scheduled: t('workspace.shippingNotice.inventorySnapshot.sourceScheduled'),
|
||||
on_demand: t('workspace.shippingNotice.inventorySnapshot.sourceOnDemand'),
|
||||
manual_upload: t('workspace.shippingNotice.inventorySnapshot.sourceManual'),
|
||||
};
|
||||
return map[key] || map.on_demand;
|
||||
};
|
||||
|
||||
const loadCases = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
@@ -378,6 +388,39 @@ onMounted(async () => {
|
||||
<div><dt class="text-muted">{{ $t('workspace.shippingNotice.fields.freightRef') }}</dt><dd>{{ detail.freight_ref_no || '—' }}</dd></div>
|
||||
</dl>
|
||||
|
||||
<div
|
||||
v-if="detail.inventory_snapshot"
|
||||
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.inventorySnapshot.title') }}
|
||||
</h3>
|
||||
<dl class="grid gap-2 sm:grid-cols-2">
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.warehouseId') }}</dt>
|
||||
<dd class="font-mono">{{ detail.inventory_snapshot.warehouse_id || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.source') }}</dt>
|
||||
<dd>{{ inventorySnapshotLabel(detail.inventory_snapshot.trigger_type) }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.exportedAt') }}</dt>
|
||||
<dd>{{ detail.inventory_snapshot.exported_at || '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="text-xs text-muted">{{ $t('workspace.shippingNotice.inventorySnapshot.fileNo') }}</dt>
|
||||
<dd class="font-mono text-xs">{{ detail.inventory_snapshot.inventory_file_no || '—' }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div
|
||||
v-if="detail.inventory_snapshot.is_fresh === false"
|
||||
class="mt-2 text-xs text-amber-700"
|
||||
>
|
||||
{{ $t('workspace.shippingNotice.inventorySnapshot.expired') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="detailErrorMessage" class="rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-sm text-rose-700">
|
||||
{{ detailErrorMessage }}
|
||||
</div>
|
||||
|
||||
@@ -180,6 +180,17 @@
|
||||
"shipTo": "Ship to",
|
||||
"freightRef": "Freight ref no."
|
||||
},
|
||||
"inventorySnapshot": {
|
||||
"title": "Inventory snapshot",
|
||||
"warehouseId": "Warehouse ID",
|
||||
"source": "Inventory source",
|
||||
"sourceScheduled": "Scheduled export",
|
||||
"sourceOnDemand": "On-demand RPA",
|
||||
"sourceManual": "Manual upload",
|
||||
"exportedAt": "Exported at",
|
||||
"fileNo": "Snapshot ID",
|
||||
"expired": "Snapshot expired; system will re-trigger RPA or wait for manual upload"
|
||||
},
|
||||
"status": {
|
||||
"all": "All",
|
||||
"created": "Created",
|
||||
|
||||
@@ -110,6 +110,17 @@
|
||||
"shipTo": "ที่อยู่จัดส่ง",
|
||||
"freightRef": "เลขอ้างอิงขนส่ง"
|
||||
},
|
||||
"inventorySnapshot": {
|
||||
"title": "สแนปช็อตสต็อก",
|
||||
"warehouseId": "Warehouse ID",
|
||||
"source": "แหล่งสต็อก",
|
||||
"sourceScheduled": "ส่งออกตามกำหนด",
|
||||
"sourceOnDemand": "RPA ตามต้องการ",
|
||||
"sourceManual": "อัปโหลดด้วยตนเอง",
|
||||
"exportedAt": "เวลาส่งออก",
|
||||
"fileNo": "รหัสสแนปช็อต",
|
||||
"expired": "สแนปช็อตหมดอายุ ระบบจะเรียก RPA ใหม่หรือรอการอัปโหลดด้วยตนเอง"
|
||||
},
|
||||
"status": {
|
||||
"all": "ทั้งหมด",
|
||||
"created": "สร้างแล้ว",
|
||||
|
||||
@@ -181,6 +181,17 @@
|
||||
"shipTo": "收货地址",
|
||||
"freightRef": "货代单号"
|
||||
},
|
||||
"inventorySnapshot": {
|
||||
"title": "库存快照",
|
||||
"warehouseId": "Warehouse ID",
|
||||
"source": "库存来源",
|
||||
"sourceScheduled": "定时导出",
|
||||
"sourceOnDemand": "按需 RPA",
|
||||
"sourceManual": "手动上传",
|
||||
"exportedAt": "导出时间",
|
||||
"fileNo": "快照编号",
|
||||
"expired": "快照已过期,系统将重新触发 RPA 或等待人工上传"
|
||||
},
|
||||
"status": {
|
||||
"all": "全部",
|
||||
"created": "已创建",
|
||||
|
||||
@@ -180,6 +180,17 @@
|
||||
"shipTo": "收貨地址",
|
||||
"freightRef": "貨代單號"
|
||||
},
|
||||
"inventorySnapshot": {
|
||||
"title": "庫存快照",
|
||||
"warehouseId": "Warehouse ID",
|
||||
"source": "庫存來源",
|
||||
"sourceScheduled": "定時匯出",
|
||||
"sourceOnDemand": "按需 RPA",
|
||||
"sourceManual": "手動上傳",
|
||||
"exportedAt": "匯出時間",
|
||||
"fileNo": "快照編號",
|
||||
"expired": "快照已過期,系統將重新觸發 RPA 或等待人工上傳"
|
||||
},
|
||||
"status": {
|
||||
"all": "全部",
|
||||
"created": "已建立",
|
||||
|
||||
Reference in new issue
Block a user