Browse Source

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

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

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

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

Loading…
Cancel
Save