"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"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _ahooks = require("ahooks");
var _moment = _interopRequireDefault(require("moment"));
var _antd = require("antd");
var _useSettings2 = _interopRequireDefault(require("../../../vm-hooks/useSettings"));
var _vmFilter = require("../../../vm-filter");
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _vmSubTabs = _interopRequireWildcard(require("../../../vm-sub-tabs"));
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _Charts = _interopRequireDefault(require("./Charts"));
var _TodayRun = _interopRequireDefault(require("./TodayRun"));
var _TodayWorkJXH = _interopRequireDefault(require("./TodayWorkJXH"));
var _TodayWorkLJSY = _interopRequireDefault(require("./TodayWorkLJSY"));
var _WorkSummary = _interopRequireDefault(require("./WorkSummary"));
var _WorkSummaryJxh = _interopRequireDefault(require("./WorkSummaryJxh"));
var _Wgfx = _interopRequireDefault(require("./Wgfx"));
var _ZyfxJXH = _interopRequireDefault(require("./ZyfxJXH"));
var _ZyfxLJSY = _interopRequireDefault(require("./ZyfxLJSY"));
var _api = require("../../api");
require("./index.less");
var _refresh = _interopRequireDefault(require("../../imgs/refresh.png"));
var _position = _interopRequireDefault(require("../../imgs/position.png"));
var _refresh_light = _interopRequireDefault(require("../../imgs/refresh_light.png"));
var _position_light = _interopRequireDefault(require("../../imgs/position_light.png"));
var _refresh_blue = _interopRequireDefault(require("../../imgs/refresh_blue.png"));
var _position_blue = _interopRequireDefault(require("../../imgs/position_blue.png"));
var _TodayWorkCC = _interopRequireDefault(require("./TodayWorkCC"));
var _ZyfxCC = _interopRequireDefault(require("./ZyfxCC"));
var _utils = require("@vtx/utils");
var _Chain = _interopRequireDefault(require("./Chain"));
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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); 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; }
var BaseInfo = function BaseInfo(props) {
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
  var id = props.id,
    baseInfo = props.baseInfo,
    info = props.info,
    service = props.service,
    showChain = props.showChain;
  var _useSettings = (0, _useSettings2["default"])(),
    _useSettings$theme = _useSettings.theme,
    theme = _useSettings$theme === void 0 ? 'light' : _useSettings$theme,
    startDate = _useSettings.startDate;
  var _useSetState = (0, _ahooks.useSetState)({
      baseActiveKey: '1',
      activeKey: '1',
      date: startDate ? (0, _moment["default"])(startDate) : (0, _moment["default"])().subtract(1, 'd'),
      subTabPanes: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var baseActiveKey = state.baseActiveKey,
    activeKey = state.activeKey,
    date = state.date;
  var noCarModalBaseLeftGif = (0, _utils.getUrlParam)('noCarModalBaseLeftGif');
  var _BaseService$useToday = _api.BaseService.useTodayRun(id, (0, _moment["default"])().format('YYYY-MM-DD'), (0, _moment["default"])().format('YYYY-MM-DD'), 'GPS'),
    todayRunRes = _BaseService$useToday.todayRunRes;
  var baseTabContent = /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      marginTop: '12px'
    }
  }, /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: baseInfo,
    gap: 18,
    horizontal: noCarModalBaseLeftGif || ((_a = info === null || info === void 0 ? void 0 : info.actionType) === null || _a === void 0 ? void 0 : _a.indexOf('ACTION_LJSY')) === -1,
    width: noCarModalBaseLeftGif || ((_b = info === null || info === void 0 ? void 0 : info.actionType) === null || _b === void 0 ? void 0 : _b.indexOf('ACTION_LJSY')) === -1 ? '50%' : '100%'
  }));
  var todayRun = /*#__PURE__*/_react["default"].createElement(_TodayRun["default"], {
    id: id,
    data: ((_c = todayRunRes === null || todayRunRes === void 0 ? void 0 : todayRunRes.alarmInfoGroupByType) === null || _c === void 0 ? void 0 : _c.items) || []
  });
  var wgfx = /*#__PURE__*/_react["default"].createElement(_Wgfx["default"], {
    data: ((_d = todayRunRes === null || todayRunRes === void 0 ? void 0 : todayRunRes.alarmGroupByType) === null || _d === void 0 ? void 0 : _d.items) || []
  });
  // 作业统计
  var workSummary = /*#__PURE__*/_react["default"].createElement(_WorkSummary["default"], {
    data: (todayRunRes === null || todayRunRes === void 0 ? void 0 : todayRunRes.alarmSum) || {}
  });
  var title = '违规分析'; // 右下角标题
  (0, _react.useEffect)(function () {
    var _a, _b, _c;
    var list = [];
    if (!(info === null || info === void 0 ? void 0 : info.actionType)) {
      return;
    }
    if (((_a = info === null || info === void 0 ? void 0 : info.actionType) === null || _a === void 0 ? void 0 : _a.indexOf('ACTION_JXH')) > -1) {
      workSummary = /*#__PURE__*/_react["default"].createElement(_WorkSummaryJxh["default"], {
        id: id,
        date: date,
        service: service
      });
      list = [{
        name: '今日作业',
        key: '1',
        content: /*#__PURE__*/_react["default"].createElement(_TodayWorkJXH["default"], {
          id: id,
          service: service
        })
      }, {
        name: '作业统计',
        key: '2',
        content: workSummary
      }];
    } else if (((_b = info === null || info === void 0 ? void 0 : info.actionType) === null || _b === void 0 ? void 0 : _b.indexOf('ACTION_LJSY')) > -1) {
      list = [{
        name: '今日作业',
        key: '1',
        content: /*#__PURE__*/_react["default"].createElement(_TodayWorkLJSY["default"], {
          id: id
        })
      }];
    } else if (((_c = info === null || info === void 0 ? void 0 : info.actionType) === null || _c === void 0 ? void 0 : _c.indexOf('ACTION_CC')) > -1) {
      list = [{
        name: '今日作业',
        key: '1',
        content: /*#__PURE__*/_react["default"].createElement(_TodayWorkCC["default"], {
          id: id
        })
      }];
    } else {
      list = [{
        name: '今日运行',
        key: '1',
        content: todayRun
      }, {
        name: '作业统计',
        key: '2',
        content: workSummary
      }];
    }
    setState({
      subTabPanes: list
    });
  }, [info === null || info === void 0 ? void 0 : info.actionType]);
  if (((_e = info === null || info === void 0 ? void 0 : info.actionType) === null || _e === void 0 ? void 0 : _e.indexOf('ACTION_JXH')) > -1) {
    wgfx = /*#__PURE__*/_react["default"].createElement(_ZyfxJXH["default"], {
      id: id,
      service: service
    });
    title = '作业分析';
  }
  if (((_f = info === null || info === void 0 ? void 0 : info.actionType) === null || _f === void 0 ? void 0 : _f.indexOf('ACTION_LJSY')) > -1) {
    wgfx = /*#__PURE__*/_react["default"].createElement(_ZyfxLJSY["default"], {
      id: id
    });
    title = '作业分析';
  }
  if (((_g = info === null || info === void 0 ? void 0 : info.actionType) === null || _g === void 0 ? void 0 : _g.indexOf('ACTION_CC')) > -1) {
    wgfx = /*#__PURE__*/_react["default"].createElement(_ZyfxCC["default"], {
      id: id
    });
    title = '作业分析';
  }
  // 基本信息
  var jbxx = /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    xxl: noCarModalBaseLeftGif || ((_h = info === null || info === void 0 ? void 0 : info.actionType) === null || _h === void 0 ? void 0 : _h.indexOf('ACTION_LJSY')) === -1 ? 24 : 10,
    xl: 24,
    lg: 24,
    md: 24
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-right-base",
    style: {
      height: noCarModalBaseLeftGif || ((_j = info === null || info === void 0 ? void 0 : info.actionType) === null || _j === void 0 ? void 0 : _j.indexOf('ACTION_LJSY')) === -1 ? 300 : 370
    }
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTabs["default"], {
    onChange: function onChange(key) {
      setState({
        baseActiveKey: key
      });
    },
    activeKey: baseActiveKey,
    ghost: "ghost"
  }, [{
    name: '基本信息',
    key: '1',
    content: baseTabContent
  }].map(function (ele) {
    return /*#__PURE__*/_react["default"].createElement(_vmSubTabs.SubTabPane, {
      subKey: ele.key,
      key: ele.key,
      tab: ele.name
    }, ele.content);
  }))));
  // 今日运行、作业统计
  var jryxZytj = /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    xxl: noCarModalBaseLeftGif || ((_k = info === null || info === void 0 ? void 0 : info.actionType) === null || _k === void 0 ? void 0 : _k.indexOf('ACTION_LJSY')) === -1 ? 24 : 14,
    xl: 24,
    lg: 24,
    md: 24
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-right-right"
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTabs["default"], {
    ghost: "ghost",
    onChange: function onChange(key) {
      setState({
        activeKey: key
      });
    },
    tabBarExtraContent: ((_l = info === null || info === void 0 ? void 0 : info.actionType) === null || _l === void 0 ? void 0 : _l.indexOf('ACTION_JXH')) > -1 && activeKey === '2' ? (/*#__PURE__*/_react["default"].createElement(_vmFilter.VMDatePicker, {
      value: date,
      onChange: function onChange(date) {
        setState({
          date: date
        });
      }
    })) : null,
    activeKey: activeKey
  }, state.subTabPanes.map(function (ele) {
    return /*#__PURE__*/_react["default"].createElement(_vmSubTabs.SubTabPane, {
      key: ele.key,
      subKey: ele.key,
      tab: ele.name
    }, ele.content);
  }))));
  var icons = {
    refresh: {
      light: _refresh_light["default"],
      dark: _refresh["default"],
      blue: _refresh_blue["default"]
    },
    position: {
      light: _position_light["default"],
      dark: _position["default"],
      blue: _position_blue["default"]
    }
  };
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base ".concat(theme)
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [10, 10],
    style: {
      height: '100%',
      width: 481
    }
  }, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-left",
    style: {
      height: noCarModalBaseLeftGif || ((_m = info === null || info === void 0 ? void 0 : info.actionType) === null || _m === void 0 ? void 0 : _m.indexOf('ACTION_LJSY')) === -1 ? 300 : 693
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-left--text"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: icons['refresh'][theme]
  }), (info === null || info === void 0 ? void 0 : info.equipmentTime) || '-'), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-left--text"
  }, /*#__PURE__*/_react["default"].createElement("img", {
    src: icons['position'][theme]
  }), (info === null || info === void 0 ? void 0 : info.address) || '-'), noCarModalBaseLeftGif || ((_o = info === null || info === void 0 ? void 0 : info.actionType) === null || _o === void 0 ? void 0 : _o.indexOf('ACTION_LJSY')) === -1 ? null : (/*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-left--online"
  }, info === null || info === void 0 ? void 0 : info.carStatusStr)), noCarModalBaseLeftGif || ((_p = info === null || info === void 0 ? void 0 : info.actionType) === null || _p === void 0 ? void 0 : _p.indexOf('ACTION_LJSY')) === -1 ? null : (/*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-left--gif"
  })), /*#__PURE__*/_react["default"].createElement(_Charts["default"], Object.assign({}, info, {
    date: (0, _moment["default"])(date).format('YYYY-MM-DD'),
    isRow: ((_q = info === null || info === void 0 ? void 0 : info.actionType) === null || _q === void 0 ? void 0 : _q.indexOf('ACTION_LJSY')) === -1,
    hasJXH: ((_r = info === null || info === void 0 ? void 0 : info.actionType) === null || _r === void 0 ? void 0 : _r.indexOf('ACTION_JXH')) > -1,
    service: service
  })), showChain && (/*#__PURE__*/_react["default"].createElement("div", {
    style: {
      marginTop: '12px'
    }
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTabs["default"], {
    ghost: "ghost",
    activeKey: '1'
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTabs.SubTabPane, {
    tab: '环比模型',
    subKey: '1',
    key: '1'
  }, /*#__PURE__*/_react["default"].createElement(_Chain["default"], {
    id: id
  }))))))), noCarModalBaseLeftGif || ((_s = info === null || info === void 0 ? void 0 : info.actionType) === null || _s === void 0 ? void 0 : _s.indexOf('ACTION_LJSY')) === -1 ? (/*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, jryxZytj)) : null), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-base-right"
  }, /*#__PURE__*/_react["default"].createElement(_antd.Row, {
    gutter: [10, 10]
  }, jbxx, noCarModalBaseLeftGif || ((_t = info === null || info === void 0 ? void 0 : info.actionType) === null || _t === void 0 ? void 0 : _t.indexOf('ACTION_LJSY')) === -1 ? null : jryxZytj, /*#__PURE__*/_react["default"].createElement(_antd.Col, {
    span: 24
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-wgfx",
    style: {
      height: noCarModalBaseLeftGif || ((_u = info === null || info === void 0 ? void 0 : info.actionType) === null || _u === void 0 ? void 0 : _u.indexOf('ACTION_LJSY')) === -1 ? 370 : 313
    }
  }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: title
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: "car-wgfx-content"
  }, wgfx))))));
};
var _default = exports["default"] = BaseInfo;
//# sourceMappingURL=index.js.map
