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 mFptopn from '../model'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable,runInAction } 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 { Card } from 'antd'
import Engp from '@/views/Public/Engp'

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


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

	@observable
	extra = { inifrm: 'fptopn', sptinr: '', ownbch: [] ,ffttyp:[]}



	constructor(props) {
		super(props)
		this.model = new mFptopn()
		this.state = {
			flag: true
		}
	}
	
	
	async componentWillMount() {
		let objinr = '';
		let objtyp = '';
		let rtnmsg = [];
		if (this.props.location.query) {
			objinr = this.props.location.query.inr
			objtyp = this.props.location.query.objtyp
			rtnmsg = await Api.post(this.extra.inifrm + '/init', { params: { objinr,objtyp} })
		} else {
			rtnmsg = await Api.post(this.extra.inifrm + '/init', {})
		}
		if (rtnmsg.retcod == SUCCESS) {
			Object.assign(this.model, rtnmsg.data)
			this.extra.ownbch = rtnmsg.codetable.ownbch;
			this.extra.ffttyp = rtnmsg.codetable.ffttyp;
			this.setState({ flag: false })
			this.model.max_cur='CNY';
		
		}
		else {
			Notification.error({ message: '服务端请求失败!' })
		}

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

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


    //交易内实现
    renderPage(){
		return (
			<Card title="福费廷开立" size="small" className="transTitle">
				<Steps>
					<StepItem title="福费廷">
						<Basic model={this.model} extra={this.extra} flag={this.state.flag} />
					</StepItem>

					<StepItem title="表外&保证金">
						<Engp 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="面函">
						<Papper model={this.model} extra={this.extra} />
					</StepItem>
				

				</Steps>
			</Card>
		)
    
	}
}
