"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 _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
require("./index.less");
var _plan = _interopRequireDefault(require("../../imgs/plan.png"));
var _actual = _interopRequireDefault(require("../../imgs/actual.png"));
var _plan_light = _interopRequireDefault(require("../../imgs/plan_light.png"));
var _actual_light = _interopRequireDefault(require("../../imgs/actual_light.png"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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; } /**
 * 路段-统计信息
 */
function Statistical(props) {
  var id = props.id,
    service = props.service;
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    sDate = _useSettings.startDate,
    eDate = _useSettings.endDate;
  var _useSetState = (0, _ahooks.useSetState)({
      startDate: sDate ? sDate : (0, _moment["default"])().startOf('M').format('YYYY-MM-DD'),
      endDate: eDate ? eDate : (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, service),
    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(_antd.Row, {
    gutter: [10, 10]
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    xxl: 4,
    xl: 4,
    lg: 8,
    md: 8
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: theme === 'dark' ? _plan["default"] : _plan_light["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(_antd.Col, {
    xxl: 4,
    xl: 4,
    lg: 8,
    md: 8
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: theme === 'dark' ? _actual["default"] : _actual_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "road-statistic-summary-main-item--name"
  }, "\u6838\u7B97\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(_antd.Col, {
    xxl: 4,
    xl: 4,
    lg: 8,
    md: 8
  }, /*#__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: theme === 'dark' ? '#4AFFE6' : '#5B8FF9',
    trailColor: theme === 'dark' ? 'rgba(255,255,255,0.2)' : '#E4E4E4',
    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(_antd.Col, {
    xxl: 12,
    xl: 12,
    lg: 24,
    md: 24
  }, /*#__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(_antd.Row, {
    gutter: [10, 10]
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    xxl: 12,
    xl: 12,
    lg: 24,
    md: 24
  }, /*#__PURE__*/_react["default"].createElement(_Zylc["default"], {
    data: mileAnalysis
  })), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    xxl: 12,
    xl: 12,
    lg: 24,
    md: 24
  }, /*#__PURE__*/_react["default"].createElement(_Zywcl["default"], {
    data: mileAnalysis
  })))));
}
var _default = exports["default"] = Statistical;
//# sourceMappingURL=index.js.map
