"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = BJFX;
var _react = _interopRequireDefault(require("react"));
var echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function BJFX(_ref) {
  var id = _ref.id,
    startTime = _ref.startTime,
    endTime = _ref.endTime;
  var _useSettings = (0, _useSettings2["default"])(),
    isDark = _useSettings.isDark,
    _useSettings$theme = _useSettings.theme,
    theme = _useSettings$theme === void 0 ? 'light' : _useSettings$theme;
  var textColor = isDark || ['dark', 'blue'].includes(theme) ? '#fff' : '#000';
  var _AlarmService$useAlar = _api.AlarmService.useAlarmTrend(id, startTime.format('YYYY-MM-DD'), endTime.format('YYYY-MM-DD')),
    alarmTrendData = _AlarmService$useAlar.alarmTrendData;
  var xAxisData = (alarmTrendData || []).map(function (item) {
    return item.date;
  });
  var ldData = (alarmTrendData || []).map(function (item) {
    return item.orderCount;
  });
  var alarmData = (alarmTrendData || []).map(function (item) {
    return item.alarmCount;
  });
  var option = {
    tooltip: {
      trigger: 'axis',
      formatter: function formatter(params) {
        var _a;
        var str = "<div style=\"text-align:left\">".concat((_a = params === null || params === void 0 ? void 0 : params[0]) === null || _a === void 0 ? void 0 : _a.axisValue, "</div >");
        params.map(function (item) {
          str += '<div>';
          str += item.marker;
          str += "".concat(item.seriesName, "\uFF1A").concat(item.data).concat(item.seriesName === '预警数量' ? '次' : '个');
          str += '</div>';
        });
        return str;
      }
    },
    grid: {
      left: '6%',
      right: '5%',
      bottom: 20
    },
    legend: [{
      align: 'left',
      itemHeight: 8,
      itemWidth: 8,
      icon: 'rect',
      itemStyle: {
        color: '#1C86F3'
      },
      textStyle: {
        color: textColor
      },
      data: ['联单数量'],
      left: '40%'
    }, {
      align: 'left',
      itemHeight: 2,
      itemWidth: 16,
      icon: 'rect',
      itemStyle: {
        color: '#1FB64D'
      },
      textStyle: {
        color: textColor
      },
      data: ['预警数量'],
      left: '60%'
    }],
    xAxis: [{
      type: 'category',
      data: xAxisData,
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: textColor
      }
    }],
    yAxis: [{
      type: 'value',
      name: '联单数量(个)',
      min: 0,
      interval: 100,
      nameTextStyle: {
        color: textColor
      },
      splitNumber: 5,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: textColor
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }, {
      show: true,
      type: 'value',
      name: '预警数量(次)',
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        }
      }
    }],
    series: [{
      name: '联单数量',
      type: 'bar',
      barWidth: 18,
      yAxisIndex: 0,
      data: ldData,
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
          offset: 0,
          color: '#1C86F3'
        }, {
          offset: 1,
          color: 'rgba(28, 134, 243, 0)'
        }])
      }
    }, {
      name: '预警数量',
      type: 'line',
      yAxisIndex: 1,
      data: alarmData,
      showSymbol: false,
      itemStyle: {
        color: '#1FB64D'
      }
    }]
  };
  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\u8D8B\u52BF\u5206\u6790")), /*#__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=BJFX.js.map
