"use strict";
Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;
var _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 _interopRequireDefault(e) {
  return e && e.__esModule ? e : {
    default: e
  }
}

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

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

function _typeof(e) {
  return (_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e) {
    return typeof e
  } : function(e) {
    return e && "function" == typeof Symbol && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e
  })(e)
}

function _extends() {
  return (_extends = Object.assign || function(e) {
    for (var t = 1; t < arguments.length; t++) {
      var r, a = arguments[t];
      for (r in a) Object.prototype.hasOwnProperty.call(a, r) && (e[r] = a[r])
    }
    return e
  }).apply(this, arguments)
}

function _classCallCheck(e, t) {
  if (!(e instanceof t)) throw new TypeError("Cannot call a class as a function")
}

function _defineProperties(e, t) {
  for (var r = 0; r < t.length; r++) {
    var a = t[r];
    a.enumerable = a.enumerable || !1, a.configurable = !0, "value" in a && (a.writable = !0), Object.defineProperty(e, a.key, a)
  }
}

function _createClass(e, t, r) {
  return t && _defineProperties(e.prototype, t), r && _defineProperties(e, r), e
}

function _inherits(e, t) {
  if ("function" != typeof t && null !== t) throw new TypeError("Super expression must either be null or a function");
  e.prototype = Object.create(t && t.prototype, {
    constructor: {
      value: e,
      writable: !0,
      configurable: !0
    }
  }), t && _setPrototypeOf(e, t)
}

function _setPrototypeOf(e, t) {
  return (_setPrototypeOf = Object.setPrototypeOf || function(e, t) {
    return e.__proto__ = t, e
  })(e, t)
}

function _createSuper(r) {
  var a = _isNativeReflectConstruct();
  return function() {
    var e, t = _getPrototypeOf(r);
    return _possibleConstructorReturn(this, a ? (e = _getPrototypeOf(this).constructor, Reflect.construct(t, arguments, e)) : t.apply(this, arguments))
  }
}

function _possibleConstructorReturn(e, t) {
  return !t || "object" !== _typeof(t) && "function" != typeof t ? _assertThisInitialized(e) : t
}

function _assertThisInitialized(e) {
  if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  return e
}

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

function _getPrototypeOf(e) {
  return (_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function(e) {
    return e.__proto__ || Object.getPrototypeOf(e)
  })(e)
}

