"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _react = _interopRequireWildcard(require("react"));
var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
var _Table = _interopRequireDefault(require("../../_component/Table"));
var _getUrlParam = _interopRequireDefault(require("@vtx/utils/lib/getUrlParam"));
var _ahooks = require("ahooks");
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 _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); }
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread 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 _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
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 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); } /**
 * @returns 纵截面分析结果弹窗
 */
var systemCode = (0, _getUrlParam["default"])('code'); // 项目

// 材质
var texture = [{
  value: '1',
  label: '混凝土管'
}, {
  value: '2',
  label: '钢筋混凝土管'
}, {
  value: '3',
  label: '陶土管'
}, {
  value: '4',
  label: 'PE(聚乙烯)管 '
}, {
  value: '5',
  label: 'HDPE(高密度聚乙烯)管'
}, {
  value: '6',
  label: 'UPVC管'
}, {
  value: '7',
  label: '铸铁管'
}, {
  value: '8',
  label: '玻璃钢夹砂管'
}, {
  value: '9',
  label: '钢管'
}, {
  value: '10',
  label: '石棉水泥管'
}, {
  value: '11',
  label: '其他'
}];

// 管道类别
var getTypeLine = function getTypeLine(line) {
  var list = {
    1: '雨水',
    2: '污水',
    3: '雨污合流'
  };
  var type = systemCode === 'yc' ? (list === null || list === void 0 ? void 0 : list[line === null || line === void 0 ? void 0 : line.netType]) || '' : line.netType == 4 ? '供水' : '污水';
  return type;
};

