"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _api = require("../../api");
var _dayjs = _interopRequireDefault(require("dayjs"));
var _antd = require("antd");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
var prefix = 'car-base-left--chain';
var StatisticsItem = function StatisticsItem(_ref) {
  var item = _ref.item;
  var name = item.name,
    value = item.value,
    ringValue = item.ringValue,
    unit = item.unit;
  var upArrowColor = '#52C41A';
  var downArrowColor = '#FF4D4F';
  var isUp = value > ringValue;
  var arrowStyle = {
    borderColor: isUp ? "transparent transparent ".concat(upArrowColor) : "".concat(downArrowColor, " transparent transparent")
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: prefix
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: prefix + '-label'
  }, name), /*#__PURE__*/_react["default"].createElement("div", {
    className: prefix + '-numberWrap'
  }, /*#__PURE__*/_react["default"].createElement("span", {
    className: prefix + '-number',
    style: {
      marginRight: 20
    }
  }, value), /*#__PURE__*/_react["default"].createElement("span", {
    className: prefix + '-label',
    style: {
      marginRight: 8
    }
  }, "\u6628\u65E5"), /*#__PURE__*/_react["default"].createElement("span", {
    className: prefix + '-lastNumber',
    style: {
      marginRight: 4
    }
  }, ringValue), /*#__PURE__*/_react["default"].createElement("span", {
    className: prefix + '-label',
    style: {
      marginRight: 4
    }
  }, unit), /*#__PURE__*/_react["default"].createElement("span", {
    className: prefix + '-arrow',
    style: arrowStyle
  })));
};
var Chain = function Chain(_ref2) {
  var _ref2$id = _ref2.id,
    id = _ref2$id === void 0 ? '' : _ref2$id;
  var data = _api.BaseService.useCarCollectDay({
    carId: id,
    searchDay: (0, _dayjs["default"])().format('YYYY-MM-DD')
  });
  var yesterData = _api.BaseService.useCarCollectDay({
    carId: id,
    searchDay: (0, _dayjs["default"])().subtract(1, 'day').format('YYYY-MM-DD')
  });
  var collectOffsetPercentStr = data.collectOffsetPercentStr,
    collectSumWeight = data.collectSumWeight,
    terminalWeight = data.terminalWeight,
    completePercentByRestaurantStr = data.completePercentByRestaurantStr;
  var list = [{
    name: '收运量(t)',
    value: collectSumWeight,
    ringValue: yesterData.collectSumWeight
  }, {
    name: '进场量(t)',
    value: terminalWeight,
    ringValue: yesterData.terminalWeight
  }, {
    name: '收运偏差比',
    value: collectOffsetPercentStr,
    ringValue: yesterData === null || yesterData === void 0 ? void 0 : yesterData.collectOffsetPercentStr
  }, {
    name: '任务完成率',
    value: completePercentByRestaurantStr,
    ringValue: yesterData.completePercentByRestaurantStr
  }];
  return /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [8, 0]
  }, list.map(function (item, index) {
    return /*#__PURE__*/_react["default"].createElement(_antd.Col, {
      span: 12,
      key: index
    }, /*#__PURE__*/_react["default"].createElement(StatisticsItem, {
      item: item
    }));
  }));
};
var _default = exports["default"] = Chain;
//# sourceMappingURL=Chain.js.map
