"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 = _interopRequireWildcard(require("react"));
var _ahooks = require("ahooks");
var _antd = require("antd");
require("../index.less");
var _utils = require("@vtx/utils");
var _icons = require("@ant-design/icons");
var _ydlBg = _interopRequireDefault(require("../../../imgs/2/ydlBg.png"));
var _ydl = _interopRequireDefault(require("../../../imgs/2/ydl.png"));
var _yslBg = _interopRequireDefault(require("../../../imgs/2/yslBg.png"));
var _ysl = _interopRequireDefault(require("../../../imgs/2/ysl.png"));
var _male = _interopRequireDefault(require("../../../imgs/2/male.png"));
var _female = _interopRequireDefault(require("../../../imgs/2/female.png"));
var _dswsjC = _interopRequireDefault(require("../../../imgs/2/dswsjC.png"));
var _tywsj = _interopRequireDefault(require("../../../imgs/2/tywsj.png"));
var _rll = _interopRequireDefault(require("../../../imgs/2/rll.png"));
var _wd = _interopRequireDefault(require("../../../imgs/2/wd.png"));
var _sd = _interopRequireDefault(require("../../../imgs/2/sd.png"));
var _cqz = _interopRequireDefault(require("../../../imgs/2/cqz.png"));
var _lhq = _interopRequireDefault(require("../../../imgs/2/lhq.png"));
var _aq = _interopRequireDefault(require("../../../imgs/2/aq.png"));
var _ty = _interopRequireDefault(require("../../../imgs/2/ty.png"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
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 readData = function readData(params) {
  return _utils.request.get('/cloud/zhgc-reborn/api/gis/pop/readData', {
    data: params
  });
};
var Sjjg = function Sjjg(props) {
  var detail = props.detail;
  var _useSetState = (0, _ahooks.useSetState)({
      loading: false,
      monitorDetail: {
        all: [],
        male: [],
        female: [],
        third: [],
        unisex: []
      }
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var loading = state.loading,
    monitorDetail = state.monitorDetail;
  (0, _react.useEffect)(function () {
    detail.id && getData();
  }, [detail.id]);
  var getData = function getData() {
    setState({
      loading: true
    });
    readData({
      id: detail.id
    }).then(function (res) {
      setState({
        loading: false
      });
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        setState({
          monitorDetail: {
            all: res.data.all || [],
            male: res.data.male || [],
            female: res.data.female || [],
            third: res.data.third || [],
            unisex: res.data.unisex || []
          }
        });
      }
    });
  };
  var totalList = [{
    name: '用电量',
    bg: _ydlBg["default"],
    tip: _ydl["default"],
    section: monitorDetail.all.filter(function (item) {
      return item.factorCode === 'ELEC_USE';
    })[0],
    unit: '度'
  }, {
    name: '用水量',
    bg: _yslBg["default"],
    tip: _ysl["default"],
    section: monitorDetail.all.filter(function (item) {
      return item.factorCode === 'WATER_USE';
    })[0],
    unit: '吨'
  }];
  var eachList = [{
    name: '男厕',
    tip: 'MALE',
    img: _male["default"],
    list: monitorDetail.male
  }, {
    name: '女厕',
    tip: 'FEMALE',
    img: _female["default"],
    list: monitorDetail.female
  }, {
    name: '第三卫生间',
    tip: 'THIRD',
    img: _dswsjC["default"],
    list: monitorDetail.third
  }, {
    name: '通用卫生间',
    tip: 'UNISEX',
    img: _tywsj["default"],
    list: monitorDetail.unisex
  }];
  var getImg = function getImg(code) {
    switch (code) {
      case 'PERSON_NUM':
        return _rll["default"];
      case 'TEMPERATURE':
        return _wd["default"];
      case 'HUMIDITY':
        return _sd["default"];
      case 'ODOR':
        return _cqz["default"];
      case 'HYDROGEN':
        return _lhq["default"];
      case 'AMMONIA':
        return _aq["default"];
      default:
        return _ty["default"];
    }
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "sjjg"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "wrTitle"
  }, "\u6570\u636E\u76D1\u7BA1", /*#__PURE__*/_react["default"].createElement("div", {
    className: "titleExtra"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Button, {
    icon: /*#__PURE__*/_react["default"].createElement(_icons.RedoOutlined, null),
    onClick: getData,
    loading: loading
  }, "\u5237\u65B0"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "wrContent"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: 'totalNum'
  }, totalList.filter(function (item) {
    return item.section;
  }).map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.name,
      className: "eachTotal",
      style: {
        backgroundImage: "url(".concat(item.bg, ")")
      }
    }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("img", {
      src: item.tip,
      alt: item.name
    }), /*#__PURE__*/_react["default"].createElement("span", null, item.name)), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
      style: {
        fontSize: '20px',
        fontWeight: 700
      }
    }, item.section.value), /*#__PURE__*/_react["default"].createElement("span", {
      style: {
        marginLeft: '4px'
      }
    }, item.unit)));
  })), eachList.filter(function (item) {
    return item.list.length !== 0;
  }).map(function (item) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: item.name,
      className: 'eachType'
    }, /*#__PURE__*/_react["default"].createElement("div", {
      className: 'typeTitle'
    }, /*#__PURE__*/_react["default"].createElement("img", {
      src: item.img,
      alt: item.name
    }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("div", null, item.name), /*#__PURE__*/_react["default"].createElement("div", {
      style: {
        color: '#8c8c8c'
      }
    }, item.tip))), /*#__PURE__*/_react["default"].createElement("div", {
      className: 'typeContent'
    }, item.list.map(function (each) {
      var _a;
      return /*#__PURE__*/_react["default"].createElement("div", {
        key: each.factorCode,
        className: 'typeItem',
        title: "\u6700\u8FD1\u66F4\u65B0\u65F6\u95F4\uFF1A".concat(each.dataTime)
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: 'itemTitle',
        title: each.factorName || each.name
      }, /*#__PURE__*/_react["default"].createElement("img", {
        src: getImg(each.factorCode),
        alt: each.factorCode
      }), each.factorName || each.name), /*#__PURE__*/_react["default"].createElement("div", {
        style: {
          paddingLeft: '20px',
          lineHeight: '30px'
        }
      }, /*#__PURE__*/_react["default"].createElement("span", {
        style: {
          fontSize: each.value === '暂无数据' ? '16px' : '20px',
          fontWeight: each.value === '暂无数据' ? 400 : 700,
          color: each.value === '暂无数据' ? '#555' : '#333'
        }
      }, (_a = each.value) !== null && _a !== void 0 ? _a : '-'), each.value !== '暂无数据' && /*#__PURE__*/_react["default"].createElement("span", {
        style: {
          marginLeft: '4px'
        }
      }, each.unit)));
    })));
  })));
};
var _default = exports["default"] = Sjjg;
//# sourceMappingURL=Sjjg.js.map
