import React,{Component,Fragment} from 'react'
import {Page,Validator,Notification,FormItem,
    InputItem,Input,Bind,SelectItem,Button,Label,Table,Section,DatePickerItem} from '@/components/Common-Library'
import {Divider} from 'antd'
import Api from '@/service/api'
import mDbixrt from '../model'
import CodeTableFactory from '@/components/CodeTable'
import "./index.less"
import { inject, observer } from 'mobx-react'
import { action, observable } from 'mobx'
import { Col, Row ,Card } from 'antd'
import {Link} from 'react-router-dom'
import Moment from 'moment'
const CodeTable = CodeTableFactory.getInstance()


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

    constructor(props)
    {
        super(props)
        this.model = new mDbixrt()
        this.model.openValidate() //开启校验
        this.bind = Bind.bind(this)
    }

    componentWillUnmount()
    {
        this.model.closeValidate()//关闭校验
    }
	onRtn = ()=>{
		this.props.history.push({pathname: 'dblxrt', state: {'selflg':true}});
	}


    //按钮事件
    async componentWillMount() {
		if(this.props.location.query){
			let selinr = this.props.location.query.inr
			const rtnmsg = await Api.post('dbixrt/init', { params: {selinr} })
			if (rtnmsg.retcod == SUCCESS) {
				//Notification.success({ message: '数据提交成功!' })
				Object.assign(this.model,rtnmsg.data)
			}
			else {
				Notification.error({ message: '服务端请求失败!' })
			}	
		}	
	}

    //交易内实现
    renderPage(){
    	const bind = this.bind
        const {i18n} = this.props
     
        return (
		   <Card title="牌价查询" size="small" className="transTitle">
        	<div style={{position:'relative'}}>
			<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000007"}/>
						</Col>
						<Col span={18}>
						<SelectItem InputProps={{...bind("cur"),disabled:true}} code={CodeTable.curtxt}  />
						</Col>
					</Col>
					<Col span={8} offset={2}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000008"}/>	
						</Col>
						<Col span={18}>
						<DatePickerItem InputProps={{...bind("begdat"),disabled:true}}   />
						</Col>
					</Col>
				</Row>
				
				<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000009"}/>
						</Col>
						<Col span={18}>
						<DatePickerItem InputProps={{...bind("enddat"),disabled:true}} />
						</Col>
					</Col>
					<Col span={8} offset={2}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000010"}/>	
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("midrat"),readOnly:true}}   />
						</Col>
					</Col>
				</Row>
				
				<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000011"}/>
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("buyrat"),readOnly:true}} />
						</Col>
					</Col>
					<Col span={8} offset={2}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000012"}/>	
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("selrat"),readOnly:true}}  />
						</Col>
					</Col>
				</Row>
				
				<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000013"}/>
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("ibrrat"),readOnly:true}} />
						</Col>
					</Col>
					<Col span={8} offset={2}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000014"}/>	
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("cshbuyrat"),readOnly:true}}  />
						</Col>
					</Col>
				</Row>
				
				<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000015"}/>
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("cshselrat"),readOnly:true}} />
						</Col>
					</Col>
					<Col span={8} offset={2}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000016"}/>	
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("ttrrat"),readOnly:true}}  />
						</Col>
					</Col>
				</Row>
				
				<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000017"}/>
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("odrrat"),readOnly:true}} />
						</Col>
					</Col>
					<Col span={8} offset={2}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000018"}/>	
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("rebrat"),readOnly:true}}   />
						</Col>
					</Col>
				</Row>
				<Row gutter={16} className="line">
					<Col span={8} offset={3}>
						<Col span={6}>
						<Label i18nId={"XRTP_LT000019"}/>
						</Col>
						<Col span={18}>
						<InputItem InputProps={{...bind("resrat"),readOnly:true}} />
						</Col>
					</Col>
				</Row>
				<Row gutter={16} className="line">
					<Col offset={11}>
						<Button type="primary" onClick={this.onRtn}>
   						   <Label i18nId="MTABUT_BT000020" />      
                        </Button>
					</Col>
				</Row>
				{/*<div className='button0'>
					 <div className='button2'>
                        <Button type="primary" onClick={this.onRtn}>
   						   <Label i18nId="MTABUT_BT000020" />      
                        </Button>
                    </div>
                </div>*/}
		</div>
		  </Card>
		)
	}
}
