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(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(arr) { if (Array.isArray(arr)) return arr; }
import { Progress } from 'antd';
import dayjs from 'dayjs';
import { useState } from 'react';
import { VmFilter, VmTag, VmTitle } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { overViewService } from "../../api";
import { getPercent } from "../OverView/RightBottom";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var GDCLXL = function GDCLXL(_ref) {
  var _ref$classPrefix = _ref.classPrefix,
    classPrefix = _ref$classPrefix === void 0 ? '' : _ref$classPrefix,
    id = _ref.id,
    _ref$businessPackage = _ref.businessPackage,
    businessPackage = _ref$businessPackage === void 0 ? 'LANDING' : _ref$businessPackage;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var _useState = useState(dayjs()),
    _useState2 = _slicedToArray(_useState, 2),
    date = _useState2[0],
    setDate = _useState2[1];
  // 工单处理效率
  var efficiencyData = overViewService.useResolveEfficiency({
    throwPointId: id,
    businessPackage: businessPackage,
    beginTime: date.format('YYYY-MM-DD 00:00:00'),
    endTime: date.format('YYYY-MM-DD 23:59:59')
  });
  var strokeColor = {
    alarm: {
      '0%': '#FF575F',
      '100%': '#F5222D'
    },
    normal: {
      '0%': '#02E574',
      '100%': '#0FB964'
    }
  };
  return /*#__PURE__*/_jsxs("div", {
    children: [/*#__PURE__*/_jsxs("div", {
      className: "".concat(classPrefix, "-row"),
      children: [/*#__PURE__*/_jsx(VmTitle, {
        title: "\u5DE5\u5355\u5904\u7406\u6548\u7387",
        border: false
      }), /*#__PURE__*/_jsx(VmFilter.VMDatePicker, {
        value: date,
        onChange: function onChange(value) {
          return setDate(value);
        }
      })]
    }), /*#__PURE__*/_jsx("div", {
      className: "".concat(classPrefix, "-progress"),
      children: [{
        name: 'AI 工单关闭率',
        value: getPercent(efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.closeRate),
        avg: getPercent(efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.closeRateAverage),
        unit: '%'
      }, {
        name: 'AI 工单处理时长',
        value: ((efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.resolveMinute) || 0) / ((efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.resolveMinuteAverage) || 1),
        avg: (efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.resolveMinuteAverage) || 0,
        unit: '分'
      }, {
        name: 'AI 工单及时关闭率',
        value: getPercent(efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.closeInTimeRate),
        avg: getPercent(efficiencyData === null || efficiencyData === void 0 ? void 0 : efficiencyData.closeInTimeRateAverage),
        unit: '%'
      }].map(function (ele, index) {
        return /*#__PURE__*/_jsxs("div", {
          className: "".concat(classPrefix, "-progress-item"),
          children: [/*#__PURE__*/_jsx("div", {
            children: ele.name
          }), /*#__PURE__*/_jsx(Progress, {
            type: "dashboard",
            percent: ele.value,
            width: 120,
            size: 120,
            strokeWidth: 10,
            gapDegree: 180,
            strokeLinecap: "butt",
            strokeColor: strokeColor[ele.value > ele.avg ? 'alarm' : 'normal'],
            trailColor: isDark ? '#9B9FA8' : 'rgba(0, 0, 0, 0.1)',
            railColor: isDark ? '#9B9FA8' : 'rgba(0, 0, 0, 0.1)',
            showInfo: false
          }), /*#__PURE__*/_jsxs("div", {
            className: "".concat(classPrefix, "-progress-desc"),
            children: ["\u5747\u503C", ele.avg, ele.unit, /*#__PURE__*/_jsxs("div", {
              className: ele.value < ele.avg ? 'white_red' : 'white_green',
              style: {
                fontSize: 16
              },
              children: [ele.value, ele.unit]
            }), /*#__PURE__*/_jsx(VmTag, {
              type: ele.value < ele.avg ? 'red' : 'green',
              title: "".concat(ele.value < ele.avg ? '差' : '优', "\u4E8E\u5747\u503C"),
              style: {
                border: 'unset',
                marginTop: 12
              }
            })]
          })]
        }, index);
      })
    })]
  });
};
export default GDCLXL;