"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 _Table = _interopRequireDefault(require("../_component/Table"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _MyTabs = _interopRequireDefault(require("../_component/MyTabs"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _propTypes = _interopRequireDefault(require("prop-types"));
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; } /**
 * @returns 纳污范围分析（污水）
 */
function Result(props) {
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map,
    highLayer = _useProps.highLayer;
  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$loading = props.loading,
    loading = _props$loading === void 0 ? false : _props$loading,
    _props$tabKeys = props.tabKeys,
    tabKeys = _props$tabKeys === void 0 ? [] : _props$tabKeys,
    _props$tableData = props.tableData,
    tableData = _props$tableData === void 0 ? [] : _props$tableData,
    isFold = props.isFold,
    setIsFold = props.setIsFold,
    activeKey = props.activeKey,
    setActiveKey = props.setActiveKey;
  var _useState = (0, _react.useState)([]),
    _useState2 = _slicedToArray(_useState, 2),
    columns = _useState2[0],
    setColumns = _useState2[1];
  var getItems = function getItems() {
    var items = [];
    (tabKeys === null || tabKeys === void 0 ? void 0 : tabKeys.length) && tabKeys.map(function (item) {
      items.push({
        label: item.name,
        key: item.key,
        children: /*#__PURE__*/_react["default"].createElement(_Table["default"], {
          columns: columns,
          loading: loading,
          dataSource: tableData,
          rowKey: "rowKey",
          scroll: {
            y: map.getViewport().clientHeight - 340,
            x: 200
          }
        })
      });
    });
    return items;
  };
  var classnames = function classnames(name) {
    if (name) {
      return "contamination-range-analysis-".concat(name);
    }
    return "contamination-range-analysis";
  };
  // 表格数据点击联动地图
  var handleCode = function handleCode() {
    var record = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
    highLayer.current && highLayer.current.setCenter(record.code);
    if (highLayer.current.selectFeature) {
      map.showTemplate(highLayer.current.selectFeature);
    }
  };
  var commonColumns = [{
    title: '编码',
    dataIndex: 'code',
    width: 120,
    render: function render(text, record) {
      return /*#__PURE__*/_react["default"].createElement("a", {
        onClick: function onClick() {
          // 点击高亮居中
          if (activeKey !== null && activeKey !== void 0 && activeKey.toUpperCase().includes('LINE')) {
            setIsFold(true);
          }
          handleCode(record);
        }
      }, text);
    }
  }];
  var pointColumns = [{
    title: '管点类别',
    dataIndex: 'categoryStr',
    width: 80
  }, {
    title: '附属物',
    dataIndex: 'appendantStr',
    width: 80
  }, {
    title: '特征点',
    dataIndex: 'featureStr',
    width: 80
  }, {
    title: '所在道路',
    dataIndex: 'roadName',
    width: 80
  }, {
    title: '地面高程',
    dataIndex: 'groundElevation',
    width: 80,
    align: 'right'
  }];
  var lineColumns = [{
    title: '管径(mm)',
    dataIndex: 'ds',
    width: 80
  }, {
    title: '起点埋深(m)',
    dataIndex: 'startDeep',
    width: 80
  }, {
    title: '终点埋深(m)',
    dataIndex: 'endDeep',
    width: 80
  }, {
    title: '终点高程(m)',
    dataIndex: 'startZ',
    width: 80
  }, {
    title: '终点高程(m)',
    dataIndex: 'endZ',
    width: 80
  }, {
    title: '管材',
    dataIndex: 'lineTextureStr',
    width: 80
  }];
  (0, _react.useEffect)(function () {
    if (activeKey !== null && activeKey !== void 0 && activeKey.toUpperCase().includes('LINE')) {
      setColumns([].concat(commonColumns, lineColumns));
    } else if (activeKey !== null && activeKey !== void 0 && activeKey.toUpperCase().includes('POINT')) {
      setColumns([].concat(commonColumns, pointColumns));
    } else {
      setColumns(commonColumns);
    }
  }, [activeKey]);
  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\u8BFB\u53D6\u6570\u636E\u5E93\u6C61\u6C34\u7BA1\u9053\u5C5E\u6027\u8868\u4E2D\u7684\u6D41\u5411\u5B57\u6BB5\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "2\u3001\u6839\u636E\u6D41\u5411\uFF0C\u4ECE\u6C61\u6C34\u6CF5\u7AD9\u5411\u4E0A\u6E38\u8FFD\u6EAF\uFF0C\u5982\u8FFD\u6EAF\u5230\u5176\u4ED6\u6C61\u6C34\u6CF5\u7AD9\uFF0C\u5219\u8FFD\u6EAF\u7ED3\u675F\uFF0C\u4E0A\u6E38\u65E0\u6C61\u6C34\u6CF5\u7AD9\u5219\u8FFD\u6EAF\u81F3\u6C61\u6C34\u7BA1\u7EBF\u6E90\u5934\uFF0C\u5C06\u9009\u62E9\u7684\u6C61\u6C34\u6CF5\u7AD9\u5730\u56FE\u5C45\u4E2D\u5C55\u793A\uFF0C\u8FFD\u6EAF\u5230\u7684\u7BA1\u7EBF\u53CA\u7BA1\u7EBF\u7BA1\u70B9\u5173\u8054\u8BBE\u5907\u7A81\u51FA\u663E\u793A")
    }),
    map: map,
    onCancel: function onCancel() {
      setVisible(false);
    },
    visible: visible,
    isCanFold: true,
    isFold: isFold,
    setIsFold: setIsFold
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: classnames('contaminationRange')
  }, /*#__PURE__*/_react["default"].createElement(_MyTabs["default"], {
    tabsList: getItems(),
    activeKey: activeKey,
    onChange: function onChange(e) {
      setActiveKey(e);
    }
  })));
}
Result.propTypes = {
  setVisible: _propTypes["default"].func,
  visible: _propTypes["default"].bool,
  showContent: _propTypes["default"].bool,
  setTableData: _propTypes["default"].func,
  columns: _propTypes["default"].array,
  loading: _propTypes["default"].bool,
  tabKeys: _propTypes["default"].array,
  tableData: _propTypes["default"].array,
  isFold: _propTypes["default"].bool,
  setIsFold: _propTypes["default"].func,
  activeKey: _propTypes["default"].string,
  setActiveKey: _propTypes["default"].func
};
var _default = exports["default"] = Result;
//# sourceMappingURL=Result.js.map
