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:"mt190",desp:"MT 190 Advice of Charges, Interest and Other Adjustments"},
    {mty:"mt191",desp:"MT 191 Request for Payment of Charges, Interest and Other Expenses"},
    {mty:"mt192",desp:"MT 192 Request for Cancellation"},
    {mty:"mt195",desp:"MT 195 Queries"},
    {mty:"mt196",desp:"MT 196 Answers"},
    {mty:"mt198",desp:"MT 198 Proprietary Message"},
    {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:"mt298",desp:"MT 298 Proprietary Message"},
    {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:"mt399",desp:"MT 399 Free Format Message"},
    
    {mty:"mt400",desp:"MT 400 Advice of Payment"},
    {mty:"mt410",desp:"MT 410 Acknowledgement"},
    {mty:"mt412",desp:"MT 412 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:"mt535",desp:"MT 535 Statement of Holdings"},
    {mty:"mt536",desp:"MT 536 Statement of Transactions"},
    {mty:"mt537",desp:"MT 537 Statement of Pending Transactions"},
    {mty:"mt538",desp:"MT 538 Statement of Intra-Position Advices"},
    {mty:"mt540",desp:"MT 540 Receive Free"},
    {mty:"mt541",desp:"MT 541 Receive Against Payment"},
    {mty:"mt542",desp:"MT 542 Deliver Free"},
    {mty:"mt543",desp:"MT 543 Deliver Against Payment"},
    {mty:"mt544",desp:"MT 544 Receive Free Confirmation"},
    {mty:"mt545",desp:"MT 545 Receive Against Payment Confirmation"},
    {mty:"mt546",desp:"MT 546 Deliver Free Confirmation"},
    {mty:"mt547",desp:"MT 547 Deliver Against Payment Confirmation"},
    {mty:"mt548",desp:"MT 548 Settlement Status and Processing Advice"},
    {mty:"mt564",desp:"MT 564 Corporate Action Notification"},
    {mty:"mt565",desp:"MT 565 Corporate Action Instruction"},
    {mty:"mt566",desp:"MT 566 Corporate Action Confirmation"},
    {mty:"mt567",desp:"MT 567 Corporate Action Status and Processing Advice"},
    */
    {mty:"mt592",desp:"MT 592 Request for Cancellation"},
    {mty:"mt595",desp:"MT 595 Queries"},
    {mty:"mt596",desp:"MT 596 Answers"},
    {mty:"mt598",desp:"MT 598 Proprietary Message"},
    {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:"mt711",desp:"MT 711 Advice of a Third Bank's or a Non-Bank's Documentary Credit"},
    
    {mty:"mt720",desp:"MT 720 Transfer of a Documentary Credit"},
    {mty:"mt721",desp:"MT 721 Transfer of a Documentary Credit"},
    
    {mty:"mt730",desp:"MT 730 Acknowledgement"},
    {mty:"mt732",desp:"MT 732 Advice of Discharge"},
    {mty:"mt734",desp:"MT 734 Advice of Refusal"},
    
    {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:"mt995",desp:"MT 995 Queries"},
    {mty:"mt996",desp:"MT 996 Answers"},
    {mty:"mt998",desp:"MT 998 Proprietary 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)