"use strict";

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); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = Bottom;
var _react = _interopRequireWildcard(require("react"));
var _vmSubTabs = require("../../../vm-sub-tabs");
var _ahooks = require("ahooks");
var _moment = _interopRequireDefault(require("moment"));
var _api = require("../../api");
var _vmIframeModal = _interopRequireDefault(require("../../../vm-iframe-modal"));
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _components = require("@vtx/components");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, "default": e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
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(r) { if (Array.isArray(r)) return r; }
function Bottom(_ref) {
  var id = _ref.id,
    alarmTypeList = _ref.alarmTypeList,
    alarmType = _ref.alarmType,
    startDate = _ref.startDate,
    endDate = _ref.endDate;
  var _useSettings = (0, _useSettings2["default"])(),
    theme = _useSettings.theme;
  var _useSetState = (0, _ahooks.useSetState)({
      tabKey: 'parkingTimeout'
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var tabKey = state.tabKey;
  var _useSetState3 = (0, _ahooks.useSetState)({
      src: '',
      visible: false,
      title: ''
    }),
    _useSetState4 = _slicedToArray(_useSetState3, 2),
    iframeModalInfo = _useSetState4[0],
    setIframeModalInfo = _useSetState4[1];
  var columns_tccs = [['运输单位', 'transportUnitName', {
    width: 150,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text !== null && text !== void 0 ? text : '-'
      });
    }
  }], ['行政区划', 'divisionName', {
    width: 150
  }], ['报警开始时间', 'alarmStartTime', {
    width: 180
  }], ['报警结束时间', 'alarmEndTime', {
    width: 180
  }], ['停车时长', 'parkingDurationStr', {
    width: 180
  }], ['处置状态', 'processStatusChs', {
    width: 100,
    render: function render(text, record) {
      return text ? (/*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processStatus) ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['处置结果', 'processResultChs', {
    width: 120,
    render: function render(text, record) {
      return text ? (/*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processResult) == 'yx' ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['操作', 'action', {
    width: 60,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_react["default"].createElement("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)
          });
        }
      }, "\u67E5\u770B");
    }
  }]];
  var columns_lxpl = [['行政区划', 'divisionName', {
    width: 150
  }], ['运输起点', 'startingPointName', {
    width: 150,
    render: function render(text) {
      return text ? /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      }) : '-';
    }
  }], ['运输终点', 'endingPointName', {
    width: 150,
    render: function render(text) {
      return text ? /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      }) : '-';
    }
  }], ['报警开始时间', 'alarmStartTime', {
    width: 180
  }], ['报警结束时间', 'alarmEndTime', {
    width: 180
  }], ['处置状态', 'processStatusChs', {
    width: 150,
    render: function render(text, record) {
      return text ? (/*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processStatus) ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['处置结果', 'processResultChs', {
    width: 150,
    render: function render(text, record) {
      return text ? (/*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processResult) == 'yx' ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['操作', 'action', {
    width: 60,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_react["default"].createElement("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)
          });
        }
      }, "\u67E5\u770B");
    }
  }]];
  var columns_ylyc = [['运输单位', 'transportUnitName', {
    width: 180,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text !== null && text !== void 0 ? text : '-'
      });
    }
  }], ['行政区划', 'divisionName', {
    width: 150
  }], ['运输起点', 'ysqdName', {
    width: 180,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text !== null && text !== void 0 ? text : '-'
      });
    }
  }], ['运输终点', 'yszdName', {
    width: 180,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text !== null && text !== void 0 ? text : '-'
      });
    }
  }], ['建筑垃圾类别', '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__*/_react["default"].createElement("span", {
        style: {
          color: record.offset > 0 ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['处置状态', 'processStatusChs', {
    width: 150,
    render: function render(text, record) {
      return text ? (/*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processStatus) ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['处置结果', 'processResultChs', {
    width: 150,
    render: function render(text, record) {
      return text ? (/*#__PURE__*/_react["default"].createElement("span", {
        style: {
          color: (record === null || record === void 0 ? void 0 : record.processResult) == 'yx' ? '#52c41a' : '#f5222d'
        }
      }, text)) : '-';
    }
  }], ['操作', 'action', {
    width: 60,
    fixed: 'right',
    render: function render(_text, record) {
      return /*#__PURE__*/_react["default"].createElement("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)
          });
        }
      }, "\u67E5\u770B");
    }
  }]];
  var columns = (tabKey === 'parkingTimeout' ? columns_tccs : tabKey === 'routeDeviation' ? columns_lxpl : tabKey === 'transportAbnormal' ? columns_ylyc : columns_tccs).map(function (item) {
    return Object.assign({
      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' ? _api.AlarmService.page_tccs : tabKey === 'routeDeviation' ? _api.AlarmService.page_lxpl : tabKey === 'transportAbnormal' ? _api.AlarmService.page_ylyc : _api.AlarmService.page_tccs;
    if (!method) {
      return {
        total: 0,
        list: []
      };
    }
    return method({
      id: id,
      startTime: (0, _moment["default"])(startDate).format('YYYY-MM-DD 00:00:00'),
      endTime: (0, _moment["default"])(endDate).format('YYYY-MM-DD 23:59:59'),
      page: current - 1,
      size: pageSize
    }).then(function (res) {
      var _a, _b;
      return {
        total: ((_a = res === null || res === void 0 ? void 0 : res.data) === null || _a === void 0 ? void 0 : _a.total) || 0,
        list: ((_b = res === null || res === void 0 ? void 0 : res.data) === null || _b === void 0 ? void 0 : _b.rows) || []
      };
    });
  };
  var _useAntdTable = (0, _ahooks.useAntdTable)(getTableData, {
      defaultPageSize: 10
    }),
    tableProps = _useAntdTable.tableProps,
    search = _useAntdTable.search;
  var reset = search.reset;
  var myTableProps = Object.assign(Object.assign({}, tableProps), {
    rowKey: 'id',
    columns: columns,
    height: 350,
    indexFixed: true
  });
  (0, _react.useEffect)(function () {
    setState({
      tabKey: alarmType
    });
  }, [alarmType]);
  (0, _react.useEffect)(function () {
    reset();
  }, [tabKey, startDate, endDate]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: "jzlj-card-content"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTabs.SubTabsLine, {
    activeKey: tabKey,
    onChange: function onChange(e) {
      setState({
        tabKey: e
      });
    }
  }, alarmTypeList.filter(function (item) {
    return alarmType ? alarmType === item.value : true;
  }).map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(_vmSubTabs.SubTabPane, {
      tab: item.text,
      key: item.value
    });
  })), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], Object.assign({}, myTableProps)))), /*#__PURE__*/_react["default"].createElement(_vmIframeModal["default"], Object.assign({}, iframeModalInfo, {
    theme: theme,
    onCancel: function onCancel() {
      return setIframeModalInfo({
        visible: false
      });
    }
  })));
}
//# sourceMappingURL=Bottom.js.map
