import React from 'react'; import { IconCode } from '@douyinfe/semi-icons'; import { isAuthorized } from '$utils' export function getNavItem(user, dispatch) { let hrUser = JSON.parse(sessionStorage.getItem('hrUser')) let admin = false hrUser && hrUser.adminHr.forEach(e => { if (e.id == hrUser.id) { admin = true } }) let list = [ { itemKey: 'humanAffairs', text: '人事管理', icon: , items: [ isAuthorized('PERSONNELFILEMANAGEMENT') ? { itemKey: 'personnelArchives', text: '人员档案', icon: , to: '/humanAffairs/archivesCenter/personnelArchives/personnelFiles', items: [ isAuthorized('PERSONNELFILES') ? { itemKey: 'personnelFiles', to: '/humanAffairs/archivesCenter/personnelArchives/personnelFiles', text: '人员档案' } : {}, isAuthorized('EMPLOYEEINFORMATION') ? { itemKey: 'employeeInformation', to: '/humanAffairs/archivesCenter/personnelArchives/employeeInformation', text: '员工信息' } : {}, isAuthorized('JOBRATING') ? { itemKey: 'positionRating', to: '/humanAffairs/archivesCenter/personnelArchives/positionRating', text: '岗位评级' } : {}] } : {}, isAuthorized('DEPARTMENTARCHIVESMANAGEMENT') ? { itemKey: 'deptArchives', text: '部门档案', icon: , to: '/humanAffairs/archivesCenter/deptArchives/department', items: [ isAuthorized('DEPARTMENTARCHIVES') ? { itemKey: 'department', to: '/humanAffairs/archivesCenter/deptArchives/department', text: '部门档案' } : {}] } : {}, isAuthorized('LEAVEMANAGEMENT') ? { itemKey: 'leaveManagement', text: '假勤管理', icon: , to: '/humanAffairs/employeeRelationship/leaveManagement/attendanceStatistics', items: [ isAuthorized('ATTENDANCESTATISTICS') ? { itemKey: 'attendanceStatistics', to: '/humanAffairs/employeeRelationship/leaveManagement/attendanceStatistics', text: '出勤统计' } : {}, isAuthorized('LEAVESTATISTICS') ? { itemKey: 'leaveStatistics', to: '/humanAffairs/employeeRelationship/leaveManagement/leaveStatistics', text: '请假统计' } : {}, isAuthorized('OVERTIMESTATISTICS') ? { itemKey: 'overtimeStatistics', to: '/humanAffairs/employeeRelationship/leaveManagement/overtimeStatistics', text: '加班统计' } : {}] } : {}, isAuthorized('EMPLOYEECOMMUNICATION') ? { itemKey: 'communication', text: '员工沟通', icon: , to: '/humanAffairs/employeeRelationship/communication/employeeCommunication', items: [ isAuthorized('EMPLOYEECOMMUNICATIONSTATISTICS') ? { itemKey: 'employeeCommunication', to: '/humanAffairs/employeeRelationship/communication/employeeCommunication', text: '员工沟通统计' } : {} ] } : {}, isAuthorized('RECRUITMENTRECORDS') ? { itemKey: 'recruitRecord', text: '招聘记录', icon: , to: '/humanAffairs/recruit/recruitRecord/appointmentRecords', items: [ isAuthorized('APPOINTMENTRECORD') ? { itemKey: 'appointmentRecords', to: '/humanAffairs/recruit/recruitRecord/appointmentRecords', text: '任用记录' } : {} ] } : {}, isAuthorized('SALESSTATISTICS') ? { itemKey: 'salesStatistics', text: '销售统计', icon: ,//wwwtodo to: '/humanAffairs/recruit/salesStatistics/personnelDistribution', items: [ isAuthorized('SALESPERSONNELDISTRIBUTION') ? { itemKey: 'personnelDistribution', to: '/humanAffairs/recruit/salesStatistics/personnelDistribution', text: '销售人员分布' } : {} ] } : {}, isAuthorized('TRAININGDOSSIER') ? { itemKey: 'trainFiles', text: '培训档案', icon: , to: '/humanAffairs/train/trainFiles/resourceRepository', items: [ isAuthorized('TRAININGRESOURCEREPOSITORY') ? { itemKey: 'resourceRepository', to: '/humanAffairs/train/trainFiles/resourceRepository', text: '培训资源储存库' } : {} ] } : {}, isAuthorized('TRAININGMANAGEMENT') ? { itemKey: 'trainingManagement', text: '培训管理', icon: , to: '/humanAffairs/train/trainingManagement/personalTrainRecord', items: [ isAuthorized('PERSONALTRAININGRECORDS') ? { itemKey: 'personalTrainRecord', to: '/humanAffairs/train/trainingManagement/personalTrainRecord', text: '个人培训记录' } : {}, isAuthorized('DEPARTMENTTRAININGRECORDS') ? { itemKey: 'departmentTrainRecord', to: '/humanAffairs/train/trainingManagement/departmentTrainRecord', text: '部门培训记录' } : {}] } : {}, isAuthorized('BASICACTIONMANAGEMENT') ? { itemKey: 'basicAction', text: '基本动作', icon: , to: '/humanAffairs/achievements/basicAction/weeklyManagement', items: [ isAuthorized('WEEKLYREPORTMANAGEMENT') ? { itemKey: 'weeklyManagement', to: '/humanAffairs/achievements/basicAction/weeklyManagement', text: '周报管理' } : {}, isAuthorized('SALESLOG') ? { itemKey: 'saleLog', to: '/humanAffairs/achievements/basicAction/saleLog', text: '销售日志' } : {}, isAuthorized('ENGINEERINGLOG') ? { itemKey: 'pmLog', to: '/humanAffairs/achievements/basicAction/pmLog', text: '工程日志' } : {}] } : {}, isAuthorized('EMPLOYEEASSESSMENT') ? { itemKey: 'employeeKPI', text: '员工考核', icon: , to: '/humanAffairs/achievements/employeeKPI/probationer', items: [ isAuthorized('EMPLOYEEASSESSMENTDURINGPROBATIONARYPERIOD') ? { itemKey: 'probationer', to: '/humanAffairs/achievements/employeeKPI/probationer', text: '试用期员工考核' } : {}, isAuthorized('FORMALEMPLOYEEASSESSMENT') ? { itemKey: 'regular', to: '/humanAffairs/achievements/employeeKPI/regular', text: '正式员工考核' } : {}] } : {}, isAuthorized('MIDDLELEVELASSESSMENT') ? { itemKey: 'middleKPI', text: '中层考核', icon: , to: '/humanAffairs/achievements/middleKPI/monthlyProcess', items: [ isAuthorized('MIDDLELEVELMONTHLYPROCESSASSESSMENT') ? { itemKey: 'monthlyProcess', to: '/humanAffairs/achievements/middleKPI/monthlyProcess', text: '月度过程考核' } : {}, isAuthorized('MIDLEVELQUARTERLYASSESSMENT') ? { itemKey: 'quarter', to: '/humanAffairs/achievements/middleKPI/quarter', text: '季度考核' } : {}] } : {}, isAuthorized('SENIORASSESSMENT') ? { itemKey: 'highKPI', text: '高管考核', icon: , to: '/humanAffairs/achievements/highKPI/highMonthly', items: [ isAuthorized('MONTHLYPROCESSASSESSMENTFORSENIORMANAGEMENT') ? { itemKey: 'highMonthly', to: '/humanAffairs/achievements/highKPI/highMonthly', text: '月度过程考核' } : {}, isAuthorized('QUARTERLYASSESSMENTOFSENIORMANAGEMENT') ? { itemKey: 'Highquarter', to: '/humanAffairs/achievements/highKPI/Highquarter', text: '季度考核' } : {}] } : {}, isAuthorized('REWARDANDPUNISHMENTMANAGEMENT') ? { itemKey: 'penalties', text: '奖惩信息', icon: , to: '/humanAffairs/achievements/penalties/penaltiesRecord', items: [ isAuthorized('REWARDANDPUNISHMENTINFORMATION') ? { itemKey: 'penaltiesRecord', to: '/humanAffairs/achievements/penalties/penaltiesRecord', text: '奖惩信息' } : {}] } : {}, admin ? { itemKey: 'authCenter', text: '权限中心', icon: , to: '/humanAffairs/authCenter/employeeAuth', items: [{ itemKey: 'employeeAuth', to: '/humanAffairs/authCenter/employeeAuth', text: '员工权限' }, { itemKey: 'formMaintenance', to: '/humanAffairs/authCenter/formMaintenance', text: '表单维护' }] } : {} ] }, ] list[0].items.map(e => { if (e.items != undefined) { e.items = e.items.filter(element => { if (Object.keys(element).length !== 0) { return true; } }) } return e }) list[0].items = list[0].items.filter(element => { if (Object.keys(element).length !== 0) { return true; } }) return list }