import React, {Component} from 'react';
import {observer} from 'mobx-react';
import {WeaDialog,WeaRightMenu,WeaNewScroll,WeaTop,WeaLocaleProvider} from 'ecCom';
import {Button} from 'antd';
import {i18n} from '../../public/i18n';
import * as mobx from 'mobx';
import {FormInfo} from '../../../hrmComsPublic/index';
const getLabel = WeaLocaleProvider.getLabel;
const toJS = mobx.toJS;
@observer
export default class DeviceEdit extends Component{
    render(){
        const {
			store
        } = this.props;
        const {
            deviceEditDialogParams,
            formTarget,
            doSaveScheduleDevice,
            formItemRender
        } = store;
        const {deviceEditConditionForm: form, deviceEditConditionFormFields: fields} = formTarget;
        const generateDialogParams = () =>{
            const props = {...deviceEditDialogParams};
            let buttons = [<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@r2hwjp`} type='primary' op='save' onClick={() => doSaveScheduleDevice()}>{i18n.label.save()}</Button>];
            Object.assign(props, {
                buttons,
                moreBtn: {datas: store.convertToMenus(buttons)},
                // key: new Date().getTime(),
            })
            return props;
        }
        
        return (
            <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@svn2ns`} {...generateDialogParams()}>
                   <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@agep9g`} height={'100%'}>
                    <FormInfo ecId={`${this && this.props && this.props.ecId || ''}_FormInfo@57s80k`} 
                        className='formComponent' 
                        center={false} 
                        form={form} 
                        formFields={fields}
                        itemRender={formItemRender}/>
                </WeaNewScroll>
            </WeaDialog>
        )
    }
}