"use strict";

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

var _react = _interopRequireDefault(require("react"));

var _ahooks = require("ahooks");

var _antd = require("antd");

var _moment = _interopRequireDefault(require("moment"));

var _vmFilter = require("../vm-filter");

var _api = require("./api");

var _propTypes = _interopRequireDefault(require("prop-types"));

var _vmInfoCollection = _interopRequireDefault(require("../vm-info-collection"));

require("./style");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }

function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }

function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }

function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }

function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

var DeviceContent = function DeviceContent() {
  var _useSetState = (0, _ahooks.useSetState)({
    start: (0, _moment["default"])().subtract(1, 'y'),
    end: (0, _moment["default"])(),
    ids: [],
    deviceId: '',
    missDate: [],
    normalDate: []
  }),
      _useSetState2 = _slicedToArray(_useSetState, 2),
      state = _useSetState2[0],
      setState = _useSetState2[1];

  var _DeviceData$deviceDat = _api.DeviceData.deviceData(state.deviceId),
      info = _DeviceData$deviceDat.info;

  var handleDateChange = function handleDateChange(deviceId) {
    setState({
      deviceId: deviceId
    });
  };

  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "community-throw-content"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "top-bar"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Space, {
    className: "right"
  }, /*#__PURE__*/_react["default"].createElement(_vmFilter.VMSelect, {
    value: state.deviceId,
    style: {
      width: '200px'
    },
    onChange: function onChange(value) {
      return value && handleDateChange(value);
    }
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "table-container"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "half"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-title"
  }, "\u57FA\u672C\u4FE1\u606F"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "half"
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: info.slice(0, 4)
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "half"
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: info.slice(5, 9)
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-title"
  }, "\u6EE1\u6EA2\u4FE1\u606F"), /*#__PURE__*/_react["default"].createElement(_antd.Timeline, {
    style: {
      marginTop: '10px'
    }
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "half"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-title"
  }, "\u8FD0\u884C\u4FE1\u606F"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "calendar"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Calendar, {
    fullscreen: false,
    headerRender: function headerRender() {
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "dateheader"
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: "date"
      }, (0, _moment["default"])().format('YYYY年MM月')), /*#__PURE__*/_react["default"].createElement("div", {
        className: "point",
        style: {
          position: 'absolute',
          right: '100px',
          top: '12px'
        }
      }), /*#__PURE__*/_react["default"].createElement("div", {
        className: "missText"
      }, "\u8FDF\u5230/\u65E9\u9000"));
    },
    dateCellRender: function dateCellRender(date) {
      if (state.missDate.indexOf((0, _moment["default"])(date).format('YYYY-MM-DD')) > -1) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          className: "point",
          style: {
            position: 'absolute',
            bottom: '10px',
            left: 'calc(50% - 3px)'
          }
        });
      }

      if (state.normalDate.indexOf((0, _moment["default"])(date).format('YYYY-MM-DD')) > -1) {
        return /*#__PURE__*/_react["default"].createElement("div", {
          className: "point",
          style: {
            position: 'absolute',
            bottom: '10px',
            left: 'calc(50% - 3px)',
            background: '#51E9CE'
          }
        });
      }
    }
  })))));
};

DeviceContent.propTypes = {
  id: _propTypes["default"].string
};
var _default = DeviceContent;
exports["default"] = _default;
//# sourceMappingURL=device.js.map
