"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Exeception;
var _react = _interopRequireDefault(require("react"));
var _moment = _interopRequireDefault(require("moment"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
 * 异常统计
 */

function Exeception(props) {
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    isDark = _useSettings.isDark,
    theme = _useSettings.theme;
  var id = props.id;
  var _AttendanceService$us = _api.AttendanceService.useAnalysis(id, (0, _moment["default"])().startOf('M').format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD')),
    attendAnalysisRes = _AttendanceService$us.attendAnalysisRes;
  var option = {
    color: chartColor,
    backgroundColor: 'transparent',
    tooltip: {
      show: true,
      trigger: 'item',
      formatter: function formatter(params) {
        var str = "".concat(params === null || params === void 0 ? void 0 : params.name);
        var color = params.color; // 获取系列的颜色
        str += "<div ><span style=\"color:".concat(color, ";font-size:24px \">\u2022</span> &nbsp;&nbsp;&nbsp;").concat(params.value, "\u6B21</div>");
        return str; // 返回带点的字符串
      }
    },
    legend: {
      orient: 'vertical',
      left: '50%',
      top: 'middle',
      align: 'left',
      itemGap: 12,
      itemWidth: 10,
      itemHeight: 10,
      formatter: function formatter(name) {
        var value = attendAnalysisRes.find(function (item) {
          return item.name === name;
        });
        if (value) {
          return "\t\t".concat(name, "\t\t").concat(value.value, "\u6B21\t\t");
        } else {
          return '';
        }
      },
      textStyle: {
        fontSize: 14,
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      pageIconColor: chartFontColor,
      pageIconInactiveColor: chartFontColor,
      pageTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    },
    series: [{
      type: 'pie',
      radius: ['55%', '75%'],
      center: ['30%', '50%'],
      hoverAnimation: true,
      z: 10,
      itemStyle: {
        normal: {
          borderWidth: 2,
          borderColor: isDark ? '#003359' : '#ffffff'
        }
      },
      label: {
        show: false
      },
      data: attendAnalysisRes,
      labelLine: {
        show: false
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    key: id,
    className: "staff-attend-exec"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u8003\u52E4\u5F02\u5E38\u7EDF\u8BA1"
  }), (attendAnalysisRes === null || attendAnalysisRes === void 0 ? void 0 : attendAnalysisRes.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '200px',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null)));
}
//# sourceMappingURL=Exeception.js.map
