import React, { Component, Fragment } from 'react'
import {
	Page, Validator, Notification, FormItem, BottomBtn,
	InputItem, Input, Bind, SelectItem, Button, Label, DatePickerItem, Section, Table, TextArea,ConfirmButton,Steps,AmountLabel
} from '@/components/Common-Library'
import Api from '@/service/api'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable } from 'mobx'
import { Row, Col, Popconfirm, Modal } from 'antd';
import {ButtonModal,ModalTest} from '@/components/Business-Library'
import {Link,withRouter} from 'react-router-dom'
import Business from '@/views/Public/Business'

const CodeTable = CodeTableFactory.getInstance()
const confirm = Modal.confirm
const {Pre,Next,StepWrapper} = Steps

@withRouter
@inject('UserContext')
@inject('i18n')
@observer
export default class GleScreen extends Page {
	@observable
	formBlur = false
	
	constructor(props) {
		super(props)
        this.model = props.model
    this.bind = Bind.bind(this)
	}
	
	async componentWillMount() {
		
	}

	componentWillUnmount() {
	//	this.model.closeValidate()//关闭校验
	}
	
	onTabFocus= async () => {
    this.com.wrappedInstance.wrappedInstance.onRebook();
	}
	
	// 会计分录
	glelstHeader = [
		{
			title: <Label i18nId="GLEMOD_TH000076" />,
			dataIndex: "dbtcdt",
			key: "dbtcdt",
			width: 60,
			render: (val, row, index) => {
				let text = val
				let em = CodeTable.dbtcdt.find(item => item.value == val)
				if (em)
					text = em.label
				return text
			}
		},
		{
			title: <Label i18nId="GLEMOD_TH000077" />,
			dataIndex: "act",
			key: "act",
			width: 60,
		},
		{
			title: <Label i18nId="GLEMOD_TH000078" />,
			dataIndex: "cur",
			key: "cur",
			width: 60,
		},
		{
			title: <Label i18nId="GLEMOD_TH000079" />,
			dataIndex: "amt",
			key: "amt",
			width: 60,
			render: (val, row, index) => {
				// let str = (Math.floor(val * 100)) + "";
				// let strindex = str.length - 2;
				// return str.slice(0, strindex) + "." + str.slice(strindex, str.length);
				return <AmountLabel cur={row.cur} amt={val} />
			},
		},
		{
			title: <Label i18nId="GLEMOD_TH000080" />,
			dataIndex: "valdat",
			key: "valdat",
			width: 60,
			render: (val, row, index) => {
				let text = val
				if (val){
					let array = val.split(" ")
					text = array[0]
				}
				return text
			}
		},
		{
			title: <Label i18nId="GLEMOD_TH000081" />,
			dataIndex: "trmtyp",
			key: "trmtyp",
			width: 60,
		},
		{
			title: <Label itext="记账方式" />,
			dataIndex: "fctsgn",
			key: "fctsgn",
			width: 60,
			render: (val, row, index) => {
				let text = val
				if (val=="X"){
					text = "核心"
				}else{text="总账"}
				return text
			}
		},
		// {
		// 	title: <Label i18nId="GLEMOD_TH000082" />,
		// 	dataIndex: "prn",
		// 	key: "prn",
		// 	width: 60,
		// },
	]
	//交易内实现
	renderPage() {
		const bind = this.bind
		const { i18n } = this.props
		
		return (
			<div style={{ position: 'relative' }}>
				 <Business  wrappedComponentRef={ref => (this.com = ref)} steps={this.props.steps} extra={this.props.extra}  model={this.model} />
				{/* 表格 */}
				<Row>
					<Col>
						<Row>
							<Label i18nId={"GLEMOD_LT000075"} />
							<Table pagination={{ pageSize: 10,hideOnSinglePage:true }} rowKey="inr" columns={this.glelstHeader} dataSource={this.model.glemod_glelst} scroll={{ x: 420 }} />
						</Row>
					</Col>
				</Row>
				<br />
				{/* 底部按钮 */}
        <BottomBtn _this={this} />
			</div >
		)
	}
}
