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

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


const Step = Steps.Step;


export const mty=[
    {mty:"mt101",desp:"MT 101 Request for Transfer"},
    {mty:"mt103",desp:"MT 103 Single Customer Credit Transfer"},
    {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:"mt210",desp:"MT 210 Notice to Receive"},
    {mty:"mt292",desp:"MT 292 Request for Cancellation"},
    {mty:"mt295",desp:"MT 295 Queries"},
    {mty:"mt296",desp:"MT 296 Answers"},
    {mty:"mt299",desp:"MT 299 Free Format Message"},

    {mty:"mt300",desp:"MT 300 Foreign Exchange Confirmation"},
    {mty:"mt305",desp:"MT 305 Foreign Currency Option Confirmation"},
    {mty:"mt320",desp:"MT 320 Fixed Loan/Deposit Confirmation"},
    {mty:"mt360",desp:"MT 360 Single Currency Interest Rate Derivative Confirmation"},
    {mty:"mt400",desp:"MT 400 Advice of Payment"},
    
    {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:"mt541",desp:"MT 541 Receive Against Payment"},
    {mty:"mt543",desp:"MT 543 Deliver Against Payment"},
    {mty:"mt599",desp:"MT 599 Free Format Message"},

    
    {mty:"mt600",desp:"MT 600 Commodity Trade Confirmation"},
    {mty:"mt605",desp:"MT 605 Commodity Notice to Receive"},
    {mty:"mt607",desp:"MT 607 Commodity Credit Advice"},
    {mty:"mt620",desp:"MT 620 Commodity Fixed Loan/Deposit Confirmation"},

    {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:"mt710",desp:"MT 710 Advice of a Third Bank's or a Non-Bank's Documentary Credit"},
    {mty:"mt720",desp:"MT 720 Transfer of a Documentary Credit"},
    {mty:"mt730",desp:"MT 730 Acknowledgement"},


    {mty:"mt732",desp:"MT 732 Advice of Discharge"},
    {mty:"mt740",desp:"MT 740 Authorisation to Reimburse"},

    {mty:"mt742",desp:"MT 742 Reimbursement Claim"},

    {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:"mt756",desp:"MT 756 Advice of Reimbursement or Payment"},


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

    {mty:"mt760",desp:"MT 760 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:"mt799",desp:"MT 799 Free Format Message"},
    {mty:"mt940",desp:"MT 940 Customer Statement Message"},
    {mty:"mt950",desp:"MT 950 Statement Message"},
    {mty:"mt999",desp:"MT 999 Free Format Message"},
    {mty:"mt1000",desp:"MT 1000 TEST"},
        
]
// 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
{
    constructor(props)
    {
        super(props)
        this.state={fil:''}
    }
    columns = [{
        title: <div>
            <Input placeholder="输入报文类型数字,快速筛选"  size="large" onChange={e=>this.setState({fil:e.target.value})}/>
            </div>,
        dataIndex: 'desp',
        key: 'desp',
        render:(text,record)=>{
            return <a href="javascript:void(0);" onClick={()=>{
                this.props.actions.initSwiftMessageTree(null)  //清空
                this.props.history.push(`swift/edit/${this.props.params.mctid?this.props.params.mctid+'/':''}${record.mty}`)
                }
                }>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={this.state.fil?mty.filter(item=>item.mty.indexOf('mt'+this.state.fil)==0):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 }, dispatch)
  };
}

export default connect(mapStateToProps, mapDispatchToProps)(LeadPage)