Browse Source

(*)顶部菜单初始加载修改

master
zmh 1 year ago
parent
commit
1036bd2cc2
  1. 48
      web/client/src/layout/components/header/contant.js
  2. 13
      web/client/src/layout/components/header/index.jsx

48
web/client/src/layout/components/header/contant.js

@ -1,13 +1,16 @@
import { isAuthorized } from '$utils' import { isAuthorized } from '$utils'
let hrUser = JSON.parse(sessionStorage.getItem('hrUser')) const userData = JSON.parse(sessionStorage.getItem('hrUser'));
let admin = false export const headerItemsFun = () => {
hrUser && hrUser.adminHr.forEach(e => { let hrUser = userData || JSON.parse(sessionStorage.getItem('hrUser'));
if (hrUser) {
let admin = false
hrUser && hrUser.adminHr.forEach(e => {
if (e.id == hrUser.id) { if (e.id == hrUser.id) {
admin = true admin = true
} }
}) })
let headerItems = [admin ? { let headerItems = [admin ? {
itemKey: "authCenter", itemKey: "authCenter",
text: "权限中心", text: "权限中心",
items: [{ items: [{
@ -23,9 +26,9 @@ let headerItems = [admin ? {
text: "表单维护", text: "表单维护",
to: "/humanAffairs/authCenter/formMaintenance" to: "/humanAffairs/authCenter/formMaintenance"
}] }]
} : {}, } : {},
isAuthorized('BASICACTIONMANAGEMENT') || isAuthorized('EMPLOYEEASSESSMENT') || isAuthorized('MIDDLELEVELASSESSMENT') || isAuthorized('SENIORASSESSMENT') || isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? { isAuthorized('BASICACTIONMANAGEMENT') || isAuthorized('EMPLOYEEASSESSMENT') || isAuthorized('MIDDLELEVELASSESSMENT') || isAuthorized('SENIORASSESSMENT') || isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? {
itemKey: "achievements", itemKey: "achievements",
text: "绩效考核", text: "绩效考核",
items: [ items: [
@ -59,8 +62,8 @@ isAuthorized('BASICACTIONMANAGEMENT') || isAuthorized('EMPLOYEEASSESSMENT') || i
text: "奖惩信息", text: "奖惩信息",
to: "/humanAffairs/achievements/penalties/penaltiesRecord" to: "/humanAffairs/achievements/penalties/penaltiesRecord"
} : {}] } : {}]
} : {}, } : {},
isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? { isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? {
itemKey: "train", itemKey: "train",
text: "培训", text: "培训",
items: [ items: [
@ -76,8 +79,8 @@ isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? {
text: "培训管理", text: "培训管理",
to: isAuthorized('TRAININGMANAGEMENT') ? "/humanAffairs/train/trainingManagement/personalTrainRecord" : "/humanAffairs/train/trainingManagement/departmentTrainRecord" to: isAuthorized('TRAININGMANAGEMENT') ? "/humanAffairs/train/trainingManagement/personalTrainRecord" : "/humanAffairs/train/trainingManagement/departmentTrainRecord"
} : {}] } : {}]
} : {}, } : {},
isAuthorized('RECRUITMENTRECORDS') || isAuthorized('SALESSTATISTICS') ? { isAuthorized('RECRUITMENTRECORDS') || isAuthorized('SALESSTATISTICS') ? {
itemKey: "recruit", itemKey: "recruit",
text: "招聘", text: "招聘",
items: [isAuthorized('RECRUITMENTRECORDS') ? { items: [isAuthorized('RECRUITMENTRECORDS') ? {
@ -92,8 +95,8 @@ isAuthorized('RECRUITMENTRECORDS') || isAuthorized('SALESSTATISTICS') ? {
text: "销售统计", text: "销售统计",
to: "/humanAffairs/recruit/salesStatistics/personnelDistribution" to: "/humanAffairs/recruit/salesStatistics/personnelDistribution"
} : {}] } : {}]
} : {}, } : {},
isAuthorized('LEAVEMANAGEMENT') || isAuthorized('EMPLOYEECOMMUNICATION') ? { isAuthorized('LEAVEMANAGEMENT') || isAuthorized('EMPLOYEECOMMUNICATION') ? {
itemKey: "employeeRelationship", itemKey: "employeeRelationship",
text: "员工关系", text: "员工关系",
items: [isAuthorized('LEAVEMANAGEMENT') ? { items: [isAuthorized('LEAVEMANAGEMENT') ? {
@ -108,8 +111,8 @@ isAuthorized('LEAVEMANAGEMENT') || isAuthorized('EMPLOYEECOMMUNICATION') ? {
text: "员工沟通", text: "员工沟通",
to: "/humanAffairs/employeeRelationship/communication/employeeCommunication" to: "/humanAffairs/employeeRelationship/communication/employeeCommunication"
} : {}] } : {}]
} : {}, } : {},
isAuthorized('PERSONNELFILEMANAGEMENT') || isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? { isAuthorized('PERSONNELFILEMANAGEMENT') || isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? {
itemKey: "archivesCenter", itemKey: "archivesCenter",
text: "档案中心", text: "档案中心",
items: [isAuthorized('PERSONNELFILEMANAGEMENT') ? { items: [isAuthorized('PERSONNELFILEMANAGEMENT') ? {
@ -125,9 +128,9 @@ isAuthorized('PERSONNELFILEMANAGEMENT') || isAuthorized('DEPARTMENTARCHIVESMANAG
text: "部门档案", text: "部门档案",
to: "/humanAffairs/archivesCenter/deptArchives/department" to: "/humanAffairs/archivesCenter/deptArchives/department"
} : {}] } : {}]
} : {}] } : {}]
headerItems.map(e => { headerItems.map(e => {
if (e.items != undefined) { if (e.items != undefined) {
e.items = e.items.filter(element => { e.items = e.items.filter(element => {
if (Object.keys(element).length !== 0) { if (Object.keys(element).length !== 0) {
@ -136,13 +139,12 @@ headerItems.map(e => {
}) })
} }
return e return e
}) })
headerItems = headerItems.filter(element => { headerItems = headerItems.filter(element => {
if (Object.keys(element).length !== 0) { if (Object.keys(element).length !== 0) {
return true; return true;
} }
}) })
return headerItems;
export { }
headerItems
} }

13
web/client/src/layout/components/header/index.jsx

@ -1,14 +1,19 @@
"use strict"; "use strict";
import React from "react"; import React, { useState, useEffect } from 'react';
import { connect } from "react-redux"; import { connect } from "react-redux";
import { SplitButtonGroup, Dropdown, Button, Nav, Avatar } from '@douyinfe/semi-ui'; import { SplitButtonGroup, Dropdown, Button, Nav, Avatar } from '@douyinfe/semi-ui';
import { IconTreeTriangleDown } from '@douyinfe/semi-icons'; import { IconTreeTriangleDown } from '@douyinfe/semi-icons';
import { headerItems } from './contant'; import { headerItemsFun } from './contant';
import "./index.less"; import "./index.less";
const Header = (props) => { const Header = (props) => {
const { dispatch, history, user, actions, socket, tochange } = props; const { dispatch, history, user, actions, socket, tochange } = props;
const [allItems, setAllItems] = useState([])
useEffect(() => {
const headerItems = headerItemsFun();
if (headerItems)
setAllItems(headerItems);
}, [user && user.authorized])
return ( return (
<> <>
<div id="top-slider"> <div id="top-slider">
@ -59,7 +64,7 @@ const Header = (props) => {
}} }}
footer={ footer={
<> <>
{headerItems.map((item, index) => { {allItems.map((item, index) => {
if (item.hasOwnProperty('items')) { if (item.hasOwnProperty('items')) {
return ( return (
<Nav.Sub <Nav.Sub

Loading…
Cancel
Save