"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"] = Result;
var _react = _interopRequireWildcard(require("react"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _Total = _interopRequireDefault(require("../_component/Total"));
var _MyTabs = _interopRequireDefault(require("../_component/MyTabs"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _ResultTitle = _interopRequireDefault(require("../_component/ResultTitle"));
var _service = _interopRequireDefault(require("../_mapUtil/service"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _MyEmpty = _interopRequireDefault(require("../_component/MyEmpty"));
var _MapLayer = _interopRequireDefault(require("./MapLayer"));
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; }
function Result() {
  var _getItems;
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map,
    analysisLayer = _useProps.analysisLayer,
    _useProps$onClose = _useProps.onClose,
    onClose = _useProps$onClose === void 0 ? function () {} : _useProps$onClose,
    setActiveKey = _useProps.setActiveKey,
    activeKey = _useProps.activeKey,
    options = _useProps.options,
    highLayer = _useProps.highLayer,
    isFold = _useProps.isFold,
    setIsFold = _useProps.setIsFold;
  var _useState = (0, _react.useState)([]),
    _useState2 = _slicedToArray(_useState, 2),
    data = _useState2[0],
    setData = _useState2[1];
  var _useState3 = (0, _react.useState)(false),
    _useState4 = _slicedToArray(_useState3, 2),
    loading = _useState4[0],
    setLoading = _useState4[1];
  var _useState5 = (0, _react.useState)([]),
    _useState6 = _slicedToArray(_useState5, 2),
    dataSource = _useState6[0],
    setDataSource = _useState6[1];
  var _useState7 = (0, _react.useState)(0),
    _useState8 = _slicedToArray(_useState7, 2),
    lineLength = _useState8[0],
    setLineLength = _useState8[1];
  (0, _react.useEffect)(function () {
    setLoading(true);
    setDataSource([]);
    analysisLayer === null || analysisLayer === void 0 || analysisLayer.getData(activeKey, options, function (_ref) {
      var dataSource = _ref.dataSource,
        data = _ref.data,
        lineLength = _ref.lineLength;
      setDataSource(dataSource);
      setData(data);
      setLineLength(lineLength);
      setLoading(false);
    });
  }, [analysisLayer, activeKey]);
  var columns = [{
    title: '序号',
    dataIndex: 'num',
    width: 40,
    onCell: function onCell(r) {
      return {
        rowSpan: r.total
      };
    }
  }, {
    title: '管线数量',
    dataIndex: 'total',
    width: 50,
    onCell: function onCell(r) {
      return {
        rowSpan: r.total
      };
    }
  }, {
    title: '管线总长(m)',
    dataIndex: 'totalLength',
    width: 50,
    render: function render(text) {
      return text && Number(text).toFixed(2);
    },
    onCell: function onCell(r) {
      return {
        rowSpan: r.total
      };
    }
  }, {
    title: '编码',
    dataIndex: 'code',
    width: 80,
    render: function render(text, record) {
      return /*#__PURE__*/_react["default"].createElement("a", {
        onClick: function onClick() {
          return _onClick(text, record);
        }
      }, text);
    }
  }];
  var _onClick = function _onClick(code) {
    _service["default"].setFieldListClick({
      record: {
        code: code
      },
      map: map,
      activeKey: activeKey,
      highLayer: highLayer
    });
  };
  var myTableParams = {
    columns: columns,
    dataSource: dataSource,
    loading: loading,
    indexColumn: false,
    pagination: false
  };
  var getItems = function getItems() {
    var items = [];
    options === null || options === void 0 || options.map(function (v) {
      items.push({
        label: v.label,
        key: v.key,
        codeField: v.codeField,
        children: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_Total["default"], {
          options: [{
            label: '环状管网数',
            value: data === null || data === void 0 ? void 0 : data.length,
            unit: '条'
          }, {
            label: '管线数量',
            value: dataSource === null || dataSource === void 0 ? void 0 : dataSource.length,
            unit: '条'
          }, {
            label: '管线总长',
            value: lineLength,
            unit: 'km'
          }]
        }), /*#__PURE__*/_react["default"].createElement(_Table["default"], myTableParams))
      });
    });
    return items;
  };
  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, "1\u3001\u8BFB\u53D6\u6570\u636E\u5E93\u7BA1\u9053\u5C5E\u6027\u8868\u4E2D\u7684\u6D41\u5411\u5B57\u6BB5\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "2\u3001\u4ECE\u4EFB\u610F\u8282\u70B9\u51FA\u53D1\uFF0C\u6839\u636E\u6D41\u5411\uFF0C\u5411\u4E0A/\u4E0B\u6E38\u904D\u5386\uFF0C\u5C06\u91CD\u590D\u7ECF\u8FC7\u7684\u8282\u70B9\u8FDB\u884C\u6807\u8BB0\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "3\u3001\u5C06\u80FD\u591F\u5F62\u6210\u95ED\u73AF\u7684\u7BA1\u7F51\u8DEF\u5F84\u8BB0\u4E3A\u73AF\u72B6\u7BA1\u7F51\uFF0C\u7EDF\u8BA1\u6BCF\u4E2A\u73AF\u72B6\u7BA1\u7F51\u7684\u7BA1\u9053\u6570\u91CF\uFF0C\u5E76\u5C06\u6240\u6709\u73AF\u72B6\u7BA1\u7F51\u8BB0\u5F55\u5728\u5F39\u6846\u8868\u683C\u4E2D\uFF0C\u5728\u5730\u56FE\u4E2D\u5C06\u5BF9\u5E94\u7BA1\u7EBF\u6807\u8BB0\u9AD8\u4EAE\u3002")
    }),
    map: map,
    onCancel: function onCancel() {
      onClose && onClose();
    },
    visible: true,
    isCanFold: true,
    isFold: isFold,
    setIsFold: setIsFold
  }, (options === null || options === void 0 ? void 0 : options.length) > 1 ? /*#__PURE__*/_react["default"].createElement(_MyTabs["default"], {
    tabsList: getItems(),
    activeKey: activeKey,
    onChange: function onChange(e) {
      setActiveKey(e);
    }
  }) : (options === null || options === void 0 ? void 0 : options.length) == 1 ? (_getItems = getItems()) === null || _getItems === void 0 || (_getItems = _getItems[0]) === null || _getItems === void 0 ? void 0 : _getItems.children : /*#__PURE__*/_react["default"].createElement(_MyEmpty["default"], null)), /*#__PURE__*/_react["default"].createElement(_MapLayer["default"], null));
}
Result.propTypes = {
  show: _propTypes["default"].bool,
  onClose: _propTypes["default"].func
};
//# sourceMappingURL=Result.js.map
