From 1036bd2cc24c39172bb51cdcb2f792905ba93ece Mon Sep 17 00:00:00 2001 From: zhangminghua Date: Wed, 12 Jul 2023 16:28:05 +0800 Subject: [PATCH] =?UTF-8?q?(*)=E9=A1=B6=E9=83=A8=E8=8F=9C=E5=8D=95?= =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8A=A0=E8=BD=BD=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/layout/components/header/contant.js | 268 +++++++++--------- .../src/layout/components/header/index.jsx | 15 +- 2 files changed, 145 insertions(+), 138 deletions(-) diff --git a/web/client/src/layout/components/header/contant.js b/web/client/src/layout/components/header/contant.js index 7b71a10..fb11729 100644 --- a/web/client/src/layout/components/header/contant.js +++ b/web/client/src/layout/components/header/contant.js @@ -1,148 +1,150 @@ import { isAuthorized } from '$utils' -let hrUser = JSON.parse(sessionStorage.getItem('hrUser')) -let admin = false -hrUser && hrUser.adminHr.forEach(e => { - if (e.id == hrUser.id) { - admin = true - } -}) -let headerItems = [admin ? { - itemKey: "authCenter", - text: "权限中心", - items: [{ - fatherKey: "authCenter", - openKey: "authCenter", - itemKey: "employeeAuth", - text: "员工权限", - to: "/humanAffairs/authCenter/employeeAuth" - }, { - fatherKey: 'authCenter', - 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" +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 ? { + itemKey: "authCenter", + text: "权限中心", + items: [{ + fatherKey: "authCenter", + openKey: "authCenter", + itemKey: "employeeAuth", + text: "员工权限", + to: "/humanAffairs/authCenter/employeeAuth" + }, { + fatherKey: 'authCenter', + openKey: "authCenter", + itemKey: "formMaintenance", + text: "表单维护", + to: "/humanAffairs/authCenter/formMaintenance" + }] } : {}, - isAuthorized('EMPLOYEEASSESSMENT') ? { - fatherKey: 'achievements', - itemKey: "employeeKPI", - text: "员工考核", - to: isAuthorized('EMPLOYEEASSESSMENTDURINGPROBATIONARYPERIOD') ? "/humanAffairs/achievements/employeeKPI/probationer" : "/humanAffairs/achievements/employeeKPI/regular" + + 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', + 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') ? { - fatherKey: "achievements", - itemKey: "middleKPI", - text: "中层考核", - to: isAuthorized('MIDDLELEVELMONTHLYPROCESSASSESSMENT') ? "/humanAffairs/achievements/middleKPI/monthlyProcess" : "/humanAffairs/achievements/middleKPI/quarter" + isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? { + itemKey: "train", + text: "培训", + items: [ + 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') ? { - fatherKey: 'achievements', - itemKey: "highKPI", - text: "高管考核", - to: isAuthorized('MONTHLYPROCESSASSESSMENTFORSENIORMANAGEMENT') ? "/humanAffairs/achievements/highKPI/highMonthly" : "/humanAffairs/achievements/highKPI/Highquarter" + 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('REWARDANDPUNISHMENTMANAGEMENT') ? { - fatherKey: 'achievements', - itemKey: "penalties", - text: "奖惩信息", - to: "/humanAffairs/achievements/penalties/penaltiesRecord" - } : {}] -} : {}, -isAuthorized('TRAININGDOSSIER') || isAuthorized('TRAININGMANAGEMENT') ? { - itemKey: "train", - text: "培训", - items: [ - isAuthorized('TRAININGDOSSIER') ? { - fatherKey: "train", - itemKey: "trainFiles", - text: "培训档案", - to: "/humanAffairs/train/trainFiles/resourceRepository" + 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('TRAININGMANAGEMENT') ? { - fatherKey: "train", - itemKey: "trainingManagement", - text: "培训管理", - to: isAuthorized('TRAININGMANAGEMENT') ? "/humanAffairs/train/trainingManagement/personalTrainRecord" : "/humanAffairs/train/trainingManagement/departmentTrainRecord" + 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" + } : {}] } : {}] -} : {}, -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 => { - if (e.items != undefined) { - e.items = e.items.filter(element => { + headerItems.map(e => { + if (e.items != undefined) { + 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) { return true; } }) + return headerItems; } - return e -}) -headerItems = headerItems.filter(element => { - if (Object.keys(element).length !== 0) { - return true; - } -}) - -export { - headerItems } \ No newline at end of file diff --git a/web/client/src/layout/components/header/index.jsx b/web/client/src/layout/components/header/index.jsx index 6de8b1b..1ddd5ab 100644 --- a/web/client/src/layout/components/header/index.jsx +++ b/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 ( <>
@@ -59,7 +64,7 @@ const Header = (props) => { }} footer={ <> - {headerItems.map((item, index) => { + {allItems.map((item, index) => { if (item.hasOwnProperty('items')) { return ( {
- {user?.name} + {user?.name}