"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;

var _react = _interopRequireWildcard(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _base = _interopRequireDefault(require("./base"));

require("./style");

var _api = require("./api");

var _bottleList = _interopRequireDefault(require("./bottleList"));

var _siteList = _interopRequireDefault(require("./siteList"));

var _userList = _interopRequireDefault(require("./userList"));

var _vmGasModal = _interopRequireDefault(require("../vm-gas-modal"));

var _useModal2 = _interopRequireDefault(require("../vm-hooks/useModal"));

var _staffList = _interopRequireDefault(require("../staff-list"));

var _utils = require("@vtx/utils");

var _excluded = ["id"],
    _excluded2 = ["showModal"];

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

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(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }

function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var TABS_BASE = 'gas-enterprise-base';
var TABS_STAFF = 'gas-enterprise-staff';
var TABS_CZ = 'gas-enterprise-cz';
var TABS_CPZ = 'gas-enterprise-cpz';
var TABS_GYZ = 'gas-enterprise-gyz';
var TABS_USER = 'gas-enterprise-user';
var TABS_BOTTLE = 'gas-enterprise-bottle';

var Modal = function Modal(_ref) {
  var id = _ref.id,
      resetProps = _objectWithoutProperties(_ref, _excluded);

  var _useState = (0, _react.useState)(false),
      _useState2 = _slicedToArray(_useState, 2),
      isShowBottle = _useState2[0],
      setIsShowBottle = _useState2[1];

  var _useState3 = (0, _react.useState)({}),
      _useState4 = _slicedToArray(_useState3, 2),
      info = _useState4[0],
      setInfo = _useState4[1];

  (0, _react.useEffect)(function () {
    if (id) {
      (0, _api.getInfo)(id).then(function (data) {
        var _data$companyType;

        if ((_data$companyType = data.companyType) !== null && _data$companyType !== void 0 && _data$companyType.includes('pzq')) {
          setIsShowBottle(true);
        }

        setInfo(data);
      });
    }
  }, [id]);
  var tabs = [{
    value: '企业信息',
    key: TABS_BASE,
    content: /*#__PURE__*/_react["default"].createElement(_base["default"], {
      info: info
    })
  }, {
    value: '从业人员档案',
    key: TABS_STAFF,
    content: /*#__PURE__*/_react["default"].createElement(_staffList["default"], {
      param: {
        companyId: id
      },
      isShowSupplyStation: true
    })
  }, {
    value: '场站档案',
    key: TABS_CZ,
    content: /*#__PURE__*/_react["default"].createElement(_siteList["default"], {
      id: id,
      code: "gas_cz"
    })
  }, {
    value: '储配站档案',
    key: TABS_CPZ,
    content: /*#__PURE__*/_react["default"].createElement(_siteList["default"], {
      id: id,
      code: "gas_cpz"
    })
  }, {
    value: '供应站档案',
    key: TABS_GYZ,
    content: /*#__PURE__*/_react["default"].createElement(_siteList["default"], {
      id: id,
      code: "gas_gyz"
    })
  }, {
    value: '用户档案',
    key: TABS_USER,
    content: /*#__PURE__*/_react["default"].createElement(_userList["default"], {
      id: id
    })
  }];

  if ((0, _utils.getUrlParam)().carqFlag == 'true') {
    tabs.splice(3, 2);
  }

  if (isShowBottle) {
    tabs.splice(1, 0, {
      value: '气瓶档案',
      key: TABS_BOTTLE,
      content: /*#__PURE__*/_react["default"].createElement(_bottleList["default"], {
        id: id
      })
    });
  }

  return /*#__PURE__*/_react["default"].createElement(_vmGasModal["default"], _extends({
    tabs: tabs,
    title: "\u71C3\u6C14\u4F01\u4E1A"
  }, resetProps));
};

var VtxGasEnterpriseModal = function VtxGasEnterpriseModal(props) {
  var label = props.label,
      id = props.id;

  var _useModal = (0, _useModal2["default"])(),
      showModal = _useModal.showModal,
      modalProps = _objectWithoutProperties(_useModal, _excluded2);

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, label ? /*#__PURE__*/_react["default"].createElement("a", {
    type: "link",
    onClick: showModal
  }, label) : /*#__PURE__*/_react["default"].createElement("span", null, "-"), modalProps.visible && /*#__PURE__*/_react["default"].createElement(Modal, _extends({
    id: id
  }, modalProps)));
};

Modal.propTypes = {
  id: _propTypes["default"].string.isRequired
};
VtxGasEnterpriseModal.propTypes = {
  id: _propTypes["default"].string.isRequired,
  label: _propTypes["default"].string.isRequired
};
VtxGasEnterpriseModal.Modal = Modal;
var _default = VtxGasEnterpriseModal;
exports["default"] = _default;
//# sourceMappingURL=index.js.map
