"use strict";

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); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Summary;
var _react = _interopRequireWildcard(require("react"));
var _ahooks = require("ahooks");
var _antd = require("antd");
var _moment = _interopRequireDefault(require("moment"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmFilter = require("../../../vm-filter");
var _Radar = _interopRequireDefault(require("./Radar"));
var _api = require("../../api");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
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(r) { if (Array.isArray(r)) return r; } /**
 * 评价信息-上半部分-汇总
 */
function Summary(props) {
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    isDark = _useSettings.isDark,
    sDate = _useSettings.startDate,
    eDate = _useSettings.endDate;
  var id = props.id,
    setDate = props.setDate;
  var _useSetState = (0, _ahooks.useSetState)({
      startDate: sDate || (0, _moment["default"])().startOf('M').format('YYYY-MM-DD'),
      endDate: eDate || (0, _moment["default"])().format('YYYY-MM-DD')
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var startDate = state.startDate,
    endDate = state.endDate;
  (0, _react.useEffect)(function () {
    setDate(startDate, endDate);
  }, [startDate, endDate]);
  var _AppraiseService$useA = _api.AppraiseService.useAppraisSummary(id, startDate ? "".concat(startDate, " 00:00:00") : '', "".concat(endDate, " 23:59:59")),
    appraiseSummary = _AppraiseService$useA.appraiseSummary;
  var valueEight = appraiseSummary.valueEight,
    valueFour = appraiseSummary.valueFour,
    valueFive = appraiseSummary.valueFive,
    valueSeven = appraiseSummary.valueSeven,
    valueSix = appraiseSummary.valueSix,
    assessCount = appraiseSummary.assessCount,
    totalValue = appraiseSummary.totalValue,
    goodItem = appraiseSummary.goodItem,
    goodItemStr = appraiseSummary.goodItemStr,
    badItem = appraiseSummary.badItem,
    badItemStr = appraiseSummary.badItemStr,
    exceedingRate = appraiseSummary.exceedingRate;
  var handleDateChange = function handleDateChange(start, end) {
    setState({
      startDate: start,
      endDate: end
    });
  };
  var radarData = {
    indicator: [{
      name: '容易找到',
      max: 10
    }, {
      name: '公众满意',
      max: 10
    }, {
      name: '服务管理',
      max: 10
    }, {
      name: '无需等待',
      max: 10
    }, {
      name: '干净卫生',
      max: 10
    }],
    value: [valueEight, valueFive, valueFour, valueSeven, valueSix]
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-head"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-subscribtion"
  }, exceedingRate > 0 && "\u8BE5\u516C\u5395\u8FD1\u671F\u7EFC\u5408\u8BC4\u4EF7\u9886\u5148".concat(exceedingRate, "%\u7684\u516C\u5395\uFF0C\u7EE7\u7EED\u4FDD\u6301\uFF01")), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_vmFilter.VMRangePicker, {
    value: [(0, _moment["default"])(startDate), (0, _moment["default"])(endDate)],
    onChange: function onChange(dates) {
      return dates && handleDateChange((0, _moment["default"])(dates[0]).format('YYYY-MM-DD'), (0, _moment["default"])(dates[1]).format('YYYY-MM-DD'));
    }
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [24, 24],
    align: "middle"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 8
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-radar"
  }, /*#__PURE__*/_react["default"].createElement(_Radar["default"], Object.assign({}, radarData)))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 8
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-avg"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-avg-progress ".concat(theme)
  }, /*#__PURE__*/_react["default"].createElement(_antd.Progress, {
    type: "circle",
    percent: totalValue || 0,
    strokeWidth: 10,
    strokeColor: isDark ? '#4AFFE6' : '#1890ff',
    trailColor: isDark ? 'rgba(255,255,255,0.1)' : '#D1D5D9',
    strokeLinecap: "butt",
    showInfo: false,
    style: {
      width: '100px',
      height: '100px',
      margin: '24px 0 0 24px'
    }
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-avg-progress-text"
  }, /*#__PURE__*/_react["default"].createElement("span", null, totalValue), /*#__PURE__*/_react["default"].createElement("div", null, "\u5E73\u5747\u603B\u5206"))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-avg-count"
  }, /*#__PURE__*/_react["default"].createElement("span", null, assessCount, "\u6B21"), /*#__PURE__*/_react["default"].createElement("div", null, "\u8BC4\u4EF7\u603B\u6B21\u6570")))), /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 8
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-appraise"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-appraise-good"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-appraise-good-bg ".concat(theme)
  }, "\u4F18\u79C0\u9879\uFF1A ", goodItem || '无'), goodItemStr || '--'), /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-appraise-bad"
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "appraise-summary-main-appraise-bad-bg ".concat(theme)
  }, "\u8584\u5F31\u9879\uFF1A", badItem || '无'), badItemStr || '--'))))));
}
//# sourceMappingURL=Summary.js.map
