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 mDetsel 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 { Card } from 'antd'

const CodeTable = CodeTableFactory.getInstance()
const StepItem = Steps.Item
 
@inject('UserContext')
@inject('i18n')
@observer
export default class DetselScreen extends Page
{
    @observable
    formBlur=false

		@observable
		extra = { inifrm: 'detsel', sptinr: '', bchlevelLst: [] }

    constructor(props)
    {
        super(props)
        this.model = new mDetsel()    
				this.bind = Bind.bind(this)
				this.state={
					flag:true,
					cfgfil_cfga:[],
					cfgfil_cfgb:[]
				}
    }
	
		//初始化代码
		async componentWillMount() {
			let sptinr = '';
			let rtnmsg = [];
			if (this.props.location.query) {
				sptinr = this.props.location.query.inr
				this.extra.sptinr = sptinr
				rtnmsg = await Api.post(this.extra.inifrm + '/init', { params: { sptinr } })
			} else {
				rtnmsg = await Api.post(this.extra.inifrm + '/init', {})
			}
			if (rtnmsg.retcod == SUCCESS) {
				Object.assign(this.model, rtnmsg.data)
				this.extra.bchlevelLst = rtnmsg.codetable.ownbch;
				this.setState({cfgfil_cfga:rtnmsg.data.cfgfil_cfga})
				this.setState({cfgfil_cfgb:rtnmsg.data.cfgfil_cfgb})
				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} cfgfil_cfga={this.state.cfgfil_cfga} cfgfil_cfgb={this.state.cfgfil_cfgb}  />
						</StepItem>

						<StepItem title="单据">
							<Detp model={this.model} extra={this.extra}  cfgfil_cfga={this.state.cfgfil_cfga} cfgfil_cfgb={this.state.cfgfil_cfgb}   />
						</StepItem>
					</Steps>
				</Card>
			)
			


  //       return (
  //       	<div className="transPage">
	// <InputItem InputProps={bind("ownref1")}  maxLength={20}  desp="业务编号" path="/dedgrp/rec/ownref" />
	// <CheckboxItem InputProps={bind("detmod_clsflg")}  desp="闭卷业务" path="/detmod/clsflg" />
	// <Button  type="primary" icon="search" onClick={this.onDetmod_sel} desp="查询" path="/detmod/sel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <InputItem InputProps={bind("nam1")}  maxLength={40}  desp="概要描述" path="/dedgrp/rec/nam" />
	// <SelectItem InputProps={bind("max1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/dedgrp/cbs/max/cur"/>
	// <InputItem InputProps={bind("max1_amt")}   desp="Balance" path="/dedgrp/cbs/max/amt" />
	// <InputItem InputProps={bind("pts2_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/ben/pts/namcn" />
	// <InputItem InputProps={bind("pts1_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/apl/pts/namcn" />
	// <SelectItem InputProps={bind("opn11_cur")} code={CodeTable.curtxt}  desp="Currency" path="/dedgrp/cbs/opn1/cur"/>
	// <InputItem InputProps={bind("opn11_amt")}   desp="Balance" path="/dedgrp/cbs/opn1/amt" />
	// <InputItem InputProps={bind("pts3_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/iss/pts/namcn" />
	// <DatePickerItem InputProps={bind("opndat1")}  desp="开立日期" path="/dedgrp/rec/opndat" />
	// <InputItem InputProps={bind("expplc")}  maxLength={100}  desp="有效地点" path="/dedgrp/rec/expplc" />
	// <SelectItem InputProps={bind("avbby")} code={CodeTable.avbby}  desp="信用证对付方式" path="/dedgrp/rec/avbby"/>
	// <DatePickerItem InputProps={bind("expdat")}  desp="有效日期" path="/dedgrp/rec/expdat" />
	// <Table rowKey="inr" columns={this.cfgfil_cfgaHeader}  dataSource={this.model.cfgfil_cfga}   path="/cfgfil/cfga"/>
	// <InputItem InputProps={bind("ownref")}  maxLength={16}  desp="Own Reference BE Number" path="/bmdgrp/rec/ownref" />
	// <Button  type="primary" icon="search" onClick={this.onBmtmod_sel} desp="查询" path="/bmtmod/sel">
	// 	<Label   itext="查询"/>
	// </Button>
	// <CheckboxItem InputProps={bind("bmtmod_clsflg")}  desp="闭卷业务" path="/bmtmod/clsflg" />
	// <InputItem InputProps={bind("nam")}  maxLength={40}  desp="Externally Displayed Name to Identify the Contract" path="/bmdgrp/rec/nam" />
	// <SelectItem InputProps={bind("max_cur")} code={CodeTable.curtxt}  desp="Currency" path="/bmdgrp/cbs/max/cur"/>
	// <InputItem InputProps={bind("max_amt")}   desp="Balance" path="/bmdgrp/cbs/max/amt" />
	// <SelectItem InputProps={bind("opn1_cur")} code={CodeTable.curtxt}  desp="Currency" path="/bmdgrp/cbs/opn1/cur"/>
	// <InputItem InputProps={bind("opn1_amt")}   desp="Balance" path="/bmdgrp/cbs/opn1/amt" />
	// <DatePickerItem InputProps={bind("opndat")}  desp="Date Opened/Issued" path="/bmdgrp/rec/opndat" />
	// <InputItem InputProps={bind("pts_namcn")}  maxLength={100}  desp="客户中文名称" path="/dedgrp/adv/pts/namcn" />
	// <DatePickerItem InputProps={bind("matdat")}  desp="Maturity Date" path="/bmdgrp/rec/matdat" />
	// <SelectItem InputProps={bind("doctypcod")} code={CodeTable.doc}  desp="Document Type" path="/bmdgrp/rec/doctypcod"/>
	// <DatePickerItem InputProps={bind("accdat")}  desp="Acceptance Date" path="/bmdgrp/rec/accdat" />
	// <InputItem InputProps={bind("expmno")}  maxLength={60}  desp="快递单号" path="/bmdgrp/rec/expmno" />
	// <Table rowKey="inr" columns={this.cfgfil_cfgbHeader}  dataSource={this.model.cfgfil_cfgb}   path="/cfgfil/cfgb"/>
	// <Table rowKey="inr" columns={this.detmod_dedlstHeader}  dataSource={this.model.detmod_dedlst}   path="/detmod/dedlst"/>
	// <Button  type="primary"  onClick={this.onDetmod_choose} desp="选中" path="/detmod/choose">
	// 	<Label   itext="选中"/>
	// </Button>
	// <Table rowKey="inr" columns={this.bmtmod_bmdlstHeader}  dataSource={this.model.bmtmod_bmdlst}   path="/bmtmod/bmdlst"/>
	// <Button  type="primary"  onClick={this.onBmtmod_choose} desp="选中" path="/bmtmod/choose">
	// 	<Label   itext="选中"/>
	// </Button>
	// 	</div>
	// 	)
	}
}
