"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 _olMap = require("@vtx/ol-map");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmFilter = require("../../../vm-filter");
var _vmSubTitle = require("../../../vm-sub-title");
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _WorkDetail = _interopRequireDefault(require("./WorkDetail"));
var _api = require("../../api");
require("./index.less");
var _all = _interopRequireDefault(require("../../imgs/all.png"));
var _in_done = _interopRequireDefault(require("../../imgs/in_done.png"));
var _in_undone = _interopRequireDefault(require("../../imgs/in_undone.png"));
var _out_done = _interopRequireDefault(require("../../imgs/out_done.png"));
var _bucket = _interopRequireDefault(require("../../imgs/bucket.png"));
var _weight = _interopRequireDefault(require("../../imgs/weight.png"));
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 BaseInfo = function BaseInfo(props) {
  var _a, _b, _c;
  var id = props.id,
    info = props.info;
  var _useSettings = (0, _useSettings2["default"])(),
    _useSettings$theme = _useSettings.theme,
    theme = _useSettings$theme === void 0 ? 'light' : _useSettings$theme,
    startDate = _useSettings.startDate;
  var _useSetState = (0, _ahooks.useSetState)({
      date: startDate ? (0, _moment["default"])(startDate) : (0, _moment["default"])(),
      subTabPanes: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var mapRef = (0, _react.useRef)(null);
  var date = state.date;
  var paramConfigsList = _api.BaseService.useConfig();
  var _BaseService$useSYCar = _api.BaseService.useSYCarInfo(id, date.format('YYYY-MM-DD')),
    syInfo = _BaseService$useSYCar.syInfo;
  var _ref = ((_a = info === null || info === void 0 ? void 0 : info.geoLocation) === null || _a === void 0 ? void 0 : _a.lngLats) ? info.geoLocation.lngLats.split(',') : [],
    _ref2 = _slicedToArray(_ref, 2),
    lng = _ref2[0],
    lat = _ref2[1];
  var mapPoints = lng ? [{
    name: info.carCode,
    geometryInfo: {
      type: 'point',
      lngLats: "".concat(lng, ",").concat(lat),
      coordType: 'wgs84'
    }
  }] : [];
  (0, _react.useEffect)(function () {
    if (lng && lat) {
      mapRef.current.fitView(mapPoints);
    }
  }, [lng, lat, JSON.stringify(mapPoints)]);
  var baseInfo = [{
    label: '当前状态',
    key: 'carStatusStr',
    value: info === null || info === void 0 ? void 0 : info.carStatusStr
  }, {
    label: '所属单位',
    key: 'deptName',
    value: info === null || info === void 0 ? void 0 : info.deptName
  }, {
    label: '使用单位',
    key: 'useUnitName',
    value: info === null || info === void 0 ? void 0 : info.useUnitName
  }, {
    label: '所属标段',
    key: 'bidSectionName',
    value: info === null || info === void 0 ? void 0 : info.bidSectionName
  }, {
    label: '行政区划',
    key: 'divisionName',
    value: info === null || info === void 0 ? void 0 : info.divisionName
  }, {
    label: '责任人',
    key: 'manageStaffName',
    value: info === null || info === void 0 ? void 0 : info.manageStaffName
  }, {
    label: '联系人',
    key: 'contact',
    value: info === null || info === void 0 ? void 0 : info.contact
  }, {
    label: '联系电话',
    key: 'contactWay',
    value: info === null || info === void 0 ? void 0 : info.contactWay
  }, {
    label: '最后定位时间',
    key: 'equipmentTime',
    value: info === null || info === void 0 ? void 0 : info.equipmentTime
  }, {
    label: '当前位置',
    key: 'address',
    value: info === null || info === void 0 ? void 0 : info.address
  }];
  var mapStyle = {
    type: 'Marker',
    style: {
      icon: 'CAR',
      color: '#119FFB'
    }
  };
  var isTask = (syInfo === null || syInfo === void 0 ? void 0 : syInfo.planCollectPoints) > 0; // 是否有任务
  var syInfos = isTask ? [{
    name: '计划收集点位',
    icon: _all["default"],
    value: syInfo === null || syInfo === void 0 ? void 0 : syInfo.planCollectPoints
  }, {
    name: '计划内已收',
    icon: _in_done["default"],
    value: syInfo === null || syInfo === void 0 ? void 0 : syInfo.taskCollectPoints
  }, {
    name: '计划内未收',
    icon: _in_undone["default"],
    value: syInfo === null || syInfo === void 0 ? void 0 : syInfo.taskNoCollectPoints
  }, {
    name: '计划外已收',
    icon: _out_done["default"],
    value: syInfo === null || syInfo === void 0 ? void 0 : syInfo.noneTaskCollectPoints
  }] : [{
    name: '已收点位',
    icon: _in_done["default"],
    value: (syInfo === null || syInfo === void 0 ? void 0 : syInfo.planCollectPoints) || 0
  }];
  if (((_b = paramConfigsList['SHOW_COLLECTING_BUCKETS']) === null || _b === void 0 ? void 0 : _b.value) === 'true') {
    syInfos.push({
      name: '收集桶数',
      icon: _bucket["default"],
      value: syInfo === null || syInfo === void 0 ? void 0 : syInfo.bucketNum
    });
  }
  if (((_c = paramConfigsList['SHOW_WEIGHTING']) === null || _c === void 0 ? void 0 : _c.value) === 'true') {
    syInfos.push({
      name: '收集重量',
      icon: _weight["default"],
      value: syInfo === null || syInfo === void 0 ? void 0 : syInfo.weight,
      unit: 'kg'
    });
  }
  var per = (syInfo === null || syInfo === void 0 ? void 0 : syInfo.taskCollectPoints) / ((syInfo === null || syInfo === void 0 ? void 0 : syInfo.planCollectPoints) || 1) * 100;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base ".concat(theme)
  }, /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      height: '100%',
      width: 330
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-left"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle.SubTitle2, {
    title: "\u57FA\u672C\u4FE1\u606F"
  }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: baseInfo,
    horizontal: true,
    gap: 13,
    padding: "0 20px"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-left-title"
  }, "\u4ECA\u65E5\u7EDF\u8BA1"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static-item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static-item-value1"
  }, (info === null || info === void 0 ? void 0 : info.mileage) || 0, ' ', /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static-item-unit"
  }, "km")), /*#__PURE__*/_react["default"].createElement("div", null, "\u4ECA\u65E5\u884C\u9A76")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static-item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static-item-value2"
  }, (info === null || info === void 0 ? void 0 : info.gpsSpeed) || 0, ' ', /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-today-static-item-unit"
  }, "km/h")), /*#__PURE__*/_react["default"].createElement("div", null, "\u5F53\u524D\u901F\u5EA6"))), lng && lat ? (/*#__PURE__*/_react["default"].createElement("div", {
    style: {
      height: 160,
      padding: '0 20px'
    }
  }, /*#__PURE__*/_react["default"].createElement(_olMap.Map, {
    tk: "1adbb6e47668cb33757cd799548bf1f4",
    createdMap: function createdMap(map) {
      mapRef.current = map;
    }
  }, /*#__PURE__*/_react["default"].createElement(_olMap.FeatureLayer, {
    data: mapPoints,
    style: mapStyle
  })))) : null)), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-right"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [10, 10]
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-right-static"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle.SubTitle2, {
    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("div", {
    className: "flex-start"
  }, isTask && (/*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-right-static-progress"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
    type: "circle",
    percent: per,
    strokeWidth: 8,
    trailColor: theme === 'dark' ? '#4AFFE6' : '#EAECF1',
    strokeColor: theme === 'dark' ? '#1890ff' : {
      '0%': '#82B4FC',
      '100%': '#5192FF'
    },
    strokeLinecap: "butt",
    showInfo: false,
    width: 100
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      transform: 'translateY(10px)'
    }
  }, "\u4EFB\u52A1\u5B8C\u6210\u7387"), /*#__PURE__*/_react["default"].createElement("span", {
    className: "sycar-base-right-static-progress-text"
  }, per === null || per === void 0 ? void 0 : per.toFixed(2), "%")))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-right-static-items"
  }, syInfos.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "sycar-base-right-static-item",
      key: index
    }, /*#__PURE__*/_react["default"].createElement("img", {
      src: item.icon
    }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
      className: "sycar-base-right-static-item-name"
    }, item.value, item.unit || '个'), /*#__PURE__*/_react["default"].createElement("div", null, item.name)));
  }))))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-right-analyse"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle.SubTitle2, {
    title: "\u4F5C\u4E1A\u660E\u7EC6"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "sycar-base-right-analyse-table"
  }, /*#__PURE__*/_react["default"].createElement(_WorkDetail["default"], {
    id: id,
    paramConfigsList: paramConfigsList,
    date: date === null || date === void 0 ? void 0 : date.format('YYYY-MM-DD')
  })))))));
};
var _default = exports["default"] = BaseInfo;
//# sourceMappingURL=index.js.map
