"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports["default"] = void 0;
var _vtxFormLayout = _interopRequireDefault(require("@vtx/components/lib/vtx-form-layout"));
var _react = _interopRequireWildcard(require("react"));
var _inputNumber = _interopRequireDefault(require("antd/lib/input-number"));
var _table = _interopRequireDefault(require("antd/lib/table"));
var _ConfigModalWrap = _interopRequireDefault(require("../ConfigModalWrap"));
var _utils = require("@vtx/utils");
var _request = _interopRequireDefault(require("../../../_mapUtil/request"));
var _antd = require("antd");
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 _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
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 _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
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 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(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(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); }
var FormContent = function FormContent(props) {
  var value = props.value,
    _onChange = props.onChange;
  var columns = [{
    title: '降水强度',
    dataIndex: 'alias',
    key: 'alias',
    align: 'center'
  }, {
    title: '12小时降水量（mm）',
    dataIndex: 'num12',
    key: 'num12',
    align: 'center'
  }, {
    title: '24小时降水量（mm）',
    dataIndex: 'num24',
    key: 'num24',
    align: 'center'
  }, {
    title: '影响时长（小时）',
    dataIndex: 'influenceHour',
    key: 'influenceHour',
    align: 'center',
    render: function render(val, record) {
      return /*#__PURE__*/_react["default"].createElement(_inputNumber["default"], {
        value: val,
        placeholder: "\u8BF7\u8F93\u5165",
        onChange: function onChange(e) {
          _onChange && _onChange(value.map(function (item) {
            if (item.alias == record.alias) {
              return _objectSpread(_objectSpread({}, item), {}, {
                influenceHour: e
              });
            }
            return item;
          }));
        }
      });
    }
  }];
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_table["default"], {
    dataSource: value,
    columns: columns,
    pagination: false,
    bordered: true,
    rowKey: 'alias'
  }));
};
var JYYXSC = function JYYXSC(props) {
  var onFinish = function onFinish(values) {
    var _values$jyyxsCRules;
    var url = '/cloud/zhsw-znfx/api/gisAnalyze/saveRainInfluenceHours';
    _request["default"].post(url, {
      body: (values === null || values === void 0 || (_values$jyyxsCRules = values.jyyxsCRules) === null || _values$jyyxsCRules === void 0 ? void 0 : _values$jyyxsCRules.map(function (item) {
        return {
          rainLevel: item.rainLevel,
          influenceHour: item.influenceHour
        };
      })) || []
    }).then(function (res) {
      if (res.result == 0) {
        props.onCancel();
        _antd.message.success('操作成功');
      }
    })["catch"](function () {});
  };
  var _Form$useForm = _antd.Form.useForm(),
    _Form$useForm2 = _slicedToArray(_Form$useForm, 1),
    form = _Form$useForm2[0];
  (0, _react.useEffect)(function () {
    _request["default"].get('/cloud/zhsw-znfx/api/gisAnalyze/getRainInfluenceHours', {
      body: {
        tenantId: (0, _utils.getUrlParam)('tenantId')
      }
    }).then(function (res) {
      if (res.result == 0) {
        var _res$data;
        form.setFieldsValue({
          jyyxsCRules: (_res$data = res.data) === null || _res$data === void 0 ? void 0 : _res$data.map(function (item) {
            return {
              alias: item.alias,
              num12: item.min12 && item.max12 ? item.min12 + '~' + item.max12 : !item.min12 && item.max12 ? '<' + item.max12 : '>' + item.min12,
              num24: item.min24 && item.max24 ? item.min24 + '~' + item.max24 : !item.min24 && item.max24 ? '<' + item.max24 : '>' + item.min24,
              influenceHour: item.influenceHour,
              rainLevel: item.rainLevel
            };
          })
        });
      }
    })["catch"](function () {});
  }, []);
  return /*#__PURE__*/_react["default"].createElement(_ConfigModalWrap["default"], _extends({}, props, {
    onFinish: onFinish,
    form: form
  }), /*#__PURE__*/_react["default"].createElement(_vtxFormLayout["default"], {
    cols: 1
  }, /*#__PURE__*/_react["default"].createElement(_vtxFormLayout["default"].FormItem, {
    name: "jyyxsCRules"
  }, /*#__PURE__*/_react["default"].createElement(FormContent, null))));
};
var _default = exports["default"] = JYYXSC;
//# sourceMappingURL=JYYXSC.js.map
