"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");
var _config = require("../../config");
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _vmNodata = _interopRequireDefault(require("../../../vm-nodata"));
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); }
var TabPane = _antd.Tabs.TabPane;
var JyqInfo = function JyqInfo() {
  var _useContext = (0, _react.useContext)(_index.PumpContext),
    id = _useContext.id;
  var dataList = _api.BasicService.jyqInfo(id).map(function (item) {
    return Object.assign(Object.assign({}, item), item.detail);
  });
  var dataTypeList = _api.BasicService.dataType();
  var getFields = function getFields(data) {
    return _config.JYQ_FIELDS.map(function (item) {
      return Object.assign(Object.assign({}, item), {
        value: item.key === 'source' ? data.source ? data.source === 'OWN' ? '自有' : '外部' : '' : item.key === 'dataType' ? data.dataType ? dataTypeList.find(function (dataType) {
          return dataType.id === data.dataType;
        }).name : '' : data === null || data === void 0 ? void 0 : data[item.key],
        render: undefined
      });
    });
  };
  var getFjFields = function getFjFields(data) {
    return [{
      key: 'photoIds',
      label: '图片'
    }, {
      key: 'attachment',
      label: '附件'
    }].map(function (item) {
      return Object.assign(Object.assign({}, item), {
        value: data === null || data === void 0 ? void 0 : data[item.key],
        render: item.key === '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),
              src: "/cloudFile/common/downloadFile?id=".concat(each.id, "&token=").concat((0, _util.getUrlPara)('token')),
              alt: each.name
            });
          }));
        } : item.key === '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.key === 'attachment' ? function () {
          var fileList = JSON.parse(data.attachment || '[]');
          return /*#__PURE__*/_react["default"].createElement(_components.VtxUpload, {
            name: "file",
            viewMode: true,
            fileList: fileList,
            flag: Math.random(),
            downloadUrl: "/cloudFile/common/downloadFile?id="
          });
        } : undefined
      });
    });
  };
  //水泵信息
  var sbColumns = [{
    title: '水泵名称',
    dataIndex: 'name',
    key: 'name',
    width: 100
  }, {
    title: '水泵类型',
    dataIndex: 'facilityClassName',
    key: 'facilityClassName',
    width: 100
  }, {
    title: '型号',
    dataIndex: 'model',
    key: 'model',
    width: 100
  }, {
    title: '厂家',
    dataIndex: 'manufactor',
    key: 'manufactor',
    width: 100,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      });
    }
  }, {
    title: '出厂日期',
    dataIndex: 'outFactoryDate',
    key: 'outFactoryDate',
    width: 100
  }, {
    title: '额定扬程(m)',
    dataIndex: 'ratedHead',
    key: 'ratedHead',
    width: 120
  }, {
    title: '额定功率(kW)',
    dataIndex: 'ratedPower',
    key: 'ratedPower',
    width: 120
  }, {
    title: '额定流量(m³/h)',
    dataIndex: 'ratedFlowRate',
    key: 'ratedFlowRate',
    width: 150
  }, {
    title: '转速(r/min)',
    dataIndex: 'speed',
    key: 'speed',
    width: 100
  }, {
    title: '状态',
    dataIndex: 'facilityStatusName',
    key: 'facilityStatusName',
    width: 100
  }];
  //配件信息
  var pjColumns = [{
    title: '配件大类',
    dataIndex: 'categoryName',
    key: 'categoryName',
    width: 100
  }, {
    title: '配件类型',
    dataIndex: 'typeName',
    key: 'typeName',
    width: 150,
    ellipsis: true
  }, {
    title: '配件名称',
    dataIndex: 'name',
    key: 'name',
    width: 150
  }, {
    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,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement(_components.VtxEllipsisText, {
        text: text
      });
    }
  }, {
    title: '出厂日期',
    dataIndex: 'outFactoryDate',
    key: 'outFactoryDate',
    width: 150
  }, {
    title: '状态',
    dataIndex: 'statusName',
    key: 'statusName',
    width: 100
  }];
  return /*#__PURE__*/_react["default"].createElement("div", null, dataList && dataList.length > 0 ? (/*#__PURE__*/_react["default"].createElement(_antd.Tabs, {
    type: "card"
  }, dataList.map(function (item) {
    return /*#__PURE__*/_react["default"].createElement(TabPane, {
      tabKey: item.id,
      tab: item.code,
      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
    }), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
      title: "\u6C34\u6CF5\u4FE1\u606F"
    }), /*#__PURE__*/_react["default"].createElement("div", {
      style: {
        width: '100%'
      }
    }, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], {
      columns: sbColumns,
      pagination: false,
      dataSource: item.waterPumpList ? item.waterPumpList.map(function (one) {
        return Object.assign(Object.assign({}, one), one.dataJson);
      }) : []
    })), /*#__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: pjColumns,
      pagination: false,
      dataSource: item.pressurizeAccessoryInfoList || [],
      scroll: {
        x: 300,
        y: 500
      }
    })), /*#__PURE__*/_react["default"].createElement("br", null), /*#__PURE__*/_react["default"].createElement(_vmSubTitle["default"], {
      title: "\u9644\u4EF6\u4FE1\u606F"
    }), /*#__PURE__*/_react["default"].createElement(_vmInfoCollection["default"], {
      data: getFjFields(item),
      horizontal: true,
      width: "50%",
      ellipsis: true
    })));
  }))) : (/*#__PURE__*/_react["default"].createElement(_vmNodata["default"], {
    style: {
      height: '200px',
      width: '400px'
    }
  })));
};
var _default = exports["default"] = JyqInfo;
//# sourceMappingURL=JyqInfo.js.map
