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 { useSetState } from 'ahooks';
import dayjs from 'dayjs';
import { useEffect } from 'react';
import { TagCloud } from 'react-tagcloud';
import { VmEmpty, VmTable } from "../../../_components";
import { VMRangePicker } from "../../../_components/vm-filter";

//公厕详情
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var getDetail = function getDetail(params) {
  return request.get('/cloud/zhgc-reborn/api/v101/evaluate/score/getByGcId', {
    data: params
  });
};

//表格
var getList = function getList(params) {
  return request.get('/cloud/zhgc-reborn/api/v101/evaluate/month/score/list', {
    data: params
  });
};
export default (function (props) {
  var _detail$score, _detail$evaluateCount;
  var id = props.id,
    theme = props.theme;
  var _useSetState = useSetState({
      detail: {
        evaluateLabelCountList: []
      },
      startDate: '',
      endDate: '',
      tableData: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var detail = state.detail,
    startDate = state.startDate,
    endDate = state.endDate,
    tableData = state.tableData;
  useEffect(function () {
    id && getDetail({
      id: id
    }).then(function (res) {
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        setState({
          detail: res.data
        });
      }
    });
  }, [id]);
  useEffect(function () {
    id && getList({
      gcId: id,
      startMonth: startDate,
      endMonth: endDate
    }).then(function (res) {
      if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
        setState({
          tableData: res.data || []
        });
      }
    });
  }, [id, startDate, endDate]);
  var columns = [{
    title: '序号',
    dataIndex: 'orderIndex',
    key: 'orderIndex',
    width: 100
  }, {
    title: '统计月份',
    dataIndex: 'month',
    key: 'month',
    width: 100
  }, {
    title: '分数',
    dataIndex: 'score',
    key: 'score',
    width: 100
  }];
  var tableProps = {
    columns: columns,
    height: 240,
    isIndex: false,
    pagination: false,
    dataSource: tableData.map(function (item, index) {
      return _objectSpread(_objectSpread({}, item), {}, {
        orderIndex: index + 1
      });
    })
  };
  var data = (detail.evaluateLabelCountList || []).map(function (item) {
    return {
      value: "".concat(item.name, " ").concat(item.count),
      count: item.count
    };
  });
  return /*#__PURE__*/_jsxs("div", {
    className: "wr-score-content",
    children: [/*#__PURE__*/_jsxs("div", {
      className: "wr-score-panel",
      style: {
        height: '290px'
      },
      children: [/*#__PURE__*/_jsx("div", {
        className: "wr-score-title",
        children: /*#__PURE__*/_jsx("div", {
          children: "\u5F97\u5206\u60C5\u51B5"
        })
      }), /*#__PURE__*/_jsxs("div", {
        className: "wr-score-content",
        children: [/*#__PURE__*/_jsx("div", {
          className: "score-chart",
          children: /*#__PURE__*/_jsxs("div", {
            className: "score-summary",
            children: [/*#__PURE__*/_jsxs("div", {
              className: "score-summary-item",
              children: [/*#__PURE__*/_jsx("img", {
                src: require("./assets/".concat(theme, "/df.png")),
                alt: "df"
              }), /*#__PURE__*/_jsxs("div", {
                children: [/*#__PURE__*/_jsx("div", {
                  children: "\u5E73\u5747\u5F97\u5206"
                }), /*#__PURE__*/_jsxs("div", {
                  children: [/*#__PURE__*/_jsx("span", {
                    style: {
                      fontSize: '20px'
                    },
                    children: (_detail$score = detail.score) !== null && _detail$score !== void 0 ? _detail$score : 0
                  }), "\xA0\u5206"]
                })]
              })]
            }), /*#__PURE__*/_jsxs("div", {
              className: "score-summary-item",
              children: [/*#__PURE__*/_jsx("img", {
                src: require("./assets/".concat(theme, "/rs.png")),
                alt: "rs"
              }), /*#__PURE__*/_jsxs("div", {
                children: [/*#__PURE__*/_jsx("div", {
                  children: "\u8BC4\u4EF7\u4EBA\u6570"
                }), /*#__PURE__*/_jsxs("div", {
                  children: [/*#__PURE__*/_jsx("span", {
                    style: {
                      fontSize: '20px'
                    },
                    children: (_detail$evaluateCount = detail.evaluateCount) !== null && _detail$evaluateCount !== void 0 ? _detail$evaluateCount : 0
                  }), "\xA0\u4EBA"]
                })]
              })]
            })]
          })
        }), /*#__PURE__*/_jsx("div", {
          className: "score-text",
          children: !!data.length ? /*#__PURE__*/_jsx(TagCloud, {
            tags: data,
            minSize: 25,
            maxSize: 50,
            colorOptions: {
              colors: ['red', 'orange', 'yellow', 'green', 'blue', 'purple']
            }
          }) : /*#__PURE__*/_jsx(VmEmpty, {})
        })]
      })]
    }), /*#__PURE__*/_jsxs("div", {
      className: "wr-score-panel",
      style: {
        height: '310px',
        marginTop: '10px'
      },
      children: [/*#__PURE__*/_jsxs("div", {
        className: "wr-score-title",
        children: [/*#__PURE__*/_jsx("div", {
          children: "\u8BC4\u4EF7\u8BB0\u5F55"
        }), /*#__PURE__*/_jsx(VMRangePicker, {
          picker: "month",
          value: startDate ? [dayjs(startDate), dayjs(endDate)] : null,
          disabledDate: function disabledDate(current) {
            return current && current > dayjs().endOf('month');
          },
          onChange: function onChange(_, dateStr) {
            return setState({
              startDate: dateStr[0],
              endDate: dateStr[1]
            });
          }
        })]
      }), /*#__PURE__*/_jsx(VmTable, _objectSpread(_objectSpread({}, tableProps), {}, {
        height: "200px"
      }))]
    })]
  });
});