"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 _chunk = _interopRequireDefault(require("lodash/chunk"));
require("../index.less");
var _utils = require("@vtx/utils");
var _maleB = _interopRequireDefault(require("../../../imgs/maleB.png"));
var _femaleB = _interopRequireDefault(require("../../../imgs/femaleB.png"));
var _rllm = _interopRequireDefault(require("../../../imgs/rllm.png"));
var _cqzm = _interopRequireDefault(require("../../../imgs/cqzm.png"));
var _wdm = _interopRequireDefault(require("../../../imgs/wdm.png"));
var _sdm = _interopRequireDefault(require("../../../imgs/sdm.png"));
var _pmm = _interopRequireDefault(require("../../../imgs/pmm.png"));
var _lhqm = _interopRequireDefault(require("../../../imgs/lhqm.png"));
var _qm = _interopRequireDefault(require("../../../imgs/qm.png"));
var _rllf = _interopRequireDefault(require("../../../imgs/rllf.png"));
var _cqzf = _interopRequireDefault(require("../../../imgs/cqzf.png"));
var _wdf = _interopRequireDefault(require("../../../imgs/wdf.png"));
var _sdf = _interopRequireDefault(require("../../../imgs/sdf.png"));
var _pmf = _interopRequireDefault(require("../../../imgs/pmf.png"));
var _lhqf = _interopRequireDefault(require("../../../imgs/lhqf.png"));
var _qf = _interopRequireDefault(require("../../../imgs/qf.png"));
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 _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 Monitor = function Monitor(props) {
  var detail = props.detail,
    typeClass = props.typeClass;
  var _useSetState = (0, _ahooks.useSetState)({
      monitorDetail: {
        all: [],
        male: [],
        female: []
      }
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  (0, _react.useEffect)(function () {
    detail.id && readData({
      id: detail.id
    }).then(function (res) {
      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 || []
          }
        });
      }
    });
  }, [detail.id]);
  var maleList = [{
    name: '人流量',
    key: 'rllm',
    style: {
      width: '16px',
      height: '13px'
    },
    code: 'PERSON_NUM',
    unit: '人次',
    img: _rllm["default"]
  }, {
    name: '臭气值',
    key: 'cqzm',
    style: {
      width: '16px',
      height: '13px'
    },
    code: 'ODOR',
    unit: 'ppm',
    img: _cqzm["default"]
  }, {
    name: '温度',
    key: 'wdm',
    style: {
      width: '9px',
      height: '13px'
    },
    code: 'TEMPERATURE',
    unit: '℃',
    img: _wdm["default"]
  }, {
    name: '湿度',
    key: 'sdm',
    style: {
      width: '13px',
      height: '13px'
    },
    code: 'HUMIDITY',
    unit: '%',
    img: _sdm["default"]
  }, {
    name: 'PM2.5',
    key: 'pm',
    style: {
      width: '13.16px',
      height: '12.8px'
    },
    code: 'PM2.5',
    unit: 'μg/m³',
    img: _pmm["default"]
  }, {
    name: '硫化氢',
    key: 'lhq',
    style: {
      width: '16px',
      height: '12px'
    },
    code: 'HYDROGRN',
    unit: 'ppm',
    img: _lhqm["default"]
  }, {
    name: '氨气',
    key: 'an',
    style: {
      width: '16px',
      height: '12px'
    },
    code: 'AMMONIA',
    unit: 'mg/m³',
    img: _qm["default"]
  }, {
    name: '坑位',
    key: 'kw',
    code: 'SEAT_NUM',
    unit: '个'
  }].filter(function (item) {
    return state.monitorDetail.male.map(function (each) {
      return each.factorCode;
    }).indexOf(item.code) !== -1;
  });
  var femaleList = [{
    name: '人流量',
    key: 'rllf',
    style: {
      width: '16px',
      height: '13px'
    },
    code: 'PERSON_NUM',
    unit: '人次',
    img: _rllf["default"]
  }, {
    name: '臭气值',
    key: 'cqzf',
    style: {
      width: '16px',
      height: '13px'
    },
    code: 'ODOR',
    unit: 'ppm',
    img: _cqzf["default"]
  }, {
    name: '温度',
    key: 'wdf',
    style: {
      width: '9px',
      height: '13px'
    },
    code: 'TEMPERATURE',
    unit: '℃',
    img: _wdf["default"]
  }, {
    name: '湿度',
    key: 'sdf',
    style: {
      width: '13px',
      height: '13px'
    },
    code: 'HUMIDITY',
    unit: '%',
    img: _sdf["default"]
  }, {
    name: 'PM2.5',
    key: 'pm',
    style: {
      width: '13.16px',
      height: '12.8px'
    },
    code: 'PM2.5',
    unit: 'μg/m³',
    img: _pmf["default"]
  }, {
    name: '硫化氢',
    key: 'lhq',
    style: {
      width: '16px',
      height: '12px'
    },
    code: 'HYDROGRN',
    unit: 'ppm',
    img: _lhqf["default"]
  }, {
    name: '氨气',
    key: 'an',
    style: {
      width: '16px',
      height: '12px'
    },
    code: 'AMMONIA',
    unit: 'mg/m³',
    img: _qf["default"]
  }, {
    name: '坑位',
    key: 'kw',
    code: 'SEAT_NUM',
    unit: '个'
  }].filter(function (item) {
    return state.monitorDetail.female.map(function (each) {
      return each.factorCode;
    }).indexOf(item.code) !== -1;
  });
  var water = state.monitorDetail.all.filter(function (item) {
    return item.factorCode === 'WATER_USE';
  })[0];
  var elec = state.monitorDetail.all.filter(function (item) {
    return item.factorCode === 'ELEC_USE';
  })[0];
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "monitorContent"
  }, (typeClass === 'four' || typeClass === 'six') && /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      lineHeight: '24px'
    }
  }, water ? "\u7528\u6C34\u91CF\uFF1A".concat(water.value, "\u5428&emsp;") : '', elec ? "\u7528\u7535\u91CF\uFF1A".concat(elec.value, "\u5EA6") : ''), /*#__PURE__*/_react["default"].createElement("div", {
    className: "monitorItem"
  }, (typeClass === 'three' || typeClass === 'five') && /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      lineHeight: '24px',
      width: '200%'
    }
  }, water ? "\u7528\u6C34\u91CF\uFF1A".concat(water.value, "\u5428&emsp;") : '', elec ? "\u7528\u7535\u91CF\uFF1A".concat(elec.value, "\u5EA6") : ''), /*#__PURE__*/_react["default"].createElement("div", {
    className: "topType topTypeM"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: _maleB["default"],
    alt: "male"
  }), "\u7537\u5395"), /*#__PURE__*/_react["default"].createElement("div", {
    className: 'monitorBox'
  }, (0, _chunk["default"])(maleList, typeClass === 'four' || typeClass === 'six' ? 3 : 2).map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: index,
      className: "monitorRow"
    }, item.map(function (each, order) {
      var _a, _b;
      return /*#__PURE__*/_react["default"].createElement("div", {
        key: each.key,
        className: "monitor",
        style: {
          marginLeft: order === 0 ? 0 : '5px'
        }
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: "tip"
      }, each.img && /*#__PURE__*/_react["default"].createElement("img", {
        style: each.style,
        src: each.img,
        alt: each.key
      }), "\u2002", each.name), /*#__PURE__*/_react["default"].createElement("div", {
        className: "num"
      }, (_b = (_a = state.monitorDetail.male.filter(function (item) {
        return item.factorCode === each.code;
      })[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0, each.unit));
    }));
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "monitorItem"
  }, (typeClass === 'three' || typeClass === 'five') && /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      height: '24px'
    }
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "topType topTypeF"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: _femaleB["default"],
    alt: "female"
  }), "\u5973\u5395"), /*#__PURE__*/_react["default"].createElement("div", {
    className: 'monitorBox'
  }, (0, _chunk["default"])(femaleList, typeClass === 'four' || typeClass === 'six' ? 3 : 2).map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      key: index,
      className: "monitorRow"
    }, item.map(function (each, order) {
      var _a, _b;
      return /*#__PURE__*/_react["default"].createElement("div", {
        key: each.key,
        className: "monitor monitorF",
        style: {
          marginLeft: order === 0 ? 0 : '5px'
        }
      }, /*#__PURE__*/_react["default"].createElement("div", {
        className: "tip"
      }, each.img && /*#__PURE__*/_react["default"].createElement("img", {
        style: each.style,
        src: each.img,
        alt: each.key
      }), "\u2002", each.name), /*#__PURE__*/_react["default"].createElement("div", {
        className: "num"
      }, (_b = (_a = state.monitorDetail.female.filter(function (item) {
        return item.factorCode === each.code;
      })[0]) === null || _a === void 0 ? void 0 : _a.value) !== null && _b !== void 0 ? _b : 0, each.unit));
    }));
  }))));
};
var _default = exports["default"] = Monitor;
//# sourceMappingURL=Monitor.js.map
