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 { VtxImage } from '@vtx/components';
import { getVtxToken } from '@vtx/utils';
import { useSetState } from 'ahooks';
import { Col, Row } from 'antd';
import dayjs from 'dayjs';
import { useRef } from 'react';
import { VmEmpty, VmInfoCollection, VmWrapper } from "../../../_components";
import { CommonService } from "../../../_service";
import { getFieldRender } from "../../../_util";
import { BaseService } from "../../api";
import "./index.less";
import Jcqsfx from "./Jcqsfx";
import Qyjcl from "./Qyjcl";
import RealtimeMonitor from "./RealtimeMonitor";
import Situation from "./Situation";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var BaseInfo = function BaseInfo(props) {
  var info = props.info,
    photos = props.photos,
    code = props.code,
    hasLm = props.hasLm,
    realtimeMonitor = props.realtimeMonitor;
  var nowDate = dayjs().format('YYYY-MM-DD');
  var _useSetState = useSetState({
      startDate: dayjs().subtract(1, 'month').format('YYYY-MM-DD'),
      endDate: nowDate
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var imgRef = useRef(null);
  var startDate = state.startDate,
    endDate = state.endDate;
  var fields = CommonService.useGetFields(info === null || info === void 0 ? void 0 : info.typeCode);
  var _BaseService$useSitua = BaseService.useSituation(code, nowDate),
    situationRes = _BaseService$useSitua.situationRes;
  return /*#__PURE__*/_jsxs("div", {
    className: "df-base-content",
    children: [/*#__PURE__*/_jsx("div", {
      className: "df-base-content-left",
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u57FA\u672C\u4FE1\u606F",
        children: [/*#__PURE__*/_jsx("div", {
          className: "base-top-img",
          ref: imgRef,
          children: photos.length ? /*#__PURE__*/_jsx("div", {
            style: {
              padding: '0 12px 12px'
            },
            children: /*#__PURE__*/_jsx(VtxImage, {
              src: "/cloudFile/common/downloadFile?id=".concat(photos[0].id, "&token=").concat(getVtxToken('token')),
              alt: photos[0].name,
              isDark: true,
              style: {
                maxWidth: '340px',
                height: 220,
                overflow: 'hidden'
              }
            }, photos[0].id)
          }) : /*#__PURE__*/_jsx(VmEmpty, {
            type: "NO_PICTURE",
            style: {
              height: 220
            }
          })
        }), /*#__PURE__*/_jsx("div", {
          className: "base-top--base",
          children: /*#__PURE__*/_jsx(VmInfoCollection, {
            data: getFieldRender(fields, info),
            horizontal: true,
            width: "50%",
            ellipsis: true,
            padding: '0 12px 12px'
          })
        })]
      })
    }), /*#__PURE__*/_jsxs("div", {
      className: "df-base-content-right",
      children: [hasLm && /*#__PURE__*/_jsxs(Row, {
        gutter: [16, 16],
        style: {
          marginBottom: 10
        },
        children: [/*#__PURE__*/_jsx(Col, {
          span: 8,
          children: /*#__PURE__*/_jsx(VmWrapper, {
            title: "\u5B9E\u65F6\u8FDB\u573A\u60C5\u51B5",
            style: {
              height: 280
            },
            children: /*#__PURE__*/_jsx(Situation, {
              situationRes: situationRes
            })
          })
        }), /*#__PURE__*/_jsx(Col, {
          span: 16,
          children: /*#__PURE__*/_jsx(VmWrapper, {
            style: {
              height: 280
            },
            title: "\u533A\u57DF\u8FDB\u573A\u91CF\u5206\u6790",
            filterType: "rangePicker",
            dateValue: [dayjs(startDate), dayjs(endDate)],
            filterChange: function filterChange(dates) {
              return dates && setState({
                startDate: dayjs(dates[0]).format('YYYY-MM-DD'),
                endDate: dayjs(dates[1]).format('YYYY-MM-DD')
              });
            },
            children: /*#__PURE__*/_jsx(Qyjcl, {
              code: code,
              startDate: startDate,
              endDate: endDate
            })
          })
        })]
      }), (realtimeMonitor === null || realtimeMonitor === void 0 ? void 0 : realtimeMonitor.length) > 0 ? /*#__PURE__*/_jsx(RealtimeMonitor, {
        realtimeMonitor: realtimeMonitor,
        hasLm: hasLm
      }) : null, hasLm && !(realtimeMonitor !== null && realtimeMonitor !== void 0 && realtimeMonitor.length) ?
      /*#__PURE__*/
      // 仅有计量
      _jsx(Jcqsfx, {
        code: code,
        startDate: startDate,
        endDate: endDate
      }) : null]
    })]
  });
};
export default BaseInfo;