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

import { Card } from 'antd'

import Ovwp from './Ovwp'

import Fee from '@/views/Public/Fee'
import Gle from '@/views/Public/Gle'
import Papper from '@/views/Public/Papper'

const CodeTable = CodeTableFactory.getInstance()
const StepItem=Steps.Item;

@inject('UserContext')
@inject('i18n')
@observer
export default class BmtfreScreen extends Page
{
    static childContextTypes = {
        trn: PropTypes.string,
    }
    getChildContext () {
        return {trn:'bmtfre'}
    }
    
    
    @observable
		formBlur=false
		
		@observable
		extra = { inifrm: 'bmtfre', sptinr: '', oldinr:'', bchlevelLst: [] };

    constructor(props)
    {
        super(props)
        this.model = new mBmtfre()    
				this.bind = Bind.bind(this)
				this.state={
          flag:true
        }
    }
	
		async componentWillMount() 
		{
			/*
			*添加初始化代码
      */
      let bmdinr = '';
      //如果携带参数，接收参数再发请求
      if(this.props.location.query){
        if(this.props.location.query.from=="sptsel"){
          //经办夹进入
          this.extra.sptinr = this.props.location.query.sptinr
        }else{
          bmdinr = this.props.location.query.bmdinr
        }
      }
      const rtnmsg = await Api.post(this.extra.inifrm + '/init', { params: { sptinr:this.extra.sptinr, bmdinr } })
			if (rtnmsg.retcod == SUCCESS) {
        Object.assign(this.model, rtnmsg.data)
        //给oldinr赋值为当前inr，为修改、退回等做准备
				this.extra.oldinr = rtnmsg.data.inr;
				this.setState({ flag: false });
			}
			else {
				Notification.error({ message: '服务端请求失败!' })
			}
	
			//快照模式下，不必开启校验，否则，静默校验，和记录变动
			!this.loadDisplay() && this.model.openMonitor() //开启校验
	
		}


    componentWillUnmount()
    {
        this.model.stopMonitor&&this.model.stopMonitor()//关闭校验
    }


