import React, { Component, Fragment } from 'react'
import {
    Page, Validator, Notification, FormItem,
    InputItem, Input, Bind, SelectItem, Button, Label, DatePickerItem, Section, Table, TextArea, ConfirmButton, Steps, Checkbox, 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 } from 'mobx'
import { Row, Col, Popconfirm, Modal, Spin } from 'antd';
import { UnicodePicker, ContryCodePicker } from '@/components/Business-Library'
import Business from '@/views/Public/Business'

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

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

    constructor(props) {
        super(props)
        this.model = props.model;
       // console.log(props)
        this.bind = Bind.bind(this)
    }

    componentWillUnmount() {
       // this.model.closeValidate()//关闭校验
    }
	
    //按钮事件
    onGetref0 = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/getref0', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
    onCustype = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/custype', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
    //按钮事件
    onCodsel1_selbut = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/codsel1_selbut', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
    onCodsel1_selbut1 = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/codsel1_selbut1', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
  
    onSel0 = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/sel0', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
    
    onGetref1 = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/getref1', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
   
 
    onSel2 = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/sel2', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
   
 
    onGetref = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/getref', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
    onSel = async () => {
        this.formBlur = true  //已触发表单提交处理
        const rtnmsg = await Api.post('cptadv/sel', { data: this.model })
        if (rtnmsg.retcod == SUCCESS) {
            Notification.success({ message: '数据提交成功!' })

        }
        else {
            Notification.error({ message: '服务端请求失败!' })
        }
        //余下逻辑处理

    }

    onExtkey0 = () => {
        this.formBlur = true  //已触发表单提交处理
        Validator.validate(this.model, this.model.descriptor, async (errors, values) => {
            if (errors)
                return
            const rtnmsg = await Api.post('cptadv/extkey0', { data: this.model })
            if (rtnmsg.retcod == SUCCESS) {
                Notification.success({ message: '数据提交成功!' })

            }
            else {
                Notification.error({ message: '服务端请求失败!' })
            }
            //余下逻辑处理

        })
    }
    loading = false;

    //交易内实现
    renderPage() {
        const bind = this.bind
        const { i18n } = this.props
        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} offset={2}>
                                <Label value="外管申报" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
                <Row>
                    <Col span={12}>
                        <Row className="row">
							<Col span={5} offset={2}>
								<Label value="申报单类型" />
							</Col>
							<Col span={14}>
								<SelectItem InputProps={bind("bopmod_szflg")} code={CodeTable.szflg} />
							</Col>
						</Row>
                    </Col>
                </Row>
                <Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label value="款项性质" />
							</Col>
							<Col span={14}>
								<SelectItem InputProps={bind("bopmod_acttyp")} code={CodeTable.acttyp} />
							</Col>
						</Row>
					</Col>
				</Row>
                <Row>
                    <Col span={12}>
                        <Row className="row">
                            <Col span={5} offset={2}>
                                <Label value="跨境人民币申报" />
                            </Col>
                        </Row>
                    </Col>
                </Row>
                <Row>
					<Col span={12}>
						<Row className="row">
							<Col span={5} offset={2}>
								<Label value="是否报送跨境人民币信息" />
							</Col>
							<Col span={14}>
								<SelectItem InputProps={bind("rmbmod_rmbflg")} code={CodeTable.rmbflg} />
							</Col>
						</Row>
					</Col>
				</Row>
                <br />
				<Row type="flex" justify="center">
					<Col>
				        <div className='button0'>
					        <div className='button2'>
						        {/* 退出按钮 */}
						        <ConfirmButton onOK={this.onRtn} title="" message="确定退出？">
							        <Label i18nId="MTABUT_BT000464" />
						        </ConfirmButton>
					        </div>
					        <div className='button2'>
						        {/* 暂存按钮 */}
						        <ConfirmButton onOK={this.onPed} title="" message="确定暂存？">
							        <Label i18nId="MTABUT_BT000398" />
						        </ConfirmButton>
					        </div>
					        <div className='button2'>
						        {/* 检核按钮 */}
						        <Button onClick={this.onChk}>
							        <Label i18nId="MTABUT_BT000180" />
						        </Button>
					        </div>
				        </div>
				    </Col>
                </Row>
            </div>
        )
    }
}
