"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _upload = _interopRequireDefault(require("antd/lib/upload"));
var _button = _interopRequireDefault(require("antd/lib/button"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
var _index = require("@ant-design/icons/es/index");
require("./index.less");
var _excluded = ["fileList", "matter", "action", "accept", "authorization", "tenantId", "text", "hintStyle", "flag", "style"];
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
var antUpload = function antUpload(_ref) {
  var fileList = _ref.fileList,
    matter = _ref.matter,
    action = _ref.action,
    accept = _ref.accept,
    authorization = _ref.authorization,
    tenantId = _ref.tenantId,
    text = _ref.text,
    hintStyle = _ref.hintStyle,
    flag = _ref.flag,
    style = _ref.style,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _style = style || {};
  // _style['height'] = _style['height'] ? _style['height'] : '30px';
  // _style['width'] = _style['width'] ? _style['width'] : '300px';
  var _otherProps = otherProps || {};
  _otherProps.style = _style;
  var props = {
    label: "文件上传",
    name: "file",
    title: "上传文件",
    action: action,
    accept: accept,
    headers: {
      Authorization: "Bearer " + authorization,
      'TENANT-ID': tenantId
    },
    fileList: fileList
    // onChange(info) {
    //   console.log(info.file, info.fileList, 5555555555555);
    //   if (info.file.status !== 'uploading') {
    //   }
    //   if (info.file.status === 'done') {
    //     message.success(`${info.file.name} file uploaded successfully`);
    //   } else if (info.file.status === 'error') {
    //     message.error(`${info.file.name} file upload failed.`);
    //   }
    // },
  };

  var yangshi = {
    fontSize: hintStyle.size,
    color: hintStyle.color,
    fontWeight: hintStyle.weight
  };
  return /*#__PURE__*/React.createElement("div", {
    style: {
      width: '100%',
      display: flag ? 'none' : ''
    }
  }, /*#__PURE__*/React.createElement(_upload["default"], (0, _extends2["default"])({}, props, _otherProps), /*#__PURE__*/React.createElement(_button["default"], {
    style: (0, _extends2["default"])({}, _otherProps.style),
    icon: /*#__PURE__*/React.createElement(_index.UploadOutlined, null)
  }, matter), /*#__PURE__*/React.createElement("span", {
    style: (0, _extends2["default"])({}, yangshi, {
      verticalAlign: 'bottom',
      marginLeft: '10px'
    })
  }, text)));
};
antUpload.displayName = 'antUpload';
var _default = antUpload;
exports["default"] = _default;