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)
    }
    onRevtxt_buttxmsel= ()=>{
        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="Declaration of" trn="gitame" />   
                            </Col>
                            <Col span={11}>
                                <TextAreaItem InputProps={bind("blk_revtxt")} desp="Declaration of Indemnity Text" path="/gidgrp/blk/revtxt"/>
                            </Col>
                            <Col span={2} offset={1}>
                                <Button  type="primary" icon="search" onClick={this.onRevtxt_buttxmsel} desp="..." path="/gitp/revtxt/buttxmsel">
                                    <Label   itext="..."/>
                                </Button>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            
                        </Row>
                    </Col>
                </Row>       
                            	
                           {/*<Label itext="Indemnity" trn="gitame" />	*/}  

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Additional Amount" trn="gitame" />    
                            </Col>
                            <Col span={6}>
                                <SelectItem InputProps={bind("max2_cur")} code={CodeTable.curtxt}  desp="Currency" path="/gidgrp/cbs/max2/cur"/>
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("max2_amt")}   desp="Balance" path="/gidgrp/cbs/max2/amt" />
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Open Add. Amount" trn="gitame" /> 
                            </Col>
                            <Col span={6}>
                                <SelectItem InputProps={bind("opn2_cur")} code={CodeTable.curtxt}  desp="Currency" path="/gidgrp/cbs/opn2/cur"/>
                            </Col>
                            <Col span={7} offset={1}>
                                <InputItem InputProps={bind("opn2_amt")}   desp="Balance" path="/gidgrp/cbs/opn2/amt" />
                            </Col>
                        </Row>
                    </Col>
                </Row>     

                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Covered" trn="gitame" />  
                            </Col>
                            <Col span={14}>
                                <TextAreaItem InputProps={bind("blk_addamtcov")} desp="Additional Amount Covered" path="/gidgrp/blk/addamtcov"/>
                            </Col>
                        </Row>
                    </Col>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label itext="Amendments so Far" trn="gitame" />    
                            </Col>
                            <Col span={14}>
                                <TextAreaItem InputProps={bind("blk_gidtxtame")} desp="History of Amendments" path="/gidgrp/blk/gidtxtame"/>
                            </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>
		)
	}
}
