"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 _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _vmMap = _interopRequireDefault(require("../../../vm-map"));
var _WorkStatic = _interopRequireDefault(require("./WorkStatic"));
var _api = require("../../api");
require("./index.less");
var _refresh = _interopRequireDefault(require("../../imgs/refresh.png"));
var _position = _interopRequireDefault(require("../../imgs/position.png"));
var _todayWork = _interopRequireDefault(require("../../imgs/todayWork.png"));
var _todayOnline = _interopRequireDefault(require("../../imgs/todayOnline.png"));
var _refresh_light = _interopRequireDefault(require("../../../vtx-car-modal/imgs/refresh_light.png"));
var _position_light = _interopRequireDefault(require("../../../vtx-car-modal/imgs/position_light.png"));
var _todayWork_light = _interopRequireDefault(require("../../imgs/todayWork_light.png"));
var _todayOnline_light = _interopRequireDefault(require("../../imgs/todayOnline_light.png"));
var _WorkStaticDay = _interopRequireDefault(require("./WorkStaticDay"));
var _ListZymx = _interopRequireDefault(require("./ListZymx"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
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;
  var id = props.id,
    employmentTypeCode = props.employmentTypeCode,
    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)({
      activeKey: '1',
      contentStyle: {}
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var activeKey = state.activeKey,
    contentStyle = state.contentStyle;
  var _BaseService$useBaseI = _api.BaseService.useBaseInfo(id),
    baseInfo = _BaseService$useBaseI.baseInfo,
    info = _BaseService$useBaseI.info;
  var _BaseService$useWorkI = _api.BaseService.useWorkInfo(id, (0, _moment["default"])().format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD')),
    workInfoRes = _BaseService$useWorkI.workInfoRes;
  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$useMapIn = _api.BaseService.useMapInfo(id, coordType),
    mapPoints = _BaseService$useMapIn.mapPoints,
    pointLngLat = _BaseService$useMapIn.pointLngLat,
    mapPolygons = _BaseService$useMapIn.mapPolygons;
  (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 gifType = function gifType() {
    if (employmentTypeCode === null || employmentTypeCode === void 0 ? void 0 : employmentTypeCode.startsWith('zhzf')) {
      return '-zhzf';
    }
    if (employmentTypeCode === null || employmentTypeCode === void 0 ? void 0 : employmentTypeCode.startsWith('yl')) {
      return '-yl';
    }
    return '';
  };
  var baseTabContent = /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left--info"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left--gif staff-base-left--gif".concat(gifType())
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left--infoList"
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: baseInfo,
    gap: 8,
    isValueCenter: true
  })));
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base ".concat(theme)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left",
    ref: contentRef,
    style: contentStyle
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left-base"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u57FA\u672C\u4FE1\u606F"
  }), baseTabContent), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left-baseBottom"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u5B9E\u65F6\u4FE1\u606F",
    extra: /*#__PURE__*/_react["default"].createElement("div", {
      className: "staff-base-left--online"
    }, (info === null || info === void 0 ? void 0 : info.statusName) || '--')
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left--text"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _refresh["default"] : _refresh_light["default"]
  }), (info === null || info === void 0 ? void 0 : info.updateTime) || '--'), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left--text"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _position["default"] : _position_light["default"]
  }), (info === null || info === void 0 ? void 0 : info.address) || '--'), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-left-baseBottom--map"
  }, /*#__PURE__*/_react["default"].createElement(_vmMap["default"], Object.assign({
    mapCenter: (pointLngLat === null || pointLngLat === void 0 ? void 0 : pointLngLat.length) ? pointLngLat : 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: "staff-base-right",
    style: contentStyle
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    className: "staff-base-right-top"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u4F5C\u4E1A\u7EDF\u8BA1",
    extra: /*#__PURE__*/_react["default"].createElement(_antd.Radio.Group, {
      value: activeKey,
      onChange: function onChange(e) {
        return setState({
          activeKey: e.target.value
        });
      }
    }, /*#__PURE__*/_react["default"].createElement(_antd.Radio.Button, {
      value: '1'
    }, "\u4ECA\u65E5"), /*#__PURE__*/_react["default"].createElement(_antd.Radio.Button, {
      value: '2'
    }, "\u672C\u6708"))
  }), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, activeKey === '1' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_antd.Row, null, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 9
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _todayWork["default"] : _todayWork_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-itemContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-name"
  }, "\u4ECA\u65E5\u884C\u8D70"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, ((_a = workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.totalMileage) === null || _a === void 0 ? void 0 : _a.toFixed(2)) || 0), "km"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _todayOnline["default"] : _todayOnline_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-itemContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-name"
  }, "\u4ECA\u65E5\u5728\u7EBF"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (workInfoRes === null || workInfoRes === void 0 ? void 0 : workInfoRes.onlineTimeStr) || '--')))))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 15
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--right"
  }, /*#__PURE__*/_react["default"].createElement(_WorkStaticDay["default"], {
    id: id
  }))))), activeKey === '2' && /*#__PURE__*/_react["default"].createElement(_WorkStatic["default"], {
    id: id
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-wgfx"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u4F5C\u4E1A\u660E\u7EC6"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-wgfx-content"
  }, /*#__PURE__*/_react["default"].createElement(_ListZymx["default"], {
    id: id,
    startDate: activeKey === '2' ? (0, _moment["default"])().startOf('M').format('YYYY-MM-DD') : '',
    endDate: activeKey === '2' ? (0, _moment["default"])().endOf('M').format('YYYY-MM-DD') : ''
  })))));
};
var _default = exports["default"] = BaseInfo;
//# sourceMappingURL=index.js.map
