"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 _MyEmpty = _interopRequireDefault(require("../_component/MyEmpty"));
var _popover = _interopRequireDefault(require("antd/lib/popover"));
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; } /*
 * @Description:孤立区域诊断-污水管网-结果分析弹框
 */
// 页面结果分析
function Result(props) {
  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),
    dataSource = _useState2[0],
    setDataSource = _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),
    totalData = _useState6[0],
    setTotalData = _useState6[1];
  var _useState7 = (0, _react.useState)(0),
    _useState8 = _slicedToArray(_useState7, 2),
    lineLength = _useState8[0],
    setLineLength = _useState8[1];
  var _onClick = function onClick(code) {
    _service["default"].setFieldListClick({
      record: {
        code: code
      },
      map: map,
      activeKey: activeKey,
      highLayer: highLayer
    });
  };

  // 获取数据
  (0, _react.useEffect)(function () {
    setLoading(true);
    setDataSource([]);
    setTotalData({});
    analysisLayer === null || analysisLayer === void 0 || analysisLayer.getData(activeKey, options, function (_ref) {
      var dataSource = _ref.dataSource,
        totalData = _ref.totalData,
        lineLength = _ref.lineLength;
      setDataSource(dataSource);
      setTotalData(totalData);
      setLoading(false);
      setLineLength(lineLength);
    });
  }, [analysisLayer, activeKey]);
  var columns = [{
    title: '序号',
    dataIndex: 'num',
    width: 40
  }, {
    title: '管线数量',
    dataIndex: 'total'
  }, {
    title: '管线总长(km)',
    dataIndex: 'totalLength',
    render: function render(text) {
      return /*#__PURE__*/_react["default"].createElement("div", null, Number(text / 1000).toFixed(5));
    }
  }, {
    title: '操作',
    dataIndex: 'code',
    width: 80,
    render: function render(code, obj) {
      return /*#__PURE__*/_react["default"].createElement(_popover["default"], {
        placement: "leftTop",
        content: /*#__PURE__*/_react["default"].createElement("div", {
          style: {
            width: 330,
            height: 400,
            display: 'flex'
          }
        }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
          columns: [{
            title: '管线编码',
            dataIndex: 'code',
            render: function render(_, record) {
              return /*#__PURE__*/_react["default"].createElement("a", {
                onClick: function onClick() {
                  _onClick(record === null || record === void 0 ? void 0 : record.code);
                  analysisLayer.loadLayer(obj.layer, activeKey);
                }
              }, record === null || record === void 0 ? void 0 : record.code);
            }
          }, {
            title: '管长(m)',
            dataIndex: 'length',
            "with": 90,
            render: function render(text) {
              return /*#__PURE__*/_react["default"].createElement("div", null, Number(text).toFixed(2));
            }
          }],
          dataSource: code,
          pagination: true,
          rowKey: "code"
        })),
        trigger: "click"
      }, /*#__PURE__*/_react["default"].createElement("a", null, "\u8BE6\u60C5"));
    }
  }];
  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: (totalData === null || totalData === void 0 ? void 0 : totalData.length) || 0,
            unit: '个'
          }, {
            label: '管线数量',
            value: _service["default"].getLineTotalBycode(dataSource),
            unit: '条'
          }, {
            label: '管线总长',
            value: lineLength,
            unit: 'km'
          }]
        }), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
          loading: loading,
          columns: columns,
          dataSource: dataSource,
          pagination: true,
          rowKey: "id",
          indexColumn: false
        }))
      });
    });
    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\u5E93\u4E2D\u6240\u6709\u7684\u7BA1\u7F51\u51FA\u53E3\u7BA1\u70B9\uFF0C\u5305\u62EC\uFF1A\u6392\u6C34\u53E3\u3001\u6CF5\u7AD9\u3001\u6C61\u6C34\u5382\u7B49", /*#__PURE__*/_react["default"].createElement("br", null), "2\u3001\u8BFB\u53D6\u6570\u636E\u5E93\u7BA1\u7EBF\u5C5E\u6027\u8868\u4E2D\u7684\u6D41\u5411\u5B57\u6BB5\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "3\u3001\u6839\u636E\u6D41\u5411\uFF0C\u4ECE\u5404\u4E2A\u7BA1\u7F51\u51FA\u53E3\u7BA1\u70B9\u5411\u4E0A\u6E38\u8FFD\u6EAF\uFF0C\u5C06\u6240\u6709\u7ECF\u8FC7\u7684\u7BA1\u9053\u6807\u8BB0\u4E3A\u975E\u5B64\u7ACB\u7BA1\u6BB5\uFF1B", /*#__PURE__*/_react["default"].createElement("br", null), "4\u3001\u5C06\u672A\u8FDE\u63A5\u5230\u7BA1\u7F51\u51FA\u53E3\u7684\u7BA1\u9053\u5F62\u6210\u7684\u96C6\u5408\u8BB0\u4E3A\u5B64\u7ACB\u533A\u57DF\uFF0C\u5E76\u7EDF\u8BA1\u6BCF\u4E2A\u533A\u57DF\u7684\u7BA1\u9053\u6570\u91CF\uFF0C\u540C\u65F6\u5728\u5730\u56FE\u4E2D\u7528\u4E0D\u540C\u989C\u8272\u533A\u5206\u5B64\u7ACB\u533A\u57DF\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));
}
//# sourceMappingURL=Result.js.map
