import { VtxImage } from '@vtx/components';
import { getVtxToken } from '@vtx/utils';
import { Spin } from 'antd';
import { VmEmpty, VmTag } from "../../../_components";
import useSettings from "../../../_hooks/useSettings";
import { throwFailBehaviorService } from "../../api";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
var WGGSContent = function WGGSContent(_ref) {
  var _data$map;
  var _ref$classPrefix = _ref.classPrefix,
    classPrefix = _ref$classPrefix === void 0 ? '' : _ref$classPrefix,
    id = _ref.id,
    throwAberrantCode = _ref.throwAberrantCode,
    startTime = _ref.startTime,
    endTime = _ref.endTime;
  var _useSettings = useSettings(),
    isDark = _useSettings.isDark;
  var _throwFailBehaviorSer = throwFailBehaviorService.useGetList({
      throwPointId: id,
      startDatetime: startTime,
      endDatetime: endTime,
      throwAberrantCode: throwAberrantCode === 'all' ? '' : throwAberrantCode
    }),
    data = _throwFailBehaviorSer.data,
    loading = _throwFailBehaviorSer.loading;
  var ThrowAberrantEnum = {
    MIXED_THROW: '#26A666',
    TRASH_BAG: '#F9667E',
    WRONG_TIME_OUT: '#7470F9',
    RIGHT_TIME_OUT: '#FFAA00',
    QITA_MIXED_THROW: '#479DE3',
    ON_LID: '#FFAA00'
  };
  var RectificationStatusEnum = {
    TO_BE_DISPATCHED: 'yellow',
    // '待派发',
    TO_BE_RESOLVED: 'gray',
    // '待处理',
    TO_BE_AUDITED: 'yellow',
    // '待审核',
    PASSED: 'green',
    // '整改通过',
    FAILED: 'red',
    // '整改不通过',
    IGNORED: 'blue' // '已忽略',
  };

  //   const ThrowAberrantColor = {
  //     '#7470F9': 'purple',
  //     '#F9667E': 'red',
  //     '#FFAA00': 'yellow',
  //     '#26A666': 'green',
  //     '#479DE3': 'cyan',
  //   };

  return !(data !== null && data !== void 0 && data.length) && !loading ? /*#__PURE__*/_jsx("div", {
    style: {
      height: 500
    },
    children: /*#__PURE__*/_jsx(VmEmpty, {})
  }) : /*#__PURE__*/_jsxs(_Fragment, {
    children: [/*#__PURE__*/_jsx(Spin, {
      spinning: loading,
      className: "".concat(classPrefix, "-content-spin")
    }), /*#__PURE__*/_jsx("div", {
      className: "".concat(classPrefix, "-content ").concat(isDark ? 'dark' : ''),
      children: data === null || data === void 0 || (_data$map = data.map) === null || _data$map === void 0 ? void 0 : _data$map.call(data, function (item) {
        var _JSON$parse$, _tempDetectObjects$fi;
        var photoId = (_JSON$parse$ = JSON.parse(item.photoAfter || '[]')[0]) === null || _JSON$parse$ === void 0 ? void 0 : _JSON$parse$.id;
        var tempDetectObjects = JSON.parse(item.detectObjects || '[]');
        var photoAfterArr = (_tempDetectObjects$fi = tempDetectObjects.find(function (item) {
          return item.pic === 'dropPic2';
        })) === null || _tempDetectObjects$fi === void 0 ? void 0 : _tempDetectObjects$fi.info;
        var str = "/cloud/sdyd/markBox?fileId=".concat(photoId, "&detectObjects=").concat(photoAfterArr ? JSON.stringify(photoAfterArr) : '', "&token=").concat(getVtxToken('token'));
        return /*#__PURE__*/_jsxs("div", {
          className: "".concat(classPrefix, "-content-item"),
          children: [/*#__PURE__*/_jsx("div", {
            className: "".concat(classPrefix, "-content-item-img"),
            children: /*#__PURE__*/_jsx(VtxImage, {
              src: str
            })
          }), /*#__PURE__*/_jsxs("p", {
            children: [/*#__PURE__*/_jsxs("div", {
              className: "".concat(classPrefix, "-content-item-info1"),
              children: [/*#__PURE__*/_jsx("span", {
                children: item.throwPointName
              }), /*#__PURE__*/_jsx("span", {
                className: "".concat(classPrefix, "-content-item-").concat(item.rectificationStatus),
                children: /*#__PURE__*/_jsx(VmTag, {
                  title: item.rectificationStatusDesc,
                  type: RectificationStatusEnum[item.rectificationStatus] || 'yellow'
                })
              })]
            }), /*#__PURE__*/_jsxs("div", {
              className: "".concat(classPrefix, "-content-item-info2"),
              children: [/*#__PURE__*/_jsx("span", {
                children: item.datetime
              }), /*#__PURE__*/_jsx("div", {
                style: {
                  color: ThrowAberrantEnum[item.aberrantCode]
                },
                children: item.aberrantName
              })]
            }), /*#__PURE__*/_jsxs("div", {
              className: "".concat(classPrefix, "-content-item-info3"),
              children: [/*#__PURE__*/_jsx("img", {
                src: require("../../imgs/avatar".concat(isDark ? '' : '_light', ".png"))
              }), item.personName || '暂无关联用户']
            })]
          })]
        }, item.id);
      })
    })]
  });
};
export default WGGSContent;