import React,{Component,Fragment} from 'react'
import PropTypes from 'prop-types'
import {Page,Validator,Notification,FormItem,BottomBtn,DatePickerItem,TextAreaItem,CheckboxItem,Checkbox,
    InputItem,Input,Bind,SelectItem,Button,Label,Image,Table} from '@/components/Common-Library'
import Api from '@/service/api'
import mGitame from '../model'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable,runInAction } from 'mobx'
import {Row ,Col} from 'antd'
import Business from '@/views/Public/Business'


const CodeTable = CodeTableFactory.getInstance()


@inject('UserContext')
@inject('i18n')
@observer
export default class GitameScreen extends Page
{
    static childContextTypes = {
        trn: PropTypes.string,
    }
    getChildContext () {
        return {trn:'gitame'}
    }
    
    
    @observable
    formBlur=false

    constructor(props)
    {
        super(props)
        this.model = props.model    
        this.bind = Bind.bind(this)
    }

    onConp_sel= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('gitame/conp_sel',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    Notification.success({message:'数据提交成功!'})
                    
                }
                else
                {
                	Notification.error({message:'服务端请求失败!'})
                }
                //余下逻辑处理
                    
        })
    }
    onIssp_sel= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('gitame/issp_sel',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    Notification.success({message:'数据提交成功!'})
                    
                }
                else
                {
                	Notification.error({message:'服务端请求失败!'})
                }
                //余下逻辑处理
                    
        })
    }
    

    //交易内实现
    renderPage(){
    	const bind = this.bind
        const {i18n} = this.props
             
        return (
        	<div style={{ position: 'relative' }}>
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Confirmation Status" trn="gitame" />  
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("cnfsta")} code={CodeTable.cnfsta}  desp="Confirmation Status" path="/gidgrp/rec/cnfsta"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            
                        </Row>
                    </Col>
                </Row>
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Confirmation Amount" trn="gitame" />  
                            </Col>
                            <Col span={4}>
                                <InputItem InputProps={bind("cnf_cur")}  maxLength={3}  desp="Currency" path="/gidgrp/cbs/cnf/cur" />
                            </Col>
                            <Col span={4} offset={1}>
                                <InputItem InputProps={bind("cnf_amt")}   desp="Balance" path="/gidgrp/cbs/cnf/amt" />
                            </Col>
                            <Col span={1} offset={1}>
                                <Label itext="or" trn="gitame" />   
                            </Col>
                            <Col span={4}>
                                <InputItem InputProps={bind("partcon")}   desp="Partial Confirmation" path="/gidgrp/rec/partcon" />
                            </Col>
                            <Col span={1} offset={1}>
                                <Label itext="%" trn="gitame" />    
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Confirmed on" trn="gitame" /> 
                            </Col>
                            <Col span={14}> 
                                <DatePickerItem InputProps={bind("cnfdat")}  desp="Confirmation Date" path="/gidgrp/rec/cnfdat" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
                          {/*    <Label itext="Confirming Bank" trn="gitame" />  */}  
                            	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Confirming Bank's Ref.   " trn="gitame" />    
                            </Col>
                            <Col span={6}>
                                <InputItem InputProps={bind("pts3_ref")}  maxLength={16}  desp="参考号" path="/gidgrp/con/pts/ref" />
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("pts4_ref")}  maxLength={16}  desp="参考号" path="/gidgrp/iss/pts/ref" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                            </Col>
                            <Col span={14}>
                            </Col>
                        </Row>
                    </Col>
                </Row>
                            	                 	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>
                                <InputItem InputProps={bind("pts3_extkey")}  maxLength={16}  desp="客户编号" path="/gidgrp/con/pts/extkey" />
                            </Col>
                            <Col span={5} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onConp_sel} desp="查询" path="/gitp/conp/sel">
                                    <Label   itext="查询"/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>
                                <InputItem InputProps={bind("pts4_extkey")}  maxLength={16}  desp="客户编号" path="/gidgrp/iss/pts/extkey" />
                            </Col>
                            <Col span={5} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onIssp_sel} desp="查询" path="/gitp/issp/sel">
                                    <Label   itext="查询"/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                </Row>
                            	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={19} offset={2}>
                                <TextAreaItem InputProps={bind("pts3_adrblk")} desp="SWIFT地址" path="/gidgrp/con/pts/adrblk"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={19} offset={2}>
                                <TextAreaItem InputProps={bind("pts4_adrblk")} desp="SWIFT地址" path="/gidgrp/iss/pts/adrblk"/>
                            </Col>
                        </Row>
                    </Col>
                </Row> 
  	
                {/*            	<Label itext="Guarantee Text " trn="gitame" />	

                            	
                            	<Label itext="before this" trn="gitame" />	

                            	
                            	<Label itext="Amendment" trn="gitame" />	

                    
                            	<Label itext="备注 R=接受, J=拒绝, I=增额修改, D=减额修改" trn="gitame" />
                            	<Button  type="primary" icon="save"
                            		  onClick={this.onSav} desp="Save" path="/mtabut/sav">
                            		<Label   itext="提交"/>
                            	</Button>
                            	<Button  type="primary"  onClick={this.onChk} desp="Check" path="/mtabut/chk">
                            		<Label   itext="检核"/>
                            	</Button>
                            	<Button  type="primary"  onClick={this.onPed} desp="暂存" path="/mtabut/ped">
                            		<Label   itext="暂存"/>
                            	</Button>
                            	<Button  type="primary"  onClick={this.onExi} desp="Exit" path="/mtabut/exi">
                            		<Label   itext="退出"/>
                            	</Button>  */}
                {/* 底部按钮 */}
                <BottomBtn _this={this} />
		</div>
		)
	}
}
