@titaui/pc 1.13.2-beta.4 → 1.13.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/lib/components/create-okr-modal/index.js +1 -4
  2. package/lib/components/dialog-upload/util.js +1 -19
  3. package/lib/components/file-list/components/single-file/index.js +1 -3
  4. package/lib/components/file-list/index.js +1 -2
  5. package/lib/components/nav-top/index.css +0 -6
  6. package/lib/components/nav-top/index.js +2 -126
  7. package/lib/components/okr-detail/schedule/components/kr-progress/index.js +4 -1
  8. package/lib/components/rich-editor/plugins/inline/color/commond.js +3 -3
  9. package/lib/components/scroll-container/index.js +6 -27
  10. package/lib/components/search-input/index.js +0 -3
  11. package/lib/components/upload/index.js +455 -261
  12. package/lib/index.js +0 -8
  13. package/lib/utils/tools.js +1 -11
  14. package/package.json +1 -1
  15. package/lib/components/checkbox-list/index.css +0 -18
  16. package/lib/components/checkbox-list/index.js +0 -66
  17. package/lib/components/dialog-qq-docs/index.css +0 -90
  18. package/lib/components/dialog-qq-docs/index.js +0 -490
  19. package/lib/components/dialog-qq-docs/request-apis.js +0 -16
  20. package/lib/components/dialog-qq-docs/utils.js +0 -80
  21. package/lib/components/dialog-select/index.css +0 -9
  22. package/lib/components/dialog-select/index.js +0 -48
  23. package/lib/components/dialog-upload/img/folder.svg +0 -40
  24. package/lib/components/dialog-upload/img/form.svg +0 -38
  25. package/lib/components/dialog-upload/img/mind.svg +0 -39
  26. package/lib/components/dialog-upload-type/assets/folder.svg +0 -20
  27. package/lib/components/dialog-upload-type/assets/qq-docs.svg +0 -20
  28. package/lib/components/dialog-upload-type/components/upload-type-item/index.css +0 -14
  29. package/lib/components/dialog-upload-type/components/upload-type-item/index.js +0 -36
  30. package/lib/components/dialog-upload-type/index.css +0 -7
  31. package/lib/components/dialog-upload-type/index.js +0 -75
  32. package/lib/components/file-preview/index.css +0 -37
  33. package/lib/components/file-preview/index.js +0 -68
  34. package/lib/components/loading/assets/loading.gif +0 -0
  35. package/lib/components/loading/index.css +0 -28
  36. package/lib/components/loading/index.js +0 -64
  37. package/lib/components/nav/index.css +0 -23
  38. package/lib/components/nav/index.js +0 -31
  39. package/lib/components/okr-guide/constant.js +0 -23
  40. package/lib/components/okr-guide/img/left-img.png +0 -0
  41. package/lib/components/okr-guide/index.css +0 -146
  42. package/lib/components/okr-guide/index.js +0 -243
  43. package/lib/components/okr-guide/request-api.js +0 -57
  44. package/lib/components/upload/upload.js +0 -566
@@ -11,27 +11,25 @@ var _react = _interopRequireWildcard(require("react"));
11
11
 
12
12
  var _titaUi = require("tita-ui");
13
13
 
14
- var _dialogUploadType = _interopRequireDefault(require("../dialog-upload-type"));
15
-
16
- var _dialogQqDocs = _interopRequireDefault(require("../dialog-qq-docs"));
17
-
18
- var _getLocale = require("../../utils/getLocale");
14
+ var _uuid = _interopRequireDefault(require("uuid"));
19
15
 
20
16
  var _Portals = _interopRequireDefault(require("../../components-v1/portals/Portals"));
21
17
 
22
- var _upload = _interopRequireDefault(require("../upload/upload"));
18
+ var _requestV = require("../../utils/request-v1");
23
19
 
24
- require("./index.css");
20
+ var _toast = _interopRequireDefault(require("../toast"));
25
21
 
26
- var _utils = require("../dialog-qq-docs/utils");
22
+ var _uploadedPreview = _interopRequireDefault(require("./components/uploadedPreview"));
27
23
 
28
- var _platform = require("../../utils/platform");
24
+ var _type = require("./type");
29
25
 
30
- var _uploadedPreview = _interopRequireDefault(require("./components/uploadedPreview"));
26
+ var _style = require("./style");
31
27
 
32
- var _tools = require("../../utils/tools");
28
+ var _imgViewer = _interopRequireDefault(require("../img-viewer"));
33
29
 
34
- var _excluded = ["children", "onlyLocal", "attachmentTipText"];
30
+ var _util = require("./util");
31
+
32
+ var _getLocale = require("../../utils/getLocale");
35
33
 
36
34
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
37
35
 
