import React, { Component, Fragment } from 'react'
import {
	Page, Validator, Notification, FormItem,
	InputItem, Input, Bind, SelectItem, Button, Label, Table, Section, DatePickerItem,ConfirmButton,TextAreaItem
} 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, autorun } from 'mobx'
import { Row, Col, Popconfirm, Modal, Spin } from 'antd';
import { PtyPicker } from '@/components/Business-Library'
import { Link, withRouter } from 'react-router-dom'
import Ptspta1 from '@/views/Public/Ptspta1'
import Business from '@/views/Public/Business'
import moment from 'moment';
import mLoginf from '../model'
const CodeTable = CodeTableFactory.getInstance()
const confirm = Modal.confirm

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

	constructor(props) {
		super(props)
		this.model = new mLoginf()
		this.bind = Bind.bind(this)
	}
	//交易描述赋值
	// componentDidMount() {
	// 	super.componentDidMount()
	
	// }
	// componentWillUnmount() {
	// 	this.autoDispose && this.autoDispose()
    // }
    evtlstHeader=[
    	{
    		title:<Label itext="会话ID" />, 
    		dataIndex:"ssninr",
    		key:"ssninr",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.ssninr,r2.ssninr),
    	},
    	{
    		title:<Label itext="操作表" />, 
    		dataIndex:"objtyp",
    		key:"objtyp",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.objtyp,r2.objtyp),
    	},
    	{
    		title:<Label itext="操作表索引" />, 
    		dataIndex:"objinr",
    		key:"objinr",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.objinr,r2.objinr),
    	},
    	{
    		title:<Label itext="用户号" />, 
    		dataIndex:"usr",
    		key:"usr",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.usr,r2.usr),
    	},
    	{
    		title:<Label itext="用户名" />, 
    		dataIndex:"usrnam",
    		key:"usrnam",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.usrnam,r2.usrnam),
    	},
    	{
    		title:<Label itext="交易码" />, 
    		dataIndex:"frm",
    		key:"frm",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.frm,r2.frm),
    	},
    	{
    		title:<Label itext="交易名" />, 
    		dataIndex:"frmnam",
    		key:"frmnam",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.frmnam,r2.frmnam),
    	},
    	{
    		title:<Label itext="操作时间" />, 
    		dataIndex:"dattim",
    		key:"dattim",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.dattim,r2.dattim),
    	},
    ]

	//按钮事件 获取业务编号
    onSelevt= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('loginf/selevt',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    this.model.evtlst = rtnmsg.data['evtlst'];
                    
                }
                else
                {
                	Notification.error({message:'服务端请求失败!'})
                }
                //余下逻辑处理
                    
        })
    }

	

	//交易内实现
	renderPage() {
		const bind = this.bind
		const { i18n } = this.props
		  //将模型变量绑定到页签的bindSet对象中，才能在检核的时候被检查到变量所在页签，继而跳转到对应页签
		 
		//const {next,pre} = this.props.steps
		return (
			<div style={{ position: 'relative' }}>
				<Business wrappedComponentRef={ref => (this.com = ref)}  extra={this.props.extra} model={this.model} />
				{/* 第一行 */}
                <Row>
                    <Col span={24}>

                        <Row>
                            <Col span={12}>
                                <Row className='row'>
                                    <Col span={5} offset={2}>
                                    <Label   itext="用户号"/>
                                    </Col>
                                    <Col span={14}>
                                    <InputItem InputProps={bind("usrkey")}  maxLength={16}  desp="用户号" path="/usrkey" />
                                    </Col>
                                </Row>
                            </Col>
                            <Col span={12}>
                                <Row className='row'>
                                    <Col span={5} offset={2}>
                                    <Label   itext="用户名称"/>
                                    </Col>
                                    <Col span={14}>
                                    <InputItem InputProps={bind("usrnam")}  maxLength={40}  desp="用户名称" path="/usrnam" />
                                    </Col>
                                </Row>
                            </Col>
                
                        </Row>
                    </Col>
                </Row>

                <Row>
                    <Col span={24}>

                        <Row>
                            <Col span={12}>
                                <Row className='row'>
                                    <Col span={5} offset={2}>
                                    <Label   itext="起始日期"/>
                                    </Col>
                                    <Col span={14}>
                                    <DatePickerItem InputProps={bind("begdat")}  desp="起始日期" path="/begdat" />
                                    </Col>
                                </Row>
                            </Col>
                            <Col span={12}>
                                <Row className='row'>
                                    <Col span={5} offset={2}>
                                    <Label   itext="结束日期"/>
                                    </Col>
                                    <Col span={14}>
                                    <DatePickerItem InputProps={bind("enddat")}  desp="结束日期" path="/enddat" />
                                    </Col>
                                </Row>
                            </Col>
                
                        </Row>
                    </Col>
                </Row>

                <div className='button0'>
                    <div className='button2'>
                        <Button type="primary" icon="search" onClick={this.onSelevt}>
                            <Label i18nId="MTABUT_BT000022" />
                        </Button>
                    </div>
    
                </div>
                <Row >
                    <Col span={23} style={{marginLeft:40}}>
                        <Table pagination={{ pageSize: 10, hideOnSinglePage: true }} columns={this.evtlstHeader} dataSource={this.model.evtlst}  />
                    </Col>
                </Row>

			</div >
				)
			}
		}
