"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _FeatureLayer = _interopRequireDefault(require("@vtx/ol-map/lib/feature-layer/FeatureLayer"));
var _ImageLayer = _interopRequireDefault(require("@vtx/ol-map/lib/image-layer/ImageLayer"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _Export = _interopRequireDefault(require("../_component/Export"));
var _service = _interopRequireDefault(require("../_mapUtil/service"));
var _MapLayer = _interopRequireDefault(require("../_component/MapLayer"));
var _config = _interopRequireDefault(require("../_mapUtil/config"));
var _ResultTitle = _interopRequireDefault(require("../_component/ResultTitle"));
var _config2 = require("./config");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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; } /**
 * 结果
 * @description: 用于展示分析结果列表、结果图层等
 */
var Result = function Result() {
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map,
    visible = _useProps.visible,
    setVisible = _useProps.setVisible,
    loading = _useProps.loading,
    tableData = _useProps.tableData,
    activeKey = _useProps.activeKey,
    analysisLayer = _useProps.analysisLayer,
    highLayer = _useProps.highLayer;
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_CustomModal["default"], {
    title: /*#__PURE__*/_react["default"].createElement(_ResultTitle["default"], {
      title: '设施搜索',
      noline: true,
      question: /*#__PURE__*/_react["default"].createElement("span", null, "\u901A\u8FC7\u9009\u62E9\u56FE\u5C42\u8BBE\u65BD\u7C7B\u578B\uFF0C\u5728\u5730\u56FE\u4E2D\u9009\u62E9\u5177\u4F53\u8303\u56F4\uFF0C\u5E73\u53F0\u5206\u6790\u51FA\u8BE5\u6761\u4EF6\u4E0B\u7684\u8BBE\u65BD\u60C5\u51B5")
    }),
    map: map,
    onCancel: function onCancel() {
      try {
        map.hideTemplate();
      } catch (err) {}
      setVisible(false);
    },
    visible: visible
  }, /*#__PURE__*/_react["default"].createElement(_Export["default"], {
    url: activeKey !== null && activeKey !== void 0 && activeKey.toUpperCase().includes('LINE') ? "".concat(_config["default"].publicUrlJCSS, "/api/line/exportExcel") : "".concat(_config["default"].publicUrlJCSS, "/api/point/exportExcel"),
    method: "POST",
    params: {
      codes: _service["default"].getField(tableData, 'code') || _service["default"].getField(tableData, 'facilityId'),
      exportType: 2
    }
  }), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
    columns: _toConsumableArray(activeKey === 'SEWERAGE_USER' ? [{
      title: '名称',
      dataIndex: ['values_', 'facilityName'],
      width: 100
    }] : [{
      title: '编码',
      dataIndex: ['values_', 'code'],
      width: 100,
      render: function render(text) {
        return /*#__PURE__*/_react["default"].createElement("a", {
          onClick: function onClick() {
            var layer = _service["default"].getLayerByActiveKey(map, activeKey);
            if (layer instanceof _ImageLayer["default"]) {
              analysisLayer.setCenterByCode(text);
              (analysisLayer === null || analysisLayer === void 0 ? void 0 : analysisLayer.selectFeature) && map.showTemplate(analysisLayer.selectFeature);
            }
            if (layer instanceof _FeatureLayer["default"]) {
              highLayer === null || highLayer === void 0 || highLayer.setCenter(text, 'code');
              (highLayer === null || highLayer === void 0 ? void 0 : highLayer.selectFeature) && (map === null || map === void 0 ? void 0 : map.showTemplate(highLayer.selectFeature));
            }
          }
        }, text);
      }
    }]),
    loading: loading,
    dataSource: tableData
  })), /*#__PURE__*/_react["default"].createElement(_MapLayer["default"], {
    emptyConfigData: Object.keys(_config2.InfiltrationType).map(function (key) {
      return {
        name: _config2.InfiltrationTypeName[_config2.InfiltrationType[key]],
        key: "INFILTRATION_GW_".concat(_config2.InfiltrationType[key]),
        color: _config2.InfiltrationTypeColor[_config2.InfiltrationType[key]],
        icon: _config2.InfiltrationTypeIcon[_config2.InfiltrationType[key]],
        filter: function filter(f) {
          return f.infiltrationType === _config2.InfiltrationType[key];
        }
      };
    })
  }));
};
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
