"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _ahooks = require("ahooks");
var _moment = _interopRequireDefault(require("moment"));
var _antd = require("antd");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmFilter = require("../../../vm-filter");
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _vmMap = _interopRequireDefault(require("../../../vm-map"));
var _api = require("../../api");
require("./index.less");
var _todayWork = _interopRequireDefault(require("../../imgs/todayWork.png"));
var _todayOnline = _interopRequireDefault(require("../../imgs/todayOnline.png"));
var _todayWork_light = _interopRequireDefault(require("../../imgs/todayWork_light.png"));
var _todayOnline_light = _interopRequireDefault(require("../../imgs/todayOnline_light.png"));
var _ListZymx = _interopRequireDefault(require("./ListZymx"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var MAX_CONTENT_HEIGHT = document.body.clientHeight - 60 - 30;
var BaseInfo = function BaseInfo(props) {
  var _a, _b, _c, _d, _e, _f;
  var id = props.id,
    customMapInfo = props.customMapInfo;
  var contentRef = (0, _react.useRef)(null);
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    isDark = _useSettings.isDark,
    mapInfo = _useSettings.mapInfo;
  var _useSetState = (0, _ahooks.useSetState)({
      contentStyle: {},
      date: (0, _moment["default"])()
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var contentStyle = state.contentStyle,
    date = state.date;
  var coordType = (customMapInfo === null || customMapInfo === void 0 ? void 0 : customMapInfo.coordinate) || (mapInfo === null || mapInfo === void 0 ? void 0 : mapInfo.coordinate);
  if ((customMapInfo === null || customMapInfo === void 0 ? void 0 : customMapInfo.mapType) === 'olmap') {
    coordType = 'wgs84';
  }
  var _BaseService$useBaseI = _api.BaseService.useBaseInfo(id, coordType),
    baseInfo = _BaseService$useBaseI.baseInfo,
    mapPolygons = _BaseService$useBaseI.mapPolygons,
    numInfo = _BaseService$useBaseI.numInfo,
    mapPoints = _BaseService$useBaseI.mapPoints;
  var _BaseService$useWorkI = _api.BaseService.useWorkInfo(id, date.format('YYYY-MM-DD')),
    workInfoRes = _BaseService$useWorkI.workInfoRes;
  (0, _react.useEffect)(function () {
    var _a;
    var contentHeight = ((_a = contentRef.current) === null || _a === void 0 ? void 0 : _a.clientHeight) || 0;
    if (contentHeight >= MAX_CONTENT_HEIGHT) {
      setState({
        contentStyle: {
          maxHeight: MAX_CONTENT_HEIGHT,
          overflowY: 'auto'
        }
      });
    } else {
      setState({
        contentStyle: {}
      });
    }
  }, [contentRef === null || contentRef === void 0 ? void 0 : contentRef.current]);
  var baseTabContent = /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left--info"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left--infoList"
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: baseInfo,
    gap: 8,
    isValueCenter: true
  })));
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base ".concat(theme)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left",
    ref: contentRef,
    style: contentStyle
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left-base"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u57FA\u672C\u4FE1\u606F"
  }), baseTabContent), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left-baseBottom"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u5B9E\u65F6\u7EDF\u8BA1"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left-num"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left-num--text"
  }, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: 'area-base-left-num--text-num'
  }, (_a = numInfo === null || numInfo === void 0 ? void 0 : numInfo.shiftNum) !== null && _a !== void 0 ? _a : '--'), "\u4EBA"), /*#__PURE__*/_react["default"].createElement("span", null, "\u5F53\u524D\u6392\u73ED\u4EBA\u6570")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left-num--text"
  }, /*#__PURE__*/_react["default"].createElement("span", null, /*#__PURE__*/_react["default"].createElement("span", {
    className: 'area-base-left-num--text-num'
  }, (_b = numInfo === null || numInfo === void 0 ? void 0 : numInfo.onlineNum) !== null && _b !== void 0 ? _b : '--'), "\u4EBA"), /*#__PURE__*/_react["default"].createElement("span", null, "\u5F53\u524D\u5728\u7EBF\u4EBA\u6570"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-left-baseBottom--map"
  }, /*#__PURE__*/_react["default"].createElement(_vmMap["default"], Object.assign({
    mapCenter: mapInfo === null || mapInfo === void 0 ? void 0 : mapInfo.mapCenter,
    mapType: (mapInfo === null || mapInfo === void 0 ? void 0 : mapInfo.mapType) || 'bmap',
    mapPoints: mapPoints,
    mapPolygons: mapPolygons
  }, customMapInfo))))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right",
    style: contentStyle
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    className: "area-base-right-top"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u4F5C\u4E1A\u7EDF\u8BA1",
    extra: /*#__PURE__*/_react["default"].createElement(_vmFilter.VMDatePicker, {
      value: date,
      onChange: function onChange(date) {
        setState({
          date: date
        });
      }
    })
  }), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, null, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 15
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _todayWork["default"] : _todayWork_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-itemContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-item-name"
  }, "\u603B\u6392\u73ED\u4EBA\u6570"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-item-value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (_c = workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.totalNum) !== null && _c !== void 0 ? _c : '--')))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _todayOnline["default"] : _todayOnline_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-itemContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-item-name"
  }, "\u603B\u51FA\u52E4\u4EBA\u6570"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--pngs-item-value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (_d = workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.normalNum) !== null && _d !== void 0 ? _d : '--')))))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 9
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--right"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
    type: "circle",
    percent: (_e = workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.rate) !== null && _e !== void 0 ? _e : 0,
    strokeWidth: 8,
    trailColor: theme === 'dark' ? '#4AFFE6' : '#CFCFCF',
    strokeColor: theme === 'dark' ? 'rgba(255,255,255,0.2)' : '#37B74E',
    strokeLinecap: "butt",
    showInfo: false,
    width: 60
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-base-right--right-progress"
  }, /*#__PURE__*/_react["default"].createElement("span", null, "\u51FA\u52E4\u7387"), /*#__PURE__*/_react["default"].createElement("span", {
    style: {
      color: theme === 'dark' ? 'rgba(255,255,255,0.2)' : '#37B74E'
    }
  }, (_f = workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.rate) !== null && _f !== void 0 ? _f : 0, "%"))))))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-wgfx"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u91CC\u7A0B\u5206\u6790"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "area-wgfx-content"
  }, /*#__PURE__*/_react["default"].createElement(_ListZymx["default"], {
    id: id,
    startDate: date.format('YYYY-MM-DD 00:00:00'),
    endDate: date.format('YYYY-MM-DD 23:59:59')
  })))));
};
var _default = exports["default"] = BaseInfo;
//# sourceMappingURL=index.js.map
