"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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")), _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"), _RecentAlarmTable = _interopRequireDefault(require("./table/RecentAlarmTable")), _HistoryAlarmTable = _interopRequireDefault(require("./../historyAlarm/table/HistoryAlarmTable")), _BatchClearAlarm = _interopRequireDefault(require("./table/BatchClearAlarm"));

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, r = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? r : 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 r = _getRequireWildcardCache(t);
  if (r && r.has(e)) return r.get(e);
  var a = {}, l = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var n in e) if ("default" !== n && Object.prototype.hasOwnProperty.call(e, n)) {
    var i = l ? Object.getOwnPropertyDescriptor(e, n) : null;
    i && (i.get || i.set) ? Object.defineProperty(a, n, i) : a[n] = e[n];
  }
  return a.default = e, r && r.set(e, a), a;
}

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

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;
  }
}

require("./alarm.scss");

var Option = _amosAntd.Select.Option, TabPane = _amosAntd.Tabs.TabPane, alarmLevel = [ {
  name: "全部",
  value: "-1"
}, {
  name: "一级",
  value: "1"
}, {
  name: "二级",
  value: "2"
}, {
  name: "三级",
  value: "3"
} ], alarmType = [ {
  name: "全部",
  value: "-1"
}, {
  name: "指标越界",
  value: 1
}, {
  name: "采集异常",
  value: 2
}, {
  name: "设备掉线",
  value: 3
} ], AlarmManageMent = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var a;
    return (0, _classCallCheck2.default)(this, r), a = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(a), "getOperation", (function() {
      var e = [], t = a.state, r = t.selectedKey, l = t.filterCondition;
      if (e.push(_react.default.createElement("div", {
        className: "alarm-refresh",
        title: "刷新",
        onClick: a.refreshAlarm
      }, _react.default.createElement("img", {
        src: require("./../../assets/iot/alarm/refresh.png"),
        alt: ""
      }))), "1" === r && a.currentAlarmChild) {
        var n = a.currentAlarmChild.batchClearAlarm, i = a.currentAlarmChild.getSelectedRowKeys;
        e.push(_react.default.createElement(_BatchClearAlarm.default, {
          title: "批量清除",
          type: "batch",
          selectedRowKeys: i,
          clearAlarm: n,
          btnType: "primary",
          size: "default"
        }));
        var u = a.currentAlarmChild.getRefreshTime();
        e.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            lineHeight: "50px",
            "font-size": "16px"
          }
        }, u));
      } else if ("2" === r && a.historyAlarmChild) {
        var o = a.historyAlarmChild.batchClearAlarm;
        e.push(_react.default.createElement("div", {
          className: "alarm-delete",
          title: "批量删除",
          onClick: o
        }, _react.default.createElement("img", {
          src: require("./../../assets/iot/alarm/delete.png"),
          alt: ""
        })));
        var s = a.historyAlarmChild.getRefreshTime();
        e.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            lineHeight: "50px",
            "font-size": "16px"
          }
        }, s));
      } else {
        var c = a.getCurrentTime();
        e.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            lineHeight: "50px",
            "font-size": "16px"
          }
        }, c));
      }
      return e.push(_react.default.createElement("div", {
        style: {
          float: "right",
          "background-color": "#E3E3E3",
          height: "50px",
          lineHeight: "50px",
          "font-size": "16px"
        }
      }, "告警刷新时间:")), e.push(_react.default.createElement("div", {
        className: "current-alarm-input"
      }, _react.default.createElement(_amosAntd.Input, {
        placeholder: "告警源",
        value: l.name,
        onChange: a.onChange
      }))), e.push(_react.default.createElement("div", {
        className: "current-alarm-select"
      }, _react.default.createElement(_amosAntd.Select, {
        style: {
          width: "160px"
        },
        dropdownStyle: {
          width: "160px"
        },
        dropdownMatchSelectWidth: !0,
        onChange: function(e) {
          return a.onSelectedChange(e, "type");
        },
        placeholder: "告警类型",
        allowClear: !0,
        value: l.type
      }, alarmType.map((function(e) {
        return _react.default.createElement(Option, {
          key: e.value,
          value: e.value
        }, e.name);
      }))))), e.push(_react.default.createElement("div", {
        className: "current-alarm-select"
      }, _react.default.createElement(_amosAntd.Select, {
        style: {
          width: "160px"
        },
        dropdownStyle: {
          width: "160px"
        },
        dropdownMatchSelectWidth: !0,
        onChange: function(e) {
          return a.onSelectedChange(e, "level");
        },
        placeholder: "告警级别",
        allowClear: !0,
        value: l.level
      }, alarmLevel.map((function(e) {
        return _react.default.createElement(Option, {
          key: e.value,
          value: e.value
        }, e.name);
      }))))), e;
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "onSelectedChange", (function(e, t) {
      var r = a.state.filterCondition;
      r[t] = e, a.setState({
        filterCondition: r
      });
      var l = a.state.selectedKey, n = {
        current: 0,
        pageSize: 10
      };
      if ("level" === t ? r.level = e : "type" === t && (r.type = e), "1" === l && a.currentAlarmChild) (0, 
      a.currentAlarmChild.refreshData)(n, r); else if ("2" === l && a.historyAlarmChild) {
        (0, a.historyAlarmChild.refreshData)(n, r);
      }
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "onChange", (function(e) {
      var t = a.state.filterCondition;
      t.name = e.target.value, a.setState({
        filterCondition: t
      });
      var r = a.state.selectedKey, l = {
        current: 0,
        pageSize: 10
      };
      if ("1" === r && a.currentAlarmChild) (0, a.currentAlarmChild.refreshData)(l, t); else if ("2" === r && a.historyAlarmChild) {
        (0, a.historyAlarmChild.refreshData)(l, t);
      }
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "changeSelected", (function(e) {
      a.setState({
        filterCondition: {}
      }), a.refreshAlarm(), a.setState({
        selectedKey: e
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "getCurrentTime", (function() {
      var e = new Date, t = e.getHours(), r = e.getMinutes();
      return r < 10 && (r = "0".concat(r)), "".concat(t, "时").concat(r, "分");
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "refreshAlarm", (function() {
      var e = a.state.selectedKey;
      "1" === e && a.currentAlarmChild ? a.currentAlarmChild.refreshTime() : "2" === e && a.historyAlarmChild && a.historyAlarmChild.refreshTime(), 
      a.setState({
        selectedKey: e
      });
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "updateStatus", (function() {
      a.setState({
        selectedKey: a.state.selectedKey
      });
    })), a.state = {
      selectedKey: "1",
      filterCondition: {}
    }, a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "componentWillMount",
    value: function() {}
  }, {
    key: "componentDidMount",
    value: function() {}
  }, {
    key: "componentWillReceiveProps",
    value: function(e) {}
  }, {
    key: "componentWillUnmount",
    value: function() {}
  }, {
    key: "render",
    value: function() {
      var e = this;
      return _react.default.createElement(_amosAntd.Tabs, {
        type: "card",
        tabBarExtraContent: this.getOperation(),
        onChange: this.changeSelected
      }, _react.default.createElement(TabPane, {
        tab: "当前告警",
        key: "1"
      }, _react.default.createElement(_RecentAlarmTable.default, (0, _extends2.default)({
        ref: function(t) {
          return e.currentAlarmChild = t;
        },
        updateStatus: this.updateStatus
      }, this.props))), _react.default.createElement(TabPane, {
        tab: "历史告警",
        key: "2"
      }, _react.default.createElement(_HistoryAlarmTable.default, {
        ref: function(t) {
          return e.historyAlarmChild = t;
        },
        updateStatus: this.updateStatus
      })));
    }
  } ]), r;
}(_react.Component);

AlarmManageMent.displayName = "AlarmManageMent", AlarmManageMent.propTypes = {};

var _default = AlarmManageMent;

exports.default = _default;