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); }
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
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 { useAntdTable } from 'ahooks';
import dayjs from 'dayjs';
import { useEffect, useState } from 'react';
import { VmFilter, VmTable, VmWrapper } from "../../../../_components";
import { JzljService } from "../../../api";
import { jsx as _jsx } from "react/jsx-runtime";
export default function Bottom(_ref) {
  var id = _ref.id,
    alarmTypeList = _ref.alarmTypeList,
    alarmType = _ref.alarmType,
    startDate = _ref.startDate,
    endDate = _ref.endDate,
    setIframeModalInfo = _ref.setIframeModalInfo;
  var _useState = useState(alarmType),
    _useState2 = _slicedToArray(_useState, 2),
    tabKey = _useState2[0],
    setTabKey = _useState2[1];
  useEffect(function () {
    if (alarmType === 'all') {
      setTabKey('parkingTimeout');
    } else {
      setTabKey(alarmType);
    }
  }, [alarmType]);
  useEffect(function () {
    submit();
  }, [tabKey, startDate, endDate]);
  var columns_tccs = [['运输单位', 'transportUnitName', {
    width: 150,
    ellipsis: true
  }], ['行政区划', 'divisionName', {
    width: 150
  }], ['报警开始时间', 'alarmStartTime', {
    width: 180
  }], ['报警结束时间', 'alarmEndTime', {
    width: 180
  }], ['停车时长', 'parkingDurationStr', {
    width: 180
  }], ['处置状态', 'processStatusChs', {
    width: 100,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: record !== null && record !== void 0 && record.processStatus ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['处置结果', 'processResultChs', {
    width: 120,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processResult) == 'yx' ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['操作', 'action', {
    width: 60,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_jsx("a", {
        onClick: function onClick() {
          setIframeModalInfo({
            visible: true,
            title: '停车超时',
            src: "/jzlj/#/intelligentWarmAnalysis?activeKey=OverTime&id=".concat(record.id, "&carId=").concat(record.carId, "&startTime=").concat(record.alarmStartTime, "&endTime=").concat(record.alarmEndTime)
          });
        },
        children: "\u67E5\u770B"
      });
    }
  }]];
  var columns_lxpl = [['行政区划', 'divisionName', {
    width: 150
  }], ['运输起点', 'startingPointName', {
    width: 150,
    ellipsis: true
  }], ['运输终点', 'endingPointName', {
    width: 150,
    ellipsis: true
  }], ['报警开始时间', 'alarmStartTime', {
    width: 160
  }], ['报警结束时间', 'alarmEndTime', {
    width: 160
  }], ['处置状态', 'processStatusChs', {
    width: 100,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: record !== null && record !== void 0 && record.processStatus ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['处置结果', 'processResultChs', {
    width: 120,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processResult) == 'yx' ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['操作', 'action', {
    width: 60,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_jsx("a", {
        onClick: function onClick() {
          setIframeModalInfo({
            visible: true,
            title: '路线偏移',
            src: "/jzlj/#/intelligentWarmAnalysis?activeKey=RouteDeviation&id=".concat(record.id, "&carId=").concat(record.carId, "&startTime=").concat(record.alarmStartTime, "&endTime=").concat(record.alarmEndTime)
          });
        },
        children: "\u67E5\u770B"
      });
    }
  }]];
  var columns_ylyc = [['运输单位', 'transportUnitName', {
    width: 180,
    ellipsis: true
  }], ['行政区划', 'divisionName', {
    width: 150
  }], ['运输起点', 'ysqdName', {
    width: 180,
    ellipsis: true
  }], ['运输终点', 'yszdName', {
    width: 180,
    ellipsis: true
  }], ['建筑垃圾类别', 'rubbishTypeChs', {
    width: 150
  }], ['核准有效期', 'effectiveDateRange', {
    width: 200
  }], ['报警生成时间', 'createTime', {
    width: 200
  }], ['核准量(吨)', 'declareTransportWeight', {
    width: 130,
    align: 'right',
    sorter: true
  }], ['实际运量(吨)', 'actualTransportWeight', {
    width: 130,
    align: 'right',
    sorter: true
  }], ['偏差比', 'offsetStr', {
    width: 180,
    align: 'right',
    sorter: true,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: record.offset > 0 ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['处置状态', 'processStatusChs', {
    width: 100,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: record !== null && record !== void 0 && record.processStatus ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['处置结果', 'processResultChs', {
    width: 120,
    render: function render(text, record) {
      return text ? /*#__PURE__*/_jsx("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processResult) == 'yx' ? '#52c41a' : '#f5222d'
        },
        children: text
      }) : '-';
    }
  }], ['操作', 'action', {
    width: 60,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_jsx("a", {
        onClick: function onClick() {
          setIframeModalInfo({
            visible: true,
            title: '运量异常',
            src: "/jzlj/#/intelligentWarmAnalysis?activeKey=TransparentAlarm&id=".concat(record.id, "&carId=").concat(record.carId, "&startTime=").concat(record.alarmStartTime, "&endTime=").concat(record.alarmEndTime)
          });
        },
        children: "\u67E5\u770B"
      });
    }
  }]];
  var columns = (tabKey === 'parkingTimeout' ? columns_tccs : tabKey === 'routeDeviation' ? columns_lxpl : tabKey === 'transportAbnormal' ? columns_ylyc : columns_tccs).map(function (item) {
    return _objectSpread({
      title: item[0],
      dataIndex: item[1],
      key: item[1]
    }, item[2]);
  });
  var getTableData = function getTableData(_ref2) {
    var current = _ref2.current,
      pageSize = _ref2.pageSize;
    var method = tabKey === 'parkingTimeout' ? JzljService.page_tccs : tabKey === 'routeDeviation' ? JzljService.page_lxpl : JzljService.page_tccs;
    if (!method) {
      return {
        total: 0,
        list: []
      };
    }
    return method({
      id: id,
      startTime: dayjs(startDate).format('YYYY-MM-DD 00:00:00'),
      endTime: dayjs(endDate).format('YYYY-MM-DD 23:59:59'),
      page: current - 1,
      //   size: pageSize,
      size: 9999
    }).then(function (res) {
      var _res$data, _res$data2;
      return {
        total: (res === null || res === void 0 || (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.total) || 0,
        list: (res === null || res === void 0 || (_res$data2 = res.data) === null || _res$data2 === void 0 ? void 0 : _res$data2.rows) || []
      };
    });
  };
  var _useAntdTable = useAntdTable(getTableData, {
      defaultPageSize: 10
    }),
    tableProps = _useAntdTable.tableProps,
    search = _useAntdTable.search;
  var submit = search.submit,
    reset = search.reset;
  var myTableProps = _objectSpread(_objectSpread({}, tableProps), {}, {
    rowKey: 'id',
    columns: columns,
    indexFixed: true,
    pagination: false
  });
  return /*#__PURE__*/_jsx(VmWrapper, {
    title: "\u62A5\u8B66\u660E\u7EC6",
    extraLeft: /*#__PURE__*/_jsx(VmFilter.VMSelect, {
      options: alarmTypeList.filter(function (item) {
        return item.value !== 'all';
      }).map(function (item) {
        return {
          value: item.value,
          label: item.text
        };
      }),
      style: {
        width: 120
      },
      placeholder: "\u62A5\u8B66\u7C7B\u578B",
      value: tabKey,
      allowClear: false,
      onChange: function onChange(val) {
        setTabKey(val);
      }
    }),
    children: /*#__PURE__*/_jsx(VmTable, _objectSpread({}, myTableProps))
  });
}