"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"] = YJZXResult;
var _react = _interopRequireWildcard(require("react"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _button = _interopRequireDefault(require("antd/lib/button"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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 && Object.prototype.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 _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(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
var RenderData = function RenderData(_ref) {
  var _ref$data = _ref.data,
    data = _ref$data === void 0 ? {} : _ref$data,
    field = _ref.field;
  return /*#__PURE__*/_react["default"].createElement("div", null, (data === null || data === void 0 ? void 0 : data[field]) || '--');
};
RenderData.propTypes = {
  data: _propTypes["default"].object,
  field: _propTypes["default"].string
};
var classnames = function classnames(name) {
  if (name) {
    return "blowout-valve-closing-analysis-".concat(name);
  }
  return "blowout-valve-closing-analysis";
};
function YJZXResult(props) {
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map;
  var _props$setVisible = props.setVisible,
    setVisible = _props$setVisible === void 0 ? function () {} : _props$setVisible,
    _props$visible = props.visible,
    visible = _props$visible === void 0 ? false : _props$visible,
    _props$getData = props.getData,
    getData = _props$getData === void 0 ? function () {} : _props$getData,
    _props$yjfxData = props.yjfxData,
    yjfxData = _props$yjfxData === void 0 ? [] : _props$yjfxData,
    _props$setType = props.setType,
    setType = _props$setType === void 0 ? function () {} : _props$setType;
  var _useState = (0, _react.useState)(''),
    _useState2 = _slicedToArray(_useState, 2),
    currentKey = _useState2[0],
    setCurrentKey = _useState2[1];
  var columns = [{
    title: '压力点',
    dataIndex: 'pointCode',
    width: 100
  }, {
    title: '压降(MPa)',
    dataIndex: 'pressureDrop',
    width: 100
  }, {
    title: '实时值(MPa)',
    dataIndex: 'w_pressure',
    width: 100
  }, {
    title: '30天压力均值',
    dataIndex: 'avgPressure',
    width: 100
  }, {
    title: '管线编码',
    dataIndex: 'lineCode',
    width: 100,
    render: function render(text, record) {
      var _record$lines;
      return /*#__PURE__*/_react["default"].createElement(RenderData, {
        data: record === null || record === void 0 || (_record$lines = record.lines) === null || _record$lines === void 0 ? void 0 : _record$lines[0],
        field: "lineCode"
      });
    }
  }, {
    title: '管龄',
    dataIndex: 'lineAge',
    width: 100,
    render: function render(text, record) {
      var _record$lines2;
      return /*#__PURE__*/_react["default"].createElement(RenderData, {
        data: record === null || record === void 0 || (_record$lines2 = record.lines) === null || _record$lines2 === void 0 ? void 0 : _record$lines2[0],
        field: "lineAge"
      });
    }
  }, {
    title: '管材',
    dataIndex: 'lineTexture',
    width: 100,
    render: function render(text, record) {
      var _record$lines3;
      return /*#__PURE__*/_react["default"].createElement(RenderData, {
        data: record === null || record === void 0 || (_record$lines3 = record.lines) === null || _record$lines3 === void 0 ? void 0 : _record$lines3[0],
        field: "lineTexture"
      });
    }
  }, {
    title: '埋深(m)',
    dataIndex: 'lineDeep',
    width: 100,
    render: function render(text, record) {
      var _record$lines4;
      return /*#__PURE__*/_react["default"].createElement(RenderData, {
        data: record === null || record === void 0 || (_record$lines4 = record.lines) === null || _record$lines4 === void 0 ? void 0 : _record$lines4[0],
        field: "lineDeep"
      });
    }
  }, {
    title: '排气阀距离(m)',
    dataIndex: 'valveDistance',
    width: 100,
    render: function render(text, record) {
      var _record$lines5;
      return /*#__PURE__*/_react["default"].createElement(RenderData, {
        data: record === null || record === void 0 || (_record$lines5 = record.lines) === null || _record$lines5 === void 0 ? void 0 : _record$lines5[0],
        field: "valveDistance"
      });
    }
  }];
  return /*#__PURE__*/_react["default"].createElement(_CustomModal["default"], {
    title: "\u538B\u964D\u4E2D\u5FC3",
    map: map,
    onCancel: function onCancel() {
      try {
        map.hideTemplate();
      } catch (err) {}
      setVisible(false);
    },
    visible: visible
  }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
    columns: columns,
    dataSource: yjfxData,
    rowKey: "pointCode",
    rowSelection: {
      type: 'radio',
      onChange: function onChange(selectedRowKeys) {
        setCurrentKey(selectedRowKeys);
      }
    },
    scroll: {
      y: 400,
      x: 200
    }
  }), /*#__PURE__*/_react["default"].createElement("div", {
    className: classnames('btn')
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    type: "primary",
    size: "small",
    disabled: !currentKey,
    onClick: function onClick() {
      setType && setType('gffx');
      if (currentKey) {
        getData({
          code: currentKey === null || currentKey === void 0 ? void 0 : currentKey[0]
        }, 'POINT');
      }
    }
  }, "\u5173\u9600\u5206\u6790")));
}
YJZXResult.propTypes = {
  setVisible: _propTypes["default"].func,
  visible: _propTypes["default"].bool,
  getData: _propTypes["default"].func,
  yjfxData: _propTypes["default"].array,
  setType: _propTypes["default"].func
};
//# sourceMappingURL=YJZXResult.js.map
