"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 _vmTable = _interopRequireDefault(require("../../../vm-table"));
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 _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; } // import { BASIC_FIELDS } from '../../config';
var PumpInfo = function PumpInfo() {
  var _useContext = (0, _react.useContext)(_index.PumpContext),
    id = _useContext.id;
  var data = _api.BasicService.facilityInfo({
    id: id
  });
  data = Object.assign(Object.assign({}, data), data.dataJson);
  var pjList = _api.BasicService.pjList(id);
  var viewDetails = _api.BasicService.viewDetail('pump');
  var allFields = [].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
    });
  });
  var basicFields = allFields.filter(function (item) {
    return item.groupCode === 'detail' && item.showKey !== 'photoIds';
  });
  var gsFields = allFields.filter(function (item) {
    return item.groupName === '其他信息';
  });
  var ptxtFields = allFields.filter(function (item) {
    return item.groupName === '详细信息';
  });
  var fjFields = allFields.filter(function (item) {
    return item.groupName === '附件信息' || item.showKey === 'photoIds';
  });
  var columns = [{
    title: '配件大类',
    dataIndex: 'categoryName',
    key: 'categoryName',
    width: 100
  }, {
    title: '配件类型',
    dataIndex: 'accessoriesTypeInfoName',
    key: 'accessoriesTypeInfoName',
    width: 100,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      });
    }
  }, {
    title: '配件名称',
    dataIndex: 'name',
    key: 'name',
    width: 100
  }, {
    title: '型号',
    dataIndex: 'model',
    key: 'model',
    width: 100
  }, {
    title: '数量',
    dataIndex: 'num',
    key: 'num',
    width: 100
  }, {
    title: '单位',
    dataIndex: 'unitName',
    key: 'unitName',
    width: 100
  }, {
    title: '厂家',
    dataIndex: 'manufactor',
    key: 'manufactor',
    width: 100
  }, {
    title: '出厂日期',
    dataIndex: 'outFactoryDate',
    key: 'outFactoryDate',
    width: 100
  }, {
    title: '状态',
    dataIndex: 'statusName',
    key: 'statusName',
    width: 100
  }];
  return /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u57FA\u672C\u4FE1\u606F"
  }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: basicFields,
    horizontal: true,
    width: "50%",
    ellipsis: true
  }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u4F9B\u6C34\u4FE1\u606F"
  }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: gsFields,
    horizontal: true,
    width: "50%",
    ellipsis: true
  }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u914D\u4EF6\u4FE1\u606F"
  }), /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      width: '100%'
    }
  }, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], {
    columns: columns,
    pagination: false,
    dataSource: pjList
  })), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u914D\u5957\u7CFB\u7EDF\u60C5\u51B5"
  }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: ptxtFields,
    horizontal: true,
    width: "50%",
    ellipsis: true
  }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
    title: "\u9644\u4EF6\u4FE1\u606F"
  }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
    data: fjFields,
    horizontal: true,
    width: "50%",
    ellipsis: true
  }));
};
var _default = exports["default"] = PumpInfo;
//# sourceMappingURL=PumpInfo.js.map
