Files
nanxiisletAdmin/src/config/project.ts
2025-12-28 22:12:08 +08:00

275 lines
8.1 KiB
TypeScript

/**
* 项目配置系统 - 框架版
*
* 该文件用于配置管理后台的框架模块
* - 系统管理
* - 财务管理
* - 平台管理
*/
import type { Component } from 'vue'
import {
PayCircleOutlined,
SettingOutlined,
AppstoreOutlined
} from '@ant-design/icons-vue'
// 项目标识类型
export type ProjectId = 'framework' | 'default'
// 当前项目配置
export const CURRENT_PROJECT: ProjectId = 'framework'
// 菜单项类型
export interface MenuItem {
key: string
label: string
icon?: Component
path?: string
children?: MenuItem[]
}
// 模块类型
export type ModuleType = 'framework'
// 模块配置
export interface ModuleConfig {
id: string
name: string
type: ModuleType
icon?: Component
menus: MenuItem[]
routes: RouteConfig[]
}
// 路由配置
export interface RouteConfig {
path: string
name: string
component: string
title: string
}
// ==================== 框架模块 ====================
// 系统管理模块
export const systemModule: ModuleConfig = {
id: 'system',
name: '系统管理',
type: 'framework',
icon: SettingOutlined,
menus: [
{
key: 'system',
label: '系统管理',
children: [
{ key: 'settings', label: '系统设置', path: '/settings' },
{ key: 'dict', label: '字典管理', path: '/settings/dict' },
{ key: 'city', label: '城市管理', path: '/settings/city' },
{ key: 'approval-flow', label: '审批流程', path: '/system/approval' },
{ key: 'approval-instances', label: '审批记录', path: '/system/approval-instances' }
]
}
],
routes: [
{ path: 'settings', name: 'Settings', component: '@/views/settings/index.vue', title: '系统设置' },
{ path: 'settings/dict', name: 'Dict', component: '@/views/settings/dict/index.vue', title: '字典管理' },
{ path: 'settings/city', name: 'City', component: '@/views/settings/city/index.vue', title: '城市管理' },
{ path: 'system/approval', name: 'ApprovalFlow', component: '@/views/system/approval/index.vue', title: '审批流程' },
{ path: 'system/approval-instances', name: 'ApprovalInstances', component: '@/views/system/approval-instances/index.vue', title: '审批记录' }
]
}
// 财务管理模块
export const financeModule: ModuleConfig = {
id: 'finance',
name: '财务管理',
type: 'framework',
icon: PayCircleOutlined,
menus: [
{
key: 'finance',
label: '财务管理',
children: [
{ key: 'finance-overview', label: '财务总览', path: '/finance/overview' },
{ key: 'income', label: '收入管理', path: '/finance/income' },
{ key: 'expense', label: '支出管理', path: '/finance/expense' },
{ key: 'reimbursement', label: '报销管理', path: '/finance/reimbursement' },
{ key: 'settlement', label: '结算管理', path: '/finance/settlement' },
{ key: 'invoice', label: '发票管理', path: '/finance/invoice' },
{ key: 'finance-accounts', label: '账户管理', path: '/finance/accounts' },
{ key: 'budget', label: '预算管理', path: '/finance/budget' },
{ key: 'finance-reports', label: '财务报表', path: '/finance/reports' },
{ key: 'finance-import', label: '数据导入', path: '/finance/import' },
{ key: 'advanced-reports', label: '高级报表', path: '/finance/advanced-reports' },
]
}
],
routes: [
{ path: 'finance/overview', name: 'FinanceOverview', component: '@/views/finance/overview/index.vue', title: '财务总览' },
{ path: 'finance/income', name: 'Income', component: '@/views/finance/income/index.vue', title: '收入管理' },
{ path: 'finance/expense', name: 'Expense', component: '@/views/finance/expense/index.vue', title: '支出管理' },
{ path: 'finance/reimbursement', name: 'Reimbursement', component: '@/views/finance/reimbursement/index.vue', title: '报销管理' },
{ path: 'finance/settlement', name: 'Settlement', component: '@/views/finance/settlement/index.vue', title: '结算管理' },
{ path: 'finance/invoice', name: 'Invoice', component: '@/views/finance/invoice/index.vue', title: '发票管理' },
{ path: 'finance/accounts', name: 'FinanceAccounts', component: '@/views/finance/accounts/index.vue', title: '账户管理' },
{ path: 'finance/budget', name: 'Budget', component: '@/views/finance/budget/index.vue', title: '预算管理' },
{ path: 'finance/reports', name: 'FinanceReports', component: '@/views/finance/reports/index.vue', title: '财务报表' },
{ path: 'finance/import', name: 'FinanceImport', component: '@/views/finance/import/index.vue', title: '数据导入' },
{ path: 'finance/advanced-reports', name: 'AdvancedReports', component: '@/views/finance/advanced-reports/index.vue', title: '高级报表' },
]
}
// 平台管理模块
export const platformModule: ModuleConfig = {
id: 'platform',
name: '平台管理',
type: 'framework',
icon: AppstoreOutlined,
menus: [
{
key: 'platform',
label: '平台管理',
children: [
{ key: 'platform-projects', label: '项目管理', path: '/platform/projects' },
{ key: 'platform-menus', label: '菜单管理', path: '/platform/menus' },
{ key: 'platform-certificates', label: '证书管理', path: '/platform/certificates' }
]
}
],
routes: [
{ path: 'platform/projects', name: 'PlatformProjects', component: '@/views/platform/projects/index.vue', title: '项目管理' },
{ path: 'platform/menus', name: 'PlatformMenus', component: '@/views/platform/menus/index.vue', title: '菜单管理' },
{ path: 'platform/certificates', name: 'PlatformCertificates', component: '@/views/platform/certificates/index.vue', title: '证书管理' }
]
}
// 所有框架模块
export const frameworkModules: ModuleConfig[] = [
financeModule,
platformModule,
systemModule
]
// ==================== 项目配置 ====================
export interface ProjectConfig {
id: ProjectId
name: string
logo: string
shortName: string
description: string
modules: ModuleConfig[]
}
// 框架项目配置
export const frameworkProject: ProjectConfig = {
id: 'framework',
name: '管理后台框架',
logo: '管',
shortName: '管理',
description: '通用管理后台框架',
modules: frameworkModules
}
// 所有项目配置
export const projectConfigs: Record<ProjectId, ProjectConfig> = {
framework: frameworkProject,
default: frameworkProject
}
// ==================== 工具函数 ====================
/**
* 获取当前项目配置
*/
export function getCurrentProject(): ProjectConfig {
return projectConfigs[CURRENT_PROJECT] || projectConfigs.default
}
/**
* 获取当前项目的所有模块
*/
export function getAllModules(): ModuleConfig[] {
return frameworkModules
}
/**
* 获取当前项目的菜单配置
*/
export function getMenuConfig(): MenuItem[] {
const modules = getAllModules()
const menus: MenuItem[] = []
modules.forEach(module => {
module.menus.forEach(menu => {
if (!menu.children) {
menus.push({
...menu,
icon: module.icon
})
} else {
menus.push({
...menu,
icon: module.icon
})
}
})
})
return menus
}
/**
* 获取菜单项到路由的映射
*/
export function getMenuRouteMap(): Record<string, string> {
const modules = getAllModules()
const map: Record<string, string> = {}
modules.forEach(module => {
module.menus.forEach(menu => {
if (menu.path) {
map[menu.key] = menu.path
}
if (menu.children) {
menu.children.forEach(child => {
if (child.path) {
map[child.key] = child.path
}
})
}
})
})
return map
}
/**
* 获取所有路由配置
*/
export function getRouteConfigs(): RouteConfig[] {
const modules = getAllModules()
const routes: RouteConfig[] = []
modules.forEach(module => {
routes.push(...module.routes)
})
return routes
}
/**
* 获取业务模块菜单(框架版无业务模块)
*/
export function getBusinessMenus(): MenuItem[] {
return []
}
/**
* 获取框架模块菜单
*/
export function getFrameworkMenus(): MenuItem[] {
return getMenuConfig()
}