import React, { Component, Fragment } from 'react'
import {
	Page, Validator, Notification, FormItem,
	InputItem, Input, Bind, SelectItem, Button, Label, Table, Section, DatePickerItem,ConfirmButton,TextAreaItem,Steps
} 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 Business from '@/views/Public/Business'
import moment from 'moment';
import mLoginf from '../model'

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

@withRouter
@inject('UserContext')
@inject('i18n')
@observer
export default class XtycckScreen 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()
    // }
    dealstHeader=[
    	{
    		title:<Label itext="交易/服务码" />, 
    		dataIndex:"srvcod",
    		key:"srvcod",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.srvcod,r2.srvcod),
    	},
    	{
    		title:<Label itext="交易/服务名" />, 
    		dataIndex:"srvnam",
    		key:"srvnam",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.srvnam,r2.srvnam),
    	},
    	{
    		title:<Label itext="异常信息" />, 
    		dataIndex:"rtnmsg",
    		key:"rtnmsg",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.rtnmsg,r2.rtnmsg),
    	},
    	{
    		title:<Label itext="异常时间" />, 
    		dataIndex:"credattim",
    		key:"credattim",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.credattim,r2.credattim),
    	},
    ]

	//按钮事件 获取业务编号
    onSeldea= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
					const rtnmsg = await Api.post('loginf/seldea',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    this.model.dealst = rtnmsg.data['dealst'];
                    
                }
                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}>
									<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.onSeldea}>
                            <Label i18nId="MTABUT_BT000022" />
                        </Button>
                    </div>
    
                </div>
                <Row >
                    <Col span={23} style={{marginLeft:40}}>
                        <Table pagination={{ pageSize: 10, hideOnSinglePage: true }} columns={this.dealstHeader} dataSource={this.model.dealst}  />
                    </Col>
                </Row>

			</div >
				)
			}
		}
