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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _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(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 _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; }
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(arr) { if (Array.isArray(arr)) return arr; }
import { request } from '@vtx/utils';
import { useEffect, useState } from 'react';
import VmCustom from "../_components/vm-custom";
import VtxBaseModal from "../vtx-base-modal";
import VtxDefaultModal from "../vtx-default-modal";
import { Appraise, Base, Build, File, Score } from "./components";
import "./style";

//弹窗配置
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
var getByCode = function getByCode(params) {
  return request.get('/cloud/jcss-reborn/facility/type/config/getByCode', {
    data: params
  });
};
//公厕详情
var smallPop = function smallPop(params) {
  return request.get('/cloud/zhgc-reborn/api/gis/pop/smallPop', {
    data: params
  });
};
export default (function (props) {
  var _config$;
  var visible = props.visible,
    theme = props.theme,
    title = props.title,
    id = props.id,
    onCancel = props.onCancel,
    _props$modalShow = props.modalShow,
    modalShow = _props$modalShow === void 0 ? true : _props$modalShow;
  var _useState = useState({}),
    _useState2 = _slicedToArray(_useState, 2),
    detail = _useState2[0],
    setDetail = _useState2[1];
  var _useState3 = useState([]),
    _useState4 = _slicedToArray(_useState3, 2),
    config = _useState4[0],
    setConfig = _useState4[1];
  useEffect(function () {
    getByCode({
      code: 'wr'
    }).then(function (res) {
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        setConfig((res.data.popupConfigJson || []).filter(function (item) {
          return item.display;
        }).map(function (item) {
          return _objectSpread(_objectSpread({}, item), {}, {
            key: item.code,
            title: item.name
          });
        }));
      }
    });
  }, []);
  useEffect(function () {
    id && smallPop({
      id: id
    }).then(function (res) {
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        setDetail(res.data || {});
      }
    });
  }, [id]);
  var contentList = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, 'base', /*#__PURE__*/_jsx(Base, _objectSpread(_objectSpread({}, props), {}, {
    detail: detail
  }))), 'appraise', /*#__PURE__*/_jsx(Appraise, _objectSpread({}, props))), 'score', /*#__PURE__*/_jsx(Score, _objectSpread({}, props))), 'build', /*#__PURE__*/_jsx(Build, _objectSpread({}, props))), 'file', /*#__PURE__*/_jsx(File, _objectSpread({}, props)));

  // 自定义页签可配置多个，
  if (config !== null && config !== void 0 && config.length) {
    config.forEach(function (ele) {
      if (ele.url) {
        contentList[ele.key] = /*#__PURE__*/_jsx(VmCustom, {
          id: id,
          url: ele === null || ele === void 0 ? void 0 : ele.url
        });
      }
    });
  }
  return /*#__PURE__*/_jsx(_Fragment, {
    children: visible && config !== null && config !== void 0 && config.length ? /*#__PURE__*/_jsx(VtxBaseModal, {
      type: "wr",
      visible: visible,
      theme: theme,
      title: title,
      id: id,
      onCancel: onCancel,
      tabs: config,
      contents: contentList,
      tabChose: (_config$ = config[0]) === null || _config$ === void 0 ? void 0 : _config$.key,
      modalShow: modalShow,
      tagList: [detail.withFacilityClass && {
        color: 'blue',
        value: detail.facilityClassName
      }, detail.withFacilityStatus && {
        color: 'green',
        value: detail.facilityStatusName
      }, detail.withDevice && {
        color: 'green',
        value: '已绑定设备'
      }, !!detail.alarmNum && {
        color: 'red',
        value: "\u6B63\u5728\u62A5\u8B66 ".concat(detail.alarmNum)
      }].filter(function (item) {
        return !!item;
      })
    }) : /*#__PURE__*/_jsx(VtxDefaultModal, {
      visible: visible,
      theme: theme,
      title: title,
      id: id,
      onCancel: onCancel
    })
  });
});