Result.js 4.39 KB
Newer Older
fukai committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
import React,{Component} from 'react'
import {bindActionCreators} from 'redux';
import {connect} from 'react-redux';
import {Input,Table,Steps,Row,Col,Progress,Spin} from 'antd'
import { updateTreeValue,updateRcvBic,initSwiftMessageTree } from '../store/modules/swift/swift_action';

import ServiceAPI from './ServiceAPI'

const Step = Steps.Step;

 class Result extends Component{

    constructor(props)
    {
        super(props)
        this.state={isOK:-1}
    }
    componentWillMount()
    {
        //提交报文
fukai committed
21
        let datas = {MSGTYP:this.props.extra.msgtyp.substring(2).toUpperCase(),SNDKEY:this.props.sndkey,MCTSWTID:this.props.extra.mctid}
fukai committed
22 23
        //取出20,21
        let tags = this.props.swift_message_tree.Tags
fukai committed
24 25
        if(tags.length && tags[0].seqlist)
            tags = tags[0].seqs[0]
fukai committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39
        if(tags.length && tags[0].tag == '20')
            datas.F20=tags[0].tagValue[1]
        if(tags.length > 1 && tags[1].tag == '21')
            datas.F21=tags[1].tagValue[1]
        ServiceAPI.saveMessage(
            // {
                
            //     smhinr:this.props.extra.smhinr,
            //     sf2msg:this.props.swift_message,
            //     datas:{
            //         msgtyp:this.props.extra.msgtyp,
            //         sndkey:this.props.rcv_bic
            //     }
            // }
fukai committed
40
            `smhinr=${this.props.extra.smhinr?this.props.extra.smhinr:''}&user=${this.props.extra.mctid||"NONE" }&sf2msg=${encodeURIComponent(this.props.swift_message)}`
fukai committed
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
            ).then(data=>{
                if(typeof data=='string')
                {
                    data = JSON.parse(data)
                }
                if(data.errorCode == '0000')
                    this.setState({isOK:0}) 
                else
                    this.setState({isOK:0,error:"保存失败!"}) 
        }).catch(reason=>{
            console.log(reason)
            this.setState({isOK:0,error:'保存失败!'})
        });
    }
    
    render()
    {

        return (<div>
                    <Row style={{marginTop:'3em'}}>
                        <Col span={3}/>
                        <Col span={18}>
                            {
                             this.props.params.kind=='0'? 
                                <Steps current={2}>
                                    <Step title="报文编辑" description="编辑报文栏位值" />
                                    <Step title="预览报文" description="预览报文" />
                                    <Step title="编辑完成" description="已完成提交" />
                                </Steps>
                                :
                                <Steps current={3}>
                                    <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} style={{textAlign:'center',paddingTop:'5em'}}>
                            {
                            this.state.isOK!==0?
                            <Spin size="large" />:
                            <Progress type="circle" percent={!this.state.error?100:70} status={this.state.error?"exception":null} format={() => !this.state.error?'Success!':'Error!'} />
                            }
                            {/*<h3 style={{display:this.state.error?'block':'none',color:'red'}}>{this.state.error}</h3>*/}
                        </Col>
                        <Col span={3}></Col>
                    </Row>
                    
            </div>
            )
    }
} 

const mapStateToProps = (state) => {
  const {swift_message,extra,snd_bic_info,swift_message_tree} = state.swift;
  return {
        swift_message,extra,sndkey:snd_bic_info.snd_bic,swift_message_tree
  };
};

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

export default connect(mapStateToProps, mapDispatchToProps)(Result)