"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 _olMap = require("@vtx/ol-map");
var _react = _interopRequireWildcard(require("react"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _ResultTitle = _interopRequireDefault(require("../_component/ResultTitle"));
var _config = require("./config");
var _ResultStatistics = _interopRequireDefault(require("../_component/ResultStatistics"));
var _antd = require("antd");
var _ResultList = _interopRequireDefault(require("../_component/ResultList"));
var _MyTag = _interopRequireDefault(require("../_component/MyTag"));
var _icons = require("@ant-design/icons");
var _MapLayer = _interopRequireDefault(require("./MapLayer"));
var _useModal2 = _interopRequireDefault(require("../_mapUtil/useModal"));
var _DetailModal = _interopRequireDefault(require("./DetailModal"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure 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 _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; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
var prefix = 'ol-analysis-water-quality';
var Result = function Result() {
  var _useProps = (0, _olMap.useProps)(),
    setVisible = _useProps.setVisible,
    setModal = _useProps.setModal,
    modal = _useProps.modal,
    map = _useProps.map;
  var modalData = modal.modalData,
    modalShow = modal.modalShow;
  var queryTimeStr = modalData.queryTimeStr,
    queryTime = modalData.queryTime,
    data = modalData.data,
    facilityTypeCodeList = modalData.facilityTypeCodeList;
  var _useModal = (0, _useModal2["default"])(),
    modalInfo = _useModal.modalInfo,
    onOpenModal = _useModal.onOpenModal,
    onCancel = _useModal.onCancel;
  var _useState = (0, _react.useState)(''),
    _useState2 = _slicedToArray(_useState, 2),
    activeKey = _useState2[0],
    setActiveKey = _useState2[1];
  var statisticsList = [{
    name: '预测对象',
    total: (data === null || data === void 0 ? void 0 : data.predictObjectNum) || 0,
    color: '#1677FF',
    key: 'all'
  }, {
    name: '预测正常',
    total: (data === null || data === void 0 ? void 0 : data.normalNum) || 0,
    color: '#00B132',
    key: _config.StatusMap.Normal
  }, {
    name: '预测异常',
    total: (data === null || data === void 0 ? void 0 : data.abnormalNum) || 0,
    color: '#FF3A3B',
    key: _config.StatusMap.Abnormal
  }];
  var filterDataList = (0, _react.useMemo)(function () {
    if (activeKey === '' || activeKey === 'all') {
      return (data === null || data === void 0 ? void 0 : data.dataList) || [];
    } else {
      return ((data === null || data === void 0 ? void 0 : data.dataList) || []).filter(function (item) {
        return item.alarmStatus === activeKey;
      });
    }
  }, [activeKey, data]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-tooltip result")
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: require('./assets/btn_icon.png'),
    width: 16,
    height: 16
  }), queryTimeStr, "\u8FD0\u884C\u9884\u6D4B", /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-result-exit-btn"),
    onClick: function onClick() {
      setModal({
        modalShow: false,
        modalData: {}
      });
      setVisible(true);
    }
  }, "\u9000\u51FA")), /*#__PURE__*/_react["default"].createElement(_CustomModal["default"], {
    map: map,
    visible: modalShow,
    isShowHidden: true
  }, /*#__PURE__*/_react["default"].createElement(_ResultTitle["default"], {
    title: "\u9884\u6D4B\u7EDF\u8BA1-".concat(queryTimeStr)
  }), /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      marginTop: 16
    }
  }, /*#__PURE__*/_react["default"].createElement(_ResultStatistics["default"], {
    list: statisticsList,
    icon: require('./assets/statistics.png'),
    activeKey: activeKey,
    setActiveKey: setActiveKey
  }), /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    style: {
      marginBottom: 20
    }
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 6
  }, "\u9884\u6D4B\u6B63\u5E38\u7387"), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 18
  }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
    percent: data === null || data === void 0 ? void 0 : data.normalPercent,
    strokeColor: '#00B132',
    format: function format(value) {
      return /*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: '#00B132'
        }
      }, value, "%");
    },
    strokeWidth: 5
  })))), /*#__PURE__*/_react["default"].createElement(_ResultTitle["default"], {
    title: "\u9884\u6D4B\u660E\u7EC6-".concat(queryTimeStr)
  }), /*#__PURE__*/_react["default"].createElement(_ResultList["default"], {
    list: filterDataList,
    idKey: 'facilityId',
    titleKey: "facilityName",
    onTitleClick: function onTitleClick(info) {
      map.showTemplateByFilter("water-balance-analysis", 'facilityId', info.facilityId);
    },
    onItemClick: function onItemClick(info) {
      onOpenModal({
        facilityId: info.facilityId,
        facilityName: info.facilityName
      });
    },
    getDetailContent: function getDetailContent(info) {
      var columns = [{
        title: '预测指标',
        dataIndex: 'monitorItemName',
        render: function render(text, record) {
          return "".concat(text).concat(record.unit ? "(".concat(record.unit, ")") : '');
        }
      }, {
        title: '预测谷值',
        dataIndex: 'minAmount',
        width: 90,
        align: 'right'
      }, {
        title: '预测峰值',
        dataIndex: 'maxAmount',
        width: 90,
        align: 'right'
      }, {
        title: '预测结果',
        dataIndex: 'alarmCount',
        width: 90,
        render: function render(text) {
          return /*#__PURE__*/_react["default"].createElement(_antd.Space, {
            style: {
              color: text > 0 ? '#FF3333' : '#00B052'
            },
            size: 5
          }, text > 0 ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_icons.ExclamationCircleFilled, null), "\u5F02\u5E38") : /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_icons.CheckCircleFilled, null), "\u6B63\u5E38"));
        }
      }];
      return /*#__PURE__*/_react["default"].createElement("div", {
        className: "ol-analysis-water-quality-table"
      }, /*#__PURE__*/_react["default"].createElement(_antd.Table, {
        bordered: true,
        columns: columns,
        dataSource: (info === null || info === void 0 ? void 0 : info.aggregationData) || [],
        pagination: false
      }));
    },
    getOtherTitle: function getOtherTitle(info) {
      var colors = ['#B388FF', '#FFCA28', '#2979FF', '#00BCD4', '#6989A8'];
      var index = facilityTypeCodeList.indexOf(info.facilityTypeCode);
      return /*#__PURE__*/_react["default"].createElement(_MyTag["default"], {
        text: info.facilityTypeName,
        color: colors[index % colors.length]
      });
    }
  })), /*#__PURE__*/_react["default"].createElement(_MapLayer["default"], {
    data: filterDataList,
    queryTimeStr: queryTimeStr,
    openModal: onOpenModal
  }), modalInfo.visible && /*#__PURE__*/_react["default"].createElement(_DetailModal["default"], _extends({
    visible: modalInfo.visible
  }, modalInfo.info, {
    onCancel: onCancel,
    queryTime: queryTime,
    queryTimeStr: queryTimeStr
  })));
};
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