    //交易内实现
    renderPage(){
    	const bind = this.bind
      const {i18n} = this.props
			
			return (
				<Card title="自由报文" size="small" className="transTitle">
					<Steps>
					
						<StepItem title="概要">
							<Ovwp model={this.model} extra={this.extra} flag={this.state.flag} />
						</StepItem>
			
						<StepItem title="费用">
							<Fee model={this.model} extra={this.extra} />
						</StepItem>
						<StepItem title="会计分录">
							<Gle model={this.model} extra={this.extra} />
						</StepItem>
						<StepItem title="面函">
							<Papper model={this.model} extra={this.extra} />
						</StepItem>
					</Steps>
				</Card>
			)






  //       return (
  //       	<div className="transPage">
	// <Button  type="primary"  onClick={this.onUsrcon} desp="登记" path="/mtabut/usrcon">
	// 	<Label   itext="登记"/>
	// </Button>
	// <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>

	
	// <Label itext="信用证通知编号" trn="bmtfre" />	
	// <InputItem InputProps={bind("ownref1")}  maxLength={20}  desp="业务编号" path="/dedgrp/rec/ownref" />

	
	// <Label itext="信用证金额" trn="bmtfre" />	
	// <InputItem InputProps={bind("opn11_cur")}  maxLength={3}  desp="Currency" path="/dedgrp/cbs/opn1/cur" />
	// <InputItem InputProps={bind("opn11_amt")}   desp="Balance" path="/dedgrp/cbs/opn1/amt" />
	// <InputItem InputProps={bind("sdamod_dadrcv")}   desp="Drag  Drop Receiver" path="/bmtp0/recget/sdamod/dadrcv" />

	
	// <Label itext="寄单单据编号" trn="bmtfre" />	
	// <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="Own Reference BE Number" path="/bmdgrp/rec/ownref" />

	
	// <Label itext="概要描述" trn="bmtfre" />	
	// <InputItem InputProps={bind("nam")}  maxLength={40}  desp="Externally Displayed Name to Identify the Contract" path="/bmdgrp/rec/nam" />

	
	// <Label itext="单据金额" trn="bmtfre" />	
	// <SelectItem InputProps={bind("max_cur")}   desp="Currency" path="/bmdgrp/cbs/max/cur"/>
	// <InputItem InputProps={bind("max_amt")}   desp="Balance" path="/bmdgrp/cbs/max/amt" />

	
	// <Label itext="收益人" trn="bmtfre" />	
	// <InputItem InputProps={bind("pts1_ref")}  maxLength={16}  desp="参考号" path="/bmdgrp/ben/pts/ref" />

	
	// <Label itext="单据余额" trn="bmtfre" />	
	// <InputItem InputProps={bind("opn1_cur")}  maxLength={3}  desp="Currency" path="/bmdgrp/cbs/opn1/cur" />
	// <InputItem InputProps={bind("opn1_amt")}   desp="Balance" path="/bmdgrp/cbs/opn1/amt" />
	// <InputItem InputProps={bind("pts1_nam")}  maxLength={35}  desp="客户英文名称" path="/bmdgrp/ben/pts/nam" />

	
	// <Label itext="开证行" trn="bmtfre" />	
	// <InputItem InputProps={bind("pts2_ref")}  maxLength={16}  desp="参考号" path="/bmdgrp/iss/pts/ref" />

	
	// <Label itext="单据类型" trn="bmtfre" />	
	// <InputItem InputProps={bind("doctypcod")}  maxLength={1}  desp="Document Type" path="/bmdgrp/rec/doctypcod" />
	// <InputItem InputProps={bind("pts2_nam")}  maxLength={35}  desp="客户英文名称" path="/bmdgrp/iss/pts/nam" />

	
	// <Label itext="日期" trn="bmtfre" />	

	
	// <Label itext="交单日期" trn="bmtfre" />	
	// <DatePickerItem InputProps={bind("orddat")}  desp="Order Date" path="/bmdgrp/rec/orddat" />

	
	// <Label itext="收单日期" trn="bmtfre" />	
	// <DatePickerItem InputProps={bind("rcvdat")}  desp="Date of Receipt of Documents" path="/bmdgrp/rec/rcvdat" />

	
	// <Label itext="交单日期" trn="bmtfre" />	
	// <DatePickerItem InputProps={bind("predat")}  desp="Presentation Date" path="/bmdgrp/rec/predat" />

	
	// <Label itext="申请人" trn="bmtfre" />	
	// <InputItem InputProps={bind("pts_ref")}  maxLength={16}  desp="参考号" path="/bmdgrp/apl/pts/ref" />

	
	// <Label itext="单据状态" trn="bmtfre" />	
	// <InputItem InputProps={bind("docsta")}  maxLength={40}  desp="Document Set Status" path="/bmdgrp/rec/docsta" />
	// <InputItem InputProps={bind("pts_nam")}  maxLength={35}  desp="客户英文名称" path="/bmdgrp/apl/pts/nam" />

	
	// <Label itext="报文内容" trn="bmtfre" />	

	
	// <Label itext="收报行" trn="bmtfre" />	
	// <TextAreaItem InputProps={bind("fremsg_fretxt")} desp="Narrative" path="/fremsg/fretxt"/>
	// <InputItem InputProps={bind("pts3_extkey")}  maxLength={16}  desp="客户编号" path="/fremsg/fmc/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onFmcp_sel} desp="查询" path="/fremsg/fmcp/sel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <Button  type="primary" icon="search" onClick={this.onFmcp_ptysel} desp="客户查询" path="/fremsg/fmcp/ptysel">
	// 	<Label   itext="客户查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts3_namcn")}  maxLength={100}  desp="客户中文名称" path="/fremsg/fmc/pts/namcn" />
	// <InputItem InputProps={bind("pts3_adrcn")}  maxLength={100}  desp="中文地址" path="/fremsg/fmc/pts/adrcn" />
	// <Button  type="primary"  onClick={this.onPed} desp="暂存" path="/mtabut/ped">
	// 	<Label   itext="暂存"/>
	// </Button>
	// <Button  type="primary"  onClick={this.onRtn} desp="退出" path="/mtabut/rtn">
	// 	<Label   itext="退出"/>
	// </Button>
	// 	</div>
	// 	)
	}
}
