import React, { Component } from 'react';
import { sendEqpTrigger, sendEqpTrigger1, sendEqpTrigger2, sendEqpTrigger3 } from './../../../services/eqpAndMovingRing'
import { Button, Toast } from 'amos-framework';
import { deviceAlarmData,donghuanAlarmData,newdonghuanAlarmData} from './../../../_mock/sendAlarm';


const eqp = "";
class EqpAndMovingRing extends Component {
  constructor(props) {
    super(props);
    this.state = {

    };
  }

  /**
   *
   */
  getData = (str) => {
    // getEqpTrigger('/src/_mock/eqpAndMovingRing/index.json',str,(data)=>{
    //     sendEqpTrigger(data).then(res=>{
    //         console.log("eqpAndMovingRing.getData",res);
    //     },err=>{
    //         console.log("eqpAndMovingRing.getData err",err);
    //     });
    // })
    if ('eqpTrigerData' == str) {
      sendEqpTrigger(deviceAlarmData.eqpTrigerData)
        .then(res => {
          Toast['success']({
            title: '成功',
            content: '设备触发成功'
          });
        }, err => {
          Toast['error']({
            title: '失败',
            content: '设备触发失败'
          });
        });
    } else if ('eqpClsData' === str) {
      sendEqpTrigger(deviceAlarmData.eqpClsData)
        .then(res => {
          Toast['success']({
            title: '成功',
            content: '设备清除成功'
          });
        }, err => {
          Toast['error']({
            title: '失败',
            content: '设备清除失败'
          });
        });
    } else if ('movingRingTrigerData' == str) {
      sendEqpTrigger(donghuanAlarmData.movingRingTrigerData)
        .then(res => {
          Toast['success']({
            title: '成功',
            content: '动环触发成功'
          });
        }, err => {
          Toast['error']({
            title: '失败',
            content: '动环触发失败'
          });
        });
    } else if ('movingRingClsData' == str) {
      sendEqpTrigger(donghuanAlarmData.movingRingClsData)
        .then(res => {
          Toast['success']({
            title: '成功',
            content: '动环清除成功'
          });
        }, err => {
          Toast['error']({
            title: '失败',
            content: '动环清除失败'
          });
        });
    }
    else if ('newmovingRingTrigerData' == str) {
      sendEqpTrigger(newdonghuanAlarmData.newmovingRingTrigerData)
      .then(res => {
        Toast['success']({
          title: '成功',
          content: '新动环触发成功'
        });
      }, err => {
        Toast['error']({
          title: '失败',
          content: '新动环触发失败'
        });
      });
    }
    else if ('newmovingRingClsData' == str) {
      sendEqpTrigger(newdonghuanAlarmData.newmovingRingClsData)
        .then(res => {
          Toast['success']({
            title: '成功',
            content: '新动环清除成功'
          });
        }, err => {
          Toast['error']({
            title: '失败',
            content: '新动环清除失败'
          });
        });
    }

  }



  render() {

    return (
      <div>
        {/* <div style={{ marginTop: '30px' }}>
          <div style={{ float: 'left' }} onClick={() => { this.getData('eqpTrigerData') }} ><Button>设备触发</Button></div>
          <div style={{ marginLeft: '104px' }} onClick={() => { this.getData('eqpClsData') }}><Button>设备清除</Button></div>
        </div>
        <div style={{ marginTop: '10px' }}>
          <div style={{ float: 'left' }} onClick={() => { this.getData('movingRingTrigerData') }}><Button>动环触发</Button></div>
          <div style={{ marginLeft: '104px' }} onClick={() => { this.getData('movingRingClsData') }}><Button>动环清除</Button></div>
        </div> */}
        <div style={{ marginTop: '30px' }}>
          <div style={{ float: 'left' }} onClick={() => { this.getData('newmovingRingTrigerData') }}><Button>新动环设备触发</Button></div>
          <div style={{ marginLeft: '104px' }} onClick={() => { this.getData('newmovingRingClsData') }}><Button>新动环设备清除</Button></div>
        </div>
      </div>
    );
  }
}

export default EqpAndMovingRing;
