"use strict";

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

function WorkStaticDay(_ref) {
  var id = _ref.id;
  var _a, _b;
  var _useSettings = (0, _useSettings2["default"])(),
    chartColor = _useSettings.chartColor,
    chartFontColor = _useSettings.chartFontColor,
    isDark = _useSettings.isDark,
    theme = _useSettings.theme;
  var _BaseService$useWorkS = _api.BaseService.useWorkStatic(id, (0, _moment["default"])().format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD')),
    workStaticRes = _BaseService$useWorkS.workStaticRes;
  var option = {
    color: chartColor,
    backgroundColor: 'transparent',
    tooltip: {
      show: true,
      trigger: 'item',
      formatter: function formatter(params) {
        var _a;
        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> ").concat((_a = params.data) === null || _a === void 0 ? void 0 : _a.durationStr, "</div>");
        return str; // 返回带点的字符串
      }
    },
    legend: {
      orient: 'vertical',
      left: '50%',
      top: 'middle',
      align: 'left',
      itemGap: 8,
      itemWidth: 10,
      itemHeight: 10,
      formatter: function formatter(name) {
        var value = workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.details.find(function (item) {
          return item.statusName === name;
        });
        if (value) {
          return "\t\t".concat(name, "\t\t").concat(value.durationStr, "\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: ['45%', '70%'],
      center: ['25%', '50%'],
      // hoverAnimation: true,
      // z: 10,
      itemStyle: {
        normal: {
          borderWidth: 0,
          borderColor: isDark ? '#003359' : '#ffffff'
        }
      },
      label: {
        show: false
      },
      data: ((_a = workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.details) === null || _a === void 0 ? void 0 : _a.length) > 0 ? workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.details.map(function (ele) {
        return {
          name: ele.statusName,
          value: ele.duration / 1000,
          durationStr: ele.durationStr
        };
      }) : [],
      labelLine: {
        show: false
      }
    },
    // 边框的设置
    {
      radius: ['65%', '70%'],
      center: ['25%', '50%'],
      type: 'pie',
      label: {
        normal: {
          show: false
        },
        emphasis: {
          show: false
        }
      },
      labelLine: {
        normal: {
          show: false
        },
        emphasis: {
          show: false
        }
      },
      animation: false,
      tooltip: {
        show: false
      },
      itemStyle: {
        normal: {
          color: 'rgba(250,250,250,0.5)'
        }
      },
      data: [{
        value: 1
      }]
    }]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-static"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-static-chart"
  }, ((_b = workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.details) === null || _b === void 0 ? void 0 : _b.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '100%',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null))));
}
//# sourceMappingURL=WorkStaticDay.js.map
