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 { useSetState } from 'ahooks';
import { Tooltip } from 'antd';
import dayjs from 'dayjs';
import { VmBarCharts, VmFactor, VmInfoCollection, VmMap, VmPieCharts, VmTitle, VmWrapper } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { BaseService } from "../../api2";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var BaseInfo = function BaseInfo(props) {
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var mapCenter = props.mapCenter,
    id = props.id;
  var _useSetState = useSetState({
      date: dayjs()
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var date = state.date;
  var _BaseService$useBaseI = BaseService.useBaseInfo(id),
    baseInfo = _BaseService$useBaseI.baseInfo,
    info = _BaseService$useBaseI.info,
    mapPoints = _BaseService$useBaseI.mapPoints,
    type = _BaseService$useBaseI.type,
    center = _BaseService$useBaseI.center,
    mapPolygons = _BaseService$useBaseI.mapPolygons;
  var _BaseService$useKhInf = BaseService.useKhInfo(id, date.startOf('M').format('YYYY-MM-DD'), date.endOf('M').format('YYYY-MM-DD')),
    khRes = _BaseService$useKhInf.khRes;
  var _BaseService$useGetQu = BaseService.useGetQuestions(id, date.startOf('M').format('YYYY-MM-DD'), date.endOf('M').format('YYYY-MM-DD')),
    questions = _BaseService$useGetQu.questions;
  var _BaseService$use7mont = BaseService.use7month(id, dayjs().subtract(6, 'M').startOf('M').format('YYYY-MM-DD'), dayjs().endOf('M').format('YYYY-MM-DD')),
    monthData = _BaseService$use7mont.monthData,
    loading = _BaseService$use7mont.loading;
  var filterChange = function filterChange(dateValue) {
    setState({
      date: dateValue
    });
  };
  var mapParam = {
    mapCenter: mapCenter
  };
  if (type) {
    mapParam = {
      mapCenter: center || mapCenter,
      geometryType: type,
      newMapPoints: mapPoints,
      mapPolygons: mapPolygons
    };
  }
  return /*#__PURE__*/_jsxs("div", {
    className: "kh-base",
    children: [/*#__PURE__*/_jsx("div", {
      className: "kh-base-left",
      children: /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u57FA\u672C\u4FE1\u606F",
        children: [/*#__PURE__*/_jsx(VmInfoCollection, {
          data: baseInfo,
          gap: 12
        }), /*#__PURE__*/_jsx("div", {
          className: "kh-base-map",
          children: /*#__PURE__*/_jsx(VmMap, _objectSpread({
            address: info === null || info === void 0 ? void 0 : info.address
          }, mapParam))
        })]
      })
    }), /*#__PURE__*/_jsxs("div", {
      className: "kh-base-right",
      children: [/*#__PURE__*/_jsx("div", {
        className: "kh-base-right-summary",
        children: /*#__PURE__*/_jsxs(VmWrapper, {
          title: "\u672C\u6708\u8003\u6838\u60C5\u51B5",
          filterType: "monthPicker",
          dateValue: state.date,
          filterChange: filterChange,
          children: [/*#__PURE__*/_jsx("div", {
            className: "kh-base-right-summary-head",
            children: [{
              name: '考核次数',
              value: khRes === null || khRes === void 0 ? void 0 : khRes.monthCheckTims,
              key: 'count',
              unit: '次',
              fontType: 'blue'
            }, {
              name: '考核得分',
              value: khRes === null || khRes === void 0 ? void 0 : khRes.monthPoint,
              key: 'score',
              unit: '分',
              fontType: 'green'
            }, {
              name: '累计扣分',
              value: khRes === null || khRes === void 0 ? void 0 : khRes.monthDeductPoint,
              key: 'subtract',
              unit: '分',
              fontType: 'red'
            }].map(function (ele) {
              return /*#__PURE__*/_jsx(VmFactor, _objectSpread(_objectSpread({}, ele), {}, {
                img: require("../../imgs/".concat(ele.key).concat(isDark ? '' : '_light', ".png")),
                unitStyle: {
                  fontSize: 14
                }
              }), ele.key);
            })
          }), /*#__PURE__*/_jsx(VmTitle, {
            title: "\u672C\u6708\u9AD8\u53D1\u95EE\u9898",
            border: false
          }), /*#__PURE__*/_jsxs("div", {
            className: "kh-base-right-question",
            children: [/*#__PURE__*/_jsx("div", {
              className: "kh-base-right-question-left",
              children: /*#__PURE__*/_jsx(VmPieCharts, {
                height: 140,
                dataList: questions === null || questions === void 0 ? void 0 : questions.map(function (ele) {
                  return {
                    name: ele.ruleName,
                    value: ele.times
                  };
                }),
                name: "\u9AD8\u53D1\u95EE\u9898",
                loading: false,
                unit: "\u6B21",
                innerRadius: ['70%', '85%'],
                outerRadius: ['85%', '90%'],
                center: ['20%', '50%'],
                legendConfig: {
                  right: 0
                }
              })
            }), /*#__PURE__*/_jsxs("div", {
              className: "kh-base-right-question-right ".concat(isDark ? 'dark' : ''),
              children: [/*#__PURE__*/_jsx("div", {
                className: "ques-title",
                children: "\u6700\u5BB9\u6613\u51FA\u73B0\u95EE\u9898\u524D\u4E09:"
              }), questions === null || questions === void 0 ? void 0 : questions.filter(function (ele, index) {
                return index < 3;
              }).map(function (ele, index) {
                return /*#__PURE__*/_jsxs("div", {
                  className: "ques-row",
                  children: [/*#__PURE__*/_jsx("div", {
                    className: "ques-order",
                    children: index + 1
                  }), /*#__PURE__*/_jsxs("div", {
                    className: "ques-name",
                    children: [ele.ruleName, " ", ele.times, "\u6B21"]
                  })]
                }, ele.ruleId);
              })]
            })]
          }), /*#__PURE__*/_jsx("div", {
            className: "kh-base-right-question-desc ".concat(isDark ? 'dark' : ''),
            children: /*#__PURE__*/_jsx(Tooltip, {
              title: '加强保洁频次与监督；设置报修专线，快速疏通维修；完善设施巡检制度，提升服务标准。，提升服务标准。，提升服务标准',
              children: "\u5EFA\u8BAE\u63AA\u65BD: \u52A0\u5F3A\u4FDD\u6D01\u9891\u6B21\u4E0E\u76D1\u7763\uFF1B\u8BBE\u7F6E\u62A5\u4FEE\u4E13\u7EBF\uFF0C\u5FEB\u901F\u758F\u901A\u7EF4\u4FEE\uFF1B\u5B8C\u5584\u8BBE\u65BD\u5DE1\u68C0\u5236\u5EA6\uFF0C\u63D0\u5347\u670D\u52A1\u6807\u51C6\u3002\uFF0C\u63D0\u5347\u670D\u52A1\u6807\u51C6\u3002\uFF0C\u63D0\u5347\u670D\u52A1\u6807\u51C6\u3002"
            })
          })]
        })
      }), /*#__PURE__*/_jsxs(VmWrapper, {
        title: "\u8FD17\u6708\u8003\u6838\u5F97\u5206\u60C5\u51B5",
        style: {
          height: 300,
          marginTop: 16
        },
        children: [/*#__PURE__*/_jsx(VmBarCharts, {
          dataList: [{
            name: '考核得分',
            data: (monthData === null || monthData === void 0 ? void 0 : monthData.map(function (ele) {
              return ele.point;
            })) || [],
            color: 'geekblue'
          }],
          xAxis: monthData === null || monthData === void 0 ? void 0 : monthData.map(function (ele) {
            return ele.month;
          }),
          yAxisList: [{
            unit: '分',
            name: '(分)',
            key: ''
          }],
          loading: loading,
          height: 250
        }), /*#__PURE__*/_jsx("div", {})]
      })]
    })]
  });
};
export default BaseInfo;