"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 _moment = _interopRequireDefault(require("moment"));
var echarts = _interopRequireWildcard(require("echarts"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _api = require("../../api");
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 }; }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
var ZyfxJXH = function ZyfxJXH(props) {
  var _a;
  var _useSettings = (0, _useSettings2["default"])(),
    chartFontColor = _useSettings.chartFontColor,
    sDate = _useSettings.startDate,
    eDate = _useSettings.endDate,
    theme = _useSettings.theme;
  var id = props.id,
    service = props.service;
  var _BaseService$useWorkA = _api.BaseService.useWorkAnaJxh(id, sDate ? sDate : (0, _moment["default"])().subtract(1, 'M').format('YYYY-MM-DD'), eDate ? eDate : (0, _moment["default"])().format('YYYY-MM-DD'), service),
    workAnaJxhRes = _BaseService$useWorkA.workAnaJxhRes;
  var extraData = workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.extraData;
  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, index) {
          var _a, _b, _c, _d, _e;
          str += "<span ><span style=\"color:".concat(((_d = (_c = (_b = (_a = params[index]) === null || _a === void 0 ? void 0 : _a.color) === null || _b === void 0 ? void 0 : _b.colorStops) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.color) || ((_e = params[index]) === null || _e === void 0 ? void 0 : _e.color), ";font-size:24px \">\u2022</span> ").concat(item.seriesName, "&nbsp;&nbsp;&nbsp;").concat(item.data).concat(item.seriesName === '完成率' ? '%' : 'km', "</span>");
        });
        return str; // 返回带点的字符串
      }
    },
    grid: {
      left: '6%',
      right: '5%',
      bottom: 20
    },
    legend: {
      align: 'left',
      itemGap: 8,
      itemHeight: 10,
      textStyle: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      },
      data: ['核算作业里程'].concat(_toConsumableArray(extraData !== null && extraData > 0 ? ['完成率'] : []))
    },
    xAxis: [{
      type: 'category',
      data: (workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.names) || [],
      axisPointer: {
        type: 'shadow'
      },
      axisTick: {
        show: false
      },
      axisLabel: {
        color: theme === 'blue' ? '#fff' : chartFontColor
      }
    }],
    yAxis: [{
      type: 'value',
      name: '(km)',
      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)'
        }
      }
    }, {
      show: extraData !== null && extraData > 0,
      type: 'value',
      name: '%'
    }],
    series: [{
      name: '核算作业里程',
      type: 'bar',
      barWidth: 18,
      data: (workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.values.length) > 0 ? workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.values[0] : [],
      itemStyle: {
        color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
          offset: 0,
          color: '#45aeff'
        }, {
          offset: 0.9,
          color: '#168fff'
        }])
      }
    }].concat(_toConsumableArray(extraData !== null && extraData > 0 ? [{
      name: '完成率',
      type: 'line',
      yAxisIndex: 1,
      data: (workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.values.length) > 1 ? workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.values[1] : [],
      itemStyle: {
        color: '#1AC47C'
      }
    }] : []))
  };
  return ((_a = workAnaJxhRes === null || workAnaJxhRes === void 0 ? void 0 : workAnaJxhRes.names) === null || _a === void 0 ? void 0 : _a.length) > 0 ? (/*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
    option: option,
    notMerge: true,
    lazyUpdate: true,
    style: {
      height: '250px',
      width: '100%'
    }
  })) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], {
    style: {
      height: '250px',
      width: '100%'
    }
  }));
};
var _default = exports["default"] = ZyfxJXH;
//# sourceMappingURL=ZyfxJXH.js.map
