"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = BJHZ;
var _react = _interopRequireDefault(require("react"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _api = require("../../api");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function BJHZ(_ref) {
  var id = _ref.id,
    startTime = _ref.startTime,
    endTime = _ref.endTime;
  var _useSettings = (0, _useSettings2["default"])(),
    isDark = _useSettings.isDark,
    theme = _useSettings.theme;
  var chartFontColor = '#000';
  var _AlarmService$useAlar = _api.AlarmService.useAlarmSummary(id, startTime.format('YYYY-MM-DD'), endTime.format('YYYY-MM-DD')),
    alarmSummaryData = _AlarmService$useAlar.alarmSummaryData;
  var _alarmSummaryData$dat = alarmSummaryData.dataList,
    dataList = _alarmSummaryData$dat === void 0 ? [] : _alarmSummaryData$dat,
    _alarmSummaryData$tot = alarmSummaryData.totalCount,
    totalCount = _alarmSummaryData$tot === void 0 ? 0 : _alarmSummaryData$tot;
  var data = dataList.map(function (item) {
    var _a;
    return Object.assign(Object.assign({}, item), {
      name: item.alarmTypeName,
      value: (_a = item.count) !== null && _a !== void 0 ? _a : 0
    });
  });
  var isDeepTheme = isDark || theme === 'blue';
  var option = {
    color: ['#438EF7', '#1DD27B'],
    backgroundColor: 'transparent',
    title: {
      textAlign: 'center',
      text: '报警总次数',
      textStyle: {
        fontSize: 14,
        color: '#595959'
      },
      subtext: totalCount !== null && totalCount !== void 0 ? totalCount : 0,
      subtextStyle: {
        fontSize: 22,
        color: '#1F1F1F'
      },
      top: '33%',
      left: '49%'
    },
    tooltip: {
      show: true,
      formatter: "{b}\uFF1A{c}\u6B21"
    },
    legend: {
      orient: 'vertical',
      bottom: 0,
      itemGap: 8,
      icon: 'circle',
      itemWidth: 10,
      itemHeight: 10,
      textStyle: {
        fontSize: 14,
        color: isDeepTheme ? '#fff' : '#000',
        rich: {
          name: {
            fontSize: 14,
            width: 120,
            color: isDeepTheme ? '#fff' : '#595959'
          },
          value: {
            fontSize: 14,
            width: 80,
            color: isDeepTheme ? '#fff' : '#1F1F1F'
          },
          rate: {
            fontSize: 14,
            width: 80,
            color: isDeepTheme ? '#fff' : '#8C8C8C'
          }
        }
      },
      pageIconColor: chartFontColor,
      pageIconInactiveColor: chartFontColor,
      pageTextStyle: {
        color: isDeepTheme ? '#fff' : chartFontColor
      },
      formatter: function formatter(name) {
        var value = data.find(function (item) {
          return item.name === name;
        });
        if (value) {
          return "{name|".concat(name, "} {value|").concat(value.value, "\u6B21} {rate|").concat(value === null || value === void 0 ? void 0 : value.rate, "%}");
        } else {
          return '';
        }
      }
    },
    series: [{
      type: 'pie',
      radius: ['40%', '55%'],
      center: ['50%', '40%'],
      hoverAnimation: true,
      z: 10,
      label: {
        show: false
      },
      data: data,
      labelLine: {
        show: false
      }
    }, {
      type: 'pie',
      radius: ['55%', '60%'],
      center: ['50%', '40%'],
      hoverAnimation: true,
      z: 10,
      label: {
        show: false
      },
      data: data,
      labelLine: {
        show: false
      },
      itemStyle: {
        borderWidth: 0,
        opacity: 0.3
      }
    }]
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card-title"
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: "jzlj-card-title-text"
  }, "\u62A5\u8B66\u6C47\u603B")), /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card-content"
  }, /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '300px',
      width: '100%'
    }
  })));
}
//# sourceMappingURL=BJHZ.js.map