// 获取材质名称
var getTextureName = function getTextureName(value) {
  var list = texture.find(function (val) {
    return val.value == value;
  }) || {};
  return list === null || list === void 0 ? void 0 : list.label;
};
function ProfileModal(props) {
  var ref = (0, _react.useRef)(null);
  var size = (0, _ahooks.useSize)(ref);
  var _props$modalData = props.modalData,
    modalData = _props$modalData === void 0 ? [] : _props$modalData,
    _onClick = props.onClick;
  var getOption = function getOption() {
    var series = [];
    var totalDistance = 2;
    var yMin = 0;
    var chartData = [],
      xAxisData = [];
    modalData.map(function (val, index) {
      var _val$line = val.line,
        line = _val$line === void 0 ? {} : _val$line,
        _val$startPoint = val.startPoint,
        startPoint = _val$startPoint === void 0 ? {} : _val$startPoint,
        _val$endPoint = val.endPoint,
        endPoint = _val$endPoint === void 0 ? {} : _val$endPoint;
      var datas = [];
      if (index === modalData.length - 1) {
        datas = [_objectSpread({
          groundElevation: startPoint.groundElevation,
          bottomElevation: startPoint.pointTopElevation,
          deep: startPoint.deep
        }, line), _objectSpread({
          groundElevation: endPoint.groundElevation,
          bottomElevation: endPoint.pointTopElevation,
          deep: endPoint.deep
        }, line)];
      } else {
        datas = [_objectSpread({
          groundElevation: startPoint.groundElevation,
          bottomElevation: startPoint.pointTopElevation,
          deep: startPoint.deep
        }, line)];
      }
      chartData.push.apply(chartData, _toConsumableArray(datas));
    });
    chartData && chartData.length && chartData.map(function (item, idx) {
      // xAxisData.push(item.code);
      series.push(item.groundElevation);
      var _space = item.space === 'NaN' ? 0 : item.space || 0;
      var _data = ((xAxisData[idx] || 0) + _space).toFixed(2);
      xAxisData.push(_data);
      if (idx === 0) {
        yMin = item.groundElevation;
      } else {
        if (item.groundElevation < yMin) {
          yMin = item.groundElevation;
        }
      }
      totalDistance += _space;
    });
    return {
      grid: {
        left: 30,
        right: 30,
        top: 30,
        bottom: 20
      },
      tooltip: {
        trigger: 'item',
        axisPointer: {
          type: 'cross'
        },
        confine: true,
        // backgroundColor: 'transparent',
        padding: 0,
        formatter: function formatter(_ref) {
          var dataIndex = _ref.dataIndex;
          return "<div class=\"corssTooltip\">\n                                <div>\u7BA1\u9876\u6807\u9AD8(m)\uFF1A".concat(chartData[dataIndex].bottomElevation || '', "</div>\n                                <div>\u57CB\u6DF1(m)\uFF1A").concat(chartData[dataIndex].deep || '', "</div>\n                                <div>\u5730\u9762\u9AD8\u7A0B(m)\uFF1A").concat(chartData[dataIndex].groundElevation || '', "</div>\n                                <div>\u7BA1\u9053\u6807\u8BC6\u7801\uFF1A").concat(chartData[dataIndex].code || '', "</div>\n                                <div>\u7BA1\u9053\u7C7B\u522B\uFF1A").concat(getTypeLine(chartData === null || chartData === void 0 ? void 0 : chartData[dataIndex]), "</div>\n                                <div>\u7BA1\u9053\u957F\u5EA6(m)\uFF1A").concat(chartData[dataIndex].lineLength || '', "</div>\n                                <div>\u89C4\u683C(mm)\uFF1A").concat(chartData[dataIndex].ds || '', "</div>\n                                <div>\u6750\u8D28\uFF1A").concat(chartData[dataIndex].lineTexture && getTextureName(chartData[dataIndex].lineTexture) || '', "</div>\n                            </div>");
        }
      },
      xAxis: {
        name: '米',
        // min: 0,
        // max: parseInt(totalDistance),
        axisTick: {
          show: false
        },
        splitLine: {
          show: false
        },
        scale: true,
        axisLine: {
          onZero: false
        },
        data: xAxisData
      },
      yAxis: {
        name: '米',
        axisTick: {
          show: false
        },
        splitLine: {
          show: false
        },
        axisLine: {
          show: true,
          onZero: false
        }
      },
      series: [{
        type: 'line',
        data: series,
        itemStyle: {
          color: '#009BFF'
        },
        emphasis: {
          itemStyle: {
            color: 'red'
          }
        }
      }]
    };
  };
  function renderChart() {
    return /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
      option: getOption(),
      style: {
        height: 240
      }
    });
  }
  function renderTable() {
    var columns = [{
      title: '管线编码',
      dataIndex: 'name',
      key: 'name',
      width: 100,
      fixed: 'left'
    }];
    var dataSource = [];

    // 表格展示数据

    var type = {
      name: '管线类别'
    };
    var lineLength = {
      name: '管长(m)'
    };
    var groundElevation = {
      name: '起点地面高程(m)'
    };
    var endZ = {
      name: '终点地面高程(m)'
    };
    var bottomElevation = {
      name: '起点管顶高程(m)'
    };
    var pointTopElevation = {
      name: '终点管底高程(m)'
    };
    var startDeep = {
      name: '起点埋深(m)'
    };
    var endDeep = {
      name: '终点埋深(m)'
    };
    var lineTexture = {
      name: '管材'
    };
    var ds = {
      name: '管径(mm)'
    };
    var roadName = {
      name: '所在道路'
    };
    var infoTime = {
      name: '数据获取时间'
    };
    var orgName = {
      name: '管理单位'
    };
    if (modalData !== null && modalData !== void 0 && modalData.length) {
      modalData.map(function (item) {
        var _item$line = item.line,
          line = _item$line === void 0 ? {} : _item$line,
          _item$startPoint = item.startPoint,
          startPoint = _item$startPoint === void 0 ? {} : _item$startPoint,
          _item$endPoint = item.endPoint,
          endPoint = _item$endPoint === void 0 ? {} : _item$endPoint;
        columns.push({
          title: /*#__PURE__*/_react["default"].createElement("a", {
            onClick: function onClick() {
              _onClick && _onClick(line.code);
            }
          }, line.code),
          key: line.code,
          dataIndex: line.code,
          width: 120
          // render: renderContent,
        });
        type[line.code] = getTypeLine(line);
        lineLength[line.code] = line.lineLength || '--';
        groundElevation[line.code] = startPoint.groundElevation || '--';
        endZ[line.code] = endPoint.groundElevation || '--';
        // bottomElevation[line.code] = startPoint.pointTopElevation || '--';
        // pointTopElevation[line.code] = endPoint.pointTopElevation || '--';
        bottomElevation[line.code] = line.startTopZ || '-';
        pointTopElevation[line.code] = line.endTopZ || '-';
        startDeep[line.code] = (startPoint === null || startPoint === void 0 ? void 0 : startPoint.deep) || '--';
        endDeep[line.code] = (endPoint === null || endPoint === void 0 ? void 0 : endPoint.deep) || '--';
        // lineTexture[line.code] =
        //     texture.find(tItem => tItem.value === String(line.lineTexture))?.label ??
        //     line.lineTexture;
        lineTexture[line.code] = line.lineTextureStr || '-';
        ds[line.code] = line.ds || '--';
        roadName[line.code] = line.roadName || '--';
        infoTime[line.code] = line.infoTime || '--';
        orgName[line.code] = line.manageUnitName || '--';
      });
      dataSource = [type, lineLength, groundElevation, endZ, bottomElevation, pointTopElevation, startDeep, endDeep, lineTexture, ds, roadName, infoTime, orgName];
    }
    return /*#__PURE__*/_react["default"].createElement("div", {
      ref: ref,
      style: {
        flex: 1,
        display: 'flex',
        padding: '10px 10px 0',
        overflow: 'hidden'
      }
    }, /*#__PURE__*/_react["default"].createElement(_Table["default"], {
      dataSource: dataSource,
      columns: columns,
      pagination: false,
      indexColumn: false,
      isList: true
    }));
  }
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, renderChart(), renderTable());
}
ProfileModal.propTypes = {
  modalData: _propTypes["default"].array,
  onClick: _propTypes["default"].func,
  map: _propTypes["default"].any
};
var _default = exports["default"] = ProfileModal;
//# sourceMappingURL=index.js.map
