HRHead.js 9.2 KB
import React,{PropTypes} from 'react';
import ReactDOM from 'react-dom';  
import cx from 'classnames';
import {Row,Col,message, Menu, Dropdown} from 'antd';
// import s from './header.scss';  
import s from '../../../containers/hrboard/Index.scss'; 

class HRHead extends React.Component {
    constructor(props) {
        super(props);
        this.goFirstIndex=this.goFirstIndex.bind(this);
        this.goIndex=this.goIndex.bind(this); 
        this.goOrganization=this.goOrganization.bind(this);
        this.goAttendanceSettings=this.goAttendanceSettings.bind(this);
        this.goChat=this.goChat.bind(this);
        this.goUserInfo=this.goUserInfo.bind(this);
        this.goSignOut=this.goSignOut.bind(this);
        this.trueOrfalse=this.trueOrfalse.bind(this);
        this.goPay=this.goPay.bind(this);
        this.goCompanyAccount = this.goCompanyAccount.bind(this);
        this.goContract = this.goContract.bind(this);
        this.state={
            menu:'1',
        }
    }
    static propTypes = {    
        title:PropTypes.string,
        close:PropTypes.func,
        userInfo:PropTypes.object,
        messageCounts:PropTypes.object,
        // pathname:PropTypes.object
    } 
    static defaultProps={   
        close:()=>{

        }
    }  
    changeMenu(menu){
        this.setState({
            menu
        })
    }
    goFirstIndex(){
        window.location.href='#/user/hrboard/firstIndex';
    }
    goIndex(){
        window.location.href='#/user/hrboard/staffs/';//'#/user/hrboard/index';
    }
    goOrganization(){
        window.location.href='#/user/hrboard/organization';
    }
    goAttendanceSettings(){
        // message.success('正在开发中,精彩稍后呈现!', 2);
        // window.location.href='#/user/hrboard/attendanceSettings';
        window.location.href='#/user/hrboard/setattend';
    }
    goPay(){
        window.location.href='#/user/hrboard/payRoll';
        // message.success('正在紧密开发中,精彩稍后呈现!', 2);
    }
    goApprovalSetting(){
         window.location.href='#/user/hrboard/approvalSetting';
    }
    goChat(){ 
        window.location.href='#/user/chat';
    }
    goUserInfo(){
        const {userInfo}=this.props;
        window.location.href='#/user/hrboard/personal/'+userInfo.user_id;
    }
    goSignOut(){
        window.location.href =`${__PREFIX__}signOut`;
    }
    goIntelligentPay(){
        // window.location.href='#/user/hrboard/intelligentPay';
        window.location.href='#/user/hrboard/calculateSalaryIndex'; 
    }
    goCompanyAccount(){
        // window.location.href='#/user/hrboard/account';
    }
    goContract(){
        window.location.href='#/user/hrboard/contract'; 
    }
    trueOrfalse(type){
        let showImg='';
        if(type){
            showImg=true
        }else{
            showImg=false
        }
        return showImg
    }
    componentDidMount(){  
    }  
    componentWillReceiveProps(nextProps){   
    }
    componentDidUpdate(prevProps,prevState){  
    }
    componentWillUnmount() {  
        
    }  
    renderLink(){
        return(
            <Menu>
                <Menu.Item key="0">
                  <a href="#/user/hrboard/account/0">我的钱包</a>
                </Menu.Item>
                <Menu.Item key="1">
                  <a href="#/user/hrboard/orders">订单管理</a>
                </Menu.Item>
                <Menu.Item key="2">
                  <a href="#/user/hrboard/invoice">发票管理</a>
                </Menu.Item>
            </Menu>
        )
    }
    render(){    
        const {title,messageCounts,userInfo:{company_logo=''},pathname}=this.props;
        const src=company_logo?
            `https://${window.oss.public_bucket}`+company_logo+'?t='+new Date().getTime():
            'LOGO';
        //公司的logo 需要的拼接的地址
        //src={'https://oss-cn-beijing.aliyuncs.com/krhrimg/user_image/'+userInfo.tenant_id+'/'+userInfo.user_id+'.png?t='+new Date().getTime()}
        let showImg=this.trueOrfalse(company_logo)
        const {menu}=this.state;
        let counts=0;
        Object.values(messageCounts).map((count,i)=>{
            counts=counts+parseInt(count);
        });
        let selectMenu=0;
        if(pathname.indexOf('hrboard/firstIndex')!=-1){
            selectMenu=0;
        }else if(pathname.indexOf('hrboard/staffs')!=-1){
            selectMenu=1;
        }else if(pathname.indexOf('hrboard/organization')!=-1){
            selectMenu=2; 
        }else if(pathname.indexOf('hrboard/attendanceSettings')!=-1 ||
            pathname.indexOf('hrboard/setattend')!=-1
            ){ 
            selectMenu=3;
        }else if(pathname.indexOf('hrboard/payRoll')!=-1||
            pathname.indexOf('hrboard/PaySheetLastChange')!=-1||
            pathname.indexOf('hrboard/payRollAction')!=-1){
            selectMenu=4; 
        }else if(pathname.indexOf('hrboard/approvalSetting')!=-1){
             selectMenu=5; 
        }else if(pathname.indexOf('hrboard/account')!=-1 || 
            pathname.indexOf('hrboard/orders')!=-1 ||
            pathname.indexOf('hrboard/invoice')!=-1 ||
            pathname.indexOf('hrboard/payconfirm')!=-1
            ){
            selectMenu=6;
        }else if(pathname.indexOf('hrboard/intelligentPay')!=-1||
            pathname.indexOf('hrboard/payrollList')!=-1||
            pathname.indexOf('hrboard/calculateSalaryIndex')!=-1||
            pathname.indexOf('hrboard/showDetail')!=-1||
            pathname.indexOf('hrboard/manageSalary')!=-1||
            pathname.indexOf('hrboard/SalarySetup')!=-1||
            pathname.indexOf('hrboard/salarySetup')!=-1||
            pathname.indexOf('hrboard/intelligentauto')!=-1||
            pathname.indexOf('hrboard/updateauto')!=-1 ||
            pathname.indexOf('hrboard/calcsalarytable')!=-1 ||
            pathname.indexOf('hrboard/PeosonalMes')!=-1 ||
            pathname.indexOf('hrboard/salaryHistory')!=-1 ||
            pathname.indexOf('hrboard/personalTaxDetail')!=-1 ||
            pathname.indexOf('hrboard/fundDetail')!=-1 ||
            pathname.indexOf('hrboard/tableDetailAtd')!=-1 ||
            pathname.indexOf('hrboard/tableDetailPay')!=-1 ||
            pathname.indexOf('hrboard/payBeanDetail')!=-1 ||
            pathname.indexOf('hrboard/optimizePayDetail')!=-1 
            ){
            selectMenu=7;
        }else if(pathname.indexOf('hrboard/listOfTable')!=-1 ||
                 pathname.indexOf('hrboard/contract')!=-1 ||
                 pathname.indexOf('hrboard/setContract')!=-1 
            ){
            selectMenu=8;
        }
        // console.log('selectMenu--------------',selectMenu)
        return (
            <div className={cx(s.indexHead)} >
                <div className={cx(s.indexHeadNav)}>
                    <div className={cx(s.indexHeadLogo)} onClick={this.goFirstIndex}>
                       {showImg? <img style={{width:'100px',height:'60px',position:'absolute',left:'20px'}} src={src} />:
                       <span style={{display:'inline-block',marginTop:'10px',marginLeft:'30px',height:'30px',fontSize:'25px',fontWeight:'bold'}}>{src}</span>}
                    </div>
                    <div className={cx(s.indexHeadLine)}></div>
                    <div className={cx(s.indexHeadList)}>
                        <a className={cx(selectMenu==0?s.headStyle:null)} onClick={this.goFirstIndex}>首页</a>
                        <a className={cx(selectMenu==1?s.headStyle:null)} onClick={this.goIndex}>员工管理</a>
                        <a className={cx(selectMenu==2?s.headStyle:null)} onClick={this.goOrganization}>组织管理</a>
                        <a className={cx(selectMenu==3?s.headStyle:null)} onClick={this.goAttendanceSettings}>考勤设置</a>
                        {/*<a className={cx(selectMenu==4?s.headStyle:null)} onClick={this.goPay}>薪酬管理</a>*/}
                        <a className={cx(selectMenu==5?s.headStyle:null)} onClick={this.goApprovalSetting}>审批管理</a>
                        <a className={cx(selectMenu==7?s.headStyle:null)} onClick={this.goIntelligentPay}>智能薪酬</a>
                        {/*by chenming*/}
                        <Dropdown overlay={this.renderLink()} trigger={['click']}>
                            <a className={cx(selectMenu==6?s.headStyle:null)} onClick={this.goCompanyAccount}>企业帐户</a>
                        </Dropdown>
                        <a className={cx(selectMenu==8?s.headStyle:null)} onClick={this.goContract}>劳动合同</a>
                    </div>
                    <div  className={cx(s.indexHeadIcon)}>
                        <span onClick={this.goChat} style={{marginRight:'20px'}}>
                            <i className={cx(s.shortcut_menu,'kr_icon')}>&#xe616;</i>
                            {counts>0&&
                                <i className={cx(s.message_point,'kr_icon')}>&#xe62c;</i>
                            }
                        </span>
                        <span onClick={this.goUserInfo} style={{marginRight:'20px'}}><i className={cx(s.shortcut_menu,'kr_icon')}>&#xe610;</i></span>
                        <span onClick={this.goSignOut}><i className={cx(s.shortcut_menu_abort)}>退出</i></span>
                    </div>
                </div>
            </div>
        ) 
    }
}



export default HRHead;