import React,{ Component } from 'react';
import { Row, Col } from 'antd';
import { ConfirmButton, Button, Label } from '@/components/Common-Library'
import { observable } from 'mobx'
import { inject, observer } from 'mobx-react'

@observer
export  class BottomBtn extends Component{
  constructor(){
    super()
  }

  @observable
  pedLoading = false    //控制暂存按钮是否处于等待状态----等待状态时不可点击

  @observable
  savLoading = false    //控制暂存按钮是否处于等待状态----等待状态时不可点击

  // 退出按钮
	onRtn = () => {
		this.props._this.com.wrappedInstance.wrappedInstance.onRtn();
  }
  onRtnPed=async()=>{
    // let rtnflg='x'
    // let  sptinr  = ''
    // sptinr=this.props.extra.sptinr
    // if (sptinr) {
		// 	rtnmsg = await Api.post(this.props.extra.inifrm + '/ped', { params: { sptinr,rtnflg }, data: this.props.model })
		// } else {
		// 	rtnmsg = await Api.post(this.props.extra.inifrm + '/ped', { params: { rtnflg }, data: this.props.model })
    // }
    // 	if (rtnmsg.retcod == SUCCESS) {
    // 		Notification.success({ message: '数据暂存成功!' })
    // 		this.props.model.spt_inr=rtnmsg.data.sptinr
    // 	}
    // 	else {
    //         Notification.error({ message: '暂存服务失败!' })
    // 	}
    this.props._this.com.wrappedInstance.wrappedInstance.onRtnPed();//暂存并退出
  }

	// 暂存按钮
	onPed = () => {
    //点击按钮第一时间让按钮处于等待状态，防止多次点击触发事件
    this.pedLoading = true
    this.props._this.com.wrappedInstance.wrappedInstance.onPed();
    setTimeout(()=>{
      this.pedLoading = false
    },3000)
	}

	// 校验 按钮
	onChk = () => {
		this.props._this.com.wrappedInstance.wrappedInstance.onChk();
	}

	//提交按钮
	onSav = () => {
    //点击按钮第一时间让按钮处于等待状态，防止多次点击触发事件
    this.savLoading = true
    this.props._this.com.wrappedInstance.wrappedInstance.onSav();
    setTimeout(()=>{
      this.savLoading = false
    },3000)
	}

  render(){
    return (
      <Row type="flex" justify="center">
        <Col>
          <div className="button0">
            <div className='button2'>
              <ConfirmButton type="primary"
                onOK={this.onRtn}
                 onOK1={this.onRtnPed}
                message="确定退出？"
                isped={true}
              >
                <Label itext="退出" />
              </ConfirmButton>
            </div>

            <div className='button2'>
              <ConfirmButton type="primary"
                onOK={this.onPed}
                message="确定暂存？"
                loading={this.pedLoading}
              >
								<Label itext="暂存" />
							</ConfirmButton>
            </div>

            <div className='button2'>
              <Button type="primary" onClick={this.onChk} >
                <Label itext="检核" />
							</Button>
            </div>

            <div className='button2'>
              <ConfirmButton type="primary"
								onOK={this.onSav}
								icon="save"
                message="确定提交？"
                loading={this.savLoading}
							>
								<Label itext="提交" />
							</ConfirmButton>
            </div>
          </div>
        </Col>
      </Row>
    )
  }
}