"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 _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _Zylc = _interopRequireDefault(require("./Zylc"));
var _Zywcl = _interopRequireDefault(require("./Zywcl"));
var _api = require("../../api");
require("./index.less");
var _plan = _interopRequireDefault(require("../../imgs/plan.png"));
var _actual = _interopRequireDefault(require("../../imgs/actual.png"));
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 = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0) { ; } } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
function Statistical(props) {
  var id = props.id;
  var _useSetState = (0, _ahooks.useSetState)({
      startDate: (0, _moment["default"])().format('YYYY-MM-DD'),
      endDate: (0, _moment["default"])().format('YYYY-MM-DD')
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var startDate = state.startDate,
    endDate = state.endDate;
  var _StaticService$useSum = _api.StaticService.useSummaryInfo(id, startDate, endDate),
    summaryInfo = _StaticService$useSum.summaryInfo,
    completionRate = _StaticService$useSum.completionRate,
    mileAnalysis = _StaticService$useSum.mileAnalysis;
  var handleDateChange = function handleDateChange(start, end) {
    setState({
      startDate: start,
      endDate: end
    });
  };
  var overRate = (summaryInfo === null || summaryInfo === void 0 ? void 0 : summaryInfo.planMileage) ? (summaryInfo.validMileage / (summaryInfo === null || summaryInfo === void 0 ? void 0 : summaryInfo.planMileage) * 100).toFixed(2) : 0;
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-title"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u4F5C\u4E1A\u6C47\u603B\u7EDF\u8BA1"
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_vmFilter.VMRangePicker, {
    value: [(0, _moment["default"])(startDate), (0, _moment["default"])(endDate)],
    onChange: function onChange(dates) {
      return dates && handleDateChange((0, _moment["default"])(dates[0]).format('YYYY-MM-DD'), (0, _moment["default"])(dates[1]).format('YYYY-MM-DD'));
    }
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: _plan["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item--name"
  }, "\u8BA1\u5212\u4F5C\u4E1A\u91CC\u7A0B"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (summaryInfo === null || summaryInfo === void 0 ? void 0 : summaryInfo.planMileage) || 0), "\u516C\u91CC"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: _actual["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item--name"
  }, "\u5B9E\u9645\u4F5C\u4E1A\u91CC\u7A0B"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (summaryInfo === null || summaryInfo === void 0 ? void 0 : summaryInfo.validMileage) || 0), "\u516C\u91CC"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-progress"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
    type: "circle",
    percent: Number(overRate) || 0,
    strokeWidth: 10,
    strokeColor: "#4AFFE6",
    trailColor: "rgba(255,255,255,0.2)",
    strokeLinecap: "butt",
    showInfo: false
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-progress--name"
  }, "\u6574\u4F53\u5B8C\u6210\u7387"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-progress--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, overRate), "%"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--block",
    style: {
      background: '#FFD736'
    }
  }), '<50%', /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (completionRate === null || completionRate === void 0 ? void 0 : completionRate.dayNum1) || 0), "\u5929")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--block",
    style: {
      background: '#3CA5FE'
    }
  }), '50%≤完成率<80%', /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (completionRate === null || completionRate === void 0 ? void 0 : completionRate.dayNum2) || 0), "\u5929")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--block",
    style: {
      background: '#4AEDEB'
    }
  }), '80%≤完成率<100%', /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (completionRate === null || completionRate === void 0 ? void 0 : completionRate.dayNum3) || 0), "\u5929")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--item"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--block",
    style: {
      background: '#4AED88'
    }
  }), '=100%', /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-rate--value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (completionRate === null || completionRate === void 0 ? void 0 : completionRate.dayNum4) || 0), "\u5929"))))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-charts"
  }, /*#__PURE__*/_react["default"].createElement(_Zylc["default"], {
    data: mileAnalysis
  }), /*#__PURE__*/_react["default"].createElement(_Zywcl["default"], {
    data: mileAnalysis
  })));
}
var _default = Statistical;
exports["default"] = _default;
//# sourceMappingURL=index.js.map
