"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 _vtxBaseModal = _interopRequireDefault(require("../vtx-base-modal"));
var _components = require("./components");
var _vmVideo = _interopRequireDefault(require("../vm-video"));
var _api = require("./api");
var _api2 = _interopRequireDefault(require("../vm-video/api"));
require("../style");
var _lodash = _interopRequireDefault(require("lodash"));
var _utils = require("@vtx/utils");
var _QdBaseInfo = _interopRequireDefault(require("./components/QdBaseInfo"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : 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(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 TABS_BASE = 'car-base';
var TABS_DETAIL = 'car-detail';
var TABS_ALARM = 'car-alarm';
var TABS_COLLECTION = 'car-collection';
var TABS_STATIC = 'car-static';
var TABS_WATER = 'car-water';
var TABS_OIL = 'car-oil';
var TABS_MAINTENANCE = 'car-maintenance';
var TABS_WORK = 'car-work';
var TABS_VIDEO = 'car-video';
// 青岛定制
var TABS_QD_BASE = 'car-qd-base';
var VtxCarModal = function VtxCarModal(props) {
  var _contents;
  var _a, _b, _c, _d;
  var id = props.id,
    title = props.title,
    theme = props.theme,
    visible = props.visible,
    onCancel = props.onCancel,
    source = props.source,
    startDate = props.startDate,
    endDate = props.endDate,
    onTdClick = props.onTdClick,
    _props$tabChose = props.tabChose,
    tabChose = _props$tabChose === void 0 ? '' : _props$tabChose,
    showCollection = props.showCollection,
    _props$showChain = props.showChain,
    showChain = _props$showChain === void 0 ? false : _props$showChain,
    _props$showCollect = props.showCollect,
    showCollect = _props$showCollect === void 0 ? true : _props$showCollect,
    _props$frameParams = props.frameParams,
    frameParams = _props$frameParams === void 0 ? {} : _props$frameParams;
  var _useState = (0, _react.useState)(''),
    _useState2 = _slicedToArray(_useState, 2),
    service = _useState2[0],
    setService = _useState2[1];
  var _useState3 = (0, _react.useState)([]),
    _useState4 = _slicedToArray(_useState3, 2),
    tabsC = _useState4[0],
    setTabsC = _useState4[1];
  var _useState5 = (0, _react.useState)(''),
    _useState6 = _slicedToArray(_useState5, 2),
    tabChoseC = _useState6[0],
    setTabChoseC = _useState6[1];
  var _ConfigService$useCon = _api.ConfigService.useConfig(),
    data = _ConfigService$useCon.data;
  var _BaseService$useField = _api.BaseService.useFieldConfig(),
    showFields = _BaseService$useField.showFields;
  var _BaseService$useBaseI = _api.BaseService.useBaseInfo(id),
    baseInfo = _BaseService$useBaseI.baseInfo,
    info = _BaseService$useBaseI.info,
    tabConfig = _BaseService$useBaseI.tabConfig;
  var _VideoService$getChan = _api2["default"].getChannels(info === null || info === void 0 ? void 0 : info.carCode, !!(info === null || info === void 0 ? void 0 : info.carCode)),
    channels = _VideoService$getChan.channels;
  var _OilService$useHasOil = _api.OilService.useHasOil(id),
    beenOilStatus = _OilService$useHasOil.beenOilStatus;
  (0, _react.useEffect)(function () {
    if (data === null || data === void 0 ? void 0 : data.id) {
      setService('zyqs-zqb');
    }
  }, [data]);
  var tabs = [{
    key: TABS_BASE,
    title: '总览信息'
  }, {
    key: TABS_DETAIL,
    title: '详细信息'
  }
  // { key: TABS_ALARM, title: '报警信息' },
  // { key: TABS_STATIC, title: '统计信息' },
  // { key: TABS_WATER, title: '水耗信息' },
  // { key: TABS_OIL, title: '油耗信息' },
  // { key: TABS_VIDEO, title: '视频信息' },
  // { key: TABS_MAINTENANCE, title: '维保信息' },
  ];
  if (showCollection) {
    tabs.splice(2, 0, {
      key: TABS_COLLECTION,
      title: '收运信息'
    });
  }
  if (((_a = info === null || info === void 0 ? void 0 : info.actionType) === null || _a === void 0 ? void 0 : _a.indexOf('ACTION_LJSY')) > -1 || ((_b = info === null || info === void 0 ? void 0 : info.actionType) === null || _b === void 0 ? void 0 : _b.indexOf('ACTION_JXH')) > -1) {
    tabs = tabs.concat([{
      key: TABS_WORK,
      title: '作业信息'
    }]);
  }
  if ((_c = info === null || info === void 0 ? void 0 : info.actionType) === null || _c === void 0 ? void 0 : _c.includes('ACTION_CC')) {
    _lodash["default"].pullAllBy(tabs, [{
      key: TABS_WATER
    }], 'key');
  }
  var subTitle = ((_d = info === null || info === void 0 ? void 0 : info.actionType) === null || _d === void 0 ? void 0 : _d.indexOf('ACTION_LJSY')) > -1 ? info === null || info === void 0 ? void 0 : info.productTypeName : info === null || info === void 0 ? void 0 : info.carClassName;
  (0, _react.useEffect)(function () {
    if (tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.length) {
      var list = tabConfig;
      if (tabConfig.findIndex(function (ele) {
        return ele.key === 'car-video';
      }) > -1 && (channels === null || channels === void 0 ? void 0 : channels.length) < 1) {
        list = tabConfig.filter(function (ele) {
          return ele.key !== 'car-video';
        });
      }
      if (tabConfig.findIndex(function (ele) {
        return ele.key === 'car-oil';
      }) > -1 && !beenOilStatus) {
        list = list.filter(function (ele) {
          return ele.key !== 'car-oil';
        });
      }
      setTabsC(list);
    } else {
      setTabsC(tabs);
    }
  }, [JSON.stringify(tabConfig), beenOilStatus, JSON.stringify(channels)]);
  (0, _react.useEffect)(function () {
    if ((tabConfig === null || tabConfig === void 0 ? void 0 : tabConfig.length) > 0 && tabChose) {
      setTabChoseC(tabChose);
    }
  }, [JSON.stringify(tabConfig), tabChose]);
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, visible && (/*#__PURE__*/_react["default"].createElement(_vtxBaseModal["default"], {
    title: title,
    subTitle: /*#__PURE__*/_react["default"].createElement("span", {
      className: "car-subtitle"
    }, /*#__PURE__*/_react["default"].createElement("span", null, subTitle ? "(".concat(subTitle, ")") : ''), (0, _utils.getUrlParam)('noCarModalBaseLeftGif') ? (/*#__PURE__*/_react["default"].createElement("div", {
      className: "car-base-left--online",
      style: {
        marginLeft: 10
      }
    }, info === null || info === void 0 ? void 0 : info.carStatusStr)) : null),
    id: id,
    type: "car",
    source: source,
    theme: theme,
    visible: visible,
    onCancel: onCancel,
    tabs: tabsC,
    tabChose: tabChoseC,
    startDate: startDate,
    endDate: endDate,
    showCollect: showCollect,
    frameParams: frameParams,
    contents: (_contents = {}, _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_contents, TABS_BASE, /*#__PURE__*/_react["default"].createElement(_components.BaseInfo, {
      id: id,
      baseInfo: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.filter(function (ele) {
        return ele.key !== 'bidSectionName' || ele.key === 'bidSectionName' && showFields.map(function (item) {
          return item.dataKey;
        }).includes('bidSectionName');
      }),
      info: info,
      service: (props === null || props === void 0 ? void 0 : props.service) || service,
      showChain: showChain
    })), TABS_QD_BASE, /*#__PURE__*/_react["default"].createElement(_QdBaseInfo["default"], {
      id: id,
      baseInfo: baseInfo === null || baseInfo === void 0 ? void 0 : baseInfo.filter(function (ele) {
        return ele.key !== 'bidSectionName' || ele.key === 'bidSectionName' && showFields.map(function (item) {
          return item.dataKey;
        }).includes('bidSectionName');
      }),
      info: info,
      service: (props === null || props === void 0 ? void 0 : props.service) || service,
      showChain: showChain
    })), TABS_DETAIL, /*#__PURE__*/_react["default"].createElement(_components.DetailInfo, {
      id: id,
      actionType: info === null || info === void 0 ? void 0 : info.actionType,
      showFields: showFields
    })), TABS_ALARM, /*#__PURE__*/_react["default"].createElement(_components.CarAlarmInfo, {
      id: id,
      carCode: info === null || info === void 0 ? void 0 : info.carCode,
      actionType: info === null || info === void 0 ? void 0 : info.actionType
    })), TABS_COLLECTION, /*#__PURE__*/_react["default"].createElement(_components.Collection, {
      id: id,
      carCode: info === null || info === void 0 ? void 0 : info.carCode
    })), TABS_STATIC, /*#__PURE__*/_react["default"].createElement(_components.StaticInfo, {
      id: id,
      onTdClick: onTdClick,
      onCancel: onCancel
    })), TABS_WATER, /*#__PURE__*/_react["default"].createElement(_components.WaterConsumption, {
      id: id
    })), TABS_OIL, /*#__PURE__*/_react["default"].createElement(_components.OilConsumption, {
      id: id
    })), TABS_MAINTENANCE, /*#__PURE__*/_react["default"].createElement(_components.Maintenance, {
      id: id
    })), TABS_WORK, /*#__PURE__*/_react["default"].createElement(_components.WorkInfo, {
      id: id,
      actionType: (info === null || info === void 0 ? void 0 : info.actionType) || '',
      service: (props === null || props === void 0 ? void 0 : props.service) || service
    })), _defineProperty(_contents, TABS_VIDEO, /*#__PURE__*/_react["default"].createElement(_vmVideo["default"], {
      videoPlaceCode: info === null || info === void 0 ? void 0 : info.carCode
    })))
  })));
};
var _default = exports["default"] = VtxCarModal;
//# sourceMappingURL=index.js.map
