feat(shipping-notice): 添加货代履约策略管理功能,支持策略创建、发布及版本控制,增强订单冻结和预约管理逻辑

This commit is contained in:
hugo committed 2026-07-23 12:06:34 +08:00
1 parent abd8fc1e16
commit d62f5107b2
82 files changed
+4914 -514

No files matched your search

@@ -1,8 +1,8 @@
<!--
features/admin/modules/shipping-inventory/ShippingInventoryPage.vue
用途:以统一配置工作台维护订单字段、库存接入、Excel 导出和运行审计。
依赖:admin.api、ShippingOrderSchemaPage、Vue Composition API、Vue I18n。
逻辑:按订单字段到库存路由的业务链路组织配置;订单字段复用同一页面内的 Schema 编辑器,避免形成割裂入口。
用途:以统一货代管理工作台维护订单字段、库存接入、Excel 导出和运行审计。
依赖:admin.api、ShippingOrderSchemaPage、Vue Router、Vue Composition API、Vue I18n。
逻辑:由 AdminLayout 统一业务目录选择工作区;section 深链与当前工作区双向同步。
-->
<template>
<section class="inventory-console">
@@ -21,22 +21,6 @@
</header>
<div class="console-layout">
<aside class="section-nav" aria-label="Shipping configuration sections">
<section v-for="group in tabGroups" :key="group.labelKey" class="nav-group">
<p>{{ t(group.labelKey) }}</p>
<button
v-for="tab in group.tabs"
:key="tab.key"
type="button"
:class="{ active: activeTab === tab.key || (tab.key === 'parsing' && activeTab === 'inventoryFields') }"
@click="selectTab(tab.key)"
>
<span>{{ t(tab.labelKey) }}</span>
<small v-if="tab.count !== null">{{ tab.count }}</small>
</button>
</section>
</aside>
<main class="workbench">
<div v-if="activeTab !== 'orderSchema'" class="workbench-heading">
<div>
@@ -435,8 +419,9 @@
<script setup lang="ts">
/** 加载六个库存管理工作区,并将每个工作区限制在各自的真实配置或运行数据边界内。 */
import { computed, nextTick, onMounted, reactive, ref } from 'vue';
import { computed, nextTick, onMounted, reactive, ref, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router';
import * as XLSX from 'xlsx';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import PaginationBar from '@/shared/components/PaginationBar.vue';
@@ -504,6 +489,8 @@ type InventoryFieldForm = { display_name: string; description: string; value_typ
type SourceActivation = { ready: boolean; checks: ShippingInventoryReadinessCheck[]; missing_requirements: string[] };
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const message = useMessage();
const activeTab = ref<TabKey>('orderSchema');
const selectedId = ref<number | null>(null);
@@ -639,13 +626,13 @@ const operators = [
];
const tabs = computed(() => [
{ key: 'orderSchema' as const, group: 'foundation', labelKey: 'admin.shippingInventory.orderFields', helpKey: '', count: null },
{ key: 'parsing' as const, group: 'foundation', labelKey: 'admin.shippingInventory.parsingProfiles', helpKey: 'admin.shippingInventory.parsingProfilesHelp', count: parsingProfiles.value.length },
{ key: 'templates' as const, group: 'foundation', labelKey: 'admin.shippingInventory.excelTemplates', helpKey: 'admin.shippingInventory.excelTemplatesHelp', count: excelTemplates.value.length },
{ key: 'orderSchema' as const, group: 'order', labelKey: 'admin.shippingInventory.orderFields', helpKey: '', count: null },
{ key: 'parsing' as const, group: 'inventory', labelKey: 'admin.shippingInventory.parsingProfiles', helpKey: 'admin.shippingInventory.parsingProfilesHelp', count: parsingProfiles.value.length },
{ key: 'profiles' as const, group: 'inventory', labelKey: 'admin.shippingInventory.connections', helpKey: 'admin.shippingInventory.connectionsHelp', count: profiles.value.length },
{ key: 'sources' as const, group: 'inventory', labelKey: 'admin.shippingInventory.sources', helpKey: 'admin.shippingInventory.sourcesHelp', count: sources.value.length },
{ key: 'rules' as const, group: 'inventory', labelKey: 'admin.shippingInventory.rules', helpKey: 'admin.shippingInventory.rulesHelp', count: rules.value.length },
{ key: 'mappings' as const, group: 'inventory', labelKey: 'admin.shippingInventory.externalMappings', helpKey: 'admin.shippingInventory.mappingsHelp', count: mappings.value.length },
{ key: 'rules' as const, group: 'inventory', labelKey: 'admin.shippingInventory.rules', helpKey: 'admin.shippingInventory.rulesHelp', count: rules.value.length },
{ key: 'templates' as const, group: 'inventory', labelKey: 'admin.shippingInventory.excelTemplates', helpKey: 'admin.shippingInventory.excelTemplatesHelp', count: excelTemplates.value.length },
{ key: 'snapshots' as const, group: 'audit', labelKey: 'admin.shippingInventory.snapshots', helpKey: 'admin.shippingInventory.snapshotsHelp', count: snapshots.value.length },
{ key: 'exports' as const, group: 'audit', labelKey: 'admin.shippingInventory.exports', helpKey: 'admin.shippingInventory.exportsHelp', count: exports.value.length },
]);
@@ -653,11 +640,6 @@ const snapshotColumnLabels = computed(() => [t('admin.shippingInventory.snapshot
const exportColumnLabels = computed(() => [t('admin.shippingInventory.runNo'), t('admin.shippingInventory.source'), t('admin.shippingInventory.connection'), t('admin.shippingInventory.triggerMode'), t('admin.shippingInventory.startedAt'), t('admin.shippingInventory.duration'), t('admin.shippingInventory.exportResult'), t('admin.shippingInventory.status'), t('admin.shippingInventory.actions')]);
const snapshotTableWidth = computed(() => snapshotColumnWidths.value.reduce((total, width) => total + width, 0));
const exportTableWidth = computed(() => exportColumnWidths.value.reduce((total, width) => total + width, 0));
const tabGroups = computed(() => [
{ labelKey: 'admin.shippingInventory.groupFoundation', tabs: tabs.value.filter((tab) => tab.group === 'foundation') },
{ labelKey: 'admin.shippingInventory.groupInventory', tabs: tabs.value.filter((tab) => tab.group === 'inventory') },
{ labelKey: 'admin.shippingInventory.groupAudit', tabs: tabs.value.filter((tab) => tab.group === 'audit') },
]);
const currentTab = computed(() => tabs.value.find((item) => item.key === activeTab.value) ?? tabs.value[0]!);
const currentSection = computed(() => activeTab.value === 'inventoryFields'
? { labelKey: 'admin.shippingInventory.parsingProfiles', helpKey: 'admin.shippingInventory.parsingProfilesHelp' }
@@ -801,14 +783,26 @@ async function load(): Promise<void> {
}
}
/** 切换管理对象时清空选择,避免不同对象的数据残留在编辑器中。 */
/** 切换管理对象时同步深链并清空选择,避免不同对象的数据残留在编辑器中。 */
function selectTab(tab: TabKey): void {
activeTab.value = tab;
void router.replace({ query: { ...route.query, section: tab } });
if (tab === 'snapshots') snapshotPage.value = 1;
if (tab === 'exports') exportPage.value = 1;
closeDrawer();
}
/** 接收侧栏或书签中的 section 深链,仅允许打开工作台已注册区段。 */
watch(
() => route.query.section,
(section) => {
if (typeof section === 'string' && tabs.value.some((tab) => tab.key === section)) {
activeTab.value = section as TabKey;
}
},
{ immediate: true },
);
/** 在库存映射内切换解析方案与字段目录,保持左侧业务入口不分裂。 */
function selectInventoryMappingTab(tab: 'parsing' | 'inventoryFields'): void {
activeTab.value = tab;
@@ -1465,7 +1459,7 @@ function openAuditDetail(item: Item, kind: 'snapshot' | 'export'): void { auditD
function paginate(items: Item[], page: number): Item[] { const start = (page - 1) * auditPageSize.value; return items.slice(start, start + auditPageSize.value); }
function downloadSnapshot(item: Item): void { void downloadShippingInventorySnapshot(Number(item.id), `${item.inventory_file_no || 'inventory'}.xlsx`).catch((cause) => { showError(cause, 'downloadFailed'); }); }
/** 将货代配置的操作失败交给平台统一消息弹窗,禁止跨工作区保留页面级错误。 */
/** 将货代管理操作失败交给平台统一消息弹窗,禁止跨工作区保留页面级错误。 */
function showError(cause: unknown, fallbackKey: 'loadFailed' | 'saveFailed' | 'deleteFailed' | 'downloadFailed' | 'inventoryAnalysisFailed' | 'configurationTestFailed' | 'templateLayoutReadFailed'): void {
message.error(cause instanceof Error ? cause.message : t(`admin.shippingInventory.${fallbackKey}`));
}
@@ -1495,15 +1489,7 @@ onMounted(load);
.flow-strip { align-self: center; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid #e0f2fe; border-radius: 6px; background: #f0f9ff; color: #0369a1; font-size: 12px; font-weight: 500; }
.flow-strip i { color: #7dd3fc; font-style: normal; }
.schema-prerequisite { margin: 0 0 14px; border: 1px solid #fde68a; border-radius: 6px; background: #fffbeb; padding: 10px 12px; color: #92400e; font-size: 13px; }
.console-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 22px; padding-top: 20px; }
.section-nav { display: flex; flex-direction: column; gap: 16px; }
.nav-group { display: grid; gap: 3px; }
.nav-group > p { margin: 0 10px 3px; color: #94a3b8; font-size: 11px; font-weight: 600; }
.section-nav button { display: flex; align-items: center; justify-content: space-between; border: 0; border-left: 2px solid transparent; border-radius: 4px; background: transparent; padding: 9px 10px; color: #64748b; font-size: 13px; text-align: left; cursor: pointer; }
.section-nav button:hover { background: #f8fafc; color: #334155; }
.section-nav button.active { border-left-color: #0ea5e9; background: #f0f9ff; color: #0369a1; font-weight: 600; }
.section-nav small { min-width: 20px; border-radius: 999px; background: #f1f5f9; padding: 2px 5px; color: #94a3b8; font-size: 11px; text-align: center; }
.section-nav .active small { background: #e0f2fe; color: #0284c7; }
.console-layout { padding-top: 20px; }
.workbench-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.workbench-heading h2 { margin: 0; color: #1e293b; font-size: 16px; font-weight: 600; letter-spacing: 0; }
.workbench-heading p { max-width: 660px; margin: 5px 0 0; color: #64748b; font-size: 13px; }
@@ -1602,6 +1588,6 @@ onMounted(load);
.audit-detail dl { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 0; margin: 0; padding: 18px 20px; }.audit-detail dt, .audit-detail dd { margin: 0; padding: 11px 0; border-bottom: 1px solid #edf2f7; font-size: 13px; }.audit-detail dt { color: #64748b; }.audit-detail dd { overflow-wrap: anywhere; color: #334155; }
.object-list .empty-state { grid-column: 1 / -1; display: grid; min-height: 260px; place-items: center; }
.empty-state { border: 1px dashed #c9d7e5; border-radius: 10px; background: #f9fbfd; padding: 38px 18px; color: #7b899a; font-size: 13px; text-align: center; }
@media (max-width: 980px) { .console-header { display: block; } .flow-strip { display: inline-flex; margin-top: 18px; } .console-layout { grid-template-columns: 1fr; } .section-nav { flex-direction: row; gap: 12px; overflow-x: auto; } .nav-group { display: flex; align-items: center; gap: 4px; } .nav-group > p { display: none; } .section-nav button { min-width: max-content; border-bottom: 3px solid transparent; border-left: 0; } .section-nav button.active { border-bottom-color: #16877f; border-left: 0; } .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 980px) { .console-header { display: block; } .flow-strip { display: inline-flex; margin-top: 18px; } .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card { grid-template-columns: 1fr 1fr; } .mapping-value-row { grid-template-columns: minmax(0, 1.6fr) minmax(180px, 1fr); }.readiness-audit { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .inventory-console { padding: 18px; } .editor-form, .parameter-row, .condition-row, .mapping-row, .template-mapping, .record-card, .mapping-value-row, .parsing-mapping-card, .readonly-mapping-section .parsing-mapping-card, .parsing-summary { grid-template-columns: 1fr; } .mapping-arrow { transform: rotate(90deg); }.workbench-heading { display: block; } .workbench-heading .primary-action { margin-top: 12px; }.batch-source-list { grid-template-columns: 1fr; }.batch-stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }.batch-run { grid-template-columns: 9px minmax(0, 1fr); }.batch-run-error { grid-column: 2; }.readiness-heading { display: grid; }.readiness-count { justify-self: start; }.readiness-steps li { grid-template-columns: 24px minmax(0, 1fr); }.readiness-action { grid-column: 2; justify-self: start; }.readiness-footer { justify-content: stretch; }.readiness-footer .primary-action { width: 100%; } }
</style>