把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与 枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa 持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀, 上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
282 lines
11 KiB
Vue
282 lines
11 KiB
Vue
/**
|
|
* features/admin/components/AdminNav.vue
|
|
* 绠$悊鍚庡彴宸︿晶瀵艰埅锛屼娇鐢ㄥ瓙璺敱璺宠浆銆?
|
|
* 渚濊禆锛歛dmin-nav.store銆乵odules 甯搁噺銆乿ue-router銆?
|
|
* 閫昏緫锛氭姤琛?浼佸井瀛愯彍鍗曢粯璁ゆ姌鍙狅紱褰撳墠璺敱钀藉湪瀵瑰簲妯″潡鏃惰嚜鍔ㄥ睍寮€浠ヤ究鐪嬪埌婵€娲婚」銆?
|
|
*/
|
|
<script setup lang="ts">
|
|
import { computed, ref, watch } from 'vue';
|
|
import { useI18n } from 'vue-i18n';
|
|
import { useRoute, useRouter } from 'vue-router';
|
|
import {
|
|
LayoutDashboard, UserCog, Building, Bot, FileText,
|
|
Settings2, Megaphone, MessageCircleQuestion, Link2, Users, BarChart2, AppWindow,
|
|
ScrollText, ExternalLink, PackageSearch, GraduationCap, Cable, ArrowLeftRight,
|
|
} from 'lucide-vue-next';
|
|
import type { Component } from 'vue';
|
|
import { config } from '@/config';
|
|
import {
|
|
ADMIN_MODULE_METAS,
|
|
ADMIN_REPORT_TABLES,
|
|
SHIPPING_CONFIG_SUB_MODULE_METAS,
|
|
} from '../constants/modules';
|
|
import { useAdminNavStore } from '../stores/admin-nav.store';
|
|
import type { AdminModuleId } from '../types/admin.types';
|
|
|
|
const { t } = useI18n();
|
|
const route = useRoute();
|
|
const router = useRouter();
|
|
const navStore = useAdminNavStore();
|
|
|
|
const iconMap: Record<AdminModuleId, Component> = {
|
|
dashboard: LayoutDashboard,
|
|
users: UserCog,
|
|
departments: Building,
|
|
agents: Bot,
|
|
knowledge_base: FileText,
|
|
schedules: Settings2,
|
|
announcements: Megaphone,
|
|
questions: MessageCircleQuestion,
|
|
wecom: Link2,
|
|
linked_services: ExternalLink,
|
|
permissions: Users,
|
|
platform_apps: AppWindow,
|
|
procurement_contract: ScrollText,
|
|
training_config: GraduationCap,
|
|
integration_connector: Cable,
|
|
transfer_types: ArrowLeftRight,
|
|
reports: BarChart2,
|
|
freight_rpa: PackageSearch,
|
|
};
|
|
|
|
const visibleModules = computed(() =>
|
|
ADMIN_MODULE_METAS.filter((item) => config.admin.modules[item.configKey] !== false),
|
|
);
|
|
|
|
// 调拨类型(transfer_types)已移入货代管理子菜单(路由规则之下),不再作为顶级入口渲染
|
|
const standardModules = computed(() =>
|
|
visibleModules.value.filter((item) => item.id !== 'wecom' && item.id !== 'freight_rpa' && item.id !== 'transfer_types'),
|
|
);
|
|
|
|
const isModuleActive = (moduleId: AdminModuleId): boolean =>
|
|
route.meta.adminModule === moduleId;
|
|
|
|
const isReportsActive = computed(() => route.meta.adminModule === 'reports');
|
|
const isWecomActive = computed(() => route.meta.adminModule === 'wecom');
|
|
// 货代管理激活态涵盖调拨类型:进入该子页时父菜单高亮并自动展开
|
|
const isShippingActive = computed(() => (
|
|
route.meta.adminModule === 'freight_rpa' || route.meta.adminModule === 'transfer_types'
|
|
));
|
|
|
|
const shippingGroups = computed(() => [...new Set(SHIPPING_CONFIG_SUB_MODULE_METAS.map((item) => item.groupKey))]);
|
|
const shippingExpanded = ref<Record<string, boolean>>({});
|
|
|
|
// 子菜单项可见性:调拨类型沿用自身的模块 config 开关,其余跟随货代管理父开关
|
|
const visibleShippingSubMetas = computed(() =>
|
|
SHIPPING_CONFIG_SUB_MODULE_METAS.filter((item) => item.id !== 'transfer_types' || config.admin.modules.transfer_types !== false),
|
|
);
|
|
|
|
const isShippingSubActive = (sub: (typeof SHIPPING_CONFIG_SUB_MODULE_METAS)[number]): boolean => {
|
|
if (route.name !== sub.routeName) return false;
|
|
if (!sub.query) return true;
|
|
return route.query.section === sub.query.section;
|
|
};
|
|
|
|
const toggleShippingGroup = (groupKey: string): void => {
|
|
shippingExpanded.value[groupKey] = !shippingExpanded.value[groupKey];
|
|
};
|
|
|
|
const navigateShipping = (sub: (typeof SHIPPING_CONFIG_SUB_MODULE_METAS)[number]): void => {
|
|
router.push({ name: sub.routeName, query: sub.query });
|
|
};
|
|
|
|
const wecomSubRoutes = [
|
|
{ name: 'AdminWecomSettings', labelKey: 'admin.wecom.nav.settings' },
|
|
{ name: 'AdminWecomBindings', labelKey: 'admin.wecom.nav.bindings' },
|
|
{ name: 'AdminWecomAudits', labelKey: 'admin.wecom.nav.audits' },
|
|
] as const;
|
|
|
|
const navigateWecom = (routeName: string): void => {
|
|
router.push({ name: routeName });
|
|
};
|
|
|
|
const getReportTableLabel = (table: string): string => {
|
|
const i18nKey = `admin.report.tables.${table}`;
|
|
const translated = t(i18nKey);
|
|
if (translated && translated !== i18nKey) return translated;
|
|
return table.replace(/_/g, ' ').replace(/\b\w/g, (m) => m.toUpperCase());
|
|
};
|
|
|
|
const navigateModule = (routeName: string): void => {
|
|
router.push({ name: routeName });
|
|
};
|
|
|
|
const navigateReport = (table: string): void => {
|
|
router.push({ name: 'AdminReports', params: { table } });
|
|
};
|
|
|
|
/**
|
|
* 杩涘叆鎶ヨ〃/浼佸井妯″潡鏃惰嚜鍔ㄥ睍寮€瀛愯彍鍗曪紝閬垮厤褰撳墠椤靛湪鎶樺彔鐘舵€佷笅涓嶅彲瑙併€?
|
|
*/
|
|
watch(
|
|
isReportsActive,
|
|
(active) => {
|
|
if (active) navStore.reportsExpanded = true;
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
|
|
watch(
|
|
isWecomActive,
|
|
(active) => {
|
|
if (active) navStore.wecomExpanded = true;
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
|
|
watch(
|
|
isShippingActive,
|
|
(active) => {
|
|
if (!active) return;
|
|
// 进入任一货代子路由时自动展开父菜单,保证当前子页可见。
|
|
navStore.shippingMenuExpanded = true;
|
|
let matched = false;
|
|
for (const groupKey of shippingGroups.value) {
|
|
const groupHasActiveSub = SHIPPING_CONFIG_SUB_MODULE_METAS.some(
|
|
(item) => item.groupKey === groupKey && isShippingSubActive(item),
|
|
);
|
|
shippingExpanded.value[groupKey] = groupHasActiveSub;
|
|
matched = matched || groupHasActiveSub;
|
|
}
|
|
if (!matched && shippingGroups.value[0]) shippingExpanded.value[shippingGroups.value[0]] = true;
|
|
},
|
|
{ immediate: true },
|
|
);
|
|
</script>
|
|
|
|
<template>
|
|
<aside
|
|
class="surface-panel rounded-2xl shadow-sm h-fit md:sticky md:top-24 overflow-hidden shrink-0 z-10 transition-all duration-300"
|
|
:class="navStore.sidebarCollapsed ? 'w-0 md:w-20' : 'w-full md:w-64'"
|
|
>
|
|
<nav class="flex md:flex-col p-3 gap-1 overflow-x-auto md:overflow-visible no-scrollbar">
|
|
<button
|
|
v-for="item in standardModules"
|
|
:key="item.id"
|
|
type="button"
|
|
class="admin-nav-btn group"
|
|
:class="{ 'admin-nav-btn--active': isModuleActive(item.id) }"
|
|
:title="navStore.sidebarCollapsed ? t(item.labelKey) : ''"
|
|
@click="navigateModule(item.routeName)"
|
|
>
|
|
<component
|
|
:is="iconMap[item.id]"
|
|
class="w-5 h-5 transition-transform group-hover:scale-110 flex-shrink-0"
|
|
:class="isModuleActive(item.id) ? 'text-brand-600' : 'text-muted group-hover:text-secondary'"
|
|
/>
|
|
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t(item.labelKey) }}</span>
|
|
<div
|
|
v-if="isModuleActive(item.id)"
|
|
class="absolute left-0 top-1/2 -translate-y-1/2 w-1 h-6 bg-brand-600 rounded-r-full"
|
|
/>
|
|
</button>
|
|
|
|
<div v-if="config.admin.modules.wecom !== false" class="flex flex-col flex-shrink-0">
|
|
<button
|
|
type="button"
|
|
class="admin-nav-btn group justify-between"
|
|
:class="{ 'admin-nav-btn--active': isWecomActive }"
|
|
@click="navStore.wecomExpanded = !navStore.wecomExpanded"
|
|
>
|
|
<div class="flex items-center gap-3">
|
|
<Link2 class="w-5 h-5 flex-shrink-0" :class="isWecomActive ? 'text-brand-600' : 'text-muted'" />
|
|
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.wecom') }}</span>
|
|
</div>
|
|
</button>
|
|
<div
|
|
v-if="navStore.wecomExpanded && !navStore.sidebarCollapsed"
|
|
class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6"
|
|
>
|
|
<button
|
|
v-for="sub in wecomSubRoutes"
|
|
:key="sub.name"
|
|
type="button"
|
|
class="admin-nav-subitem"
|
|
:class="{ 'admin-nav-subitem--active': route.name === sub.name }"
|
|
@click="navigateWecom(sub.name)"
|
|
>
|
|
{{ t(sub.labelKey) }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="config.admin.modules.freight_rpa !== false" class="flex flex-col flex-shrink-0">
|
|
<button
|
|
type="button"
|
|
class="admin-nav-btn group justify-between"
|
|
:class="{ 'admin-nav-btn--active': isShippingActive }"
|
|
@click="navStore.shippingMenuExpanded = !navStore.shippingMenuExpanded"
|
|
>
|
|
<div class="flex items-center gap-3">
|
|
<PackageSearch class="w-5 h-5 flex-shrink-0" :class="isShippingActive ? 'text-brand-600' : 'text-muted'" />
|
|
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.shippingConfig') }}</span>
|
|
</div>
|
|
</button>
|
|
<div v-if="navStore.shippingMenuExpanded && !navStore.sidebarCollapsed" class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6">
|
|
<div v-for="groupKey in shippingGroups" :key="groupKey" class="flex flex-col">
|
|
<button
|
|
type="button"
|
|
class="admin-nav-subitem text-left font-medium"
|
|
@click="toggleShippingGroup(groupKey)"
|
|
>
|
|
{{ t(groupKey) }}
|
|
</button>
|
|
<div v-if="shippingExpanded[groupKey]" class="pl-3 space-y-1">
|
|
<button
|
|
v-for="sub in visibleShippingSubMetas.filter((item) => item.groupKey === groupKey)"
|
|
:key="sub.id"
|
|
type="button"
|
|
class="admin-nav-subitem text-left"
|
|
:class="{ 'admin-nav-subitem--active': isShippingSubActive(sub) }"
|
|
@click="navigateShipping(sub)"
|
|
>
|
|
{{ t(sub.labelKey) }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div v-if="config.admin.modules.reports !== false" class="flex flex-col flex-shrink-0">
|
|
<button
|
|
type="button"
|
|
class="admin-nav-btn group justify-between"
|
|
:class="{ 'admin-nav-btn--active': isReportsActive }"
|
|
@click="navStore.reportsExpanded = !navStore.reportsExpanded"
|
|
>
|
|
<div class="flex items-center gap-3">
|
|
<BarChart2 class="w-5 h-5 flex-shrink-0" :class="isReportsActive ? 'text-brand-600' : 'text-muted'" />
|
|
<span :class="navStore.sidebarCollapsed ? 'md:hidden' : ''">{{ t('admin.nav.reports') }}</span>
|
|
</div>
|
|
</button>
|
|
<div
|
|
v-if="navStore.reportsExpanded && !navStore.sidebarCollapsed"
|
|
class="pl-4 space-y-1 mt-1 border-l-2 border-subtle ml-6"
|
|
>
|
|
<button
|
|
v-for="table in ADMIN_REPORT_TABLES"
|
|
:key="table"
|
|
type="button"
|
|
class="admin-nav-subitem"
|
|
:class="{ 'admin-nav-subitem--active': isReportsActive && route.params.table === table }"
|
|
@click="navigateReport(table)"
|
|
>
|
|
{{ getReportTableLabel(table) }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
</aside>
|
|
</template>
|
|
|