"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 _util = require("../../../util");
var _vmInfoCollection = _interopRequireDefault(require("../../../vm-info-collection"));
var _index = require("../../index");
var _api = require("../../api");
require("./index.less");
var _vmSubTitle = _interopRequireDefault(require("../../../vm-sub-title"));
var _components = require("@vtx/components");
var _antd = require("antd");
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 _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
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; }
var TabPane = _antd.Tabs.TabPane;
var SxInfo = function SxInfo() {
  var _useContext = (0, _react.useContext)(_index.PumpContext),
    id = _useContext.id;
  var dataList = _api.BasicService.sxInfo(id).map(function (item) {
    return Object.assign(Object.assign({}, item), item.dataJson);
  });
  var viewDetails = _api.BasicService.viewDetail('sx');
  var getFields = function getFields(data) {
    return [].concat(_toConsumableArray((viewDetails === null || viewDetails === void 0 ? void 0 : viewDetails.baseFields) || []), _toConsumableArray((viewDetails === null || viewDetails === void 0 ? void 0 : viewDetails.customFields) || [])).map(function (item) {
      return Object.assign(Object.assign({}, item), {
        label: item.showName,
        value: data === null || data === void 0 ? void 0 : data[item.showKey],
        render: item.showKey === 'photoIds' ? function () {
          var photos = JSON.parse(data.photoIds || '[]');
          return /*#__PURE__*/_react["default"].createElement(_components.VtxImage.PreviewGroup, null, photos.map(function (each) {
            return /*#__PURE__*/_react["default"].createElement(_components.VtxImage, {
              style: {
                width: 80,
                height: 80,
                marginRight: 8
              },
              key: each.id,
              thumb: "/vortex/rest/cloud/np/file/downloadFileThumbnail?outputQuality=0.5&scale=0.2&id=".concat(each.id, "&token=").concat((0, _util.getUrlPara)('token')),
              src: "/cloudFile/common/downloadFile?id=".concat(each.id, "&token=").concat((0, _util.getUrlPara)('token')),
              alt: each.name
            });
          }));
        } : item.showKey === 'geometryInfo' ? function () {
          var _a;
          return /*#__PURE__*/_react["default"].createElement("span", null, "\u7ECF\u7EAC\u5EA6\uFF1A", (_a = data === null || data === void 0 ? void 0 : data.geometryInfo) === null || _a === void 0 ? void 0 : _a.lngLats);
        } : item.showKey === 'fj' ? function () {
          var fileList = JSON.parse(data.fj || '[]');
          return /*#__PURE__*/_react["default"].createElement(_components.VtxUpload, {
            name: "file",
            viewMode: true,
            fileList: fileList,
            flag: Math.random(),
            downloadUrl: "/cloudFile/common/downloadFile?id="
          });
        } : undefined
      });
    });
  };
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_antd.Tabs, {
    type: "card"
  }, dataList.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(TabPane, {
      tabKey: item.id,
      tab: item.name,
      key: item.id
    }, /*#__PURE__*/_react["default"].createElement("div", {
      style: {
        paddingTop: 10
      }
    }, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
      title: "\u57FA\u672C\u4FE1\u606F"
    }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
      data: getFields(item),
      horizontal: true,
      width: "50%",
      ellipsis: true
    })));
  })));
};
var _default = exports["default"] = SxInfo;
//# sourceMappingURL=SxInfo.js.map
