Browse Source

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

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

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

@ -1,148 +1,150 @@
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 (e.id == hrUser.id) { if (hrUser) {
admin = true let admin = false
} hrUser && hrUser.adminHr.forEach(e => {
}) if (e.id == hrUser.id) {
let headerItems = [admin ? { admin = true
itemKey: "authCenter", }
text: "权限中心", })
items: [{ let headerItems = [admin ? {
fatherKey: "authCenter", itemKey: "authCenter",
openKey: "authCenter", text: "权限中心",
itemKey: "employeeAuth", items: [{
text: "员工权限", fatherKey: "authCenter",
to: "/humanAffairs/authCenter/employeeAuth" openKey: "authCenter",
}, { itemKey: "employeeAuth",
fatherKey: 'authCenter', text: "员工权限",
openKey: "authCenter", to: "/humanAffairs/authCenter/employeeAuth"
itemKey: "formMaintenance", }, {
text: "表单维护", fatherKey: 'authCenter',
to: "/humanAffairs/authCenter/formMaintenance" openKey: "authCenter",
}] itemKey: "formMaintenance",
} : {}, text: "表单维护",
to: "/humanAffairs/authCenter/formMaintenance"
isAuthorized('BASICACTIONMANAGEMENT') || isAuthorized('EMPLOYEEASSESSMENT') || isAuthorized('MIDDLELEVELASSESSMENT') || isAuthorized('SENIORASSESSMENT') || isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? { }]
itemKey: "achievements",
text: "绩效考核",
items: [
isAuthorized('BASICACTIONMANAGEMENT') ? {
fatherKey: "achievements",
itemKey: "basicAction",
text: "基本动作",
to: isAuthorized('WEEKLYREPORTMANAGEMENT') ? "/humanAffairs/achievements/basicAction/weeklyManagement" : isAuthorized('SALESLOG') ? "/humanAffairs/achievements/basicAction/saleLog" : "/humanAffairs/achievements/basicAction/pmLog"
} : {}, } : {},
isAuthorized('EMPLOYEEASSESSMENT') ? {
fatherKey: 'achievements', isAuthorized('BASICACTIONMANAGEMENT') || isAuthorized('EMPLOYEEASSESSMENT') || isAuthorized('MIDDLELEVELASSESSMENT') || isAuthorized('SENIORASSESSMENT') || isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? {
itemKey: "employeeKPI", itemKey: "achievements",
text: "员工考核", text: "绩效考核",
to: isAuthorized('EMPLOYEEASSESSMENTDURINGPROBATIONARYPERIOD') ? "/humanAffairs/achievements/employeeKPI/probationer" : "/humanAffairs/achievements/employeeKPI/regular" items: [
isAuthorized('BASICACTIONMANAGEMENT') ? {
fatherKey: "achievements",
itemKey: "basicAction",
text: "基本动作",
to: isAuthorized('WEEKLYREPORTMANAGEMENT') ? "/humanAffairs/achievements/basicAction/weeklyManagement" : isAuthorized('SALESLOG') ? "/humanAffairs/achievements/basicAction/saleLog" : "/humanAffairs/achievements/basicAction/pmLog"
} : {},
isAuthorized('EMPLOYEEASSESSMENT') ? {
fatherKey: 'achievements',
itemKey: "employeeKPI",
text: "员工考核",
to: isAuthorized('EMPLOYEEASSESSMENTDURINGPROBATIONARYPERIOD') ? "/humanAffairs/achievements/employeeKPI/probationer" : "/humanAffairs/achievements/employeeKPI/regular"
} : {},
isAuthorized('MIDDLELEVELASSESSMENT') ? {
fatherKey: "achievements",
itemKey: "middleKPI",
text: "中层考核",
to: isAuthorized('MIDDLELEVELMONTHLYPROCESSASSESSMENT') ? "/humanAffairs/achievements/middleKPI/monthlyProcess" : "/humanAffairs/achievements/middleKPI/quarter"
} : {},
isAuthorized('SENIORASSESSMENT') ? {
fatherKey: 'achievements',
itemKey: "highKPI",
text: "高管考核",
to: isAuthorized('MONTHLYPROCESSASSESSMENTFORSENIORMANAGEMENT') ? "/humanAffairs/achievements/highKPI/highMonthly" : "/humanAffairs/achievements/highKPI/Highquarter"
} : {},
isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? {
fatherKey: 'achievements',
itemKey: "penalties",
text: "奖惩信息",
to: "/humanAffairs/achievements/penalties/penaltiesRecord"
} : {}]
} : {}, } : {},
isAuthorized('MIDDLELEVELASSESSMENT') ? { isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? {
fatherKey: "achievements", itemKey: "train",
itemKey: "middleKPI", text: "培训",
text: "中层考核", items: [
to: isAuthorized('MIDDLELEVELMONTHLYPROCESSASSESSMENT') ? "/humanAffairs/achievements/middleKPI/monthlyProcess" : "/humanAffairs/achievements/middleKPI/quarter" isAuthorized('TRAININGDOSSIER') ? {
fatherKey: "train",
itemKey: "trainFiles",
text: "培训档案",
to: "/humanAffairs/train/trainFiles/resourceRepository"
} : {},
isAuthorized('TRAININGMANAGEMENT') ? {
fatherKey: "train",
itemKey: "trainingManagement",
text: "培训管理",
to: isAuthorized('TRAININGMANAGEMENT') ? "/humanAffairs/train/trainingManagement/personalTrainRecord" : "/humanAffairs/train/trainingManagement/departmentTrainRecord"
} : {}]
} : {}, } : {},
isAuthorized('SENIORASSESSMENT') ? { isAuthorized('RECRUITMENTRECORDS') || isAuthorized('SALESSTATISTICS') ? {
fatherKey: 'achievements', itemKey: "recruit",
itemKey: "highKPI", text: "招聘",
text: "高管考核", items: [isAuthorized('RECRUITMENTRECORDS') ? {
to: isAuthorized('MONTHLYPROCESSASSESSMENTFORSENIORMANAGEMENT') ? "/humanAffairs/achievements/highKPI/highMonthly" : "/humanAffairs/achievements/highKPI/Highquarter" fatherKey: "recruit",
itemKey: "recruitRecord",
text: "招聘记录",
to: "/humanAffairs/recruit/recruitRecord/appointmentRecords"
} : {},
isAuthorized('SALESSTATISTICS') ? {
fatherKey: "recruit",
itemKey: "salesStatistics",
text: "销售统计",
to: "/humanAffairs/recruit/salesStatistics/personnelDistribution"
} : {}]
} : {}, } : {},
isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? { isAuthorized('LEAVEMANAGEMENT') || isAuthorized('EMPLOYEECOMMUNICATION') ? {
fatherKey: 'achievements', itemKey: "employeeRelationship",
itemKey: "penalties", text: "员工关系",
text: "奖惩信息", items: [isAuthorized('LEAVEMANAGEMENT') ? {
to: "/humanAffairs/achievements/penalties/penaltiesRecord" fatherKey: "employeeRelationship",
} : {}] itemKey: "leaveManagement",
} : {}, text: "假勤管理",
isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? { to: isAuthorized('ATTENDANCESTATISTICS') ? "/humanAffairs/employeeRelationship/leaveManagement/attendanceStatistics" : isAuthorized('LEAVESTATISTICS') ? "/humanAffairs/employeeRelationship/leaveManagement/leaveStatistics" : "/humanAffairs/employeeRelationship/leaveManagement/overtimeStatistics"
itemKey: "train", } : {},
text: "培训", isAuthorized('EMPLOYEECOMMUNICATION') ? {
items: [ fatherKey: "employeeRelationship",
isAuthorized('TRAININGDOSSIER') ? { itemKey: "communication",
fatherKey: "train", text: "员工沟通",
itemKey: "trainFiles", to: "/humanAffairs/employeeRelationship/communication/employeeCommunication"
text: "培训档案", } : {}]
to: "/humanAffairs/train/trainFiles/resourceRepository"
} : {}, } : {},
isAuthorized('TRAININGMANAGEMENT') ? { isAuthorized('PERSONNELFILEMANAGEMENT') || isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? {
fatherKey: "train", itemKey: "archivesCenter",
itemKey: "trainingManagement", text: "档案中心",
text: "培训管理", items: [isAuthorized('PERSONNELFILEMANAGEMENT') ? {
to: isAuthorized('TRAININGMANAGEMENT') ? "/humanAffairs/train/trainingManagement/personalTrainRecord" : "/humanAffairs/train/trainingManagement/departmentTrainRecord" fatherKey: "archivesCenter",
openKey: "personnelArchives",
itemKey: "personnelFiles",
text: "人员档案",
to: isAuthorized('PERSONNELFILES') ? "/humanAffairs/archivesCenter/personnelArchives/personnelFiles" : isAuthorized('EMPLOYEEINFORMATION') ? "/humanAffairs/archivesCenter/personnelArchives/employeeInformation" : "/humanAffairs/archivesCenter/personnelArchives/positionRating"
} : {},
isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? {
fatherKey: 'archivesCenter',
itemKey: "deptArchives",
text: "部门档案",
to: "/humanAffairs/archivesCenter/deptArchives/department"
} : {}]
} : {}] } : {}]
} : {},
isAuthorized('RECRUITMENTRECORDS') || isAuthorized('SALESSTATISTICS') ? {
itemKey: "recruit",
text: "招聘",
items: [isAuthorized('RECRUITMENTRECORDS') ? {
fatherKey: "recruit",
itemKey: "recruitRecord",
text: "招聘记录",
to: "/humanAffairs/recruit/recruitRecord/appointmentRecords"
} : {},
isAuthorized('SALESSTATISTICS') ? {
fatherKey: "recruit",
itemKey: "salesStatistics",
text: "销售统计",
to: "/humanAffairs/recruit/salesStatistics/personnelDistribution"
} : {}]
} : {},
isAuthorized('LEAVEMANAGEMENT') || isAuthorized('EMPLOYEECOMMUNICATION') ? {
itemKey: "employeeRelationship",
text: "员工关系",
items: [isAuthorized('LEAVEMANAGEMENT') ? {
fatherKey: "employeeRelationship",
itemKey: "leaveManagement",
text: "假勤管理",
to: isAuthorized('ATTENDANCESTATISTICS') ? "/humanAffairs/employeeRelationship/leaveManagement/attendanceStatistics" : isAuthorized('LEAVESTATISTICS') ? "/humanAffairs/employeeRelationship/leaveManagement/leaveStatistics" : "/humanAffairs/employeeRelationship/leaveManagement/overtimeStatistics"
} : {},
isAuthorized('EMPLOYEECOMMUNICATION') ? {
fatherKey: "employeeRelationship",
itemKey: "communication",
text: "员工沟通",
to: "/humanAffairs/employeeRelationship/communication/employeeCommunication"
} : {}]
} : {},
isAuthorized('PERSONNELFILEMANAGEMENT') || isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? {
itemKey: "archivesCenter",
text: "档案中心",
items: [isAuthorized('PERSONNELFILEMANAGEMENT') ? {
fatherKey: "archivesCenter",
openKey: "personnelArchives",
itemKey: "personnelFiles",
text: "人员档案",
to: isAuthorized('PERSONNELFILES') ? "/humanAffairs/archivesCenter/personnelArchives/personnelFiles" : isAuthorized('EMPLOYEEINFORMATION') ? "/humanAffairs/archivesCenter/personnelArchives/employeeInformation" : "/humanAffairs/archivesCenter/personnelArchives/positionRating"
} : {},
isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? {
fatherKey: 'archivesCenter',
itemKey: "deptArchives",
text: "部门档案",
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) {
return true;
}
})
}
return e
})
headerItems = headerItems.filter(element => {
if (Object.keys(element).length !== 0) { if (Object.keys(element).length !== 0) {
return true; return true;
} }
}) })
return headerItems;
} }
return e
})
headerItems = headerItems.filter(element => {
if (Object.keys(element).length !== 0) {
return true;
}
})
export {
headerItems
} }

15
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
@ -89,7 +94,7 @@ const Header = (props) => {
<img src="/assets/images/background/username.png" alt="" style={{ width: '100%', height: '100%' }} /> <img src="/assets/images/background/username.png" alt="" style={{ width: '100%', height: '100%' }} />
</div> </div>
<div style={{ color: '#92CBFF', fontSize: 12, marginLeft: 10, cursor: "pointer" }}> <div style={{ color: '#92CBFF', fontSize: 12, marginLeft: 10, cursor: "pointer" }}>
{user?.name} {user?.name}
</div> </div>
</div> </div>

Loading…
Cancel
Save