function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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 { Select } from 'antd';
import dayjs from 'dayjs';
import { useEffect, useState } from 'react';
import { VmWrapper } from "../../../_components";
import { getViolateBehavior } from "../../api";
import { filterCode } from "../../config";
import WGXWContent from "./Content";
import "./index.less";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
var Option = Select.Option;
var WGXW = function WGXW(_ref) {
  var _ref$classPrefix = _ref.classPrefix,
    classPrefix = _ref$classPrefix === void 0 ? '' : _ref$classPrefix,
    id = _ref.id,
    _ref$throwPoints = _ref.throwPoints,
    throwPoints = _ref$throwPoints === void 0 ? [] : _ref$throwPoints,
    serviceList = _ref.serviceList;
  var prefix = "".concat(classPrefix, "-wgxw");
  var _useState = useState('all'),
    _useState2 = _slicedToArray(_useState, 2),
    tab = _useState2[0],
    setTab = _useState2[1];
  var _useState3 = useState([dayjs(), dayjs()]),
    _useState4 = _slicedToArray(_useState3, 2),
    times = _useState4[0],
    setTimes = _useState4[1];
  // 违规行为
  var _useState5 = useState('all'),
    _useState6 = _slicedToArray(_useState5, 2),
    throwAberrantCode = _useState6[0],
    setThrowAberrantCode = _useState6[1];
  // 违规行为
  var _useState7 = useState([]),
    _useState8 = _slicedToArray(_useState7, 2),
    throwAberrantList = _useState8[0],
    setThrowAberrantList = _useState8[1];
  useEffect(function () {
    getViolateBehavior().then(function (data) {
      setThrowAberrantList([{
        text: '全部',
        value: 'all'
      }].concat(_toConsumableArray(data || [])));
    });
  }, []);
  var onTabChange = function onTabChange(tab) {
    setTab(tab);
  };
  var searchContent = /*#__PURE__*/_jsxs("div", {
    style: {
      textAlign: 'right',
      paddingRight: 10
    },
    className: "searchContent ",
    children: [/*#__PURE__*/_jsx("span", {
      style: {
        color: '#B3C4CE'
      },
      children: " \u8FDD\u89C4\u884C\u4E3A\uFF1A"
    }), /*#__PURE__*/_jsx(Select, {
      value: throwAberrantCode,
      onChange: function onChange(value) {
        return setThrowAberrantCode(value);
      },
      style: {
        width: 120
      },
      children: throwAberrantList.map(function (item) {
        return /*#__PURE__*/_jsx(Option, {
          children: item.text
        }, item.value);
      })
    })]
  });
  return /*#__PURE__*/_jsx("div", {
    className: prefix,
    children: /*#__PURE__*/_jsxs(VmWrapper, {
      tabList: [{
        label: '所有投放点',
        key: 'all'
      }].concat(throwPoints === null || throwPoints === void 0 ? void 0 : throwPoints.map(function (ele) {
        return {
          label: ele.pointName,
          key: ele.id
        };
      })),
      activeKey: tab,
      onChangeTab: onTabChange,
      filterType: "rangePicker",
      dateValue: times,
      filterChange: function filterChange(date) {
        setTimes(date);
      },
      children: [tab === 'all' && /*#__PURE__*/_jsx(WGXWContent, {
        classPrefix: prefix,
        id: id,
        throwAberrantCode: throwAberrantCode,
        startTime: times[0].format('YYYY-MM-DD 00:00:00'),
        endTime: times[1].format('YYYY-MM-DD 23:59:59'),
        throwPointId: ""
      }), tab !== 'all' && filterCode(serviceList, ['CHUYU_QUALITY', 'LANDING', 'ON_LID', 'QITA_QUALITY']) && /*#__PURE__*/_jsx(WGXWContent, {
        classPrefix: prefix,
        id: id,
        throwAberrantCode: throwAberrantCode,
        startTime: times[0].format('YYYY-MM-DD 00:00:00'),
        endTime: times[1].format('YYYY-MM-DD 23:59:59'),
        throwPointId: tab
      })]
    })
  });
};
export default WGXW;