import React, { Component, Fragment } from 'react'
import {
	Page, Validator, Notification, FormItem,
	InputItem, Input, Bind, SelectItem, Button, Label, DatePickerItem, Section, Table, TextArea,ConfirmButton,Steps
} from '@/components/Common-Library'
import Api from '@/service/api'
import mFetopn from '../model'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable } from 'mobx'
import Basic from './Basic'
import Fee from '@/views/Public/Fee'
import Gle from '@/views/Public/Gle'
import Papper from '@/views/Public/Papper'
import Dbb from '@/views/Public/Dbb'
import {Card} from 'antd'
const  StepItem = Steps.Item

@inject('UserContext')
@inject('i18n')
@observer
export default class FetopnScreen extends Page {
	@observable
	formBlur = false
	
	@observable
	extra={inifrm:'cptopn',sptinr:'',bchlevelLst:[]}
	
	constructor(props) {
		super(props)
		this.model = new mFetopn()
		this.model.openValidate() //开启校验
		
	}
	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.branchinr;
		}
		else {
			Notification.error({ message: '服务端请求失败!' })
		}	
	}

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

	//交易内实现
	renderPage() {
		return (
		    <Card title="即期结售汇" size="small" className="transTitle">
			<Steps>
				<StepItem title="概况">
					<Basic model={this.model} extra={this.extra} />
				</StepItem>
				<StepItem title="费用">
					<Fee model={this.model} extra={this.extra}/>
				</StepItem>
				<StepItem title="会计分录">
					<Gle model={this.model} extra={this.extra}/>
				</StepItem>
				<StepItem title="外管申报">
					<Dbb model={this.model} extra={this.extra}/>
				</StepItem>
				<StepItem title="面函">
					<Papper model={this.model} extra={this.extra}/>
				</StepItem>
			</Steps>
			</Card>
		)
	}
}
