/*
 * Create:      柿子
 * CreateDate:  2022/07/13
 * Describe：   视光管理系统 - 检查结束
 * */
import React, { Component } from 'react';
import { Modal, Button, message } from 'antd';
import { $http } from 'containers/config/https';
class EndOfInspection extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: true
    }
  }

  // 修改弹窗状态
  modifyVisible = (visible) => {
    this.setState({ visible })
  }

  // 验光师结束检查(结束检查)
  handleEndInspection = () => {
    let currentPatData = sessionStorage.getItem('titleData') && JSON.parse(sessionStorage.getItem('titleData'));
    if (!(currentPatData && currentPatData.queID)) { return }
    let data = {
      params: [{
        queID: currentPatData?.queID,
        areaRoomID: currentPatData?.areaRoomID || '',
        statusCode: 'F'
      }],
    }
    $http.post('urlS', this, {
      code: '17020009',
      data,
      success: function (res) {
        if (res.errorCode === '0') {
          message.success(res.errorMessage || '操作成功');
          this.props.handleEndOperation && this.props.handleEndOperation(0, 'Y');
        }
      }
    })
  }

  // 继续处理当前病人
  handleContinueProcessing = () => {
    // this.props.handleEndOperation && this.props.handleEndOperation(1);
    this.modifyVisible(false);
  }

  render() {
    let { visible } = this.state;
    return (
      <Modal
        width="520px"
        title="检查结束"
        footer={null}
        destroyOnClose={true}
        visible={visible}
        onCancel={() => this.modifyVisible(false)}
      >
        <div>
          <p style={{ textAlign: 'center' }}>是否完成本次检查???</p>
          <div className="flex-center" style={{ marginTop: 52 }}>
            <Button
              type="primary"
              style={{ marginRight: 20 }}
              onClick={this.handleEndInspection}
            >
              {'确定>>返回病人列表'}
            </Button>
            <Button
              ghost
              type="danger"
              onClick={this.handleContinueProcessing}
            >
              {'取消>>继续处理当前病人'}
            </Button>
          </div>
        </div>
      </Modal>
    );
  }
};

export default EndOfInspection;
