"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _PublicService = _interopRequireDefault(require("../_mapUtil/PublicService"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _MyEmpty = _interopRequireDefault(require("../_component/MyEmpty"));
var _dashedLine = _interopRequireDefault(require("../assets/dashedLine.png"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _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(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; } /**
 * 结果
 * @description: 用于展示分析结果列表、结果图层等
 */
var Result = function Result() {
  var _useProps = (0, _useProps2["default"])(),
    tableData = _useProps.tableData,
    classnames = _useProps.classnames,
    isWaterLevel = _useProps.isWaterLevel;
  var _ref = tableData || {},
    _ref$timeList = _ref.timeList,
    timeList = _ref$timeList === void 0 ? [] : _ref$timeList;
  // 获取series数据
  var getSeriesData = function getSeriesData(data, time) {
    var defaultArr = [];
    time.length && time.forEach(function (item) {
      var dataValue = (data || []).filter(function (val) {
        return val.time === item;
      }) || [];
      if (dataValue.length) {
        defaultArr.push(dataValue[0].value);
      } else {
        defaultArr.push(null);
      }
    });
    return defaultArr;
  };
  var renderRainHybridJunction = function renderRainHybridJunction() {
    var _ref2 = tableData || {},
      _ref2$rainCapacity = _ref2.rainCapacity,
      rainCapacity = _ref2$rainCapacity === void 0 ? [] : _ref2$rainCapacity,
      _ref2$waterLevel = _ref2.waterLevel,
      waterLevel = _ref2$waterLevel === void 0 ? [] : _ref2$waterLevel,
      _ref2$ddl = _ref2.ddl,
      ddl = _ref2$ddl === void 0 ? [] : _ref2$ddl,
      _ref2$timeList = _ref2.timeList,
      timeList = _ref2$timeList === void 0 ? [] : _ref2$timeList;
    var timeData = _PublicService["default"].getDataByKey(timeList, 'time');
    var RainData = getSeriesData(rainCapacity, timeData);
    var waterLevelData = getSeriesData(waterLevel, timeData);
    var ddlData = getSeriesData(ddl, timeData);
    var ddlWarnData = new Array(ddlData.length).fill(1000);
    var colors = ['#fbe5c8', '#869ad6', '#b1da9d', '#FF5216'];
    var tootipColor = {
      '电导率(us/cm)': '#fbe5c8',
      '液位(m)': '#869ad6',
      '降雨量(mm)': '#b1da9d',
      电导率阈值线: '#FF5216'
    };
    var option = {
      color: colors,
      grid: {
        top: 60,
        left: isWaterLevel ? '12%' : '8%',
        right: '8%',
        bottom: 50,
        containLabel: true
      },
      legend: {
        show: true,
        itemWidth: 25,
        itemHeight: 10,
        data: [{
          name: '电导率(us/cm)'
        }].concat(_toConsumableArray(isWaterLevel ? [{
          name: '液位(m)'
        }] : []), [{
          name: '降雨量(mm)'
        }, {
          name: '电导率阈值线',
          icon: "image://".concat(_dashedLine["default"])
        }])
      },
      tooltip: {
        trigger: 'axis',
        axisLine: {
          lineStyle: {
            color: '#FEFEFE'
          }
        },
        confine: true,
        axisPointer: {
          type: 'cross',
          animation: false,
          label: {
            show: false,
            formatter: function formatter(params) {
              if (params.seriesData.length === 0 && params.axisIndex === 0) {
                window.mouseCurValueDdl = params.value;
              }
            }
          },
          crossStyle: {
            opacity: 0
          }
        },
        formatter: function formatter(params) {
          var content = null;
          var ddlValue = params.filter(function (item) {
            return item.seriesName === '电导率(us/cm)';
          }) || [];
          if (ddlValue.length) {
            var value = ddlValue[0].value && Number(ddlValue[0].value);
            if (window.mouseCurValueDdl > 1000 && value > 1000) {
              content = '存在雨污混接风险';
            } else {
              var subItem = '';
              params.length && params.map(function (val, idx) {
                var htmlMarket = "<span style=\"display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color: ".concat(tootipColor[val.seriesName], "\"></span>");
                if (idx == 0) {
                  subItem += "<div>".concat(val.axisValue, "</div>");
                }
                subItem += "<div>".concat(htmlMarket, " ").concat(val.seriesName, " ").concat(val.data || '', "</div>");
              });
              content = "<div>".concat(subItem, "</div>");
            }
          } else {
            var _subItem = '';
            params.length && params.map(function (val, idx) {
              var htmlMarket = "<span style=\"display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color: ".concat(tootipColor[val.seriesName], "\"></span>");
              if (idx == 0) {
                _subItem += "<div>".concat(val.axisValue, "</div>");
              }
              _subItem += "<div>".concat(htmlMarket, " ").concat(val.seriesName, " ").concat(val.data || '', "</div>");
            });
            content = "<div>".concat(_subItem, "</div>");
          }
          return content;
        }
      },
      xAxis: {
        type: 'category',
        data: timeData.map(function (str) {
          return str.replace(' ', '\n');
        }),
        axisTick: {
          show: false
        },
        axisLabel: {
          color: '#000'
        }
      },
      yAxis: [{
        type: 'value',
        name: '电导率(us/cm)',
        position: 'left',
        offset: isWaterLevel ? 65 : 0,
        alignTicks: true,
        axisLine: {
          show: true
        }
      }].concat(_toConsumableArray(isWaterLevel ? [{
        type: 'value',
        name: '液位(m)',
        position: 'left',
        alignTicks: true,
        axisLine: {
          show: true
        }
      }] : []), [{
        type: 'value',
        name: '降雨量(mm)',
        nameLocation: 'start',
        position: 'right',
        alignTicks: true,
        inverse: true,
        axisLine: {
          show: true
        }
      }]),
      visualMap: {
        show: false,
        seriesIndex: 0,
        outOfRange: {
          color: '#fbe5c8'
        },
        pieces: [{
          gt: 0,
          lte: 1000,
          color: '#fbe5c8'
        }, {
          gt: 1000,
          color: '#ec808d'
        }]
      },
      dataZoom: [{
        // 这个dataZoom组件，默认控制x轴。
        type: 'slider',
        // 这个 dataZoom 组件是 slider 型 dataZoom 组件
        start: 0,
        // 左边在 10% 的位置。
        end: 100,
        // 右边在 60% 的位置。
        button: '15%',
        fillerColor: 'rgba(97, 212, 225, 0.35)',
        borderColor: 'none',
        handleIcon: 'M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
        handleSize: '150%',
        height: 10,
        handleStyle: {
          color: '#fff',
          shadowBlur: 3,
          shadowColor: 'rgba(0, 0, 0, 0.4)',
          shadowOffsetX: 2,
          shadowOffsetY: 2
        },
        showDataShadow: false,
        showDetail: false,
        bottom: 14
      }, {
        // 这个dataZoom组件，也控制x轴。
        type: 'inside',
        // 这个 dataZoom 组件是 inside 型 dataZoom 组件
        start: 0,
        // 左边在 10% 的位置。
        end: 100,
        // 右边在 60% 的位置。
        height: 10,
        bottom: 14
      }],
      series: [{
        data: ddlData,
        type: 'line',
        name: '电导率(us/cm)',
        connectNulls: true,
        areaStyle: {
          opacity: 1
        },
        lineStyle: {
          color: '#fbe5c8'
        },
        symbol: 'none',
        zlevel: 3
      }].concat(_toConsumableArray(isWaterLevel ? [{
        data: waterLevelData,
        connectNulls: true,
        type: 'line',
        name: '液位(m)',
        areaStyle: {
          color: '#869ad6'
        },
        yAxisIndex: 1,
        lineStyle: {
          color: '#869ad6'
        },
        symbol: 'none'
      }] : []), [{
        data: RainData,
        type: 'bar',
        name: '降雨量(mm)',
        barMaxWidth: 25,
        yAxisIndex: isWaterLevel ? 2 : 1,
        symbol: 'none',
        itemStyle: {
          color: '#b1da9d'
        }
      }, {
        name: '电导率阈值线',
        type: 'line',
        data: ddlWarnData,
        smooth: true,
        symbol: 'none',
        connectNulls: true,
        lineStyle: {
          color: '#FF5216',
          type: 'dashed'
        }
      }])
    };
    return /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
      style: {
        height: 240
      },
      option: option,
      notMerge: true,
      lazyUpdate: true
    });
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: classnames('contentWarp')
  }, timeList !== null && timeList !== void 0 && timeList.length ? renderRainHybridJunction() : /*#__PURE__*/_react["default"].createElement(_MyEmpty["default"], {
    type: "charts"
  }));
};
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