@@ -39,309 +37,505 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
39
37
 
40
38
  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; }
41
39
 
40
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
41
+
42
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
43
+
44
+ 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); }
45
+
46
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
47
+
48
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
49
+
50
+ 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; }
51
+
42
52
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
43
53
 
44
54
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
45
55
 
46
56
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
47
57
 
48
- function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
58
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
49
59
 
50
- function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
60
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
51
61
 
52
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
62
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
53
63
 
54
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
64
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
55
65
 
56
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
66
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
57
67
 
58
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
68
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
59
69
 
60
- function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
70
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
61
71
 
62
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
72
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
63
73
 
64
- 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."); }
74
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
65
75
 
66
- 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); }
76
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
67
77
 
68
- 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; }
78
+ var Upload = /*#__PURE__*/function (_PureComponent) {
79
+ _inherits(Upload, _PureComponent);
69
80
 
70
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
81
+ var _super = _createSuper(Upload);
71
82
 
72
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
83
+ function Upload(props) {
84
+ var _this;
73
85
 
74
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
86
+ _classCallCheck(this, Upload);
75
87
 
76
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
88
+ _this = _super.call(this, props);
77
89
 
78
- /** 是否开启腾讯文档选项 */
79
- var openTencentDocFile = window.BSGlobal && window.BSGlobal.TenantAdvancedSetting.TenantFunAdvancedSetting.TencentDocFile && // 默认在钉钉环境下禁用
80
- !(0, _platform.isDD)(true);
90
+ _this.onFileInputChange = function () {
91
+ var fileInput = _this.refs.fileInput; // @ts-ignore
81
92
 
82
- var onDefaultSubmit = function onDefaultSubmit() {};
93
+ var selectFiles = fileInput.files; // 选择的文件
94
+ // @ts-ignore
83
95
 
84
- var UploadMode = function UploadMode(_ref) {
85
- var children = _ref.children,
86
- _ref$onlyLocal = _ref.onlyLocal,
87
- onlyLocal = _ref$onlyLocal === void 0 ? !openTencentDocFile : _ref$onlyLocal,
88
- _ref$attachmentTipTex = _ref.attachmentTipText,
89
- attachmentTipText = _ref$attachmentTipTex === void 0 ? (0, _getLocale.getLocale)('OKR_MyO_KRP_Draganddropu') : _ref$attachmentTipTex,
90
- restProps = _objectWithoutProperties(_ref, _excluded);
96
+ if (!fileInput.value) return; // 未选择文件或选择文件超出个数限制时
91
97
 
92
- var _useState = (0, _react.useState)(),
93
- _useState2 = _slicedToArray(_useState, 2),
94
- defaultQQDocsData = _useState2[0],
95
- setDefaultQQDocsData = _useState2[1]; // 区分存储腾讯文档数据和本地文件
98
+ _this.dealSelectFiles(Array.from(selectFiles));
96
99
 
100
+ if (fileInput) {
101
+ // @ts-ignore
102
+ fileInput.value = '';
103
+ }
104
+ };
105
+
106
+ _this.dealSelectFiles = function (uploadSelectFilesObj) {
107
+ var _this$state = _this.state,
108
+ uploadSuccessFiles = _this$state.uploadSuccessFiles,
109
+ selectFiles = _this$state.selectFiles;
110
+ var _this$props = _this.props,
111
+ action = _this$props.action,
112
+ fileNumLimit = _this$props.fileNumLimit,
113
+ fileSizeLimit = _this$props.fileSizeLimit,
114
+ filesTotal = _this$props.filesTotal;
115
+ var uploadSelectFilesLen = uploadSelectFilesObj.length; // 选中上传的文件数量
116
+
117
+ var uploadSuccessFilesLen = uploadSuccessFiles.length; // 已上传成功的文件数量
97
118
 
98
- var _useState3 = (0, _react.useState)([]),
99
- _useState4 = _slicedToArray(_useState3, 2),
100
- qqFileData = _useState4[0],
101
- setQQFileData = _useState4[1];
119
+ var allFilesTotal = uploadSuccessFilesLen + uploadSelectFilesLen; // 把文件字节流保存,用来文件重传用
102
120
 
103
- var _useState5 = (0, _react.useState)([]),
104
- _useState6 = _slicedToArray(_useState5, 2),
105
- localFileData = _useState6[0],
106
- setLocalFileData = _useState6[1];
121
+ uploadSelectFilesObj.forEach(function (ele) {
122
+ if (!selectFiles[ele.name]) {
123
+ selectFiles[ele.name] = ele;
124
+ }
125
+ });
107
126
 
108
- var _useState7 = (0, _react.useState)([]),
109
- _useState8 = _slicedToArray(_useState7, 2),
110
- allFileData = _useState8[0],
111
- setAllFileData = _useState8[1];
127
+ _this.setState({
128
+ selectFiles: selectFiles
129
+ });
112
130
 
113
- var onSubmit = restProps.onSubmit;
114
- (0, _react.useEffect)(function () {
115
- function handleMessage(event) {
116
- var origin = event.origin;
117
- console.log('origin', origin); // 腾讯授权完成通知
131
+ if (filesTotal && allFilesTotal > filesTotal) {
132
+ _toast["default"].Error("\u6700\u591A\u53EF\u4E0A\u4F20 ".concat(filesTotal, " \u4E2A\u6587\u4EF6"), {
133
+ canClose: false
134
+ });
118
135
 
119
- if (event.data.tencentAuthSuccess) {
120
- console.log('授权完成');
136
+ uploadSelectFilesObj = uploadSelectFilesObj.slice(0, filesTotal - uploadSuccessFilesLen);
121
137
  }
122
- }
123
138
 
124
- if (typeof window.addEventListener !== 'undefined') {
125
- window.addEventListener('message', handleMessage, false);
126
- } else if (typeof window.attachEvent !== 'undefined') {
127
- window.attachEvent('onmessage', handleMessage);
128
- }
139
+ if (fileNumLimit && uploadSelectFilesObj.length > fileNumLimit) {
140
+ _toast["default"].Error("\u5355\u6B21\u6700\u591A\u53EF\u4E0A\u4F20 ".concat(fileNumLimit, " \u4E2A\u6587\u4EF6"), {
141
+ canClose: false
142
+ });
129
143
 
130
- return function () {
131
- if (typeof window.removeEventListener !== 'undefined') {
132
- window.removeEventListener('message', handleMessage);
133
- } else if (typeof window.detachEvent !== 'undefined') {
134
- window.detachEvent('onmessage', handleMessage);
144
+ uploadSelectFilesObj = uploadSelectFilesObj.slice(0, fileNumLimit);
135
145
  }
146
+
147
+ if (!uploadSelectFilesObj.length) return;
148
+ var uploadSelectFilesSize = uploadSelectFilesObj.map(function (item) {
149
+ return item.size;
150
+ }).reduce(function (total, num) {
151
+ return total + num;
152
+ }); // 上传文件的大小
153
+
154
+ if (uploadSelectFilesSize > fileNumLimit * fileSizeLimit * 1024 * 1024) return _toast["default"].Error("\u5355\u6B21\u6700\u591A\u53EF\u4E0A\u4F20 ".concat(fileNumLimit, " \u4E2A\u6587\u4EF6\uFF0C\u6BCF\u4E2A\u4E0D\u8D85\u8FC7 ").concat(fileSizeLimit, "M")); // 文件大小超出限制
155
+
156
+ var uploadStartFiles = []; // 开始上传的文件
157
+
158
+ uploadSelectFilesObj.forEach(function (element, index) {
159
+ var formData = new FormData(); // FormData 对象
160
+
161
+ var uploadStartFile = null;
162
+ var timestamp = new Date().getTime(); // 给每个文件加一个时间戳
163
+
164
+ var uploadFileType = element.name.substring(element.name.lastIndexOf('.') + 1);
165
+ uploadStartFile = {
166
+ FileName: element.name,
167
+ FileType: (0, _type._dealAttachmentType)(uploadFileType).FileType,
168
+ FileSize: element.size,
169
+ FileLastModified: element.lastModified,
170
+ IsImage: (0, _type._dealAttachmentType)(uploadFileType).IsImage,
171
+ percentComplete: 0,
172
+ uploadStatus: 1,
173
+ // 开始上传
174
+ IsSuccess: false,
175
+ uid: (0, _uuid["default"])(),
176
+ _smallImageUrl: '',
177
+ _bigImageUrl: '',
178
+ MediaType: '',
179
+ UserId: 0,
180
+ MaxDocCount: 0,
181
+ DfsPath: '',
182
+ ClientUrl: '',
183
+ SmallImageUrl: '',
184
+ BigImageUrl: '',
185
+ DownloadUrl: '',
186
+ Msg: '',
187
+ AllowUploadAttachmentSize: 50,
188
+ Deleteable: true,
189
+ requestXHR: new XMLHttpRequest() // 在这创建是为了取消用
190
+
191
+ };
192
+ var sameFile = uploadSuccessFiles.find(function (file) {
193
+ return _this.isSameFile(file, uploadStartFile) && file.uploadStatus !== 4;
194
+ });
195
+
196
+ if (sameFile) {
197
+ return;
198
+ }
199
+
200
+ uploadStartFiles.push(uploadStartFile);
201
+
202
+ _this._dealUploadStart(uploadStartFiles); // 处理开始上传的文件
203
+
204
+
205
+ formData.append('file', element);
206
+ var url = action || (0, _requestV.getApiUrl)("Upload/PostFiles?format=json&timestamp=".concat(timestamp));
207
+
208
+ _this._dealUploadXHRRequest(formData, url, uploadStartFile);
209
+ });
136
210
  };
137
- }, []);
138
-
139
- var _useState9 = (0, _react.useState)(false),
140
- _useState10 = _slicedToArray(_useState9, 2),
141
- dialogUploadTypeVidible = _useState10[0],
142
- setDialogUploadTypeVidible = _useState10[1];
143
-
144
- var onShowDialogUploadType = (0, _react.useCallback)(function () {
145
- setDialogUploadTypeVidible(true);
146
- }, []);
147
- var onHideDialogUploadType = (0, _react.useCallback)(function () {
148
- setDialogUploadTypeVidible(false);
149
- }, []);
150
-
151
- var _useState11 = (0, _react.useState)(false),
152
- _useState12 = _slicedToArray(_useState11, 2),
153
- dialogQQDocsVidible = _useState12[0],
154
- setDialogQQDocsVidible = _useState12[1];
155
-
156
- var onShowDialogQQDocs = (0, _react.useCallback)( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
157
- var data;
158
- return _regeneratorRuntime().wrap(function _callee$(_context) {
159
- while (1) {
160
- switch (_context.prev = _context.next) {
161
- case 0:
162
- _context.next = 2;
163
- return (0, _utils.checkTencentAuth)({});
164
-
165
- case 2:
166
- data = _context.sent;
167
-
168
- if (data) {
169
- _context.next = 5;
170
- break;
211
+
212
+ _this._dealUploadXHRRequest = function (formData, url, uploadStartFile) {
213
+ if (uploadStartFile.FileSize > _this.props.fileSizeLimit * 1024 * 1024) {
214
+ setTimeout(function () {
215
+ _this._dealUploadSuccess(_objectSpread(_objectSpread({}, uploadStartFile), {
216
+ Msg: '上传失败,文件过大',
217
+ IsImage: false,
218
+ uploadStatus: 5
219
+ }));
220
+ }, 300);
221
+ return;
222
+ }
223
+
224
+ var xhr = uploadStartFile.requestXHR; // xhr.onreadystatechange = () => {
225
+ // if (xhr.readyState == 4 && xhr.status == 200) {
226
+ // const result = { ...JSON.parse(xhr.responseText).Result[0] }; // 上传成功接口返回数据
227
+ // result.percentComplete = 100;
228
+ // result.IsSuccess = !!result.IsSuccess;
229
+ // result.uploadStatus = result.IsSuccess ? 3 : 4; // 3上传成功;4上传失败
230
+ // this._dealUploadSuccess({ ...uploadStartFile, ...result });
231
+ // }
232
+ // };
233
+ // // 进度条部分
234
+ // xhr.upload.onprogress = (evt) => {
235
+ // const uploadSuccessFiles = [...this.state.uploadSuccessFiles];
236
+ // if (evt.lengthComputable) {
237
+ // uploadSuccessFiles.forEach((item: UploadResultObj) => {
238
+ // if (this.isSameFile(item, uploadStartFile)) {
239
+ // item.uploadStatus = 2; // 上传中
240
+ // item.percentComplete = Math.round((evt.loaded * 100) / evt.total);
241
+ // }
242
+ // });
243
+ // this.setState({ uploadSuccessFiles });
244
+ // }
245
+ // };
246
+
247
+ xhr.onreadystatechange = function () {
248
+ if (xhr.readyState == 4 && xhr.status == 200) {
249
+ var result = Object.assign({}, _objectSpread({}, JSON.parse(xhr.responseText).Result[0])); // 上传成功接口返回数据
250
+
251
+ result.percentComplete = 100;
252
+ result.IsSuccess = !!result.IsSuccess;
253
+ result.uploadStatus = result.IsSuccess ? 3 : 4; // 3上传成功;4上传失败
254
+
255
+ _this._dealUploadSuccess(_objectSpread(_objectSpread({}, uploadStartFile), result));
256
+ }
257
+ }; //进度条部分
258
+
259
+
260
+ xhr.upload.onprogress = function (evt) {
261
+ var uploadSuccessFiles = JSON.parse(JSON.stringify(_this.state.uploadSuccessFiles));
262
+
263
+ if (evt.lengthComputable) {
264
+ uploadSuccessFiles.forEach(function (item) {
265
+ if (_this.isSameFile(item, uploadStartFile)) {
266
+ item.uploadStatus = 2; // 上传中
267
+
268
+ item.percentComplete = Math.round(evt.loaded * 100 / evt.total);
171
269
  }
270
+ });
271
+
272
+ _this.setState({
273
+ uploadSuccessFiles: uploadSuccessFiles
274
+ });
275
+ }
276
+ };
277
+
278
+ xhr.upload.onerror = function (evt) {
279
+ var uploadSuccessFiles = _toConsumableArray(_this.state.uploadSuccessFiles);
280
+
281
+ uploadSuccessFiles.forEach(function (item) {
282
+ if (_this.isSameFile(item, uploadStartFile)) {
283
+ item.uploadStatus = 4; // 上传失败
284
+
285
+ item.percentComplete = Math.round(evt.loaded * 100 / evt.total);
286
+ item.Msg = '网络异常,请重新上传';
287
+ }
288
+ });
289
+
290
+ _this.setState({
291
+ uploadSuccessFiles: uploadSuccessFiles
292
+ });
293
+ };
294
+
295
+ xhr.open('POST', url, true);
296
+ xhr.send(formData); // 开始上传,发送form数据
297
+ };
172
298
 
173
- return _context.abrupt("return");
299
+ _this._dealUploadStart = function (uploadStartFiles) {
300
+ var uploadSuccessFiles = [];
174
301
 
175
- case 5:
176
- // 设置默认的文档数据,避免在弹窗内部再查询一次
177
- setDefaultQQDocsData(data);
178
- setDialogUploadTypeVidible(false);
179
- setDialogQQDocsVidible(true);
302
+ var uploadedFiles = _toConsumableArray(_this.state.uploadSuccessFiles); // 处理重传文件,直接展开会导致同样的文件展示两个
180
303
 
181
- case 8:
182
- case "end":
183
- return _context.stop();
304
+
305
+ var uploadFilesConcatArr = uploadedFiles;
306
+ var isReloadFile = uploadFilesConcatArr.filter(function (item) {
307
+ return _this.isSameFile(item, uploadStartFiles[0]);
308
+ });
309
+
310
+ if (!isReloadFile || isReloadFile.length === 0) {
311
+ uploadFilesConcatArr = [].concat(_toConsumableArray(uploadedFiles), _toConsumableArray(uploadStartFiles));
312
+ }
313
+
314
+ uploadFilesConcatArr.forEach(function (item) {
315
+ var res = uploadSuccessFiles.filter(function (v) {
316
+ return _this.isSameFile(item, v);
317
+ });
318
+ uploadSuccessFiles.forEach(function (element) {
319
+ if (_this.isSameFile(item, element)) {
320
+ element = item;
321
+ }
322
+ });
323
+
324
+ if (res.length === 0) {
325
+ uploadSuccessFiles.push(item);
184
326
  }
327
+ });
328
+
329
+ _this.setState({
330
+ uploadSuccessFiles: uploadSuccessFiles
331
+ });
332
+ };
333
+
334
+ _this._dealUploadSuccess = function (uploadSuccessFile) {
335
+ var onSubmit = _this.props.onSubmit;
336
+
337
+ var uploadSuccessFiles = _toConsumableArray(_this.state.uploadSuccessFiles);
338
+
339
+ var uploadSuccessFilesFormat = uploadSuccessFiles.map(function (element) {
340
+ return _this.isSameFile(uploadSuccessFile, element) ? uploadSuccessFile : element;
341
+ });
342
+ var uploadSuccessFilesPath = uploadSuccessFilesFormat.map(function (item) {
343
+ return item.DfsPath;
344
+ }); // 获取文件上传后返回的路径
345
+
346
+ onSubmit(uploadSuccessFilesPath); // 将上传完成的文件路径传递给父组件
347
+
348
+ _this.setState({
349
+ uploadSuccessFiles: uploadSuccessFilesFormat,
350
+ attachmentPreviewUrl: (0, _util.getPreviewImgs)(uploadSuccessFilesFormat)
351
+ });
352
+ };
353
+
354
+ _this.isImg = function (fileType) {
355
+ if (/^(jpg|png|gif|jpeg|image|JPG|PNG|GIF|JPEG)$/.test(fileType)) {
356
+ return true;
185
357
  }
186
- }, _callee);
187
- })), []);
188
- var onHideDialogQQDocs = (0, _react.useCallback)(function () {
189
- setDialogQQDocsVidible(false);
190
- }, []);
191
-
192
- if (onlyLocal) {
193
- return /*#__PURE__*/_react["default"].createElement(_upload["default"], restProps, children);
194
- }
195
358
 
196
- (0, _react.useEffect)(function () {
197
- var filePaths = allFileData.map(function (_ref3) {
198
- var type = _ref3.type,
199
- fileData = _ref3.fileData;
200
-
201
- if (type === 'qq') {
202
- // 需要返回 url|type|title|tencentdoc 格式的字符串数组
203
- var url = fileData.url,
204
- _type = fileData.type,
205
- title = fileData.title;
206
- return "".concat(url, "|").concat(_type, "|").concat(title, "|tencentdoc");
359
+ return false;
360
+ };
361
+
362
+ _this.getImgIndex = function (index) {
363
+ var newIndex = 0;
364
+ var uploadSuccessFiles = _this.state.uploadSuccessFiles;
365
+
366
+ for (var i = 0; i < index; i++) {
367
+ if (_this.isImg(uploadSuccessFiles[i].FileType)) {
368
+ newIndex++;
369
+ }
207
370
  }
208
371
 
209
- if (type === 'local') {
210
- return fileData.DfsPath;
372
+ return newIndex;
373
+ };
374
+
375
+ _this.handlerUploadPreviewOptions = function (index, options) {
376
+ var _this$props2 = _this.props,
377
+ onSubmit = _this$props2.onSubmit,
378
+ onDelete = _this$props2.onDelete;
379
+
380
+ if (options === 'cancel') {
381
+ var reUploadFileInfo = _this.state.uploadSuccessFiles[index];
382
+ reUploadFileInfo.requestXHR.abort();
211
383
  }
212
384
 
213
- return '';
214
- });
215
- if (onSubmit) onSubmit(filePaths);
216
- }, [allFileData]);
217
- (0, _react.useEffect)(function () {
218
- console.log('allFileData', _toConsumableArray(allFileData));
219
- console.log('localFileData', _toConsumableArray(localFileData)); // upload 组件返回的是选择的所有文件对象,需要对其进行重新排序
220
-
221
- var localFileListKeys = allFileData.filter(function (_ref4) {
222
- var type = _ref4.type;
223
- return type === 'local';
224
- }).map(function (_ref5) {
225
- var key = _ref5.key;
226
- return key;
227
- }); // 递归查找第一个不存在的 key
228
-
229
- var sliceStartIndex = localFileData.findIndex(function (item) {
230
- return !localFileListKeys.includes(item.uid);
231
- }); // 然后从该位置开始截取并追加到 allFileData
232
-
233
- var newLocalFile = sliceStartIndex === -1 ? [] : localFileData.slice(sliceStartIndex);
234
- console.log('sliceStartIndex', sliceStartIndex);
235
- console.log('newLocalFile', newLocalFile); // 追加
236
- // 由于 upload 内部使用了 setTimeout,导致 onLocalUploadSuccessHandler 没有被更新,allFileData 取到的是旧的
237
-
238
- setAllFileData([].concat(_toConsumableArray(allFileData), _toConsumableArray(newLocalFile.map(function (item) {
239
- return {
240
- key: item.uid,
241
- type: 'local',
242
- fileData: item
243
- };
244
- }))));
245
- }, [localFileData]);
246
- var onSelectQQDocsFileHandler = (0, _react.useCallback)(function (checkedDocsList) {
247
- setQQFileData([].concat(_toConsumableArray(qqFileData), _toConsumableArray(checkedDocsList))); // qq 文档只会返回每次新增的文档数组,所以直接在后面追加即可
248
-
249
- setAllFileData([].concat(_toConsumableArray(allFileData), _toConsumableArray(checkedDocsList.map(function (item) {
250
- return {
251
- key: item.id,
252
- type: 'qq',
253
- fileData: item
254
- };
255
- }))));
256
- onHideDialogQQDocs();
257
- }, [qqFileData, allFileData]);
258
- var onLocalUploadSuccessHandler = (0, _react.useCallback)(function (localFileList) {
259
- setLocalFileData(localFileList);
260
- }, []);
261
- var onClickFileHandler = (0, _react.useCallback)(function (index, options) {
262
- var currentFile = allFileData[index];
263
-
264
- if (options === 'delete' || options === 'cancel') {
265
- if (currentFile.type === 'qq') {
266
- var removeIndex = qqFileData.findIndex(function (item) {
267
- return item.id === currentFile.key;
385
+ if (options === 'delete' || options === 'cancel') {
386
+ var uploadResultFiles = _toConsumableArray(_this.state.uploadSuccessFiles);
387
+
388
+ var deleteFiles = uploadResultFiles[index];
389
+ onDelete && onDelete(deleteFiles.documentId ? deleteFiles.documentId : deleteFiles.DfsPath);
390
+ uploadResultFiles.splice(index, 1);
391
+
392
+ var _uploadSuccessFilesPath = uploadResultFiles.map(function (item) {
393
+ return item.DfsPath;
268
394
  });
269
- qqFileData.splice(removeIndex, 1);
270
- setQQFileData(_toConsumableArray(qqFileData));
271
- } else {
272
- var _removeIndex = localFileData.findIndex(function (item) {
273
- return item.uid === currentFile.key;
395
+
396
+ onSubmit(_uploadSuccessFilesPath, options);
397
+
398
+ _this.setState({
399
+ uploadSuccessFiles: uploadResultFiles
274
400
  });
401
+ } else if (options === 'preview') {
402
+ var imgIndex = _this.getImgIndex(index);
275
403
 
276
- localFileData.splice(_removeIndex, 1);
277
- setLocalFileData(_toConsumableArray(localFileData));
404
+ _this.refs.imgViewerRef.show(imgIndex);
405
+ } else if (options === 'reupload') {
406
+ var _reUploadFileInfo = _this.state.uploadSuccessFiles[index];
407
+ var reUploadFile = _this.state.selectFiles[_reUploadFileInfo.FileName];
408
+
409
+ _this.dealSelectFiles([reUploadFile]);
278
410
  }
411
+ };
279
412
 
280
- allFileData.splice(index, 1);
281
- setAllFileData(_toConsumableArray(allFileData));
282
- } else if (options === 'preview') {
283
- if (currentFile.type === 'qq') {
284
- var file = qqFileData[index];
285
- (0, _tools.openUrl)(file.url);
413
+ _this.isSameFile = function (item, element) {
414
+ return item.FileName === element.FileName && item.FileSize === element.FileSize && item.FileLastModified === element.FileLastModified;
415
+ };
416
+
417
+ _this.renderUploadList = function (list) {
418
+ var attachmentPreviewBox = _this.props.attachmentPreviewBox;
419
+ var attachmentPreviewUrl = _this.state.attachmentPreviewUrl;
420
+ if (!list.length) return;
421
+ return /*#__PURE__*/_react["default"].createElement(_Portals["default"], {
422
+ domNode: attachmentPreviewBox,
423
+ className: "uploadFile__preview__list"
424
+ }, /*#__PURE__*/_react["default"].createElement(_imgViewer["default"], {
425
+ data: attachmentPreviewUrl,
426
+ ref: "imgViewerRef",
427
+ showDownload: false
428
+ }), list.map(function (item, index) {
429
+ return /*#__PURE__*/_react["default"].createElement(_uploadedPreview["default"], {
430
+ uploadResultItem: item,
431
+ index: index,
432
+ key: item.uid,
433
+ className: "uploaded__preview",
434
+ onSubmit: function onSubmit(index, options) {
435
+ _this.handlerUploadPreviewOptions(index, options);
436
+ }
437
+ });
438
+ }));
439
+ };
440
+
441
+ _this.handleButtonClick = function (e) {
442
+ e.nativeEvent.stopImmediatePropagation();
443
+
444
+ if (_this.refs.fileInput) {
445
+ // @ts-ignore
446
+ _this.refs.fileInput.click();
286
447
  }
287
- }
288
- }, [allFileData, qqFileData, localFileData]);
289
-
290
- function renderUploadList(list) {
291
- var attachmentPreviewBox = restProps.attachmentPreviewBox;
292
- if (!list.length) return '';
293
- return /*#__PURE__*/_react["default"].createElement(_Portals["default"], {
294
- domNode: attachmentPreviewBox,
295
- className: "uploadFile__preview__list"
296
- }, list.map(function (item, index) {
297
- return /*#__PURE__*/_react["default"].createElement(_uploadedPreview["default"], {
298
- uploadResultItem: item.type === 'qq' ? {
299
- FileName: item.fileData.title,
300
- FileType: item.fileData.type,
301
- ClientUrl: item.fileData.url,
302
- uid: item.fileData.id,
303
- uploadStatus: 3,
304
- Deleteable: true,
305
- SmallImageUrl: item.fileData.url
306
- } : item.fileData,
307
- index: index,
308
- key: item.key,
309
- className: "uploaded__preview",
310
- onSubmit: onClickFileHandler
311
- });
312
- }));
448
+ };
449
+
450
+ _this.state = {
451
+ uploadSuccessFiles: props.attachments || [],
452
+ attachmentPreviewUrl: props.attachments ? (0, _util.getPreviewImgs)(props.attachments) : [],
453
+ selectFiles: {}
454
+ };
455
+ return _this;
313
456
  }
314
457
 
315
- var uploadProps = (0, _react.useMemo)(function () {
316
- return _objectSpread(_objectSpread({}, restProps), {}, {
317
- filesTotal: undefined,
318
- // 禁止
319
- onSubmit: onDefaultSubmit,
320
- onUploadSuccess: onLocalUploadSuccessHandler
321
- });
322
- }, [restProps, onLocalUploadSuccessHandler]);
323
- return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_dialogUploadType["default"], {
324
- uploadProps: uploadProps,
325
- onSelectQQDocs: onShowDialogQQDocs,
326
- visible: dialogUploadTypeVidible,
327
- onClose: onHideDialogUploadType
328
- }), /*#__PURE__*/_react["default"].createElement(_dialogQqDocs["default"], {
329
- fileNumLimit: uploadProps.fileNumLimit,
330
- defaultQQDocsData: defaultQQDocsData,
331
- visible: dialogQQDocsVidible,
332
- onClose: onHideDialogQQDocs,
333
- onSubmit: onSelectQQDocsFileHandler
334
- }), /*#__PURE__*/_react["default"].createElement(_titaUi.Tooltip, {
335
- container: document.body,
336
- content: /*#__PURE__*/_react["default"].createElement("p", {
337
- dangerouslySetInnerHTML: {
338
- __html: attachmentTipText
458
+ _createClass(Upload, [{
459
+ key: "componentDidMount",
460
+ value: function componentDidMount() {
461
+ var attachments = this.props.attachments;
462
+ this.setState({
463
+ uploadSuccessFiles: attachments || [],
464
+ attachmentPreviewUrl: attachments ? (0, _util.getPreviewImgs)(attachments) : []
465
+ });
466
+ }
467
+ }, {
468
+ key: "componentWillReceiveProps",
469
+ value: function componentWillReceiveProps(nextProps) {
470
+ if (this.props.submitStatus === 2 && nextProps.submitStatus == 1) {
471
+ this.setState({
472
+ uploadSuccessFiles: [],
473
+ attachmentPreviewUrl: []
474
+ });
475
+ } else {
476
+ this.setState({
477
+ // uploadSuccessFiles: nextProps.attachments || [],
478
+ attachmentPreviewUrl: nextProps.attachments ? (0, _util.getPreviewImgs)(nextProps.attachments) : []
479
+ });
480
+ }
481
+
482
+ if (nextProps.dragFilesList && nextProps.dragFilesList.length) {
483
+ this.dealSelectFiles(nextProps.dragFilesList);
339
484
  }
340
- })
341
- }, /*#__PURE__*/_react["default"].createElement("div", {
342
- onClick: onShowDialogUploadType
343
- }, children)), renderUploadList(allFileData));
485
+ }
486
+ }, {
487
+ key: "render",
488
+ value: function render() {
489
+ var _this2 = this;
490
+
491
+ var _this$props3 = this.props,
492
+ children = _this$props3.children,
493
+ className = _this$props3.className,
494
+ style = _this$props3.style,
495
+ _this$props3$attachme = _this$props3.attachmentTipText,
496
+ attachmentTipText = _this$props3$attachme === void 0 ? (0, _getLocale.getLocale)('OKR_MyO_KRP_Draganddropu') : _this$props3$attachme;
497
+ var uploadSuccessFiles = this.state.uploadSuccessFiles;
498
+ return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_titaUi.Tooltip, {
499
+ container: document.body,
500
+ content: /*#__PURE__*/_react["default"].createElement("p", {
501
+ dangerouslySetInnerHTML: {
502
+ __html: attachmentTipText
503
+ }
504
+ })
505
+ }, /*#__PURE__*/_react["default"].createElement(_style.UploadFormContainer, {
506
+ className: className,
507
+ style: style,
508
+ onMouseUp: function onMouseUp(e) {
509
+ return _this2.handleButtonClick(e);
510
+ }
511
+ }, /*#__PURE__*/_react["default"].createElement("div", {
512
+ ref: "uploader-trigger",
513
+ style: {
514
+ cursor: 'pointer'
515
+ }
516
+ }, children), /*#__PURE__*/_react["default"].createElement("input", {
517
+ type: "file",
518
+ ref: "fileInput",
519
+ className: "upload_file_input",
520
+ multiple: this.props.multiple,
521
+ style: {
522
+ display: 'none'
523
+ },
524
+ onChange: this.onFileInputChange
525
+ }))), this.renderUploadList(uploadSuccessFiles));
526
+ }
527
+ }]);
528
+
529
+ return Upload;
530
+ }(_react.PureComponent);
531
+
532
+ Upload.Preview = _uploadedPreview["default"];
533
+ Upload.defaultProps = {
534
+ fileNumLimit: 20,
535
+ fileSizeLimit: 50,
536
+ filesTotal: 50,
537
+ multiple: true,
538
+ attachmentPreviewBox: 'MBlog__attachmentViewBox'
344
539
  };
345
-
346
- var _default = UploadMode;
540
+ var _default = Upload;
347
541
  exports["default"] = _default;