"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _MyTabs = _interopRequireDefault(require("../_component/MyTabs"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
/**
 * @returns 连通性分析（供水、污水）
 */

function Result(props) {
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map,
    highLayers = _useProps.highLayers,
    paramsName = _useProps.paramsName,
    _useProps$setVisible = _useProps.setVisible,
    setVisible = _useProps$setVisible === void 0 ? function () {} : _useProps$setVisible,
    _useProps$visible = _useProps.visible,
    visible = _useProps$visible === void 0 ? false : _useProps$visible,
    _useProps$tableData = _useProps.tableData,
    tableData = _useProps$tableData === void 0 ? [] : _useProps$tableData;

  // 表格联动地图
  var handleCode = function handleCode(record) {
    var _highLayers$paramsNam;
    for (var key in highLayers) {
      highLayers[key] && highLayers[key].clearSelectFeature();
    }
    var keyName = "".concat(record.category, "-").concat(record.lineType);
    var code = record.code;
    highLayers[paramsName[keyName]] && highLayers[paramsName[keyName]].setCenterByCode(code);
    var selectFeature = (_highLayers$paramsNam = highLayers[paramsName[keyName]]) === null || _highLayers$paramsNam === void 0 ? void 0 : _highLayers$paramsNam.selectFeature;
    if (selectFeature) map === null || map === void 0 || map.showTemplate(selectFeature);
  };
  var columns = [{
    title: '编号/名称',
    dataIndex: 'code',
    render: function render(text, record) {
      return /*#__PURE__*/_react["default"].createElement("a", {
        onClick: function onClick() {
          handleCode && handleCode(record);
        }
      }, text);
    }
  }, {
    title: '类别',
    dataIndex: 'category',
    width: 60
  }, {
    title: '类型',
    dataIndex: 'lineType',
    width: 60,
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement("span", null, text === 1 ? '污水' : text === 2 ? '供水' : '原水');
    }
  }];

  /**
   * @description: 获取表格数据
   * @return {*}
   */
  var getItems = function getItems() {
    var items = [];
    var lineData = [],
      pointData = [];
    tableData === null || tableData === void 0 || tableData.map(function (v) {
      if ((v === null || v === void 0 ? void 0 : v.category) === '管点') {
        pointData.push(v);
      } else if ((v === null || v === void 0 ? void 0 : v.category) === '管线') {
        lineData.push(v);
      }
    });
    items = [{
      label: '管线',
      key: 'line',
      children: /*#__PURE__*/_react["default"].createElement(_Table["default"], {
        rowKey: "code",
        columns: columns || [],
        dataSource: lineData,
        scroll: {
          y: map.getViewport().clientHeight - 240,
          x: 200
        }
      })
    }, {
      label: '管点',
      key: 'point',
      children: /*#__PURE__*/_react["default"].createElement(_Table["default"], {
        rowKey: "code",
        columns: columns || [],
        dataSource: pointData,
        scroll: {
          y: map.getViewport().clientHeight - 240,
          x: 200
        }
      })
    }];
    return items;
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_CustomModal["default"], {
    title: "\u8FDE\u901A\u6027\u5206\u6790",
    map: map,
    onCancel: function onCancel() {
      setVisible(false);
    },
    visible: visible
  }, /*#__PURE__*/_react["default"].createElement(_MyTabs["default"], {
    tabsList: getItems()
  })));
}
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
