保存规则库 YAML 维护改造进展
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
import { getUserRoutesByRole, type MenuItem } from './user-routes';
|
||||
import { normalizeRoutePathForPermission } from '~/utils/route-alias';
|
||||
|
||||
/**
|
||||
* 从 MenuItem 数组中提取所有路径(包括子路由)
|
||||
@@ -50,15 +51,17 @@ function isDynamicIdSegment(segment: string): boolean {
|
||||
* 检查路径是否在允许列表中
|
||||
*/
|
||||
function isPathAllowed(pathname: string, allowedPaths: string[]): boolean {
|
||||
const checkPath = normalizeRoutePathForPermission(pathname);
|
||||
|
||||
// 精确匹配
|
||||
if (allowedPaths.includes(pathname)) {
|
||||
if (allowedPaths.includes(checkPath)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 动态路由匹配
|
||||
for (const allowedPath of allowedPaths) {
|
||||
if (pathname.startsWith(allowedPath + '/')) {
|
||||
const subPath = pathname.substring(allowedPath.length + 1);
|
||||
if (checkPath.startsWith(allowedPath + '/')) {
|
||||
const subPath = checkPath.substring(allowedPath.length + 1);
|
||||
const segments = subPath.split('/');
|
||||
const firstSegment = segments[0];
|
||||
|
||||
@@ -69,7 +72,7 @@ function isPathAllowed(pathname: string, allowedPaths: string[]): boolean {
|
||||
}
|
||||
|
||||
// 根路径
|
||||
if (pathname === '/') {
|
||||
if (checkPath === '/') {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -124,7 +124,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
|
||||
{
|
||||
id: 'rules-list',
|
||||
title: '评查点列表',
|
||||
path: '/rules',
|
||||
path: '/rules/list',
|
||||
icon: 'ri-list-check-3',
|
||||
order: 2
|
||||
},
|
||||
@@ -266,7 +266,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
|
||||
{
|
||||
id: 'rules-list',
|
||||
title: '评查点列表',
|
||||
path: '/rules',
|
||||
path: '/rules/list',
|
||||
icon: 'ri-list-check-3',
|
||||
order: 2
|
||||
},
|
||||
@@ -381,7 +381,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
|
||||
{
|
||||
id: 'rules-list',
|
||||
title: '评查点列表',
|
||||
path: '/rules',
|
||||
path: '/rules/list',
|
||||
icon: 'ri-list-check-3',
|
||||
order: 2
|
||||
},
|
||||
@@ -489,7 +489,7 @@ const FALLBACK_MENU_DATA: Record<string, MenuItem[]> = {
|
||||
{
|
||||
id: 'rules-list',
|
||||
title: '评查点列表',
|
||||
path: '/rules',
|
||||
path: '/rules/list',
|
||||
icon: 'ri-list-check-3',
|
||||
order: 2
|
||||
},
|
||||
@@ -1009,4 +1009,4 @@ export function mapUserRoleToRoleKey(userRole: string): string {
|
||||
|
||||
// 如果找不到映射,返回 userRole 本身(假设后端已经返回了正确的 role_key)
|
||||
return roleMapping[userRole] || userRole || 'common';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ export interface RulesQueryParams {
|
||||
isActive?: boolean;
|
||||
keyword?: string;
|
||||
area?: string; // 地区过滤
|
||||
documentAttributeType?: string; // 子类型(原文档属性类型)
|
||||
orderBy?: string;
|
||||
orderDirection?: 'asc' | 'desc';
|
||||
userRole?: string; // 用户角色
|
||||
@@ -116,6 +117,8 @@ export interface Rule {
|
||||
priority: string;
|
||||
description: string;
|
||||
isActive: boolean;
|
||||
area?: string;
|
||||
documentAttributeType?: string;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
@@ -194,6 +197,7 @@ export async function getRulesList(params: RulesQueryParams): Promise<{data: Rul
|
||||
isActive,
|
||||
keyword,
|
||||
area,
|
||||
documentAttributeType,
|
||||
userRole,
|
||||
token
|
||||
} = params;
|
||||
@@ -238,6 +242,11 @@ export async function getRulesList(params: RulesQueryParams): Promise<{data: Rul
|
||||
queryParams.append('is_enabled', isActive.toString());
|
||||
}
|
||||
|
||||
// 添加子类型过滤(原 document_attribute_type)
|
||||
if (documentAttributeType) {
|
||||
queryParams.append('document_attribute_type', documentAttributeType);
|
||||
}
|
||||
|
||||
// 🔑 添加地区过滤
|
||||
// if (user_role === 'provincial_admin') {
|
||||
// queryParams.append('area', '省级');
|
||||
@@ -1276,4 +1285,4 @@ export async function getAttributeTypes(
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user