"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireDefault(require("react"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _ResultTitle = _interopRequireDefault(require("../_component/ResultTitle"));
var _Total = _interopRequireDefault(require("../_component/Total"));
var _HorizontalTotal = _interopRequireDefault(require("../_component/HorizontalTotal"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _MyTabs = _interopRequireDefault(require("../_component/MyTabs"));
var _MapLayer = _interopRequireDefault(require("./MapLayer"));
var _service = _interopRequireDefault(require("../_mapUtil/service"));
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,
    isFold = _useProps.isFold,
    setIsFold = _useProps.setIsFold;

  // 表格联动地图
  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, _service["default"].getLayerTypeByLineType(text));
    }
  }];

  /**
   * @description: 获取表格数据
   * @return {*}
   */
  var getItems = function getItems() {
    var _tableData$tableData;
    var items = [];
    var lineData = [],
      pointData = [];
    tableData === null || tableData === void 0 || (_tableData$tableData = tableData.tableData) === null || _tableData$tableData === void 0 || _tableData$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
      })
    }, {
      label: '管点',
      key: 'point',
      children: /*#__PURE__*/_react["default"].createElement(_Table["default"], {
        rowKey: "code",
        columns: columns || [],
        dataSource: pointData
      })
    }];
    return items;
  };
  var getTotal = function getTotal() {
    var _tableData$tableData2;
    var lineData = [],
      pointData = [];
    tableData === null || tableData === void 0 || (_tableData$tableData2 = tableData.tableData) === null || _tableData$tableData2 === void 0 || _tableData$tableData2.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);
      }
    });
    return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_HorizontalTotal["default"], {
      options: [{
        label: '起点',
        value: (tableData === null || tableData === void 0 ? void 0 : tableData.pointStartCode) || '-'
      }, {
        label: ' 终点',
        value: (tableData === null || tableData === void 0 ? void 0 : tableData.pointEndCode) || '-'
      }, {
        label: '分析结果',
        value: /*#__PURE__*/_react["default"].createElement("div", {
          style: {
            color: (tableData === null || tableData === void 0 ? void 0 : tableData.result) == '不连通' ? 'rgb(255, 58, 59)' : (tableData === null || tableData === void 0 ? void 0 : tableData.result) == '连通' ? 'rgb(0, 177, 50)' : ''
          }
        }, (tableData === null || tableData === void 0 ? void 0 : tableData.result) || '-')
      }]
    }), /*#__PURE__*/_react["default"].createElement(_Total["default"], {
      options: [{
        label: '连通管线数',
        value: lineData === null || lineData === void 0 ? void 0 : lineData.length,
        unit: '条'
      }, {
        label: '管线总长',
        value: _service["default"].getLineTotalLength(lineData, 'lineLength', 2),
        unit: 'm'
      }, {
        label: '管点数',
        value: pointData === null || pointData === void 0 ? void 0 : pointData.length,
        unit: '个'
      }]
    }));
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__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, "\u8BA1\u7B97\u7BA1\u7F51\u4E0A\u4E24\u4E2A\u7BA1\u70B9\u4E0A\u662F\u5426\u8FDE\u901A\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "\u9009\u62E9\u7BA1\u7F51\u4E2D\u4EFB\u610F\u4E24\u4E2A\u7BA1\u70B9\u4F5C\u4E3A\u8D77\u7EC8\u70B9\uFF0C\u6839\u636E\u9009\u5B9A\u7684\u8D77\u70B9\u8FDB\u884C\u4E0A\u4E0B\u6E38\u6EAF\u6E90\uFF0C\u6EAF\u6E90\u51FA\u6240\u6709\u7684\u7BA1\u70B9\uFF0C\u82E5\u7EC8\u70B9\u5728\u6EAF\u6E90\u51FA\u7684\u7BA1\u70B9\u4E2D\uFF0C\u5219\u8868\u660E\u8D77\u70B9\u548C\u7EC8\u70B9\u662F\u8054\u901A\u7684\u3002")
    }),
    map: map,
    onCancel: function onCancel() {
      setVisible(false);
    },
    visible: visible,
    isCanFold: true,
    isFold: isFold,
    setIsFold: setIsFold
  }, /*#__PURE__*/_react["default"].createElement(_ResultTitle["default"], {
    title: '分析结果统计'
  }), getTotal(), /*#__PURE__*/_react["default"].createElement(_ResultTitle["default"], {
    title: '连通数据明细'
  }), /*#__PURE__*/_react["default"].createElement(_MyTabs["default"], {
    tabsList: getItems()
  })), /*#__PURE__*/_react["default"].createElement(_MapLayer["default"], null));
}
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
