"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 _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _HighLayer = _interopRequireDefault(require("@vtx/ol-map/lib/high-layer/HighLayer"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _ResultTitle = _interopRequireDefault(require("../_component/ResultTitle"));
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; } /**
 * 结果
 * @description: 用于展示分析结果列表、结果图层等
 */
var Result = function Result(props) {
  var tableData = props.tableData,
    loading = props.loading,
    visible = props.visible,
    setVisible = props.setVisible;
  var highLayer = (0, _react.useRef)();
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map;
  var _useState = (0, _react.useState)(true),
    _useState2 = _slicedToArray(_useState, 2),
    isFold = _useState2[0],
    setIsFold = _useState2[1];
  (0, _react.useEffect)(function () {
    // 地图提示
    highLayer.current = new _HighLayer["default"]({
      map: map
    });
    return function () {
      highLayer.current.destroy();
    };
  }, [map]);
  return /*#__PURE__*/_react["default"].createElement(_CustomModal["default"], {
    width: !isFold ? '50vw' : '',
    title: /*#__PURE__*/_react["default"].createElement(_ResultTitle["default"], {
      title: '污染源分析',
      noline: true,
      question: /*#__PURE__*/_react["default"].createElement("span", null, "1\u3001\u6839\u636E\u7BA1\u7F51\u6C34\u8D28\u68C0\u6D4B\u4EEA\u68C0\u6D4B\u51FA\u7684\u6C34\u8D28\u95EE\u9898\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "2\u3001\u8BFB\u53D6\u6570\u636E\u5E93\u4F9B\u6C34\u7BA1\u9053\u5C5E\u6027\u8868\u4E2D\u7684\u6D41\u5411\u5B57\u6BB5\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "3\u3001\u6839\u636E\u6D41\u5411\uFF0C\u4ECE\u7528\u6237\u6240\u5C5E\u7BA1\u7406\u8868\u7ED1\u5B9A\u7684\u7BA1\u7EBF\u5411\u4E0A\u6E38\u8FFD\u6EAF\uFF0C\u5217\u8868\u5C55\u793A\u8FFD\u6EAF\u5230\u7684\u4E0D\u8FBE\u6807\u70B9\uFF0C\u5217\u8868\u5C55\u793A\u5DE5\u5355\u4E0A\u62A5\u65F6\u95F4-\u7CFB\u7EDF\u5F53\u524D\u65F6\u95F4\u7684\u76D1\u6D4B\u6570\u636E\uFF0C\u5E76\u5728\u5730\u56FE\u4E2D\u7A81\u51FA\u5C55\u793A\u3002")
    }),
    map: map,
    onCancel: function onCancel() {
      setVisible(false);
    },
    visible: visible,
    isCanFold: true,
    isFold: isFold,
    setIsFold: setIsFold
  }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
    columns: [{
      title: '编码',
      dataIndex: 'code',
      width: 100,
      render: function render(text) {
        return /*#__PURE__*/_react["default"].createElement("a", {
          onClick: function onClick() {
            var _layer$getSource;
            setIsFold(true);
            var layer = map === null || map === void 0 ? void 0 : map.getLayerByKey('SZZ');
            var features = (_layer$getSource = layer.getSource()) === null || _layer$getSource === void 0 ? void 0 : _layer$getSource.getFeatures();
            var feature = features === null || features === void 0 ? void 0 : features.find(function (item) {
              var _item$values_;
              return ((_item$values_ = item.values_) === null || _item$values_ === void 0 ? void 0 : _item$values_.code) == text;
            });
            if (feature) {
              var _highLayer$current;
              (_highLayer$current = highLayer.current) === null || _highLayer$current === void 0 || _highLayer$current.setHighlight([feature]);
            }
          }
        }, text);
      }
    }, {
      title: '名称',
      dataIndex: 'name',
      width: 100
    }, {
      title: '设备类型',
      dataIndex: 'deviceTypeName',
      width: 100
    }],
    loading: loading,
    dataSource: tableData
  }));
};
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
