import React,{Component,Fragment} from 'react'
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 mDetreg from '../model'
import CodeTableFactory from '@/components/CodeTable'

import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable,runInAction } from 'mobx'
 
import Ovwp from './Ovwp'
import Detp from './Detp'
import Tkp from './Tkp'
import Fee from '@/views/Public/Fee'
import Gle from '@/views/Public/Gle'
import Papper from '@/views/Public/Papper'

import { Card } from 'antd'

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

@inject('UserContext')
@inject('i18n')
@observer
export default class DetregScreen extends Page
{
    @observable
    formBlur=false

    @observable
		extra = { inifrm: 'detreg', sptinr: '', bchlevelLst: [] }
 
  constructor(props)
  {
      super(props)
      this.model = new mDetreg()    
			this.bind = Bind.bind(this)
			this.state={
				flag:true
			}
  }
	
	async componentWillMount(){
		/*
		*添加初始化代码
    */
    let dedinr = '';
    //如果携带参数，接收参数再发请求
    if(this.props.location.query){
      if(this.props.location.query.from=="sptsel"){
        //经办夹进入
        this.extra.sptinr = this.props.location.query.sptinr
      }else{
        dedinr = this.props.location.query.dedinr
      }
    }
    const rtnmsg = await Api.post(this.extra.inifrm + '/init', { params: { sptinr:this.extra.sptinr, dedinr } })
		if (rtnmsg.retcod == SUCCESS) {
			Object.assign(this.model, rtnmsg.data)
			this.extra.bchlevelLst = rtnmsg.codetable.ownbch;
			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="附加">
                <Detp model={this.model} extra={this.extra} flag={this.state.flag} />
            	</StepItem>
          	  <StepItem title="条款">
                <Tkp 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>
				)

  //       	<div style={{position:'relative'}}>
	// <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="业务编号" path="/dedgrp/rec/ownref" />
	// <Button  type="primary"  onClick={this.onGetref} desp="Get Ref." path="/mtabut/getref">
	// 	<Label   itext="获取"/>
	// </Button>
	// <InputItem InputProps={bind("nam")}  maxLength={40}  desp="概要描述" path="/dedgrp/rec/nam" />
	
	// <DatePickerItem InputProps={bind("opndat")}  desp="开立日期" path="/dedgrp/rec/opndat" />
	// <InputItem InputProps={bind("nom1_cur")}  maxLength={3}  desp="Currency" path="/dedgrp/cbs/nom1/cur" />
	// <InputItem InputProps={bind("nom1_amt")}   desp="Balance" path="/dedgrp/cbs/nom1/amt" />
	// <InputItem InputProps={bind("nomtop")}   desp="上浮" path="/dedgrp/rec/nomtop" />
	// <InputItem InputProps={bind("nomton")}   desp="下浮" path="/dedgrp/rec/nomton" />
	// <InputItem InputProps={bind("max_cur")}  maxLength={3}  desp="Currency" path="/dedgrp/cbs/max/cur" />
	// <InputItem InputProps={bind("max_amt")}   desp="Balance" path="/dedgrp/cbs/max/amt" />
	// <SelectItem InputProps={bind("isstyp")} code={CodeTable.isstyp}  desp="开证类型" path="/dedgrp/rec/isstyp"/>
	// <SelectItem InputProps={bind("trdtyp")} code={CodeTable.trdtyp}  desp="贸易方式" path="/dedgrp/rec/trdtyp"/>
	// <DatePickerItem InputProps={bind("shpdat")}  desp="最迟货物装运/服务提供日期 " path="/dedgrp/rec/shpdat" />
	// <DatePickerItem InputProps={bind("expdat")}  desp="有效日期" path="/dedgrp/rec/expdat" />
	// <SelectItem InputProps={bind("avbby")} code={CodeTable.avbby}  desp="信用证对付方式" path="/dedgrp/rec/avbby"/>
	// <InputItem InputProps={bind("tenmaxday")}   desp="期限" path="/dedgrp/rec/tenmaxday" />
	// <InputItem InputProps={bind("pts1_extkey")}  maxLength={16}  desp="客户编号" path="/dedgrp/apl/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onAplp_ptysel} desp="客户查询" path="/detp/aplp/ptysel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts1_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/apl/pts/namcn" />
	// <InputItem InputProps={bind("pts1_adrcn")}  maxLength={100}  desp="中文地址" path="/dedgrp/apl/pts/adrcn" />
	// <InputItem InputProps={bind("pts2_extkey")}  maxLength={16}  desp="客户编号" path="/dedgrp/ben/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onBenp_ptysel} desp="客户查询" path="/detp/benp/ptysel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts2_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/ben/pts/namcn" />
	// <InputItem InputProps={bind("pts2_adrcn")}  maxLength={100}  desp="中文地址" path="/dedgrp/ben/pts/adrcn" />
	// <InputItem InputProps={bind("defdet")}  maxLength={60}  desp="远期付款指示" path="/dedgrp/rec/defdet" />
	// <SelectItem InputProps={bind("ownbch")}   desp="归属机构" path="/dedgrp/rec/ownbch"/>
	// <InputItem InputProps={bind("accusr")}  maxLength={8}  desp="客户经理" path="/dedgrp/rec/accusr" />
	// <InputItem InputProps={bind("pts4_extkey")}  maxLength={16}  desp="客户编号" path="/dedgrp/iss/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onIssp_ptysel} desp="客户查询" path="/detp/issp/ptysel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts4_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/iss/pts/namcn" />
	// <InputItem InputProps={bind("pts4_adrcn")}  maxLength={100}  desp="中文地址" path="/dedgrp/iss/pts/adrcn" />
	// <InputItem InputProps={bind("tratyp")}  maxLength={20}  desp="货物运输或交货方式/服务方式" path="/dedgrp/rec/tratyp" />
	// <InputItem InputProps={bind("shpfro")}  maxLength={100}  desp="货物装运地(港)" path="/dedgrp/rec/shpfro" />
	// <InputItem InputProps={bind("shpto")}  maxLength={100}  desp="货物目的地、交货地（港）" path="/dedgrp/rec/shpto" />
	// <InputItem InputProps={bind("shppro")}  maxLength={100}  desp="服务提供地点" path="/dedgrp/rec/shppro" />
	// <InputItem InputProps={bind("expplc")}  maxLength={100}  desp="有效地点" path="/dedgrp/rec/expplc" />
	// <InputItem InputProps={bind("preper")}  maxLength={100}  desp="交单期限" path="/dedgrp/rec/preper" />
	// <InputItem InputProps={bind("conno")}  maxLength={35}  desp="合同编号" path="/dedgrp/rec/conno" />
	// <InputItem InputProps={bind("conamt")}   desp="合同金额" path="/dedgrp/rec/conamt" />
	// <InputItem InputProps={bind("concur")}  maxLength={3}  desp="合同币种" path="/dedgrp/rec/concur" />
	// <SelectItem InputProps={bind("negflg")} code={CodeTable.yesno}  desp="是否可议付" path="/dedgrp/rec/negflg"/>
	// <SelectItem InputProps={bind("traflg")} code={CodeTable.yesno}  desp="是否可转让" path="/dedgrp/rec/traflg"/>
	// <SelectItem InputProps={bind("cfmflg")} code={CodeTable.yesno}  desp="保兑标志" path="/dedgrp/rec/cfmflg"/>
	// <InputItem InputProps={bind("pts5_extkey")}  maxLength={16}  desp="客户编号" path="/dedgrp/neg/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onNegp_ptysel} desp="客户查询" path="/detp/negp/ptysel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts5_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/neg/pts/namcn" />
	// <InputItem InputProps={bind("pts5_adrcn")}  maxLength={100}  desp="中文地址" path="/dedgrp/neg/pts/adrcn" />
	// <InputItem InputProps={bind("pts3_extkey")}  maxLength={16}  desp="客户编号" path="/dedgrp/con/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onConp_ptysel} desp="客户查询" path="/detp/conp/ptysel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts3_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/con/pts/namcn" />
	// <InputItem InputProps={bind("pts3_adrcn")}  maxLength={100}  desp="中文地址" path="/dedgrp/con/pts/adrcn" />
	// <InputItem InputProps={bind("pts_extkey")}  maxLength={16}  desp="客户编号" path="/dedgrp/a2b/pts/extkey" />
	// <Button  type="primary" icon="search" onClick={this.onA2bp_ptysel} desp="客户查询" path="/detp/a2bp/ptysel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("pts_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/a2b/pts/namcn" />
	// <InputItem InputProps={bind("pts_adrcn")}  maxLength={100}  desp="中文地址" path="/dedgrp/a2b/pts/adrcn" />
	// <InputItem InputProps={bind("trdapt")}  maxLength={100}  desp="分期装运/提供服务约定" path="/dedgrp/rec/trdapt" />
	// <SelectItem InputProps={bind("shppar")} code={CodeTable.allow}  desp="分批装运货物/分次提供服务" path="/dedgrp/rec/shppar"/>
	// <SelectItem InputProps={bind("shpper")} code={CodeTable.allow}  desp="分期装运/提供服务" path="/dedgrp/rec/shpper"/>
	// <SelectItem InputProps={bind("shptrs")} code={CodeTable.allow}  desp="转运" path="/dedgrp/rec/shptrs"/>
	// <TextAreaItem InputProps={bind("lcrgod")} desp="货物服务描述" path="/dedgrp/rec/lcrgod"/>
	// <TextAreaItem InputProps={bind("lcrdoc")} desp="单据要求" path="/dedgrp/rec/lcrdoc"/>
	// <TextAreaItem InputProps={bind("adlcnd")} desp="附加条款" path="/dedgrp/rec/adlcnd"/>

	
	// <Label itext="业务编号"  />	

	
	// <Label itext="概要描述"  />	

	
	// <Label itext="开立日期"  />	

	
	// <Label itext="信用证金额"  />	

	
	// <Label itext="上下浮动比例+/-% "  />	

	
	// <Label itext="/"  />	

	
	// <Label itext="信用证最大金额"  />	

	
	// <Label itext="开证类型"  />	

	
	// <Label itext="贸易方式"  />	

	
	// <Label itext="最迟货物装运/服务提供日期 "  />	

	
	// <Label itext="有效日期"  />	

	
	// <Label itext="信用证对付方式"  />	

	
	// <Label itext="天"  />	

	
	// <Label itext="申请人"  />	

	
	// <Label itext="受益人"  />	

	
	// <Label itext="开证行"  />	

	
	// <Label itext="远期付款指示"  />	

	
	// <Label itext="归属机构"  />	

	
	// <Label itext="客户经理"  />	

	
	// <Label itext="货物运输或交货方式/服务方式"  />	

	
	// <Label itext="货物装运地(港)"  />	

	
	// <Label itext="货物目的地、交货地（港）"  />	

	
	// <Label itext="服务提供地点"  />	

	
	// <Label itext="有效地点"  />	

	
	// <Label itext="交单期限"  />	

	
	// <Label itext="合同编号"  />	

	
	// <Label itext="合同金额"  />	

	
	// <Label itext="是否可议付"  />	

	
	// <Label itext="是否可转让"  />	

	
	// <Label itext="保兑标志"  />	

	
	// <Label itext="议付行"  />	

	
	// <Label itext="保兑行"  />	

	
	// <Label itext="转让行"  />	

	
	// <Label itext="分期装运/提供服务约定"  />	

	
	// <Label itext="分批装运货物/分次提供服务"  />	

	
	// <Label itext="分期装运/提供服务"  />	

	
	// <Label itext="转运"  />	

	
	// <Label itext="委托行"  />	

	
	// <Label itext="货物服务描述"  />	

	
	// <Label itext="单据要求"  />	

	
	// <Label itext="附加条款"  />	
	// 	</div>
	//	)
	}
}
