"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 _antd = require("antd");

var _components = require("@vtx/components");

var _map = require("@vtx/map");

var _useMapInfo2 = _interopRequireDefault(require("../vm-hooks/useMapInfo"));

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

var _vtxGasUserModal = _interopRequireDefault(require("../vtx-gas-user-modal"));

var _vtxGasStaffModal = _interopRequireDefault(require("../vtx-gas-staff-modal"));

var _vtxGasEnterpriseModal = _interopRequireDefault(require("../vtx-gas-enterprise-modal"));

var _useSettings2 = _interopRequireDefault(require("../vm-hooks/useSettings"));

var _index = _interopRequireDefault(require("./style/index.less"));

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 _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; }

var BaseContent = function BaseContent(_ref) {
  var _formData$checkAddres, _formData$checkAddres2, _formData$configList;

  var id = _ref.id;

  var _useState = (0, _react.useState)({}),
      _useState2 = _slicedToArray(_useState, 2),
      formData = _useState2[0],
      setFormData = _useState2[1];

  var _useMapInfo = (0, _useMapInfo2["default"])(),
      mapInfo = _useMapInfo.mapInfo;

  (0, _react.useEffect)(function () {
    (0, _api.getInfo)(id).then(function (data) {
      return setFormData(data);
    });
  }, [id]);
  var checkColumns = [{
    title: '项目名称',
    dataIndex: 'projectName',
    width: 200,
    render: function render(text, record) {
      return {
        props: {
          rowSpan: record.rowSpan
        },
        children: text
      };
    }
  }, {
    title: '安检内容',
    dataIndex: 'subName',
    width: 200
  }, {
    title: '安检情况',
    dataIndex: 'value',
    render: function render(text, record) {
      if (record.type === 'IMAGE') {
        return text === null || text === void 0 ? void 0 : text.map(function (item) {
          return /*#__PURE__*/_react["default"].createElement(_components.VtxImage, {
            key: item.id,
            alt: item.name,
            width: 200 // thumb={`/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=${item.id}`}
            ,
            src: "/cloudFile/common/downloadFile?id=".concat(item.id)
          });
        });
      }

      if (record.type === 'CHECKBOX') {
        return text === null || text === void 0 ? void 0 : text.join('、');
      }

      return text;
    }
  }];

  var _useSettings = (0, _useSettings2["default"])(),
      theme = _useSettings.theme;

  var _ref2 = ((_formData$checkAddres = formData.checkAddress) === null || _formData$checkAddres === void 0 ? void 0 : (_formData$checkAddres2 = _formData$checkAddres.lngLats) === null || _formData$checkAddres2 === void 0 ? void 0 : _formData$checkAddres2.split(',')) || [],
      _ref3 = _slicedToArray(_ref2, 2),
      lng = _ref3[0],
      lat = _ref3[1];

  return /*#__PURE__*/_react["default"].createElement(_antd.Form, {
    layout: "inline"
  }, /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout, {
    mode: "view",
    cols: 3,
    card: true
  }, /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.Card, {
    title: "\u57FA\u672C\u4FE1\u606F"
  }, /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u4F9B\u6C14\u7C7B\u578B"
  }, formData.gasTypeStr || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u7528\u6237\u7C7B\u522B"
  }, formData.gasUserTypeStr || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u7528\u6237\u7F16\u53F7"
  }, formData.gasUserNo || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u7528\u6237\u540D"
  }, /*#__PURE__*/_react["default"].createElement(_vtxGasUserModal["default"], {
    label: formData.gasUserName,
    id: formData.gasUserId
  })), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u7528\u6237\u5730\u5740"
  }, formData.gasUserAddress || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u884C\u653F\u533A\u5212"
  }, formData.gasUserRegionStr || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u5B89\u68C0\u4EBA\u5458"
  }, /*#__PURE__*/_react["default"].createElement(_vtxGasStaffModal["default"], {
    label: formData.gasStaffName,
    id: formData.gasStaffId
  })), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u8D1F\u8D23\u4F01\u4E1A"
  }, /*#__PURE__*/_react["default"].createElement(_vtxGasEnterpriseModal["default"], {
    label: formData.gasCompanyName,
    id: formData.gasCompanyId
  })), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u5165\u6237\u72B6\u6001"
  }, formData.homeStepStatusStr || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u5B89\u68C0\u65F6\u95F4"
  }, formData.checkDate || '--'), (formData.homeStepStatus === 'PERMISSION' || formData.homeStepStatus === 'GAS_STOP_USE') && /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u7ED3\u8BBA"
  }, formData.resultStr || '--'), /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u5B89\u68C0\u56FE\u7247",
    weights: 3
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: _index["default"].img
  }, formData.photo ? JSON.parse(formData.photo).map(function (item, i) {
    return /*#__PURE__*/_react["default"].createElement(_antd.Image, {
      width: 100,
      key: i,
      src: "/cloudFile/common/downloadFile?id=".concat(item.id)
    });
  }) : '--')), formData.homeStepStatus === 'PERMISSION' && /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.FormItem, {
    label: "\u7528\u6237\u7B7E\u540D",
    weights: 3
  }, formData.userSignFile ? /*#__PURE__*/_react["default"].createElement(_components.VtxImage, {
    alt: "\u7B7E\u540D",
    width: 200 // thumb={`/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=${formData.userSignFile}`}
    ,
    src: "/cloudFile/common/downloadFile?id=".concat(formData.userSignFile)
  }) : '--'), lng && lat && /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      width: '100%',
      height: 200
    }
  }, /*#__PURE__*/_react["default"].createElement(_map.VtxMap, {
    mapId: "securityCheck",
    mapType: mapInfo.mapType,
    mapCenter: [lng, lat],
    mapZoomLevel: 15,
    mapPoints: [{
      id: '1',
      longitude: lng,
      latitude: lat
    }],
    mapStyle: theme === 'dark' ? theme : ''
  })))), formData.homeStepStatus === 'PERMISSION' && /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout, {
    card: true
  }, /*#__PURE__*/_react["default"].createElement(_components.VtxFormLayout.Card, {
    title: "\u5B89\u68C0\u9879\u76EE\u4FE1\u606F"
  }, (_formData$configList = formData.configList) !== null && _formData$configList !== void 0 && _formData$configList.length ? /*#__PURE__*/_react["default"].createElement(_components.VtxDatagrid, {
    toolbar: false,
    indexColumn: false,
    autoFit: false,
    columns: checkColumns,
    dataSource: formData.configList,
    pagination: false,
    style: {
      width: '100%'
    }
  }) : /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      padding: '8px 0',
      width: '100%',
      textAlign: 'center',
      color: '#999'
    }
  }, "\u6682\u65E0\u6570\u636E"))));
};

BaseContent.propTypes = {
  id: _propTypes["default"].string.isRequired
};
var _default = BaseContent;
exports["default"] = _default;
//# sourceMappingURL=base.js.map
