"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 _button = _interopRequireDefault(require("antd/lib/button"));
var _message = _interopRequireDefault(require("antd/lib/message"));
var _Table = _interopRequireDefault(require("../_component/Table"));
var _CustomModal = _interopRequireDefault(require("../_component/CustomModal"));
var _request = _interopRequireDefault(require("../_mapUtil/request"));
var _config = _interopRequireDefault(require("../_mapUtil/config"));
var _useProps2 = _interopRequireDefault(require("@vtx/ol-map/lib/use-props"));
var _YJZXResult = _interopRequireDefault(require("./YJZXResult"));
var _propTypes = _interopRequireDefault(require("prop-types"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
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 && {}.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 ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _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(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
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(r) { if (Array.isArray(r)) return r; } /*
 * @description: 爆管关阀分析
 */
function Result(props) {
  var _useProps = (0, _useProps2["default"])(),
    map = _useProps.map,
    layerRef = _useProps.layerRef;
  var _props$setVisible = props.setVisible,
    setVisible = _props$setVisible === void 0 ? function () {} : _props$setVisible,
    _props$yjfxData = props.yjfxData,
    yjfxData = _props$yjfxData === void 0 ? [] : _props$yjfxData,
    _props$setType = props.setType,
    setType = _props$setType === void 0 ? function () {} : _props$setType,
    _props$getData = props.getData,
    getData = _props$getData === void 0 ? function () {} : _props$getData,
    _props$expandData = props.expandData,
    expandData = _props$expandData === void 0 ? [] : _props$expandData,
    _props$setExpandData = props.setExpandData,
    setExpandData = _props$setExpandData === void 0 ? function () {} : _props$setExpandData,
    _props$type = props.type,
    type = _props$type === void 0 ? '' : _props$type,
    _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$dataSource = props.dataSource,
    dataSource = _props$dataSource === void 0 ? [] : _props$dataSource;
  var _useState = (0, _react.useState)(false),
    _useState2 = _slicedToArray(_useState, 2),
    expandLoading = _useState2[0],
    setExpandLoading = _useState2[1];
  var _useState3 = (0, _react.useState)(''),
    _useState4 = _slicedToArray(_useState3, 2),
    currentKey = _useState4[0],
    setCurrentKey = _useState4[1];
  var getExpandData = function getExpandData(code) {
    setExpandLoading(true);
    var url = "".concat(_config["default"].publicUrlZNFX, "/api/gisAnalyze/detonationPointAnalysis");
    var params = {
      lineType: 2,
      // 1 污水 2 供水
      pointCode: code
    };
    _request["default"].post(url, {
      body: params
    }).then(function (res) {
      setExpandLoading(false);
      if ((res === null || res === void 0 ? void 0 : res.result) === 0 && res !== null && res !== void 0 && res.data) {
        var data = res.data.map(function (v) {
          return _objectSpread(_objectSpread({}, v), {}, {
            key: v.code
          });
        });
        setExpandData(data);
      } else {
        _message["default"].warning('暂无数据！');
      }
    })["catch"](function () {
      setExpandLoading(false);
    });
  };
  var classnames = function classnames(name) {
    if (name) {
      return "blowout-valve-closing-analysis-".concat(name);
    }
    return "blowout-valve-closing-analysis";
  };
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, type === 'gffx' ? /*#__PURE__*/_react["default"].createElement(_CustomModal["default"], {
    title: "\u7206\u7BA1\u5206\u6790",
    map: map,
    onCancel: function onCancel() {
      try {
        map.hideTemplate();
      } catch (err) {}
      setVisible(false);
    },
    visible: visible
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: classnames('title')
  }, "\u9700\u8981\u5173\u95ED\u9600\u95E8"), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
    columns: [{
      title: '阀门编码',
      dataIndex: 'code',
      width: 100,
      render: function render(text, record) {
        return /*#__PURE__*/_react["default"].createElement("a", {
          onClick: function onClick() {
            var _layerRef$current, _layerRef$current2;
            (layerRef === null || layerRef === void 0 ? void 0 : layerRef.current) && (layerRef === null || layerRef === void 0 || (_layerRef$current = layerRef.current) === null || _layerRef$current === void 0 ? void 0 : _layerRef$current.setCenter(text));
            var selectFeature = layerRef === null || layerRef === void 0 || (_layerRef$current2 = layerRef.current) === null || _layerRef$current2 === void 0 ? void 0 : _layerRef$current2.selectFeature;
            if (selectFeature) map === null || map === void 0 || map.showTemplate(selectFeature);
          }
        }, text);
      }
    }, {
      title: '口径(mm)',
      dataIndex: 'ds',
      width: 100,
      render: function render(text) {
        return text || String(text) ? text : '--';
      }
    }, {
      title: '所在道路',
      dataIndex: 'roadName',
      width: 150
    }],
    loading: loading,
    dataSource: dataSource,
    rowSelection: {
      type: 'radio',
      onChange: function onChange(selectedRowKeys) {
        setCurrentKey(selectedRowKeys);
      }
    },
    rowKey: "code"
  }), dataSource !== null && dataSource !== void 0 && dataSource.length ? /*#__PURE__*/_react["default"].createElement("div", {
    className: classnames('btn')
  }, /*#__PURE__*/_react["default"].createElement(_button["default"], {
    type: "primary",
    size: "small",
    disabled: !currentKey,
    onClick: function onClick() {
      if (currentKey) {
        setExpandData([]);
        getExpandData(currentKey[0]);
      } else {
        _message["default"].warning('请先在需要关闭阀门列表中勾选失效阀门！', 2);
      }
    }
  }, "\u6269\u5927\u5173\u9600")) : null, expandData !== null && expandData !== void 0 && expandData.length ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("div", {
    className: classnames('title')
  }, "\u9700\u8981\u6269\u5927\u5173\u95ED\u7684\u9600\u95E8"), /*#__PURE__*/_react["default"].createElement(_Table["default"], {
    columns: [{
      title: '阀门编码',
      dataIndex: 'code',
      width: 100,
      render: function render(text) {
        return /*#__PURE__*/_react["default"].createElement("a", {
          onClick: function onClick() {
            var _layerRef$current3, _layerRef$current4;
            (layerRef === null || layerRef === void 0 ? void 0 : layerRef.current) && (layerRef === null || layerRef === void 0 || (_layerRef$current3 = layerRef.current) === null || _layerRef$current3 === void 0 ? void 0 : _layerRef$current3.setCenter(text));
            var selectFeature = layerRef === null || layerRef === void 0 || (_layerRef$current4 = layerRef.current) === null || _layerRef$current4 === void 0 ? void 0 : _layerRef$current4.selectFeature;
            if (selectFeature) map === null || map === void 0 || map.showTemplate(selectFeature);
          }
        }, text);
      }
    }, {
      title: '口径(mm)',
      dataIndex: 'ds',
      width: 100,
      render: function render(text) {
        return text || String(text) ? text : '--';
      }
    }],
    loading: expandLoading,
    dataSource: expandData,
    rowKey: "code",
    scroll: {
      y: 400,
      x: 200
    }
  })) : null) : /*#__PURE__*/_react["default"].createElement(_YJZXResult["default"], {
    setVisible: setVisible,
    highlight: layerRef,
    visible: visible,
    getData: getData,
    yjfxData: yjfxData,
    setType: setType
  }));
}
Result.propTypes = {
  setVisible: _propTypes["default"].func,
  yjfxData: _propTypes["default"].array,
  setType: _propTypes["default"].string,
  getData: _propTypes["default"].func,
  expandData: _propTypes["default"].array,
  setExpandData: _propTypes["default"].func,
  type: _propTypes["default"].string,
  visible: _propTypes["default"].bool,
  loading: _propTypes["default"].bool,
  dataSource: _propTypes["default"].array
};
//# sourceMappingURL=Result.js.map
