import {
    inject,
    observer,
} from 'mobx-react'

import {
    WeaAuth
} from 'ecCom'

import {
    Spin
} from 'antd'

import React from 'react'
const toJS = mobx.toJS;

@inject('hrmEngineGroup')
@observer
export default class AddGpMember extends React.Component {
    constructor(props) {
        super(props);
    }

    handleOk(data) {
        const {
            hrmEngineGroup
        } = this.props;

        hrmEngineGroup.setGpMemParams(data); //设置参数
        hrmEngineGroup.setOperation('addGpMemSave');
        hrmEngineGroup.memberSave();
    }

    render() {
        const {
            hrmEngineGroup
        } = this.props, {
            addGpMemTitle,
            addGpMemDialogVisible,
            addGpMemLoading,
            addGpMemCondition,
        } = hrmEngineGroup;

        if (addGpMemLoading) {
            return <div>
                        <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@endep4`} spinning={addGpMemLoading}></Spin>
                    </div>
        } else {
            return (
                <WeaAuth ecId={`${this && this.props && this.props.ecId || ''}_WeaAuth@n4njln`}
                    visible={addGpMemDialogVisible}
                    title={addGpMemTitle()}
                    height={200}
                    icon="icon-coms-hrm"
                    iconBgcolor="#217346"
                    conditions={toJS(addGpMemCondition)}
                    onOk={data => this.handleOk(data)}
                    onCancel={()=>hrmEngineGroup.setAddGpMemDialogVisible(false)}
                />
            )
        }

    }
}