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 { VmBarCharts, VmTable } from "../../../_components";
import { VMRangePicker } from "../../../_components/vm-filter";

//柱状图
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var overview = function overview(params) {
  return request.get('/cloud/zhgc-reborn/api/v101/evaluate/score/getStatistic', {
    data: params
  });
};

//评价记录?gcId=
var evaluateDetailList = function evaluateDetailList(params) {
  return request.get('/cloud/zhgc-reborn/api/v101/evaluate/detail/list', {
    data: params
  });
};
export default (function (props) {
  var _baseInfo$total, _baseInfo$score, _baseInfo$goodLabel, _baseInfo$badLabel;
  var theme = props.theme,
    id = props.id;
  var _useSetState = useSetState({
      startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
      endDate: dayjs().format('YYYY-MM-DD'),
      baseInfo: {},
      tableData: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var startDate = state.startDate,
    endDate = state.endDate,
    baseInfo = state.baseInfo,
    tableData = state.tableData;
  useEffect(function () {
    if (id) {
      overview({
        id: id,
        startDate: startDate,
        endDate: endDate
      }).then(function (res) {
        if ((res === null || res === void 0 ? void 0 : res.result) === 0) {
          setState({
            baseInfo: res.data || {}
          });
        }
      });
      evaluateDetailList({
        gcId: id,
        startEvaluateTime: "".concat(startDate, " 00:00:00"),
        endEvaluateTime: "".concat(endDate, " 23:59:59")
      }).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: 60
  }, {
    title: '评分',
    dataIndex: 'score',
    key: 'score',
    width: 60
  }, {
    title: '评价标签',
    dataIndex: 'evaluateLabelNames',
    key: 'evaluateLabelNames',
    width: 100,
    ellipsis: true
  }, {
    title: '评价内容',
    dataIndex: 'evaluateContent',
    key: 'evaluateContent',
    width: 200,
    ellipsis: true
  }];
  var tableProps = {
    columns: columns,
    height: 240,
    isIndex: false,
    pagination: false,
    dataSource: tableData.map(function (item, index) {
      return _objectSpread(_objectSpread({}, item), {}, {
        orderIndex: index + 1
      });
    })
  };
  return /*#__PURE__*/_jsxs("div", {
    className: "wr-appraise-content",
    children: [/*#__PURE__*/_jsxs("div", {
      className: "wr-appraise-panel",
      style: {
        height: '290px'
      },
      children: [/*#__PURE__*/_jsxs("div", {
        className: "wr-appraise-title",
        children: [/*#__PURE__*/_jsx("div", {
          children: "\u4F5C\u4E1A\u6C47\u603B\u5206\u6790"
        }), /*#__PURE__*/_jsx(VMRangePicker, {
          value: [dayjs(startDate), dayjs(endDate)],
          disabledDate: function disabledDate(current) {
            return current && current > dayjs();
          },
          onChange: function onChange(_, dateStr) {
            return setState({
              startDate: dateStr[0],
              endDate: dateStr[1]
            });
          }
        })]
      }), /*#__PURE__*/_jsxs("div", {
        className: "wr-appraise-content",
        children: [/*#__PURE__*/_jsxs("div", {
          className: "appraise-chart",
          children: [/*#__PURE__*/_jsxs("div", {
            className: "appraise-summary",
            children: [/*#__PURE__*/_jsxs("div", {
              className: "appraise-summary-item",
              children: [/*#__PURE__*/_jsx("img", {
                src: require("./assets/".concat(theme, "/pjcs.png")),
                alt: "pjcs"
              }), /*#__PURE__*/_jsxs("div", {
                children: [/*#__PURE__*/_jsx("div", {
                  children: "\u603B\u8BC4\u4EF7\u6B21\u6570"
                }), /*#__PURE__*/_jsxs("div", {
                  children: [/*#__PURE__*/_jsx("span", {
                    style: {
                      fontSize: '20px'
                    },
                    children: (_baseInfo$total = baseInfo.total) !== null && _baseInfo$total !== void 0 ? _baseInfo$total : 0
                  }), "\xA0\u6B21"]
                })]
              })]
            }), /*#__PURE__*/_jsxs("div", {
              className: "appraise-summary-item",
              children: [/*#__PURE__*/_jsx("img", {
                src: require("./assets/".concat(theme, "/pjfs.png")),
                alt: "pjfs"
              }), /*#__PURE__*/_jsxs("div", {
                children: [/*#__PURE__*/_jsx("div", {
                  children: "\u5E73\u5747\u603B\u5206"
                }), /*#__PURE__*/_jsxs("div", {
                  children: [/*#__PURE__*/_jsx("span", {
                    style: {
                      fontSize: '20px'
                    },
                    children: (_baseInfo$score = baseInfo.score) !== null && _baseInfo$score !== void 0 ? _baseInfo$score : 0
                  }), "\xA0\u5206"]
                })]
              })]
            })]
          }), /*#__PURE__*/_jsx(VmBarCharts, {
            height: 140,
            xAxis: (baseInfo.evaluateLabelCountList || []).map(function (item) {
              return item.name;
            }),
            yAxisList: [{
              key: '',
              unit: '次',
              name: '(次)'
            }],
            dataList: [{
              data: (baseInfo.evaluateLabelCountList || []).map(function (item) {
                var _item$count;
                return (_item$count = item.count) !== null && _item$count !== void 0 ? _item$count : 0;
              })
            }],
            unit: "\u5206",
            gridOptions: {
              top: 40
            }
          })]
        }), /*#__PURE__*/_jsxs("div", {
          className: "appraise-text",
          children: [/*#__PURE__*/_jsxs("div", {
            className: "appraise-text-item",
            style: {
              backgroundImage: "url(".concat(require("./assets/".concat(theme, "/bgY.png")), ")"),
              color: '#1CE548'
            },
            children: [/*#__PURE__*/_jsx("div", {
              children: "\u4F18\u79C0\u9879\uFF1A"
            }), /*#__PURE__*/_jsx("div", {
              style: {
                color: '#1CE548'
              },
              children: ((_baseInfo$goodLabel = baseInfo.goodLabel) === null || _baseInfo$goodLabel === void 0 ? void 0 : _baseInfo$goodLabel.name) || '无'
            })]
          }), /*#__PURE__*/_jsxs("div", {
            className: "appraise-text-item",
            style: {
              backgroundImage: "url(".concat(require("./assets/".concat(theme, "/bgR.png")), ")"),
              color: '#FF5861'
            },
            children: [/*#__PURE__*/_jsx("div", {
              children: "\u8584\u5F31\u9879\uFF1A"
            }), /*#__PURE__*/_jsx("div", {
              children: ((_baseInfo$badLabel = baseInfo.badLabel) === null || _baseInfo$badLabel === void 0 ? void 0 : _baseInfo$badLabel.name) || '无'
            })]
          })]
        })]
      })]
    }), /*#__PURE__*/_jsxs("div", {
      className: "wr-appraise-panel",
      style: {
        height: '310px',
        marginTop: '10px'
      },
      children: [/*#__PURE__*/_jsx("div", {
        className: "wr-appraise-title",
        children: /*#__PURE__*/_jsx("div", {
          children: "\u8BC4\u4EF7\u8BB0\u5F55"
        })
      }), /*#__PURE__*/_jsx(VmTable, _objectSpread({}, tableProps))]
    })]
  });
});