"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"), _typeof = require("@babel/runtime/helpers/typeof");

Object.defineProperty(exports, "__esModule", {
  value: !0
}), exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")), _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck")), _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass")), _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized")), _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits")), _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn")), _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf")), _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")), _react = _interopRequireWildcard(require("react")), _propTypes = _interopRequireDefault(require("prop-types")), _processor = require("./../../common/utils/processor"), _amosAntd = require("amos-antd");

function _getRequireWildcardCache(e) {
  if ("function" != typeof WeakMap) return null;
  var t = new WeakMap, r = new WeakMap;
  return (_getRequireWildcardCache = function(e) {
    return e ? r : t;
  })(e);
}

function _interopRequireWildcard(e, t) {
  if (!t && e && e.__esModule) return e;
  if (null === e || "object" !== _typeof(e) && "function" != typeof e) return {
    default: e
  };
  var r = _getRequireWildcardCache(t);
  if (r && r.has(e)) return r.get(e);
  var a = {}, s = Object.defineProperty && Object.getOwnPropertyDescriptor;
  for (var l in e) if ("default" !== l && Object.prototype.hasOwnProperty.call(e, l)) {
    var n = s ? Object.getOwnPropertyDescriptor(e, l) : null;
    n && (n.get || n.set) ? Object.defineProperty(a, l, n) : a[l] = e[l];
  }
  return a.default = e, r && r.set(e, a), a;
}

function _createSuper(e) {
  var t = _isNativeReflectConstruct();
  return function() {
    var r, a = (0, _getPrototypeOf2.default)(e);
    if (t) {
      var s = (0, _getPrototypeOf2.default)(this).constructor;
      r = Reflect.construct(a, arguments, s);
    } else r = a.apply(this, arguments);
    return (0, _possibleConstructorReturn2.default)(this, r);
  };
}

function _isNativeReflectConstruct() {
  if ("undefined" == typeof Reflect || !Reflect.construct) return !1;
  if (Reflect.construct.sham) return !1;
  if ("function" == typeof Proxy) return !0;
  try {
    return Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], (function() {}))), 
    !0;
  } catch (e) {
    return !1;
  }
}

var FormItem = _amosAntd.Form.Item, dataToTree = function e() {
  var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : [];
  t.map((function(t) {
    t.label = t.text, t.key = t.id, t.value = t.id, t.children && e(t.children);
  }));
}, EditPassword = function(e) {
  (0, _inherits2.default)(r, e);
  var t = _createSuper(r);
  function r(e) {
    var a;
    return (0, _classCallCheck2.default)(this, r), a = t.call(this, e), (0, _defineProperty2.default)((0, 
    _assertThisInitialized2.default)(a), "checkPassword", (function(e, t, r) {
      var s = a.props.parentform.getFieldValue;
      s("originalPassword") ? t ? _processor.AmosValidate.isPassword(t) ? t === s("originalPassword") ? r("新密码和原始密码不能相同！") : r() : r("请输入正确的密码格式！") : r() : r("请先输入原始密码！");
    })), (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(a), "checkRePassword", (function(e, t, r) {
      var s = a.props.parentform.getFieldValue;
      t && t !== s("newPassword") ? r("两次输入密码不一致！") : r();
    })), a.state = {}, a;
  }
  return (0, _createClass2.default)(r, [ {
    key: "render",
    value: function() {
      var e = this.props, t = e.parentform, r = e.submit, a = t.getFieldProps, s = a("originalPassword", {
        rules: [ {
          required: !0,
          message: "请输入原密码"
        }, {
          validator: this.checkOriginalPassword
        } ]
      }), l = a("newPassword", {
        rules: [ {
          required: !0,
          message: "请输入新密码"
        }, {
          validator: this.checkPassword
        } ]
      }), n = a("newConfirmPassword", {
        rules: [ {
          required: !0,
          message: "请输入确认密码"
        }, {
          validator: this.checkRePassword
        } ]
      }), i = {
        labelCol: {
          span: 7
        },
        wrapperCol: {
          span: 16
        }
      };
      return _react.default.createElement("div", {
        className: "user-add-edit amos-grid-from"
      }, _react.default.createElement(_amosAntd.Form, {
        inline: !0,
        onSubmit: r
      }, _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 12
      }, _react.default.createElement(FormItem, (0, _extends2.default)({
        label: "原始密码"
      }, i), _react.default.createElement(_amosAntd.Input, (0, _extends2.default)({
        className: "amos-grid-form-input",
        type: "password"
      }, s, {
        style: {
          width: 240
        }
      }))))), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 12
      }, _react.default.createElement(FormItem, (0, _extends2.default)({
        label: "新密码"
      }, i), _react.default.createElement(_amosAntd.Input, (0, _extends2.default)({
        className: "amos-grid-form-input",
        type: "password"
      }, l, {
        style: {
          width: 240
        }
      }))))), _react.default.createElement(_amosAntd.Row, null, _react.default.createElement(_amosAntd.Col, {
        span: 12
      }, _react.default.createElement(FormItem, (0, _extends2.default)({
        label: "确认密码"
      }, i), _react.default.createElement(_amosAntd.Input, (0, _extends2.default)({
        className: "amos-grid-form-input"
      }, n, {
        type: "password",
        style: {
          width: 240
        }
      })))))));
    }
  } ]), r;
}(_react.Component);

EditPassword.displayName = "EditPassword", EditPassword.propTypes = {
  user: _propTypes.default.object,
  submit: _propTypes.default.func,
  cancel: _propTypes.default.func,
  parentform: _propTypes.default.any
}, EditPassword.defaultProps = {};

var _default = EditPassword;

exports.default = _default;