import React,{Component} from 'react'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Table,Steps,Row,Col} from 'antd'

import { updateTreeValue,updateRcvBic,initSwiftMessageTree ,updateSwiftMessage,initGpiConf} from '../store/modules/swift/swift_action';


const Step = Steps.Step;


export const mty=[
    {mty:"mt103",desp:"MT 103 Single Customer Credit Transfer"},
    {mty:"mt192",desp:"MT 192 Request for Cancellation"},
    {mty:"mt195",desp:"MT 195 Queries"},
    {mty:"mt196",desp:"MT 196 Answers"},
    {mty:"mt199",desp:"MT 199 Free Format Message"},
    {mty:"mt202",desp:"MT 202 General Financial Institution Transfer"},
    {mty:"mt202COV",desp:"MT 202 COV General Financial Institution Transfer"},
    {mty:"mt295",desp:"MT 295 Queries"},
    {mty:"mt296",desp:"MT 296 Answers"},
    {mty:"mt299",desp:"MT 299 Free Format Message"},
    {mty:"mt410",desp:"MT 410 Acknowledgement"},
    {mty:"mt420",desp:"MT 420 Tracer"},
    {mty:"mt422",desp:"MT 422 Advice of Fate and Request for Instructions"},
    {mty:"mt499",desp:"MT 499 Free Format Message"},
    {mty:"mt700",desp:"MT 700 Issue of a Documentary Credit"},
    {mty:"mt701",desp:"MT 701 General Financial Institution Transfer"},
    {mty:"mt707",desp:"MT 707 Amendment to a Documentary Credit"},
    {mty:"mt732",desp:"MT 732 Advice of Discharge"},
    {mty:"mt740",desp:"MT 740 Authorisation to Reimburse"},
    {mty:"mt747",desp:"MT 747 Amendment to an Authorisation to Reimburse"},
    {mty:"mt750",desp:"MT 750 Advice of Discrepancy"},
    {mty:"mt752",desp:"MT 752 Authorisation to Pay, Accept or Negotiate"},
    {mty:"mt754",desp:"MT 754 Advice of Payment/Acceptance/Negotiation"},
    

    {mty:"mt759",desp:"MT 759 Ancillary Trade Structured Message"},

    {mty:"mt760",desp:"MT 760 Guarantee/Standby Letter of Credit"},

    {mty:"mt761",desp:"MT 761 Guarantee/Standby Letter of Credit"},

    {mty:"mt767",desp:"MT 767 Guarantee/Standby Letter of Credit Amendment"},
    {mty:"mt768",desp:"MT 768 Acknowledgement of a Guarantee/Standby Message"},
    {mty:"mt769",desp:"MT 769 Advice of Reduction or Release"},
    {mty:"mt775",desp:"MT 775 Amendment to a Demand Guarantee/Standby Letter of Credit"},
    {mty:"mt799",desp:"MT 799 Free Format Message"},
    {mty:"mt999",desp:"MT 999 Free Format Message"},
]
// const columns = [{
//   title: '创建报文',
//   dataIndex: 'desp',
//   key: 'desp',
//   render:(text,record)=>{
//       return <a href="javascript:void(0);" onClick={()=>{this.props.history.push(`swift/${record.mty}`)}}>Create {record.desp}</a>
//   }
// },
// ]
export   class LeadPage extends Component
{
    columns = [{
        title: '创建报文',
        dataIndex: 'desp',
        key: 'desp',
        render:(text,record)=>{
            return <a href="javascript:void(0);" onClick={()=>{
                this.props.actions.initSwiftMessageTree(null)  //清空
                this.props.actions.initGpiConf({inited:false})
                this.props.history.push(`swift/edit/${this.props.params.mctid||'NONE'}/${record.mty}/NONE`)
                }
                }>Create {record.desp}</a>
        }
        },
    ]

    render()
    {
        return (
        <div>
            <Row style={{marginTop:'3em'}}>
                <Col span={3}/>
                <Col span={18}>
                        <Steps current={0}>
                            <Step title="选择类型" description="选择报文类型" />
                            <Step title="报文编辑" description="编辑报文栏位值" />
                            <Step title="预览报文" description="预览报文" />
                            <Step title="编辑完成" description="已完成提交" />
                        </Steps>
                </Col>
                <Col span={3}/>
            </Row>
            <Row>
                                <Col span={3}/>

            <Col span={18}>
            <Table columns={this.columns} dataSource={mty} />
            </Col>
                            <Col span={3}/>

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

function mapDispatchToProps(dispatch) {
  return {
    actions: bindActionCreators({ initSwiftMessageTree,initGpiConf }, dispatch)
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(LeadPage)