"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = WorkStatic;
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"));
var _zzx = _interopRequireDefault(require("../../../vtx-staff-modal/imgs/zzx.png"));
var _rjzx = _interopRequireDefault(require("../../../vtx-staff-modal/imgs/rjzx.png"));
var _zzx_light = _interopRequireDefault(require("../../../vtx-staff-modal/imgs/zzx_light.png"));
var _rjzx_light = _interopRequireDefault(require("../../../vtx-staff-modal/imgs/rjzx_light.png"));
var _antd = require("antd");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
 * 作业统计
 */

function WorkStatic(_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"])().startOf('M').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%', '65%'],
      center: ['25%', '50%'],
      hoverAnimation: true,
      z: 10,
      itemStyle: {
        normal: {
          borderWidth: 2,
          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
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_antd.Row, null, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 9
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _zzx["default"] : _zzx_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-itemContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-name"
  }, "\u603B\u6709\u6548\u4F5C\u4E1A\u65F6\u957F"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.totalOnLineTimeStr) || '--')))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: isDark ? _rjzx["default"] : _rjzx_light["default"]
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-itemContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-name"
  }, "\u65E5\u5747\u6709\u6548\u4F5C\u4E1A\u65F6\u957F"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--pngs-item-value"
  }, /*#__PURE__*/_react["default"].createElement("span", null, (workStaticRes === null || workStaticRes === void 0 ? void 0 : workStaticRes.avgOnLineTimeStr) || '--')))))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 15
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "staff-base-right--right"
  }, ((_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=WorkStatic.js.map
