"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"] = Sbxl;
var _react = _interopRequireWildcard(require("react"));
var _index = require("../../index");
require("./index.less");
var _antd = require("antd");
var _ahooks = require("ahooks");
var _SBYXQK = _interopRequireDefault(require("./SBYXQK"));
var _SBXLFX = _interopRequireDefault(require("./SBXLFX"));
var _vmTable = _interopRequireDefault(require("../../../vm-table"));
var _api = require("../../api");
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 _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; }
var TabPane = _antd.Tabs.TabPane;
function Sbxl() {
  var _useContext = (0, _react.useContext)(_index.PumpContext),
    prefix = _useContext.prefix,
    id = _useContext.id;
  var _useSetState = (0, _ahooks.useSetState)({
      areaList: [],
      activeTab: '',
      waterPumpList: []
    }),
    _useSetState2 = _slicedToArray(_useSetState, 2),
    state = _useSetState2[0],
    setState = _useSetState2[1];
  var activeTab = state.activeTab,
    areaList = state.areaList,
    waterPumpList = state.waterPumpList;
  //水泵信息
  var sbColumns = [{
    title: '水泵名称',
    dataIndex: 'name',
    key: 'name',
    width: 100
  }, {
    title: '水泵类型',
    dataIndex: 'facilityClassName',
    key: 'facilityClassName',
    width: 100
  }, {
    title: '型号',
    dataIndex: 'model',
    key: 'model',
    width: 100
  }, {
    title: '厂家',
    dataIndex: 'manufactor',
    key: 'manufactor',
    width: 100
  }, {
    title: '出厂日期',
    dataIndex: 'outFactoryDate',
    key: 'outFactoryDate',
    width: 100
  }, {
    title: '额定扬程(m)',
    dataIndex: 'ratedHead',
    key: 'ratedHead',
    width: 120
  }, {
    title: '额定功率(kW)',
    dataIndex: 'ratedPower',
    key: 'ratedPower',
    width: 120
  }, {
    title: '额定流量(m³/h)',
    dataIndex: 'ratedFlowRate',
    key: 'ratedFlowRate',
    width: 150
  }, {
    title: '转速(r/min)',
    dataIndex: 'speed',
    key: 'speed',
    width: 100
  }, {
    title: '状态',
    dataIndex: 'facilityStatusName',
    key: 'facilityStatusName',
    width: 100
  }];
  (0, _react.useEffect)(function () {
    _api.SbxlService.jyqInfo(id).then(function (data) {
      var _a;
      setState({
        areaList: data || [],
        activeTab: data && data.length ? (_a = data[0].detail) === null || _a === void 0 ? void 0 : _a.deviceId : '',
        waterPumpList: data && data.length ? data[0].waterPumpList : []
      });
    });
  }, []);
  return /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-sbxl")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-sbxl-tab")
  }, /*#__PURE__*/_react["default"].createElement(_antd.Tabs, {
    activeKey: activeTab,
    onChange: function onChange(e) {
      var _a;
      setState({
        activeTab: e,
        waterPumpList: ((_a = areaList.find(function (item) {
          return item.id === e;
        })) === null || _a === void 0 ? void 0 : _a.waterPumpList) || []
      });
    },
    style: {
      background: '#FFFFFF'
    }
  }, areaList.map(function (item) {
    var _a;
    var tab = "".concat(item.code, "(").concat((_a = item === null || item === void 0 ? void 0 : item.detail) === null || _a === void 0 ? void 0 : _a.areaName, ")");
    var key = item.id;
    return /*#__PURE__*/_react["default"].createElement(TabPane, {
      tabKey: key,
      key: key,
      tab: tab
    });
  }))), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-sbxl-main")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-sbxl-main-top")
  }, /*#__PURE__*/_react["default"].createElement(_SBYXQK["default"], {
    facilityId: id,
    prefix: prefix,
    deviceId: activeTab
  }), /*#__PURE__*/_react["default"].createElement(_SBXLFX["default"], {
    facilityId: id,
    prefix: prefix,
    deviceId: activeTab
  })), /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-sbxl-main-bottom")
  }, /*#__PURE__*/_react["default"].createElement("div", {
    className: "".concat(prefix, "-sbxl-main-bottom-title")
  }, "\u6C34\u6CF5\u4FE1\u606F"), /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      width: '100%',
      padding: 20
    }
  }, /*#__PURE__*/_react["default"].createElement("div", {
    style: {
      width: '100%'
    }
  }, /*#__PURE__*/_react["default"].createElement(_vmTable["default"], {
    pagination: false,
    columns: sbColumns,
    dataSource: waterPumpList,
    height: 300
  }))))));
}
//# sourceMappingURL=index.js.map
