优化菜单权限
This commit is contained in:
@@ -1016,7 +1016,7 @@ export interface MenuItem {
|
|||||||
/** 组件 */
|
/** 组件 */
|
||||||
component?: string | null;
|
component?: string | null;
|
||||||
/** 子菜单 */
|
/** 子菜单 */
|
||||||
children?: MenuItem[] | string[];
|
children?: MenuItem[];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -97,21 +97,18 @@ export const HomeSection = () => {
|
|||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log('获取用户菜单权限返回内容:', res);
|
console.log('获取用户菜单权限返回内容:', res);
|
||||||
|
|
||||||
// 检查菜单 children 中是否有 authCode === 'HisTijianPad_Btn_Tongji' 的项
|
let authCode: string[] = [];
|
||||||
const menus = res.Data?.menus || [];
|
// 存储authCode
|
||||||
|
for (const child of res.Data?.menus?.[0]?.children || []) {
|
||||||
|
if (child.authCode) {
|
||||||
|
authCode.push(child.authCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
localStorage.setItem('authCode', authCode.join(','));
|
||||||
|
|
||||||
let hasPermission = false;
|
let hasPermission = false;
|
||||||
|
|
||||||
for (const menu of menus) {
|
hasPermission = authCode.includes('HisTijianPad_Btn_Tongji');
|
||||||
if (menu.children && Array.isArray(menu.children)) {
|
|
||||||
for (const child of menu.children) {
|
|
||||||
if (typeof child === 'object' && child.authCode === 'HisTijianPad_Btn_Tongji') {
|
|
||||||
hasPermission = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (hasPermission) break;
|
|
||||||
}
|
|
||||||
|
|
||||||
setShowRevenueStats(hasPermission);
|
setShowRevenueStats(hasPermission);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import type { ExamClient, ExamModalTab } from '../data/mockData';
|
|||||||
import { EXAM_TAGS } from '../data/mockData';
|
import { EXAM_TAGS } from '../data/mockData';
|
||||||
import { ExamSection } from '../components/exam/ExamSection';
|
import { ExamSection } from '../components/exam/ExamSection';
|
||||||
import { ExamModal } from '../components/exam/ExamModal';
|
import { ExamModal } from '../components/exam/ExamModal';
|
||||||
import { getPhysicalExamCustomerList } from '../api';
|
import { getPhysicalExamCustomerList, getUserOwnedMenus } from '../api';
|
||||||
|
|
||||||
|
const APP_ID = 'b2b49e91d21446aeb14579930f732985';
|
||||||
|
|
||||||
export const ExamPage = () => {
|
export const ExamPage = () => {
|
||||||
const [searchValue, setSearchValue] = useState<string>('');
|
const [searchValue, setSearchValue] = useState<string>('');
|
||||||
@@ -16,6 +18,29 @@ export const ExamPage = () => {
|
|||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [refreshSeq, setRefreshSeq] = useState(0);
|
const [refreshSeq, setRefreshSeq] = useState(0);
|
||||||
|
|
||||||
|
// 进入页面时获取用户菜单权限
|
||||||
|
useEffect(() => {
|
||||||
|
const token = localStorage.getItem('accessToken');
|
||||||
|
if (!token) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
getUserOwnedMenus({ app_id: APP_ID })
|
||||||
|
.then((res) => {
|
||||||
|
console.log('获取用户菜单权限返回内容:', res);
|
||||||
|
let authCode: string[] = [];
|
||||||
|
// 存储authCode
|
||||||
|
for (const child of res.Data?.menus?.[0]?.children || []) {
|
||||||
|
if (child.authCode) {
|
||||||
|
authCode.push(child.authCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
localStorage.setItem('authCode', authCode.join(','));
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('获取用户菜单权限失败', err);
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
// 处理筛选标签切换(支持多选)
|
// 处理筛选标签切换(支持多选)
|
||||||
const handleFilterChange = (tag: (typeof EXAM_TAGS)[number]) => {
|
const handleFilterChange = (tag: (typeof EXAM_TAGS)[number]) => {
|
||||||
setExamFilterTags((prev) => {
|
setExamFilterTags((prev) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user