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 mDitselback from '../model'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable} from 'mobx'
import Xinyongzheng from './Xinyongzheng'
import Danju from './Danju'
import { Card } from 'antd'
import DateFormat from  '@/utils/DateUtil'

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


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

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



	constructor(props) {
		super(props)
		this.state = {
			flag: true
		}
		this.model = new mDitselback()
	}
	
	componentWillMount(){
		this.initTrans()
	}
	
	initTrans = async ()=> {
	
		let rtnmsg = [];
	
			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({ flag: false })
			this.model.opndat1 =DateFormat();
		}
		else {
			Notification.error({ message: '服务端请求失败!' })
		}

		//快照模式下，不必开启校验，否则，静默校验，和记录变动
		!this.loadDisplay() && this.model.openMonitor() //开启校验	
	}

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


    //交易内实现
    renderPage(){
		return (
			<Card title="国内证买方" size="small" className="transTitle">
				<Steps>
					<StepItem title="信用证">
						<Xinyongzheng model={this.model} extra={this.extra} flag={this.state.flag} initTrans={this.initTrans}/>
					</StepItem>

					<StepItem title="单据">
						<Danju model={this.model} extra={this.extra} initTrans={this.initTrans} />
					</StepItem>
				

				</Steps>
			</Card>
		)
 
	}
}
