"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _ahooks = require("ahooks");
var _service = require("./service");
var _row = _interopRequireDefault(require("antd/lib/row"));
var _col = _interopRequireDefault(require("antd/lib/col"));
var _icons = require("@ant-design/icons");
var _classnames = _interopRequireDefault(require("classnames"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var prefix = 'ol-map-analysis-sunny-rain-ratio-statistics-item';
var typeImgMap = {
  manhole: require('./assets/manhole.png'),
  line: require('./assets/line.png'),
  pump_station: require('./assets/pump_station.png'),
  sewage_plant: require('./assets/sewage_plant.png')
};
var ResultStatistics = function ResultStatistics(_ref) {
  var rainId = _ref.rainId,
    _ref$checkInfo = _ref.checkInfo,
    checkInfo = _ref$checkInfo === void 0 ? {} : _ref$checkInfo,
    onSelectFacility = _ref.onSelectFacility;
  var _useRequest = (0, _ahooks.useRequest)(function () {
      return (0, _service.queryTypeStatistics)({
        rainId: rainId
      });
    }, {
      refreshDeps: [rainId],
      ready: !!rainId
    }),
    _useRequest$data = _useRequest.data,
    data = _useRequest$data === void 0 ? [] : _useRequest$data;
  var _onClick = function onClick(e, type, isAlarm) {
    e.stopPropagation();
    onSelectFacility({
      isAlarm: isAlarm,
      type: type
    });
  };
  return /*#__PURE__*/_react["default"].createElement(_row["default"], {
    gutter: [10, 10],
    style: {
      marginTop: 15,
      marginBottom: 24
    }
  }, data.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(_col["default"], {
      span: 12,
      key: item.type
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])("".concat(prefix, "-wrap"), {
        active: item.type === checkInfo.type
      }),
      onClick: function onClick() {
        var _checkInfo$isAlarm;
        onSelectFacility({
          type: item.type,
          isAlarm: (_checkInfo$isAlarm = checkInfo.isAlarm) !== null && _checkInfo$isAlarm !== void 0 ? _checkInfo$isAlarm : false
        });
      }
    }, item.type === checkInfo.type && /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "-checked")
    }, /*#__PURE__*/_react["default"].createElement(_icons.CheckOutlined, null)), /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "-left")
    }, /*#__PURE__*/_react["default"].createElement("img", {
      style: {
        width: 38,
        height: 38
      },
      src: typeImgMap[item.type]
    }), /*#__PURE__*/_react["default"].createElement("div", null, item.typeName)), /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "-right")
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "-value"),
      onClick: function onClick(e) {
        return _onClick(e, item.type, false);
      }
    }, /*#__PURE__*/_react["default"].createElement("div", null, "\u6B63\u5E38"), /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])("".concat(prefix, "-number"), {
        active: !checkInfo.isAlarm && item.type === checkInfo.type
      })
    }, item.count, " ", /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "-unit")
    }, "\u6761"))), /*#__PURE__*/_react["default"].createElement("div", {
      className: "".concat(prefix, "-value"),
      onClick: function onClick(e) {
        return _onClick(e, item.type, true);
      }
    }, /*#__PURE__*/_react["default"].createElement("div", null, "\u5F02\u5E38"), /*#__PURE__*/_react["default"].createElement("div", {
      className: (0, _classnames["default"])("".concat(prefix, "-number ").concat(prefix, "-number-error"), {
        active: checkInfo.isAlarm && item.type === checkInfo.type
      })
    }, item.abnormalCount, ' ', /*#__PURE__*/_react["default"].createElement("span", {
      className: "".concat(prefix, "-unit")
    }, "\u6761"))))));
  }));
};
var _default = exports["default"] = ResultStatistics;
//# sourceMappingURL=ResultStatistics.js.map
