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)
    }
	


    //按钮事件
    onAmebut_buttxmsel= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('gitame/amebut_buttxmsel',{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' }}>
                
                <Business  wrappedComponentRef={ref => (this.com = ref)} page={this} steps={this.props.steps} extra={this.props.extra}  model={this.model} />
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                {/* 业务编号 */}
                                <Label itext="Reference" trn="gitame" />
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="Reference" path="/gidgrp/rec/ownref" />
                            </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="Amendment Date" trn="gitame" />
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="Reference" path="/gidgrp/rec/ownref" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Amend. No Receiv." trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("swiadd_amenbr")}   desp="Number of Amendment" path="/gitamep/swiadd/amenbr" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Order from" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("gitamep_orddat")}  desp="Order From" path="/gitamep/orddat" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Actual Amendment No" trn="gitame" />     
                            </Col>
                            <Col span={14}>
                                <InputItem InputProps={bind("gitamep_amenbr")}   desp="Number of Amendment" path="/gitamep/amenbr" />
                            </Col>
                        </Row>
                    </Col>
                </Row>

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Old Validity" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("expdat1")}  desp="Valid until" path="/oldgidgrp/rec/expdat" />
                            </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("gitamep_amenumjmg")}  maxLength={2}  desp="变更次数" path="/gitamep/amenumjmg" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
	
	           <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Old Guarantee Amt." trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("liadat1")}  desp="Liability until" path="/oldgidgrp/rec/liadat" />
                            </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("vrfdat")}  desp="核销日期" path="/gidgrp/rec/vrfdat" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
	
	           <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>   
                                <Label itext="Old Liability " trn="gitame" />   
                            </Col>
                            <Col span={6}>
                                <InputItem InputProps={bind("max1_cur")}  maxLength={3}  desp="Currency" path="/oldgidgrp/cbs/max/cur" />
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("max1_amt")}   desp="Balance" path="/oldgidgrp/cbs/max/amt" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="New Validity" trn="gitame" /> 
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("swiadd_newexpdat")}  desp="New Expiry Date" path="/gitamep/swiadd/newexpdat" />
                            </Col>
                        </Row>
                    </Col>
                </Row>

                            {/*	<Label itext="Amended" trn="gitame" />	*/}

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>   
                                <Label itext="Guarantee Amount" trn="gitame" /> 
                            </Col>
                            <Col span={6}>
                                <InputItem InputProps={bind("swiadd_amecur")}  maxLength={3}  desp="Currency of amended amount" path="/gitamep/swiadd/amecur" />
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("swiadd_ameamt")}   desp="Amended Amount" path="/gitamep/swiadd/ameamt" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="New Liability" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <DatePickerItem InputProps={bind("swiadd_newliadat")}  desp="New Liability Date" path="/gitamep/swiadd/newliadat" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
           	
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>   
                                <Label itext="Amounts Covered" trn="gitame" />  
                            </Col>
                            <Col span={6}>
                                <InputItem InputProps={bind("swiadd_newcur")}  maxLength={3}  desp="Currency of new amount" path="/gitamep/swiadd/newcur" />
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("swiadd_newamt")}   desp="New amount" path="/gitamep/swiadd/newamt" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Adding amount" trn="gitame" />    
                            </Col>
                            <Col span={6}>
                                <InputItem InputProps={bind("max2_cur")}  maxLength={3}  desp="Currency" path="/gidgrp/cbs/max2/cur" />
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("swiadd_addamt")}   desp="Additional Amount" path="/gitamep/swiadd/addamt" />
                            </Col>
                        </Row>
                    </Col>
                </Row>

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>   
                                <TextAreaItem InputProps={bind("swiadd_addamtcov")} desp="Additional Amount Covered" path="/gitamep/swiadd/addamtcov"/>
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("swiadd_newexpflg")}  desp="Unlimited Validity" path="/gitamep/swiadd/newexpflg" />
                            </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={5} offset={2}>
                                <Label itext="Amendments" trn="gitame" />   
                            </Col>
                            <Col span={14}>
                                <TextAreaItem InputProps={bind("gitamep_ametxt")} desp="Amendment :77C:" path="/gitamep/ametxt"/>
                            </Col>
                        </Row>
                    </Col>
                </Row>          	

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>   
                                <SelectItem InputProps={bind("gitamep_ramrol")}   desp="Request of Amendment send to" path="/gitamep/ramrol"/>
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("gitamep_cre767flg")}  desp="Create Amendment Message" path="/gitamep/cre767flg" />
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("gitamep_prtflg")}  desp="choose full text" path="/gitamep/prtflg" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={14} offset={2}>
                                <TextAreaItem InputProps={bind("swiadd_ameblk")} desp="Text for Amendments" path="/gitamep/swiadd/ameblk"/>
                            </Col>
                            <Col span={2} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onAmebut_buttxmsel} desp="..." path="/gitamep/amebut/buttxmsel">
                                    <Label   itext="..."/>
                                </Button>
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("gitamep_clsclmflg")}  desp="Close picked up claim now" path="/gitamep/clsclmflg" />
                            </Col>
                            <Col span={1} offset={1}>
                                <CheckboxItem InputProps={bind("gitamep_abrflg")}  desp="agreement of bene. required" path="/gitamep/abrflg" />
                            </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>
		)
	}
}
