"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _form = _interopRequireDefault(require("@alifd/next/lib/form"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _switch = _interopRequireDefault(require("@alifd/next/lib/switch"));
var _rating = _interopRequireDefault(require("@alifd/next/lib/rating"));
var _timePicker = _interopRequireDefault(require("@alifd/next/lib/time-picker2"));
var _numberPicker = _interopRequireDefault(require("@alifd/next/lib/number-picker"));
var _datePicker = _interopRequireDefault(require("@alifd/next/lib/date-picker2"));
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
var _inheritsLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/inheritsLoose"));
var _react = _interopRequireDefault(require("react"));
require("./index.scss");
//这是表单项组件
var FormItem = /*#__PURE__*/function (_React$Component) {
  (0, _inheritsLoose2["default"])(FormItem, _React$Component);
  function FormItem(props) {
    var _this;
    _this = _React$Component.call(this, props) || this;
    // 控件类型
    _this.renderColumns = function () {
      var _this$props = _this.props,
        componentType = _this$props.componentType,
        placeholder = _this$props.placeholder,
        defaultValue = _this$props.defaultValue;
      if (componentType === 'Input') {
        return /*#__PURE__*/_react["default"].createElement(_input["default"], {
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'DatePicker') {
        return /*#__PURE__*/_react["default"].createElement(_datePicker["default"], {
          outputFormat: "YYYY-MM-DD",
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'TextArea') {
        return /*#__PURE__*/_react["default"].createElement(_input["default"].TextArea, {
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'NumberPicker') {
        return /*#__PURE__*/_react["default"].createElement(_numberPicker["default"], {
          defaultValue: defaultValue
        });
      }
      if (componentType === 'TimePicker') {
        return /*#__PURE__*/_react["default"].createElement(_timePicker["default"], {
          placeholder: placeholder,
          defaultValue: defaultValue
        });
      }
      if (componentType === 'Rating') {
        return /*#__PURE__*/_react["default"].createElement(_rating["default"], {
          defaultValue: defaultValue
        });
      }
      if (componentType === 'Switch') {
        return /*#__PURE__*/_react["default"].createElement(_switch["default"], {
          defaultChecked: defaultValue
        });
      }
      return /*#__PURE__*/_react["default"].createElement(_input["default"], {
        placeholder: placeholder,
        defaultValue: defaultValue
      });
    };
    return _this;
  }
  var _proto = FormItem.prototype;
  _proto.render = function render() {
    var _this$props2 = this.props,
      displayName = _this$props2.displayName,
      isPreview = _this$props2.isPreview,
      fieldName = _this$props2.fieldName,
      style = _this$props2.style,
      isEdit = _this$props2.isEdit,
      isEmpty = _this$props2.isEmpty,
      extraText = _this$props2.extraText;
    // 表单项
    var formItemLayoutItem = {
      labelCol: {
        span: 8
      },
      wrapperCol: {
        span: 14
      }
    };
    return /*#__PURE__*/_react["default"].createElement(_form["default"].Item, (0, _extends2["default"])({
      style: style,
      colon: true,
      name: fieldName
    }, formItemLayoutItem, {
      help: extraText,
      isPreview: !isPreview,
      required: isEmpty,
      disabled: isEdit,
      labelAlign: "left",
      label: displayName,
      requiredMessage: "\u8BF7\u8F93\u5165" + displayName
    }), this.renderColumns());
  };
  return FormItem;
}(_react["default"].Component);
FormItem.displayName = void 0;
var _default = FormItem;
exports["default"] = _default;