import React, { Component, Fragment } from 'react'
import {
	Page, Validator, Notification, FormItem, BottomBtn,
	InputItem, Input, Bind, SelectItem, Button, Label, DatePickerItem, Section, Table, TextArea, ConfirmButton, Steps,AmountLabel,TextAreaItem
} from '@/components/Common-Library'
import Api from '@/service/api'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable } from 'mobx'
import { Row, Col, Popconfirm, Modal,Spin } from 'antd';
import { ButtonModal, ModalTest } from '@/components/Business-Library'
import ELCMessage from '@/components/Business-Library/ELCMessage'
import { Link, withRouter } from 'react-router-dom'
import { height } from 'window-size';
import Business from '@/views/Public/Business'
import { TableExpansion } from '@/components/Business-Library'
import Ptspta1 from '@/views/Public/Ptspta1'
import mElschk from '../model'
const { Pre, Next, StepWrapper } = Steps
const CodeTable = CodeTableFactory.getInstance()
const confirm = Modal.confirm
@withRouter
@inject('UserContext')
@inject('i18n')
@observer
export default class Fasongcreen extends Page
{

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

    onComchk_show= ()=>{
		this.formBlur=true  //已触发表单提交处理
		Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
				if(errors)
					return 
				const rtnmsg = await Api.post('elschk/comchk_show',{data:this.model})
				if(rtnmsg.retcod == SUCCESS)
				{
					Modal.info({
					  title: '电证报文', content: <div style={{ height: 400, overflow: 'auto' }}><ELCMessage mty={"elcs.721.001.01"} message={rtnmsg.data["\\chkp\\elcmod\\msgdat"]} /></div>,
					  width: 1000,
					})
				}
				else
				{
				  Notification.error({message:'服务端请求失败!'})
				}
				//余下逻辑处理
					
		})
    }
    onSend= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('elschk/send',{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)}  extra={this.props.extra} model={this.model} />
        {/* 第一行 */}
        <Row>
            <Col span={12}>
              <Row className="row">
                <Col span={10} offset={2}>
                <Label itext="信用证业务对账申请报文" />
                </Col>
             
              </Row>
            </Col>

          </Row>

		  <Row>
          
            <Col span={12}>
              <Row className="row">
                <Col span={5} offset={2}>
                <Label itext="对账日期" />
                </Col>
                <Col span={14}>
				<DatePickerItem InputProps={bind("comchk_chkdat")}  desp="对账日期" path="/chkp/comchk/chkdat" />
                </Col>
              </Row>
            </Col>
          </Row>
		  <br/>
        <Row type="flex" justify="center">
              <Col>
                <div className='button2'>
                  <ConfirmButton
                    type="primary"
                    onOK={this.onSend}
                    message="确定发送？"
                  >
                    <Label i18nId="发送" />
                  </ConfirmButton>
                </div>
				<div className='button2'>
                  <Button type="primary" onClick={this.onComchk_show}>
                    <Label itext="展示报文" />
                  </Button>
                </div>
           
              </Col>
            </Row>
       

    </div >)
    }
}