/**
 * 区域进场量分析
 */

import { Col, Row } from 'antd';
import dayjs from 'dayjs';
import { VmEmpty, VmFactor, VmPieCharts } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { BaseService } from "../../api";
import mileageLight from "../../imgs/mileage.png";
import mileageDark from "../../imgs/mileage_dark.png";
import onlineLight from "../../imgs/online.png";
import onlineDark from "../../imgs/online_dark.png";
import allTimeLight from "../../imgs/all_time.png";
import allTimeDark from "../../imgs/all_time_dark.png";
import avgLight from "../../imgs/avg.png";
import avgDark from "../../imgs/avg_dark.png";
import "./index.less";
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
function WorkStaticDay(_ref) {
  var type = _ref.type,
    service = _ref.service,
    id = _ref.id;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var _BaseService$useStaff = BaseService.useStaffStatic(id, type === 'day' ? dayjs().format('YYYY-MM-DD') : dayjs().startOf('M').format('YYYY-MM-DD'), dayjs().format('YYYY-MM-DD'), service),
    workInfoRes = _BaseService$useStaff.workInfoRes;
  var _ref2 = workInfoRes || {},
    _ref2$totalMileageStr = _ref2.totalMileageStr,
    totalMileageStr = _ref2$totalMileageStr === void 0 ? 0 : _ref2$totalMileageStr,
    onlineHour = _ref2.onlineHour,
    validWorkHour = _ref2.validWorkHour,
    outShiftHour = _ref2.outShiftHour,
    violateStayHour = _ref2.violateStayHour,
    outPostHour = _ref2.outPostHour;
  var avgWorkHour = 0;
  var detail = [];
  if (Number(validWorkHour)) {
    avgWorkHour = (Number(validWorkHour) / dayjs().date()).toFixed(2) || 0;
    detail.push({
      name: '有效作业',
      value: Number(validWorkHour)
    });
  }
  if (Number(outShiftHour)) {
    detail.push({
      name: '脱岗',
      value: Number(outShiftHour)
    });
  }
  if (Number(violateStayHour)) {
    detail.push({
      name: '违规滞留',
      value: Number(violateStayHour)
    });
  }
  if (Number(outPostHour)) {
    detail.push({
      name: '异常离线',
      value: Number(outPostHour)
    });
  }
  return /*#__PURE__*/_jsxs(Row, {
    children: [/*#__PURE__*/_jsx(Col, {
      span: 9,
      children: /*#__PURE__*/_jsxs("div", {
        className: "staff-base-right-static",
        children: [type === 'day' && /*#__PURE__*/_jsxs(_Fragment, {
          children: [/*#__PURE__*/_jsx(VmFactor, {
            name: "\u4ECA\u65E5\u884C\u8D70",
            unit: "km",
            value: totalMileageStr || 0,
            img: isDark ? mileageDark : mileageLight,
            fontType: "blue"
          }), /*#__PURE__*/_jsx(VmFactor, {
            name: "\u4ECA\u65E5\u5728\u7EBF",
            unit: "h",
            value: onlineHour || '--',
            img: isDark ? onlineDark : onlineLight,
            style: {
              marginBottom: 12
            },
            fontType: "green"
          })]
        }), type === 'month' && /*#__PURE__*/_jsxs(_Fragment, {
          children: [/*#__PURE__*/_jsx(VmFactor, {
            name: "\u603B\u6709\u6548\u4F5C\u4E1A\u65F6\u957F",
            unit: "h",
            value: validWorkHour || 0,
            img: isDark ? allTimeDark : allTimeLight,
            fontType: "blue"
          }), /*#__PURE__*/_jsx(VmFactor, {
            name: "\u65E5\u5747\u6709\u6548\u4F5C\u4E1A\u65F6\u957F",
            unit: "h",
            value: avgWorkHour || '--',
            img: isDark ? avgDark : avgLight,
            fontType: "green",
            style: {
              marginBottom: 12
            }
          })]
        })]
      })
    }), /*#__PURE__*/_jsx(Col, {
      span: 15,
      children: /*#__PURE__*/_jsx("div", {
        className: "staff-base-right--right",
        children: /*#__PURE__*/_jsx("div", {
          className: "staff-base-static-chart",
          children: detail.length ? /*#__PURE__*/_jsx(VmPieCharts, {
            unit: "h",
            name: "",
            innerRadius: ['50%', '65%'],
            outerRadius: ['65%', '70%'],
            dataList: detail,
            legendConfig: {
              right: 20
            }
          }) : /*#__PURE__*/_jsx(VmEmpty, {
            type: "NO_CHART"
          })
        })
      })
    })]
  });
}
export default WorkStaticDay;