"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"] = void 0;
var _react = _interopRequireDefault(require("react"));
var echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _vmSubTitle = require("../../../vm-sub-title");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
var _vmFilter = require("../../../vm-filter");
var _moment = _interopRequireDefault(require("moment"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var AlarmDetail = function AlarmDetail(props) {
  var _a, _b;
  var _useSettings = (0, _useSettings2["default"])(),
    chartFontColor = _useSettings.chartFontColor,
    theme = _useSettings.theme;
  var code = props.code,
    startDate = props.startDate,
    endDate = props.endDate,
    setState = props.setState;
  var _BaseService$useJcccs = _api.BaseService.useJcccsjfb(code, startDate, endDate),
    jcccsjfbRes = _BaseService$useJcccs.jcccsjfbRes;
  var option = {
    tooltip: {
      trigger: 'axis',
      formatter: '{b0}: 进场{c0}次'
    },
    grid: {
      top: 30,
      left: 56,
      right: 56,
      bottom: 24
    },
    legend: {
      show: false
    },
    xAxis: [{
      type: 'category',
      name: '时段',
      data: (jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.names) || [],
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    }],
    yAxis: {
      type: 'value',
      name: '车次',
      min: 0,
      // interval: 100,
      nameTextStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      splitNumber: 5,
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      splitLine: {
        lineStyle: {
          type: 'dashed',
          color: 'rgba(151,151,151,0.28)'
        },
        splitNumber: 5,
        axisTick: {
          show: false
        },
        axisLabel: {
          color: theme === 'blue' ? '#fff' : chartFontColor
        },
        splitLine: {
          lineStyle: {
            type: 'dashed',
            color: 'rgba(151,151,151,0.28)'
          }
        }
      }
    },
    series: [{
      type: 'bar',
      barWidth: 18,
      data: (jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.values) ? jcccsjfbRes.values[0] : [],
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: theme === 'light' ? '#1677FF' : '#0C3D44'
        }, {
          offset: 1,
          color: theme === 'light' ? '#25ABFF' : '#37D3B0'
        }])
      }
    }]
  };
  var dates = ((_a = jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.extraData) === null || _a === void 0 ? void 0 : _a.length) > 0 ? jcccsjfbRes.extraData.map(function (ele) {
    return ele.date;
  }) : [];
  var count = ((_b = jcccsjfbRes === null || jcccsjfbRes === void 0 ? void 0 : jcccsjfbRes.extraData) === null || _b === void 0 ? void 0 : _b.length) > 0 ? jcccsjfbRes.extraData.map(function (ele) {
    return ele.count;
  }) : [];
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-bottom--right"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle.SubTitle2, {
    title: "\u8FDB\u573A\u8F66\u6B21\u65F6\u95F4\u5206\u5E03",
    extra: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_vmFilter.VMRangePicker, {
      value: [(0, _moment["default"])(startDate), (0, _moment["default"])(endDate)],
      onChange: function onChange(dates) {
        return dates && setState({
          startDateAlarm: (0, _moment["default"])(dates[0]).format('YYYY-MM-DD'),
          endDateAlarm: (0, _moment["default"])(dates[1]).format('YYYY-MM-DD')
        });
      }
    }))
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-bottom--right-desc"
  }, "\u8FDB\u573A\u9AD8\u5CF0\u96C6\u4E2D\u5728", /*#__PURE__*/_react["default"].createElement("span", null, (dates === null || dates === void 0 ? void 0 : dates.join('点、')) || 0, "\u70B9"), "\uFF0C\u8FDB\u573A\u8F66\u6B21\u5206\u522B\u4E3A", /*#__PURE__*/_react["default"].createElement("span", null, (count === null || count === void 0 ? void 0 : count.join('车、')) || '-', "\u8F66"), "\u6CE8\u610F\u5408\u7406\u8C03\u5EA6\uFF0C\u7F13\u89E3\u5382\u533A\u6392\u961F\u60C5\u51B5"), /*#__PURE__*/_react["default"].createElement("div", {
    className: "base-bottom--right-content"
  }, /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '200px',
      width: '100%'
    }
  })));
};
var _default = exports["default"] = AlarmDetail;
//# sourceMappingURL=AlarmDetail.js.map
