"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _amosAntd = require("amos-antd");

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, a = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? a : t;
  })(e);
}

function _interopRequireWildcard(e, t) {
  if (!t && e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var a = _getRequireWildcardCache(t);
  if (a && a.has(e)) return a.get(e);
  var l = {}, r = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var n in e) if ("default" !== n && Object.prototype.hasOwnProperty.call(e, n)) {
    var s = r ? Object.getOwnPropertyDescriptor(e, n) : null;
    s && (s.get || s.set) ? Object.defineProperty(l, n, s) : l[n] = e[n];
  }
  return l.default = e, a && a.set(e, l), l;
}

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var a, l = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var r = (0, _getPrototypeOf2.default)(this).constructor;
      a = Reflect.construct(l, arguments, r);
    } else a = l.apply(this, arguments);
    return (0, _possibleConstructorReturn2.default)(this, a);
  };
}

function _isNativeReflectConstruct() {
  if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
  if (Reflect.construct.sham) return !1;
  if ("function" == typeof Proxy) return !0;
  try {
    return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
    !0;
  } catch (e) {
    return !1;
  }
}

var createForm = _amosAntd.Form.create(), AlarmDetail = function(e) {
  (0, _inherits2.default)(a, e);
  var t = _createSuper(a);
  function a(e) {
    var l;
    return (0, _classCallCheck2.default)(this, a), l = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(l), "onClick", (function() {
      l.setState({
        visible: !0
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(l), "onSubClick", (function() {
      l.setState({
        subVisible: !0
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(l), "onChange", (function(e) {
      l.setState({
        inputStr: e.target.value
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(l), "handleCancel", (function(e) {
      l.setState({
        visible: !1
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(l), "handleSubCancel", (function() {
      l.setState({
        subVisible: !1
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(l), "handleSubmit", (function() {
      l.handleSubCancel();
      var e = [];
      e.push(l.props.alarmInfo.id), l.props.clearAlarm(l.state.inputStr, e);
    })), l.state = {
      visible: !1,
      subVisible: !1,
      inputStr: "告警已处理！"
    }, l;
  }
  return (0, _createClass2.default)(a, [ {
    key: "componentDidMount",
    value: function() {}
  }, {
    key: "render",
    value: function() {
      var e = this.props.alarmInfo, t = this.state.inputStr, a = e.name, l = e.level, r = e.status, n = e.type, s = e.durationDate, i = e.count, o = e.descr;
      return _react.default.createElement("div", {
        className: "alarm-detail-root"
      }, _react.default.createElement("label", {
        onClick: this.onClick
      }, "详情"), _react.default.createElement(_amosAntd.Modal, {
        className: "alarm-detail-modal",
        title: "告警详情",
        visible: this.state.visible,
        onCancel: this.handleCancel,
        footer: null,
        width: 700
      }, _react.default.createElement("div", {
        className: "alarm-detail-content"
      }, _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-source-name",
        span: 5
      }, "告警源:"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-source-value",
        span: 19
      }, a)), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-descr-name",
        span: 5
      }, "描述:"), _react.default.createElement(_amosAntd.Col, {
        title: o,
        className: "alarm-detail-descr-value",
        span: 19
      }, o)), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-level-name",
        span: 5
      }, "告警级别:"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-level-value",
        span: 19
      }, 1 === l ? "一级" : 2 === l ? "二级" : "三级")), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-type-name",
        span: 5
      }, "告警类型:"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-type-value",
        span: 19
      }, 1 === n ? "指标越界" : 2 === n ? "采集异常" : "设备掉线")), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-status-name",
        span: 5
      }, "状态:"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-status-value",
        span: 19
      }, 1 === r ? "未处理" : 2 === r ? "历史告警" : "已删除")), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-duration-name",
        span: 5
      }, "持续时间:"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-duration-value",
        span: 19
      }, s)), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-count-name",
        span: 5
      }, "告警次数:"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-count-value",
        span: 19
      }, i)), _react.default.createElement(_amosAntd.Row, {
        style: {
          "padding-top": "15px"
        }
      }, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-clear",
        span: 4,
        offset: 20,
        onClick: this.onSubClick
      }, "清除", _react.default.createElement(_amosAntd.Modal, {
        width: 333,
        className: "clear-alarm-modal",
        title: "清除告警信息",
        visible: this.state.subVisible,
        footer: null,
        onCancel: this.handleSubCancel,
        maskClosable: !1,
        destroyOnClose: !0
      }, _react.default.createElement("div", null, _react.default.createElement(_amosAntd.Row, {
        style: {
          marginTop: "20px",
          textAlign: "center"
        }
      }, _react.default.createElement(_amosAntd.Col, {
        span: 24
      }, _react.default.createElement("span", {
        style: {
          "font-size": "13px"
        }
      }, "备注："), _react.default.createElement(_amosAntd.Input, {
        value: t,
        style: {
          width: "250px",
          "font-size": "13px"
        },
        onChange: this.onChange
      })))), _react.default.createElement(_amosAntd.Row, {
        style: {
          "padding-top": "30px"
        }
      }, _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-clear",
        span: 4,
        offset: 6,
        onClick: this.handleSubmit
      }, "确定"), _react.default.createElement(_amosAntd.Col, {
        className: "alarm-detail-cancel",
        span: 4,
        offset: 2,
        onClick: this.handleSubCancel
      }, "取消"))))))));
    }
  } ]), a;
}(_react.Component);

AlarmDetail.displayName = "AlarmDetail", AlarmDetail.propTypes = {
  form: _propTypes.default.any,
  alarmInfo: _propTypes.default.any,
  clearAlarm: _propTypes.default.func
};

var _default = createForm(AlarmDetail);

exports.default = _default;