"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = TodayWork;
var _react = _interopRequireDefault(require("react"));
var _progress = _interopRequireDefault(require("antd/es/progress"));
var _utils = require("@vtx/utils");
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
require("./index.less");
var _all_rate = _interopRequireDefault(require("../../imgs/all_rate.png"));
var _all_rate_light = _interopRequireDefault(require("../../imgs/all_rate_light.png"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
 * 收集点-总览信息-收运规则
 */

// import cyRate from '../../imgs/cy_rate.png';
// import qtRate from '../../imgs/qt_rate.png';
// import yhRate from '../../imgs/yh_rate.png';

// import cyRateLight from '../../imgs/cy_rate_light.png';
// import qtRateLight from '../../imgs/qt_rate_light.png';
// import yhRateLight from '../../imgs/yh_rate_light.png';
function TodayWork(props) {
  var data = props.data,
    paramConfigsList = props.paramConfigsList,
    productTypes = props.productTypes;
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme,
    isDark = _useSettings.isDark;
  var blockItem = function blockItem(title, value, unit) {
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "twork--item-block-item"
    }, /*#__PURE__*/_react["default"].createElement("div", null, title), /*#__PURE__*/_react["default"].createElement("div", {
      className: "twork--item-block-item-value"
    }, /*#__PURE__*/_react["default"].createElement("span", null, value || 0), unit));
  };
  var getIcon = function getIcon(id) {
    var _a;
    var src = '';
    if ((_a = productTypes === null || productTypes === void 0 ? void 0 : productTypes[id]) === null || _a === void 0 ? void 0 : _a.icon) {
      var icon = JSON.parse(productTypes[id].icon)[0];
      src = "/cloudFile/common/downloadFile?id=".concat(icon.id, "&token=").concat((0, _utils.getVtxToken)('token'));
    }
    return src;
  };
  var img = {
    dark: {
      全部: _all_rate["default"]
      // 其他垃圾: getIcon('QITA') || qtRate,
      // 厨余垃圾: getIcon('CHUYU') || cyRate,
      // 有害垃圾: getIcon('YOUHAI') || yhRate,
    },
    light: {
      全部: _all_rate_light["default"]
      // 其他垃圾: getIcon('QITA') || qtRateLight,
      // 厨余垃圾: getIcon('CHUYU') || cyRateLight,
      // 有害垃圾: getIcon('YOUHAI') || yhRateLight,
    },
    blue: {
      全部: _all_rate_light["default"]
      // 其他垃圾: getIcon('QITA') || qtRateLight,
      // 厨余垃圾: getIcon('CHUYU') || cyRateLight,
      // 有害垃圾: getIcon('YOUHAI') || yhRateLight,
    }
  };
  var getValue = function getValue(name, id) {
    var _a;
    var strokeColor = {
      '0%': '#BFFFE8',
      '100%': '#37D3B0'
    };
    var src = name === '全部' ? theme ? (_a = img[theme]) === null || _a === void 0 ? void 0 : _a[name] : '' : getIcon(id);
    switch (name) {
      case '全部':
        strokeColor = {
          '0%': '#BFFFE8',
          '100%': '#37D3B0'
        };
        break;
      case '其他垃圾':
        strokeColor = {
          '0%': '#EC982B',
          '100%': '#FFE49A'
        };
        break;
      case '厨余垃圾':
        strokeColor = {
          '0%': '#62C1FD',
          '100%': '#3E9DF9'
        };
        break;
      case '有害垃圾':
        strokeColor = {
          '0%': '#FFA793',
          '100%': '#FF6770'
        };
        break;
      default:
        strokeColor = {
          '0%': '#EC982B',
          '100%': '#FFE49A'
        };
        break;
    }
    return {
      strokeColor: isDark ? strokeColor : '#00AA64',
      src: src
    };
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "twork"
  }, Array.isArray(data) ? data.map(function (item, index) {
    var _a, _b;
    var _getValue = getValue(item === null || item === void 0 ? void 0 : item.productTypeName, item === null || item === void 0 ? void 0 : item.productTypeId),
      strokeColor = _getValue.strokeColor,
      src = _getValue.src;
    return /*#__PURE__*/_react["default"].createElement("div", {
      className: "twork--item",
      key: index
    }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("img", {
      src: src
    })), /*#__PURE__*/_react["default"].createElement("div", {
      className: "twork--item-progress"
    }, /*#__PURE__*/_react["default"].createElement("div", null, item === null || item === void 0 ? void 0 : item.productTypeName, "\u5B8C\u6210\u7387\uFF1A", item.rate || 0, "%"), /*#__PURE__*/_react["default"].createElement("div", {
      className: "twork--item-progress-bg"
    }, /*#__PURE__*/_react["default"].createElement(_progress["default"], {
      strokeLinecap: "butt",
      percent: item.rate,
      strokeColor: strokeColor,
      trailColor: isDark ? '#444B59' : '#D2D2D2',
      strokeWidth: 6,
      showInfo: false
    }))), /*#__PURE__*/_react["default"].createElement("div", {
      className: "twork--item-block"
    }, blockItem('应收次数', item === null || item === void 0 ? void 0 : item.planCollectNums, '次'), blockItem('实收次数', item === null || item === void 0 ? void 0 : item.collectNums, '次'), ((_a = paramConfigsList['SHOW_COLLECTING_BUCKETS']) === null || _a === void 0 ? void 0 : _a.value) === 'true' && blockItem('收集桶数', item === null || item === void 0 ? void 0 : item.bucketNum, '桶'), ((_b = paramConfigsList['SHOW_WEIGHTING']) === null || _b === void 0 ? void 0 : _b.value) === 'true' && blockItem('收集重量', item === null || item === void 0 ? void 0 : item.weight, 'kg')));
  }) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], null)));
}
//# sourceMappingURL=TodayWork.js.map
