import React,{Component} from 'react'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Input,Table,Steps,Row,Col,Button} from 'antd'
import { updateTreeValue,updateRcvBic,initSwiftMessageTree,updateSwiftMessage } from '../store/modules/swift/swift_action';


const Step = Steps.Step;

 class PreView extends Component{

    render()
    {
        return (<div>
                    <Row style={{marginTop:'3em'}}>
                        <Col span={3}/>
                        <Col span={18}>
                            {
                             this.props.params.kind=='0'? 
                                <Steps current={1}>
                                    <Step title="报文编辑" description="编辑报文栏位值" />
                                    <Step title="预览报文" description="预览报文" />
                                    <Step title="编辑完成" description="已完成提交" />
                                </Steps>
                                :
                                <Steps current={2}>
                                    <Step title="选择类型" description="选择报文类型" />
                                    <Step title="报文编辑" description="编辑报文栏位值" />
                                    <Step title="预览报文" description="预览报文" />
                                    <Step title="编辑完成" description="已完成提交" />
                                </Steps>
                            }
                        </Col>
                        <Col span={3}/>
                    </Row>
                    
                    <Row>
                        <Col span={3}>
                        </Col>
                        <Col span={18}>
                        {/*onChange={e=>this.props.actions.updateSwiftMessage(e.target.value)}*/}
                            <Input type="textarea" readOnly="readonly" value={this.props.value} rows={20} cols={50} />
                        </Col>
                        <Col span={3}>
                        </Col>
                    </Row>
                    <Row style={{marginTop:'3em'}}>
                        <Col span={24} style={{textAlign:'center'}}>
                            <Button  type="primary"   icon="check" title="save" style={{marginRight:'1em'}} onClick={()=>this.props.history.push(`result/${this.props.params.kind}`)} >Save</Button>
                            <Button  type="dangerous"   icon="cross" title="cancel" onClick={()=>this.props.history.goBack()}>Return</Button>
                        </Col>
                    </Row>
            </div>
            )
    }
} 

const mapStateToProps = (state) => {
  const {swift_message} = state.swift;
  return {
    value:swift_message
  };
};

function mapDispatchToProps(dispatch) {
  return {
    actions: bindActionCreators({ updateTreeValue,updateRcvBic,initSwiftMessageTree,updateSwiftMessage }, dispatch)
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(PreView)