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)
    }
    //查询
    onAplp_sel= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('gitame/aplp_sel',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    Notification.success({message:'数据提交成功!'})
                    
                }
                else
                {
                	Notification.error({message:'服务端请求失败!'})
                }
                //余下逻辑处理
                    
        })
    }
  
    //查询
    onBenp_sel= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('gitame/benp_sel',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    Notification.success({message:'数据提交成功!'})
                    
                }
                else
                {
                	Notification.error({message:'服务端请求失败!'})
                }
                //余下逻辑处理
                    
        })
    }
    //获取ref
    onGetref= async ()=>{
        this.formBlur=true  //已触发表单提交处理
        const rtnmsg = await Api.post('gitame/getref',{data:this.model})
        if(rtnmsg.retcod == SUCCESS)
        {
            Notification.success({message:'数据提交成功!'})
            this.model.ownref = rtnmsg.data.ownref;
        }
        else
        {
        	Notification.error({message:'服务端请求失败!'})
        }
        //余下逻辑处理

    }
    onAdvp_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="Reference" trn="gitame" />    
                            </Col>
                            <Col span={10}>
                                <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="Reference" path="/gidgrp/rec/ownref" />
                            </Col>
                            <Col span={4} offset={1}>
                                <Button  type="primary"  onClick={this.onGetref} desp="Get Ref." path="/mtabut/getref">
                                    <Label   itext="获取"/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Name" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("nam")}  maxLength={40}  desp="Externally Displayed Name to Identify the Contract" path="/gidgrp/rec/nam" />
                            </Col>
                        </Row>
                    </Col>
                </Row>

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Responsible User" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("usr_nam")}  maxLength={8}  desp="用户ID" path="/gitp//sysmod/usr/nam" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Applicant  Ref." trn="gitame" />  
                            </Col>
                            <Col span={10}>
                                <InputItem InputProps={bind("pts1_ref")}  maxLength={16}  desp="参考号" path="/gidgrp/apl/pts/ref" />
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("resflg")}  desp="Reserved Contract" path="/gidgrp/rec/resflg" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
                            	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Guarantee Amount" trn="gitame" /> 
                            </Col>
                            <Col span={6}>
                                <SelectItem InputProps={bind("max_cur")} code={CodeTable.curtxt}  desp="Currency" path="/gidgrp/cbs/max/cur"/>
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("max_amt")}   desp="Balance" path="/gidgrp/cbs/max/amt" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>
                                <InputItem InputProps={bind("pts1_extkey")}  maxLength={16}  desp="客户编号" path="/gidgrp/apl/pts/extkey" />
                            </Col>
                            <Col span={5} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onAplp_sel} desp="查询" path="/gitp/aplp/sel">
                                    <Label   itext="查询"/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                </Row>           	
          	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Open Amount" trn="gitame" />  
                            </Col>
                            <Col span={6}>
                                <SelectItem InputProps={bind("opn1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/gidgrp/cbs/opn1/cur"/>
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("opn1_amt")}   desp="Balance" path="/gidgrp/cbs/opn1/amt" />
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("aammod_addamtflg")}  desp="Add. Amount" path="/gitp/aamp/aammod/addamtflg" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={19} offset={2}>
                                <TextAreaItem InputProps={bind("pts1_adrblk")} desp="SWIFT地址" path="/gidgrp/apl/pts/adrblk"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>               	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Request" value={this.model.gitp_drpreflglab}   desp="Label for Type of Request" path="/gitp/drpreflglab" />
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("gitp_drpreflg")} code={CodeTable.drpreflg}  desp="Type of Request" path="/gitp/drpreflg"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Handling Type" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("hndtyp")} code={CodeTable.hndtyp}  desp="Handling Type" path="/gidgrp/rec/hndtyp"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>            	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Type of Undertaking" trn="gitame" />  
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("gartyp")} code={CodeTable.typgar}  desp="Type of Undertaking" path="/gidgrp/rec/gartyp"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="境内外对手行代码" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("oppbnk")}  maxLength={12}  desp="境内外对手行代码" path="/gidgrp/rec/oppbnk" />
                            </Col>
                        </Row>
                    </Col>
                </Row>                      	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="面函标题" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("gitp_lettername")}  maxLength={60}  desp="面函标题" path="/gitp/lettername" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Adv/Rcv bank     Ref." trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("pts_ref")}  maxLength={16}  desp="参考号" path="/gidgrp/adv/pts/ref" />
                            </Col>
                        </Row>
                    </Col>
                </Row>              	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Applicable Rules" trn="gitame" /> 
                            </Col>
                            <Col span={6}>
                                <SelectItem InputProps={bind("blk_apprul")} code={CodeTable.gitapprul}  desp="Applicable Rules" path="/gidgrp/blk/apprul"/>
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("blk_apprultxt")}  maxLength={35}  desp="Specification of Applicable Rule" path="/gidgrp/blk/apprultxt" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>
                                <InputItem InputProps={bind("pts_extkey")}  maxLength={16}  desp="客户编号" path="/gidgrp/adv/pts/extkey" />
                            </Col>
                            <Col span={5} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onAdvp_sel} desp="查询" path="/gitp/advp/sel">
                                    <Label   itext="查询"/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                </Row>                  	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Language of Undertak." trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("giduil")} code={CodeTable.uiltxt}  desp="Guarantee Language" path="/gidgrp/rec/giduil"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={19} offset={2}>
                                <TextAreaItem InputProps={bind("pts_adrblk")} desp="SWIFT地址" path="/gidgrp/adv/pts/adrblk"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>     	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Choice of Text" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("gtxinr")}   desp="INR of Generating Text" path="/gidgrp/rec/gtxinr"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="特殊保函类型" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("ghd_segtyp")}   desp="特殊保函类型" path="/gidgrp/ghd/segtyp"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>                 	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="是否分离式保函" trn="gitame" />  
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("fenlishi")} code={CodeTable.fenlishi}  desp="是否分离式保函" path="/gidgrp/rec/fenlishi"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Order Date" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("orddat")}  desp="Date of Customer's Order" path="/gidgrp/rec/orddat" />
                            </Col>
                        </Row>
                    </Col>
                </Row>                  	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Issuance Date" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("opndat")}  desp="Valid from" path="/gidgrp/rec/opndat" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Beneficiary  Ref." trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("pts2_ref")}  maxLength={16}  desp="参考号" path="/gidgrp/ben/pts/ref" />
                            </Col>
                        </Row>
                    </Col>
                </Row>               	
       	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Validity until" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("expdat")}  desp="Valid until" path="/gidgrp/rec/expdat" />
                            </Col>
                            <Col span={2} offset={1}>
                                <CheckboxItem InputProps={bind("expflg")}  desp="Unlimited Guarantee" path="/gidgrp/rec/expflg" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>
                                <InputItem InputProps={bind("pts2_extkey")}  maxLength={16}  desp="客户编号" path="/gidgrp/ben/pts/extkey" />
                            </Col>
                            <Col span={5} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onBenp_sel} desp="查询" path="/gitp/benp/sel">
                                    <Label   itext="查询"/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                </Row> 
                            	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Our Liability until" trn="gitame" />  
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("liadat")}  desp="Liability until" path="/gidgrp/rec/liadat" />
                            </Col>
                            <Col span={2} offset={1}>
                                <CheckboxItem InputProps={bind("liaflg")}  desp="Unlimited Liability" path="/gidgrp/rec/liaflg" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={19} offset={2}>
                                <TextAreaItem InputProps={bind("pts2_adrblk")} desp="SWIFT地址" path="/gidgrp/ben/pts/adrblk"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>             	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Old Reference" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("oldref")}  maxLength={16}  desp="Old Reference" path="/gidgrp/rec/oldref" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="保函生效日" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("inudat")}  desp="Inure Date" path="/gidgrp/rec/inudat" />
                            </Col>
                        </Row>
                    </Col>
                </Row>              
            	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Mortgage Flag" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("guaflg")} code={CodeTable.guaflg}  desp="Mortgage Flag" path="/gidgrp/rec/guaflg"/>
                            </Col>
                            <Col span={2} offset={1}>
                                <CheckboxItem InputProps={bind("teskeyunc")}  desp="Test Key Unconfirmity" path="/gidgrp/rec/teskeyunc" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="是否对外担保" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <SelectItem InputProps={bind("fingua")} code={CodeTable.fingua}  desp="是否对外担保" path="/gidgrp/rec/fingua"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>  

           	    <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="担保类型" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("cfaguatyp")}  maxLength={4}  desp="对外担保类型" path="/gidgrp/rec/cfaguatyp" />
                            </Col>
                            <Col span={2} offset={1}>
                                <CheckboxItem InputProps={bind("cmtflg")}  desp="跨境人民币保函" path="/gidgrp/rec/cmtflg" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            
                        </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>
		)
	}
}