function _defineProperty(e, t, r) {
  return t in e ? Object.defineProperty(e, t, {
    value: r,
    enumerable: !0,
    configurable: !0,
    writable: !0
  }) : e[t] = r, e
}
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() {
    _inherits(r, _react.Component);
    var t = _createSuper(r);

    function r(e) {
      var i;
      return _classCallCheck(this, r), _defineProperty(_assertThisInitialized(i = t.call(this, e)), "getOperation", function() {
        var e, t, r = [],
          a = i.state,
          n = a.selectedKey,
          l = a.filterCondition;
        return r.push(_react.default.createElement("div", {
          className: "alarm-refresh",
          title: "刷新",
          onClick: i.refreshAlarm
        }, _react.default.createElement("img", {
          src: require("./../../assets/iot/alarm/refresh.png"),
          alt: ""
        }))), "1" === n && i.refs.currentAlarmChild ? (e = i.refs.currentAlarmChild.batchClearAlarm, a = i.refs.currentAlarmChild.getSelectedRowKeys, r.push(_react.default.createElement(_BatchClearAlarm.default, {
          title: "批量清除",
          type: "batch",
          selectedRowKeys: a,
          clearAlarm: e,
          btnType: "primary",
          size: "default"
        })), e = i.refs.currentAlarmChild.getRefreshTime(), r.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            "line-height": "50px",
            "font-size": "16px"
          }
        }, e))) : "2" === n && i.refs.historyAlarmChild ? (t = i.refs.historyAlarmChild.batchClearAlarm, r.push(_react.default.createElement("div", {
          className: "alarm-delete",
          title: "批量删除",
          onClick: t
        }, _react.default.createElement("img", {
          src: require("./../../assets/iot/alarm/delete.png"),
          alt: ""
        }))), t = i.refs.historyAlarmChild.getRefreshTime(), r.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            "line-height": "50px",
            "font-size": "16px"
          }
        }, t))) : (t = i.getCurrentTime(), r.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            "line-height": "50px",
            "font-size": "16px"
          }
        }, t))), r.push(_react.default.createElement("div", {
          style: {
            float: "right",
            "background-color": "#E3E3E3",
            height: "50px",
            "line-height": "50px",
            "font-size": "16px"
          }
        }, "告警刷新时间:")), r.push(_react.default.createElement("div", {
          className: "current-alarm-input"
        }, _react.default.createElement(_amosAntd.Input, {
          placeholder: "告警源",
          value: l.name,
          onChange: i.onChange
        }))), r.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 i.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)
        })))), r.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 i.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)
        })))), r
      }), _defineProperty(_assertThisInitialized(i), "onSelectedChange", function(e, t) {
        var r = i.state.filterCondition;
        r[t] = e, i.setState({
          filterCondition: r
        });
        var a = i.state.selectedKey,
          n = {
            current: 0,
            pageSize: 10
          };
        "level" === t ? r.level = e : "type" === t && (r.type = e), "1" === a && i.refs.currentAlarmChild ? (0, i.refs.currentAlarmChild.refreshData)(n, r) : "2" === a && i.refs.historyAlarmChild && (0, i.refs.historyAlarmChild.refreshData)(n, r)
      }), _defineProperty(_assertThisInitialized(i), "onChange", function(e) {
        var t = i.state.filterCondition;
        t.name = e.target.value, i.setState({
          filterCondition: t
        });
        var r = i.state.selectedKey,
          e = {
            current: 0,
            pageSize: 10
          };
        "1" === r && i.refs.currentAlarmChild ? (0, i.refs.currentAlarmChild.refreshData)(e, t) : "2" === r && i.refs.historyAlarmChild && (0, i.refs.historyAlarmChild.refreshData)(e, t)
      }), _defineProperty(_assertThisInitialized(i), "changeSelected", function(e) {
        i.setState({
          filterCondition: {}
        }), i.refreshAlarm(), i.setState({
          selectedKey: e
        })
      }), _defineProperty(_assertThisInitialized(i), "getCurrentTime", function() {
        var e = new Date,
          t = e.getHours(),
          e = e.getMinutes();
        return e < 10 && (e = "0".concat(e)), "".concat(t, "时").concat(e, "分")
      }), _defineProperty(_assertThisInitialized(i), "refreshAlarm", function() {
        var e = i.state.selectedKey;
        "1" === e && i.refs.currentAlarmChild ? i.refs.currentAlarmChild.refreshTime() : "2" === e && i.refs.historyAlarmChild && i.refs.historyAlarmChild.refreshTime(), i.setState({
          selectedKey: e
        })
      }), _defineProperty(_assertThisInitialized(i), "updateStatus", function() {
        i.setState({
          selectedKey: i.state.selectedKey
        })
      }), i.state = {
        selectedKey: "1",
        filterCondition: {}
      }, i
    }
    return _createClass(r, [{
      key: "componentWillMount",
      value: function() {}
    }, {
      key: "componentDidMount",
      value: function() {}
    }, {
      key: "componentWillReceiveProps",
      value: function() {}
    }, {
      key: "componentWillUnmount",
      value: function() {}
    }, {
      key: "render",
      value: function() {
        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, _extends({
          ref: "currentAlarmChild",
          updateStatus: this.updateStatus
        }, this.props))), _react.default.createElement(TabPane, {
          tab: "历史告警",
          key: "2"
        }, _react.default.createElement(_HistoryAlarmTable.default, {
          ref: "historyAlarmChild",
          updateStatus: this.updateStatus
        })))
      }
    }]), r
  }();
AlarmManageMent.displayName = "AlarmManageMent", AlarmManageMent.propTypes = {};
var _default = AlarmManageMent;
exports.default = AlarmManageMent, module.exports = exports.default;
