import React, { Component, Fragment } from 'react'
import {
    Page, Validator, Notification, FormItem,
    InputItem, Input, Bind, SelectItem, Button, Label, DatePickerItem, Section, ConfirmButton, Steps, CheckboxItem, TextAreaItem, Table
} 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, Tooltip, 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 mFptsel from '../model'
const { Pre, Next, StepWrapper } = Steps
const CodeTable = CodeTableFactory.getInstance()
const confirm = Modal.confirm

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

    constructor(props) {
        super(props)
        this.model = new mFptsel()
        this.bind = Bind.bind(this)
 
    }

    async componentWillMount() {
		/*
		*添加初始化代码
		*/
		// const rtnmsg = await Api.post('fptsel/init', { data: this.model })
		// if (rtnmsg.retcod == SUCCESS) {
		// 	const { data } = rtnmsg
		// 	runInAction(() => {
		// 		Object.assign(this.model, data)
		// 	})
		// }
		//快照模式下，不必开启校验，否则，静默校验，和记录变动
		!this.loadDisplay() && this.model.openMonitor && this.model.openMonitor() //开启校验	
	}
	componentWillUnmount() {
		this.model.stopMonitor && this.model.stopMonitor()//关闭校验
	}

    fptp_fsdlstHeader=[
    	{
    		title:<Label itext="福费廷卖出编号" />, 
    		dataIndex:"ownref",
    		key:"ownref",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.ownref,r2.ownref),
    	},
    	{
    		title:<Label itext="描述" />, 
    		dataIndex:"nam",
    		key:"nam",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.nam,r2.nam),
    	},
    	{
    		title:<Label itext="福费廷买入编号" />, 
    		dataIndex:"pntref",
    		key:"pntref",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.pntref,r2.pntref),
    	},
    	{
    		title:<Label itext="卖出利率" />, 
    		dataIndex:"basrat",
    		key:"basrat",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.basrat,r2.basrat),
    	},
    	{
    		title:<Label itext="利差" />, 
    		dataIndex:"difrat",
    		key:"difrat",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.difrat,r2.difrat),
    	},
    	{
    		title:<Label itext="创建日期" />, 
    		dataIndex:"credat",
    		key:"credat",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.credat,r2.credat),
    	},
    	{
    		title:<Label itext="卖出日期" />, 
    		dataIndex:"opndat",
    		key:"opndat",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.opndat,r2.opndat),
    	},
    	{
    		title:<Label itext="经办柜员" />, 
    		dataIndex:"ownusr",
    		key:"ownusr",
    		width:100,
    		sorter: (r1,r2)=>ColSorter(r1.ownusr,r2.ownusr),
        },
        {
			title: <Label itext="操作" />,
			width: 60,
			key: "operation",
			render: (val, row, index) => {
				return (

					<Link to={{ pathname: 'fstset', query: { inr: row.inr} }}>回款转汇</Link>)
			}
		},
    ]

    onFptp_fsdsel= ()=>{
        this.formBlur=true  //已触发表单提交处理
        Validator.validate(this.model,this.model.descriptor,async(errors,values)=>{
                if(errors)
                    return 
                const rtnmsg = await Api.post('fptsel/fptp_fsdsel',{data:this.model})
                if(rtnmsg.retcod == SUCCESS)
                {
                    this.model.fptp_fsdlst = rtnmsg.data.fptp_fsdlst;
                    
                }
                else
                {
                	Notification.error({message:'服务端请求失败!'})
                }
                //余下逻辑处理
                    
        })
    }
    //交易内实现
    renderPage() {
        const bind = this.bind
        const { i18n } = this.props
        const { bchlevelLst } = this.props.extra
        const dateFormat = 'YYYY-MM-DD';
        //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={12}>
							<Row className="row">
								<Col span={5} >
									{/* 福费廷卖出编号 */}
									<Label itext="福费廷卖出编号" trn="fptsel" />
								</Col>
								<Col span={10}>
                                <InputItem InputProps={bind("fptp_ownref1")}  maxLength={16}  desp="福费廷卖出编号" path="/fptp/ownref1" />
								</Col>
								<Col span={4} offset={1}>
									<Button type="primary" icon="search" onClick={this.onFptp_fsdsel} desp="查询" path="/sel">
										<Label itext="查询" />
									</Button>
								</Col>
							</Row>
						</Col>


					</Row>


					<Table rowKey="inr" columns={this.fptp_fsdlstHeader}  dataSource={this.model.fptp_fsdlst}   path="/fptp/fsdlst"/>



            </div >
        )
    }
}
